idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
16,100 | public final void parse ( final SQLStatement sqlStatement , final boolean isSingleTableOnly ) { do { parseTableReference ( sqlStatement , isSingleTableOnly ) ; } while ( lexerEngine . skipIfEqual ( Symbol . COMMA ) ) ; } | Parse table references . |
16,101 | public final void parseSingleTableWithoutAlias ( final SQLStatement sqlStatement ) { int beginPosition = lexerEngine . getCurrentToken ( ) . getEndPosition ( ) - lexerEngine . getCurrentToken ( ) . getLiterals ( ) . length ( ) ; String literals = lexerEngine . getCurrentToken ( ) . getLiterals ( ) ; int skippedSchemaNa... | Parse single table without alias . |
16,102 | public static ExecutorService getExecutor ( final boolean isOccupyThreadForPerConnection , final TransactionType transactionType , final ChannelId channelId ) { return ( isOccupyThreadForPerConnection || TransactionType . XA == transactionType || TransactionType . BASE == transactionType ) ? ChannelThreadExecutorGroup ... | Get executor service . |
16,103 | public void appendPlaceholder ( final ShardingPlaceholder shardingPlaceholder ) { segments . add ( shardingPlaceholder ) ; currentSegment = new StringBuilder ( ) ; segments . add ( currentSegment ) ; } | Append sharding placeholder . |
16,104 | public SQLBuilder rewrite ( final boolean isSingleRouting ) { SQLBuilder result = new SQLBuilder ( parameters ) ; if ( sqlTokens . isEmpty ( ) ) { return appendOriginalLiterals ( result ) ; } appendInitialLiterals ( ! isSingleRouting , result ) ; appendTokensAndPlaceholders ( ! isSingleRouting , result ) ; reviseParame... | rewrite SQL . |
16,105 | public SQLUnit generateSQL ( final TableUnit tableUnit , final SQLBuilder sqlBuilder , final ShardingDataSourceMetaData shardingDataSourceMetaData ) { return sqlBuilder . toSQL ( tableUnit , getTableTokens ( tableUnit ) , shardingRule , shardingDataSourceMetaData ) ; } | Generate SQL string . |
16,106 | public static AbstractInsertParser newInstance ( final DatabaseType dbType , final ShardingRule shardingRule , final LexerEngine lexerEngine , final ShardingTableMetaData shardingTableMetaData ) { switch ( dbType ) { case H2 : case MySQL : return new MySQLInsertParser ( shardingRule , lexerEngine , shardingTableMetaDat... | Create insert parser instance . |
16,107 | public static Properties unmarshalProperties ( final String yamlContent ) { return Strings . isNullOrEmpty ( yamlContent ) ? new Properties ( ) : new Yaml ( ) . loadAs ( yamlContent , Properties . class ) ; } | Unmarshal properties YAML . |
16,108 | public Collection < String > getAllInstanceDataSourceNames ( ) { Collection < String > result = new LinkedList < > ( ) ; for ( Entry < String , DataSourceMetaData > entry : dataSourceMetaDataMap . entrySet ( ) ) { if ( ! isExisted ( entry . getKey ( ) , result ) ) { result . add ( entry . getKey ( ) ) ; } } return resu... | Get all instance data source names . |
16,109 | public void parse ( final SelectStatement selectStatement ) { if ( ! lexerEngine . skipIfEqual ( SQLServerKeyword . OFFSET ) ) { return ; } int offsetValue = - 1 ; int offsetIndex = - 1 ; if ( lexerEngine . equalAny ( Literals . INT ) ) { offsetValue = Integer . parseInt ( lexerEngine . getCurrentToken ( ) . getLiteral... | Parse offset . |
16,110 | public Map < String , List < DataNode > > getDataNodeGroups ( ) { Map < String , List < DataNode > > result = new LinkedHashMap < > ( actualDataNodes . size ( ) , 1 ) ; for ( DataNode each : actualDataNodes ) { String dataSourceName = each . getDataSourceName ( ) ; if ( ! result . containsKey ( dataSourceName ) ) { res... | Get data node groups . |
16,111 | public Collection < String > getActualDatasourceNames ( ) { Collection < String > result = new LinkedHashSet < > ( actualDataNodes . size ( ) ) ; for ( DataNode each : actualDataNodes ) { result . add ( each . getDataSourceName ( ) ) ; } return result ; } | Get actual data source names . |
16,112 | public Collection < String > getActualTableNames ( final String targetDataSource ) { Collection < String > result = new LinkedHashSet < > ( actualDataNodes . size ( ) ) ; for ( DataNode each : actualDataNodes ) { if ( targetDataSource . equals ( each . getDataSourceName ( ) ) ) { result . add ( each . getTableName ( ) ... | Get actual table names via target data source name . |
16,113 | public Optional < String > parseSelectItemAlias ( ) { if ( lexerEngine . skipIfEqual ( DefaultKeyword . AS ) ) { return parseWithAs ( null , false , null ) ; } if ( lexerEngine . equalAny ( getDefaultAvailableKeywordsForSelectItemAlias ( ) ) || lexerEngine . equalAny ( getCustomizedAvailableKeywordsForSelectItemAlias (... | Parse alias for select item . |
16,114 | public Optional < String > parseTableAlias ( final SQLStatement sqlStatement , final boolean setTableToken , final String tableName ) { if ( lexerEngine . skipIfEqual ( DefaultKeyword . AS ) ) { return parseWithAs ( sqlStatement , setTableToken , tableName ) ; } if ( lexerEngine . equalAny ( getDefaultAvailableKeywords... | Parse alias for table . |
16,115 | public final synchronized void renew ( final DataSourceChangedEvent dataSourceChangedEvent ) { dataSource . close ( ) ; dataSource = new ShardingDataSource ( DataSourceConverter . getDataSourceMap ( dataSourceChangedEvent . getDataSourceConfigurations ( ) ) , dataSource . getShardingContext ( ) . getShardingRule ( ) , ... | Renew sharding data source . |
16,116 | public void processParameters ( final List < Object > parameters , final boolean isFetchAll , final DatabaseType databaseType ) { fill ( parameters ) ; rewrite ( parameters , isFetchAll , databaseType ) ; } | Fill parameters for rewrite limit . |
16,117 | public boolean isNeedRewriteRowCount ( final DatabaseType databaseType ) { return DatabaseType . MySQL == databaseType || DatabaseType . PostgreSQL == databaseType || DatabaseType . H2 == databaseType ; } | Judge is need rewrite row count or not . |
16,118 | public static XAConnection createXAConnection ( final DatabaseType databaseType , final XADataSource xaDataSource , final Connection connection ) { switch ( databaseType ) { case MySQL : return new MySQLXAConnectionWrapper ( ) . wrap ( xaDataSource , connection ) ; case PostgreSQL : return new PostgreSQLXAConnectionWra... | Create XA connection from normal connection . |
16,119 | public void add ( final OrchestrationShardingSchema orchestrationShardingSchema ) { String schemaName = orchestrationShardingSchema . getSchemaName ( ) ; if ( ! schemaGroup . containsKey ( schemaName ) ) { schemaGroup . put ( schemaName , new LinkedList < String > ( ) ) ; } schemaGroup . get ( schemaName ) . add ( orch... | Add orchestration sharding schema . |
16,120 | public void put ( final String shardingSchemaName , final Collection < String > dataSourceNames ) { schemaGroup . put ( shardingSchemaName , dataSourceNames ) ; } | Put orchestration sharding schema . |
16,121 | public Collection < String > getDataSourceNames ( final String shardingSchemaName ) { return schemaGroup . containsKey ( shardingSchemaName ) ? schemaGroup . get ( shardingSchemaName ) : Collections . < String > emptyList ( ) ; } | Get data source names . |
16,122 | public OrCondition buildCondition ( final OrPredicateSegment sqlSegment , final SQLStatement sqlStatement ) { OrCondition result = createOrCondition ( sqlSegment , sqlStatement ) ; createEncryptOrPredicateFiller ( ) . fill ( sqlSegment , sqlStatement ) ; return result ; } | Build condition . |
16,123 | public static boolean isDCL ( final TokenType primaryTokenType , final TokenType secondaryTokenType ) { return STATEMENT_PREFIX . contains ( primaryTokenType ) || ( PRIMARY_STATEMENT_PREFIX . contains ( primaryTokenType ) && SECONDARY_STATEMENT_PREFIX . contains ( secondaryTokenType ) ) ; } | Is DCL statement . |
16,124 | public void close ( ) { SHUTDOWN_EXECUTOR . execute ( new Runnable ( ) { public void run ( ) { try { executorService . shutdown ( ) ; while ( ! executorService . awaitTermination ( 5 , TimeUnit . SECONDS ) ) { executorService . shutdownNow ( ) ; } } catch ( final InterruptedException ex ) { Thread . currentThread ( ) .... | Close executor service . |
16,125 | public SQLStatement fill ( final Collection < SQLSegment > sqlSegments , final SQLStatementRule rule ) { SQLStatement result = rule . getSqlStatementClass ( ) . newInstance ( ) ; result . setLogicSQL ( sql ) ; for ( SQLSegment each : sqlSegments ) { Optional < SQLSegmentFiller > filler = parsingRuleRegistry . findSQLSe... | Fill SQL statement . |
16,126 | public final List < Connection > getConnections ( final ConnectionMode connectionMode , final String dataSourceName , final int connectionSize ) throws SQLException { DataSource dataSource = getDataSourceMap ( ) . get ( dataSourceName ) ; Preconditions . checkState ( null != dataSource , "Missing the data source name: ... | Get database connections . |
16,127 | public final void parse ( final SelectStatement selectStatement ) { if ( ! lexerEngine . skipIfEqual ( DefaultKeyword . ORDER ) ) { return ; } List < OrderItem > result = new LinkedList < > ( ) ; lexerEngine . skipIfEqual ( OracleKeyword . SIBLINGS ) ; lexerEngine . accept ( DefaultKeyword . BY ) ; do { Optional < Orde... | Parse order by . |
16,128 | public boolean isAlwaysFalse ( ) { if ( shardingConditions . isEmpty ( ) ) { return false ; } for ( ShardingCondition each : shardingConditions ) { if ( ! ( each instanceof AlwaysFalseShardingCondition ) ) { return false ; } } return true ; } | Judge sharding conditions is always false or not . |
16,129 | public static boolean isSymbol ( final char ch ) { return '(' == ch || ')' == ch || '[' == ch || ']' == ch || '{' == ch || '}' == ch || '+' == ch || '-' == ch || '*' == ch || '/' == ch || '%' == ch || '^' == ch || '=' == ch || '>' == ch || '<' == ch || '~' == ch || '!' == ch || '?' == ch || '&' == ch || '|' == ch || '.... | Judge is symbol or not . |
16,130 | @ SuppressWarnings ( "unchecked" ) public < T > T getValue ( final ShardingPropertiesConstant shardingPropertiesConstant ) { if ( cachedProperties . containsKey ( shardingPropertiesConstant ) ) { return ( T ) cachedProperties . get ( shardingPropertiesConstant ) ; } String value = props . getProperty ( shardingProperti... | Get property value . |
16,131 | public void init ( final ExtractorRuleDefinitionEntity ruleDefinitionEntity ) { for ( ExtractorRuleEntity each : ruleDefinitionEntity . getRules ( ) ) { rules . put ( each . getId ( ) , ( SQLSegmentExtractor ) Class . forName ( each . getExtractorClass ( ) ) . newInstance ( ) ) ; } } | Initialize SQL extractor rule definition . |
16,132 | public void clear ( ) throws SQLException { clearStatements ( ) ; statements . clear ( ) ; parameterSets . clear ( ) ; connections . clear ( ) ; resultSets . clear ( ) ; executeGroups . clear ( ) ; } | Clear data . |
16,133 | public List < String > splitAndEvaluate ( ) { if ( null == inlineExpression ) { return Collections . emptyList ( ) ; } return flatten ( evaluate ( split ( ) ) ) ; } | Split and evaluate inline expression . |
16,134 | public static boolean isBooleanValue ( final String value ) { return Boolean . TRUE . toString ( ) . equalsIgnoreCase ( value ) || Boolean . FALSE . toString ( ) . equalsIgnoreCase ( value ) ; } | Judge is boolean value or not . |
16,135 | public static boolean isIntValue ( final String value ) { try { Integer . parseInt ( value ) ; return true ; } catch ( final NumberFormatException ex ) { return false ; } } | Judge is int value or not . |
16,136 | public static boolean isLongValue ( final String value ) { try { Long . parseLong ( value ) ; return true ; } catch ( final NumberFormatException ex ) { return false ; } } | Judge is long value or not . |
16,137 | public static void init ( ) { String tracerClassName = System . getProperty ( OPENTRACING_TRACER_CLASS_NAME ) ; Preconditions . checkNotNull ( tracerClassName , "Can not find opentracing tracer implementation class via system property `%s`" , OPENTRACING_TRACER_CLASS_NAME ) ; try { init ( ( Tracer ) Class . forName ( t... | Initialize sharding tracer . |
16,138 | public SQLAST parse ( ) { ParseTree parseTree = SQLParserFactory . newInstance ( databaseType , sql ) . execute ( ) . getChild ( 0 ) ; if ( parseTree instanceof ErrorNode ) { throw new SQLParsingUnsupportedException ( String . format ( "Unsupported SQL of `%s`" , sql ) ) ; } Optional < SQLStatementRule > sqlStatementRu... | Parse SQL to abstract syntax tree . |
16,139 | public String getInstancesNodeFullPath ( final String instanceId ) { return Joiner . on ( "/" ) . join ( "" , name , ROOT , INSTANCES_NODE_PATH , instanceId ) ; } | Get instance node full path . |
16,140 | public String getDataSourcesNodeFullPath ( final String schemaDataSourceName ) { return Joiner . on ( "/" ) . join ( "" , name , ROOT , DATA_SOURCES_NODE_PATH , schemaDataSourceName ) ; } | Get data source node full path . |
16,141 | public static LexerEngine newInstance ( final DatabaseType dbType , final String sql ) { switch ( dbType ) { case H2 : return new LexerEngine ( new H2Lexer ( sql ) ) ; case MySQL : return new LexerEngine ( new MySQLLexer ( sql ) ) ; case Oracle : return new LexerEngine ( new OracleLexer ( sql ) ) ; case SQLServer : ret... | Create lexical analysis engine instance . |
16,142 | public boolean execute ( final int [ ] columnIndexes ) throws SQLException { return execute ( new Executor ( ) { public boolean execute ( final Statement statement , final String sql ) throws SQLException { return statement . execute ( sql , columnIndexes ) ; } } ) ; } | Execute SQL with column indexes . |
16,143 | public static boolean isTCLUnsafe ( final DatabaseType databaseType , final TokenType tokenType , final LexerEngine lexerEngine ) { if ( DefaultKeyword . SET . equals ( tokenType ) || DatabaseType . SQLServer . equals ( databaseType ) && DefaultKeyword . IF . equals ( tokenType ) ) { lexerEngine . skipUntil ( DefaultKe... | Is TCL statement . |
16,144 | public void addBatchForRouteUnits ( final SQLRouteResult routeResult ) { handleOldRouteUnits ( createBatchRouteUnits ( routeResult . getRouteUnits ( ) ) ) ; handleNewRouteUnits ( createBatchRouteUnits ( routeResult . getRouteUnits ( ) ) ) ; batchCount ++ ; } | Add batch for route units . |
16,145 | public List < Statement > getStatements ( ) { List < Statement > result = new LinkedList < > ( ) ; for ( ShardingExecuteGroup < StatementExecuteUnit > each : getExecuteGroups ( ) ) { result . addAll ( Lists . transform ( each . getInputs ( ) , new Function < StatementExecuteUnit , Statement > ( ) { public Statement app... | Get statements . |
16,146 | public LogicSchema getLogicSchema ( final String schemaName ) { return Strings . isNullOrEmpty ( schemaName ) ? null : logicSchemas . get ( schemaName ) ; } | Get logic schema . |
16,147 | public synchronized void renew ( final SchemaAddedEvent schemaAddedEvent ) { logicSchemas . put ( schemaAddedEvent . getShardingSchemaName ( ) , createLogicSchema ( schemaAddedEvent . getShardingSchemaName ( ) , Collections . singletonMap ( schemaAddedEvent . getShardingSchemaName ( ) , DataSourceConverter . getDataSou... | Renew to add new schema . |
16,148 | public static CommandExecutor newInstance ( final PostgreSQLCommandPacketType commandPacketType , final PostgreSQLCommandPacket commandPacket , final BackendConnection backendConnection ) { log . debug ( "Execute packet type: {}, value: {}" , commandPacketType , commandPacket ) ; switch ( commandPacketType ) { case QUE... | Create new instance of command executor . |
16,149 | public final void nextToken ( ) { skipIgnoredToken ( ) ; if ( isVariableBegin ( ) ) { currentToken = new Tokenizer ( input , dictionary , offset ) . scanVariable ( ) ; } else if ( isNCharBegin ( ) ) { currentToken = new Tokenizer ( input , dictionary , ++ offset ) . scanChars ( ) ; } else if ( isIdentifierBegin ( ) ) {... | Analyse next token . |
16,150 | public final void parse ( ) { Collection < Keyword > unsupportedRestKeywords = new LinkedList < > ( ) ; unsupportedRestKeywords . addAll ( Arrays . asList ( DefaultKeyword . UNION , DefaultKeyword . INTERSECT , DefaultKeyword . EXCEPT , DefaultKeyword . MINUS ) ) ; unsupportedRestKeywords . addAll ( Arrays . asList ( g... | Parse select rest . |
16,151 | public boolean isSingleTable ( ) { Collection < String > tableNames = new TreeSet < > ( String . CASE_INSENSITIVE_ORDER ) ; for ( Table each : tables ) { tableNames . add ( each . getName ( ) ) ; } return 1 == tableNames . size ( ) ; } | Judge is single table or not . |
16,152 | public Collection < String > getTableNames ( ) { Collection < String > result = new LinkedHashSet < > ( tables . size ( ) , 1 ) ; for ( Table each : tables ) { result . add ( each . getName ( ) ) ; } return result ; } | Get table names . |
16,153 | public Optional < Table > find ( final String tableNameOrAlias ) { Optional < Table > tableFromName = findTableFromName ( tableNameOrAlias ) ; return tableFromName . isPresent ( ) ? tableFromName : findTableFromAlias ( tableNameOrAlias ) ; } | Find table via table name or alias . |
16,154 | public String skipParentheses ( final SQLStatement sqlStatement ) { StringBuilder result = new StringBuilder ( "" ) ; int count = 0 ; if ( Symbol . LEFT_PAREN == lexer . getCurrentToken ( ) . getType ( ) ) { final int beginPosition = lexer . getCurrentToken ( ) . getEndPosition ( ) ; result . append ( Symbol . LEFT_PAR... | skip all tokens that inside parentheses . |
16,155 | public void accept ( final TokenType tokenType ) { if ( lexer . getCurrentToken ( ) . getType ( ) != tokenType ) { throw new SQLParsingException ( lexer , tokenType ) ; } lexer . nextToken ( ) ; } | Assert current token type should equals input token and go to next token type . |
16,156 | public boolean equalAny ( final TokenType ... tokenTypes ) { for ( TokenType each : tokenTypes ) { if ( each == lexer . getCurrentToken ( ) . getType ( ) ) { return true ; } } return false ; } | Judge current token equals one of input tokens or not . |
16,157 | public void skipAll ( final TokenType ... tokenTypes ) { Set < TokenType > tokenTypeSet = Sets . newHashSet ( tokenTypes ) ; while ( tokenTypeSet . contains ( lexer . getCurrentToken ( ) . getType ( ) ) ) { lexer . nextToken ( ) ; } } | Skip all input tokens . |
16,158 | public void skipUntil ( final TokenType ... tokenTypes ) { Set < TokenType > tokenTypeSet = Sets . newHashSet ( tokenTypes ) ; tokenTypeSet . add ( Assist . END ) ; while ( ! tokenTypeSet . contains ( lexer . getCurrentToken ( ) . getType ( ) ) ) { lexer . nextToken ( ) ; } } | Skip until one of input tokens . |
16,159 | public void parse ( final SelectStatement selectStatement ) { if ( ! lexerEngine . skipIfEqual ( SQLServerKeyword . TOP ) ) { return ; } int beginPosition = lexerEngine . getCurrentToken ( ) . getEndPosition ( ) ; if ( ! lexerEngine . skipIfEqual ( Symbol . LEFT_PAREN ) ) { beginPosition = lexerEngine . getCurrentToken... | Parse top . |
16,160 | public static MySQLErrPacket newInstance ( final int sequenceId , final Exception cause ) { if ( cause instanceof SQLException ) { SQLException sqlException = ( SQLException ) cause ; return new MySQLErrPacket ( sequenceId , sqlException . getErrorCode ( ) , sqlException . getSQLState ( ) , sqlException . getMessage ( ... | New instance of MytSQL ERR packet . |
16,161 | public static < T > void register ( final Class < T > service ) { for ( T each : ServiceLoader . load ( service ) ) { registerServiceClass ( service , each ) ; } } | Register SPI service into map for new instance . |
16,162 | @ SuppressWarnings ( "unchecked" ) public static < T > Collection < T > newServiceInstances ( final Class < T > service ) { Collection < T > result = new LinkedList < > ( ) ; if ( null == SERVICE_MAP . get ( service ) ) { return result ; } for ( Class < ? > each : SERVICE_MAP . get ( service ) ) { result . add ( ( T ) ... | New service instances . |
16,163 | public static void main ( final String [ ] args ) throws IOException { ShardingConfiguration shardingConfig = new ShardingConfigurationLoader ( ) . load ( ) ; int port = getPort ( args ) ; if ( null == shardingConfig . getServerConfiguration ( ) . getOrchestration ( ) ) { startWithoutRegistryCenter ( shardingConfig . g... | Main entrance . |
16,164 | public Collection < ShardingExecuteGroup < StatementExecuteUnit > > getExecuteUnitGroups ( final Collection < RouteUnit > routeUnits , final SQLExecutePrepareCallback callback ) throws SQLException { return getSynchronizedExecuteUnitGroups ( routeUnits , callback ) ; } | Get execute unit groups . |
16,165 | public List < Comparable < ? > > getConditionValues ( final List < ? > parameters ) { List < Comparable < ? > > result = new LinkedList < > ( positionValueMap . values ( ) ) ; for ( Entry < Integer , Integer > entry : positionIndexMap . entrySet ( ) ) { Object parameter = parameters . get ( entry . getValue ( ) ) ; if ... | Get condition values . |
16,166 | public static DataSourceConfiguration getDataSourceConfiguration ( final DataSource dataSource ) { DataSourceConfiguration result = new DataSourceConfiguration ( dataSource . getClass ( ) . getName ( ) ) ; result . getProperties ( ) . putAll ( findAllGetterProperties ( dataSource ) ) ; return result ; } | Get data source configuration . |
16,167 | public DataSource createDataSource ( ) { DataSource result = ( DataSource ) Class . forName ( dataSourceClassName ) . newInstance ( ) ; Method [ ] methods = result . getClass ( ) . getMethods ( ) ; for ( Entry < String , Object > entry : properties . entrySet ( ) ) { if ( SKIPPED_PROPERTY_NAMES . contains ( entry . get... | Create data source . |
16,168 | public void setStatus ( final ConnectionStatus update ) { status . getAndSet ( update ) ; if ( ConnectionStatus . TERMINATED == status . get ( ) ) { resourceSynchronizer . doNotify ( ) ; } } | Change connection status using get and set . |
16,169 | public void setRunningStatusIfNecessary ( ) { if ( ConnectionStatus . TRANSACTION != status . get ( ) && ConnectionStatus . RUNNING != status . get ( ) ) { status . getAndSet ( ConnectionStatus . RUNNING ) ; } } | Change connection status to running if necessary . |
16,170 | void doNotifyIfNecessary ( ) { if ( status . compareAndSet ( ConnectionStatus . RUNNING , ConnectionStatus . RELEASE ) || status . compareAndSet ( ConnectionStatus . TERMINATED , ConnectionStatus . RELEASE ) ) { resourceSynchronizer . doNotify ( ) ; } } | Notify connection to finish wait if necessary . |
16,171 | public void waitUntilConnectionReleasedIfNecessary ( ) throws InterruptedException { if ( ConnectionStatus . RUNNING == status . get ( ) || ConnectionStatus . TERMINATED == status . get ( ) ) { while ( ! status . compareAndSet ( ConnectionStatus . RELEASE , ConnectionStatus . RUNNING ) ) { resourceSynchronizer . doAwai... | Wait until connection is released if necessary . |
16,172 | public OrderItem createOrderItem ( ) { if ( orderByItemSegment instanceof IndexOrderByItemSegment ) { return createOrderItem ( ( IndexOrderByItemSegment ) orderByItemSegment ) ; } if ( orderByItemSegment instanceof ColumnOrderByItemSegment ) { return createOrderItem ( selectStatement , ( ColumnOrderByItemSegment ) orde... | Create order item . |
16,173 | public void initListeners ( ) { instanceStateChangedListener . watch ( ChangedType . UPDATED ) ; dataSourceStateChangedListener . watch ( ChangedType . UPDATED , ChangedType . DELETED ) ; } | Initialize all state changed listeners . |
16,174 | public void setTransactionType ( final TransactionType transactionType ) { if ( null == schemaName ) { throw new ShardingException ( "Please select database, then switch transaction type." ) ; } if ( isSwitchFailed ( ) ) { throw new ShardingException ( "Failed to switch transaction type, please terminate current transa... | Change transaction type of current channel . |
16,175 | public void setCurrentSchema ( final String schemaName ) { if ( isSwitchFailed ( ) ) { throw new ShardingException ( "Failed to switch schema, please terminate current transaction." ) ; } this . schemaName = schemaName ; this . logicSchema = LogicSchemas . getInstance ( ) . getLogicSchema ( schemaName ) ; } | Change logic schema of current channel . |
16,176 | public List < Connection > getConnections ( final ConnectionMode connectionMode , final String dataSourceName , final int connectionSize ) throws SQLException { if ( stateHandler . isInTransaction ( ) ) { return getConnectionsWithTransaction ( connectionMode , dataSourceName , connectionSize ) ; } else { return getConn... | Get connections of current thread datasource . |
16,177 | public synchronized void close ( final boolean forceClose ) throws SQLException { Collection < SQLException > exceptions = new LinkedList < > ( ) ; MasterVisitedManager . clear ( ) ; exceptions . addAll ( closeResultSets ( ) ) ; exceptions . addAll ( closeStatements ( ) ) ; if ( ! stateHandler . isInTransaction ( ) || ... | Close cached connection . |
16,178 | public void parse ( final InsertStatement insertStatement ) { if ( ! lexerEngine . skipIfEqual ( getCustomizedInsertKeywords ( ) ) ) { return ; } lexerEngine . accept ( DefaultKeyword . DUPLICATE ) ; lexerEngine . accept ( DefaultKeyword . KEY ) ; lexerEngine . accept ( DefaultKeyword . UPDATE ) ; do { Column column = ... | Parse insert duplicate key update . |
16,179 | public static Optional < Condition > createCompareCondition ( final PredicateCompareRightValue compareRightValue , final Column column ) { return compareRightValue . getExpression ( ) instanceof SimpleExpressionSegment ? Optional . of ( new Condition ( column , ( ( SimpleExpressionSegment ) compareRightValue . getExpre... | Create condition of compare operator . |
16,180 | public static Optional < Condition > createInCondition ( final PredicateInRightValue inRightValue , final Column column ) { List < SQLExpression > sqlExpressions = new LinkedList < > ( ) ; for ( ExpressionSegment each : inRightValue . getSqlExpressions ( ) ) { if ( ! ( each instanceof SimpleExpressionSegment ) ) { sqlE... | Create condition of IN operator . |
16,181 | public static Optional < Condition > createBetweenCondition ( final PredicateBetweenRightValue betweenRightValue , final Column column ) { return betweenRightValue . getBetweenExpression ( ) instanceof SimpleExpressionSegment && betweenRightValue . getAndExpression ( ) instanceof SimpleExpressionSegment ? Optional . of... | Create condition of BETWEEN ... AND ... operator . |
16,182 | public void init ( final DatabaseType databaseType , final Map < String , DataSource > dataSourceMap ) { for ( Entry < TransactionType , ShardingTransactionManager > entry : transactionManagerMap . entrySet ( ) ) { entry . getValue ( ) . init ( databaseType , getResourceDataSources ( dataSourceMap ) ) ; } } | Initialize sharding transaction managers . |
16,183 | public ShardingTransactionManager getTransactionManager ( final TransactionType transactionType ) { ShardingTransactionManager result = transactionManagerMap . get ( transactionType ) ; if ( TransactionType . LOCAL != transactionType ) { Preconditions . checkNotNull ( result , "Cannot find transaction manager of [%s]" ... | Get sharding transaction manager . |
16,184 | public void close ( ) throws Exception { for ( Entry < TransactionType , ShardingTransactionManager > entry : transactionManagerMap . entrySet ( ) ) { entry . getValue ( ) . close ( ) ; } } | Close sharding transaction managers . |
16,185 | public static AbstractUpdateParser newInstance ( final DatabaseType dbType , final ShardingRule shardingRule , final LexerEngine lexerEngine ) { switch ( dbType ) { case H2 : case MySQL : return new MySQLUpdateParser ( shardingRule , lexerEngine ) ; case Oracle : return new OracleUpdateParser ( shardingRule , lexerEngi... | Create update parser instance . |
16,186 | public static String getSQLStatementRuleDefinitionFileName ( final String rootDir , final DatabaseType databaseType ) { return Joiner . on ( '/' ) . join ( rootDir , databaseType . name ( ) . toLowerCase ( ) , SQL_STATEMENT_RULE_DEFINITION_FILE_NAME ) ; } | Get SQL statement rule definition file name . |
16,187 | public static Optional < GeneratedKey > getGenerateKey ( final ShardingRule shardingRule , final List < Object > parameters , final InsertStatement insertStatement ) { Optional < String > generateKeyColumnName = shardingRule . findGenerateKeyColumnName ( insertStatement . getTables ( ) . getSingleTableName ( ) ) ; if (... | Get generate key . |
16,188 | public static String getDriverClassName ( final String url ) { for ( Entry < String , String > entry : URL_PREFIX_AND_DRIVER_CLASS_NAME_MAPPER . entrySet ( ) ) { if ( url . startsWith ( entry . getKey ( ) ) ) { return entry . getValue ( ) ; } } throw new ShardingException ( "Cannot resolve JDBC url `%s`. Please impleme... | Get JDBC driver class name . |
16,189 | public static DataSourceMetaData newInstance ( final DatabaseType databaseType , final String url ) { switch ( databaseType ) { case H2 : return new H2DataSourceMetaData ( url ) ; case MySQL : return new MySQLDataSourceMetaData ( url ) ; case Oracle : return new OracleDataSourceMetaData ( url ) ; case PostgreSQL : retu... | Create new instance of data source meta data . |
16,190 | public static XADataSource build ( final DatabaseType databaseType , final DataSource dataSource ) { XADataSource result = createXADataSource ( databaseType ) ; Properties xaProperties = XAPropertiesFactory . createXAProperties ( databaseType ) . build ( SWAPPER . swap ( dataSource ) ) ; PropertyUtils . setProperties (... | Create XA data source through general data source . |
16,191 | public SQLStatement judge ( ) { LexerEngine lexerEngine = LexerEngineFactory . newInstance ( DatabaseType . MySQL , sql ) ; lexerEngine . nextToken ( ) ; while ( true ) { TokenType tokenType = lexerEngine . getCurrentToken ( ) . getType ( ) ; if ( tokenType instanceof Keyword ) { if ( DQLStatement . isDQL ( tokenType )... | Judge SQL type only . |
16,192 | public Object getCell ( final int columnIndex ) { Preconditions . checkArgument ( columnIndex > 0 && columnIndex < data . length + 1 ) ; return data [ columnIndex - 1 ] ; } | Get data from cell . |
16,193 | public void setCell ( final int columnIndex , final Object value ) { Preconditions . checkArgument ( columnIndex > 0 && columnIndex < data . length + 1 ) ; data [ columnIndex - 1 ] = value ; } | Set data for cell . |
16,194 | public void parse ( final InsertStatement insertStatement , final ShardingTableMetaData shardingTableMetaData ) { String tableName = insertStatement . getTables ( ) . getSingleTableName ( ) ; insertStatement . getColumnNames ( ) . addAll ( lexerEngine . equalAny ( Symbol . LEFT_PAREN ) ? parseWithColumn ( insertStateme... | Parse insert columns . |
16,195 | public static AbstractDeleteParser newInstance ( final DatabaseType dbType , final ShardingRule shardingRule , final LexerEngine lexerEngine ) { switch ( dbType ) { case H2 : case MySQL : return new MySQLDeleteParser ( shardingRule , lexerEngine ) ; case Oracle : return new OracleDeleteParser ( shardingRule , lexerEngi... | Create delete parser instance . |
16,196 | public static AbstractShowParser newInstance ( final DatabaseType dbType , final ShardingRule shardingRule , final LexerEngine lexerEngine ) { switch ( dbType ) { case H2 : case MySQL : return new MySQLShowParser ( shardingRule , lexerEngine ) ; default : throw new UnsupportedOperationException ( String . format ( "Can... | Create show parser instance . |
16,197 | public static boolean isDDL ( final TokenType primaryTokenType , final TokenType secondaryTokenType ) { return PRIMARY_STATEMENT_PREFIX . contains ( primaryTokenType ) && ! NOT_SECONDARY_STATEMENT_PREFIX . contains ( secondaryTokenType ) ; } | Is DDL statement . |
16,198 | public void init ( final Map < String , Map < String , DataSourceConfiguration > > dataSourceConfigurationMap , final Map < String , RuleConfiguration > schemaRuleMap , final Authentication authentication , final Properties props ) { for ( Entry < String , Map < String , DataSourceConfiguration > > entry : dataSourceCo... | Initialize for orchestration . |
16,199 | public void parse ( final ShardingRule shardingRule , final SQLStatement sqlStatement , final List < SelectItem > items ) { aliasExpressionParser . parseTableAlias ( ) ; if ( lexerEngine . skipIfEqual ( DefaultKeyword . WHERE ) ) { parseWhere ( shardingRule , sqlStatement , items ) ; } } | Parse where . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.