idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
155,300
private static void fixDistributedApproxCountDistinct ( AggregatePlanNode distNode , AggregatePlanNode coordNode ) { assert ( distNode != null ) ; assert ( coordNode != null ) ; List < ExpressionType > distAggTypes = distNode . getAggregateTypes ( ) ; boolean hasApproxCountDistinct = false ; for ( int i = 0 ; i < distA...
This function is called once it s been determined that we can push down an aggregation plan node .
155,301
protected AbstractPlanNode checkLimitPushDownViability ( AbstractPlanNode root ) { AbstractPlanNode receiveNode = root ; List < ParsedColInfo > orderBys = m_parsedSelect . orderByColumns ( ) ; boolean orderByCoversAllGroupBy = m_parsedSelect . groupByIsAnOrderByPermutation ( ) ; while ( ! ( receiveNode instanceof Recei...
Check if we can push the limit node down .
155,302
private static Set < String > getIndexedColumnSetForTable ( Table table ) { HashSet < String > columns = new HashSet < > ( ) ; for ( Index index : table . getIndexes ( ) ) { for ( ColumnRef colRef : index . getColumns ( ) ) { columns . add ( colRef . getColumn ( ) . getTypeName ( ) ) ; } } return columns ; }
Get the unique set of names of all columns that are part of an index on the given table .
155,303
private static boolean isNullRejecting ( Collection < String > tableAliases , List < AbstractExpression > exprs ) { for ( AbstractExpression expr : exprs ) { for ( String tableAlias : tableAliases ) { if ( ExpressionUtil . isNullRejectingExpression ( expr , tableAlias ) ) { return true ; } } } return false ; }
Verify if an expression from the input list is NULL - rejecting for any of the tables from the list
155,304
private int determineIndexOrdering ( StmtTableScan tableScan , int keyComponentCount , List < AbstractExpression > indexedExprs , List < ColumnRef > indexedColRefs , AccessPath retval , int [ ] orderSpoilers , List < AbstractExpression > bindingsForOrder ) { ParsedSelectStmt pss = ( m_parsedStmt instanceof ParsedSelect...
Determine if an index which is in the AccessPath argument retval can satisfy a parsed select statement s order by or window function ordering requirements .
155,305
private static List < AbstractExpression > findBindingsForOneIndexedExpression ( ExpressionOrColumn nextStatementEOC , ExpressionOrColumn indexEntry ) { assert ( nextStatementEOC . m_expr != null ) ; AbstractExpression nextStatementExpr = nextStatementEOC . m_expr ; if ( indexEntry . m_colRef != null ) { ColumnRef inde...
Match the indexEntry which is from an index with a statement expression or column . The nextStatementEOC must be an expression not a column reference .
155,306
private static boolean removeExactMatchCoveredExpressions ( AbstractExpression coveringExpr , List < AbstractExpression > exprsToCover ) { boolean hasMatch = false ; Iterator < AbstractExpression > iter = exprsToCover . iterator ( ) ; while ( iter . hasNext ( ) ) { AbstractExpression exprToCover = iter . next ( ) ; if ...
Loop over the expressions to cover to find ones that exactly match the covering expression and remove them from the original list . Returns true if there is at least one match . False otherwise .
155,307
private static List < AbstractExpression > removeNotNullCoveredExpressions ( StmtTableScan tableScan , List < AbstractExpression > coveringExprs , List < AbstractExpression > exprsToCover ) { Set < TupleValueExpression > coveringTves = new HashSet < > ( ) ; for ( AbstractExpression coveringExpr : coveringExprs ) { if (...
Remove NOT NULL expressions that are covered by the NULL - rejecting expressions . For example COL IS NOT NULL is covered by the COL > 0 NULL - rejecting comparison expression .
155,308
protected static AbstractPlanNode addSendReceivePair ( AbstractPlanNode scanNode ) { SendPlanNode sendNode = new SendPlanNode ( ) ; sendNode . addAndLinkChild ( scanNode ) ; ReceivePlanNode recvNode = new ReceivePlanNode ( ) ; recvNode . addAndLinkChild ( sendNode ) ; return recvNode ; }
Insert a send receive pair above the supplied scanNode .
155,309
protected static AbstractPlanNode getAccessPlanForTable ( JoinNode tableNode ) { StmtTableScan tableScan = tableNode . getTableScan ( ) ; AccessPath path = tableNode . m_currentAccessPath ; assert ( path != null ) ; if ( path . index == null ) { return getScanAccessPlanForTable ( tableScan , path ) ; } return getIndexA...
Given an access path build the single - site or distributed plan that will assess the data from the table according to the path .
155,310
private static AbstractPlanNode getIndexAccessPlanForTable ( StmtTableScan tableScan , AccessPath path ) { Index index = path . index ; IndexScanPlanNode scanNode = new IndexScanPlanNode ( tableScan , index ) ; AbstractPlanNode resultNode = scanNode ; scanNode . setSortDirection ( path . sortDirection ) ; for ( Abstrac...
Get an index scan access plan for a table .
155,311
private static AbstractPlanNode injectIndexedJoinWithMaterializedScan ( AbstractExpression listElements , IndexScanPlanNode scanNode ) { MaterializedScanPlanNode matScan = new MaterializedScanPlanNode ( ) ; assert ( listElements instanceof VectorValueExpression || listElements instanceof ParameterValueExpression ) ; ma...
Generate a plan for an IN - LIST - driven index scan
155,312
private static void replaceInListFilterWithEqualityFilter ( List < AbstractExpression > endExprs , AbstractExpression inListRhs , AbstractExpression equalityRhs ) { for ( AbstractExpression comparator : endExprs ) { AbstractExpression otherExpr = comparator . getRight ( ) ; if ( otherExpr == inListRhs ) { endExprs . re...
with an equality filter referencing the second given rhs .
155,313
CallEvent [ ] makeRandomEvent ( ) { long callId = ++ lastCallIdUsed ; Integer agentId = agentsAvailable . poll ( ) ; if ( agentId == null ) { return null ; } Long phoneNo = phoneNumbersAvailable . poll ( ) ; assert ( phoneNo != null ) ; Date startTS = new Date ( currentSystemMilliTimestamp ) ; long durationms = - 1 ; l...
Generate a random call event with a duration .
155,314
public CallEvent next ( long systemCurrentTimeMillis ) { if ( systemCurrentTimeMillis > currentSystemMilliTimestamp ) { long eventBacklog = targetEventsThisMillisecond - eventsSoFarThisMillisecond ; targetEventsThisMillisecond = ( long ) Math . floor ( targetEventsPerMillisecond ) ; double targetFraction = targetEvents...
Return the next call event that is safe for delivery or null if there are no safe objects to deliver .
155,315
private void validate ( ) { long delayedEventCount = delayedEvents . size ( ) ; long outstandingAgents = config . agents - agentsAvailable . size ( ) ; long outstandingPhones = config . numbers - phoneNumbersAvailable . size ( ) ; if ( outstandingAgents != outstandingPhones ) { throw new RuntimeException ( String . for...
Smoke check on validity of data structures . This was useful while getting the code right for this class but it doesn t do much now unless the code needs changes .
155,316
void printSummary ( ) { System . out . printf ( "There are %d agents outstanding and %d phones. %d entries waiting to go.\n" , agentsAvailable . size ( ) , phoneNumbersAvailable . size ( ) , delayedEvents . size ( ) ) ; }
Debug statement to help users verify there are no lost or delayed events .
155,317
private boolean isNegativeNumber ( String token ) { try { Double . parseDouble ( token ) ; return true ; } catch ( NumberFormatException e ) { return false ; } }
Check if the token is a negative number .
155,318
private boolean isLongOption ( String token ) { if ( ! token . startsWith ( "-" ) || token . length ( ) == 1 ) { return false ; } int pos = token . indexOf ( "=" ) ; String t = pos == - 1 ? token : token . substring ( 0 , pos ) ; if ( ! options . getMatchingOptions ( t ) . isEmpty ( ) ) { return true ; } else if ( getL...
Tells if the token looks like a long option .
155,319
private void handleUnknownToken ( String token ) throws ParseException { if ( token . startsWith ( "-" ) && token . length ( ) > 1 && ! stopAtNonOption ) { throw new UnrecognizedOptionException ( "Unrecognized option: " + token , token ) ; } cmd . addArg ( token ) ; if ( stopAtNonOption ) { skipParsing = true ; } }
Handles an unknown token . If the token starts with a dash an UnrecognizedOptionException is thrown . Otherwise the token is added to the arguments of the command line . If the stopAtNonOption flag is set this stops the parsing and the remaining tokens are added as - is in the arguments of the command line .
155,320
public String getText ( ) { if ( sqlTextStr == null ) { sqlTextStr = new String ( sqlText , Constants . UTF8ENCODING ) ; } return sqlTextStr ; }
Get the text of the SQL statement represented .
155,321
public static String canonicalizeStmt ( String stmtStr ) { stmtStr = stmtStr . replaceAll ( "\n" , " " ) ; stmtStr = stmtStr . trim ( ) ; if ( ! stmtStr . endsWith ( ";" ) ) { stmtStr += ";" ; } return stmtStr ; }
use the same statement to compute crc .
155,322
private static boolean [ ] createSafeOctets ( String safeChars ) { int maxChar = - 1 ; char [ ] safeCharArray = safeChars . toCharArray ( ) ; for ( char c : safeCharArray ) { maxChar = Math . max ( c , maxChar ) ; } boolean [ ] octets = new boolean [ maxChar + 1 ] ; for ( char c : safeCharArray ) { octets [ c ] = true ...
Creates a boolean array with entries corresponding to the character values specified in safeChars set to true . The array is as small as is required to hold the given character information .
155,323
String getTableName ( ) { if ( opType == OpTypes . MULTICOLUMN ) { return tableName ; } if ( opType == OpTypes . COLUMN ) { if ( rangeVariable == null ) { return tableName ; } return rangeVariable . getTable ( ) . getName ( ) . name ; } return "" ; }
Returns the table name for a column expression as a string
155,324
VoltXMLElement voltAnnotateColumnXML ( VoltXMLElement exp ) { if ( tableName != null ) { if ( rangeVariable != null && rangeVariable . rangeTable != null && rangeVariable . tableAlias != null && rangeVariable . rangeTable . tableType == TableBase . SYSTEM_SUBQUERY ) { exp . attributes . put ( "table" , rangeVariable . ...
VoltDB added method to provide detail for a non - catalog - dependent representation of this HSQLDB object .
155,325
void parseTablesAndParams ( VoltXMLElement root ) { parseParameters ( root ) ; parseCommonTableExpressions ( root ) ; for ( VoltXMLElement node : root . children ) { if ( node . name . equalsIgnoreCase ( "tablescan" ) ) { parseTable ( node ) ; } else if ( node . name . equalsIgnoreCase ( "tablescans" ) ) { parseTables ...
Parse tables and parameters .
155,326
private AbstractExpression parseExpressionNode ( VoltXMLElement exprNode ) { String elementName = exprNode . name . toLowerCase ( ) ; XMLElementExpressionParser parser = m_exprParsers . get ( elementName ) ; if ( parser == null ) { throw new PlanningErrorException ( "Unsupported expression node '" + elementName + "'" )...
Given a VoltXMLElement expression node translate it into an AbstractExpression . This is mostly a lookup in the table m_exprParsers .
155,327
private AbstractExpression parseVectorExpression ( VoltXMLElement exprNode ) { ArrayList < AbstractExpression > args = new ArrayList < > ( ) ; for ( VoltXMLElement argNode : exprNode . children ) { assert ( argNode != null ) ; AbstractExpression argExpr = parseExpressionNode ( argNode ) ; assert ( argExpr != null ) ; a...
Parse a Vector value for SQL - IN
155,328
private SelectSubqueryExpression parseSubqueryExpression ( VoltXMLElement exprNode ) { assert ( exprNode . children . size ( ) == 1 ) ; VoltXMLElement subqueryElmt = exprNode . children . get ( 0 ) ; AbstractParsedStmt subqueryStmt = parseSubquery ( subqueryElmt ) ; String withoutAlias = null ; StmtSubqueryScan stmtSub...
Parse an expression subquery
155,329
private StmtTableScan resolveStmtTableScanByAlias ( String tableAlias ) { StmtTableScan tableScan = getStmtTableScanByAlias ( tableAlias ) ; if ( tableScan != null ) { return tableScan ; } if ( m_parentStmt != null ) { return m_parentStmt . resolveStmtTableScanByAlias ( tableAlias ) ; } return null ; }
Return StmtTableScan by table alias . In case of correlated queries may need to walk up the statement tree .
155,330
protected StmtTableScan addTableToStmtCache ( Table table , String tableAlias ) { StmtTableScan tableScan = m_tableAliasMap . get ( tableAlias ) ; if ( tableScan == null ) { tableScan = new StmtTargetTableScan ( table , tableAlias , m_stmtId ) ; m_tableAliasMap . put ( tableAlias , tableScan ) ; } return tableScan ; }
Add a table to the statement cache .
155,331
protected StmtSubqueryScan addSubqueryToStmtCache ( AbstractParsedStmt subquery , String tableAlias ) { assert ( subquery != null ) ; if ( tableAlias == null ) { tableAlias = AbstractParsedStmt . TEMP_TABLE_NAME + "_" + subquery . m_stmtId ; } StmtSubqueryScan subqueryScan = new StmtSubqueryScan ( subquery , tableAlias...
Add a sub - query to the statement cache .
155,332
private StmtTargetTableScan addSimplifiedSubqueryToStmtCache ( StmtSubqueryScan subqueryScan , StmtTargetTableScan tableScan ) { String tableAlias = subqueryScan . getTableAlias ( ) ; assert ( tableAlias != null ) ; Table promotedTable = tableScan . getTargetTable ( ) ; StmtTargetTableScan promotedScan = new StmtTarget...
Replace an existing subquery scan with its underlying table scan . The subquery has already passed all the checks from the canSimplifySubquery method . Subquery ORDER BY clause is ignored if such exists .
155,333
protected AbstractExpression replaceExpressionsWithPve ( AbstractExpression expr ) { assert ( expr != null ) ; if ( expr instanceof TupleValueExpression ) { int paramIdx = ParameterizationInfo . getNextParamIndex ( ) ; ParameterValueExpression pve = new ParameterValueExpression ( paramIdx , expr ) ; m_parameterTveMap ....
Helper method to replace all TVEs and aggregated expressions with the corresponding PVEs . The original expressions are placed into the map to be propagated to the EE . The key to the map is the parameter index .
155,334
private StmtCommonTableScan resolveCommonTableByName ( String tableName , String tableAlias ) { StmtCommonTableScan answer = null ; StmtCommonTableScanShared scan = null ; for ( AbstractParsedStmt scope = this ; scope != null && scan == null ; scope = scope . getParentStmt ( ) ) { scan = scope . getCommonTableByName ( ...
Look for a common table by name possibly in parent scopes . This is different from resolveStmtTableByAlias in that it looks for common tables and only by name not by alias . Of course a name and an alias are both strings so this is kind of a stylized distinction .
155,335
protected void parseParameters ( VoltXMLElement root ) { VoltXMLElement paramsNode = null ; for ( VoltXMLElement node : root . children ) { if ( node . name . equalsIgnoreCase ( "parameters" ) ) { paramsNode = node ; break ; } } if ( paramsNode == null ) { return ; } for ( VoltXMLElement node : paramsNode . children ) ...
Populate the statement s paramList from the parameters element . Each parameter has an id and an index both of which are numeric . It also has a type and an indication of whether it s a vector parameter . For each parameter we create a ParameterValueExpression named pve which holds the type and vector parameter indicat...
155,336
protected void promoteUnionParametersFromChild ( AbstractParsedStmt childStmt ) { getParamsByIndex ( ) . putAll ( childStmt . getParamsByIndex ( ) ) ; m_parameterTveMap . putAll ( childStmt . m_parameterTveMap ) ; }
in the EE .
155,337
HashMap < AbstractExpression , Set < AbstractExpression > > analyzeValueEquivalence ( ) { m_joinTree . analyzeJoinExpressions ( m_noTableSelectionList ) ; return m_joinTree . getAllEquivalenceFilters ( ) ; }
Collect value equivalence expressions across the entire SQL statement
155,338
protected Table getTableFromDB ( String tableName ) { Table table = m_db . getTables ( ) . getExact ( tableName ) ; return table ; }
Look up a table by name . This table may be stored in the local catalog or else the global catalog .
155,339
private AbstractExpression parseTableCondition ( VoltXMLElement tableScan , String joinOrWhere ) { AbstractExpression condExpr = null ; for ( VoltXMLElement childNode : tableScan . children ) { if ( ! childNode . name . equalsIgnoreCase ( joinOrWhere ) ) { continue ; } assert ( childNode . children . size ( ) == 1 ) ; ...
Parse a where or join clause . This behavior is common to all kinds of statements .
155,340
LimitPlanNode limitPlanNodeFromXml ( VoltXMLElement limitXml , VoltXMLElement offsetXml ) { if ( limitXml == null && offsetXml == null ) { return null ; } String node ; long limitParameterId = - 1 ; long offsetParameterId = - 1 ; long limit = - 1 ; long offset = 0 ; if ( limitXml != null ) { if ( ( node = limitXml . at...
Produce a LimitPlanNode from the given XML
155,341
protected boolean orderByColumnsCoverUniqueKeys ( ) { HashMap < String , List < AbstractExpression > > baseTableAliases = new HashMap < > ( ) ; for ( ParsedColInfo col : orderByColumns ( ) ) { AbstractExpression expr = col . m_expression ; List < TupleValueExpression > baseTVEExpressions = expr . findAllTupleValueSubex...
Order by Columns or expressions has to operate on the display columns or expressions .
155,342
protected void addHonoraryOrderByExpressions ( HashSet < AbstractExpression > orderByExprs , List < ParsedColInfo > candidateColumns ) { if ( m_tableAliasMap . size ( ) != 1 ) { return ; } HashMap < AbstractExpression , Set < AbstractExpression > > valueEquivalence = analyzeValueEquivalence ( ) ; for ( ParsedColInfo co...
Given a set of order - by expressions and a select list which is a list of columns each with an expression and an alias expand the order - by list with new expressions which could be on the order - by list without changing the sort order and which are otherwise helpful .
155,343
protected boolean producesOneRowOutput ( ) { if ( m_tableAliasMap . size ( ) != 1 ) { return false ; } StmtTableScan scan = m_tableAliasMap . values ( ) . iterator ( ) . next ( ) ; Table table = getTableFromDB ( scan . getTableName ( ) ) ; if ( table == null ) { return false ; } CatalogMap < Index > indexes = table . g...
row else false
155,344
public Collection < String > calculateUDFDependees ( ) { List < String > answer = new ArrayList < > ( ) ; Collection < AbstractExpression > fCalls = findAllSubexpressionsOfClass ( FunctionExpression . class ) ; for ( AbstractExpression fCall : fCalls ) { FunctionExpression fexpr = ( FunctionExpression ) fCall ; if ( fe...
Calculate the UDF dependees . These are the UDFs called in an expression in this procedure .
155,345
public void statementGuaranteesDeterminism ( boolean hasLimitOrOffset , boolean order , String contentDeterminismDetail ) { m_statementHasLimitOrOffset = hasLimitOrOffset ; m_statementIsOrderDeterministic = order ; if ( contentDeterminismDetail != null ) { m_contentDeterminismDetail = contentDeterminismDetail ; } }
Mark the level of result determinism imposed by the statement which can save us from a difficult determination based on the plan graph .
155,346
private static void setParamIndexes ( BitSet ints , List < AbstractExpression > params ) { for ( AbstractExpression ae : params ) { assert ( ae instanceof ParameterValueExpression ) ; ParameterValueExpression pve = ( ParameterValueExpression ) ae ; int param = pve . getParameterIndex ( ) ; ints . set ( param ) ; } }
sources of bindings IndexScans and IndexCounts .
155,347
private static int [ ] bitSetToIntVector ( BitSet ints ) { int intCount = ints . cardinality ( ) ; if ( intCount == 0 ) { return null ; } int [ ] result = new int [ intCount ] ; int nextBit = ints . nextSetBit ( 0 ) ; for ( int ii = 0 ; ii < intCount ; ii ++ ) { assert ( nextBit != - 1 ) ; result [ ii ] = nextBit ; nex...
to convert the set bits to their integer indexes .
155,348
public VoltType [ ] parameterTypes ( ) { if ( m_parameterTypes == null ) { m_parameterTypes = new VoltType [ getParameters ( ) . length ] ; int ii = 0 ; for ( ParameterValueExpression param : getParameters ( ) ) { m_parameterTypes [ ii ++ ] = param . getValueType ( ) ; } } return m_parameterTypes ; }
This is assumed to be called only after parameters has been fully initialized .
155,349
public static Session newSession ( int dbID , String user , String password , int timeZoneSeconds ) { Database db = ( Database ) databaseIDMap . get ( dbID ) ; if ( db == null ) { return null ; } Session session = db . connect ( user , password , timeZoneSeconds ) ; session . isNetwork = true ; return session ; }
Used by server to open a new session
155,350
public static Session newSession ( String type , String path , String user , String password , HsqlProperties props , int timeZoneSeconds ) { Database db = getDatabase ( type , path , props ) ; if ( db == null ) { return null ; } return db . connect ( user , password , timeZoneSeconds ) ; }
Used by in - process connections and by Servlet
155,351
public static synchronized Database lookupDatabaseObject ( String type , String path ) { assert ( type == DatabaseURL . S_MEM ) ; java . util . HashMap < String , Database > databaseMap = memDatabaseMap ; String key = path ; return ( Database ) databaseMap . get ( key ) ; }
Looks up database of a given type and path in the registry . Returns null if there is none .
155,352
private static synchronized void addDatabaseObject ( String type , String path , Database db ) { assert ( type == DatabaseURL . S_MEM ) ; java . util . HashMap < String , Database > databaseMap = memDatabaseMap ; String key = path ; databaseIDMap . put ( db . databaseID , db ) ; databaseMap . put ( key , db ) ; }
Adds a database to the registry . Returns null if there is none .
155,353
static void removeDatabase ( Database database ) { int dbID = database . databaseID ; String type = database . getType ( ) ; String path = database . getPath ( ) ; notifyServers ( database ) ; assert ( type == DatabaseURL . S_MEM ) ; java . util . HashMap < String , Database > databaseMap = memDatabaseMap ; String key ...
Removes the database from registry .
155,354
private static void deRegisterServer ( Server server , Database db ) { Iterator it = serverMap . values ( ) . iterator ( ) ; for ( ; it . hasNext ( ) ; ) { HashSet databases = ( HashSet ) it . next ( ) ; databases . remove ( db ) ; if ( databases . isEmpty ( ) ) { it . remove ( ) ; } } }
Deregisters a server as serving a given database . Not yet used .
155,355
private static void registerServer ( Server server , Database db ) { if ( ! serverMap . containsKey ( server ) ) { serverMap . put ( server , new HashSet ( ) ) ; } HashSet databases = ( HashSet ) serverMap . get ( server ) ; databases . add ( db ) ; }
Registers a server as serving a given database .
155,356
private static void notifyServers ( Database db ) { Iterator it = serverMap . keySet ( ) . iterator ( ) ; for ( ; it . hasNext ( ) ; ) { Server server = ( Server ) it . next ( ) ; HashSet databases = ( HashSet ) serverMap . get ( server ) ; if ( databases . contains ( db ) ) { } } }
Notifies all servers that serve the database that the database has been shutdown .
155,357
private static String filePathToKey ( String path ) { try { return FileUtil . getDefaultInstance ( ) . canonicalPath ( path ) ; } catch ( Exception e ) { return path ; } }
thrown exception to an HsqlException in the process
155,358
public static boolean isComment ( String sql ) { Matcher commentMatcher = PAT_SINGLE_LINE_COMMENT . matcher ( sql ) ; return commentMatcher . matches ( ) ; }
Check if a SQL string is a comment .
155,359
public static String extractDDLToken ( String sql ) { String ddlToken = null ; Matcher ddlMatcher = PAT_ANY_DDL_FIRST_TOKEN . matcher ( sql ) ; if ( ddlMatcher . find ( ) ) { ddlToken = ddlMatcher . group ( 1 ) . toLowerCase ( ) ; } return ddlToken ; }
Get the DDL token if any at the start of this statement .
155,360
public static String extractDDLTableName ( String sql ) { Matcher matcher = PAT_TABLE_DDL_PREAMBLE . matcher ( sql ) ; if ( matcher . find ( ) ) { return matcher . group ( 2 ) . toLowerCase ( ) ; } return null ; }
Get the table name for a CREATE or DROP DDL statement .
155,361
public static String checkPermitted ( String sql ) { for ( CheckedPattern cp : BLACKLISTS ) { CheckedPattern . Result result = cp . check ( sql ) ; if ( result . matcher != null ) { return String . format ( "%s, in statement: %s" , result . explanation , sql ) ; } } boolean hadWLMatch = false ; for ( CheckedPattern cp ...
Naive filtering for stuff we haven t implemented yet . Hopefully this gets whittled away and eventually disappears .
155,362
static private boolean matchesStringAtIndex ( char [ ] buf , int index , String str ) { int strLength = str . length ( ) ; if ( index + strLength > buf . length ) { return false ; } for ( int i = 0 ; i < strLength ; ++ i ) { if ( buf [ index + i ] != str . charAt ( i ) ) { return false ; } } return true ; }
Determine if a character buffer contains the specified string a the specified index . Avoids an array index exception if the buffer is too short .
155,363
private static String removeCStyleComments ( String ddl ) { StringBuilder sb = new StringBuilder ( ) ; for ( String part : PAT_STRIP_CSTYLE_COMMENTS . split ( ddl ) ) { sb . append ( part ) ; } return sb . toString ( ) ; }
Remove c - style comments from a string aggressively
155,364
private static ObjectToken findObjectToken ( String objectTypeName ) { if ( objectTypeName != null ) { for ( ObjectToken ot : OBJECT_TOKENS ) { if ( ot . token . equalsIgnoreCase ( objectTypeName ) ) { return ot ; } } } return null ; }
Find information about an object type token if it s a known object type .
155,365
synchronized void pushPair ( Session session , Object [ ] row1 , Object [ ] row2 ) { if ( maxRowsQueued == 0 ) { trigger . fire ( triggerType , name . name , table . getName ( ) . name , row1 , row2 ) ; return ; } if ( rowsQueued >= maxRowsQueued ) { if ( nowait ) { pendingQueue . removeLast ( ) ; } else { try { wait (...
The main thread tells the trigger thread to fire by this call . If this Trigger is not threaded then the fire method is caled immediately and executed by the main thread . Otherwise the row data objects are added to the queue to be used by the Trigger thread .
155,366
public synchronized CompiledPlan planSqlCore ( String sql , StatementPartitioning partitioning ) { TrivialCostModel costModel = new TrivialCostModel ( ) ; DatabaseEstimates estimates = new DatabaseEstimates ( ) ; CompiledPlan plan = null ; try ( QueryPlanner planner = new QueryPlanner ( sql , "PlannerTool" , "PlannerTo...
Stripped down compile that is ONLY used to plan default procedures .
155,367
private boolean isReadOnlyProcedure ( String pname ) { final Boolean b = m_procedureInfo . get ( ) . get ( pname ) ; if ( b == null ) { return false ; } return b ; }
Check if procedure is readonly?
155,368
private VoltTable [ ] aggregateProcedureProfileStats ( VoltTable [ ] baseStats ) { if ( baseStats == null || baseStats . length != 1 ) { return baseStats ; } StatsProcProfTable timeTable = new StatsProcProfTable ( ) ; baseStats [ 0 ] . resetRowPosition ( ) ; while ( baseStats [ 0 ] . advanceRow ( ) ) { boolean transact...
Produce PROCEDUREPROFILE aggregation of PROCEDURE subselector
155,369
private VoltTable [ ] aggregateProcedureInputStats ( VoltTable [ ] baseStats ) { if ( baseStats == null || baseStats . length != 1 ) { return baseStats ; } StatsProcInputTable timeTable = new StatsProcInputTable ( ) ; baseStats [ 0 ] . resetRowPosition ( ) ; while ( baseStats [ 0 ] . advanceRow ( ) ) { boolean transact...
Produce PROCEDUREINPUT aggregation of PROCEDURE subselector
155,370
private VoltTable [ ] aggregateProcedureOutputStats ( VoltTable [ ] baseStats ) { if ( baseStats == null || baseStats . length != 1 ) { return baseStats ; } StatsProcOutputTable timeTable = new StatsProcOutputTable ( ) ; baseStats [ 0 ] . resetRowPosition ( ) ; while ( baseStats [ 0 ] . advanceRow ( ) ) { boolean trans...
Produce PROCEDUREOUTPUT aggregation of PROCEDURE subselector
155,371
public void notifyOfCatalogUpdate ( ) { m_procedureInfo = getProcedureInformationfoSupplier ( ) ; m_registeredStatsSources . put ( StatsSelector . PROCEDURE , new NonBlockingHashMap < Long , NonBlockingHashSet < StatsSource > > ( ) ) ; }
Please be noted that this function will be called from Site thread where most other functions in the class are from StatsAgent thread .
155,372
public void addState ( long agreementHSId ) { SiteState ss = m_stateBySite . get ( agreementHSId ) ; if ( ss != null ) return ; ss = new SiteState ( ) ; ss . hsId = agreementHSId ; ss . newestConfirmedTxnId = m_newestConfirmedTxnId ; m_stateBySite . put ( agreementHSId , ss ) ; }
Once a failed node is rejoined put it s sites back into all of the data structures here .
155,373
public Pair < CompleteTransactionTask , Boolean > pollFirstCompletionTask ( CompletionCounter nextTaskCounter ) { Pair < CompleteTransactionTask , Boolean > pair = m_compTasks . pollFirstEntry ( ) . getValue ( ) ; if ( m_compTasks . isEmpty ( ) ) { return pair ; } Pair < CompleteTransactionTask , Boolean > next = peekF...
Remove the CompleteTransactionTask from the head and count the next CompleteTransactionTask
155,374
private static boolean isComparable ( CompleteTransactionTask c1 , CompleteTransactionTask c2 ) { return c1 . getMsgTxnId ( ) == c2 . getMsgTxnId ( ) && MpRestartSequenceGenerator . isForRestart ( c1 . getTimestamp ( ) ) == MpRestartSequenceGenerator . isForRestart ( c2 . getTimestamp ( ) ) ; }
4 ) restart completion and repair completion can t overwrite each other
155,375
public boolean matchCompleteTransactionTask ( long txnId , long timestamp ) { if ( ! m_compTasks . isEmpty ( ) ) { long lowestTxnId = m_compTasks . firstKey ( ) ; if ( txnId == lowestTxnId ) { Pair < CompleteTransactionTask , Boolean > pair = m_compTasks . get ( lowestTxnId ) ; return timestamp == pair . getFirst ( ) ....
Only match CompleteTransactionTask at head of the queue
155,376
public static VoltTable aggregateStats ( VoltTable stats ) throws IllegalArgumentException { stats . resetRowPosition ( ) ; if ( stats . getRowCount ( ) == 0 ) { return stats ; } String role = null ; Map < Byte , State > states = new TreeMap < > ( ) ; while ( stats . advanceRow ( ) ) { final byte clusterId = ( byte ) s...
Aggregates DRROLE statistics reported by multiple nodes into a single cluster - wide row . The role column should be the same across all nodes . The state column may defer slightly and it uses the same logical AND - ish operation to combine the states .
155,377
public static String getString ( String key ) { if ( RESOURCE_BUNDLE == null ) throw new RuntimeException ( "Localized messages from resource bundle '" + BUNDLE_NAME + "' not loaded during initialization of driver." ) ; try { if ( key == null ) throw new IllegalArgumentException ( "Message key can not be null" ) ; Stri...
Returns the localized message for the given message key
155,378
public void createAllDevNullTargets ( Exception lastWriteException ) { Map < Integer , SnapshotDataTarget > targets = Maps . newHashMap ( ) ; final AtomicInteger numTargets = new AtomicInteger ( ) ; for ( Deque < SnapshotTableTask > tasksForSite : m_taskListsForHSIds . values ( ) ) { for ( SnapshotTableTask task : task...
In case the deferred setup phase fails some data targets may have not been created yet . This method will close all existing data targets and replace all with DevNullDataTargets so that snapshot can be drained .
155,379
private Map < String , Boolean > collapseSets ( List < List < String > > allTableSets ) { Map < String , Boolean > answer = new TreeMap < > ( ) ; for ( List < String > tables : allTableSets ) { for ( String table : tables ) { answer . put ( table , false ) ; } } return answer ; }
Take a list of list of table names and collapse into a map which maps all table names to false . We will set the correct values later on . We just want to get the structure right now . Note that tables may be named multiple time in the lists of lists of tables . Everything gets mapped to false so we don t care .
155,380
private List < List < String > > decodeTables ( String [ ] tablesThatMustBeEmpty ) { List < List < String > > answer = new ArrayList < > ( ) ; for ( String tableSet : tablesThatMustBeEmpty ) { String tableNames [ ] = tableSet . split ( "\\+" ) ; answer . add ( Arrays . asList ( tableNames ) ) ; } return answer ; }
Decode sets of names encoded as by concatenation with plus signs into lists of lists of strings . Preserve the order since we need it to match to error messages later on .
155,381
public VoltTable [ ] run ( SystemProcedureExecutionContext ctx ) { createAndExecuteSysProcPlan ( SysProcFragmentId . PF_shutdownSync , SysProcFragmentId . PF_shutdownSyncDone ) ; SynthesizedPlanFragment pfs [ ] = new SynthesizedPlanFragment [ ] { new SynthesizedPlanFragment ( SysProcFragmentId . PF_shutdownCommand , tr...
Begin an un - graceful shutdown .
155,382
public void drain ( ) throws InterruptedException , IOException { ClientImpl currentClient = this . getClient ( ) ; if ( currentClient == null ) { throw new IOException ( "Client is unavailable for drain()." ) ; } currentClient . drain ( ) ; }
Block the current thread until all queued stored procedure invocations have received responses or there are no more connections to the cluster
155,383
public void backpressureBarrier ( ) throws InterruptedException , IOException { ClientImpl currentClient = this . getClient ( ) ; if ( currentClient == null ) { throw new IOException ( "Client is unavailable for backpressureBarrier()." ) ; } currentClient . backpressureBarrier ( ) ; }
Blocks the current thread until there is no more backpressure or there are no more connections to the database
155,384
public boolean absolute ( int position ) { if ( position < 0 ) { position += size ; } if ( position < 0 ) { beforeFirst ( ) ; return false ; } if ( position > size ) { afterLast ( ) ; return false ; } if ( size == 0 ) { return false ; } if ( position < currentPos ) { beforeFirst ( ) ; } while ( position > currentPos ) ...
Uses similar semantics to java . sql . ResultSet except this is 0 based . When position is 0 or positive it is from the start ; when negative it is from end
155,385
private void printErrorAndQuit ( String message ) { System . out . println ( message + "\n-------------------------------------------------------------------------------------\n" ) ; printUsage ( ) ; System . exit ( - 1 ) ; }
Prints out an error message and the application usage print - out then terminates the application .
155,386
public AppHelper printActualUsage ( ) { System . out . println ( "-------------------------------------------------------------------------------------" ) ; int maxLength = 24 ; for ( Argument a : Arguments ) if ( maxLength < a . Name . length ( ) ) maxLength = a . Name . length ( ) ; for ( Argument a : Arguments ) { S...
Prints a full list of actual arguments that will be used by the application after interpretation of defaults and actual argument values as passed by the user on the command line .
155,387
public byte byteValue ( String name ) { try { return Byte . valueOf ( this . getArgumentByName ( name ) . Value ) ; } catch ( NullPointerException npe ) { printErrorAndQuit ( String . format ( "Argument '%s' was not provided." , name ) ) ; } catch ( Exception x ) { printErrorAndQuit ( String . format ( "Argument '%s' c...
Retrieves the value of an argument as a byte .
155,388
public short shortValue ( String name ) { try { return Short . valueOf ( this . getArgumentByName ( name ) . Value ) ; } catch ( NullPointerException npe ) { printErrorAndQuit ( String . format ( "Argument '%s' was not provided." , name ) ) ; } catch ( Exception x ) { printErrorAndQuit ( String . format ( "Argument '%s...
Retrieves the value of an argument as a short .
155,389
public int intValue ( String name ) { try { return Integer . valueOf ( this . getArgumentByName ( name ) . Value ) ; } catch ( NullPointerException npe ) { printErrorAndQuit ( String . format ( "Argument '%s' was not provided." , name ) ) ; } catch ( Exception x ) { printErrorAndQuit ( String . format ( "Argument '%s' ...
Retrieves the value of an argument as a int .
155,390
public long longValue ( String name ) { try { return Long . valueOf ( this . getArgumentByName ( name ) . Value ) ; } catch ( NullPointerException npe ) { printErrorAndQuit ( String . format ( "Argument '%s' was not provided." , name ) ) ; } catch ( Exception x ) { printErrorAndQuit ( String . format ( "Argument '%s' c...
Retrieves the value of an argument as a long .
155,391
public double doubleValue ( String name ) { try { return Double . valueOf ( this . getArgumentByName ( name ) . Value ) ; } catch ( NullPointerException npe ) { printErrorAndQuit ( String . format ( "Argument '%s' was not provided." , name ) ) ; } catch ( Exception x ) { printErrorAndQuit ( String . format ( "Argument ...
Retrieves the value of an argument as a double .
155,392
public String stringValue ( String name ) { try { return this . getArgumentByName ( name ) . Value ; } catch ( Exception npe ) { printErrorAndQuit ( String . format ( "Argument '%s' was not provided." , name ) ) ; } return null ; }
Retrieves the value of an argument as a string .
155,393
public boolean booleanValue ( String name ) { try { return Boolean . valueOf ( this . getArgumentByName ( name ) . Value ) ; } catch ( NullPointerException npe ) { printErrorAndQuit ( String . format ( "Argument '%s' was not provided." , name ) ) ; } catch ( Exception x ) { printErrorAndQuit ( String . format ( "Argume...
Retrieves the value of an argument as a boolean .
155,394
public void setBounds ( int x , int y , int w , int h ) { super . setBounds ( x , y , w , h ) ; iSbHeight = sbHoriz . getPreferredSize ( ) . height ; iSbWidth = sbVert . getPreferredSize ( ) . width ; iHeight = h - iSbHeight ; iWidth = w - iSbWidth ; sbHoriz . setBounds ( 0 , iHeight , iWidth , iSbHeight ) ; sbVert . s...
with additional replacement of deprecated methods
155,395
private String write ( String logDir ) throws IOException , ExecutionException , InterruptedException { final File file = new File ( logDir , "trace_" + System . currentTimeMillis ( ) + ".json.gz" ) ; if ( file . exists ( ) ) { throw new IOException ( "Trace file " + file . getAbsolutePath ( ) + " already exists" ) ; }...
Write the events in the queue to file .
155,396
public static TraceEventBatch log ( Category cat ) { final VoltTrace tracer = s_tracer ; if ( tracer != null && tracer . isCategoryEnabled ( cat ) ) { final TraceEventBatch batch = new TraceEventBatch ( cat ) ; tracer . queueEvent ( batch ) ; return batch ; } else { return null ; } }
Create a trace event batch for the given category . The events that go into this batch should all originate from the same thread .
155,397
public static String closeAllAndShutdown ( String logDir , long timeOutMillis ) throws IOException { String path = null ; final VoltTrace tracer = s_tracer ; if ( tracer != null ) { if ( logDir != null ) { path = dump ( logDir ) ; } s_tracer = null ; if ( timeOutMillis >= 0 ) { try { tracer . m_writerThread . shutdownN...
Close all open files and wait for shutdown .
155,398
private static synchronized void start ( ) throws IOException { if ( s_tracer == null ) { final VoltTrace tracer = new VoltTrace ( ) ; final Thread thread = new Thread ( tracer ) ; thread . setDaemon ( true ) ; thread . start ( ) ; s_tracer = tracer ; } }
Creates and starts a new tracer . If one already exists this is a no - op . Synchronized to prevent multiple threads enabling it at the same time .
155,399
public static String dump ( String logDir ) throws IOException { String path = null ; final VoltTrace tracer = s_tracer ; if ( tracer != null ) { final File dir = new File ( logDir ) ; if ( ! dir . getParentFile ( ) . canWrite ( ) || ! dir . getParentFile ( ) . canExecute ( ) ) { throw new IOException ( "Trace log pare...
Write all trace events in the queue to file .