repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
VoltDB/voltdb
src/frontend/org/voltdb/planner/PlanAssembler.java
PlanAssembler.fixDistributedApproxCountDistinct
private static void fixDistributedApproxCountDistinct( AggregatePlanNode distNode, AggregatePlanNode coordNode) { assert (distNode != null); assert (coordNode != null); // Patch up any APPROX_COUNT_DISTINCT on the distributed node. List<ExpressionType> distAggTypes = distNode.getAggregateTypes(); boolean hasApproxCountDistinct = false; for (int i = 0; i < distAggTypes.size(); ++i) { ExpressionType et = distAggTypes.get(i); if (et == ExpressionType.AGGREGATE_APPROX_COUNT_DISTINCT) { hasApproxCountDistinct = true; distNode.updateAggregate(i, ExpressionType.AGGREGATE_VALS_TO_HYPERLOGLOG); } } if (hasApproxCountDistinct) { // Now, patch up any APPROX_COUNT_DISTINCT on the coordinating node. List<ExpressionType> coordAggTypes = coordNode.getAggregateTypes(); for (int i = 0; i < coordAggTypes.size(); ++i) { ExpressionType et = coordAggTypes.get(i); if (et == ExpressionType.AGGREGATE_APPROX_COUNT_DISTINCT) { coordNode.updateAggregate(i, ExpressionType.AGGREGATE_HYPERLOGLOGS_TO_CARD); } } } }
java
private static void fixDistributedApproxCountDistinct( AggregatePlanNode distNode, AggregatePlanNode coordNode) { assert (distNode != null); assert (coordNode != null); // Patch up any APPROX_COUNT_DISTINCT on the distributed node. List<ExpressionType> distAggTypes = distNode.getAggregateTypes(); boolean hasApproxCountDistinct = false; for (int i = 0; i < distAggTypes.size(); ++i) { ExpressionType et = distAggTypes.get(i); if (et == ExpressionType.AGGREGATE_APPROX_COUNT_DISTINCT) { hasApproxCountDistinct = true; distNode.updateAggregate(i, ExpressionType.AGGREGATE_VALS_TO_HYPERLOGLOG); } } if (hasApproxCountDistinct) { // Now, patch up any APPROX_COUNT_DISTINCT on the coordinating node. List<ExpressionType> coordAggTypes = coordNode.getAggregateTypes(); for (int i = 0; i < coordAggTypes.size(); ++i) { ExpressionType et = coordAggTypes.get(i); if (et == ExpressionType.AGGREGATE_APPROX_COUNT_DISTINCT) { coordNode.updateAggregate(i, ExpressionType.AGGREGATE_HYPERLOGLOGS_TO_CARD); } } } }
[ "private", "static", "void", "fixDistributedApproxCountDistinct", "(", "AggregatePlanNode", "distNode", ",", "AggregatePlanNode", "coordNode", ")", "{", "assert", "(", "distNode", "!=", "null", ")", ";", "assert", "(", "coordNode", "!=", "null", ")", ";", "// Patc...
This function is called once it's been determined that we can push down an aggregation plan node. If an APPROX_COUNT_DISTINCT aggregate is distributed, then we need to convert the distributed aggregate function to VALS_TO_HYPERLOGLOG, and the coordinating aggregate function to HYPERLOGLOGS_TO_CARD. @param distNode The aggregate node executed on each partition @param coordNode The aggregate node executed on the coordinator
[ "This", "function", "is", "called", "once", "it", "s", "been", "determined", "that", "we", "can", "push", "down", "an", "aggregation", "plan", "node", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/PlanAssembler.java#L3004-L3032
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/PlanAssembler.java
PlanAssembler.checkLimitPushDownViability
protected AbstractPlanNode checkLimitPushDownViability( AbstractPlanNode root) { AbstractPlanNode receiveNode = root; List<ParsedColInfo> orderBys = m_parsedSelect.orderByColumns(); boolean orderByCoversAllGroupBy = m_parsedSelect.groupByIsAnOrderByPermutation(); while ( ! (receiveNode instanceof ReceivePlanNode)) { // Limitation: can only push past some nodes (see above comment) // Delete the aggregate node case to handle ENG-6485, // or say we don't push down meeting aggregate node // TODO: We might want to optimize/push down "limit" for some cases if ( ! (receiveNode instanceof OrderByPlanNode) && ! (receiveNode instanceof ProjectionPlanNode) && ! isValidAggregateNodeForLimitPushdown(receiveNode, orderBys, orderByCoversAllGroupBy) ) { return null; } if (receiveNode instanceof OrderByPlanNode) { // if grouping by the partition key, // limit can still push down if ordered by aggregate values. if (! m_parsedSelect.hasPartitionColumnInGroupby() && isOrderByAggregationValue(m_parsedSelect.orderByColumns())) { return null; } } // Traverse... if (receiveNode.getChildCount() == 0) { return null; } // nothing that allows pushing past has multiple inputs assert(receiveNode.getChildCount() == 1); receiveNode = receiveNode.getChild(0); } return receiveNode.getChild(0); }
java
protected AbstractPlanNode checkLimitPushDownViability( AbstractPlanNode root) { AbstractPlanNode receiveNode = root; List<ParsedColInfo> orderBys = m_parsedSelect.orderByColumns(); boolean orderByCoversAllGroupBy = m_parsedSelect.groupByIsAnOrderByPermutation(); while ( ! (receiveNode instanceof ReceivePlanNode)) { // Limitation: can only push past some nodes (see above comment) // Delete the aggregate node case to handle ENG-6485, // or say we don't push down meeting aggregate node // TODO: We might want to optimize/push down "limit" for some cases if ( ! (receiveNode instanceof OrderByPlanNode) && ! (receiveNode instanceof ProjectionPlanNode) && ! isValidAggregateNodeForLimitPushdown(receiveNode, orderBys, orderByCoversAllGroupBy) ) { return null; } if (receiveNode instanceof OrderByPlanNode) { // if grouping by the partition key, // limit can still push down if ordered by aggregate values. if (! m_parsedSelect.hasPartitionColumnInGroupby() && isOrderByAggregationValue(m_parsedSelect.orderByColumns())) { return null; } } // Traverse... if (receiveNode.getChildCount() == 0) { return null; } // nothing that allows pushing past has multiple inputs assert(receiveNode.getChildCount() == 1); receiveNode = receiveNode.getChild(0); } return receiveNode.getChild(0); }
[ "protected", "AbstractPlanNode", "checkLimitPushDownViability", "(", "AbstractPlanNode", "root", ")", "{", "AbstractPlanNode", "receiveNode", "=", "root", ";", "List", "<", "ParsedColInfo", ">", "orderBys", "=", "m_parsedSelect", ".", "orderByColumns", "(", ")", ";", ...
Check if we can push the limit node down. Return a mid-plan send node, if one exists and can host a distributed limit node. There is guaranteed to be at most a single receive/send pair. Abort the search if a node that a "limit" can't be pushed past is found before its receive node. Can only push past: * coordinatingAggregator: a distributed aggregator a copy of which has already been pushed down. Distributing a LIMIT to just above that aggregator is correct. (I've got some doubts that this is correct??? --paul) * order by: if the plan requires a sort, getNextSelectPlan() will have already added an ORDER BY. A distributed LIMIT will be added above a copy of that ORDER BY node. * projection: these have no effect on the application of limits. @param root @return If we can push the limit down, the send plan node is returned. Otherwise null -- when the plan is single-partition when its "coordinator" part contains a push-blocking node type.
[ "Check", "if", "we", "can", "push", "the", "limit", "node", "down", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/PlanAssembler.java#L3166-L3204
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/PlanAssembler.java
PlanAssembler.getIndexedColumnSetForTable
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; }
java
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; }
[ "private", "static", "Set", "<", "String", ">", "getIndexedColumnSetForTable", "(", "Table", "table", ")", "{", "HashSet", "<", "String", ">", "columns", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "Index", "index", ":", "table", ".", "getInd...
Get the unique set of names of all columns that are part of an index on the given table. @param table The table to build the list of index-affected columns with. @return The set of column names affected by indexes with duplicates removed.
[ "Get", "the", "unique", "set", "of", "names", "of", "all", "columns", "that", "are", "part", "of", "an", "index", "on", "the", "given", "table", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/PlanAssembler.java#L3343-L3353
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/PlanAssembler.java
PlanAssembler.isNullRejecting
private static boolean isNullRejecting(Collection<String> tableAliases, List<AbstractExpression> exprs) { for (AbstractExpression expr : exprs) { for (String tableAlias : tableAliases) { if (ExpressionUtil.isNullRejectingExpression(expr, tableAlias)) { // We are done at this level return true; } } } return false; }
java
private static boolean isNullRejecting(Collection<String> tableAliases, List<AbstractExpression> exprs) { for (AbstractExpression expr : exprs) { for (String tableAlias : tableAliases) { if (ExpressionUtil.isNullRejectingExpression(expr, tableAlias)) { // We are done at this level return true; } } } return false; }
[ "private", "static", "boolean", "isNullRejecting", "(", "Collection", "<", "String", ">", "tableAliases", ",", "List", "<", "AbstractExpression", ">", "exprs", ")", "{", "for", "(", "AbstractExpression", "expr", ":", "exprs", ")", "{", "for", "(", "String", ...
Verify if an expression from the input list is NULL-rejecting for any of the tables from the list @param tableAliases list of tables @param exprs list of expressions @return TRUE if there is a NULL-rejecting expression
[ "Verify", "if", "an", "expression", "from", "the", "input", "list", "is", "NULL", "-", "rejecting", "for", "any", "of", "the", "tables", "from", "the", "list" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/PlanAssembler.java#L3490-L3501
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.determineIndexOrdering
private int determineIndexOrdering(StmtTableScan tableScan, int keyComponentCount, List<AbstractExpression> indexedExprs, List<ColumnRef> indexedColRefs, AccessPath retval, int[] orderSpoilers, List<AbstractExpression> bindingsForOrder) { // Organize a little bit. ParsedSelectStmt pss = (m_parsedStmt instanceof ParsedSelectStmt) ? ((ParsedSelectStmt)m_parsedStmt) : null; boolean hasOrderBy = ( m_parsedStmt.hasOrderByColumns() && ( ! m_parsedStmt.orderByColumns().isEmpty() ) ); boolean hasWindowFunctions = (pss != null && pss.hasWindowFunctionExpression()); // // If we have no statement level order by or window functions, // then we can't use this index for ordering, and we // return 0. // if (! hasOrderBy && ! hasWindowFunctions) { return 0; } // // We make a definition. Let S1 and S2 be sequences of expressions, // and OS be an increasing sequence of indices into S2. Let erase(S2, OS) be // the sequence of expressions which results from erasing all S2 // expressions whose indices are in OS. We say *S1 is a prefix of // S2 with OS-singular values* if S1 is a prefix of erase(S2, OS). // That is to say, if we erase the expressions in S2 whose indices are // in OS, S1 is a prefix of the result. // // What expressions must we match? // 1.) We have the parameters indexedExpressions and indexedColRefs. // These are the expressions or column references in an index. // Exactly one of them is non-null. Since these are both an // indexed sequence of expression-like things, denote the // non-null one IS. // What expressions do we care about? We have two kinds. // 1.) The expressions from the statement level order by clause, OO. // This sequence of expressions must be a prefix of IS with OS // singular values for some sequence OS. The sequence OS will be // called the order spoilers. Later on we will test that the // index expressions at the positions in OS can have only a // single value. // 2.) The expressions in a window function's partition by list, WP, // followed by the expressions in the window function's // order by list, WO. The partition by functions are a set not // a sequence. We need to find a sequence of expressions, S, // such that S is a permutation of P and S+WO is a singular prefix // of IS. // // So, in both cases, statement level order by and window function, we are looking for // a sequence of expressions, S1, and a list of IS indices, OS, such // that S1 is a prefix of IS with OS-singular values. // // If the statement level order by expression list is not a prefix of // the index, we still care to know about window functions. The reverse // is not true. If there are window functions but they all fail to match the index, // we must give up on this index, even if the statement level order // by list is still matching. This is because the window functions will // require sorting before the statement level order by clause's // sort, and this window function sort will invalidate the statement level // order by sort. // // Note also that it's possible that the statement level order by and // the window function order by are compatible. So this index may provide // all the sorting needed. // // There need to be enough indexed expressions to provide full sort coverage. // More indexed expressions are ok. // // We keep a scoreboard which keeps track of everything. All the window // functions and statement level order by functions are kept in the scoreboard. // WindowFunctionScoreboard windowFunctionScores = new WindowFunctionScoreboard(m_parsedStmt, tableScan); // indexCtr is an index into the index expressions or columns. for (int indexCtr = 0; !windowFunctionScores.isDone() && indexCtr < keyComponentCount; indexCtr += 1) { // Figure out what to do with index expression or column at indexCtr. // First, fetch it out. AbstractExpression indexExpr = (indexedExprs == null) ? null : indexedExprs.get(indexCtr); ColumnRef indexColRef = (indexedColRefs == null) ? null : indexedColRefs.get(indexCtr); // Then see if it matches something. If // this doesn't match one thing it may match // another. If it doesn't match anything, it may // be an order spoiler, which we will maintain in // the scoreboard. windowFunctionScores.matchIndexEntry(new ExpressionOrColumn(indexCtr, tableScan, indexExpr, SortDirectionType.INVALID, indexColRef)); } // // The result is the number of order spoilers, but // also the access path we have chosen, the order // spoilers themselves and the bindings. Return these // by reference. // return windowFunctionScores.getResult(retval, orderSpoilers, bindingsForOrder); }
java
private int determineIndexOrdering(StmtTableScan tableScan, int keyComponentCount, List<AbstractExpression> indexedExprs, List<ColumnRef> indexedColRefs, AccessPath retval, int[] orderSpoilers, List<AbstractExpression> bindingsForOrder) { // Organize a little bit. ParsedSelectStmt pss = (m_parsedStmt instanceof ParsedSelectStmt) ? ((ParsedSelectStmt)m_parsedStmt) : null; boolean hasOrderBy = ( m_parsedStmt.hasOrderByColumns() && ( ! m_parsedStmt.orderByColumns().isEmpty() ) ); boolean hasWindowFunctions = (pss != null && pss.hasWindowFunctionExpression()); // // If we have no statement level order by or window functions, // then we can't use this index for ordering, and we // return 0. // if (! hasOrderBy && ! hasWindowFunctions) { return 0; } // // We make a definition. Let S1 and S2 be sequences of expressions, // and OS be an increasing sequence of indices into S2. Let erase(S2, OS) be // the sequence of expressions which results from erasing all S2 // expressions whose indices are in OS. We say *S1 is a prefix of // S2 with OS-singular values* if S1 is a prefix of erase(S2, OS). // That is to say, if we erase the expressions in S2 whose indices are // in OS, S1 is a prefix of the result. // // What expressions must we match? // 1.) We have the parameters indexedExpressions and indexedColRefs. // These are the expressions or column references in an index. // Exactly one of them is non-null. Since these are both an // indexed sequence of expression-like things, denote the // non-null one IS. // What expressions do we care about? We have two kinds. // 1.) The expressions from the statement level order by clause, OO. // This sequence of expressions must be a prefix of IS with OS // singular values for some sequence OS. The sequence OS will be // called the order spoilers. Later on we will test that the // index expressions at the positions in OS can have only a // single value. // 2.) The expressions in a window function's partition by list, WP, // followed by the expressions in the window function's // order by list, WO. The partition by functions are a set not // a sequence. We need to find a sequence of expressions, S, // such that S is a permutation of P and S+WO is a singular prefix // of IS. // // So, in both cases, statement level order by and window function, we are looking for // a sequence of expressions, S1, and a list of IS indices, OS, such // that S1 is a prefix of IS with OS-singular values. // // If the statement level order by expression list is not a prefix of // the index, we still care to know about window functions. The reverse // is not true. If there are window functions but they all fail to match the index, // we must give up on this index, even if the statement level order // by list is still matching. This is because the window functions will // require sorting before the statement level order by clause's // sort, and this window function sort will invalidate the statement level // order by sort. // // Note also that it's possible that the statement level order by and // the window function order by are compatible. So this index may provide // all the sorting needed. // // There need to be enough indexed expressions to provide full sort coverage. // More indexed expressions are ok. // // We keep a scoreboard which keeps track of everything. All the window // functions and statement level order by functions are kept in the scoreboard. // WindowFunctionScoreboard windowFunctionScores = new WindowFunctionScoreboard(m_parsedStmt, tableScan); // indexCtr is an index into the index expressions or columns. for (int indexCtr = 0; !windowFunctionScores.isDone() && indexCtr < keyComponentCount; indexCtr += 1) { // Figure out what to do with index expression or column at indexCtr. // First, fetch it out. AbstractExpression indexExpr = (indexedExprs == null) ? null : indexedExprs.get(indexCtr); ColumnRef indexColRef = (indexedColRefs == null) ? null : indexedColRefs.get(indexCtr); // Then see if it matches something. If // this doesn't match one thing it may match // another. If it doesn't match anything, it may // be an order spoiler, which we will maintain in // the scoreboard. windowFunctionScores.matchIndexEntry(new ExpressionOrColumn(indexCtr, tableScan, indexExpr, SortDirectionType.INVALID, indexColRef)); } // // The result is the number of order spoilers, but // also the access path we have chosen, the order // spoilers themselves and the bindings. Return these // by reference. // return windowFunctionScores.getResult(retval, orderSpoilers, bindingsForOrder); }
[ "private", "int", "determineIndexOrdering", "(", "StmtTableScan", "tableScan", ",", "int", "keyComponentCount", ",", "List", "<", "AbstractExpression", ">", "indexedExprs", ",", "List", "<", "ColumnRef", ">", "indexedColRefs", ",", "AccessPath", "retval", ",", "int"...
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. @param table only used here to validate base table names of ORDER BY columns' . @param bindingsForOrder restrictions on parameter settings that are prerequisite to the any ordering optimization determined here @param keyComponentCount the length of indexedExprs or indexedColRefs, ONE of which must be valid @param indexedExprs expressions for key components in the general case @param indexedColRefs column references for key components in the simpler case @param retval the eventual result of getRelevantAccessPathForIndex, the bearer of a (tentative) sortDirection determined here @param orderSpoilers positions of key components which MAY invalidate the tentative sortDirection @param bindingsForOrder restrictions on parameter settings that are prerequisite to the any ordering optimization determined here. @return the number of discovered orderSpoilers that will need to be recovered from, to maintain the established sortDirection - always 0 if no sort order was determined.
[ "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", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L1619-L1719
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.findBindingsForOneIndexedExpression
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 indexColRef = indexEntry.m_colRef; // This is a column. So try to match it // with the expression in nextStatementEOC. if (matchExpressionAndColumnRef(nextStatementExpr, indexColRef, indexEntry.m_tableScan)) { return s_reusableImmutableEmptyBinding; } return null; } // So, this index entry is an expression. List<AbstractExpression> moreBindings = nextStatementEOC.m_expr.bindingToIndexedExpression(indexEntry.m_expr); if (moreBindings != null) { return moreBindings; } return null; }
java
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 indexColRef = indexEntry.m_colRef; // This is a column. So try to match it // with the expression in nextStatementEOC. if (matchExpressionAndColumnRef(nextStatementExpr, indexColRef, indexEntry.m_tableScan)) { return s_reusableImmutableEmptyBinding; } return null; } // So, this index entry is an expression. List<AbstractExpression> moreBindings = nextStatementEOC.m_expr.bindingToIndexedExpression(indexEntry.m_expr); if (moreBindings != null) { return moreBindings; } return null; }
[ "private", "static", "List", "<", "AbstractExpression", ">", "findBindingsForOneIndexedExpression", "(", "ExpressionOrColumn", "nextStatementEOC", ",", "ExpressionOrColumn", "indexEntry", ")", "{", "assert", "(", "nextStatementEOC", ".", "m_expr", "!=", "null", ")", ";"...
Match the indexEntry, which is from an index, with a statement expression or column. The nextStatementEOC must be an expression, not a column reference. @param nextStatementEOC The expression or column in the SQL statement. @param indexEntry The expression or column in the index. @return A list of bindings for this match. Return null if there is no match. If there are no bindings but the expressions match, return an empty, non-null list.
[ "Match", "the", "indexEntry", "which", "is", "from", "an", "index", "with", "a", "statement", "expression", "or", "column", ".", "The", "nextStatementEOC", "must", "be", "an", "expression", "not", "a", "column", "reference", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L1733-L1754
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.removeExactMatchCoveredExpressions
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 (coveringExpr.bindingToIndexedExpression(exprToCover) != null) { iter.remove(); hasMatch = true; // need to keep going to remove all matches } } return hasMatch; }
java
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 (coveringExpr.bindingToIndexedExpression(exprToCover) != null) { iter.remove(); hasMatch = true; // need to keep going to remove all matches } } return hasMatch; }
[ "private", "static", "boolean", "removeExactMatchCoveredExpressions", "(", "AbstractExpression", "coveringExpr", ",", "List", "<", "AbstractExpression", ">", "exprsToCover", ")", "{", "boolean", "hasMatch", "=", "false", ";", "Iterator", "<", "AbstractExpression", ">", ...
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. @param coveringExpr @param exprsToCover @return true is the covering expression exactly matches to one or more expressions to cover
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L2020-L2034
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.removeNotNullCoveredExpressions
private static List<AbstractExpression> removeNotNullCoveredExpressions(StmtTableScan tableScan, List<AbstractExpression> coveringExprs, List<AbstractExpression> exprsToCover) { // Collect all TVEs from NULL-rejecting covering expressions Set<TupleValueExpression> coveringTves = new HashSet<>(); for (AbstractExpression coveringExpr : coveringExprs) { if (ExpressionUtil.isNullRejectingExpression(coveringExpr, tableScan.getTableAlias())) { coveringTves.addAll(ExpressionUtil.getTupleValueExpressions(coveringExpr)); } } // For each NOT NULL expression to cover extract the TVE expressions. If all of them are also part // of the covering NULL-rejecting collection then this NOT NULL expression is covered Iterator<AbstractExpression> iter = exprsToCover.iterator(); while (iter.hasNext()) { AbstractExpression filter = iter.next(); if (ExpressionType.OPERATOR_NOT == filter.getExpressionType()) { assert(filter.getLeft() != null); if (ExpressionType.OPERATOR_IS_NULL == filter.getLeft().getExpressionType()) { assert(filter.getLeft().getLeft() != null); List<TupleValueExpression> tves = ExpressionUtil.getTupleValueExpressions(filter.getLeft().getLeft()); if (coveringTves.containsAll(tves)) { iter.remove(); } } } } return exprsToCover; }
java
private static List<AbstractExpression> removeNotNullCoveredExpressions(StmtTableScan tableScan, List<AbstractExpression> coveringExprs, List<AbstractExpression> exprsToCover) { // Collect all TVEs from NULL-rejecting covering expressions Set<TupleValueExpression> coveringTves = new HashSet<>(); for (AbstractExpression coveringExpr : coveringExprs) { if (ExpressionUtil.isNullRejectingExpression(coveringExpr, tableScan.getTableAlias())) { coveringTves.addAll(ExpressionUtil.getTupleValueExpressions(coveringExpr)); } } // For each NOT NULL expression to cover extract the TVE expressions. If all of them are also part // of the covering NULL-rejecting collection then this NOT NULL expression is covered Iterator<AbstractExpression> iter = exprsToCover.iterator(); while (iter.hasNext()) { AbstractExpression filter = iter.next(); if (ExpressionType.OPERATOR_NOT == filter.getExpressionType()) { assert(filter.getLeft() != null); if (ExpressionType.OPERATOR_IS_NULL == filter.getLeft().getExpressionType()) { assert(filter.getLeft().getLeft() != null); List<TupleValueExpression> tves = ExpressionUtil.getTupleValueExpressions(filter.getLeft().getLeft()); if (coveringTves.containsAll(tves)) { iter.remove(); } } } } return exprsToCover; }
[ "private", "static", "List", "<", "AbstractExpression", ">", "removeNotNullCoveredExpressions", "(", "StmtTableScan", "tableScan", ",", "List", "<", "AbstractExpression", ">", "coveringExprs", ",", "List", "<", "AbstractExpression", ">", "exprsToCover", ")", "{", "// ...
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. @param tableScan @param coveringExprs @param exprsToCover @return List<AbstractExpression>
[ "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"...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L2045-L2070
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.addSendReceivePair
protected static AbstractPlanNode addSendReceivePair(AbstractPlanNode scanNode) { SendPlanNode sendNode = new SendPlanNode(); sendNode.addAndLinkChild(scanNode); ReceivePlanNode recvNode = new ReceivePlanNode(); recvNode.addAndLinkChild(sendNode); return recvNode; }
java
protected static AbstractPlanNode addSendReceivePair(AbstractPlanNode scanNode) { SendPlanNode sendNode = new SendPlanNode(); sendNode.addAndLinkChild(scanNode); ReceivePlanNode recvNode = new ReceivePlanNode(); recvNode.addAndLinkChild(sendNode); return recvNode; }
[ "protected", "static", "AbstractPlanNode", "addSendReceivePair", "(", "AbstractPlanNode", "scanNode", ")", "{", "SendPlanNode", "sendNode", "=", "new", "SendPlanNode", "(", ")", ";", "sendNode", ".", "addAndLinkChild", "(", "scanNode", ")", ";", "ReceivePlanNode", "...
Insert a send receive pair above the supplied scanNode. @param scanNode that needs to be distributed @return return the newly created receive node (which is linked to the new sends)
[ "Insert", "a", "send", "receive", "pair", "above", "the", "supplied", "scanNode", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L2133-L2141
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.getAccessPlanForTable
protected static AbstractPlanNode getAccessPlanForTable(JoinNode tableNode) { StmtTableScan tableScan = tableNode.getTableScan(); // Access path to access the data in the table (index/scan/etc). AccessPath path = tableNode.m_currentAccessPath; assert(path != null); // if no index, it is a sequential scan if (path.index == null) { return getScanAccessPlanForTable(tableScan, path); } return getIndexAccessPlanForTable(tableScan, path); }
java
protected static AbstractPlanNode getAccessPlanForTable(JoinNode tableNode) { StmtTableScan tableScan = tableNode.getTableScan(); // Access path to access the data in the table (index/scan/etc). AccessPath path = tableNode.m_currentAccessPath; assert(path != null); // if no index, it is a sequential scan if (path.index == null) { return getScanAccessPlanForTable(tableScan, path); } return getIndexAccessPlanForTable(tableScan, path); }
[ "protected", "static", "AbstractPlanNode", "getAccessPlanForTable", "(", "JoinNode", "tableNode", ")", "{", "StmtTableScan", "tableScan", "=", "tableNode", ".", "getTableScan", "(", ")", ";", "// Access path to access the data in the table (index/scan/etc).", "AccessPath", "p...
Given an access path, build the single-site or distributed plan that will assess the data from the table according to the path. @param table The table to get data from. @return The root of a plan graph to get the data.
[ "Given", "an", "access", "path", "build", "the", "single", "-", "site", "or", "distributed", "plan", "that", "will", "assess", "the", "data", "from", "the", "table", "according", "to", "the", "path", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L2150-L2161
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.getIndexAccessPlanForTable
private static AbstractPlanNode getIndexAccessPlanForTable( StmtTableScan tableScan, AccessPath path) { // now assume this will be an index scan and get the relevant index Index index = path.index; IndexScanPlanNode scanNode = new IndexScanPlanNode(tableScan, index); AbstractPlanNode resultNode = scanNode; // set sortDirection here because it might be used for IN list scanNode.setSortDirection(path.sortDirection); // Build the list of search-keys for the index in question // They are the rhs expressions of normalized indexExpr comparisons // except for geo indexes. For geo indexes, the search key is directly // the one element of indexExprs. for (AbstractExpression expr : path.indexExprs) { if (path.lookupType == IndexLookupType.GEO_CONTAINS) { scanNode.addSearchKeyExpression(expr); scanNode.addCompareNotDistinctFlag(false); continue; } AbstractExpression exprRightChild = expr.getRight(); assert(exprRightChild != null); if (expr.getExpressionType() == ExpressionType.COMPARE_IN) { // Replace this method's result with an injected NLIJ. resultNode = injectIndexedJoinWithMaterializedScan(exprRightChild, scanNode); // Extract a TVE from the LHS MaterializedScan for use by the IndexScan in its new role. MaterializedScanPlanNode matscan = (MaterializedScanPlanNode)resultNode.getChild(0); AbstractExpression elemExpr = matscan.getOutputExpression(); assert(elemExpr != null); // Replace the IN LIST condition in the end expression referencing all the list elements // with a more efficient equality filter referencing the TVE for each element in turn. replaceInListFilterWithEqualityFilter(path.endExprs, exprRightChild, elemExpr); // Set up the similar VectorValue --> TVE replacement of the search key expression. exprRightChild = elemExpr; } if (exprRightChild instanceof AbstractSubqueryExpression) { // The AbstractSubqueryExpression must be wrapped up into a // ScalarValueExpression which extracts the actual row/column from // the subquery // ENG-8175: this part of code seems not working for float/varchar type index ?! // DEAD CODE with the guards on index: ENG-8203 assert(false); } scanNode.addSearchKeyExpression(exprRightChild); // If the index expression is an "IS NOT DISTINCT FROM" comparison, let the NULL values go through. (ENG-11096) scanNode.addCompareNotDistinctFlag(expr.getExpressionType() == ExpressionType.COMPARE_NOTDISTINCT); } // create the IndexScanNode with all its metadata scanNode.setLookupType(path.lookupType); scanNode.setBindings(path.bindings); scanNode.setEndExpression(ExpressionUtil.combinePredicates(path.endExprs)); if (! path.index.getPredicatejson().isEmpty()) { try { scanNode.setPartialIndexPredicate( AbstractExpression.fromJSONString(path.index.getPredicatejson(), tableScan)); } catch (JSONException e) { throw new PlanningErrorException(e.getMessage(), 0); } } scanNode.setPredicate(path.otherExprs); // Propagate the sorting information // into the scan node from the access path. // The initial expression is needed to control a (short?) forward scan to adjust the start of a reverse // iteration after it had to initially settle for starting at "greater than a prefix key". scanNode.setInitialExpression(ExpressionUtil.combinePredicates(path.initialExpr)); scanNode.setSkipNullPredicate(); scanNode.setEliminatedPostFilters(path.eliminatedPostExprs); final IndexUseForOrderBy indexUse = scanNode.indexUse(); indexUse.setWindowFunctionUsesIndex(path.m_windowFunctionUsesIndex); indexUse.setSortOrderFromIndexScan(path.sortDirection); indexUse.setWindowFunctionIsCompatibleWithOrderBy(path.m_stmtOrderByIsCompatible); indexUse.setFinalExpressionOrderFromIndexScan(path.m_finalExpressionOrder); return resultNode; }
java
private static AbstractPlanNode getIndexAccessPlanForTable( StmtTableScan tableScan, AccessPath path) { // now assume this will be an index scan and get the relevant index Index index = path.index; IndexScanPlanNode scanNode = new IndexScanPlanNode(tableScan, index); AbstractPlanNode resultNode = scanNode; // set sortDirection here because it might be used for IN list scanNode.setSortDirection(path.sortDirection); // Build the list of search-keys for the index in question // They are the rhs expressions of normalized indexExpr comparisons // except for geo indexes. For geo indexes, the search key is directly // the one element of indexExprs. for (AbstractExpression expr : path.indexExprs) { if (path.lookupType == IndexLookupType.GEO_CONTAINS) { scanNode.addSearchKeyExpression(expr); scanNode.addCompareNotDistinctFlag(false); continue; } AbstractExpression exprRightChild = expr.getRight(); assert(exprRightChild != null); if (expr.getExpressionType() == ExpressionType.COMPARE_IN) { // Replace this method's result with an injected NLIJ. resultNode = injectIndexedJoinWithMaterializedScan(exprRightChild, scanNode); // Extract a TVE from the LHS MaterializedScan for use by the IndexScan in its new role. MaterializedScanPlanNode matscan = (MaterializedScanPlanNode)resultNode.getChild(0); AbstractExpression elemExpr = matscan.getOutputExpression(); assert(elemExpr != null); // Replace the IN LIST condition in the end expression referencing all the list elements // with a more efficient equality filter referencing the TVE for each element in turn. replaceInListFilterWithEqualityFilter(path.endExprs, exprRightChild, elemExpr); // Set up the similar VectorValue --> TVE replacement of the search key expression. exprRightChild = elemExpr; } if (exprRightChild instanceof AbstractSubqueryExpression) { // The AbstractSubqueryExpression must be wrapped up into a // ScalarValueExpression which extracts the actual row/column from // the subquery // ENG-8175: this part of code seems not working for float/varchar type index ?! // DEAD CODE with the guards on index: ENG-8203 assert(false); } scanNode.addSearchKeyExpression(exprRightChild); // If the index expression is an "IS NOT DISTINCT FROM" comparison, let the NULL values go through. (ENG-11096) scanNode.addCompareNotDistinctFlag(expr.getExpressionType() == ExpressionType.COMPARE_NOTDISTINCT); } // create the IndexScanNode with all its metadata scanNode.setLookupType(path.lookupType); scanNode.setBindings(path.bindings); scanNode.setEndExpression(ExpressionUtil.combinePredicates(path.endExprs)); if (! path.index.getPredicatejson().isEmpty()) { try { scanNode.setPartialIndexPredicate( AbstractExpression.fromJSONString(path.index.getPredicatejson(), tableScan)); } catch (JSONException e) { throw new PlanningErrorException(e.getMessage(), 0); } } scanNode.setPredicate(path.otherExprs); // Propagate the sorting information // into the scan node from the access path. // The initial expression is needed to control a (short?) forward scan to adjust the start of a reverse // iteration after it had to initially settle for starting at "greater than a prefix key". scanNode.setInitialExpression(ExpressionUtil.combinePredicates(path.initialExpr)); scanNode.setSkipNullPredicate(); scanNode.setEliminatedPostFilters(path.eliminatedPostExprs); final IndexUseForOrderBy indexUse = scanNode.indexUse(); indexUse.setWindowFunctionUsesIndex(path.m_windowFunctionUsesIndex); indexUse.setSortOrderFromIndexScan(path.sortDirection); indexUse.setWindowFunctionIsCompatibleWithOrderBy(path.m_stmtOrderByIsCompatible); indexUse.setFinalExpressionOrderFromIndexScan(path.m_finalExpressionOrder); return resultNode; }
[ "private", "static", "AbstractPlanNode", "getIndexAccessPlanForTable", "(", "StmtTableScan", "tableScan", ",", "AccessPath", "path", ")", "{", "// now assume this will be an index scan and get the relevant index", "Index", "index", "=", "path", ".", "index", ";", "IndexScanPl...
Get an index scan access plan for a table. @param tableAliasIndex The table to get data from. @param path The access path to access the data in the table (index/scan/etc). @return An index scan plan node OR, in one edge case, an NLIJ of a MaterializedScan and an index scan plan node.
[ "Get", "an", "index", "scan", "access", "plan", "for", "a", "table", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L2189-L2261
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.injectIndexedJoinWithMaterializedScan
private static AbstractPlanNode injectIndexedJoinWithMaterializedScan( AbstractExpression listElements, IndexScanPlanNode scanNode) { MaterializedScanPlanNode matScan = new MaterializedScanPlanNode(); assert(listElements instanceof VectorValueExpression || listElements instanceof ParameterValueExpression); matScan.setRowData(listElements); matScan.setSortDirection(scanNode.getSortDirection()); NestLoopIndexPlanNode nlijNode = new NestLoopIndexPlanNode(); nlijNode.setJoinType(JoinType.INNER); nlijNode.addInlinePlanNode(scanNode); nlijNode.addAndLinkChild(matScan); // resolve the sort direction nlijNode.resolveSortDirection(); return nlijNode; }
java
private static AbstractPlanNode injectIndexedJoinWithMaterializedScan( AbstractExpression listElements, IndexScanPlanNode scanNode) { MaterializedScanPlanNode matScan = new MaterializedScanPlanNode(); assert(listElements instanceof VectorValueExpression || listElements instanceof ParameterValueExpression); matScan.setRowData(listElements); matScan.setSortDirection(scanNode.getSortDirection()); NestLoopIndexPlanNode nlijNode = new NestLoopIndexPlanNode(); nlijNode.setJoinType(JoinType.INNER); nlijNode.addInlinePlanNode(scanNode); nlijNode.addAndLinkChild(matScan); // resolve the sort direction nlijNode.resolveSortDirection(); return nlijNode; }
[ "private", "static", "AbstractPlanNode", "injectIndexedJoinWithMaterializedScan", "(", "AbstractExpression", "listElements", ",", "IndexScanPlanNode", "scanNode", ")", "{", "MaterializedScanPlanNode", "matScan", "=", "new", "MaterializedScanPlanNode", "(", ")", ";", "assert",...
Generate a plan for an IN-LIST-driven index scan
[ "Generate", "a", "plan", "for", "an", "IN", "-", "LIST", "-", "driven", "index", "scan" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L2265-L2279
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/SubPlanAssembler.java
SubPlanAssembler.replaceInListFilterWithEqualityFilter
private static void replaceInListFilterWithEqualityFilter(List<AbstractExpression> endExprs, AbstractExpression inListRhs, AbstractExpression equalityRhs) { for (AbstractExpression comparator : endExprs) { AbstractExpression otherExpr = comparator.getRight(); if (otherExpr == inListRhs) { endExprs.remove(comparator); AbstractExpression replacement = new ComparisonExpression(ExpressionType.COMPARE_EQUAL, comparator.getLeft(), equalityRhs); endExprs.add(replacement); break; } } }
java
private static void replaceInListFilterWithEqualityFilter(List<AbstractExpression> endExprs, AbstractExpression inListRhs, AbstractExpression equalityRhs) { for (AbstractExpression comparator : endExprs) { AbstractExpression otherExpr = comparator.getRight(); if (otherExpr == inListRhs) { endExprs.remove(comparator); AbstractExpression replacement = new ComparisonExpression(ExpressionType.COMPARE_EQUAL, comparator.getLeft(), equalityRhs); endExprs.add(replacement); break; } } }
[ "private", "static", "void", "replaceInListFilterWithEqualityFilter", "(", "List", "<", "AbstractExpression", ">", "endExprs", ",", "AbstractExpression", "inListRhs", ",", "AbstractExpression", "equalityRhs", ")", "{", "for", "(", "AbstractExpression", "comparator", ":", ...
with an equality filter referencing the second given rhs.
[ "with", "an", "equality", "filter", "referencing", "the", "second", "given", "rhs", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L2284-L2300
train
VoltDB/voltdb
examples/callcenter/client/callcenter/CallSimulator.java
CallSimulator.makeRandomEvent
CallEvent[] makeRandomEvent() { long callId = ++lastCallIdUsed; // get agentid Integer agentId = agentsAvailable.poll(); if (agentId == null) { return null; } // get phone number Long phoneNo = phoneNumbersAvailable.poll(); assert(phoneNo != null); // voltdb timestamp type uses micros from epoch Date startTS = new Date(currentSystemMilliTimestamp); long durationms = -1; long meancalldurationms = config.meancalldurationseconds * 1000; long maxcalldurationms = config.maxcalldurationseconds * 1000; double stddev = meancalldurationms / 2.0; // repeat until in the range (0..maxcalldurationms] while ((durationms <= 0) || (durationms > maxcalldurationms)) { durationms = (long) (rand.nextGaussian() * stddev) + meancalldurationms; } Date endTS = new Date(startTS.getTime() + durationms); CallEvent[] event = new CallEvent[2]; event[0] = new CallEvent(callId, agentId, phoneNo, startTS, null); event[1] = new CallEvent(callId, agentId, phoneNo, null, endTS); // some debugging code //System.out.println("Creating event with range:"); //System.out.println(new Date(startTS.getTime() / 1000)); //System.out.println(new Date(endTS.getTime() / 1000)); return event; }
java
CallEvent[] makeRandomEvent() { long callId = ++lastCallIdUsed; // get agentid Integer agentId = agentsAvailable.poll(); if (agentId == null) { return null; } // get phone number Long phoneNo = phoneNumbersAvailable.poll(); assert(phoneNo != null); // voltdb timestamp type uses micros from epoch Date startTS = new Date(currentSystemMilliTimestamp); long durationms = -1; long meancalldurationms = config.meancalldurationseconds * 1000; long maxcalldurationms = config.maxcalldurationseconds * 1000; double stddev = meancalldurationms / 2.0; // repeat until in the range (0..maxcalldurationms] while ((durationms <= 0) || (durationms > maxcalldurationms)) { durationms = (long) (rand.nextGaussian() * stddev) + meancalldurationms; } Date endTS = new Date(startTS.getTime() + durationms); CallEvent[] event = new CallEvent[2]; event[0] = new CallEvent(callId, agentId, phoneNo, startTS, null); event[1] = new CallEvent(callId, agentId, phoneNo, null, endTS); // some debugging code //System.out.println("Creating event with range:"); //System.out.println(new Date(startTS.getTime() / 1000)); //System.out.println(new Date(endTS.getTime() / 1000)); return event; }
[ "CallEvent", "[", "]", "makeRandomEvent", "(", ")", "{", "long", "callId", "=", "++", "lastCallIdUsed", ";", "// get agentid", "Integer", "agentId", "=", "agentsAvailable", ".", "poll", "(", ")", ";", "if", "(", "agentId", "==", "null", ")", "{", "return",...
Generate a random call event with a duration. Reserves agent and phone number from the pool.
[ "Generate", "a", "random", "call", "event", "with", "a", "duration", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/examples/callcenter/client/callcenter/CallSimulator.java#L86-L123
train
VoltDB/voltdb
examples/callcenter/client/callcenter/CallSimulator.java
CallSimulator.next
@Override public CallEvent next(long systemCurrentTimeMillis) { // check for time passing if (systemCurrentTimeMillis > currentSystemMilliTimestamp) { // build a target for this 1ms window long eventBacklog = targetEventsThisMillisecond - eventsSoFarThisMillisecond; targetEventsThisMillisecond = (long) Math.floor(targetEventsPerMillisecond); double targetFraction = targetEventsPerMillisecond - targetEventsThisMillisecond; targetEventsThisMillisecond += (rand.nextDouble() <= targetFraction) ? 1 : 0; targetEventsThisMillisecond += eventBacklog; // reset counter for this 1ms window eventsSoFarThisMillisecond = 0; currentSystemMilliTimestamp = systemCurrentTimeMillis; } // drain scheduled events first CallEvent callEvent = delayedEvents.nextReady(systemCurrentTimeMillis); if (callEvent != null) { // double check this is an end event assert(callEvent.startTS == null); assert(callEvent.endTS != null); // return the agent/phone for this event to the available lists agentsAvailable.add(callEvent.agentId); phoneNumbersAvailable.add(callEvent.phoneNo); validate(); return callEvent; } // check if we made all the target events for this 1ms window if (targetEventsThisMillisecond == eventsSoFarThisMillisecond) { validate(); return null; } // generate rando event (begin/end pair) CallEvent[] event = makeRandomEvent(); // this means all agents are busy if (event == null) { validate(); return null; } // schedule the end event long endTimeKey = event[1].endTS.getTime(); assert((endTimeKey - systemCurrentTimeMillis) < (config.maxcalldurationseconds * 1000)); delayedEvents.add(endTimeKey, event[1]); eventsSoFarThisMillisecond++; validate(); return event[0]; }
java
@Override public CallEvent next(long systemCurrentTimeMillis) { // check for time passing if (systemCurrentTimeMillis > currentSystemMilliTimestamp) { // build a target for this 1ms window long eventBacklog = targetEventsThisMillisecond - eventsSoFarThisMillisecond; targetEventsThisMillisecond = (long) Math.floor(targetEventsPerMillisecond); double targetFraction = targetEventsPerMillisecond - targetEventsThisMillisecond; targetEventsThisMillisecond += (rand.nextDouble() <= targetFraction) ? 1 : 0; targetEventsThisMillisecond += eventBacklog; // reset counter for this 1ms window eventsSoFarThisMillisecond = 0; currentSystemMilliTimestamp = systemCurrentTimeMillis; } // drain scheduled events first CallEvent callEvent = delayedEvents.nextReady(systemCurrentTimeMillis); if (callEvent != null) { // double check this is an end event assert(callEvent.startTS == null); assert(callEvent.endTS != null); // return the agent/phone for this event to the available lists agentsAvailable.add(callEvent.agentId); phoneNumbersAvailable.add(callEvent.phoneNo); validate(); return callEvent; } // check if we made all the target events for this 1ms window if (targetEventsThisMillisecond == eventsSoFarThisMillisecond) { validate(); return null; } // generate rando event (begin/end pair) CallEvent[] event = makeRandomEvent(); // this means all agents are busy if (event == null) { validate(); return null; } // schedule the end event long endTimeKey = event[1].endTS.getTime(); assert((endTimeKey - systemCurrentTimeMillis) < (config.maxcalldurationseconds * 1000)); delayedEvents.add(endTimeKey, event[1]); eventsSoFarThisMillisecond++; validate(); return event[0]; }
[ "@", "Override", "public", "CallEvent", "next", "(", "long", "systemCurrentTimeMillis", ")", "{", "// check for time passing", "if", "(", "systemCurrentTimeMillis", ">", "currentSystemMilliTimestamp", ")", "{", "// build a target for this 1ms window", "long", "eventBacklog", ...
Return the next call event that is safe for delivery or null if there are no safe objects to deliver. Null response could mean empty, or could mean all objects are scheduled for the future. @param systemCurrentTimeMillis The current time. @return CallEvent
[ "Return", "the", "next", "call", "event", "that", "is", "safe", "for", "delivery", "or", "null", "if", "there", "are", "no", "safe", "objects", "to", "deliver", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/examples/callcenter/client/callcenter/CallSimulator.java#L135-L188
train
VoltDB/voltdb
examples/callcenter/client/callcenter/CallSimulator.java
CallSimulator.validate
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.format("outstandingAgents (%d) != outstandingPhones (%d)", outstandingAgents, outstandingPhones)); } if (outstandingAgents != delayedEventCount) { throw new RuntimeException( String.format("outstandingAgents (%d) != delayedEventCount (%d)", outstandingAgents, delayedEventCount)); } }
java
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.format("outstandingAgents (%d) != outstandingPhones (%d)", outstandingAgents, outstandingPhones)); } if (outstandingAgents != delayedEventCount) { throw new RuntimeException( String.format("outstandingAgents (%d) != delayedEventCount (%d)", outstandingAgents, delayedEventCount)); } }
[ "private", "void", "validate", "(", ")", "{", "long", "delayedEventCount", "=", "delayedEvents", ".", "size", "(", ")", ";", "long", "outstandingAgents", "=", "config", ".", "agents", "-", "agentsAvailable", ".", "size", "(", ")", ";", "long", "outstandingPh...
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.
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/examples/callcenter/client/callcenter/CallSimulator.java#L219-L235
train
VoltDB/voltdb
examples/callcenter/client/callcenter/CallSimulator.java
CallSimulator.printSummary
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()); }
java
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()); }
[ "void", "printSummary", "(", ")", "{", "System", ".", "out", ".", "printf", "(", "\"There are %d agents outstanding and %d phones. %d entries waiting to go.\\n\"", ",", "agentsAvailable", ".", "size", "(", ")", ",", "phoneNumbersAvailable", ".", "size", "(", ")", ",",...
Debug statement to help users verify there are no lost or delayed events.
[ "Debug", "statement", "to", "help", "users", "verify", "there", "are", "no", "lost", "or", "delayed", "events", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/examples/callcenter/client/callcenter/CallSimulator.java#L240-L243
train
VoltDB/voltdb
third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java
DefaultParser.isNegativeNumber
private boolean isNegativeNumber(String token) { try { Double.parseDouble(token); return true; } catch (NumberFormatException e) { return false; } }
java
private boolean isNegativeNumber(String token) { try { Double.parseDouble(token); return true; } catch (NumberFormatException e) { return false; } }
[ "private", "boolean", "isNegativeNumber", "(", "String", "token", ")", "{", "try", "{", "Double", ".", "parseDouble", "(", "token", ")", ";", "return", "true", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "false", ";", "}", "...
Check if the token is a negative number. @param token
[ "Check", "if", "the", "token", "is", "a", "negative", "number", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java#L271-L282
train
VoltDB/voltdb
third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java
DefaultParser.isLongOption
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()) { // long or partial long options (--L, -L, --L=V, -L=V, --l, --l=V) return true; } else if (getLongPrefix(token) != null && !token.startsWith("--")) { // -LV return true; } return false; }
java
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()) { // long or partial long options (--L, -L, --L=V, -L=V, --l, --l=V) return true; } else if (getLongPrefix(token) != null && !token.startsWith("--")) { // -LV return true; } return false; }
[ "private", "boolean", "isLongOption", "(", "String", "token", ")", "{", "if", "(", "!", "token", ".", "startsWith", "(", "\"-\"", ")", "||", "token", ".", "length", "(", ")", "==", "1", ")", "{", "return", "false", ";", "}", "int", "pos", "=", "tok...
Tells if the token looks like a long option. @param token
[ "Tells", "if", "the", "token", "looks", "like", "a", "long", "option", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java#L310-L332
train
VoltDB/voltdb
third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java
DefaultParser.handleUnknownToken
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; } }
java
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; } }
[ "private", "void", "handleUnknownToken", "(", "String", "token", ")", "throws", "ParseException", "{", "if", "(", "token", ".", "startsWith", "(", "\"-\"", ")", "&&", "token", ".", "length", "(", ")", ">", "1", "&&", "!", "stopAtNonOption", ")", "{", "th...
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. @param token the command line token to handle
[ "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", "."...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java#L343-L355
train
VoltDB/voltdb
src/frontend/org/voltdb/SQLStmt.java
SQLStmt.getText
public String getText() { if (sqlTextStr == null) { sqlTextStr = new String(sqlText, Constants.UTF8ENCODING); } return sqlTextStr; }
java
public String getText() { if (sqlTextStr == null) { sqlTextStr = new String(sqlText, Constants.UTF8ENCODING); } return sqlTextStr; }
[ "public", "String", "getText", "(", ")", "{", "if", "(", "sqlTextStr", "==", "null", ")", "{", "sqlTextStr", "=", "new", "String", "(", "sqlText", ",", "Constants", ".", "UTF8ENCODING", ")", ";", "}", "return", "sqlTextStr", ";", "}" ]
Get the text of the SQL statement represented. @return String containing the text of the SQL statement represented.
[ "Get", "the", "text", "of", "the", "SQL", "statement", "represented", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/SQLStmt.java#L201-L206
train
VoltDB/voltdb
src/frontend/org/voltdb/SQLStmt.java
SQLStmt.canonicalizeStmt
public static String canonicalizeStmt(String stmtStr) { // Cleanup whitespace newlines and adding semicolon for catalog compatibility stmtStr = stmtStr.replaceAll("\n", " "); stmtStr = stmtStr.trim(); if (!stmtStr.endsWith(";")) { stmtStr += ";"; } return stmtStr; }
java
public static String canonicalizeStmt(String stmtStr) { // Cleanup whitespace newlines and adding semicolon for catalog compatibility stmtStr = stmtStr.replaceAll("\n", " "); stmtStr = stmtStr.trim(); if (!stmtStr.endsWith(";")) { stmtStr += ";"; } return stmtStr; }
[ "public", "static", "String", "canonicalizeStmt", "(", "String", "stmtStr", ")", "{", "// Cleanup whitespace newlines and adding semicolon for catalog compatibility", "stmtStr", "=", "stmtStr", ".", "replaceAll", "(", "\"\\n\"", ",", "\" \"", ")", ";", "stmtStr", "=", "...
use the same statement to compute crc.
[ "use", "the", "same", "statement", "to", "compute", "crc", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/SQLStmt.java#L229-L238
train
VoltDB/voltdb
third_party/java/src/com/google_voltpatches/common/net/PercentEscaper.java
PercentEscaper.createSafeOctets
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; } return octets; }
java
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; } return octets; }
[ "private", "static", "boolean", "[", "]", "createSafeOctets", "(", "String", "safeChars", ")", "{", "int", "maxChar", "=", "-", "1", ";", "char", "[", "]", "safeCharArray", "=", "safeChars", ".", "toCharArray", "(", ")", ";", "for", "(", "char", "c", "...
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.
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/net/PercentEscaper.java#L111-L122
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/ExpressionColumn.java
ExpressionColumn.getTableName
String getTableName() { if (opType == OpTypes.MULTICOLUMN) { return tableName; } if (opType == OpTypes.COLUMN) { if (rangeVariable == null) { return tableName; } return rangeVariable.getTable().getName().name; } return ""; }
java
String getTableName() { if (opType == OpTypes.MULTICOLUMN) { return tableName; } if (opType == OpTypes.COLUMN) { if (rangeVariable == null) { return tableName; } return rangeVariable.getTable().getName().name; } return ""; }
[ "String", "getTableName", "(", ")", "{", "if", "(", "opType", "==", "OpTypes", ".", "MULTICOLUMN", ")", "{", "return", "tableName", ";", "}", "if", "(", "opType", "==", "OpTypes", ".", "COLUMN", ")", "{", "if", "(", "rangeVariable", "==", "null", ")", ...
Returns the table name for a column expression as a string @return table name
[ "Returns", "the", "table", "name", "for", "a", "column", "expression", "as", "a", "string" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/ExpressionColumn.java#L770-L782
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/ExpressionColumn.java
ExpressionColumn.voltAnnotateColumnXML
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.tableAlias.name.toUpperCase()); } else { exp.attributes.put("table", tableName.toUpperCase()); } } exp.attributes.put("column", columnName.toUpperCase()); if ((alias == null) || (getAlias().length() == 0)) { exp.attributes.put("alias", columnName.toUpperCase()); } if (rangeVariable != null && rangeVariable.tableAlias != null) { exp.attributes.put("tablealias", rangeVariable.tableAlias.name.toUpperCase()); } exp.attributes.put("index", Integer.toString(columnIndex)); return exp; }
java
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.tableAlias.name.toUpperCase()); } else { exp.attributes.put("table", tableName.toUpperCase()); } } exp.attributes.put("column", columnName.toUpperCase()); if ((alias == null) || (getAlias().length() == 0)) { exp.attributes.put("alias", columnName.toUpperCase()); } if (rangeVariable != null && rangeVariable.tableAlias != null) { exp.attributes.put("tablealias", rangeVariable.tableAlias.name.toUpperCase()); } exp.attributes.put("index", Integer.toString(columnIndex)); return exp; }
[ "VoltXMLElement", "voltAnnotateColumnXML", "(", "VoltXMLElement", "exp", ")", "{", "if", "(", "tableName", "!=", "null", ")", "{", "if", "(", "rangeVariable", "!=", "null", "&&", "rangeVariable", ".", "rangeTable", "!=", "null", "&&", "rangeVariable", ".", "ta...
VoltDB added method to provide detail for a non-catalog-dependent representation of this HSQLDB object. @return XML, correctly indented, representing this object.
[ "VoltDB", "added", "method", "to", "provide", "detail", "for", "a", "non", "-", "catalog", "-", "dependent", "representation", "of", "this", "HSQLDB", "object", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/ExpressionColumn.java#L1320-L1340
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.parseTablesAndParams
void parseTablesAndParams(VoltXMLElement root) { // Parse parameters first to satisfy a dependency of expression parsing // which happens during table scan parsing. parseParameters(root); parseCommonTableExpressions(root); for (VoltXMLElement node : root.children) { if (node.name.equalsIgnoreCase("tablescan")) { parseTable(node); } else if (node.name.equalsIgnoreCase("tablescans")) { parseTables(node); } } }
java
void parseTablesAndParams(VoltXMLElement root) { // Parse parameters first to satisfy a dependency of expression parsing // which happens during table scan parsing. parseParameters(root); parseCommonTableExpressions(root); for (VoltXMLElement node : root.children) { if (node.name.equalsIgnoreCase("tablescan")) { parseTable(node); } else if (node.name.equalsIgnoreCase("tablescans")) { parseTables(node); } } }
[ "void", "parseTablesAndParams", "(", "VoltXMLElement", "root", ")", "{", "// Parse parameters first to satisfy a dependency of expression parsing", "// which happens during table scan parsing.", "parseParameters", "(", "root", ")", ";", "parseCommonTableExpressions", "(", "root", "...
Parse tables and parameters . @param root @param db
[ "Parse", "tables", "and", "parameters", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L283-L299
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.parseExpressionNode
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 + "'"); } AbstractExpression retval = parser.parse(this, exprNode); assert("asterisk".equals(elementName) || retval != null); return retval; }
java
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 + "'"); } AbstractExpression retval = parser.parse(this, exprNode); assert("asterisk".equals(elementName) || retval != null); return retval; }
[ "private", "AbstractExpression", "parseExpressionNode", "(", "VoltXMLElement", "exprNode", ")", "{", "String", "elementName", "=", "exprNode", ".", "name", ".", "toLowerCase", "(", ")", ";", "XMLElementExpressionParser", "parser", "=", "m_exprParsers", ".", "get", "...
Given a VoltXMLElement expression node, translate it into an AbstractExpression. This is mostly a lookup in the table m_exprParsers.
[ "Given", "a", "VoltXMLElement", "expression", "node", "translate", "it", "into", "an", "AbstractExpression", ".", "This", "is", "mostly", "a", "lookup", "in", "the", "table", "m_exprParsers", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L400-L410
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.parseVectorExpression
private AbstractExpression parseVectorExpression(VoltXMLElement exprNode) { ArrayList<AbstractExpression> args = new ArrayList<>(); for (VoltXMLElement argNode : exprNode.children) { assert(argNode != null); // recursively parse each argument subtree (could be any kind of expression). AbstractExpression argExpr = parseExpressionNode(argNode); assert(argExpr != null); args.add(argExpr); } VectorValueExpression vve = new VectorValueExpression(); vve.setValueType(VoltType.VOLTTABLE); vve.setArgs(args); return vve; }
java
private AbstractExpression parseVectorExpression(VoltXMLElement exprNode) { ArrayList<AbstractExpression> args = new ArrayList<>(); for (VoltXMLElement argNode : exprNode.children) { assert(argNode != null); // recursively parse each argument subtree (could be any kind of expression). AbstractExpression argExpr = parseExpressionNode(argNode); assert(argExpr != null); args.add(argExpr); } VectorValueExpression vve = new VectorValueExpression(); vve.setValueType(VoltType.VOLTTABLE); vve.setArgs(args); return vve; }
[ "private", "AbstractExpression", "parseVectorExpression", "(", "VoltXMLElement", "exprNode", ")", "{", "ArrayList", "<", "AbstractExpression", ">", "args", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "VoltXMLElement", "argNode", ":", "exprNode", ".",...
Parse a Vector value for SQL-IN
[ "Parse", "a", "Vector", "value", "for", "SQL", "-", "IN" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L415-L429
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.parseSubqueryExpression
private SelectSubqueryExpression parseSubqueryExpression(VoltXMLElement exprNode) { assert(exprNode.children.size() == 1); VoltXMLElement subqueryElmt = exprNode.children.get(0); AbstractParsedStmt subqueryStmt = parseSubquery(subqueryElmt); // add table to the query cache String withoutAlias = null; StmtSubqueryScan stmtSubqueryScan = addSubqueryToStmtCache(subqueryStmt, withoutAlias); // Set to the default SELECT_SUBQUERY. May be overridden depending on the context return new SelectSubqueryExpression(ExpressionType.SELECT_SUBQUERY, stmtSubqueryScan); }
java
private SelectSubqueryExpression parseSubqueryExpression(VoltXMLElement exprNode) { assert(exprNode.children.size() == 1); VoltXMLElement subqueryElmt = exprNode.children.get(0); AbstractParsedStmt subqueryStmt = parseSubquery(subqueryElmt); // add table to the query cache String withoutAlias = null; StmtSubqueryScan stmtSubqueryScan = addSubqueryToStmtCache(subqueryStmt, withoutAlias); // Set to the default SELECT_SUBQUERY. May be overridden depending on the context return new SelectSubqueryExpression(ExpressionType.SELECT_SUBQUERY, stmtSubqueryScan); }
[ "private", "SelectSubqueryExpression", "parseSubqueryExpression", "(", "VoltXMLElement", "exprNode", ")", "{", "assert", "(", "exprNode", ".", "children", ".", "size", "(", ")", "==", "1", ")", ";", "VoltXMLElement", "subqueryElmt", "=", "exprNode", ".", "children...
Parse an expression subquery
[ "Parse", "an", "expression", "subquery" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L596-L606
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.resolveStmtTableScanByAlias
private StmtTableScan resolveStmtTableScanByAlias(String tableAlias) { StmtTableScan tableScan = getStmtTableScanByAlias(tableAlias); if (tableScan != null) { return tableScan; } if (m_parentStmt != null) { // This may be a correlated subquery return m_parentStmt.resolveStmtTableScanByAlias(tableAlias); } return null; }
java
private StmtTableScan resolveStmtTableScanByAlias(String tableAlias) { StmtTableScan tableScan = getStmtTableScanByAlias(tableAlias); if (tableScan != null) { return tableScan; } if (m_parentStmt != null) { // This may be a correlated subquery return m_parentStmt.resolveStmtTableScanByAlias(tableAlias); } return null; }
[ "private", "StmtTableScan", "resolveStmtTableScanByAlias", "(", "String", "tableAlias", ")", "{", "StmtTableScan", "tableScan", "=", "getStmtTableScanByAlias", "(", "tableAlias", ")", ";", "if", "(", "tableScan", "!=", "null", ")", "{", "return", "tableScan", ";", ...
Return StmtTableScan by table alias. In case of correlated queries, may need to walk up the statement tree. @param tableAlias
[ "Return", "StmtTableScan", "by", "table", "alias", ".", "In", "case", "of", "correlated", "queries", "may", "need", "to", "walk", "up", "the", "statement", "tree", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L786-L796
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.addTableToStmtCache
protected StmtTableScan addTableToStmtCache(Table table, String tableAlias) { // Create an index into the query Catalog cache StmtTableScan tableScan = m_tableAliasMap.get(tableAlias); if (tableScan == null) { tableScan = new StmtTargetTableScan(table, tableAlias, m_stmtId); m_tableAliasMap.put(tableAlias, tableScan); } return tableScan; }
java
protected StmtTableScan addTableToStmtCache(Table table, String tableAlias) { // Create an index into the query Catalog cache StmtTableScan tableScan = m_tableAliasMap.get(tableAlias); if (tableScan == null) { tableScan = new StmtTargetTableScan(table, tableAlias, m_stmtId); m_tableAliasMap.put(tableAlias, tableScan); } return tableScan; }
[ "protected", "StmtTableScan", "addTableToStmtCache", "(", "Table", "table", ",", "String", "tableAlias", ")", "{", "// Create an index into the query Catalog cache", "StmtTableScan", "tableScan", "=", "m_tableAliasMap", ".", "get", "(", "tableAlias", ")", ";", "if", "("...
Add a table to the statement cache. @param table @param tableAlias @return the cache entry
[ "Add", "a", "table", "to", "the", "statement", "cache", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L804-L812
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.addSubqueryToStmtCache
protected StmtSubqueryScan addSubqueryToStmtCache( AbstractParsedStmt subquery, String tableAlias) { assert(subquery != null); // If there is no usable alias because the subquery is inside an expression, // generate a unique one for internal use. if (tableAlias == null) { tableAlias = AbstractParsedStmt.TEMP_TABLE_NAME + "_" + subquery.m_stmtId; } StmtSubqueryScan subqueryScan = new StmtSubqueryScan(subquery, tableAlias, m_stmtId); StmtTableScan prior = m_tableAliasMap.put(tableAlias, subqueryScan); assert(prior == null); return subqueryScan; }
java
protected StmtSubqueryScan addSubqueryToStmtCache( AbstractParsedStmt subquery, String tableAlias) { assert(subquery != null); // If there is no usable alias because the subquery is inside an expression, // generate a unique one for internal use. if (tableAlias == null) { tableAlias = AbstractParsedStmt.TEMP_TABLE_NAME + "_" + subquery.m_stmtId; } StmtSubqueryScan subqueryScan = new StmtSubqueryScan(subquery, tableAlias, m_stmtId); StmtTableScan prior = m_tableAliasMap.put(tableAlias, subqueryScan); assert(prior == null); return subqueryScan; }
[ "protected", "StmtSubqueryScan", "addSubqueryToStmtCache", "(", "AbstractParsedStmt", "subquery", ",", "String", "tableAlias", ")", "{", "assert", "(", "subquery", "!=", "null", ")", ";", "// If there is no usable alias because the subquery is inside an expression,", "// genera...
Add a sub-query to the statement cache. @param subquery @param tableAlias @return the cache entry
[ "Add", "a", "sub", "-", "query", "to", "the", "statement", "cache", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L820-L833
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.addSimplifiedSubqueryToStmtCache
private StmtTargetTableScan addSimplifiedSubqueryToStmtCache( StmtSubqueryScan subqueryScan, StmtTargetTableScan tableScan) { String tableAlias = subqueryScan.getTableAlias(); assert(tableAlias != null); // It is guaranteed by the canSimplifySubquery that there is // one and only one TABLE in the subquery's FROM clause. Table promotedTable = tableScan.getTargetTable(); StmtTargetTableScan promotedScan = new StmtTargetTableScan(promotedTable, tableAlias, m_stmtId); // Keep the original subquery scan to be able to tie the parent // statement column/table names and aliases to the table's. promotedScan.setOriginalSubqueryScan(subqueryScan); // Replace the subquery scan with the table scan StmtTableScan prior = m_tableAliasMap.put(tableAlias, promotedScan); assert(prior == subqueryScan); m_tableList.add(promotedTable); return promotedScan; }
java
private StmtTargetTableScan addSimplifiedSubqueryToStmtCache( StmtSubqueryScan subqueryScan, StmtTargetTableScan tableScan) { String tableAlias = subqueryScan.getTableAlias(); assert(tableAlias != null); // It is guaranteed by the canSimplifySubquery that there is // one and only one TABLE in the subquery's FROM clause. Table promotedTable = tableScan.getTargetTable(); StmtTargetTableScan promotedScan = new StmtTargetTableScan(promotedTable, tableAlias, m_stmtId); // Keep the original subquery scan to be able to tie the parent // statement column/table names and aliases to the table's. promotedScan.setOriginalSubqueryScan(subqueryScan); // Replace the subquery scan with the table scan StmtTableScan prior = m_tableAliasMap.put(tableAlias, promotedScan); assert(prior == subqueryScan); m_tableList.add(promotedTable); return promotedScan; }
[ "private", "StmtTargetTableScan", "addSimplifiedSubqueryToStmtCache", "(", "StmtSubqueryScan", "subqueryScan", ",", "StmtTargetTableScan", "tableScan", ")", "{", "String", "tableAlias", "=", "subqueryScan", ".", "getTableAlias", "(", ")", ";", "assert", "(", "tableAlias",...
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. @param subqueryScan subquery scan to simplify @param tableAlias @return StmtTargetTableScan
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L894-L911
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.replaceExpressionsWithPve
protected AbstractExpression replaceExpressionsWithPve(AbstractExpression expr) { assert(expr != null); if (expr instanceof TupleValueExpression) { int paramIdx = ParameterizationInfo.getNextParamIndex(); ParameterValueExpression pve = new ParameterValueExpression(paramIdx, expr); m_parameterTveMap.put(paramIdx, expr); return pve; } if (expr instanceof AggregateExpression) { int paramIdx = ParameterizationInfo.getNextParamIndex(); ParameterValueExpression pve = new ParameterValueExpression(paramIdx, expr); // Disallow aggregation of parent columns in a subquery. // except the case HAVING AGG(T1.C1) IN (SELECT T2.C2 ...) List<TupleValueExpression> tves = ExpressionUtil.getTupleValueExpressions(expr); assert(m_parentStmt != null); for (TupleValueExpression tve : tves) { int origId = tve.getOrigStmtId(); if (m_stmtId != origId && m_parentStmt.m_stmtId != origId) { throw new PlanningErrorException( "Subqueries do not support aggregation of parent statement columns"); } } m_parameterTveMap.put(paramIdx, expr); return pve; } if (expr.getLeft() != null) { expr.setLeft(replaceExpressionsWithPve(expr.getLeft())); } if (expr.getRight() != null) { expr.setRight(replaceExpressionsWithPve(expr.getRight())); } if (expr.getArgs() != null) { List<AbstractExpression> newArgs = new ArrayList<>(); for (AbstractExpression argument : expr.getArgs()) { newArgs.add(replaceExpressionsWithPve(argument)); } expr.setArgs(newArgs); } return expr; }
java
protected AbstractExpression replaceExpressionsWithPve(AbstractExpression expr) { assert(expr != null); if (expr instanceof TupleValueExpression) { int paramIdx = ParameterizationInfo.getNextParamIndex(); ParameterValueExpression pve = new ParameterValueExpression(paramIdx, expr); m_parameterTveMap.put(paramIdx, expr); return pve; } if (expr instanceof AggregateExpression) { int paramIdx = ParameterizationInfo.getNextParamIndex(); ParameterValueExpression pve = new ParameterValueExpression(paramIdx, expr); // Disallow aggregation of parent columns in a subquery. // except the case HAVING AGG(T1.C1) IN (SELECT T2.C2 ...) List<TupleValueExpression> tves = ExpressionUtil.getTupleValueExpressions(expr); assert(m_parentStmt != null); for (TupleValueExpression tve : tves) { int origId = tve.getOrigStmtId(); if (m_stmtId != origId && m_parentStmt.m_stmtId != origId) { throw new PlanningErrorException( "Subqueries do not support aggregation of parent statement columns"); } } m_parameterTveMap.put(paramIdx, expr); return pve; } if (expr.getLeft() != null) { expr.setLeft(replaceExpressionsWithPve(expr.getLeft())); } if (expr.getRight() != null) { expr.setRight(replaceExpressionsWithPve(expr.getRight())); } if (expr.getArgs() != null) { List<AbstractExpression> newArgs = new ArrayList<>(); for (AbstractExpression argument : expr.getArgs()) { newArgs.add(replaceExpressionsWithPve(argument)); } expr.setArgs(newArgs); } return expr; }
[ "protected", "AbstractExpression", "replaceExpressionsWithPve", "(", "AbstractExpression", "expr", ")", "{", "assert", "(", "expr", "!=", "null", ")", ";", "if", "(", "expr", "instanceof", "TupleValueExpression", ")", "{", "int", "paramIdx", "=", "ParameterizationIn...
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. @param stmt - subquery statement @param expr - expression with parent TVEs @return Expression with parent TVE replaced with PVE
[ "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", ".", "T...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1166-L1207
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.resolveCommonTableByName
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(tableName); } if (scan != null) { answer = new StmtCommonTableScan(tableName, tableAlias, scan); } return answer; }
java
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(tableName); } if (scan != null) { answer = new StmtCommonTableScan(tableName, tableAlias, scan); } return answer; }
[ "private", "StmtCommonTableScan", "resolveCommonTableByName", "(", "String", "tableName", ",", "String", "tableAlias", ")", "{", "StmtCommonTableScan", "answer", "=", "null", ";", "StmtCommonTableScanShared", "scan", "=", "null", ";", "for", "(", "AbstractParsedStmt", ...
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. @param tableName @return
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1482-L1492
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.parseParameters
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) { if (node.name.equalsIgnoreCase("parameter")) { long id = Long.parseLong(node.attributes.get("id")); String typeName = node.attributes.get("valuetype"); String isVectorParam = node.attributes.get("isvector"); // Get the index for this parameter in the EE's parameter vector String indexAttr = node.attributes.get("index"); assert(indexAttr != null); int index = Integer.parseInt(indexAttr); VoltType type = VoltType.typeFromString(typeName); ParameterValueExpression pve = new ParameterValueExpression(); pve.setParameterIndex(index); pve.setValueType(type); if (isVectorParam != null && isVectorParam.equalsIgnoreCase("true")) { pve.setParamIsVector(); } m_paramsById.put(id, pve); getParamsByIndex().put(index, pve); } } }
java
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) { if (node.name.equalsIgnoreCase("parameter")) { long id = Long.parseLong(node.attributes.get("id")); String typeName = node.attributes.get("valuetype"); String isVectorParam = node.attributes.get("isvector"); // Get the index for this parameter in the EE's parameter vector String indexAttr = node.attributes.get("index"); assert(indexAttr != null); int index = Integer.parseInt(indexAttr); VoltType type = VoltType.typeFromString(typeName); ParameterValueExpression pve = new ParameterValueExpression(); pve.setParameterIndex(index); pve.setValueType(type); if (isVectorParam != null && isVectorParam.equalsIgnoreCase("true")) { pve.setParamIsVector(); } m_paramsById.put(id, pve); getParamsByIndex().put(index, pve); } } }
[ "protected", "void", "parseParameters", "(", "VoltXMLElement", "root", ")", "{", "VoltXMLElement", "paramsNode", "=", "null", ";", "for", "(", "VoltXMLElement", "node", ":", "root", ".", "children", ")", "{", "if", "(", "node", ".", "name", ".", "equalsIgnor...
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 indication. We add the pve to two maps, m_paramsById and m_paramsByIndex. A parameter's index attribute is its offset in the parameters array which is used to determine the parameter's value in the EE at runtime. Some parameters are generated after we generate VoltXML but before we plan (constants may become parameters in ad hoc queries so their plans may be cached). In this case the index of the parameter is already set. Otherwise, the parameter's index will have been set in HSQL. @param paramsNode
[ "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", "ind...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1567-L1601
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.promoteUnionParametersFromChild
protected void promoteUnionParametersFromChild(AbstractParsedStmt childStmt) { getParamsByIndex().putAll(childStmt.getParamsByIndex()); m_parameterTveMap.putAll(childStmt.m_parameterTveMap); }
java
protected void promoteUnionParametersFromChild(AbstractParsedStmt childStmt) { getParamsByIndex().putAll(childStmt.getParamsByIndex()); m_parameterTveMap.putAll(childStmt.m_parameterTveMap); }
[ "protected", "void", "promoteUnionParametersFromChild", "(", "AbstractParsedStmt", "childStmt", ")", "{", "getParamsByIndex", "(", ")", ".", "putAll", "(", "childStmt", ".", "getParamsByIndex", "(", ")", ")", ";", "m_parameterTveMap", ".", "putAll", "(", "childStmt"...
in the EE.
[ "in", "the", "EE", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1628-L1631
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.analyzeValueEquivalence
HashMap<AbstractExpression, Set<AbstractExpression>> analyzeValueEquivalence() { // collect individual where/join expressions m_joinTree.analyzeJoinExpressions(m_noTableSelectionList); return m_joinTree.getAllEquivalenceFilters(); }
java
HashMap<AbstractExpression, Set<AbstractExpression>> analyzeValueEquivalence() { // collect individual where/join expressions m_joinTree.analyzeJoinExpressions(m_noTableSelectionList); return m_joinTree.getAllEquivalenceFilters(); }
[ "HashMap", "<", "AbstractExpression", ",", "Set", "<", "AbstractExpression", ">", ">", "analyzeValueEquivalence", "(", ")", "{", "// collect individual where/join expressions", "m_joinTree", ".", "analyzeJoinExpressions", "(", "m_noTableSelectionList", ")", ";", "return", ...
Collect value equivalence expressions across the entire SQL statement @return a map of tuple value expressions to the other expressions, TupleValueExpressions, ConstantValueExpressions, or ParameterValueExpressions, that they are constrained to equal.
[ "Collect", "value", "equivalence", "expressions", "across", "the", "entire", "SQL", "statement" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1639-L1643
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.getTableFromDB
protected Table getTableFromDB(String tableName) { Table table = m_db.getTables().getExact(tableName); return table; }
java
protected Table getTableFromDB(String tableName) { Table table = m_db.getTables().getExact(tableName); return table; }
[ "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. @param tableName @return
[ "Look", "up", "a", "table", "by", "name", ".", "This", "table", "may", "be", "stored", "in", "the", "local", "catalog", "or", "else", "the", "global", "catalog", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1651-L1654
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.parseTableCondition
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); assert(condExpr == null); condExpr = parseConditionTree(childNode.children.get(0)); assert(condExpr != null); ExpressionUtil.finalizeValueTypes(condExpr); condExpr = ExpressionUtil.evaluateExpression(condExpr); // If the condition is a trivial CVE(TRUE) (after the evaluation) simply drop it if (ConstantValueExpression.isBooleanTrue(condExpr)) { condExpr = null; } } return condExpr; }
java
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); assert(condExpr == null); condExpr = parseConditionTree(childNode.children.get(0)); assert(condExpr != null); ExpressionUtil.finalizeValueTypes(condExpr); condExpr = ExpressionUtil.evaluateExpression(condExpr); // If the condition is a trivial CVE(TRUE) (after the evaluation) simply drop it if (ConstantValueExpression.isBooleanTrue(condExpr)) { condExpr = null; } } return condExpr; }
[ "private", "AbstractExpression", "parseTableCondition", "(", "VoltXMLElement", "tableScan", ",", "String", "joinOrWhere", ")", "{", "AbstractExpression", "condExpr", "=", "null", ";", "for", "(", "VoltXMLElement", "childNode", ":", "tableScan", ".", "children", ")", ...
Parse a where or join clause. This behavior is common to all kinds of statements.
[ "Parse", "a", "where", "or", "join", "clause", ".", "This", "behavior", "is", "common", "to", "all", "kinds", "of", "statements", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1735-L1754
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.limitPlanNodeFromXml
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) { // Parse limit if ((node = limitXml.attributes.get("limit_paramid")) != null) { limitParameterId = Long.parseLong(node); } else { assert(limitXml.children.size() == 1); VoltXMLElement valueNode = limitXml.children.get(0); String isParam = valueNode.attributes.get("isparam"); if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) { limitParameterId = Long.parseLong(valueNode.attributes.get("id")); } else { node = limitXml.attributes.get("limit"); assert(node != null); limit = Long.parseLong(node); } } } if (offsetXml != null) { // Parse offset if ((node = offsetXml.attributes.get("offset_paramid")) != null) { offsetParameterId = Long.parseLong(node); } else { if (offsetXml.children.size() == 1) { VoltXMLElement valueNode = offsetXml.children.get(0); String isParam = valueNode.attributes.get("isparam"); if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) { offsetParameterId = Long.parseLong(valueNode.attributes.get("id")); } else { node = offsetXml.attributes.get("offset"); assert(node != null); offset = Long.parseLong(node); } } } } // limit and offset can't have both value and parameter if (limit != -1) assert limitParameterId == -1 : "Parsed value and param. limit."; if (offset != 0) assert offsetParameterId == -1 : "Parsed value and param. offset."; LimitPlanNode limitPlanNode = new LimitPlanNode(); limitPlanNode.setLimit((int) limit); limitPlanNode.setOffset((int) offset); limitPlanNode.setLimitParameterIndex(parameterCountIndexById(limitParameterId)); limitPlanNode.setOffsetParameterIndex(parameterCountIndexById(offsetParameterId)); return limitPlanNode; }
java
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) { // Parse limit if ((node = limitXml.attributes.get("limit_paramid")) != null) { limitParameterId = Long.parseLong(node); } else { assert(limitXml.children.size() == 1); VoltXMLElement valueNode = limitXml.children.get(0); String isParam = valueNode.attributes.get("isparam"); if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) { limitParameterId = Long.parseLong(valueNode.attributes.get("id")); } else { node = limitXml.attributes.get("limit"); assert(node != null); limit = Long.parseLong(node); } } } if (offsetXml != null) { // Parse offset if ((node = offsetXml.attributes.get("offset_paramid")) != null) { offsetParameterId = Long.parseLong(node); } else { if (offsetXml.children.size() == 1) { VoltXMLElement valueNode = offsetXml.children.get(0); String isParam = valueNode.attributes.get("isparam"); if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) { offsetParameterId = Long.parseLong(valueNode.attributes.get("id")); } else { node = offsetXml.attributes.get("offset"); assert(node != null); offset = Long.parseLong(node); } } } } // limit and offset can't have both value and parameter if (limit != -1) assert limitParameterId == -1 : "Parsed value and param. limit."; if (offset != 0) assert offsetParameterId == -1 : "Parsed value and param. offset."; LimitPlanNode limitPlanNode = new LimitPlanNode(); limitPlanNode.setLimit((int) limit); limitPlanNode.setOffset((int) offset); limitPlanNode.setLimitParameterIndex(parameterCountIndexById(limitParameterId)); limitPlanNode.setOffsetParameterIndex(parameterCountIndexById(offsetParameterId)); return limitPlanNode; }
[ "LimitPlanNode", "limitPlanNodeFromXml", "(", "VoltXMLElement", "limitXml", ",", "VoltXMLElement", "offsetXml", ")", "{", "if", "(", "limitXml", "==", "null", "&&", "offsetXml", "==", "null", ")", "{", "return", "null", ";", "}", "String", "node", ";", "long",...
Produce a LimitPlanNode from the given XML @param limitXml Volt XML for limit @param offsetXml Volt XML for offset @return An instance of LimitPlanNode for the given XML
[ "Produce", "a", "LimitPlanNode", "from", "the", "given", "XML" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1848-L1909
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.orderByColumnsCoverUniqueKeys
protected boolean orderByColumnsCoverUniqueKeys() { // In theory, if EVERY table in the query has a uniqueness constraint // (primary key or other unique index) on columns that are all listed in the ORDER BY values, // the result is deterministic. // This holds regardless of whether the associated index is actually used in the selected plan, // so this check is plan-independent. // // baseTableAliases associates table aliases with the order by // expressions which reference them. Presumably by using // table aliases we will map table scans to expressions rather // than tables to expressions, and not confuse ourselves with // different instances of the same table in self joins. HashMap<String, List<AbstractExpression> > baseTableAliases = new HashMap<>(); for (ParsedColInfo col : orderByColumns()) { AbstractExpression expr = col.m_expression; // // Compute the set of tables mentioned in the expression. // 1. Search out all the TVEs. // 2. Throw the aliases of the tables of each of these into a HashSet. // The table must have an alias. It might not have a name. // 3. If the HashSet has size > 1 we can't use this expression. // List<TupleValueExpression> baseTVEExpressions = expr.findAllTupleValueSubexpressions(); Set<String> baseTableNames = new HashSet<>(); for (TupleValueExpression tve : baseTVEExpressions) { String tableAlias = tve.getTableAlias(); assert(tableAlias != null); baseTableNames.add(tableAlias); } if (baseTableNames.size() != 1) { // Table-spanning ORDER BYs -- like ORDER BY A.X + B.Y are not helpful. // Neither are (nonsense) constant (table-less) expressions. continue; } // Everything in the baseTVEExpressions table is a column // in the same table and has the same alias. So just grab the first one. // All we really want is the alias. AbstractExpression baseTVE = baseTVEExpressions.get(0); String nextTableAlias = ((TupleValueExpression)baseTVE).getTableAlias(); // This was tested above. But the assert above may prove to be over cautious // and disappear. assert(nextTableAlias != null); List<AbstractExpression> perTable = baseTableAliases.get(nextTableAlias); if (perTable == null) { perTable = new ArrayList<>(); baseTableAliases.put(nextTableAlias, perTable); } perTable.add(expr); } if (m_tableAliasMap.size() > baseTableAliases.size()) { // FIXME: There are more table aliases in the select list than tables // named in the order by clause. So, some tables named in the // select list are not explicitly listed in the order by // clause. // // This would be one of the tricky cases where the goal would be to prove that the // row with no ORDER BY component came from the right side of a 1-to-1 or many-to-1 join. // like Unique Index nested loop join, etc. return false; } boolean allScansAreDeterministic = true; for (Entry<String, List<AbstractExpression>> orderedAlias : baseTableAliases.entrySet()) { List<AbstractExpression> orderedAliasExprs = orderedAlias.getValue(); StmtTableScan tableScan = getStmtTableScanByAlias(orderedAlias.getKey()); if (tableScan == null) { assert(false); return false; } if (tableScan instanceof StmtSubqueryScan) { return false; // don't yet handle FROM clause subquery, here. } Table table = ((StmtTargetTableScan)tableScan).getTargetTable(); // This table's scans need to be proven deterministic. allScansAreDeterministic = false; // Search indexes for one that makes the order by deterministic for (Index index : table.getIndexes()) { // skip non-unique indexes if ( ! index.getUnique()) { continue; } // get the list of expressions for the index List<AbstractExpression> indexExpressions = new ArrayList<>(); String jsonExpr = index.getExpressionsjson(); // if this is a pure-column index... if (jsonExpr.isEmpty()) { for (ColumnRef cref : index.getColumns()) { Column col = cref.getColumn(); TupleValueExpression tve = new TupleValueExpression(table.getTypeName(), orderedAlias.getKey(), col.getName(), col.getName(), col.getIndex()); indexExpressions.add(tve); } } // if this is a fancy expression-based index... else { try { indexExpressions = AbstractExpression.fromJSONArrayString(jsonExpr, tableScan); } catch (JSONException e) { e.printStackTrace(); assert(false); continue; } } // If the sort covers the index, then it's a unique sort. // TODO: The statement's equivalence sets would be handy here to recognize cases like // WHERE B.unique_id = A.b_id // ORDER BY A.unique_id, A.b_id if (orderedAliasExprs.containsAll(indexExpressions)) { allScansAreDeterministic = true; break; } } // ALL tables' scans need to have proved deterministic if ( ! allScansAreDeterministic) { return false; } } return true; }
java
protected boolean orderByColumnsCoverUniqueKeys() { // In theory, if EVERY table in the query has a uniqueness constraint // (primary key or other unique index) on columns that are all listed in the ORDER BY values, // the result is deterministic. // This holds regardless of whether the associated index is actually used in the selected plan, // so this check is plan-independent. // // baseTableAliases associates table aliases with the order by // expressions which reference them. Presumably by using // table aliases we will map table scans to expressions rather // than tables to expressions, and not confuse ourselves with // different instances of the same table in self joins. HashMap<String, List<AbstractExpression> > baseTableAliases = new HashMap<>(); for (ParsedColInfo col : orderByColumns()) { AbstractExpression expr = col.m_expression; // // Compute the set of tables mentioned in the expression. // 1. Search out all the TVEs. // 2. Throw the aliases of the tables of each of these into a HashSet. // The table must have an alias. It might not have a name. // 3. If the HashSet has size > 1 we can't use this expression. // List<TupleValueExpression> baseTVEExpressions = expr.findAllTupleValueSubexpressions(); Set<String> baseTableNames = new HashSet<>(); for (TupleValueExpression tve : baseTVEExpressions) { String tableAlias = tve.getTableAlias(); assert(tableAlias != null); baseTableNames.add(tableAlias); } if (baseTableNames.size() != 1) { // Table-spanning ORDER BYs -- like ORDER BY A.X + B.Y are not helpful. // Neither are (nonsense) constant (table-less) expressions. continue; } // Everything in the baseTVEExpressions table is a column // in the same table and has the same alias. So just grab the first one. // All we really want is the alias. AbstractExpression baseTVE = baseTVEExpressions.get(0); String nextTableAlias = ((TupleValueExpression)baseTVE).getTableAlias(); // This was tested above. But the assert above may prove to be over cautious // and disappear. assert(nextTableAlias != null); List<AbstractExpression> perTable = baseTableAliases.get(nextTableAlias); if (perTable == null) { perTable = new ArrayList<>(); baseTableAliases.put(nextTableAlias, perTable); } perTable.add(expr); } if (m_tableAliasMap.size() > baseTableAliases.size()) { // FIXME: There are more table aliases in the select list than tables // named in the order by clause. So, some tables named in the // select list are not explicitly listed in the order by // clause. // // This would be one of the tricky cases where the goal would be to prove that the // row with no ORDER BY component came from the right side of a 1-to-1 or many-to-1 join. // like Unique Index nested loop join, etc. return false; } boolean allScansAreDeterministic = true; for (Entry<String, List<AbstractExpression>> orderedAlias : baseTableAliases.entrySet()) { List<AbstractExpression> orderedAliasExprs = orderedAlias.getValue(); StmtTableScan tableScan = getStmtTableScanByAlias(orderedAlias.getKey()); if (tableScan == null) { assert(false); return false; } if (tableScan instanceof StmtSubqueryScan) { return false; // don't yet handle FROM clause subquery, here. } Table table = ((StmtTargetTableScan)tableScan).getTargetTable(); // This table's scans need to be proven deterministic. allScansAreDeterministic = false; // Search indexes for one that makes the order by deterministic for (Index index : table.getIndexes()) { // skip non-unique indexes if ( ! index.getUnique()) { continue; } // get the list of expressions for the index List<AbstractExpression> indexExpressions = new ArrayList<>(); String jsonExpr = index.getExpressionsjson(); // if this is a pure-column index... if (jsonExpr.isEmpty()) { for (ColumnRef cref : index.getColumns()) { Column col = cref.getColumn(); TupleValueExpression tve = new TupleValueExpression(table.getTypeName(), orderedAlias.getKey(), col.getName(), col.getName(), col.getIndex()); indexExpressions.add(tve); } } // if this is a fancy expression-based index... else { try { indexExpressions = AbstractExpression.fromJSONArrayString(jsonExpr, tableScan); } catch (JSONException e) { e.printStackTrace(); assert(false); continue; } } // If the sort covers the index, then it's a unique sort. // TODO: The statement's equivalence sets would be handy here to recognize cases like // WHERE B.unique_id = A.b_id // ORDER BY A.unique_id, A.b_id if (orderedAliasExprs.containsAll(indexExpressions)) { allScansAreDeterministic = true; break; } } // ALL tables' scans need to have proved deterministic if ( ! allScansAreDeterministic) { return false; } } return true; }
[ "protected", "boolean", "orderByColumnsCoverUniqueKeys", "(", ")", "{", "// In theory, if EVERY table in the query has a uniqueness constraint", "// (primary key or other unique index) on columns that are all listed in the ORDER BY values,", "// the result is deterministic.", "// This holds regard...
Order by Columns or expressions has to operate on the display columns or expressions. @return
[ "Order", "by", "Columns", "or", "expressions", "has", "to", "operate", "on", "the", "display", "columns", "or", "expressions", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L1915-L2045
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.addHonoraryOrderByExpressions
protected void addHonoraryOrderByExpressions( HashSet<AbstractExpression> orderByExprs, List<ParsedColInfo> candidateColumns) { // If there is not exactly one table scan we will not proceed. // We don't really know how to make indices work with joins, // and there is nothing more to do with subqueries. The processing // of joins is the content of ticket ENG-8677. if (m_tableAliasMap.size() != 1) { return; } HashMap<AbstractExpression, Set<AbstractExpression>> valueEquivalence = analyzeValueEquivalence(); for (ParsedColInfo colInfo : candidateColumns) { AbstractExpression colExpr = colInfo.m_expression; if (colExpr instanceof TupleValueExpression) { Set<AbstractExpression> tveEquivs = valueEquivalence.get(colExpr); if (tveEquivs != null) { for (AbstractExpression expr : tveEquivs) { if (expr instanceof ParameterValueExpression || expr instanceof ConstantValueExpression) { orderByExprs.add(colExpr); } } } } } // We know there's exactly one. StmtTableScan scan = m_tableAliasMap.values().iterator().next(); // Get the table. There's only one. Table table = getTableFromDB(scan.getTableName()); // Maybe this is a subquery? If we can't find the table // there's no use to continue. if (table == null) { return; } // Now, look to see if there is a constraint which can help us. // If there is a unique constraint on a set of columns, and all // the constrained columns are in the order by list, then all // the columns in the table can be added to the order by list. // // The indices we care about have columns, but the order by list has expressions. // Extract the columns from the order by list. Set<Column> orderByColumns = new HashSet<>(); for (AbstractExpression expr : orderByExprs) { if (expr instanceof TupleValueExpression) { TupleValueExpression tve = (TupleValueExpression) expr; Column col = table.getColumns().get(tve.getColumnName()); orderByColumns.add(col); } } CatalogMap<Constraint> constraints = table.getConstraints(); // If we have no constraints, there's nothing more to do here. if (constraints == null) { return; } Set<Index> indices = new HashSet<>(); for (Constraint constraint : constraints) { Index index = constraint.getIndex(); // Only use column indices for now. if (index != null && index.getUnique() && index.getExpressionsjson().isEmpty()) { indices.add(index); } } for (ParsedColInfo colInfo : candidateColumns) { AbstractExpression expr = colInfo.m_expression; if (expr instanceof TupleValueExpression) { TupleValueExpression tve = (TupleValueExpression) expr; // If one of the indices is completely covered // we will not have to process any other indices. // So, we remember this and early-out. for (Index index : indices) { CatalogMap<ColumnRef> columns = index.getColumns(); // If all the columns in this index are in the current // honorary order by list, then we can add all the // columns in this table to the honorary order by list. boolean addAllColumns = true; for (ColumnRef cr : columns) { Column col = cr.getColumn(); if (orderByColumns.contains(col) == false) { addAllColumns = false; break; } } if (addAllColumns) { for (Column addCol : table.getColumns()) { // We have to convert this to a TVE to add // it to the orderByExprs. We will use -1 // for the column index. We don't have a column // alias. TupleValueExpression ntve = new TupleValueExpression(tve.getTableName(), tve.getTableAlias(), addCol.getName(), null, -1); orderByExprs.add(ntve); } // Don't forget to remember to forget the other indices. (E. Presley, 1955) break; } } } } }
java
protected void addHonoraryOrderByExpressions( HashSet<AbstractExpression> orderByExprs, List<ParsedColInfo> candidateColumns) { // If there is not exactly one table scan we will not proceed. // We don't really know how to make indices work with joins, // and there is nothing more to do with subqueries. The processing // of joins is the content of ticket ENG-8677. if (m_tableAliasMap.size() != 1) { return; } HashMap<AbstractExpression, Set<AbstractExpression>> valueEquivalence = analyzeValueEquivalence(); for (ParsedColInfo colInfo : candidateColumns) { AbstractExpression colExpr = colInfo.m_expression; if (colExpr instanceof TupleValueExpression) { Set<AbstractExpression> tveEquivs = valueEquivalence.get(colExpr); if (tveEquivs != null) { for (AbstractExpression expr : tveEquivs) { if (expr instanceof ParameterValueExpression || expr instanceof ConstantValueExpression) { orderByExprs.add(colExpr); } } } } } // We know there's exactly one. StmtTableScan scan = m_tableAliasMap.values().iterator().next(); // Get the table. There's only one. Table table = getTableFromDB(scan.getTableName()); // Maybe this is a subquery? If we can't find the table // there's no use to continue. if (table == null) { return; } // Now, look to see if there is a constraint which can help us. // If there is a unique constraint on a set of columns, and all // the constrained columns are in the order by list, then all // the columns in the table can be added to the order by list. // // The indices we care about have columns, but the order by list has expressions. // Extract the columns from the order by list. Set<Column> orderByColumns = new HashSet<>(); for (AbstractExpression expr : orderByExprs) { if (expr instanceof TupleValueExpression) { TupleValueExpression tve = (TupleValueExpression) expr; Column col = table.getColumns().get(tve.getColumnName()); orderByColumns.add(col); } } CatalogMap<Constraint> constraints = table.getConstraints(); // If we have no constraints, there's nothing more to do here. if (constraints == null) { return; } Set<Index> indices = new HashSet<>(); for (Constraint constraint : constraints) { Index index = constraint.getIndex(); // Only use column indices for now. if (index != null && index.getUnique() && index.getExpressionsjson().isEmpty()) { indices.add(index); } } for (ParsedColInfo colInfo : candidateColumns) { AbstractExpression expr = colInfo.m_expression; if (expr instanceof TupleValueExpression) { TupleValueExpression tve = (TupleValueExpression) expr; // If one of the indices is completely covered // we will not have to process any other indices. // So, we remember this and early-out. for (Index index : indices) { CatalogMap<ColumnRef> columns = index.getColumns(); // If all the columns in this index are in the current // honorary order by list, then we can add all the // columns in this table to the honorary order by list. boolean addAllColumns = true; for (ColumnRef cr : columns) { Column col = cr.getColumn(); if (orderByColumns.contains(col) == false) { addAllColumns = false; break; } } if (addAllColumns) { for (Column addCol : table.getColumns()) { // We have to convert this to a TVE to add // it to the orderByExprs. We will use -1 // for the column index. We don't have a column // alias. TupleValueExpression ntve = new TupleValueExpression(tve.getTableName(), tve.getTableAlias(), addCol.getName(), null, -1); orderByExprs.add(ntve); } // Don't forget to remember to forget the other indices. (E. Presley, 1955) break; } } } } }
[ "protected", "void", "addHonoraryOrderByExpressions", "(", "HashSet", "<", "AbstractExpression", ">", "orderByExprs", ",", "List", "<", "ParsedColInfo", ">", "candidateColumns", ")", "{", "// If there is not exactly one table scan we will not proceed.", "// We don't really know h...
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.
[ "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...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L2053-L2157
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.producesOneRowOutput
protected boolean producesOneRowOutput () { if (m_tableAliasMap.size() != 1) { return false; } // Get the table. There's only one. StmtTableScan scan = m_tableAliasMap.values().iterator().next(); Table table = getTableFromDB(scan.getTableName()); // May be sub-query? If can't find the table there's no use to continue. if (table == null) { return false; } // Get all the indexes defined on the table CatalogMap<Index> indexes = table.getIndexes(); if (indexes == null || indexes.size() == 0) { // no indexes defined on the table return false; } // Collect value equivalence expression for the SQL statement HashMap<AbstractExpression, Set<AbstractExpression>> valueEquivalence = analyzeValueEquivalence(); // If no value equivalence filter defined in SQL statement, there's no use to continue if (valueEquivalence.isEmpty()) { return false; } // Collect all tve expressions from value equivalence set which have equivalence // defined to parameterized or constant value expression. // Eg: T.A = ? or T.A = 1 Set <AbstractExpression> parameterizedConstantKeys = new HashSet<>(); Set<AbstractExpression> valueEquivalenceKeys = valueEquivalence.keySet(); // get all the keys for (AbstractExpression key : valueEquivalenceKeys) { if (key instanceof TupleValueExpression) { Set<AbstractExpression> values = valueEquivalence.get(key); for (AbstractExpression value : values) { if ((value instanceof ParameterValueExpression) || (value instanceof ConstantValueExpression)) { TupleValueExpression tve = (TupleValueExpression) key; parameterizedConstantKeys.add(tve); } } } } // Iterate over the unique indexes defined on the table to check if the unique // index defined on table appears in tve equivalence expression gathered above. for (Index index : indexes) { // Perform lookup only on pure column indices which are unique if (!index.getUnique() || !index.getExpressionsjson().isEmpty()) { continue; } Set<AbstractExpression> indexExpressions = new HashSet<>(); CatalogMap<ColumnRef> indexColRefs = index.getColumns(); for (ColumnRef indexColRef:indexColRefs) { Column col = indexColRef.getColumn(); TupleValueExpression tve = new TupleValueExpression(scan.getTableName(), scan.getTableAlias(), col.getName(), col.getName(), col.getIndex()); indexExpressions.add(tve); } if (parameterizedConstantKeys.containsAll(indexExpressions)) { return true; } } return false; }
java
protected boolean producesOneRowOutput () { if (m_tableAliasMap.size() != 1) { return false; } // Get the table. There's only one. StmtTableScan scan = m_tableAliasMap.values().iterator().next(); Table table = getTableFromDB(scan.getTableName()); // May be sub-query? If can't find the table there's no use to continue. if (table == null) { return false; } // Get all the indexes defined on the table CatalogMap<Index> indexes = table.getIndexes(); if (indexes == null || indexes.size() == 0) { // no indexes defined on the table return false; } // Collect value equivalence expression for the SQL statement HashMap<AbstractExpression, Set<AbstractExpression>> valueEquivalence = analyzeValueEquivalence(); // If no value equivalence filter defined in SQL statement, there's no use to continue if (valueEquivalence.isEmpty()) { return false; } // Collect all tve expressions from value equivalence set which have equivalence // defined to parameterized or constant value expression. // Eg: T.A = ? or T.A = 1 Set <AbstractExpression> parameterizedConstantKeys = new HashSet<>(); Set<AbstractExpression> valueEquivalenceKeys = valueEquivalence.keySet(); // get all the keys for (AbstractExpression key : valueEquivalenceKeys) { if (key instanceof TupleValueExpression) { Set<AbstractExpression> values = valueEquivalence.get(key); for (AbstractExpression value : values) { if ((value instanceof ParameterValueExpression) || (value instanceof ConstantValueExpression)) { TupleValueExpression tve = (TupleValueExpression) key; parameterizedConstantKeys.add(tve); } } } } // Iterate over the unique indexes defined on the table to check if the unique // index defined on table appears in tve equivalence expression gathered above. for (Index index : indexes) { // Perform lookup only on pure column indices which are unique if (!index.getUnique() || !index.getExpressionsjson().isEmpty()) { continue; } Set<AbstractExpression> indexExpressions = new HashSet<>(); CatalogMap<ColumnRef> indexColRefs = index.getColumns(); for (ColumnRef indexColRef:indexColRefs) { Column col = indexColRef.getColumn(); TupleValueExpression tve = new TupleValueExpression(scan.getTableName(), scan.getTableAlias(), col.getName(), col.getName(), col.getIndex()); indexExpressions.add(tve); } if (parameterizedConstantKeys.containsAll(indexExpressions)) { return true; } } return false; }
[ "protected", "boolean", "producesOneRowOutput", "(", ")", "{", "if", "(", "m_tableAliasMap", ".", "size", "(", ")", "!=", "1", ")", "{", "return", "false", ";", "}", "// Get the table. There's only one.", "StmtTableScan", "scan", "=", "m_tableAliasMap", ".", "v...
row else false
[ "row", "else", "false" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L2282-L2353
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/AbstractParsedStmt.java
AbstractParsedStmt.calculateUDFDependees
public Collection<String> calculateUDFDependees() { List<String> answer = new ArrayList<>(); Collection<AbstractExpression> fCalls = findAllSubexpressionsOfClass(FunctionExpression.class); for (AbstractExpression fCall : fCalls) { FunctionExpression fexpr = (FunctionExpression)fCall; if (fexpr.isUserDefined()) { answer.add(fexpr.getFunctionName()); } } return answer; }
java
public Collection<String> calculateUDFDependees() { List<String> answer = new ArrayList<>(); Collection<AbstractExpression> fCalls = findAllSubexpressionsOfClass(FunctionExpression.class); for (AbstractExpression fCall : fCalls) { FunctionExpression fexpr = (FunctionExpression)fCall; if (fexpr.isUserDefined()) { answer.add(fexpr.getFunctionName()); } } return answer; }
[ "public", "Collection", "<", "String", ">", "calculateUDFDependees", "(", ")", "{", "List", "<", "String", ">", "answer", "=", "new", "ArrayList", "<>", "(", ")", ";", "Collection", "<", "AbstractExpression", ">", "fCalls", "=", "findAllSubexpressionsOfClass", ...
Calculate the UDF dependees. These are the UDFs called in an expression in this procedure. @return The list of names of UDF dependees. These are function names, and should all be in lower case.
[ "Calculate", "the", "UDF", "dependees", ".", "These", "are", "the", "UDFs", "called", "in", "an", "expression", "in", "this", "procedure", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/AbstractParsedStmt.java#L2382-L2392
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/CompiledPlan.java
CompiledPlan.statementGuaranteesDeterminism
public void statementGuaranteesDeterminism(boolean hasLimitOrOffset, boolean order, String contentDeterminismDetail) { m_statementHasLimitOrOffset = hasLimitOrOffset; m_statementIsOrderDeterministic = order; if (contentDeterminismDetail != null) { m_contentDeterminismDetail = contentDeterminismDetail; } }
java
public void statementGuaranteesDeterminism(boolean hasLimitOrOffset, boolean order, String contentDeterminismDetail) { m_statementHasLimitOrOffset = hasLimitOrOffset; m_statementIsOrderDeterministic = order; if (contentDeterminismDetail != null) { m_contentDeterminismDetail = contentDeterminismDetail; } }
[ "public", "void", "statementGuaranteesDeterminism", "(", "boolean", "hasLimitOrOffset", ",", "boolean", "order", ",", "String", "contentDeterminismDetail", ")", "{", "m_statementHasLimitOrOffset", "=", "hasLimitOrOffset", ";", "m_statementIsOrderDeterministic", "=", "order", ...
Mark the level of result determinism imposed by the statement, which can save us from a difficult determination based on the plan graph.
[ "Mark", "the", "level", "of", "result", "determinism", "imposed", "by", "the", "statement", "which", "can", "save", "us", "from", "a", "difficult", "determination", "based", "on", "the", "plan", "graph", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/CompiledPlan.java#L133-L141
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/CompiledPlan.java
CompiledPlan.setParamIndexes
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); } }
java
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); } }
[ "private", "static", "void", "setParamIndexes", "(", "BitSet", "ints", ",", "List", "<", "AbstractExpression", ">", "params", ")", "{", "for", "(", "AbstractExpression", "ae", ":", "params", ")", "{", "assert", "(", "ae", "instanceof", "ParameterValueExpression"...
sources of bindings, IndexScans and IndexCounts.
[ "sources", "of", "bindings", "IndexScans", "and", "IndexCounts", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/CompiledPlan.java#L230-L237
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/CompiledPlan.java
CompiledPlan.bitSetToIntVector
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; nextBit = ints.nextSetBit(nextBit+1); } assert(nextBit == -1); return result; }
java
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; nextBit = ints.nextSetBit(nextBit+1); } assert(nextBit == -1); return result; }
[ "private", "static", "int", "[", "]", "bitSetToIntVector", "(", "BitSet", "ints", ")", "{", "int", "intCount", "=", "ints", ".", "cardinality", "(", ")", ";", "if", "(", "intCount", "==", "0", ")", "{", "return", "null", ";", "}", "int", "[", "]", ...
to convert the set bits to their integer indexes.
[ "to", "convert", "the", "set", "bits", "to", "their", "integer", "indexes", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/CompiledPlan.java#L241-L255
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/CompiledPlan.java
CompiledPlan.parameterTypes
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; }
java
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; }
[ "public", "VoltType", "[", "]", "parameterTypes", "(", ")", "{", "if", "(", "m_parameterTypes", "==", "null", ")", "{", "m_parameterTypes", "=", "new", "VoltType", "[", "getParameters", "(", ")", ".", "length", "]", ";", "int", "ii", "=", "0", ";", "fo...
This is assumed to be called only after parameters has been fully initialized.
[ "This", "is", "assumed", "to", "be", "called", "only", "after", "parameters", "has", "been", "fully", "initialized", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/CompiledPlan.java#L287-L296
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.newSession
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; }
java
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; }
[ "public", "static", "Session", "newSession", "(", "int", "dbID", ",", "String", "user", ",", "String", "password", ",", "int", "timeZoneSeconds", ")", "{", "Database", "db", "=", "(", "Database", ")", "databaseIDMap", ".", "get", "(", "dbID", ")", ";", "...
Used by server to open a new session
[ "Used", "by", "server", "to", "open", "a", "new", "session" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L147-L161
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.newSession
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); }
java
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); }
[ "public", "static", "Session", "newSession", "(", "String", "type", ",", "String", "path", ",", "String", "user", ",", "String", "password", ",", "HsqlProperties", "props", ",", "int", "timeZoneSeconds", ")", "{", "Database", "db", "=", "getDatabase", "(", "...
Used by in-process connections and by Servlet
[ "Used", "by", "in", "-", "process", "connections", "and", "by", "Servlet" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L166-L177
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.lookupDatabaseObject
public static synchronized Database lookupDatabaseObject(String type, String path) { // A VoltDB extension to work around ENG-6044 /* disabled 14 lines ... Object key = path; HashMap databaseMap; if (type == DatabaseURL.S_FILE) { databaseMap = fileDatabaseMap; key = filePathToKey(path); } else if (type == DatabaseURL.S_RES) { databaseMap = resDatabaseMap; } else if (type == DatabaseURL.S_MEM) { databaseMap = memDatabaseMap; } else { throw (Error.runtimeError( ErrorCode.U_S0500, "DatabaseManager.lookupDatabaseObject()")); } ... disabled 14 lines */ assert (type == DatabaseURL.S_MEM); java.util.HashMap<String, Database> databaseMap = memDatabaseMap; String key = path; // End of VoltDB extension return (Database) databaseMap.get(key); }
java
public static synchronized Database lookupDatabaseObject(String type, String path) { // A VoltDB extension to work around ENG-6044 /* disabled 14 lines ... Object key = path; HashMap databaseMap; if (type == DatabaseURL.S_FILE) { databaseMap = fileDatabaseMap; key = filePathToKey(path); } else if (type == DatabaseURL.S_RES) { databaseMap = resDatabaseMap; } else if (type == DatabaseURL.S_MEM) { databaseMap = memDatabaseMap; } else { throw (Error.runtimeError( ErrorCode.U_S0500, "DatabaseManager.lookupDatabaseObject()")); } ... disabled 14 lines */ assert (type == DatabaseURL.S_MEM); java.util.HashMap<String, Database> databaseMap = memDatabaseMap; String key = path; // End of VoltDB extension return (Database) databaseMap.get(key); }
[ "public", "static", "synchronized", "Database", "lookupDatabaseObject", "(", "String", "type", ",", "String", "path", ")", "{", "// A VoltDB extension to work around ENG-6044", "/* disabled 14 lines ...\n Object key = path;\n HashMap databaseMap;\n\n if (type == Dat...
Looks up database of a given type and path in the registry. Returns null if there is none.
[ "Looks", "up", "database", "of", "a", "given", "type", "and", "path", "in", "the", "registry", ".", "Returns", "null", "if", "there", "is", "none", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L321-L348
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.addDatabaseObject
private static synchronized void addDatabaseObject(String type, String path, Database db) { // A VoltDB extension to work around ENG-6044 /* disable 15 lines ... Object key = path; HashMap databaseMap; if (type == DatabaseURL.S_FILE) { databaseMap = fileDatabaseMap; key = filePathToKey(path); } else if (type == DatabaseURL.S_RES) { databaseMap = resDatabaseMap; } else if (type == DatabaseURL.S_MEM) { databaseMap = memDatabaseMap; } else { throw Error.runtimeError(ErrorCode.U_S0500, "DatabaseManager.addDatabaseObject()"); } ... disabled 15 lines */ assert(type == DatabaseURL.S_MEM); java.util.HashMap<String, Database> databaseMap = memDatabaseMap; String key = path; // End of VoltDB extension databaseIDMap.put(db.databaseID, db); databaseMap.put(key, db); }
java
private static synchronized void addDatabaseObject(String type, String path, Database db) { // A VoltDB extension to work around ENG-6044 /* disable 15 lines ... Object key = path; HashMap databaseMap; if (type == DatabaseURL.S_FILE) { databaseMap = fileDatabaseMap; key = filePathToKey(path); } else if (type == DatabaseURL.S_RES) { databaseMap = resDatabaseMap; } else if (type == DatabaseURL.S_MEM) { databaseMap = memDatabaseMap; } else { throw Error.runtimeError(ErrorCode.U_S0500, "DatabaseManager.addDatabaseObject()"); } ... disabled 15 lines */ assert(type == DatabaseURL.S_MEM); java.util.HashMap<String, Database> databaseMap = memDatabaseMap; String key = path; // End of VoltDB extension databaseIDMap.put(db.databaseID, db); databaseMap.put(key, db); }
[ "private", "static", "synchronized", "void", "addDatabaseObject", "(", "String", "type", ",", "String", "path", ",", "Database", "db", ")", "{", "// A VoltDB extension to work around ENG-6044", "/* disable 15 lines ...\n Object key = path;\n\n HashMap databaseMap;\n\...
Adds a database to the registry. Returns null if there is none.
[ "Adds", "a", "database", "to", "the", "registry", ".", "Returns", "null", "if", "there", "is", "none", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L354-L383
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.removeDatabase
static void removeDatabase(Database database) { int dbID = database.databaseID; String type = database.getType(); String path = database.getPath(); // A VoltDB extension to work around ENG-6044 /* disable 2 lines ... Object key = path; HashMap databaseMap; ... disabled 2 lines */ // End of VoltDB extension notifyServers(database); // A VoltDB extension to work around ENG-6044 /* disable 11 lines ... if (type == DatabaseURL.S_FILE) { databaseMap = fileDatabaseMap; key = filePathToKey(path); } else if (type == DatabaseURL.S_RES) { databaseMap = resDatabaseMap; } else if (type == DatabaseURL.S_MEM) { databaseMap = memDatabaseMap; } else { throw (Error.runtimeError( ErrorCode.U_S0500, "DatabaseManager.lookupDatabaseObject()")); } ... disabled 11 lines */ assert(type == DatabaseURL.S_MEM); java.util.HashMap<String, Database> databaseMap = memDatabaseMap; String key = path; // End of VoltDB extension databaseIDMap.remove(dbID); databaseMap.remove(key); if (databaseIDMap.isEmpty()) { ValuePool.resetPool(); } }
java
static void removeDatabase(Database database) { int dbID = database.databaseID; String type = database.getType(); String path = database.getPath(); // A VoltDB extension to work around ENG-6044 /* disable 2 lines ... Object key = path; HashMap databaseMap; ... disabled 2 lines */ // End of VoltDB extension notifyServers(database); // A VoltDB extension to work around ENG-6044 /* disable 11 lines ... if (type == DatabaseURL.S_FILE) { databaseMap = fileDatabaseMap; key = filePathToKey(path); } else if (type == DatabaseURL.S_RES) { databaseMap = resDatabaseMap; } else if (type == DatabaseURL.S_MEM) { databaseMap = memDatabaseMap; } else { throw (Error.runtimeError( ErrorCode.U_S0500, "DatabaseManager.lookupDatabaseObject()")); } ... disabled 11 lines */ assert(type == DatabaseURL.S_MEM); java.util.HashMap<String, Database> databaseMap = memDatabaseMap; String key = path; // End of VoltDB extension databaseIDMap.remove(dbID); databaseMap.remove(key); if (databaseIDMap.isEmpty()) { ValuePool.resetPool(); } }
[ "static", "void", "removeDatabase", "(", "Database", "database", ")", "{", "int", "dbID", "=", "database", ".", "databaseID", ";", "String", "type", "=", "database", ".", "getType", "(", ")", ";", "String", "path", "=", "database", ".", "getPath", "(", "...
Removes the database from registry.
[ "Removes", "the", "database", "from", "registry", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L388-L428
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.deRegisterServer
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(); } } }
java
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(); } } }
[ "private", "static", "void", "deRegisterServer", "(", "Server", "server", ",", "Database", "db", ")", "{", "Iterator", "it", "=", "serverMap", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "for", "(", ";", "it", ".", "hasNext", "(", ")", "...
Deregisters a server as serving a given database. Not yet used.
[ "Deregisters", "a", "server", "as", "serving", "a", "given", "database", ".", "Not", "yet", "used", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L449-L462
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.registerServer
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); }
java
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); }
[ "private", "static", "void", "registerServer", "(", "Server", "server", ",", "Database", "db", ")", "{", "if", "(", "!", "serverMap", ".", "containsKey", "(", "server", ")", ")", "{", "serverMap", ".", "put", "(", "server", ",", "new", "HashSet", "(", ...
Registers a server as serving a given database.
[ "Registers", "a", "server", "as", "serving", "a", "given", "database", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L467-L476
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.notifyServers
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)) { // A VoltDB extension to disable a package dependency /* disable 2 lines ... server.notify(ServerConstants.SC_DATABASE_SHUTDOWN, db.databaseID); ... disabled 2 lines */ // End of VoltDB extension } } }
java
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)) { // A VoltDB extension to disable a package dependency /* disable 2 lines ... server.notify(ServerConstants.SC_DATABASE_SHUTDOWN, db.databaseID); ... disabled 2 lines */ // End of VoltDB extension } } }
[ "private", "static", "void", "notifyServers", "(", "Database", "db", ")", "{", "Iterator", "it", "=", "serverMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "for", "(", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Server", "s...
Notifies all servers that serve the database that the database has been shutdown.
[ "Notifies", "all", "servers", "that", "serve", "the", "database", "that", "the", "database", "has", "been", "shutdown", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L482-L499
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java
DatabaseManager.filePathToKey
private static String filePathToKey(String path) { try { return FileUtil.getDefaultInstance().canonicalPath(path); } catch (Exception e) { return path; } }
java
private static String filePathToKey(String path) { try { return FileUtil.getDefaultInstance().canonicalPath(path); } catch (Exception e) { return path; } }
[ "private", "static", "String", "filePathToKey", "(", "String", "path", ")", "{", "try", "{", "return", "FileUtil", ".", "getDefaultInstance", "(", ")", ".", "canonicalPath", "(", "path", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", ...
thrown exception to an HsqlException in the process
[ "thrown", "exception", "to", "an", "HsqlException", "in", "the", "process" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/DatabaseManager.java#L526-L533
train
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.isComment
public static boolean isComment(String sql) { Matcher commentMatcher = PAT_SINGLE_LINE_COMMENT.matcher(sql); return commentMatcher.matches(); }
java
public static boolean isComment(String sql) { Matcher commentMatcher = PAT_SINGLE_LINE_COMMENT.matcher(sql); return commentMatcher.matches(); }
[ "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. @param sql SQL string @return true if it's a comment
[ "Check", "if", "a", "SQL", "string", "is", "a", "comment", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L167-L171
train
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.extractDDLToken
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; }
java
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; }
[ "public", "static", "String", "extractDDLToken", "(", "String", "sql", ")", "{", "String", "ddlToken", "=", "null", ";", "Matcher", "ddlMatcher", "=", "PAT_ANY_DDL_FIRST_TOKEN", ".", "matcher", "(", "sql", ")", ";", "if", "(", "ddlMatcher", ".", "find", "(",...
Get the DDL token, if any, at the start of this statement. @return returns token, or null if it wasn't DDL
[ "Get", "the", "DDL", "token", "if", "any", "at", "the", "start", "of", "this", "statement", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L187-L195
train
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.extractDDLTableName
public static String extractDDLTableName(String sql) { Matcher matcher = PAT_TABLE_DDL_PREAMBLE.matcher(sql); if (matcher.find()) { return matcher.group(2).toLowerCase(); } return null; }
java
public static String extractDDLTableName(String sql) { Matcher matcher = PAT_TABLE_DDL_PREAMBLE.matcher(sql); if (matcher.find()) { return matcher.group(2).toLowerCase(); } return null; }
[ "public", "static", "String", "extractDDLTableName", "(", "String", "sql", ")", "{", "Matcher", "matcher", "=", "PAT_TABLE_DDL_PREAMBLE", ".", "matcher", "(", "sql", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "return", "matcher", ".",...
Get the table name for a CREATE or DROP DDL statement. @return returns token, or null if the DDL isn't (CREATE|DROP) TABLE
[ "Get", "the", "table", "name", "for", "a", "CREATE", "or", "DROP", "DDL", "statement", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L248-L255
train
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.checkPermitted
public static String checkPermitted(String sql) { /* * IMPORTANT: Black-lists are checked first because they know more about * what they don't like about a statement and can provide a better message. * It requires that black-lists patterns be very selective and that they * don't mind seeing statements that wouldn't pass the white-lists. */ //=== Check against blacklists, must not be rejected by any. for (CheckedPattern cp : BLACKLISTS) { CheckedPattern.Result result = cp.check(sql); if (result.matcher != null) { return String.format("%s, in statement: %s", result.explanation, sql); } } //=== Check against whitelists, must be accepted by at least one. boolean hadWLMatch = false; for (CheckedPattern cp : WHITELISTS) { if (cp.matches(sql)) { hadWLMatch = true; break; } } if (!hadWLMatch) { return String.format("AdHoc DDL contains an unsupported statement: %s", sql); } // The statement is permitted. return null; }
java
public static String checkPermitted(String sql) { /* * IMPORTANT: Black-lists are checked first because they know more about * what they don't like about a statement and can provide a better message. * It requires that black-lists patterns be very selective and that they * don't mind seeing statements that wouldn't pass the white-lists. */ //=== Check against blacklists, must not be rejected by any. for (CheckedPattern cp : BLACKLISTS) { CheckedPattern.Result result = cp.check(sql); if (result.matcher != null) { return String.format("%s, in statement: %s", result.explanation, sql); } } //=== Check against whitelists, must be accepted by at least one. boolean hadWLMatch = false; for (CheckedPattern cp : WHITELISTS) { if (cp.matches(sql)) { hadWLMatch = true; break; } } if (!hadWLMatch) { return String.format("AdHoc DDL contains an unsupported statement: %s", sql); } // The statement is permitted. return null; }
[ "public", "static", "String", "checkPermitted", "(", "String", "sql", ")", "{", "/*\n * IMPORTANT: Black-lists are checked first because they know more about\n * what they don't like about a statement and can provide a better message.\n * It requires that black-lists patte...
Naive filtering for stuff we haven't implemented yet. Hopefully this gets whittled away and eventually disappears. @param sql statement to check @return rejection explanation string or null if accepted
[ "Naive", "filtering", "for", "stuff", "we", "haven", "t", "implemented", "yet", ".", "Hopefully", "this", "gets", "whittled", "away", "and", "eventually", "disappears", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L264-L297
train
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.matchesStringAtIndex
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; }
java
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; }
[ "static", "private", "boolean", "matchesStringAtIndex", "(", "char", "[", "]", "buf", ",", "int", "index", ",", "String", "str", ")", "{", "int", "strLength", "=", "str", ".", "length", "(", ")", ";", "if", "(", "index", "+", "strLength", ">", "buf", ...
Determine if a character buffer contains the specified string a the specified index. Avoids an array index exception if the buffer is too short. @param buf a character buffer @param index an offset into the buffer @param str the string to look for @return true if the buffer contains the specified string
[ "Determine", "if", "a", "character", "buffer", "contains", "the", "specified", "string", "a", "the", "specified", "index", ".", "Avoids", "an", "array", "index", "exception", "if", "the", "buffer", "is", "too", "short", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L395-L408
train
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.removeCStyleComments
private static String removeCStyleComments(String ddl) { // Avoid Apache commons StringUtils.join() to minimize client dependencies. StringBuilder sb = new StringBuilder(); for (String part : PAT_STRIP_CSTYLE_COMMENTS.split(ddl)) { sb.append(part); } return sb.toString(); }
java
private static String removeCStyleComments(String ddl) { // Avoid Apache commons StringUtils.join() to minimize client dependencies. StringBuilder sb = new StringBuilder(); for (String part : PAT_STRIP_CSTYLE_COMMENTS.split(ddl)) { sb.append(part); } return sb.toString(); }
[ "private", "static", "String", "removeCStyleComments", "(", "String", "ddl", ")", "{", "// Avoid Apache commons StringUtils.join() to minimize client dependencies.", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "part", ":", "P...
Remove c-style comments from a string aggressively
[ "Remove", "c", "-", "style", "comments", "from", "a", "string", "aggressively" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L677-L685
train
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.findObjectToken
private static ObjectToken findObjectToken(String objectTypeName) { if (objectTypeName != null) { for (ObjectToken ot : OBJECT_TOKENS) { if (ot.token.equalsIgnoreCase(objectTypeName)) { return ot; } } } return null; }
java
private static ObjectToken findObjectToken(String objectTypeName) { if (objectTypeName != null) { for (ObjectToken ot : OBJECT_TOKENS) { if (ot.token.equalsIgnoreCase(objectTypeName)) { return ot; } } } return null; }
[ "private", "static", "ObjectToken", "findObjectToken", "(", "String", "objectTypeName", ")", "{", "if", "(", "objectTypeName", "!=", "null", ")", "{", "for", "(", "ObjectToken", "ot", ":", "OBJECT_TOKENS", ")", "{", "if", "(", "ot", ".", "token", ".", "equ...
Find information about an object type token, if it's a known object type. @param objectTypeName object type name to look up @return object token information or null if it wasn't found
[ "Find", "information", "about", "an", "object", "type", "token", "if", "it", "s", "a", "known", "object", "type", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L692-L702
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/TriggerDef.java
TriggerDef.pushPair
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(); // overwrite last } else { try { wait(); } catch (InterruptedException e) { /* ignore and resume */ } rowsQueued++; } } else { rowsQueued++; } pendingQueue.add(new TriggerData(session, row1, row2)); notify(); // notify pop's wait }
java
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(); // overwrite last } else { try { wait(); } catch (InterruptedException e) { /* ignore and resume */ } rowsQueued++; } } else { rowsQueued++; } pendingQueue.add(new TriggerData(session, row1, row2)); notify(); // notify pop's wait }
[ "synchronized", "void", "pushPair", "(", "Session", "session", ",", "Object", "[", "]", "row1", ",", "Object", "[", "]", "row2", ")", "{", "if", "(", "maxRowsQueued", "==", "0", ")", "{", "trigger", ".", "fire", "(", "triggerType", ",", "name", ".", ...
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. @param row1 @param row2
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/TriggerDef.java#L445-L473
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/PlannerTool.java
PlannerTool.planSqlCore
public synchronized CompiledPlan planSqlCore(String sql, StatementPartitioning partitioning) { TrivialCostModel costModel = new TrivialCostModel(); DatabaseEstimates estimates = new DatabaseEstimates(); CompiledPlan plan = null; // This try-with-resources block acquires a global lock on all planning // This is required until we figure out how to do parallel planning. try (QueryPlanner planner = new QueryPlanner( sql, "PlannerTool", "PlannerToolProc", m_database, partitioning, m_hsql, estimates, !VoltCompiler.DEBUG_MODE, costModel, null, null, DeterminismMode.FASTER, false)) { // do the expensive full planning. planner.parse(); plan = planner.plan(); assert(plan != null); } catch (Exception e) { /* * Don't log PlanningErrorExceptions or HSQLParseExceptions, as they * are at least somewhat expected. */ String loggedMsg = ""; if (!(e instanceof PlanningErrorException || e instanceof HSQLParseException)) { logException(e, "Error compiling query"); loggedMsg = " (Stack trace has been written to the log.)"; } if (e.getMessage() != null) { throw new RuntimeException("SQL error while compiling query: " + e.getMessage() + loggedMsg, e); } throw new RuntimeException("SQL error while compiling query: " + e.toString() + loggedMsg, e); } if (plan == null) { throw new RuntimeException("Null plan received in PlannerTool.planSql"); } return plan; }
java
public synchronized CompiledPlan planSqlCore(String sql, StatementPartitioning partitioning) { TrivialCostModel costModel = new TrivialCostModel(); DatabaseEstimates estimates = new DatabaseEstimates(); CompiledPlan plan = null; // This try-with-resources block acquires a global lock on all planning // This is required until we figure out how to do parallel planning. try (QueryPlanner planner = new QueryPlanner( sql, "PlannerTool", "PlannerToolProc", m_database, partitioning, m_hsql, estimates, !VoltCompiler.DEBUG_MODE, costModel, null, null, DeterminismMode.FASTER, false)) { // do the expensive full planning. planner.parse(); plan = planner.plan(); assert(plan != null); } catch (Exception e) { /* * Don't log PlanningErrorExceptions or HSQLParseExceptions, as they * are at least somewhat expected. */ String loggedMsg = ""; if (!(e instanceof PlanningErrorException || e instanceof HSQLParseException)) { logException(e, "Error compiling query"); loggedMsg = " (Stack trace has been written to the log.)"; } if (e.getMessage() != null) { throw new RuntimeException("SQL error while compiling query: " + e.getMessage() + loggedMsg, e); } throw new RuntimeException("SQL error while compiling query: " + e.toString() + loggedMsg, e); } if (plan == null) { throw new RuntimeException("Null plan received in PlannerTool.planSql"); } return plan; }
[ "public", "synchronized", "CompiledPlan", "planSqlCore", "(", "String", "sql", ",", "StatementPartitioning", "partitioning", ")", "{", "TrivialCostModel", "costModel", "=", "new", "TrivialCostModel", "(", ")", ";", "DatabaseEstimates", "estimates", "=", "new", "Databa...
Stripped down compile that is ONLY used to plan default procedures.
[ "Stripped", "down", "compile", "that", "is", "ONLY", "used", "to", "plan", "default", "procedures", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/PlannerTool.java#L147-L185
train
VoltDB/voltdb
src/frontend/org/voltdb/StatsAgent.java
StatsAgent.isReadOnlyProcedure
private boolean isReadOnlyProcedure(String pname) { final Boolean b = m_procedureInfo.get().get(pname); if (b == null) { return false; } return b; }
java
private boolean isReadOnlyProcedure(String pname) { final Boolean b = m_procedureInfo.get().get(pname); if (b == null) { return false; } return b; }
[ "private", "boolean", "isReadOnlyProcedure", "(", "String", "pname", ")", "{", "final", "Boolean", "b", "=", "m_procedureInfo", ".", "get", "(", ")", ".", "get", "(", "pname", ")", ";", "if", "(", "b", "==", "null", ")", "{", "return", "false", ";", ...
Check if procedure is readonly? @param pname @return
[ "Check", "if", "procedure", "is", "readonly?" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/StatsAgent.java#L118-L124
train
VoltDB/voltdb
src/frontend/org/voltdb/StatsAgent.java
StatsAgent.aggregateProcedureProfileStats
private VoltTable[] aggregateProcedureProfileStats(VoltTable[] baseStats) { if (baseStats == null || baseStats.length != 1) { return baseStats; } StatsProcProfTable timeTable = new StatsProcProfTable(); baseStats[0].resetRowPosition(); while (baseStats[0].advanceRow()) { // Skip non-transactional procedures for some of these rollups until // we figure out how to make them less confusing. // NB: They still show up in the raw PROCEDURE stata. boolean transactional = baseStats[0].getLong("TRANSACTIONAL") == 1; if (!transactional) { continue; } if ( ! baseStats[0].getString("STATEMENT").equalsIgnoreCase("<ALL>")) { continue; } String pname = baseStats[0].getString("PROCEDURE"); timeTable.updateTable(!isReadOnlyProcedure(pname), baseStats[0].getLong("TIMESTAMP"), pname, baseStats[0].getLong("PARTITION_ID"), baseStats[0].getLong("INVOCATIONS"), baseStats[0].getLong("MIN_EXECUTION_TIME"), baseStats[0].getLong("MAX_EXECUTION_TIME"), baseStats[0].getLong("AVG_EXECUTION_TIME"), baseStats[0].getLong("FAILURES"), baseStats[0].getLong("ABORTS")); } return new VoltTable[] { timeTable.sortByAverage("EXECUTION_TIME") }; }
java
private VoltTable[] aggregateProcedureProfileStats(VoltTable[] baseStats) { if (baseStats == null || baseStats.length != 1) { return baseStats; } StatsProcProfTable timeTable = new StatsProcProfTable(); baseStats[0].resetRowPosition(); while (baseStats[0].advanceRow()) { // Skip non-transactional procedures for some of these rollups until // we figure out how to make them less confusing. // NB: They still show up in the raw PROCEDURE stata. boolean transactional = baseStats[0].getLong("TRANSACTIONAL") == 1; if (!transactional) { continue; } if ( ! baseStats[0].getString("STATEMENT").equalsIgnoreCase("<ALL>")) { continue; } String pname = baseStats[0].getString("PROCEDURE"); timeTable.updateTable(!isReadOnlyProcedure(pname), baseStats[0].getLong("TIMESTAMP"), pname, baseStats[0].getLong("PARTITION_ID"), baseStats[0].getLong("INVOCATIONS"), baseStats[0].getLong("MIN_EXECUTION_TIME"), baseStats[0].getLong("MAX_EXECUTION_TIME"), baseStats[0].getLong("AVG_EXECUTION_TIME"), baseStats[0].getLong("FAILURES"), baseStats[0].getLong("ABORTS")); } return new VoltTable[] { timeTable.sortByAverage("EXECUTION_TIME") }; }
[ "private", "VoltTable", "[", "]", "aggregateProcedureProfileStats", "(", "VoltTable", "[", "]", "baseStats", ")", "{", "if", "(", "baseStats", "==", "null", "||", "baseStats", ".", "length", "!=", "1", ")", "{", "return", "baseStats", ";", "}", "StatsProcPro...
Produce PROCEDUREPROFILE aggregation of PROCEDURE subselector
[ "Produce", "PROCEDUREPROFILE", "aggregation", "of", "PROCEDURE", "subselector" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/StatsAgent.java#L189-L223
train
VoltDB/voltdb
src/frontend/org/voltdb/StatsAgent.java
StatsAgent.aggregateProcedureInputStats
private VoltTable[] aggregateProcedureInputStats(VoltTable[] baseStats) { if (baseStats == null || baseStats.length != 1) { return baseStats; } StatsProcInputTable timeTable = new StatsProcInputTable(); baseStats[0].resetRowPosition(); while (baseStats[0].advanceRow()) { // Skip non-transactional procedures for some of these rollups until // we figure out how to make them less confusing. // NB: They still show up in the raw PROCEDURE stata. boolean transactional = baseStats[0].getLong("TRANSACTIONAL") == 1; if (!transactional) { continue; } if ( ! baseStats[0].getString("STATEMENT").equalsIgnoreCase("<ALL>")) { continue; } String pname = baseStats[0].getString("PROCEDURE"); timeTable.updateTable(!isReadOnlyProcedure(pname), pname, baseStats[0].getLong("PARTITION_ID"), baseStats[0].getLong("TIMESTAMP"), baseStats[0].getLong("INVOCATIONS"), baseStats[0].getLong("MIN_PARAMETER_SET_SIZE"), baseStats[0].getLong("MAX_PARAMETER_SET_SIZE"), baseStats[0].getLong("AVG_PARAMETER_SET_SIZE") ); } return new VoltTable[] { timeTable.sortByInput("PROCEDURE_INPUT") }; }
java
private VoltTable[] aggregateProcedureInputStats(VoltTable[] baseStats) { if (baseStats == null || baseStats.length != 1) { return baseStats; } StatsProcInputTable timeTable = new StatsProcInputTable(); baseStats[0].resetRowPosition(); while (baseStats[0].advanceRow()) { // Skip non-transactional procedures for some of these rollups until // we figure out how to make them less confusing. // NB: They still show up in the raw PROCEDURE stata. boolean transactional = baseStats[0].getLong("TRANSACTIONAL") == 1; if (!transactional) { continue; } if ( ! baseStats[0].getString("STATEMENT").equalsIgnoreCase("<ALL>")) { continue; } String pname = baseStats[0].getString("PROCEDURE"); timeTable.updateTable(!isReadOnlyProcedure(pname), pname, baseStats[0].getLong("PARTITION_ID"), baseStats[0].getLong("TIMESTAMP"), baseStats[0].getLong("INVOCATIONS"), baseStats[0].getLong("MIN_PARAMETER_SET_SIZE"), baseStats[0].getLong("MAX_PARAMETER_SET_SIZE"), baseStats[0].getLong("AVG_PARAMETER_SET_SIZE") ); } return new VoltTable[] { timeTable.sortByInput("PROCEDURE_INPUT") }; }
[ "private", "VoltTable", "[", "]", "aggregateProcedureInputStats", "(", "VoltTable", "[", "]", "baseStats", ")", "{", "if", "(", "baseStats", "==", "null", "||", "baseStats", ".", "length", "!=", "1", ")", "{", "return", "baseStats", ";", "}", "StatsProcInput...
Produce PROCEDUREINPUT aggregation of PROCEDURE subselector
[ "Produce", "PROCEDUREINPUT", "aggregation", "of", "PROCEDURE", "subselector" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/StatsAgent.java#L227-L259
train
VoltDB/voltdb
src/frontend/org/voltdb/StatsAgent.java
StatsAgent.aggregateProcedureOutputStats
private VoltTable[] aggregateProcedureOutputStats(VoltTable[] baseStats) { if (baseStats == null || baseStats.length != 1) { return baseStats; } StatsProcOutputTable timeTable = new StatsProcOutputTable(); baseStats[0].resetRowPosition(); while (baseStats[0].advanceRow()) { // Skip non-transactional procedures for some of these rollups until // we figure out how to make them less confusing. // NB: They still show up in the raw PROCEDURE stata. boolean transactional = baseStats[0].getLong("TRANSACTIONAL") == 1; if (!transactional) { continue; } if ( ! baseStats[0].getString("STATEMENT").equalsIgnoreCase("<ALL>")) { continue; } String pname = baseStats[0].getString("PROCEDURE"); timeTable.updateTable(!isReadOnlyProcedure(pname), pname, baseStats[0].getLong("PARTITION_ID"), baseStats[0].getLong("TIMESTAMP"), baseStats[0].getLong("INVOCATIONS"), baseStats[0].getLong("MIN_RESULT_SIZE"), baseStats[0].getLong("MAX_RESULT_SIZE"), baseStats[0].getLong("AVG_RESULT_SIZE") ); } return new VoltTable[] { timeTable.sortByOutput("PROCEDURE_OUTPUT") }; }
java
private VoltTable[] aggregateProcedureOutputStats(VoltTable[] baseStats) { if (baseStats == null || baseStats.length != 1) { return baseStats; } StatsProcOutputTable timeTable = new StatsProcOutputTable(); baseStats[0].resetRowPosition(); while (baseStats[0].advanceRow()) { // Skip non-transactional procedures for some of these rollups until // we figure out how to make them less confusing. // NB: They still show up in the raw PROCEDURE stata. boolean transactional = baseStats[0].getLong("TRANSACTIONAL") == 1; if (!transactional) { continue; } if ( ! baseStats[0].getString("STATEMENT").equalsIgnoreCase("<ALL>")) { continue; } String pname = baseStats[0].getString("PROCEDURE"); timeTable.updateTable(!isReadOnlyProcedure(pname), pname, baseStats[0].getLong("PARTITION_ID"), baseStats[0].getLong("TIMESTAMP"), baseStats[0].getLong("INVOCATIONS"), baseStats[0].getLong("MIN_RESULT_SIZE"), baseStats[0].getLong("MAX_RESULT_SIZE"), baseStats[0].getLong("AVG_RESULT_SIZE") ); } return new VoltTable[] { timeTable.sortByOutput("PROCEDURE_OUTPUT") }; }
[ "private", "VoltTable", "[", "]", "aggregateProcedureOutputStats", "(", "VoltTable", "[", "]", "baseStats", ")", "{", "if", "(", "baseStats", "==", "null", "||", "baseStats", ".", "length", "!=", "1", ")", "{", "return", "baseStats", ";", "}", "StatsProcOutp...
Produce PROCEDUREOUTPUT aggregation of PROCEDURE subselector
[ "Produce", "PROCEDUREOUTPUT", "aggregation", "of", "PROCEDURE", "subselector" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/StatsAgent.java#L265-L297
train
VoltDB/voltdb
src/frontend/org/voltdb/StatsAgent.java
StatsAgent.notifyOfCatalogUpdate
public void notifyOfCatalogUpdate() { m_procedureInfo = getProcedureInformationfoSupplier(); m_registeredStatsSources.put(StatsSelector.PROCEDURE, new NonBlockingHashMap<Long, NonBlockingHashSet<StatsSource>>()); }
java
public void notifyOfCatalogUpdate() { m_procedureInfo = getProcedureInformationfoSupplier(); m_registeredStatsSources.put(StatsSelector.PROCEDURE, new NonBlockingHashMap<Long, NonBlockingHashSet<StatsSource>>()); }
[ "public", "void", "notifyOfCatalogUpdate", "(", ")", "{", "m_procedureInfo", "=", "getProcedureInformationfoSupplier", "(", ")", ";", "m_registeredStatsSources", ".", "put", "(", "StatsSelector", ".", "PROCEDURE", ",", "new", "NonBlockingHashMap", "<", "Long", ",", ...
Please be noted that this function will be called from Site thread, where most other functions in the class are from StatsAgent thread. Need to release references to catalog related stats sources to avoid hoarding references to the catalog.
[ "Please", "be", "noted", "that", "this", "function", "will", "be", "called", "from", "Site", "thread", "where", "most", "other", "functions", "in", "the", "class", "are", "from", "StatsAgent", "thread", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/StatsAgent.java#L307-L311
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/AgreementTxnIdSafetyState.java
AgreementTxnIdSafetyState.addState
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); }
java
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); }
[ "public", "void", "addState", "(", "long", "agreementHSId", ")", "{", "SiteState", "ss", "=", "m_stateBySite", ".", "get", "(", "agreementHSId", ")", ";", "if", "(", "ss", "!=", "null", ")", "return", ";", "ss", "=", "new", "SiteState", "(", ")", ";", ...
Once a failed node is rejoined, put it's sites back into all of the data structures here. @param executorSiteId @param partitionId
[ "Once", "a", "failed", "node", "is", "rejoined", "put", "it", "s", "sites", "back", "into", "all", "of", "the", "data", "structures", "here", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/AgreementTxnIdSafetyState.java#L107-L114
train
VoltDB/voltdb
src/frontend/org/voltdb/iv2/Scoreboard.java
Scoreboard.pollFirstCompletionTask
public Pair<CompleteTransactionTask, Boolean> pollFirstCompletionTask(CompletionCounter nextTaskCounter) { // remove from the head Pair<CompleteTransactionTask, Boolean> pair = m_compTasks.pollFirstEntry().getValue(); if (m_compTasks.isEmpty()) { return pair; } // check next task for completion to ensure that the heads on all the site // have the same transaction and timestamp Pair<CompleteTransactionTask, Boolean> next = peekFirst(); if (nextTaskCounter.txnId == 0L) { nextTaskCounter.txnId = next.getFirst().getMsgTxnId(); nextTaskCounter.completionCount++; nextTaskCounter.timestamp = next.getFirst().getTimestamp(); } else if (nextTaskCounter.txnId == next.getFirst().getMsgTxnId() && nextTaskCounter.timestamp == next.getFirst().getTimestamp()) { nextTaskCounter.completionCount++; } return pair; }
java
public Pair<CompleteTransactionTask, Boolean> pollFirstCompletionTask(CompletionCounter nextTaskCounter) { // remove from the head Pair<CompleteTransactionTask, Boolean> pair = m_compTasks.pollFirstEntry().getValue(); if (m_compTasks.isEmpty()) { return pair; } // check next task for completion to ensure that the heads on all the site // have the same transaction and timestamp Pair<CompleteTransactionTask, Boolean> next = peekFirst(); if (nextTaskCounter.txnId == 0L) { nextTaskCounter.txnId = next.getFirst().getMsgTxnId(); nextTaskCounter.completionCount++; nextTaskCounter.timestamp = next.getFirst().getTimestamp(); } else if (nextTaskCounter.txnId == next.getFirst().getMsgTxnId() && nextTaskCounter.timestamp == next.getFirst().getTimestamp()) { nextTaskCounter.completionCount++; } return pair; }
[ "public", "Pair", "<", "CompleteTransactionTask", ",", "Boolean", ">", "pollFirstCompletionTask", "(", "CompletionCounter", "nextTaskCounter", ")", "{", "// remove from the head", "Pair", "<", "CompleteTransactionTask", ",", "Boolean", ">", "pair", "=", "m_compTasks", "...
Remove the CompleteTransactionTask from the head and count the next CompleteTransactionTask @param nextTaskCounter CompletionCounter @return the removed CompleteTransactionTask
[ "Remove", "the", "CompleteTransactionTask", "from", "the", "head", "and", "count", "the", "next", "CompleteTransactionTask" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/iv2/Scoreboard.java#L75-L94
train
VoltDB/voltdb
src/frontend/org/voltdb/iv2/Scoreboard.java
Scoreboard.isComparable
private static boolean isComparable(CompleteTransactionTask c1, CompleteTransactionTask c2) { return c1.getMsgTxnId() == c2.getMsgTxnId() && MpRestartSequenceGenerator.isForRestart(c1.getTimestamp()) == MpRestartSequenceGenerator.isForRestart(c2.getTimestamp()); }
java
private static boolean isComparable(CompleteTransactionTask c1, CompleteTransactionTask c2) { return c1.getMsgTxnId() == c2.getMsgTxnId() && MpRestartSequenceGenerator.isForRestart(c1.getTimestamp()) == MpRestartSequenceGenerator.isForRestart(c2.getTimestamp()); }
[ "private", "static", "boolean", "isComparable", "(", "CompleteTransactionTask", "c1", ",", "CompleteTransactionTask", "c2", ")", "{", "return", "c1", ".", "getMsgTxnId", "(", ")", "==", "c2", ".", "getMsgTxnId", "(", ")", "&&", "MpRestartSequenceGenerator", ".", ...
4) restart completion and repair completion can't overwrite each other
[ "4", ")", "restart", "completion", "and", "repair", "completion", "can", "t", "overwrite", "each", "other" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/iv2/Scoreboard.java#L123-L127
train
VoltDB/voltdb
src/frontend/org/voltdb/iv2/Scoreboard.java
Scoreboard.matchCompleteTransactionTask
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().getTimestamp(); } } return false; }
java
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().getTimestamp(); } } return false; }
[ "public", "boolean", "matchCompleteTransactionTask", "(", "long", "txnId", ",", "long", "timestamp", ")", "{", "if", "(", "!", "m_compTasks", ".", "isEmpty", "(", ")", ")", "{", "long", "lowestTxnId", "=", "m_compTasks", ".", "firstKey", "(", ")", ";", "if...
Only match CompleteTransactionTask at head of the queue
[ "Only", "match", "CompleteTransactionTask", "at", "head", "of", "the", "queue" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/iv2/Scoreboard.java#L144-L153
train
VoltDB/voltdb
src/frontend/org/voltdb/DRRoleStats.java
DRRoleStats.aggregateStats
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) stats.getLong(CN_REMOTE_CLUSTER_ID); final String curRole = stats.getString(CN_ROLE); if (role == null) { role = curRole; } else if (!role.equals(curRole)) { throw new IllegalArgumentException("Inconsistent DR role across cluster nodes: " + stats.toFormattedString(false)); } final State state = State.valueOf(stats.getString(CN_STATE)); states.put(clusterId, state.and(states.get(clusterId))); } // Remove the -1 placeholder if there are real cluster states if (states.size() > 1) { states.remove((byte) -1); } assert role != null; stats.clearRowData(); for (Map.Entry<Byte, State> e : states.entrySet()) { stats.addRow(role, e.getValue().name(), e.getKey()); } return stats; }
java
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) stats.getLong(CN_REMOTE_CLUSTER_ID); final String curRole = stats.getString(CN_ROLE); if (role == null) { role = curRole; } else if (!role.equals(curRole)) { throw new IllegalArgumentException("Inconsistent DR role across cluster nodes: " + stats.toFormattedString(false)); } final State state = State.valueOf(stats.getString(CN_STATE)); states.put(clusterId, state.and(states.get(clusterId))); } // Remove the -1 placeholder if there are real cluster states if (states.size() > 1) { states.remove((byte) -1); } assert role != null; stats.clearRowData(); for (Map.Entry<Byte, State> e : states.entrySet()) { stats.addRow(role, e.getValue().name(), e.getKey()); } return stats; }
[ "public", "static", "VoltTable", "aggregateStats", "(", "VoltTable", "stats", ")", "throws", "IllegalArgumentException", "{", "stats", ".", "resetRowPosition", "(", ")", ";", "if", "(", "stats", ".", "getRowCount", "(", ")", "==", "0", ")", "{", "return", "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. This method modifies the VoltTable in place. @param stats Statistics from all cluster nodes. This will be modified in place. Cannot be null. @return The same VoltTable as in the parameter. @throws IllegalArgumentException If the cluster nodes don't agree on the DR role.
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/DRRoleStats.java#L169-L202
train
VoltDB/voltdb
src/frontend/org/voltdb/jdbc/Resources.java
Resources.getString
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"); String message = RESOURCE_BUNDLE.getString(key); if (message == null) message = "Missing error message for key '" + key + "'"; return message; } catch (MissingResourceException e) { return '!' + key + '!'; } }
java
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"); String message = RESOURCE_BUNDLE.getString(key); if (message == null) message = "Missing error message for key '" + key + "'"; return message; } catch (MissingResourceException e) { return '!' + key + '!'; } }
[ "public", "static", "String", "getString", "(", "String", "key", ")", "{", "if", "(", "RESOURCE_BUNDLE", "==", "null", ")", "throw", "new", "RuntimeException", "(", "\"Localized messages from resource bundle '\"", "+", "BUNDLE_NAME", "+", "\"' not loaded during initiali...
Returns the localized message for the given message key @param key the message key @return The localized message for the key
[ "Returns", "the", "localized", "message", "for", "the", "given", "message", "key" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/Resources.java#L64-L84
train
VoltDB/voltdb
src/frontend/org/voltdb/sysprocs/saverestore/SnapshotWritePlan.java
SnapshotWritePlan.createAllDevNullTargets
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 : tasksForSite) { // Close any created targets and replace them with DevNull, go web-scale if (task.getTarget(true) != null) { try { task.getTarget().close(); } catch (Exception e) { SNAP_LOG.error("Failed closing data target after error", e); } } SnapshotDataTarget target = targets.get(task.m_table.getRelativeIndex()); if (target == null) { target = new DevNullSnapshotTarget(lastWriteException); final Runnable onClose = new TargetStatsClosure(target, task.m_table.getTypeName(), numTargets, m_snapshotRecord); target.setOnCloseHandler(onClose); targets.put(task.m_table.getRelativeIndex(), target); m_targets.add(target); numTargets.incrementAndGet(); } task.setTarget(target); } } }
java
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 : tasksForSite) { // Close any created targets and replace them with DevNull, go web-scale if (task.getTarget(true) != null) { try { task.getTarget().close(); } catch (Exception e) { SNAP_LOG.error("Failed closing data target after error", e); } } SnapshotDataTarget target = targets.get(task.m_table.getRelativeIndex()); if (target == null) { target = new DevNullSnapshotTarget(lastWriteException); final Runnable onClose = new TargetStatsClosure(target, task.m_table.getTypeName(), numTargets, m_snapshotRecord); target.setOnCloseHandler(onClose); targets.put(task.m_table.getRelativeIndex(), target); m_targets.add(target); numTargets.incrementAndGet(); } task.setTarget(target); } } }
[ "public", "void", "createAllDevNullTargets", "(", "Exception", "lastWriteException", ")", "{", "Map", "<", "Integer", ",", "SnapshotDataTarget", ">", "targets", "=", "Maps", ".", "newHashMap", "(", ")", ";", "final", "AtomicInteger", "numTargets", "=", "new", "A...
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.
[ "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", "DevNullData...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotWritePlan.java#L170-L203
train
VoltDB/voltdb
src/frontend/org/voltdb/sysprocs/UpdateCore.java
UpdateCore.collapseSets
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; }
java
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; }
[ "private", "Map", "<", "String", ",", "Boolean", ">", "collapseSets", "(", "List", "<", "List", "<", "String", ">", ">", "allTableSets", ")", "{", "Map", "<", "String", ",", "Boolean", ">", "answer", "=", "new", "TreeMap", "<>", "(", ")", ";", "for",...
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. @param allTableSets @return
[ "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", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/UpdateCore.java#L183-L191
train
VoltDB/voltdb
src/frontend/org/voltdb/sysprocs/UpdateCore.java
UpdateCore.decodeTables
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; }
java
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; }
[ "private", "List", "<", "List", "<", "String", ">", ">", "decodeTables", "(", "String", "[", "]", "tablesThatMustBeEmpty", ")", "{", "List", "<", "List", "<", "String", ">>", "answer", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String",...
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. @param tablesThatMustBeEmpty @return The decoded lists.
[ "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", "late...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/UpdateCore.java#L201-L208
train
VoltDB/voltdb
src/frontend/org/voltdb/sysprocs/Shutdown.java
Shutdown.run
public VoltTable[] run(SystemProcedureExecutionContext ctx) { createAndExecuteSysProcPlan(SysProcFragmentId.PF_shutdownSync, SysProcFragmentId.PF_shutdownSyncDone); SynthesizedPlanFragment pfs[] = new SynthesizedPlanFragment[] { new SynthesizedPlanFragment(SysProcFragmentId.PF_shutdownCommand, true) }; executeSysProcPlanFragments(pfs, SysProcFragmentId.PF_procedureDone); return new VoltTable[0]; }
java
public VoltTable[] run(SystemProcedureExecutionContext ctx) { createAndExecuteSysProcPlan(SysProcFragmentId.PF_shutdownSync, SysProcFragmentId.PF_shutdownSyncDone); SynthesizedPlanFragment pfs[] = new SynthesizedPlanFragment[] { new SynthesizedPlanFragment(SysProcFragmentId.PF_shutdownCommand, true) }; executeSysProcPlanFragments(pfs, SysProcFragmentId.PF_procedureDone); return new VoltTable[0]; }
[ "public", "VoltTable", "[", "]", "run", "(", "SystemProcedureExecutionContext", "ctx", ")", "{", "createAndExecuteSysProcPlan", "(", "SysProcFragmentId", ".", "PF_shutdownSync", ",", "SysProcFragmentId", ".", "PF_shutdownSyncDone", ")", ";", "SynthesizedPlanFragment", "pf...
Begin an un-graceful shutdown. @param ctx Internal parameter not exposed to the end-user. @return Never returned, no he never returned...
[ "Begin", "an", "un", "-", "graceful", "shutdown", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/Shutdown.java#L126-L134
train
VoltDB/voltdb
src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java
JDBC4ClientConnection.drain
public void drain() throws InterruptedException, IOException { ClientImpl currentClient = this.getClient(); if (currentClient == null) { throw new IOException("Client is unavailable for drain()."); } currentClient.drain(); }
java
public void drain() throws InterruptedException, IOException { ClientImpl currentClient = this.getClient(); if (currentClient == null) { throw new IOException("Client is unavailable for drain()."); } currentClient.drain(); }
[ "public", "void", "drain", "(", ")", "throws", "InterruptedException", ",", "IOException", "{", "ClientImpl", "currentClient", "=", "this", ".", "getClient", "(", ")", ";", "if", "(", "currentClient", "==", "null", ")", "{", "throw", "new", "IOException", "(...
Block the current thread until all queued stored procedure invocations have received responses or there are no more connections to the cluster @throws InterruptedException @throws IOException @see Client#drain()
[ "Block", "the", "current", "thread", "until", "all", "queued", "stored", "procedure", "invocations", "have", "received", "responses", "or", "there", "are", "no", "more", "connections", "to", "the", "cluster" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java#L503-L509
train
VoltDB/voltdb
src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java
JDBC4ClientConnection.backpressureBarrier
public void backpressureBarrier() throws InterruptedException, IOException { ClientImpl currentClient = this.getClient(); if (currentClient == null) { throw new IOException("Client is unavailable for backpressureBarrier()."); } currentClient.backpressureBarrier(); }
java
public void backpressureBarrier() throws InterruptedException, IOException { ClientImpl currentClient = this.getClient(); if (currentClient == null) { throw new IOException("Client is unavailable for backpressureBarrier()."); } currentClient.backpressureBarrier(); }
[ "public", "void", "backpressureBarrier", "(", ")", "throws", "InterruptedException", ",", "IOException", "{", "ClientImpl", "currentClient", "=", "this", ".", "getClient", "(", ")", ";", "if", "(", "currentClient", "==", "null", ")", "{", "throw", "new", "IOEx...
Blocks the current thread until there is no more backpressure or there are no more connections to the database @throws InterruptedException @throws IOException
[ "Blocks", "the", "current", "thread", "until", "there", "is", "no", "more", "backpressure", "or", "there", "are", "no", "more", "connections", "to", "the", "database" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java#L518-L524
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/navigator/RowSetNavigator.java
RowSetNavigator.absolute
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(); } // go to the tagget row; while (position > currentPos) { next(); } return true; }
java
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(); } // go to the tagget row; while (position > currentPos) { next(); } return true; }
[ "public", "boolean", "absolute", "(", "int", "position", ")", "{", "if", "(", "position", "<", "0", ")", "{", "position", "+=", "size", ";", "}", "if", "(", "position", "<", "0", ")", "{", "beforeFirst", "(", ")", ";", "return", "false", ";", "}", ...
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
[ "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", "en...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/navigator/RowSetNavigator.java#L215-L247
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.printErrorAndQuit
private void printErrorAndQuit(String message) { System.out.println(message + "\n-------------------------------------------------------------------------------------\n"); printUsage(); System.exit(-1); }
java
private void printErrorAndQuit(String message) { System.out.println(message + "\n-------------------------------------------------------------------------------------\n"); printUsage(); System.exit(-1); }
[ "private", "void", "printErrorAndQuit", "(", "String", "message", ")", "{", "System", ".", "out", ".", "println", "(", "message", "+", "\"\\n-------------------------------------------------------------------------------------\\n\"", ")", ";", "printUsage", "(", ")", ";",...
Prints out an error message and the application usage print-out, then terminates the application.
[ "Prints", "out", "an", "error", "message", "and", "the", "application", "usage", "print", "-", "out", "then", "terminates", "the", "application", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L219-L224
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.printActualUsage
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) { String template = "%1$" + String.valueOf(maxLength-1) + "s : "; System.out.printf(template, a.Name); System.out.println(a.Value); } System.out.println("-------------------------------------------------------------------------------------"); return this; }
java
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) { String template = "%1$" + String.valueOf(maxLength-1) + "s : "; System.out.printf(template, a.Name); System.out.println(a.Value); } System.out.println("-------------------------------------------------------------------------------------"); return this; }
[ "public", "AppHelper", "printActualUsage", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"-------------------------------------------------------------------------------------\"", ")", ";", "int", "maxLength", "=", "24", ";", "for", "(", "Argument", "a", ...
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. @return reference to this application helper, allowing command-chaining.
[ "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", "comma...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L231-L246
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.byteValue
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' could not be cast to type: 'byte'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
java
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' could not be cast to type: 'byte'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
[ "public", "byte", "byteValue", "(", "String", "name", ")", "{", "try", "{", "return", "Byte", ".", "valueOf", "(", "this", ".", "getArgumentByName", "(", "name", ")", ".", "Value", ")", ";", "}", "catch", "(", "NullPointerException", "npe", ")", "{", "...
Retrieves the value of an argument as a byte. @param name the (case-sensitive) name of the argument to retrieve. @return the value of the argument cast as a byte. Will terminate the application if a required argument is found missing or the casting call fails, printing out detailed usage.
[ "Retrieves", "the", "value", "of", "an", "argument", "as", "a", "byte", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L330-L345
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.shortValue
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' could not be cast to type: 'short'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
java
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' could not be cast to type: 'short'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
[ "public", "short", "shortValue", "(", "String", "name", ")", "{", "try", "{", "return", "Short", ".", "valueOf", "(", "this", ".", "getArgumentByName", "(", "name", ")", ".", "Value", ")", ";", "}", "catch", "(", "NullPointerException", "npe", ")", "{", ...
Retrieves the value of an argument as a short. @param name the (case-sensitive) name of the argument to retrieve. @return the value of the argument cast as a short. Will terminate the application if a required argument is found missing or the casting call fails, printing out detailed usage.
[ "Retrieves", "the", "value", "of", "an", "argument", "as", "a", "short", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L353-L368
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.intValue
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' could not be cast to type: 'int'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
java
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' could not be cast to type: 'int'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
[ "public", "int", "intValue", "(", "String", "name", ")", "{", "try", "{", "return", "Integer", ".", "valueOf", "(", "this", ".", "getArgumentByName", "(", "name", ")", ".", "Value", ")", ";", "}", "catch", "(", "NullPointerException", "npe", ")", "{", ...
Retrieves the value of an argument as a int. @param name the (case-sensitive) name of the argument to retrieve. @return the value of the argument cast as a int. Will terminate the application if a required argument is found missing or the casting call fails, printing out detailed usage.
[ "Retrieves", "the", "value", "of", "an", "argument", "as", "a", "int", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L376-L391
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.longValue
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' could not be cast to type: 'long'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
java
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' could not be cast to type: 'long'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
[ "public", "long", "longValue", "(", "String", "name", ")", "{", "try", "{", "return", "Long", ".", "valueOf", "(", "this", ".", "getArgumentByName", "(", "name", ")", ".", "Value", ")", ";", "}", "catch", "(", "NullPointerException", "npe", ")", "{", "...
Retrieves the value of an argument as a long. @param name the (case-sensitive) name of the argument to retrieve. @return the value of the argument cast as a long. Will terminate the application if a required argument is found missing or the casting call fails, printing out detailed usage.
[ "Retrieves", "the", "value", "of", "an", "argument", "as", "a", "long", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L399-L414
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.doubleValue
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 '%s' could not be cast to type: 'double'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
java
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 '%s' could not be cast to type: 'double'.", name)); } return -1; // We will never get here: printErrorAndQuit will have terminated the application! }
[ "public", "double", "doubleValue", "(", "String", "name", ")", "{", "try", "{", "return", "Double", ".", "valueOf", "(", "this", ".", "getArgumentByName", "(", "name", ")", ".", "Value", ")", ";", "}", "catch", "(", "NullPointerException", "npe", ")", "{...
Retrieves the value of an argument as a double. @param name the (case-sensitive) name of the argument to retrieve. @return the value of the argument cast as a double. Will terminate the application if a required argument is found missing or the casting call fails, printing out detailed usage.
[ "Retrieves", "the", "value", "of", "an", "argument", "as", "a", "double", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L422-L437
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.stringValue
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; // We will never get here: printErrorAndQuit will have terminated the application! }
java
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; // We will never get here: printErrorAndQuit will have terminated the application! }
[ "public", "String", "stringValue", "(", "String", "name", ")", "{", "try", "{", "return", "this", ".", "getArgumentByName", "(", "name", ")", ".", "Value", ";", "}", "catch", "(", "Exception", "npe", ")", "{", "printErrorAndQuit", "(", "String", ".", "fo...
Retrieves the value of an argument as a string. @param name the (case-sensitive) name of the argument to retrieve. @return the value of the argument as a string (as passed on the command line). Will terminate the application if a required argument is found missing, printing out detailed usage.
[ "Retrieves", "the", "value", "of", "an", "argument", "as", "a", "string", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L445-L456
train
VoltDB/voltdb
src/frontend/org/voltdb/client/exampleutils/AppHelper.java
AppHelper.booleanValue
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("Argument '%s' could not be cast to type: 'boolean'.", name)); } return false; // We will never get here: printErrorAndQuit will have terminated the application! }
java
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("Argument '%s' could not be cast to type: 'boolean'.", name)); } return false; // We will never get here: printErrorAndQuit will have terminated the application! }
[ "public", "boolean", "booleanValue", "(", "String", "name", ")", "{", "try", "{", "return", "Boolean", ".", "valueOf", "(", "this", ".", "getArgumentByName", "(", "name", ")", ".", "Value", ")", ";", "}", "catch", "(", "NullPointerException", "npe", ")", ...
Retrieves the value of an argument as a boolean. @param name the (case-sensitive) name of the argument to retrieve. @return the value of the argument cast as a boolean. Will terminate the application if a required argument is found missing or the casting call fails, printing out detailed usage.
[ "Retrieves", "the", "value", "of", "an", "argument", "as", "a", "boolean", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/exampleutils/AppHelper.java#L464-L479
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/util/Tree.java
Tree.setBounds
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.setBounds(iWidth, 0, iSbWidth, iHeight); adjustScroll(); iImage = null; repaint(); }
java
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.setBounds(iWidth, 0, iSbWidth, iHeight); adjustScroll(); iImage = null; repaint(); }
[ "public", "void", "setBounds", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "super", ".", "setBounds", "(", "x", ",", "y", ",", "w", ",", "h", ")", ";", "iSbHeight", "=", "sbHoriz", ".", "getPreferredSize", "(", ...
with additional replacement of deprecated methods
[ "with", "additional", "replacement", "of", "deprecated", "methods" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/Tree.java#L167-L183
train
VoltDB/voltdb
src/frontend/org/voltdb/utils/VoltTrace.java
VoltTrace.write
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"); } if (!file.getParentFile().canWrite() || !file.getParentFile().canExecute()) { throw new IOException("Trace file " + file.getAbsolutePath() + " is not writable"); } SettableFuture<Future<?>> f = SettableFuture.create(); m_work.offer(() -> f.set(dumpEvents(file))); final Future<?> writeFuture = f.get(); if (writeFuture != null) { writeFuture.get(); // Wait for the write to finish without blocking new events return file.getAbsolutePath(); } else { // A write is already in progress, ignore this request return null; } }
java
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"); } if (!file.getParentFile().canWrite() || !file.getParentFile().canExecute()) { throw new IOException("Trace file " + file.getAbsolutePath() + " is not writable"); } SettableFuture<Future<?>> f = SettableFuture.create(); m_work.offer(() -> f.set(dumpEvents(file))); final Future<?> writeFuture = f.get(); if (writeFuture != null) { writeFuture.get(); // Wait for the write to finish without blocking new events return file.getAbsolutePath(); } else { // A write is already in progress, ignore this request return null; } }
[ "private", "String", "write", "(", "String", "logDir", ")", "throws", "IOException", ",", "ExecutionException", ",", "InterruptedException", "{", "final", "File", "file", "=", "new", "File", "(", "logDir", ",", "\"trace_\"", "+", "System", ".", "currentTimeMilli...
Write the events in the queue to file. @param logDir The directory to write the file to. @return The file path if successfully written, or null if the there is already a write in progress.
[ "Write", "the", "events", "in", "the", "queue", "to", "file", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L394-L413
train
VoltDB/voltdb
src/frontend/org/voltdb/utils/VoltTrace.java
VoltTrace.log
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; } }
java
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; } }
[ "public", "static", "TraceEventBatch", "log", "(", "Category", "cat", ")", "{", "final", "VoltTrace", "tracer", "=", "s_tracer", ";", "if", "(", "tracer", "!=", "null", "&&", "tracer", ".", "isCategoryEnabled", "(", "cat", ")", ")", "{", "final", "TraceEve...
Create a trace event batch for the given category. The events that go into this batch should all originate from the same thread. @param cat The category to write the events to. @return The batch object to add events to, or null if trace logging for the category is not enabled.
[ "Create", "a", "trace", "event", "batch", "for", "the", "given", "category", ".", "The", "events", "that", "go", "into", "this", "batch", "should", "all", "originate", "from", "the", "same", "thread", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L443-L452
train
VoltDB/voltdb
src/frontend/org/voltdb/utils/VoltTrace.java
VoltTrace.closeAllAndShutdown
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.shutdownNow(); tracer.m_writerThread.awaitTermination(timeOutMillis, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { } } tracer.shutdown(); } return path; }
java
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.shutdownNow(); tracer.m_writerThread.awaitTermination(timeOutMillis, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { } } tracer.shutdown(); } return path; }
[ "public", "static", "String", "closeAllAndShutdown", "(", "String", "logDir", ",", "long", "timeOutMillis", ")", "throws", "IOException", "{", "String", "path", "=", "null", ";", "final", "VoltTrace", "tracer", "=", "s_tracer", ";", "if", "(", "tracer", "!=", ...
Close all open files and wait for shutdown. @param logDir The directory to write the trace events to, null to skip writing to file. @param timeOutMillis Timeout in milliseconds. Negative to not wait @return The path to the trace file if written, or null if a write is already in progress.
[ "Close", "all", "open", "files", "and", "wait", "for", "shutdown", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L515-L538
train
VoltDB/voltdb
src/frontend/org/voltdb/utils/VoltTrace.java
VoltTrace.start
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; } }
java
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; } }
[ "private", "static", "synchronized", "void", "start", "(", ")", "throws", "IOException", "{", "if", "(", "s_tracer", "==", "null", ")", "{", "final", "VoltTrace", "tracer", "=", "new", "VoltTrace", "(", ")", ";", "final", "Thread", "thread", "=", "new", ...
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.
[ "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", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L545-L553
train
VoltDB/voltdb
src/frontend/org/voltdb/utils/VoltTrace.java
VoltTrace.dump
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 parent directory " + dir.getParentFile().getAbsolutePath() + " is not writable"); } if (!dir.exists()) { if (!dir.mkdir()) { throw new IOException("Failed to create trace log directory " + dir.getAbsolutePath()); } } try { path = tracer.write(logDir); } catch (Exception e) { s_logger.info("Unable to write trace file: " + e.getMessage(), e); } } return path; }
java
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 parent directory " + dir.getParentFile().getAbsolutePath() + " is not writable"); } if (!dir.exists()) { if (!dir.mkdir()) { throw new IOException("Failed to create trace log directory " + dir.getAbsolutePath()); } } try { path = tracer.write(logDir); } catch (Exception e) { s_logger.info("Unable to write trace file: " + e.getMessage(), e); } } return path; }
[ "public", "static", "String", "dump", "(", "String", "logDir", ")", "throws", "IOException", "{", "String", "path", "=", "null", ";", "final", "VoltTrace", "tracer", "=", "s_tracer", ";", "if", "(", "tracer", "!=", "null", ")", "{", "final", "File", "dir...
Write all trace events in the queue to file. @return The file path if written successfully, or null if a write is already in progress.
[ "Write", "all", "trace", "events", "in", "the", "queue", "to", "file", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L559-L583
train