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/PostgreSQLBackend.java
PostgreSQLBackend.indexOfNthOccurrenceOfCharIn
static private int indexOfNthOccurrenceOfCharIn(String str, char ch, int n) { boolean inMiddleOfQuote = false; int index = -1, previousIndex = 0; for (int i=0; i < n; i++) { do { index = str.indexOf(ch, index+1); if (index < 0) { return -1; } if (hasOddNumberOfSingleQuotes(str.substring(previousIndex, index))) { inMiddleOfQuote = !inMiddleOfQuote; } previousIndex = index; } while (inMiddleOfQuote); } return index; }
java
static private int indexOfNthOccurrenceOfCharIn(String str, char ch, int n) { boolean inMiddleOfQuote = false; int index = -1, previousIndex = 0; for (int i=0; i < n; i++) { do { index = str.indexOf(ch, index+1); if (index < 0) { return -1; } if (hasOddNumberOfSingleQuotes(str.substring(previousIndex, index))) { inMiddleOfQuote = !inMiddleOfQuote; } previousIndex = index; } while (inMiddleOfQuote); } return index; }
[ "static", "private", "int", "indexOfNthOccurrenceOfCharIn", "(", "String", "str", ",", "char", "ch", ",", "int", "n", ")", "{", "boolean", "inMiddleOfQuote", "=", "false", ";", "int", "index", "=", "-", "1", ",", "previousIndex", "=", "0", ";", "for", "(...
Returns the Nth occurrence of the specified character in the specified String, but ignoring those contained in single quotes.
[ "Returns", "the", "Nth", "occurrence", "of", "the", "specified", "character", "in", "the", "specified", "String", "but", "ignoring", "those", "contained", "in", "single", "quotes", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/PostgreSQLBackend.java#L666-L682
train
VoltDB/voltdb
src/frontend/org/voltdb/PostgreSQLBackend.java
PostgreSQLBackend.runDML
protected VoltTable runDML(String dml, boolean transformDml) { String modifiedDml = (transformDml ? transformDML(dml) : dml); printTransformedSql(dml, modifiedDml); return super.runDML(modifiedDml); }
java
protected VoltTable runDML(String dml, boolean transformDml) { String modifiedDml = (transformDml ? transformDML(dml) : dml); printTransformedSql(dml, modifiedDml); return super.runDML(modifiedDml); }
[ "protected", "VoltTable", "runDML", "(", "String", "dml", ",", "boolean", "transformDml", ")", "{", "String", "modifiedDml", "=", "(", "transformDml", "?", "transformDML", "(", "dml", ")", ":", "dml", ")", ";", "printTransformedSql", "(", "dml", ",", "modifi...
Optionally, modifies queries in such a way that PostgreSQL results will match VoltDB results; and then passes the remaining work to the base class version.
[ "Optionally", "modifies", "queries", "in", "such", "a", "way", "that", "PostgreSQL", "results", "will", "match", "VoltDB", "results", ";", "and", "then", "passes", "the", "remaining", "work", "to", "the", "base", "class", "version", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/PostgreSQLBackend.java#L1066-L1070
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.getClassCode
static int getClassCode(Class cla) { if (!cla.isPrimitive()) { return ArrayUtil.CLASS_CODE_OBJECT; } return classCodeMap.get(cla, -1); }
java
static int getClassCode(Class cla) { if (!cla.isPrimitive()) { return ArrayUtil.CLASS_CODE_OBJECT; } return classCodeMap.get(cla, -1); }
[ "static", "int", "getClassCode", "(", "Class", "cla", ")", "{", "if", "(", "!", "cla", ".", "isPrimitive", "(", ")", ")", "{", "return", "ArrayUtil", ".", "CLASS_CODE_OBJECT", ";", "}", "return", "classCodeMap", ".", "get", "(", "cla", ",", "-", "1", ...
Returns a distinct int code for each primitive type and for all Object types.
[ "Returns", "a", "distinct", "int", "code", "for", "each", "primitive", "type", "and", "for", "all", "Object", "types", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L71-L78
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.clearArray
public static void clearArray(int type, Object data, int from, int to) { switch (type) { case ArrayUtil.CLASS_CODE_BYTE : { byte[] array = (byte[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_CHAR : { byte[] array = (byte[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_SHORT : { short[] array = (short[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_INT : { int[] array = (int[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_LONG : { long[] array = (long[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_FLOAT : { float[] array = (float[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_DOUBLE : { double[] array = (double[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_BOOLEAN : { boolean[] array = (boolean[]) data; while (--to >= from) { array[to] = false; } return; } default : { Object[] array = (Object[]) data; while (--to >= from) { array[to] = null; } return; } } }
java
public static void clearArray(int type, Object data, int from, int to) { switch (type) { case ArrayUtil.CLASS_CODE_BYTE : { byte[] array = (byte[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_CHAR : { byte[] array = (byte[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_SHORT : { short[] array = (short[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_INT : { int[] array = (int[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_LONG : { long[] array = (long[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_FLOAT : { float[] array = (float[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_DOUBLE : { double[] array = (double[]) data; while (--to >= from) { array[to] = 0; } return; } case ArrayUtil.CLASS_CODE_BOOLEAN : { boolean[] array = (boolean[]) data; while (--to >= from) { array[to] = false; } return; } default : { Object[] array = (Object[]) data; while (--to >= from) { array[to] = null; } return; } } }
[ "public", "static", "void", "clearArray", "(", "int", "type", ",", "Object", "data", ",", "int", "from", ",", "int", "to", ")", "{", "switch", "(", "type", ")", "{", "case", "ArrayUtil", ".", "CLASS_CODE_BYTE", ":", "{", "byte", "[", "]", "array", "=...
Clears an area of the given array of the given type.
[ "Clears", "an", "area", "of", "the", "given", "array", "of", "the", "given", "type", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L83-L169
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.adjustArray
public static void adjustArray(int type, Object array, int usedElements, int index, int count) { if (index >= usedElements) { return; } int newCount = usedElements + count; int source; int target; int size; if (count >= 0) { source = index; target = index + count; size = usedElements - index; } else { source = index - count; target = index; size = usedElements - index + count; } if (size > 0) { System.arraycopy(array, source, array, target, size); } if (count < 0) { clearArray(type, array, newCount, usedElements); } }
java
public static void adjustArray(int type, Object array, int usedElements, int index, int count) { if (index >= usedElements) { return; } int newCount = usedElements + count; int source; int target; int size; if (count >= 0) { source = index; target = index + count; size = usedElements - index; } else { source = index - count; target = index; size = usedElements - index + count; } if (size > 0) { System.arraycopy(array, source, array, target, size); } if (count < 0) { clearArray(type, array, newCount, usedElements); } }
[ "public", "static", "void", "adjustArray", "(", "int", "type", ",", "Object", "array", ",", "int", "usedElements", ",", "int", "index", ",", "int", "count", ")", "{", "if", "(", "index", ">=", "usedElements", ")", "{", "return", ";", "}", "int", "newCo...
Moves the contents of an array to allow both addition and removal of elements. Used arguments must be in range. @param type class type of the array @param array the array @param usedElements count of elements of array in use @param index point at which to add or remove elements @param count number of elements to add or remove
[ "Moves", "the", "contents", "of", "an", "array", "to", "allow", "both", "addition", "and", "removal", "of", "elements", ".", "Used", "arguments", "must", "be", "in", "range", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L181-L210
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.sortArray
public static void sortArray(int[] array) { boolean swapped; do { swapped = false; for (int i = 0; i < array.length - 1; i++) { if (array[i] > array[i + 1]) { int temp = array[i + 1]; array[i + 1] = array[i]; array[i] = temp; swapped = true; } } } while (swapped); }
java
public static void sortArray(int[] array) { boolean swapped; do { swapped = false; for (int i = 0; i < array.length - 1; i++) { if (array[i] > array[i + 1]) { int temp = array[i + 1]; array[i + 1] = array[i]; array[i] = temp; swapped = true; } } } while (swapped); }
[ "public", "static", "void", "sortArray", "(", "int", "[", "]", "array", ")", "{", "boolean", "swapped", ";", "do", "{", "swapped", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", "-", "1", ";", "i", "...
Basic sort for small arrays of int.
[ "Basic", "sort", "for", "small", "arrays", "of", "int", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L215-L232
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.find
public static int find(Object[] array, Object object) { for (int i = 0; i < array.length; i++) { if (array[i] == object) { // hadles both nulls return i; } if (object != null && object.equals(array[i])) { return i; } } return -1; }
java
public static int find(Object[] array, Object object) { for (int i = 0; i < array.length; i++) { if (array[i] == object) { // hadles both nulls return i; } if (object != null && object.equals(array[i])) { return i; } } return -1; }
[ "public", "static", "int", "find", "(", "Object", "[", "]", "array", ",", "Object", "object", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "if", "(", "array", "[", "i", "]", "=="...
Basic find for small arrays of Object.
[ "Basic", "find", "for", "small", "arrays", "of", "Object", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L237-L252
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.findNot
public static int findNot(int[] array, int value) { for (int i = 0; i < array.length; i++) { if (array[i] != value) { return i; } } return -1; }
java
public static int findNot(int[] array, int value) { for (int i = 0; i < array.length; i++) { if (array[i] != value) { return i; } } return -1; }
[ "public", "static", "int", "findNot", "(", "int", "[", "]", "array", ",", "int", "value", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "if", "(", "array", "[", "i", "]", "!=", ...
Finds the first element of the array that is not equal to the given value.
[ "Finds", "the", "first", "element", "of", "the", "array", "that", "is", "not", "equal", "to", "the", "given", "value", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L293-L302
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.areEqualSets
public static boolean areEqualSets(int[] arra, int[] arrb) { return arra.length == arrb.length && ArrayUtil.haveEqualSets(arra, arrb, arra.length); }
java
public static boolean areEqualSets(int[] arra, int[] arrb) { return arra.length == arrb.length && ArrayUtil.haveEqualSets(arra, arrb, arra.length); }
[ "public", "static", "boolean", "areEqualSets", "(", "int", "[", "]", "arra", ",", "int", "[", "]", "arrb", ")", "{", "return", "arra", ".", "length", "==", "arrb", ".", "length", "&&", "ArrayUtil", ".", "haveEqualSets", "(", "arra", ",", "arrb", ",", ...
Returns true if arra and arrb contain the same set of integers, not necessarily in the same order. This implies the arrays are of the same length.
[ "Returns", "true", "if", "arra", "and", "arrb", "contain", "the", "same", "set", "of", "integers", "not", "necessarily", "in", "the", "same", "order", ".", "This", "implies", "the", "arrays", "are", "of", "the", "same", "length", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L309-L312
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.haveEqualArrays
public static boolean haveEqualArrays(int[] arra, int[] arrb, int count) { if (count > arra.length || count > arrb.length) { return false; } for (int j = 0; j < count; j++) { if (arra[j] != arrb[j]) { return false; } } return true; }
java
public static boolean haveEqualArrays(int[] arra, int[] arrb, int count) { if (count > arra.length || count > arrb.length) { return false; } for (int j = 0; j < count; j++) { if (arra[j] != arrb[j]) { return false; } } return true; }
[ "public", "static", "boolean", "haveEqualArrays", "(", "int", "[", "]", "arra", ",", "int", "[", "]", "arrb", ",", "int", "count", ")", "{", "if", "(", "count", ">", "arra", ".", "length", "||", "count", ">", "arrb", ".", "length", ")", "{", "retur...
Returns true if the first count elements of arra and arrb are identical subarrays of integers
[ "Returns", "true", "if", "the", "first", "count", "elements", "of", "arra", "and", "arrb", "are", "identical", "subarrays", "of", "integers" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L377-L390
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.haveEqualArrays
public static boolean haveEqualArrays(Object[] arra, Object[] arrb, int count) { if (count > arra.length || count > arrb.length) { return false; } for (int j = 0; j < count; j++) { if (arra[j] != arrb[j]) { if (arra[j] == null || !arra[j].equals(arrb[j])) { return false; } } } return true; }
java
public static boolean haveEqualArrays(Object[] arra, Object[] arrb, int count) { if (count > arra.length || count > arrb.length) { return false; } for (int j = 0; j < count; j++) { if (arra[j] != arrb[j]) { if (arra[j] == null || !arra[j].equals(arrb[j])) { return false; } } } return true; }
[ "public", "static", "boolean", "haveEqualArrays", "(", "Object", "[", "]", "arra", ",", "Object", "[", "]", "arrb", ",", "int", "count", ")", "{", "if", "(", "count", ">", "arra", ".", "length", "||", "count", ">", "arrb", ".", "length", ")", "{", ...
Returns true if the first count elements of arra and arrb are identical subarrays of Objects
[ "Returns", "true", "if", "the", "first", "count", "elements", "of", "arra", "and", "arrb", "are", "identical", "subarrays", "of", "Objects" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L397-L413
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.countSameElements
public static int countSameElements(byte[] arra, int start, byte[] arrb) { int k = 0; int limit = arra.length - start; if (limit > arrb.length) { limit = arrb.length; } for (int i = 0; i < limit; i++) { if (arra[i + start] == arrb[i]) { k++; } else { break; } } return k; }
java
public static int countSameElements(byte[] arra, int start, byte[] arrb) { int k = 0; int limit = arra.length - start; if (limit > arrb.length) { limit = arrb.length; } for (int i = 0; i < limit; i++) { if (arra[i + start] == arrb[i]) { k++; } else { break; } } return k; }
[ "public", "static", "int", "countSameElements", "(", "byte", "[", "]", "arra", ",", "int", "start", ",", "byte", "[", "]", "arrb", ")", "{", "int", "k", "=", "0", ";", "int", "limit", "=", "arra", ".", "length", "-", "start", ";", "if", "(", "lim...
Returns the count of elements in arra from position start that are sequentially equal to the elements of arrb.
[ "Returns", "the", "count", "of", "elements", "in", "arra", "from", "position", "start", "that", "are", "sequentially", "equal", "to", "the", "elements", "of", "arrb", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L518-L536
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.find
public static int find(byte[] arra, int start, int limit, byte[] arrb) { int k = start; limit = limit - arrb.length + 1; int value = arrb[0]; for (; k < limit; k++) { if (arra[k] == value) { if (arrb.length == 1) { return k; } if (containsAt(arra, k, arrb)) { return k; } } } return -1; }
java
public static int find(byte[] arra, int start, int limit, byte[] arrb) { int k = start; limit = limit - arrb.length + 1; int value = arrb[0]; for (; k < limit; k++) { if (arra[k] == value) { if (arrb.length == 1) { return k; } if (containsAt(arra, k, arrb)) { return k; } } } return -1; }
[ "public", "static", "int", "find", "(", "byte", "[", "]", "arra", ",", "int", "start", ",", "int", "limit", ",", "byte", "[", "]", "arrb", ")", "{", "int", "k", "=", "start", ";", "limit", "=", "limit", "-", "arrb", ".", "length", "+", "1", ";"...
Returns the index of the first occurence of arrb in arra. Or -1 if not found.
[ "Returns", "the", "index", "of", "the", "first", "occurence", "of", "arrb", "in", "arra", ".", "Or", "-", "1", "if", "not", "found", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L565-L586
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.find
public static int find(byte[] arra, int start, int limit, int b, int c) { int k = 0; for (; k < limit; k++) { if (arra[k] == b || arra[k] == c) { return k; } } return -1; }
java
public static int find(byte[] arra, int start, int limit, int b, int c) { int k = 0; for (; k < limit; k++) { if (arra[k] == b || arra[k] == c) { return k; } } return -1; }
[ "public", "static", "int", "find", "(", "byte", "[", "]", "arra", ",", "int", "start", ",", "int", "limit", ",", "int", "b", ",", "int", "c", ")", "{", "int", "k", "=", "0", ";", "for", "(", ";", "k", "<", "limit", ";", "k", "++", ")", "{",...
Returns the index of b or c in arra. Or -1 if not found.
[ "Returns", "the", "index", "of", "b", "or", "c", "in", "arra", ".", "Or", "-", "1", "if", "not", "found", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L633-L644
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.intIndexesToBooleanArray
public static void intIndexesToBooleanArray(int[] arra, boolean[] arrb) { for (int i = 0; i < arra.length; i++) { if (arra[i] < arrb.length) { arrb[arra[i]] = true; } } }
java
public static void intIndexesToBooleanArray(int[] arra, boolean[] arrb) { for (int i = 0; i < arra.length; i++) { if (arra[i] < arrb.length) { arrb[arra[i]] = true; } } }
[ "public", "static", "void", "intIndexesToBooleanArray", "(", "int", "[", "]", "arra", ",", "boolean", "[", "]", "arrb", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arra", ".", "length", ";", "i", "++", ")", "{", "if", "(", "arra",...
Set elements of arrb true if their indexes appear in arrb.
[ "Set", "elements", "of", "arrb", "true", "if", "their", "indexes", "appear", "in", "arrb", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L649-L656
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.containsAllTrueElements
public static boolean containsAllTrueElements(boolean[] arra, boolean[] arrb) { for (int i = 0; i < arra.length; i++) { if (arrb[i] && !arra[i]) { return false; } } return true; }
java
public static boolean containsAllTrueElements(boolean[] arra, boolean[] arrb) { for (int i = 0; i < arra.length; i++) { if (arrb[i] && !arra[i]) { return false; } } return true; }
[ "public", "static", "boolean", "containsAllTrueElements", "(", "boolean", "[", "]", "arra", ",", "boolean", "[", "]", "arrb", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arra", ".", "length", ";", "i", "++", ")", "{", "if", "(", "...
Return true if for each true element in arrb, the corresponding element in arra is true
[ "Return", "true", "if", "for", "each", "true", "element", "in", "arrb", "the", "corresponding", "element", "in", "arra", "is", "true" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L683-L693
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.countTrueElements
public static int countTrueElements(boolean[] arra) { int count = 0; for (int i = 0; i < arra.length; i++) { if (arra[i]) { count++; } } return count; }
java
public static int countTrueElements(boolean[] arra) { int count = 0; for (int i = 0; i < arra.length; i++) { if (arra[i]) { count++; } } return count; }
[ "public", "static", "int", "countTrueElements", "(", "boolean", "[", "]", "arra", ")", "{", "int", "count", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arra", ".", "length", ";", "i", "++", ")", "{", "if", "(", "arra", "[",...
Return count of true elements in array
[ "Return", "count", "of", "true", "elements", "in", "array" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L698-L709
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.hasNull
public static boolean hasNull(Object[] array, int[] columnMap) { int count = columnMap.length; for (int i = 0; i < count; i++) { if (array[columnMap[i]] == null) { return true; } } return false; }
java
public static boolean hasNull(Object[] array, int[] columnMap) { int count = columnMap.length; for (int i = 0; i < count; i++) { if (array[columnMap[i]] == null) { return true; } } return false; }
[ "public", "static", "boolean", "hasNull", "(", "Object", "[", "]", "array", ",", "int", "[", "]", "columnMap", ")", "{", "int", "count", "=", "columnMap", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++...
Determines if the array has a null column for any of the positions given in the rowColMap array.
[ "Determines", "if", "the", "array", "has", "a", "null", "column", "for", "any", "of", "the", "positions", "given", "in", "the", "rowColMap", "array", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L715-L726
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.containsAt
public static boolean containsAt(byte[] arra, int start, byte[] arrb) { return countSameElements(arra, start, arrb) == arrb.length; }
java
public static boolean containsAt(byte[] arra, int start, byte[] arrb) { return countSameElements(arra, start, arrb) == arrb.length; }
[ "public", "static", "boolean", "containsAt", "(", "byte", "[", "]", "arra", ",", "int", "start", ",", "byte", "[", "]", "arrb", ")", "{", "return", "countSameElements", "(", "arra", ",", "start", ",", "arrb", ")", "==", "arrb", ".", "length", ";", "}...
Returns true if arra from position start contains all elements of arrb in sequential order.
[ "Returns", "true", "if", "arra", "from", "position", "start", "contains", "all", "elements", "of", "arrb", "in", "sequential", "order", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L746-L748
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.countStartElementsAt
public static int countStartElementsAt(byte[] arra, int start, byte[] arrb) { int k = 0; mainloop: for (int i = start; i < arra.length; i++) { for (int j = 0; j < arrb.length; j++) { if (arra[i] == arrb[j]) { k++; continue mainloop; } } break; } return k; }
java
public static int countStartElementsAt(byte[] arra, int start, byte[] arrb) { int k = 0; mainloop: for (int i = start; i < arra.length; i++) { for (int j = 0; j < arrb.length; j++) { if (arra[i] == arrb[j]) { k++; continue mainloop; } } break; } return k; }
[ "public", "static", "int", "countStartElementsAt", "(", "byte", "[", "]", "arra", ",", "int", "start", ",", "byte", "[", "]", "arrb", ")", "{", "int", "k", "=", "0", ";", "mainloop", ":", "for", "(", "int", "i", "=", "start", ";", "i", "<", "arra...
Returns the count of elements in arra from position start that are among the elements of arrb. Stops at any element not in arrb.
[ "Returns", "the", "count", "of", "elements", "in", "arra", "from", "position", "start", "that", "are", "among", "the", "elements", "of", "arrb", ".", "Stops", "at", "any", "element", "not", "in", "arrb", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L754-L773
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.arraySlice
public static int[] arraySlice(int[] source, int start, int count) { int[] slice = new int[count]; System.arraycopy(source, start, slice, 0, count); return slice; }
java
public static int[] arraySlice(int[] source, int start, int count) { int[] slice = new int[count]; System.arraycopy(source, start, slice, 0, count); return slice; }
[ "public", "static", "int", "[", "]", "arraySlice", "(", "int", "[", "]", "source", ",", "int", "start", ",", "int", "count", ")", "{", "int", "[", "]", "slice", "=", "new", "int", "[", "count", "]", ";", "System", ".", "arraycopy", "(", "source", ...
Returns a range of elements of source from start to end of the array.
[ "Returns", "a", "range", "of", "elements", "of", "source", "from", "start", "to", "end", "of", "the", "array", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L817-L824
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.fillArray
public static void fillArray(Object[] array, Object value) { int to = array.length; while (--to >= 0) { array[to] = value; } }
java
public static void fillArray(Object[] array, Object value) { int to = array.length; while (--to >= 0) { array[to] = value; } }
[ "public", "static", "void", "fillArray", "(", "Object", "[", "]", "array", ",", "Object", "value", ")", "{", "int", "to", "=", "array", ".", "length", ";", "while", "(", "--", "to", ">=", "0", ")", "{", "array", "[", "to", "]", "=", "value", ";",...
Fills the array with a value.
[ "Fills", "the", "array", "with", "a", "value", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L829-L836
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.duplicateArray
public static Object duplicateArray(Object source) { int size = Array.getLength(source); Object newarray = Array.newInstance(source.getClass().getComponentType(), size); System.arraycopy(source, 0, newarray, 0, size); return newarray; }
java
public static Object duplicateArray(Object source) { int size = Array.getLength(source); Object newarray = Array.newInstance(source.getClass().getComponentType(), size); System.arraycopy(source, 0, newarray, 0, size); return newarray; }
[ "public", "static", "Object", "duplicateArray", "(", "Object", "source", ")", "{", "int", "size", "=", "Array", ".", "getLength", "(", "source", ")", ";", "Object", "newarray", "=", "Array", ".", "newInstance", "(", "source", ".", "getClass", "(", ")", "...
Returns a duplicates of an array.
[ "Returns", "a", "duplicates", "of", "an", "array", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L853-L862
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.resizeArrayIfDifferent
public static Object resizeArrayIfDifferent(Object source, int newsize) { int oldsize = Array.getLength(source); if (oldsize == newsize) { return source; } Object newarray = Array.newInstance(source.getClass().getComponentType(), newsize); if (oldsize < newsize) { newsize = oldsize; } System.arraycopy(source, 0, newarray, 0, newsize); return newarray; }
java
public static Object resizeArrayIfDifferent(Object source, int newsize) { int oldsize = Array.getLength(source); if (oldsize == newsize) { return source; } Object newarray = Array.newInstance(source.getClass().getComponentType(), newsize); if (oldsize < newsize) { newsize = oldsize; } System.arraycopy(source, 0, newarray, 0, newsize); return newarray; }
[ "public", "static", "Object", "resizeArrayIfDifferent", "(", "Object", "source", ",", "int", "newsize", ")", "{", "int", "oldsize", "=", "Array", ".", "getLength", "(", "source", ")", ";", "if", "(", "oldsize", "==", "newsize", ")", "{", "return", "source"...
Returns the given array if newsize is the same as existing. Returns a new array of given size, containing as many elements of the original array as it can hold.
[ "Returns", "the", "given", "array", "if", "newsize", "is", "the", "same", "as", "existing", ".", "Returns", "a", "new", "array", "of", "given", "size", "containing", "as", "many", "elements", "of", "the", "original", "array", "as", "it", "can", "hold", "...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L869-L887
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java
ArrayUtil.copyAdjustArray
public static void copyAdjustArray(Object source, Object dest, Object addition, int colindex, int adjust) { int length = Array.getLength(source); if (colindex < 0) { System.arraycopy(source, 0, dest, 0, length); return; } System.arraycopy(source, 0, dest, 0, colindex); if (adjust == 0) { int endcount = length - colindex - 1; Array.set(dest, colindex, addition); if (endcount > 0) { System.arraycopy(source, colindex + 1, dest, colindex + 1, endcount); } } else if (adjust < 0) { int endcount = length - colindex - 1; if (endcount > 0) { System.arraycopy(source, colindex + 1, dest, colindex, endcount); } } else { int endcount = length - colindex; Array.set(dest, colindex, addition); if (endcount > 0) { System.arraycopy(source, colindex, dest, colindex + 1, endcount); } } }
java
public static void copyAdjustArray(Object source, Object dest, Object addition, int colindex, int adjust) { int length = Array.getLength(source); if (colindex < 0) { System.arraycopy(source, 0, dest, 0, length); return; } System.arraycopy(source, 0, dest, 0, colindex); if (adjust == 0) { int endcount = length - colindex - 1; Array.set(dest, colindex, addition); if (endcount > 0) { System.arraycopy(source, colindex + 1, dest, colindex + 1, endcount); } } else if (adjust < 0) { int endcount = length - colindex - 1; if (endcount > 0) { System.arraycopy(source, colindex + 1, dest, colindex, endcount); } } else { int endcount = length - colindex; Array.set(dest, colindex, addition); if (endcount > 0) { System.arraycopy(source, colindex, dest, colindex + 1, endcount); } } }
[ "public", "static", "void", "copyAdjustArray", "(", "Object", "source", ",", "Object", "dest", ",", "Object", "addition", ",", "int", "colindex", ",", "int", "adjust", ")", "{", "int", "length", "=", "Array", ".", "getLength", "(", "source", ")", ";", "i...
Copies elements of source to dest. If adjust is -1 the element at colindex is not copied. If adjust is +1 that element is filled with the Object addition. All the rest of the elements in source are shifted left or right accordingly when they are copied. If adjust is 0 the addition is copied over the element at colindex. No checks are perfomed on array sizes and an exception is thrown if they are not consistent with the other arguments.
[ "Copies", "elements", "of", "source", "to", "dest", ".", "If", "adjust", "is", "-", "1", "the", "element", "at", "colindex", "is", "not", "copied", ".", "If", "adjust", "is", "+", "1", "that", "element", "is", "filled", "with", "the", "Object", "additi...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L938-L978
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.prependColumn
private static ColumnInfo[] prependColumn(ColumnInfo firstColumn, ColumnInfo[] columns) { int allLen = 1 + columns.length; ColumnInfo[] allColumns = new ColumnInfo[allLen]; allColumns[0] = firstColumn; for (int i = 0; i < columns.length; i++) { allColumns[i+1] = columns[i]; } return allColumns; }
java
private static ColumnInfo[] prependColumn(ColumnInfo firstColumn, ColumnInfo[] columns) { int allLen = 1 + columns.length; ColumnInfo[] allColumns = new ColumnInfo[allLen]; allColumns[0] = firstColumn; for (int i = 0; i < columns.length; i++) { allColumns[i+1] = columns[i]; } return allColumns; }
[ "private", "static", "ColumnInfo", "[", "]", "prependColumn", "(", "ColumnInfo", "firstColumn", ",", "ColumnInfo", "[", "]", "columns", ")", "{", "int", "allLen", "=", "1", "+", "columns", ".", "length", ";", "ColumnInfo", "[", "]", "allColumns", "=", "new...
Given a column and an array of columns, return a new array of columns with the single guy prepended onto the others. This function is used in the constructor below so that one constructor can call another without breaking Java rules about chained constructors being the first thing called.
[ "Given", "a", "column", "and", "an", "array", "of", "columns", "return", "a", "new", "array", "of", "columns", "with", "the", "single", "guy", "prepended", "onto", "the", "others", ".", "This", "function", "is", "used", "in", "the", "constructor", "below",...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L422-L430
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.getColumnName
public final String getColumnName(int index) { assert(verifyTableInvariants()); if ((index < 0) || (index >= m_colCount)) { throw new IllegalArgumentException("Not a valid column index."); } // move to the start of the list of column names int pos = POS_COL_TYPES + m_colCount; String name = null; for (int i = 0; i < index; i++) { pos += m_buffer.getInt(pos) + 4; } name = readString(pos, METADATA_ENCODING); assert(name != null); assert(verifyTableInvariants()); return name; }
java
public final String getColumnName(int index) { assert(verifyTableInvariants()); if ((index < 0) || (index >= m_colCount)) { throw new IllegalArgumentException("Not a valid column index."); } // move to the start of the list of column names int pos = POS_COL_TYPES + m_colCount; String name = null; for (int i = 0; i < index; i++) { pos += m_buffer.getInt(pos) + 4; } name = readString(pos, METADATA_ENCODING); assert(name != null); assert(verifyTableInvariants()); return name; }
[ "public", "final", "String", "getColumnName", "(", "int", "index", ")", "{", "assert", "(", "verifyTableInvariants", "(", ")", ")", ";", "if", "(", "(", "index", "<", "0", ")", "||", "(", "index", ">=", "m_colCount", ")", ")", "{", "throw", "new", "I...
Return the name of the column with the specified index. @param index Index of the column @return Name of the column with the specified index.
[ "Return", "the", "name", "of", "the", "column", "with", "the", "specified", "index", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L639-L656
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.addRow
public final void addRow(Object... values) { assert(verifyTableInvariants()); if (m_readOnly) { throw new IllegalStateException("Table is read-only. Make a copy before changing."); } if (m_colCount == 0) { throw new IllegalStateException("Table has no columns defined"); } if (values.length != m_colCount) { throw new IllegalArgumentException(values.length + " arguments but table has " + m_colCount + " columns"); } // memoize the start of this row in case we roll back final int pos = m_buffer.position(); try { // Allow the buffer to grow to max capacity m_buffer.limit(m_buffer.capacity()); // advance the row size value m_buffer.position(pos + 4); // where does the type bytes start // skip rowstart + status code + colcount int typePos = POS_COL_TYPES; for (int col = 0; col < m_colCount; col++) { Object value = values[col]; VoltType columnType = VoltType.get(m_buffer.get(typePos + col)); addColumnValue(value, columnType, col); } // // Note, there is some near-identical code in both row add methods. // [ add(..) and addRow(..) ] // If you change code below here, change it in the other method too. // (It would be nice to re-factor, but I couldn't make a clean go at // it quickly - Hugg) // final int rowsize = m_buffer.position() - pos - 4; assert(rowsize >= 0); // check for too big rows if (rowsize > VoltTableRow.MAX_TUPLE_LENGTH) { throw new VoltOverflowException( "Table row total length larger than allowed max " + VoltTableRow.MAX_TUPLE_LENGTH_STR); } // buffer overflow is caught and handled below. m_buffer.putInt(pos, rowsize); m_rowCount++; m_buffer.putInt(m_rowStart, m_rowCount); } catch (VoltTypeException vte) { // revert the row size advance and any other // buffer additions m_buffer.position(pos); throw vte; } catch (BufferOverflowException e) { m_buffer.position(pos); expandBuffer(); addRow(values); } // row was too big, reset and rethrow catch (VoltOverflowException e) { m_buffer.position(pos); throw e; } catch (IllegalArgumentException e) { m_buffer.position(pos); // if this was thrown because of a lack of space // then grow the buffer // the number 32 was picked out of a hat ( maybe a bug if str > 32 ) if (m_buffer.limit() - m_buffer.position() < 32) { expandBuffer(); addRow(values); } else { throw e; } } finally { // constrain buffer limit back to the new position m_buffer.limit(m_buffer.position()); } assert(verifyTableInvariants()); }
java
public final void addRow(Object... values) { assert(verifyTableInvariants()); if (m_readOnly) { throw new IllegalStateException("Table is read-only. Make a copy before changing."); } if (m_colCount == 0) { throw new IllegalStateException("Table has no columns defined"); } if (values.length != m_colCount) { throw new IllegalArgumentException(values.length + " arguments but table has " + m_colCount + " columns"); } // memoize the start of this row in case we roll back final int pos = m_buffer.position(); try { // Allow the buffer to grow to max capacity m_buffer.limit(m_buffer.capacity()); // advance the row size value m_buffer.position(pos + 4); // where does the type bytes start // skip rowstart + status code + colcount int typePos = POS_COL_TYPES; for (int col = 0; col < m_colCount; col++) { Object value = values[col]; VoltType columnType = VoltType.get(m_buffer.get(typePos + col)); addColumnValue(value, columnType, col); } // // Note, there is some near-identical code in both row add methods. // [ add(..) and addRow(..) ] // If you change code below here, change it in the other method too. // (It would be nice to re-factor, but I couldn't make a clean go at // it quickly - Hugg) // final int rowsize = m_buffer.position() - pos - 4; assert(rowsize >= 0); // check for too big rows if (rowsize > VoltTableRow.MAX_TUPLE_LENGTH) { throw new VoltOverflowException( "Table row total length larger than allowed max " + VoltTableRow.MAX_TUPLE_LENGTH_STR); } // buffer overflow is caught and handled below. m_buffer.putInt(pos, rowsize); m_rowCount++; m_buffer.putInt(m_rowStart, m_rowCount); } catch (VoltTypeException vte) { // revert the row size advance and any other // buffer additions m_buffer.position(pos); throw vte; } catch (BufferOverflowException e) { m_buffer.position(pos); expandBuffer(); addRow(values); } // row was too big, reset and rethrow catch (VoltOverflowException e) { m_buffer.position(pos); throw e; } catch (IllegalArgumentException e) { m_buffer.position(pos); // if this was thrown because of a lack of space // then grow the buffer // the number 32 was picked out of a hat ( maybe a bug if str > 32 ) if (m_buffer.limit() - m_buffer.position() < 32) { expandBuffer(); addRow(values); } else { throw e; } } finally { // constrain buffer limit back to the new position m_buffer.limit(m_buffer.position()); } assert(verifyTableInvariants()); }
[ "public", "final", "void", "addRow", "(", "Object", "...", "values", ")", "{", "assert", "(", "verifyTableInvariants", "(", ")", ")", ";", "if", "(", "m_readOnly", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Table is read-only. Make a copy before ch...
Append a new row to the table using the supplied column values. @param values Values of each column in the row. @throws VoltTypeException when there are casting/type failures between an input value and the corresponding column
[ "Append", "a", "new", "row", "to", "the", "table", "using", "the", "supplied", "column", "values", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L1130-L1219
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.varbinaryToPrintableString
public static String varbinaryToPrintableString(byte[] bin) { PureJavaCrc32 crc = new PureJavaCrc32(); StringBuilder sb = new StringBuilder(); sb.append("bin[crc:"); crc.update(bin); sb.append(crc.getValue()); sb.append(",value:0x"); String hex = Encoder.hexEncode(bin); if (hex.length() > 13) { sb.append(hex.substring(0, 10)); sb.append("..."); } else { sb.append(hex); } sb.append("]"); return sb.toString(); }
java
public static String varbinaryToPrintableString(byte[] bin) { PureJavaCrc32 crc = new PureJavaCrc32(); StringBuilder sb = new StringBuilder(); sb.append("bin[crc:"); crc.update(bin); sb.append(crc.getValue()); sb.append(",value:0x"); String hex = Encoder.hexEncode(bin); if (hex.length() > 13) { sb.append(hex.substring(0, 10)); sb.append("..."); } else { sb.append(hex); } sb.append("]"); return sb.toString(); }
[ "public", "static", "String", "varbinaryToPrintableString", "(", "byte", "[", "]", "bin", ")", "{", "PureJavaCrc32", "crc", "=", "new", "PureJavaCrc32", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", ...
Make a printable, short string for a varbinary. String includes a CRC and the contents of the varbinary in hex. Contents longer than 13 chars are truncated and elipsized. Yes, "elipsized" is totally a word. Example: "bin[crc:1298399436,value:0xABCDEF12345...]" @param bin The bytes to print out. @return A string representation that is printable and short.
[ "Make", "a", "printable", "short", "string", "for", "a", "varbinary", ".", "String", "includes", "a", "CRC", "and", "the", "contents", "of", "the", "varbinary", "in", "hex", ".", "Contents", "longer", "than", "13", "chars", "are", "truncated", "and", "elip...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L1550-L1567
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.toJSONString
@Override public String toJSONString() { JSONStringer js = new JSONStringer(); try { js.object(); // status code (1 byte) js.keySymbolValuePair(JSON_STATUS_KEY, getStatusCode()); // column schema js.key(JSON_SCHEMA_KEY).array(); for (int i = 0; i < getColumnCount(); i++) { js.object(); js.keySymbolValuePair(JSON_NAME_KEY, getColumnName(i)); js.keySymbolValuePair(JSON_TYPE_KEY, getColumnType(i).getValue()); js.endObject(); } js.endArray(); // row data js.key(JSON_DATA_KEY).array(); VoltTableRow row = cloneRow(); row.resetRowPosition(); while (row.advanceRow()) { js.array(); for (int i = 0; i < getColumnCount(); i++) { row.putJSONRep(i, js); } js.endArray(); } js.endArray(); js.endObject(); } catch (JSONException e) { e.printStackTrace(); throw new RuntimeException("Failed to serialized a table to JSON.", e); } return js.toString(); }
java
@Override public String toJSONString() { JSONStringer js = new JSONStringer(); try { js.object(); // status code (1 byte) js.keySymbolValuePair(JSON_STATUS_KEY, getStatusCode()); // column schema js.key(JSON_SCHEMA_KEY).array(); for (int i = 0; i < getColumnCount(); i++) { js.object(); js.keySymbolValuePair(JSON_NAME_KEY, getColumnName(i)); js.keySymbolValuePair(JSON_TYPE_KEY, getColumnType(i).getValue()); js.endObject(); } js.endArray(); // row data js.key(JSON_DATA_KEY).array(); VoltTableRow row = cloneRow(); row.resetRowPosition(); while (row.advanceRow()) { js.array(); for (int i = 0; i < getColumnCount(); i++) { row.putJSONRep(i, js); } js.endArray(); } js.endArray(); js.endObject(); } catch (JSONException e) { e.printStackTrace(); throw new RuntimeException("Failed to serialized a table to JSON.", e); } return js.toString(); }
[ "@", "Override", "public", "String", "toJSONString", "(", ")", "{", "JSONStringer", "js", "=", "new", "JSONStringer", "(", ")", ";", "try", "{", "js", ".", "object", "(", ")", ";", "// status code (1 byte)", "js", ".", "keySymbolValuePair", "(", "JSON_STATUS...
Get a JSON representation of this table. @return A string containing a JSON representation of this table.
[ "Get", "a", "JSON", "representation", "of", "this", "table", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L1722-L1762
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.fromJSONString
public static VoltTable fromJSONString(String json) throws JSONException, IOException { JSONObject jsonObj = new JSONObject(json); return fromJSONObject(jsonObj); }
java
public static VoltTable fromJSONString(String json) throws JSONException, IOException { JSONObject jsonObj = new JSONObject(json); return fromJSONObject(jsonObj); }
[ "public", "static", "VoltTable", "fromJSONString", "(", "String", "json", ")", "throws", "JSONException", ",", "IOException", "{", "JSONObject", "jsonObj", "=", "new", "JSONObject", "(", "json", ")", ";", "return", "fromJSONObject", "(", "jsonObj", ")", ";", "...
Construct a table from a JSON string. Only parses VoltDB VoltTable JSON format. @param json String containing JSON-formatted table data. @return Constructed <code>VoltTable</code> instance. @throws JSONException on JSON-related error. @throws IOException if thrown by our JSON library.
[ "Construct", "a", "table", "from", "a", "JSON", "string", ".", "Only", "parses", "VoltDB", "VoltTable", "JSON", "format", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L1794-L1797
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.semiDeepCopy
VoltTable semiDeepCopy() { assert(verifyTableInvariants()); // share the immutable metadata if it's present for tests final VoltTable cloned = new VoltTable(m_extraMetadata); cloned.m_colCount = m_colCount; cloned.m_rowCount = m_rowCount; cloned.m_rowStart = m_rowStart; cloned.m_buffer = m_buffer.duplicate(); cloned.m_activeRowIndex = m_activeRowIndex; cloned.m_hasCalculatedOffsets = m_hasCalculatedOffsets; cloned.m_memoizedBufferOffset = m_memoizedBufferOffset; cloned.m_memoizedRowOffset = m_memoizedRowOffset; cloned.m_offsets = m_offsets == null ? null : m_offsets.clone(); cloned.m_position = m_position; cloned.m_schemaString = m_schemaString == null ? null : m_schemaString.clone(); cloned.m_wasNull = m_wasNull; // make the new table read only cloned.m_readOnly = true; assert(verifyTableInvariants()); assert(cloned.verifyTableInvariants()); return cloned; }
java
VoltTable semiDeepCopy() { assert(verifyTableInvariants()); // share the immutable metadata if it's present for tests final VoltTable cloned = new VoltTable(m_extraMetadata); cloned.m_colCount = m_colCount; cloned.m_rowCount = m_rowCount; cloned.m_rowStart = m_rowStart; cloned.m_buffer = m_buffer.duplicate(); cloned.m_activeRowIndex = m_activeRowIndex; cloned.m_hasCalculatedOffsets = m_hasCalculatedOffsets; cloned.m_memoizedBufferOffset = m_memoizedBufferOffset; cloned.m_memoizedRowOffset = m_memoizedRowOffset; cloned.m_offsets = m_offsets == null ? null : m_offsets.clone(); cloned.m_position = m_position; cloned.m_schemaString = m_schemaString == null ? null : m_schemaString.clone(); cloned.m_wasNull = m_wasNull; // make the new table read only cloned.m_readOnly = true; assert(verifyTableInvariants()); assert(cloned.verifyTableInvariants()); return cloned; }
[ "VoltTable", "semiDeepCopy", "(", ")", "{", "assert", "(", "verifyTableInvariants", "(", ")", ")", ";", "// share the immutable metadata if it's present for tests", "final", "VoltTable", "cloned", "=", "new", "VoltTable", "(", "m_extraMetadata", ")", ";", "cloned", "....
Non-public method to duplicate a table. It's possible this might be useful to end-users of VoltDB, but we should talk about naming and semantics first, don't just make this public.
[ "Non", "-", "public", "method", "to", "duplicate", "a", "table", ".", "It", "s", "possible", "this", "might", "be", "useful", "to", "end", "-", "users", "of", "VoltDB", "but", "we", "should", "talk", "about", "naming", "and", "semantics", "first", "don",...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L1942-L1966
train
VoltDB/voltdb
src/frontend/org/voltdb/VoltTable.java
VoltTable.getTableSchema
public ColumnInfo[] getTableSchema() { ColumnInfo[] schema = new ColumnInfo[m_colCount]; for (int i = 0; i < m_colCount; i++) { ColumnInfo col = new ColumnInfo(getColumnName(i), getColumnType(i)); schema[i] = col; } return schema; }
java
public ColumnInfo[] getTableSchema() { ColumnInfo[] schema = new ColumnInfo[m_colCount]; for (int i = 0; i < m_colCount; i++) { ColumnInfo col = new ColumnInfo(getColumnName(i), getColumnType(i)); schema[i] = col; } return schema; }
[ "public", "ColumnInfo", "[", "]", "getTableSchema", "(", ")", "{", "ColumnInfo", "[", "]", "schema", "=", "new", "ColumnInfo", "[", "m_colCount", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m_colCount", ";", "i", "++", ")", "{", "Co...
Get the schema of the table. Can be fed into another table's constructor. @return An ordered array of {@link ColumnInfo} instances for each table column.
[ "Get", "the", "schema", "of", "the", "table", ".", "Can", "be", "fed", "into", "another", "table", "s", "constructor", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L2193-L2200
train
VoltDB/voltdb
src/frontend/org/voltdb/export/processors/GuestProcessor.java
GuestProcessor.checkProcessorConfig
@Override public void checkProcessorConfig(Properties properties) { String exportClientClass = properties.getProperty(EXPORT_TO_TYPE); Preconditions.checkNotNull(exportClientClass, "export to type is undefined or custom export plugin class missing."); try { final Class<?> clientClass = Class.forName(exportClientClass); ExportClientBase client = (ExportClientBase) clientClass.newInstance(); client.configure(properties); } catch(Throwable t) { throw new RuntimeException(t); } }
java
@Override public void checkProcessorConfig(Properties properties) { String exportClientClass = properties.getProperty(EXPORT_TO_TYPE); Preconditions.checkNotNull(exportClientClass, "export to type is undefined or custom export plugin class missing."); try { final Class<?> clientClass = Class.forName(exportClientClass); ExportClientBase client = (ExportClientBase) clientClass.newInstance(); client.configure(properties); } catch(Throwable t) { throw new RuntimeException(t); } }
[ "@", "Override", "public", "void", "checkProcessorConfig", "(", "Properties", "properties", ")", "{", "String", "exportClientClass", "=", "properties", ".", "getProperty", "(", "EXPORT_TO_TYPE", ")", ";", "Preconditions", ".", "checkNotNull", "(", "exportClientClass",...
Pass processor specific processor configuration properties for checking
[ "Pass", "processor", "specific", "processor", "configuration", "properties", "for", "checking" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/export/processors/GuestProcessor.java#L166-L178
train
VoltDB/voltdb
src/frontend/org/voltdb/export/processors/GuestProcessor.java
GuestProcessor.extractCommittedSpHandle
private long extractCommittedSpHandle(ExportRow row, long committedSeqNo) { long ret = 0; if (committedSeqNo == ExportDataSource.NULL_COMMITTED_SEQNO) { return ret; } // Get the rows's sequence number (3rd column) long seqNo = (long) row.values[2]; if (seqNo != committedSeqNo) { return ret; } // Get the row's sp handle (1rst column) ret = (long) row.values[0]; return ret; }
java
private long extractCommittedSpHandle(ExportRow row, long committedSeqNo) { long ret = 0; if (committedSeqNo == ExportDataSource.NULL_COMMITTED_SEQNO) { return ret; } // Get the rows's sequence number (3rd column) long seqNo = (long) row.values[2]; if (seqNo != committedSeqNo) { return ret; } // Get the row's sp handle (1rst column) ret = (long) row.values[0]; return ret; }
[ "private", "long", "extractCommittedSpHandle", "(", "ExportRow", "row", ",", "long", "committedSeqNo", ")", "{", "long", "ret", "=", "0", ";", "if", "(", "committedSeqNo", "==", "ExportDataSource", ".", "NULL_COMMITTED_SEQNO", ")", "{", "return", "ret", ";", "...
If the row is the last committed row, return the SpHandle, otherwise return 0 @param row the export row @param committedSeqNo the sequence number of the last committed row @return
[ "If", "the", "row", "is", "the", "last", "committed", "row", "return", "the", "SpHandle", "otherwise", "return", "0" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/export/processors/GuestProcessor.java#L506-L521
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/MaterializedViewProcessor.java
MaterializedViewProcessor.processMaterializedViewWarnings
public void processMaterializedViewWarnings(Database db, HashMap<Table, String> matViewMap) throws VoltCompilerException { for (Table table : db.getTables()) { for (MaterializedViewInfo mvInfo : table.getViews()) { for (Statement stmt : mvInfo.getFallbackquerystmts()) { // If there is any statement in the fallBackQueryStmts map, then // there must be some min/max columns. // Only check if the plan uses index scan. if (needsWarningForSingleTableView( getPlanNodeTreeFromCatalogStatement(db, stmt))) { // If we are using IS NOT DISTINCT FROM as our equality operator (which is necessary // to get correct answers), then there will often be no index scans in the plan, // since we cannot optimize IS NOT DISTINCT FROM. m_compiler.addWarn( "No index found to support UPDATE and DELETE on some of the min() / max() columns " + "in the materialized view " + mvInfo.getTypeName() + ", and a sequential scan might be issued when current min / max value is updated / deleted."); break; } } } // If it's a view on join query case, we check if the join can utilize indices. // We throw out warning only if no index scan is used in the plan (ENG-10864). MaterializedViewHandlerInfo mvHandlerInfo = table.getMvhandlerinfo().get("mvHandlerInfo"); if (mvHandlerInfo != null) { Statement createQueryStatement = mvHandlerInfo.getCreatequery().get("createQuery"); if (needsWarningForJoinQueryView( getPlanNodeTreeFromCatalogStatement(db, createQueryStatement))) { m_compiler.addWarn( "No index found to support some of the join operations required to refresh the materialized view " + table.getTypeName() + ". The refreshing may be slow."); } } } }
java
public void processMaterializedViewWarnings(Database db, HashMap<Table, String> matViewMap) throws VoltCompilerException { for (Table table : db.getTables()) { for (MaterializedViewInfo mvInfo : table.getViews()) { for (Statement stmt : mvInfo.getFallbackquerystmts()) { // If there is any statement in the fallBackQueryStmts map, then // there must be some min/max columns. // Only check if the plan uses index scan. if (needsWarningForSingleTableView( getPlanNodeTreeFromCatalogStatement(db, stmt))) { // If we are using IS NOT DISTINCT FROM as our equality operator (which is necessary // to get correct answers), then there will often be no index scans in the plan, // since we cannot optimize IS NOT DISTINCT FROM. m_compiler.addWarn( "No index found to support UPDATE and DELETE on some of the min() / max() columns " + "in the materialized view " + mvInfo.getTypeName() + ", and a sequential scan might be issued when current min / max value is updated / deleted."); break; } } } // If it's a view on join query case, we check if the join can utilize indices. // We throw out warning only if no index scan is used in the plan (ENG-10864). MaterializedViewHandlerInfo mvHandlerInfo = table.getMvhandlerinfo().get("mvHandlerInfo"); if (mvHandlerInfo != null) { Statement createQueryStatement = mvHandlerInfo.getCreatequery().get("createQuery"); if (needsWarningForJoinQueryView( getPlanNodeTreeFromCatalogStatement(db, createQueryStatement))) { m_compiler.addWarn( "No index found to support some of the join operations required to refresh the materialized view " + table.getTypeName() + ". The refreshing may be slow."); } } } }
[ "public", "void", "processMaterializedViewWarnings", "(", "Database", "db", ",", "HashMap", "<", "Table", ",", "String", ">", "matViewMap", ")", "throws", "VoltCompilerException", "{", "for", "(", "Table", "table", ":", "db", ".", "getTables", "(", ")", ")", ...
Process materialized view warnings.
[ "Process", "materialized", "view", "warnings", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/MaterializedViewProcessor.java#L774-L806
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/MaterializedViewProcessor.java
MaterializedViewProcessor.getMaterializedViewInfo
public static MaterializedViewInfo getMaterializedViewInfo(Table tbl) { MaterializedViewInfo mvInfo = null; Table source = tbl.getMaterializer(); if (source != null) { mvInfo = source.getViews().get(tbl.getTypeName()); } return mvInfo; }
java
public static MaterializedViewInfo getMaterializedViewInfo(Table tbl) { MaterializedViewInfo mvInfo = null; Table source = tbl.getMaterializer(); if (source != null) { mvInfo = source.getViews().get(tbl.getTypeName()); } return mvInfo; }
[ "public", "static", "MaterializedViewInfo", "getMaterializedViewInfo", "(", "Table", "tbl", ")", "{", "MaterializedViewInfo", "mvInfo", "=", "null", ";", "Table", "source", "=", "tbl", ".", "getMaterializer", "(", ")", ";", "if", "(", "source", "!=", "null", "...
If the argument table is a single-table materialized view, then return the attendant MaterializedViewInfo object. Otherwise return null.
[ "If", "the", "argument", "table", "is", "a", "single", "-", "table", "materialized", "view", "then", "return", "the", "attendant", "MaterializedViewInfo", "object", ".", "Otherwise", "return", "null", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/MaterializedViewProcessor.java#L1095-L1102
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/ActivePlanRepository.java
ActivePlanRepository.getFragmentIdForPlanHash
public static long getFragmentIdForPlanHash(byte[] planHash) { Sha1Wrapper key = new Sha1Wrapper(planHash); FragInfo frag = null; synchronized (FragInfo.class) { frag = m_plansByHash.get(key); } assert(frag != null); return frag.fragId; }
java
public static long getFragmentIdForPlanHash(byte[] planHash) { Sha1Wrapper key = new Sha1Wrapper(planHash); FragInfo frag = null; synchronized (FragInfo.class) { frag = m_plansByHash.get(key); } assert(frag != null); return frag.fragId; }
[ "public", "static", "long", "getFragmentIdForPlanHash", "(", "byte", "[", "]", "planHash", ")", "{", "Sha1Wrapper", "key", "=", "new", "Sha1Wrapper", "(", "planHash", ")", ";", "FragInfo", "frag", "=", "null", ";", "synchronized", "(", "FragInfo", ".", "clas...
Get the site-local fragment id for a given plan identified by 20-byte sha-1 hash
[ "Get", "the", "site", "-", "local", "fragment", "id", "for", "a", "given", "plan", "identified", "by", "20", "-", "byte", "sha", "-", "1", "hash" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/ActivePlanRepository.java#L68-L76
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/ActivePlanRepository.java
ActivePlanRepository.getStmtTextForPlanHash
public static String getStmtTextForPlanHash(byte[] planHash) { Sha1Wrapper key = new Sha1Wrapper(planHash); FragInfo frag = null; synchronized (FragInfo.class) { frag = m_plansByHash.get(key); } assert(frag != null); // SQL statement text is not stored in the repository for ad hoc statements // -- it may be inaccurate because we parameterize the statement on its constants. // Callers know if they are asking about ad hoc or pre-planned fragments, // and shouldn't call this method for the ad hoc case. assert(frag.stmtText != null); return frag.stmtText; }
java
public static String getStmtTextForPlanHash(byte[] planHash) { Sha1Wrapper key = new Sha1Wrapper(planHash); FragInfo frag = null; synchronized (FragInfo.class) { frag = m_plansByHash.get(key); } assert(frag != null); // SQL statement text is not stored in the repository for ad hoc statements // -- it may be inaccurate because we parameterize the statement on its constants. // Callers know if they are asking about ad hoc or pre-planned fragments, // and shouldn't call this method for the ad hoc case. assert(frag.stmtText != null); return frag.stmtText; }
[ "public", "static", "String", "getStmtTextForPlanHash", "(", "byte", "[", "]", "planHash", ")", "{", "Sha1Wrapper", "key", "=", "new", "Sha1Wrapper", "(", "planHash", ")", ";", "FragInfo", "frag", "=", "null", ";", "synchronized", "(", "FragInfo", ".", "clas...
Get the statement text for the fragment identified by its hash
[ "Get", "the", "statement", "text", "for", "the", "fragment", "identified", "by", "its", "hash" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/ActivePlanRepository.java#L81-L94
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/ActivePlanRepository.java
ActivePlanRepository.loadOrAddRefPlanFragment
public static long loadOrAddRefPlanFragment(byte[] planHash, byte[] plan, String stmtText) { Sha1Wrapper key = new Sha1Wrapper(planHash); synchronized (FragInfo.class) { FragInfo frag = m_plansByHash.get(key); if (frag == null) { frag = new FragInfo(key, plan, m_nextFragId++, stmtText); m_plansByHash.put(frag.hash, frag); m_plansById.put(frag.fragId, frag); if (m_plansById.size() > ExecutionEngine.EE_PLAN_CACHE_SIZE) { evictLRUfragment(); } } // Bit of a hack to work around an issue where a statement-less adhoc // fragment could be identical to a statement-needing regular procedure. // This doesn't really address the broader issue that fragment hashes // are not 1-1 with SQL statements. if (frag.stmtText == null) { frag.stmtText = stmtText; } // The fragment MAY be in the LRU map. // An incremented refCount is a lazy way to keep it safe from eviction // without having to update the map. // This optimizes for popular fragments in a small or stable cache that may be reused // many times before the eviction process needs to take any notice. frag.refCount++; return frag.fragId; } }
java
public static long loadOrAddRefPlanFragment(byte[] planHash, byte[] plan, String stmtText) { Sha1Wrapper key = new Sha1Wrapper(planHash); synchronized (FragInfo.class) { FragInfo frag = m_plansByHash.get(key); if (frag == null) { frag = new FragInfo(key, plan, m_nextFragId++, stmtText); m_plansByHash.put(frag.hash, frag); m_plansById.put(frag.fragId, frag); if (m_plansById.size() > ExecutionEngine.EE_PLAN_CACHE_SIZE) { evictLRUfragment(); } } // Bit of a hack to work around an issue where a statement-less adhoc // fragment could be identical to a statement-needing regular procedure. // This doesn't really address the broader issue that fragment hashes // are not 1-1 with SQL statements. if (frag.stmtText == null) { frag.stmtText = stmtText; } // The fragment MAY be in the LRU map. // An incremented refCount is a lazy way to keep it safe from eviction // without having to update the map. // This optimizes for popular fragments in a small or stable cache that may be reused // many times before the eviction process needs to take any notice. frag.refCount++; return frag.fragId; } }
[ "public", "static", "long", "loadOrAddRefPlanFragment", "(", "byte", "[", "]", "planHash", ",", "byte", "[", "]", "plan", ",", "String", "stmtText", ")", "{", "Sha1Wrapper", "key", "=", "new", "Sha1Wrapper", "(", "planHash", ")", ";", "synchronized", "(", ...
Get the site-local fragment id for a given plan identified by 20-byte sha-1 hash If the plan isn't known to this SPC, load it up. Otherwise addref it.
[ "Get", "the", "site", "-", "local", "fragment", "id", "for", "a", "given", "plan", "identified", "by", "20", "-", "byte", "sha", "-", "1", "hash", "If", "the", "plan", "isn", "t", "known", "to", "this", "SPC", "load", "it", "up", ".", "Otherwise", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/ActivePlanRepository.java#L100-L129
train
VoltDB/voltdb
src/frontend/org/voltdb/planner/ActivePlanRepository.java
ActivePlanRepository.planForFragmentId
public static byte[] planForFragmentId(long fragmentId) { assert(fragmentId > 0); FragInfo frag = null; synchronized (FragInfo.class) { frag = m_plansById.get(fragmentId); } assert(frag != null); return frag.plan; }
java
public static byte[] planForFragmentId(long fragmentId) { assert(fragmentId > 0); FragInfo frag = null; synchronized (FragInfo.class) { frag = m_plansById.get(fragmentId); } assert(frag != null); return frag.plan; }
[ "public", "static", "byte", "[", "]", "planForFragmentId", "(", "long", "fragmentId", ")", "{", "assert", "(", "fragmentId", ">", "0", ")", ";", "FragInfo", "frag", "=", "null", ";", "synchronized", "(", "FragInfo", ".", "class", ")", "{", "frag", "=", ...
Get the full JSON plan associated with a given site-local fragment id. Called by the EE
[ "Get", "the", "full", "JSON", "plan", "associated", "with", "a", "given", "site", "-", "local", "fragment", "id", ".", "Called", "by", "the", "EE" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/ActivePlanRepository.java#L231-L240
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.bindingToIndexedExpression
public List<AbstractExpression> bindingToIndexedExpression( AbstractExpression expr) { // Defer the result construction for as long as possible on the // assumption that this function mostly gets applied to eliminate // negative cases. if (m_type != expr.m_type) { // The only allowed difference in expression types is between a // parameter and its original constant value. // That's handled in the independent override. return null; } // From here, this is much like the straight equality check, // except that this function and "equals" must each call themselves // in their recursions. // Delegating to this factored-out component of the "equals" // implementation eases simultaneous refinement of both methods. if ( ! hasEqualAttributes(expr)) { return null; } // The derived classes have verified that any added attributes // are identical. // Check that the presence, or lack, of children is the same if ((expr.m_left == null) != (m_left == null)) { return null; } if ((expr.m_right == null) != (m_right == null)) { return null; } if ((expr.m_args == null) != (m_args == null)) { return null; } // Check that the children identify themselves as matching List<AbstractExpression> leftBindings = null; if (m_left != null) { leftBindings = m_left.bindingToIndexedExpression(expr.m_left); if (leftBindings == null) { return null; } } List<AbstractExpression> rightBindings = null; if (m_right != null) { rightBindings = m_right.bindingToIndexedExpression(expr.m_right); if (rightBindings == null) { return null; } } List<AbstractExpression> argBindings = null; if (m_args != null) { if (m_args.size() != expr.m_args.size()) { return null; } argBindings = new ArrayList<>(); int ii = 0; // iterate the args lists in parallel, binding pairwise for (AbstractExpression rhs : expr.m_args) { AbstractExpression lhs = m_args.get(ii++); List<AbstractExpression> moreBindings = lhs.bindingToIndexedExpression(rhs); if (moreBindings == null) { // fail on any non-match return null; } argBindings.addAll(moreBindings); } } // It's a match, so gather up the details. // It's rare (if even possible) for the same bound parameter to get // listed twice, so don't worry about duplicate entries, here. // That should not cause any issue for the caller. List<AbstractExpression> result = new ArrayList<>(); if (leftBindings != null) { // null here can only mean no left child result.addAll(leftBindings); } if (rightBindings != null) { // null here can only mean no right child result.addAll(rightBindings); } if (argBindings != null) { // null here can only mean no args result.addAll(argBindings); } return result; }
java
public List<AbstractExpression> bindingToIndexedExpression( AbstractExpression expr) { // Defer the result construction for as long as possible on the // assumption that this function mostly gets applied to eliminate // negative cases. if (m_type != expr.m_type) { // The only allowed difference in expression types is between a // parameter and its original constant value. // That's handled in the independent override. return null; } // From here, this is much like the straight equality check, // except that this function and "equals" must each call themselves // in their recursions. // Delegating to this factored-out component of the "equals" // implementation eases simultaneous refinement of both methods. if ( ! hasEqualAttributes(expr)) { return null; } // The derived classes have verified that any added attributes // are identical. // Check that the presence, or lack, of children is the same if ((expr.m_left == null) != (m_left == null)) { return null; } if ((expr.m_right == null) != (m_right == null)) { return null; } if ((expr.m_args == null) != (m_args == null)) { return null; } // Check that the children identify themselves as matching List<AbstractExpression> leftBindings = null; if (m_left != null) { leftBindings = m_left.bindingToIndexedExpression(expr.m_left); if (leftBindings == null) { return null; } } List<AbstractExpression> rightBindings = null; if (m_right != null) { rightBindings = m_right.bindingToIndexedExpression(expr.m_right); if (rightBindings == null) { return null; } } List<AbstractExpression> argBindings = null; if (m_args != null) { if (m_args.size() != expr.m_args.size()) { return null; } argBindings = new ArrayList<>(); int ii = 0; // iterate the args lists in parallel, binding pairwise for (AbstractExpression rhs : expr.m_args) { AbstractExpression lhs = m_args.get(ii++); List<AbstractExpression> moreBindings = lhs.bindingToIndexedExpression(rhs); if (moreBindings == null) { // fail on any non-match return null; } argBindings.addAll(moreBindings); } } // It's a match, so gather up the details. // It's rare (if even possible) for the same bound parameter to get // listed twice, so don't worry about duplicate entries, here. // That should not cause any issue for the caller. List<AbstractExpression> result = new ArrayList<>(); if (leftBindings != null) { // null here can only mean no left child result.addAll(leftBindings); } if (rightBindings != null) { // null here can only mean no right child result.addAll(rightBindings); } if (argBindings != null) { // null here can only mean no args result.addAll(argBindings); } return result; }
[ "public", "List", "<", "AbstractExpression", ">", "bindingToIndexedExpression", "(", "AbstractExpression", "expr", ")", "{", "// Defer the result construction for as long as possible on the", "// assumption that this function mostly gets applied to eliminate", "// negative cases.", "if",...
strict expression equality that didn't involve parameters.
[ "strict", "expression", "equality", "that", "didn", "t", "involve", "parameters", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L482-L566
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.toJSONArrayFromSortList
public static void toJSONArrayFromSortList( JSONStringer stringer, List<AbstractExpression> sortExpressions, List<SortDirectionType> sortDirections) throws JSONException { stringer.key(SortMembers.SORT_COLUMNS); stringer.array(); int listSize = sortExpressions.size(); for (int ii = 0; ii < listSize; ii++) { stringer.object(); stringer.key(SortMembers.SORT_EXPRESSION).object(); sortExpressions.get(ii).toJSONString(stringer); stringer.endObject(); if (sortDirections != null) { stringer.keySymbolValuePair(SortMembers.SORT_DIRECTION, sortDirections.get(ii).toString()); } stringer.endObject(); } stringer.endArray(); }
java
public static void toJSONArrayFromSortList( JSONStringer stringer, List<AbstractExpression> sortExpressions, List<SortDirectionType> sortDirections) throws JSONException { stringer.key(SortMembers.SORT_COLUMNS); stringer.array(); int listSize = sortExpressions.size(); for (int ii = 0; ii < listSize; ii++) { stringer.object(); stringer.key(SortMembers.SORT_EXPRESSION).object(); sortExpressions.get(ii).toJSONString(stringer); stringer.endObject(); if (sortDirections != null) { stringer.keySymbolValuePair(SortMembers.SORT_DIRECTION, sortDirections.get(ii).toString()); } stringer.endObject(); } stringer.endArray(); }
[ "public", "static", "void", "toJSONArrayFromSortList", "(", "JSONStringer", "stringer", ",", "List", "<", "AbstractExpression", ">", "sortExpressions", ",", "List", "<", "SortDirectionType", ">", "sortDirections", ")", "throws", "JSONException", "{", "stringer", ".", ...
Given a JSONStringer and a sequence of sort expressions and directions, serialize the sort expressions. These will be in an array which is the value of SortMembers.SORT_COLUMNS in the current object of the JSONString. The JSONString should be in object state, not array state. @param stringer The stringer used to serialize the sort list. @param sortExpressions The sort expressions. @param sortDirections The sort directions. These may be empty if the directions are not valueable to us. @throws JSONException
[ "Given", "a", "JSONStringer", "and", "a", "sequence", "of", "sort", "expressions", "and", "directions", "serialize", "the", "sort", "expressions", ".", "These", "will", "be", "in", "an", "array", "which", "is", "the", "value", "of", "SortMembers", ".", "SORT...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L648-L667
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.loadSortListFromJSONArray
public static void loadSortListFromJSONArray( List<AbstractExpression> sortExpressions, List<SortDirectionType> sortDirections, JSONObject jobj) throws JSONException { if (jobj.has(SortMembers.SORT_COLUMNS)) { sortExpressions.clear(); if (sortDirections != null) { sortDirections.clear(); } JSONArray jarray = jobj.getJSONArray(SortMembers.SORT_COLUMNS); int size = jarray.length(); for (int ii = 0; ii < size; ++ii) { JSONObject tempObj = jarray.getJSONObject(ii); sortExpressions.add( fromJSONChild(tempObj, SortMembers.SORT_EXPRESSION)); if (sortDirections == null || ! tempObj.has(SortMembers.SORT_DIRECTION)) { continue; } String sdAsString = tempObj.getString(SortMembers.SORT_DIRECTION); sortDirections.add(SortDirectionType.get(sdAsString)); } } assert(sortDirections == null || sortExpressions.size() == sortDirections.size()); }
java
public static void loadSortListFromJSONArray( List<AbstractExpression> sortExpressions, List<SortDirectionType> sortDirections, JSONObject jobj) throws JSONException { if (jobj.has(SortMembers.SORT_COLUMNS)) { sortExpressions.clear(); if (sortDirections != null) { sortDirections.clear(); } JSONArray jarray = jobj.getJSONArray(SortMembers.SORT_COLUMNS); int size = jarray.length(); for (int ii = 0; ii < size; ++ii) { JSONObject tempObj = jarray.getJSONObject(ii); sortExpressions.add( fromJSONChild(tempObj, SortMembers.SORT_EXPRESSION)); if (sortDirections == null || ! tempObj.has(SortMembers.SORT_DIRECTION)) { continue; } String sdAsString = tempObj.getString(SortMembers.SORT_DIRECTION); sortDirections.add(SortDirectionType.get(sdAsString)); } } assert(sortDirections == null || sortExpressions.size() == sortDirections.size()); }
[ "public", "static", "void", "loadSortListFromJSONArray", "(", "List", "<", "AbstractExpression", ">", "sortExpressions", ",", "List", "<", "SortDirectionType", ">", "sortDirections", ",", "JSONObject", "jobj", ")", "throws", "JSONException", "{", "if", "(", "jobj", ...
Load two lists from a JSONObject. One list is for sort expressions and the other is for sort directions. The lists are cleared before they are filled in. This is the inverse of toJSONArrayFromSortList. The JSONObject should be in object state, not array state. It should have a member named SORT_COLUMNS, which is an array with the <expression, direction> pairs. Sometimes the sort directions are not needed. For example, when deserializing @param sortExpressions The container for the sort expressions. @param sortDirections The container for the sort directions. This may be null if we don't care about directions. If there are no directions in the list this will be empty. @param jarray @throws JSONException
[ "Load", "two", "lists", "from", "a", "JSONObject", ".", "One", "list", "is", "for", "sort", "expressions", "and", "the", "other", "is", "for", "sort", "directions", ".", "The", "lists", "are", "cleared", "before", "they", "are", "filled", "in", ".", "Thi...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L752-L776
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.loadFromJSONArrayChild
public static List<AbstractExpression> loadFromJSONArrayChild( List<AbstractExpression> starter, JSONObject parent, String label, StmtTableScan tableScan) throws JSONException { if (parent.isNull(label)) { return null; } JSONArray jarray = parent.getJSONArray(label); return loadFromJSONArray(starter, jarray, tableScan); }
java
public static List<AbstractExpression> loadFromJSONArrayChild( List<AbstractExpression> starter, JSONObject parent, String label, StmtTableScan tableScan) throws JSONException { if (parent.isNull(label)) { return null; } JSONArray jarray = parent.getJSONArray(label); return loadFromJSONArray(starter, jarray, tableScan); }
[ "public", "static", "List", "<", "AbstractExpression", ">", "loadFromJSONArrayChild", "(", "List", "<", "AbstractExpression", ">", "starter", ",", "JSONObject", "parent", ",", "String", "label", ",", "StmtTableScan", "tableScan", ")", "throws", "JSONException", "{",...
For TVEs, it is only serialized column index and table index. In order to match expression, there needs more information to revert back the table name, table alisa and column name. By adding @param tableScan, the TVE will load table name, table alias and column name for TVE. @param starter @param parent @param label @param tableScan @throws JSONException
[ "For", "TVEs", "it", "is", "only", "serialized", "column", "index", "and", "table", "index", ".", "In", "order", "to", "match", "expression", "there", "needs", "more", "information", "to", "revert", "back", "the", "table", "name", "table", "alisa", "and", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L812-L823
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.replaceWithTVE
public AbstractExpression replaceWithTVE( Map<AbstractExpression, Integer> aggTableIndexMap, Map<Integer, ParsedColInfo> indexToColumnMap) { Integer ii = aggTableIndexMap.get(this); if (ii != null) { ParsedColInfo col = indexToColumnMap.get(ii); TupleValueExpression tve = new TupleValueExpression( col.m_tableName, col.m_tableAlias, col.m_columnName, col.m_alias, this, ii); if (this instanceof TupleValueExpression) { tve.setOrigStmtId(((TupleValueExpression)this).getOrigStmtId()); } // To prevent pushdown of LIMIT when ORDER BY references an agg. ENG-3487. if (hasAnySubexpressionOfClass(AggregateExpression.class)) { tve.setHasAggregate(true); } return tve; } AbstractExpression lnode = null; AbstractExpression rnode = null; if (m_left != null) { lnode = m_left.replaceWithTVE(aggTableIndexMap, indexToColumnMap); } if (m_right != null) { rnode = m_right.replaceWithTVE(aggTableIndexMap, indexToColumnMap); } ArrayList<AbstractExpression> newArgs = null; boolean changed = false; if (m_args != null) { newArgs = new ArrayList<>(); for (AbstractExpression expr: m_args) { AbstractExpression ex = expr.replaceWithTVE(aggTableIndexMap, indexToColumnMap); newArgs.add(ex); if (ex != expr) { changed = true; } } } if (m_left != lnode || m_right != rnode || changed) { AbstractExpression resExpr = clone(); resExpr.setLeft(lnode); resExpr.setRight(rnode); resExpr.setArgs(newArgs); return resExpr; } return this; }
java
public AbstractExpression replaceWithTVE( Map<AbstractExpression, Integer> aggTableIndexMap, Map<Integer, ParsedColInfo> indexToColumnMap) { Integer ii = aggTableIndexMap.get(this); if (ii != null) { ParsedColInfo col = indexToColumnMap.get(ii); TupleValueExpression tve = new TupleValueExpression( col.m_tableName, col.m_tableAlias, col.m_columnName, col.m_alias, this, ii); if (this instanceof TupleValueExpression) { tve.setOrigStmtId(((TupleValueExpression)this).getOrigStmtId()); } // To prevent pushdown of LIMIT when ORDER BY references an agg. ENG-3487. if (hasAnySubexpressionOfClass(AggregateExpression.class)) { tve.setHasAggregate(true); } return tve; } AbstractExpression lnode = null; AbstractExpression rnode = null; if (m_left != null) { lnode = m_left.replaceWithTVE(aggTableIndexMap, indexToColumnMap); } if (m_right != null) { rnode = m_right.replaceWithTVE(aggTableIndexMap, indexToColumnMap); } ArrayList<AbstractExpression> newArgs = null; boolean changed = false; if (m_args != null) { newArgs = new ArrayList<>(); for (AbstractExpression expr: m_args) { AbstractExpression ex = expr.replaceWithTVE(aggTableIndexMap, indexToColumnMap); newArgs.add(ex); if (ex != expr) { changed = true; } } } if (m_left != lnode || m_right != rnode || changed) { AbstractExpression resExpr = clone(); resExpr.setLeft(lnode); resExpr.setRight(rnode); resExpr.setArgs(newArgs); return resExpr; } return this; }
[ "public", "AbstractExpression", "replaceWithTVE", "(", "Map", "<", "AbstractExpression", ",", "Integer", ">", "aggTableIndexMap", ",", "Map", "<", "Integer", ",", "ParsedColInfo", ">", "indexToColumnMap", ")", "{", "Integer", "ii", "=", "aggTableIndexMap", ".", "g...
This function recursively replaces any subexpression matching an entry in aggTableIndexMap with an equivalent TVE. Its column index and alias are also built up here. @param aggTableIndexMap @param indexToColumnMap @return
[ "This", "function", "recursively", "replaces", "any", "subexpression", "matching", "an", "entry", "in", "aggTableIndexMap", "with", "an", "equivalent", "TVE", ".", "Its", "column", "index", "and", "alias", "are", "also", "built", "up", "here", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L848-L900
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.hasAnySubexpressionWithPredicate
public boolean hasAnySubexpressionWithPredicate(SubexprFinderPredicate pred) { if (pred.matches(this)) { return true; } if (m_left != null && m_left.hasAnySubexpressionWithPredicate(pred)) { return true; } if (m_right != null && m_right.hasAnySubexpressionWithPredicate(pred)) { return true; } if (m_args != null) { for (AbstractExpression argument : m_args) { if (argument.hasAnySubexpressionWithPredicate(pred)) { return true; } } } return false; }
java
public boolean hasAnySubexpressionWithPredicate(SubexprFinderPredicate pred) { if (pred.matches(this)) { return true; } if (m_left != null && m_left.hasAnySubexpressionWithPredicate(pred)) { return true; } if (m_right != null && m_right.hasAnySubexpressionWithPredicate(pred)) { return true; } if (m_args != null) { for (AbstractExpression argument : m_args) { if (argument.hasAnySubexpressionWithPredicate(pred)) { return true; } } } return false; }
[ "public", "boolean", "hasAnySubexpressionWithPredicate", "(", "SubexprFinderPredicate", "pred", ")", "{", "if", "(", "pred", ".", "matches", "(", "this", ")", ")", "{", "return", "true", ";", "}", "if", "(", "m_left", "!=", "null", "&&", "m_left", ".", "ha...
Searches the expression tree rooted at this for nodes for which "pred" evaluates to true. @param pred Predicate object instantiated by caller @return true if the predicate ever returns true, false otherwise
[ "Searches", "the", "expression", "tree", "rooted", "at", "this", "for", "nodes", "for", "which", "pred", "evaluates", "to", "true", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1061-L1083
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.refineOperandType
void refineOperandType(VoltType valueType) { if (m_valueType != VoltType.NUMERIC) { return; } if (valueType == VoltType.DECIMAL) { m_valueType = VoltType.DECIMAL; m_valueSize = VoltType.DECIMAL.getLengthInBytesForFixedTypes(); } else { m_valueType = VoltType.FLOAT; m_valueSize = VoltType.FLOAT.getLengthInBytesForFixedTypes(); } }
java
void refineOperandType(VoltType valueType) { if (m_valueType != VoltType.NUMERIC) { return; } if (valueType == VoltType.DECIMAL) { m_valueType = VoltType.DECIMAL; m_valueSize = VoltType.DECIMAL.getLengthInBytesForFixedTypes(); } else { m_valueType = VoltType.FLOAT; m_valueSize = VoltType.FLOAT.getLengthInBytesForFixedTypes(); } }
[ "void", "refineOperandType", "(", "VoltType", "valueType", ")", "{", "if", "(", "m_valueType", "!=", "VoltType", ".", "NUMERIC", ")", "{", "return", ";", "}", "if", "(", "valueType", "==", "VoltType", ".", "DECIMAL", ")", "{", "m_valueType", "=", "VoltType...
Helper function to patch up NUMERIC typed constant operands and the functions and operators that they parameterize.
[ "Helper", "function", "to", "patch", "up", "NUMERIC", "typed", "constant", "operands", "and", "the", "functions", "and", "operators", "that", "they", "parameterize", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1138-L1151
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.finalizeChildValueTypes
protected final void finalizeChildValueTypes() { if (m_left != null) { m_left.finalizeValueTypes(); updateContentDeterminismMessage(m_left.getContentDeterminismMessage()); } if (m_right != null) { m_right.finalizeValueTypes(); updateContentDeterminismMessage(m_right.getContentDeterminismMessage()); } if (m_args != null) { for (AbstractExpression argument : m_args) { argument.finalizeValueTypes(); updateContentDeterminismMessage(argument.getContentDeterminismMessage()); } } }
java
protected final void finalizeChildValueTypes() { if (m_left != null) { m_left.finalizeValueTypes(); updateContentDeterminismMessage(m_left.getContentDeterminismMessage()); } if (m_right != null) { m_right.finalizeValueTypes(); updateContentDeterminismMessage(m_right.getContentDeterminismMessage()); } if (m_args != null) { for (AbstractExpression argument : m_args) { argument.finalizeValueTypes(); updateContentDeterminismMessage(argument.getContentDeterminismMessage()); } } }
[ "protected", "final", "void", "finalizeChildValueTypes", "(", ")", "{", "if", "(", "m_left", "!=", "null", ")", "{", "m_left", ".", "finalizeValueTypes", "(", ")", ";", "updateContentDeterminismMessage", "(", "m_left", ".", "getContentDeterminismMessage", "(", ")"...
Do the recursive part of finalizeValueTypes as requested. Note that this updates the content non-determinism state.
[ "Do", "the", "recursive", "part", "of", "finalizeValueTypes", "as", "requested", ".", "Note", "that", "this", "updates", "the", "content", "non", "-", "determinism", "state", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1216-L1231
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.resolveChildrenForTable
protected final void resolveChildrenForTable(Table table) { if (m_left != null) { m_left.resolveForTable(table); } if (m_right != null) { m_right.resolveForTable(table); } if (m_args != null) { for (AbstractExpression argument : m_args) { argument.resolveForTable(table); } } }
java
protected final void resolveChildrenForTable(Table table) { if (m_left != null) { m_left.resolveForTable(table); } if (m_right != null) { m_right.resolveForTable(table); } if (m_args != null) { for (AbstractExpression argument : m_args) { argument.resolveForTable(table); } } }
[ "protected", "final", "void", "resolveChildrenForTable", "(", "Table", "table", ")", "{", "if", "(", "m_left", "!=", "null", ")", "{", "m_left", ".", "resolveForTable", "(", "table", ")", ";", "}", "if", "(", "m_right", "!=", "null", ")", "{", "m_right",...
Walk the expression tree, resolving TVEs and function expressions as we go.
[ "Walk", "the", "expression", "tree", "resolving", "TVEs", "and", "function", "expressions", "as", "we", "go", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1249-L1261
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.isValidExprForIndexesAndMVs
public boolean isValidExprForIndexesAndMVs(StringBuffer msg, boolean isMV) { if (containsFunctionById(FunctionSQL.voltGetCurrentTimestampId())) { msg.append("cannot include the function NOW or CURRENT_TIMESTAMP."); return false; } else if (hasAnySubexpressionOfClass(AggregateExpression.class)) { msg.append("cannot contain aggregate expressions."); return false; } else if (hasAnySubexpressionOfClass(AbstractSubqueryExpression.class)) { // There may not be any of these in HSQL1.9.3b. However, in // HSQL2.3.2 subqueries are stored as expressions. So, we may // find some here. We will keep it here for the moment. if (isMV) { msg.append("cannot contain subquery sources."); } else { msg.append("cannot contain subqueries."); } return false; } else if (hasUserDefinedFunctionExpression()) { msg.append("cannot contain calls to user defined functions."); return false; } else { return true; } }
java
public boolean isValidExprForIndexesAndMVs(StringBuffer msg, boolean isMV) { if (containsFunctionById(FunctionSQL.voltGetCurrentTimestampId())) { msg.append("cannot include the function NOW or CURRENT_TIMESTAMP."); return false; } else if (hasAnySubexpressionOfClass(AggregateExpression.class)) { msg.append("cannot contain aggregate expressions."); return false; } else if (hasAnySubexpressionOfClass(AbstractSubqueryExpression.class)) { // There may not be any of these in HSQL1.9.3b. However, in // HSQL2.3.2 subqueries are stored as expressions. So, we may // find some here. We will keep it here for the moment. if (isMV) { msg.append("cannot contain subquery sources."); } else { msg.append("cannot contain subqueries."); } return false; } else if (hasUserDefinedFunctionExpression()) { msg.append("cannot contain calls to user defined functions."); return false; } else { return true; } }
[ "public", "boolean", "isValidExprForIndexesAndMVs", "(", "StringBuffer", "msg", ",", "boolean", "isMV", ")", "{", "if", "(", "containsFunctionById", "(", "FunctionSQL", ".", "voltGetCurrentTimestampId", "(", ")", ")", ")", "{", "msg", ".", "append", "(", "\"cann...
Return true if the given expression usable as part of an index or MV's group by and where clause expression. If false, put the tail of an error message in the string buffer. The string buffer will be initialized with the name of the index. @param expr The expression to check @param msg The StringBuffer to pack with the error message tail. @return true iff the expression can be part of an index.
[ "Return", "true", "if", "the", "given", "expression", "usable", "as", "part", "of", "an", "index", "or", "MV", "s", "group", "by", "and", "where", "clause", "expression", ".", "If", "false", "put", "the", "tail", "of", "an", "error", "message", "in", "...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1301-L1324
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.validateExprsForIndexesAndMVs
public static boolean validateExprsForIndexesAndMVs(List<AbstractExpression> checkList, StringBuffer msg, boolean isMV) { for (AbstractExpression expr : checkList) { if (!expr.isValidExprForIndexesAndMVs(msg, isMV)) { return false; } } return true; }
java
public static boolean validateExprsForIndexesAndMVs(List<AbstractExpression> checkList, StringBuffer msg, boolean isMV) { for (AbstractExpression expr : checkList) { if (!expr.isValidExprForIndexesAndMVs(msg, isMV)) { return false; } } return true; }
[ "public", "static", "boolean", "validateExprsForIndexesAndMVs", "(", "List", "<", "AbstractExpression", ">", "checkList", ",", "StringBuffer", "msg", ",", "boolean", "isMV", ")", "{", "for", "(", "AbstractExpression", "expr", ":", "checkList", ")", "{", "if", "(...
Return true if the all of the expressions in the list can be part of an index expression or in group by and where clause of MV. As with validateExprForIndexesAndMVs for individual expression, the StringBuffer parameter, msg, contains the name of the index. Error messages should be appended to it. @param checkList @param msg @return
[ "Return", "true", "if", "the", "all", "of", "the", "expressions", "in", "the", "list", "can", "be", "part", "of", "an", "index", "expression", "or", "in", "group", "by", "and", "where", "clause", "of", "MV", ".", "As", "with", "validateExprForIndexesAndMVs...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1390-L1397
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.containsFunctionById
private boolean containsFunctionById(int functionId) { if (this instanceof AbstractValueExpression) { return false; } List<AbstractExpression> functionsList = findAllFunctionSubexpressions(); for (AbstractExpression funcExpr: functionsList) { assert(funcExpr instanceof FunctionExpression); if (((FunctionExpression)funcExpr).hasFunctionId(functionId)) { return true; } } return false; }
java
private boolean containsFunctionById(int functionId) { if (this instanceof AbstractValueExpression) { return false; } List<AbstractExpression> functionsList = findAllFunctionSubexpressions(); for (AbstractExpression funcExpr: functionsList) { assert(funcExpr instanceof FunctionExpression); if (((FunctionExpression)funcExpr).hasFunctionId(functionId)) { return true; } } return false; }
[ "private", "boolean", "containsFunctionById", "(", "int", "functionId", ")", "{", "if", "(", "this", "instanceof", "AbstractValueExpression", ")", "{", "return", "false", ";", "}", "List", "<", "AbstractExpression", ">", "functionsList", "=", "findAllFunctionSubexpr...
This function will recursively find any function expression with ID functionId. If found, return true. Otherwise, return false. @param expr @param functionId @return
[ "This", "function", "will", "recursively", "find", "any", "function", "expression", "with", "ID", "functionId", ".", "If", "found", "return", "true", ".", "Otherwise", "return", "false", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1407-L1421
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.isValueTypeIndexable
public boolean isValueTypeIndexable(StringBuffer msg) { if (!m_valueType.isIndexable()) { msg.append("expression of type " + m_valueType.getName()); return false; } return true; }
java
public boolean isValueTypeIndexable(StringBuffer msg) { if (!m_valueType.isIndexable()) { msg.append("expression of type " + m_valueType.getName()); return false; } return true; }
[ "public", "boolean", "isValueTypeIndexable", "(", "StringBuffer", "msg", ")", "{", "if", "(", "!", "m_valueType", ".", "isIndexable", "(", ")", ")", "{", "msg", ".", "append", "(", "\"expression of type \"", "+", "m_valueType", ".", "getName", "(", ")", ")",...
Returns true iff the expression is indexable. If the expression is not indexable, expression information gets populated in the msg string buffer passed in. @param msg @return
[ "Returns", "true", "iff", "the", "expression", "is", "indexable", ".", "If", "the", "expression", "is", "not", "indexable", "expression", "information", "gets", "populated", "in", "the", "msg", "string", "buffer", "passed", "in", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1435-L1441
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.isValueTypeUniqueIndexable
public boolean isValueTypeUniqueIndexable(StringBuffer msg) { // This call to isValueTypeIndexable is needed because // all comparison, all conjunction, and some operator expressions // need to refine it to compensate for their false claims that // their value types (actually non-indexable boolean) is BIGINT. // that their value type is actually boolean. // If they were fixed, isValueTypeIndexable and // isValueTypeUniqueIndexable could be replaced by VoltType functions. if (!isValueTypeIndexable(msg)) { return false; } if (!m_valueType.isUniqueIndexable()) { msg.append("expression of type " + m_valueType.getName()); return false; } return true; }
java
public boolean isValueTypeUniqueIndexable(StringBuffer msg) { // This call to isValueTypeIndexable is needed because // all comparison, all conjunction, and some operator expressions // need to refine it to compensate for their false claims that // their value types (actually non-indexable boolean) is BIGINT. // that their value type is actually boolean. // If they were fixed, isValueTypeIndexable and // isValueTypeUniqueIndexable could be replaced by VoltType functions. if (!isValueTypeIndexable(msg)) { return false; } if (!m_valueType.isUniqueIndexable()) { msg.append("expression of type " + m_valueType.getName()); return false; } return true; }
[ "public", "boolean", "isValueTypeUniqueIndexable", "(", "StringBuffer", "msg", ")", "{", "// This call to isValueTypeIndexable is needed because", "// all comparison, all conjunction, and some operator expressions", "// need to refine it to compensate for their false claims that", "// their va...
Returns true iff the expression is indexable in a unique index. If the expression is not indexable, expression information gets populated in the msg string buffer passed in. @param msg @return
[ "Returns", "true", "iff", "the", "expression", "is", "indexable", "in", "a", "unique", "index", ".", "If", "the", "expression", "is", "not", "indexable", "expression", "information", "gets", "populated", "in", "the", "msg", "string", "buffer", "passed", "in", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1450-L1466
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.findUnsafeOperatorsForDDL
public void findUnsafeOperatorsForDDL(UnsafeOperatorsForDDL ops) { if ( ! m_type.isSafeForDDL()) { ops.add(m_type.symbol()); } if (m_left != null) { m_left.findUnsafeOperatorsForDDL(ops); } if (m_right != null) { m_right.findUnsafeOperatorsForDDL(ops); } if (m_args != null) { for (AbstractExpression arg : m_args) { arg.findUnsafeOperatorsForDDL(ops); } } }
java
public void findUnsafeOperatorsForDDL(UnsafeOperatorsForDDL ops) { if ( ! m_type.isSafeForDDL()) { ops.add(m_type.symbol()); } if (m_left != null) { m_left.findUnsafeOperatorsForDDL(ops); } if (m_right != null) { m_right.findUnsafeOperatorsForDDL(ops); } if (m_args != null) { for (AbstractExpression arg : m_args) { arg.findUnsafeOperatorsForDDL(ops); } } }
[ "public", "void", "findUnsafeOperatorsForDDL", "(", "UnsafeOperatorsForDDL", "ops", ")", "{", "if", "(", "!", "m_type", ".", "isSafeForDDL", "(", ")", ")", "{", "ops", ".", "add", "(", "m_type", ".", "symbol", "(", ")", ")", ";", "}", "if", "(", "m_lef...
Returns true iff this expression is allowable when creating materialized views on nonempty tables. We have marked all the ExpressionType enumerals and all the function id integers which are safe. These are marked statically. So we just recurse through the tree, looking at operation types and function types until we find something we don't like. If we get all the way through the search we are happy, and return true.
[ "Returns", "true", "iff", "this", "expression", "is", "allowable", "when", "creating", "materialized", "views", "on", "nonempty", "tables", ".", "We", "have", "marked", "all", "the", "ExpressionType", "enumerals", "and", "all", "the", "function", "id", "integers...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1501-L1516
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/AbstractExpression.java
AbstractExpression.getFirstArgument
public AbstractExpression getFirstArgument() { if (m_left != null) { assert(m_args == null); return m_left; } if (m_args != null && m_args.size() > 0) { assert(m_left == null && m_right == null); return m_args.get(0); } return null; }
java
public AbstractExpression getFirstArgument() { if (m_left != null) { assert(m_args == null); return m_left; } if (m_args != null && m_args.size() > 0) { assert(m_left == null && m_right == null); return m_args.get(0); } return null; }
[ "public", "AbstractExpression", "getFirstArgument", "(", ")", "{", "if", "(", "m_left", "!=", "null", ")", "{", "assert", "(", "m_args", "==", "null", ")", ";", "return", "m_left", ";", "}", "if", "(", "m_args", "!=", "null", "&&", "m_args", ".", "size...
Ferret out the first argument. This can be m_left or else the first element of m_args.
[ "Ferret", "out", "the", "first", "argument", ".", "This", "can", "be", "m_left", "or", "else", "the", "first", "element", "of", "m_args", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1535-L1545
train
VoltDB/voltdb
src/frontend/org/voltdb/client/ConnectionUtil.java
ConnectionUtil.getHashedPassword
public static byte[] getHashedPassword(ClientAuthScheme scheme, String password) { if (password == null) { return null; } MessageDigest md = null; try { md = MessageDigest.getInstance(ClientAuthScheme.getDigestScheme(scheme)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); System.exit(-1); } byte hashedPassword[] = null; hashedPassword = md.digest(password.getBytes(Constants.UTF8ENCODING)); return hashedPassword; }
java
public static byte[] getHashedPassword(ClientAuthScheme scheme, String password) { if (password == null) { return null; } MessageDigest md = null; try { md = MessageDigest.getInstance(ClientAuthScheme.getDigestScheme(scheme)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); System.exit(-1); } byte hashedPassword[] = null; hashedPassword = md.digest(password.getBytes(Constants.UTF8ENCODING)); return hashedPassword; }
[ "public", "static", "byte", "[", "]", "getHashedPassword", "(", "ClientAuthScheme", "scheme", ",", "String", "password", ")", "{", "if", "(", "password", "==", "null", ")", "{", "return", "null", ";", "}", "MessageDigest", "md", "=", "null", ";", "try", ...
Get a hashed password using SHA-1 in a consistent way. @param scheme hashing scheme for password. @param password The password to encode. @return The bytes of the hashed password.
[ "Get", "a", "hashed", "password", "using", "SHA", "-", "1", "in", "a", "consistent", "way", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/ConnectionUtil.java#L223-L238
train
VoltDB/voltdb
src/frontend/org/voltdb/client/ConnectionUtil.java
ConnectionUtil.getAuthenticatedConnection
public static Object[] getAuthenticatedConnection(String host, String username, byte[] hashedPassword, int port, final Subject subject, ClientAuthScheme scheme, long timeoutMillis) throws IOException { String service = subject == null ? "database" : Constants.KERBEROS; return getAuthenticatedConnection(service, host, username, hashedPassword, port, subject, scheme, null, timeoutMillis); }
java
public static Object[] getAuthenticatedConnection(String host, String username, byte[] hashedPassword, int port, final Subject subject, ClientAuthScheme scheme, long timeoutMillis) throws IOException { String service = subject == null ? "database" : Constants.KERBEROS; return getAuthenticatedConnection(service, host, username, hashedPassword, port, subject, scheme, null, timeoutMillis); }
[ "public", "static", "Object", "[", "]", "getAuthenticatedConnection", "(", "String", "host", ",", "String", "username", ",", "byte", "[", "]", "hashedPassword", ",", "int", "port", ",", "final", "Subject", "subject", ",", "ClientAuthScheme", "scheme", ",", "lo...
Create a connection to a Volt server and authenticate the connection. @param host @param username @param hashedPassword @param port @param subject @throws IOException @returns An array of objects. The first is an authenticated socket channel, the second. is an array of 4 longs - Integer hostId, Long connectionId, Long timestamp (part of instanceId), Int leaderAddress (part of instanceId). The last object is the build string
[ "Create", "a", "connection", "to", "a", "Volt", "server", "and", "authenticate", "the", "connection", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/ConnectionUtil.java#L253-L259
train
VoltDB/voltdb
src/frontend/org/voltdb/SnapshotInitiationInfo.java
SnapshotInitiationInfo.getJSONObjectForZK
public JSONObject getJSONObjectForZK() throws JSONException { final JSONObject jsObj = new JSONObject(); jsObj.put(SnapshotUtil.JSON_PATH, m_path); jsObj.put(SnapshotUtil.JSON_PATH_TYPE, m_stype.toString()); jsObj.put(SnapshotUtil.JSON_NONCE, m_nonce); jsObj.put(SnapshotUtil.JSON_BLOCK, m_blocking); jsObj.put(SnapshotUtil.JSON_FORMAT, m_format.toString()); jsObj.putOpt(SnapshotUtil.JSON_DATA, m_data); jsObj.putOpt(SnapshotUtil.JSON_TERMINUS, m_terminus); return jsObj; }
java
public JSONObject getJSONObjectForZK() throws JSONException { final JSONObject jsObj = new JSONObject(); jsObj.put(SnapshotUtil.JSON_PATH, m_path); jsObj.put(SnapshotUtil.JSON_PATH_TYPE, m_stype.toString()); jsObj.put(SnapshotUtil.JSON_NONCE, m_nonce); jsObj.put(SnapshotUtil.JSON_BLOCK, m_blocking); jsObj.put(SnapshotUtil.JSON_FORMAT, m_format.toString()); jsObj.putOpt(SnapshotUtil.JSON_DATA, m_data); jsObj.putOpt(SnapshotUtil.JSON_TERMINUS, m_terminus); return jsObj; }
[ "public", "JSONObject", "getJSONObjectForZK", "(", ")", "throws", "JSONException", "{", "final", "JSONObject", "jsObj", "=", "new", "JSONObject", "(", ")", ";", "jsObj", ".", "put", "(", "SnapshotUtil", ".", "JSON_PATH", ",", "m_path", ")", ";", "jsObj", "."...
When we write to ZK to request the snapshot, generate the JSON which will be written to the node's data.
[ "When", "we", "write", "to", "ZK", "to", "request", "the", "snapshot", "generate", "the", "JSON", "which", "will", "be", "written", "to", "the", "node", "s", "data", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/SnapshotInitiationInfo.java#L293-L304
train
VoltDB/voltdb
src/frontend/org/voltdb/utils/CatalogSizing.java
CatalogSizing.getCatalogSizes
public static DatabaseSizes getCatalogSizes(Database dbCatalog, boolean isXDCR) { DatabaseSizes dbSizes = new DatabaseSizes(); for (Table table: dbCatalog.getTables()) { dbSizes.addTable(getTableSize(table, isXDCR)); } return dbSizes; }
java
public static DatabaseSizes getCatalogSizes(Database dbCatalog, boolean isXDCR) { DatabaseSizes dbSizes = new DatabaseSizes(); for (Table table: dbCatalog.getTables()) { dbSizes.addTable(getTableSize(table, isXDCR)); } return dbSizes; }
[ "public", "static", "DatabaseSizes", "getCatalogSizes", "(", "Database", "dbCatalog", ",", "boolean", "isXDCR", ")", "{", "DatabaseSizes", "dbSizes", "=", "new", "DatabaseSizes", "(", ")", ";", "for", "(", "Table", "table", ":", "dbCatalog", ".", "getTables", ...
Produce a sizing of all significant database objects. @param dbCatalog database catalog @param isXDCR Is XDCR enabled @return database size result object tree
[ "Produce", "a", "sizing", "of", "all", "significant", "database", "objects", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/CatalogSizing.java#L394-L400
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/lib/tar/TarGenerator.java
TarGenerator.main
static public void main(String[] sa) throws IOException, TarMalformatException { if (sa.length < 1) { System.out.println(RB.singleton.getString(RB.TARGENERATOR_SYNTAX, DbBackup.class.getName())); System.exit(0); } TarGenerator generator = new TarGenerator(new File(sa[0]), true, null); if (sa.length == 1) { generator.queueEntry("stdin", System.in, 10240); } else { for (int i = 1; i < sa.length; i++) { generator.queueEntry(new File(sa[i])); } } generator.write(); }
java
static public void main(String[] sa) throws IOException, TarMalformatException { if (sa.length < 1) { System.out.println(RB.singleton.getString(RB.TARGENERATOR_SYNTAX, DbBackup.class.getName())); System.exit(0); } TarGenerator generator = new TarGenerator(new File(sa[0]), true, null); if (sa.length == 1) { generator.queueEntry("stdin", System.in, 10240); } else { for (int i = 1; i < sa.length; i++) { generator.queueEntry(new File(sa[i])); } } generator.write(); }
[ "static", "public", "void", "main", "(", "String", "[", "]", "sa", ")", "throws", "IOException", ",", "TarMalformatException", "{", "if", "(", "sa", ".", "length", "<", "1", ")", "{", "System", ".", "out", ".", "println", "(", "RB", ".", "singleton", ...
Creates specified tar file to contain specified files, or stdin, using default blocks-per-record and replacing tar file if it already exists.
[ "Creates", "specified", "tar", "file", "to", "contain", "specified", "files", "or", "stdin", "using", "default", "blocks", "-", "per", "-", "record", "and", "replacing", "tar", "file", "if", "it", "already", "exists", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/tar/TarGenerator.java#L60-L80
train
VoltDB/voltdb
src/frontend/org/voltdb/client/ClientUtils.java
ClientUtils.fileToBytes
public static byte[] fileToBytes(File path) throws IOException { FileInputStream fin = new FileInputStream(path); byte[] buffer = new byte[(int) fin.getChannel().size()]; try { if (fin.read(buffer) == -1) { throw new IOException("File " + path.getAbsolutePath() + " is empty"); } } finally { fin.close(); } return buffer; }
java
public static byte[] fileToBytes(File path) throws IOException { FileInputStream fin = new FileInputStream(path); byte[] buffer = new byte[(int) fin.getChannel().size()]; try { if (fin.read(buffer) == -1) { throw new IOException("File " + path.getAbsolutePath() + " is empty"); } } finally { fin.close(); } return buffer; }
[ "public", "static", "byte", "[", "]", "fileToBytes", "(", "File", "path", ")", "throws", "IOException", "{", "FileInputStream", "fin", "=", "new", "FileInputStream", "(", "path", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "(", "int", ...
Serialize a file into bytes. Used to serialize catalog and deployment file for UpdateApplicationCatalog on the client. @param path @return a byte array of the file @throws IOException If there are errors reading the file
[ "Serialize", "a", "file", "into", "bytes", ".", "Used", "to", "serialize", "catalog", "and", "deployment", "file", "for", "UpdateApplicationCatalog", "on", "the", "client", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/client/ClientUtils.java#L65-L76
train
VoltDB/voltdb
src/frontend/org/voltdb/sysprocs/NibbleDeleteMP.java
NibbleDeleteMP.run
public VoltTable run(SystemProcedureExecutionContext ctx, String tableName, String columnName, String compStr, VoltTable parameter, long chunksize) { return nibbleDeleteCommon(ctx, tableName, columnName, compStr, parameter, chunksize, true); }
java
public VoltTable run(SystemProcedureExecutionContext ctx, String tableName, String columnName, String compStr, VoltTable parameter, long chunksize) { return nibbleDeleteCommon(ctx, tableName, columnName, compStr, parameter, chunksize, true); }
[ "public", "VoltTable", "run", "(", "SystemProcedureExecutionContext", "ctx", ",", "String", "tableName", ",", "String", "columnName", ",", "String", "compStr", ",", "VoltTable", "parameter", ",", "long", "chunksize", ")", "{", "return", "nibbleDeleteCommon", "(", ...
Nibble delete procedure for replicated tables @param ctx Internal API provided to all system procedures @param tableName Name of persistent partitioned table @param columnName A column in the given table that its value can be used to provide order for delete action. (Unique or non-unique) index is expected on the column, if not a warning message will be printed. @param compStr ">", "<", ">=", "<=", "==" @param parameter value to compare @param chunksize maximum number of rows allow to be deleted @return how many rows are deleted and how many rows left to be deleted (if any)
[ "Nibble", "delete", "procedure", "for", "replicated", "tables" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/NibbleDeleteMP.java#L38-L49
train
VoltDB/voltdb
src/frontend/org/voltdb/utils/CSVTableSaveFile.java
CSVTableSaveFile.read
public byte[] read() throws IOException { if (m_exception.get() != null) { throw m_exception.get(); } byte bytes[] = null; if (m_activeConverters.get() == 0) { bytes = m_available.poll(); } else { try { bytes = m_available.take(); } catch (InterruptedException e) { throw new IOException(e); } } if (bytes != null) { m_availableBytes.addAndGet(-1 * bytes.length); } return bytes; }
java
public byte[] read() throws IOException { if (m_exception.get() != null) { throw m_exception.get(); } byte bytes[] = null; if (m_activeConverters.get() == 0) { bytes = m_available.poll(); } else { try { bytes = m_available.take(); } catch (InterruptedException e) { throw new IOException(e); } } if (bytes != null) { m_availableBytes.addAndGet(-1 * bytes.length); } return bytes; }
[ "public", "byte", "[", "]", "read", "(", ")", "throws", "IOException", "{", "if", "(", "m_exception", ".", "get", "(", ")", "!=", "null", ")", "{", "throw", "m_exception", ".", "get", "(", ")", ";", "}", "byte", "bytes", "[", "]", "=", "null", ";...
Returns a more CSV data in UTF-8 format. Returns null when there is no more data. May block. @return null if there is no more data or a byte array contain some number of complete CSV lines @throws IOException
[ "Returns", "a", "more", "CSV", "data", "in", "UTF", "-", "8", "format", ".", "Returns", "null", "when", "there", "is", "no", "more", "data", ".", "May", "block", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/CSVTableSaveFile.java#L68-L87
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.compileFromDDL
public boolean compileFromDDL(final String jarOutputPath, final String... ddlFilePaths) { if (ddlFilePaths.length == 0) { compilerLog.error("At least one DDL file is required."); return false; } List<VoltCompilerReader> ddlReaderList; try { ddlReaderList = DDLPathsToReaderList(ddlFilePaths); } catch (VoltCompilerException e) { compilerLog.error("Unable to open DDL file.", e); return false; } return compileInternalToFile(jarOutputPath, null, null, ddlReaderList, null); }
java
public boolean compileFromDDL(final String jarOutputPath, final String... ddlFilePaths) { if (ddlFilePaths.length == 0) { compilerLog.error("At least one DDL file is required."); return false; } List<VoltCompilerReader> ddlReaderList; try { ddlReaderList = DDLPathsToReaderList(ddlFilePaths); } catch (VoltCompilerException e) { compilerLog.error("Unable to open DDL file.", e); return false; } return compileInternalToFile(jarOutputPath, null, null, ddlReaderList, null); }
[ "public", "boolean", "compileFromDDL", "(", "final", "String", "jarOutputPath", ",", "final", "String", "...", "ddlFilePaths", ")", "{", "if", "(", "ddlFilePaths", ".", "length", "==", "0", ")", "{", "compilerLog", ".", "error", "(", "\"At least one DDL file is ...
Compile from a set of DDL files. @param jarOutputPath The location to put the finished JAR to. @param ddlFilePaths The array of DDL files to compile (at least one is required). @return true if successful @throws VoltCompilerException
[ "Compile", "from", "a", "set", "of", "DDL", "files", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L514-L528
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.compileDDLString
public boolean compileDDLString(String ddl, String jarPath) { final File schemaFile = VoltProjectBuilder.writeStringToTempFile(ddl); schemaFile.deleteOnExit(); final String schemaPath = schemaFile.getPath(); return compileFromDDL(jarPath, schemaPath); }
java
public boolean compileDDLString(String ddl, String jarPath) { final File schemaFile = VoltProjectBuilder.writeStringToTempFile(ddl); schemaFile.deleteOnExit(); final String schemaPath = schemaFile.getPath(); return compileFromDDL(jarPath, schemaPath); }
[ "public", "boolean", "compileDDLString", "(", "String", "ddl", ",", "String", "jarPath", ")", "{", "final", "File", "schemaFile", "=", "VoltProjectBuilder", ".", "writeStringToTempFile", "(", "ddl", ")", ";", "schemaFile", ".", "deleteOnExit", "(", ")", ";", "...
Compile from DDL in a single string @param ddl The inline DDL text @param jarPath The location to put the finished JAR to. @return true if successful @throws VoltCompilerException
[ "Compile", "from", "DDL", "in", "a", "single", "string" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L599-L605
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.compileEmptyCatalog
public boolean compileEmptyCatalog(final String jarOutputPath) { // Use a special DDL reader to provide the contents. List<VoltCompilerReader> ddlReaderList = new ArrayList<>(1); ddlReaderList.add(new VoltCompilerStringReader("ddl.sql", m_emptyDDLComment)); // Seed it with the DDL so that a version upgrade hack in compileInternalToFile() // doesn't try to get the DDL file from the path. InMemoryJarfile jarFile = new InMemoryJarfile(); try { ddlReaderList.get(0).putInJar(jarFile, "ddl.sql"); } catch (IOException e) { compilerLog.error("Failed to add DDL file to empty in-memory jar."); return false; } return compileInternalToFile(jarOutputPath, null, null, ddlReaderList, jarFile); }
java
public boolean compileEmptyCatalog(final String jarOutputPath) { // Use a special DDL reader to provide the contents. List<VoltCompilerReader> ddlReaderList = new ArrayList<>(1); ddlReaderList.add(new VoltCompilerStringReader("ddl.sql", m_emptyDDLComment)); // Seed it with the DDL so that a version upgrade hack in compileInternalToFile() // doesn't try to get the DDL file from the path. InMemoryJarfile jarFile = new InMemoryJarfile(); try { ddlReaderList.get(0).putInJar(jarFile, "ddl.sql"); } catch (IOException e) { compilerLog.error("Failed to add DDL file to empty in-memory jar."); return false; } return compileInternalToFile(jarOutputPath, null, null, ddlReaderList, jarFile); }
[ "public", "boolean", "compileEmptyCatalog", "(", "final", "String", "jarOutputPath", ")", "{", "// Use a special DDL reader to provide the contents.", "List", "<", "VoltCompilerReader", ">", "ddlReaderList", "=", "new", "ArrayList", "<>", "(", "1", ")", ";", "ddlReaderL...
Compile empty catalog jar @param jarOutputPath output jar path @return true if successful
[ "Compile", "empty", "catalog", "jar" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L612-L627
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.debugVerifyCatalog
private void debugVerifyCatalog(InMemoryJarfile origJarFile, Catalog origCatalog) { final VoltCompiler autoGenCompiler = new VoltCompiler(m_isXDCR); // Make the new compiler use the original jarfile's classloader so it can // pull in the class files for procedures and imports autoGenCompiler.m_classLoader = origJarFile.getLoader(); List<VoltCompilerReader> autogenReaderList = new ArrayList<>(1); autogenReaderList.add(new VoltCompilerJarFileReader(origJarFile, AUTOGEN_DDL_FILE_NAME)); InMemoryJarfile autoGenJarOutput = new InMemoryJarfile(); autoGenCompiler.m_currentFilename = AUTOGEN_DDL_FILE_NAME; // This call is purposely replicated in retryFailedCatalogRebuildUnderDebug, // where it provides an opportunity to set a breakpoint on a do-over when this // mainline call produces a flawed catalog that fails the catalog diff. // Keep the two calls in synch to allow debugging under the same exact conditions. Catalog autoGenCatalog = autoGenCompiler.compileCatalogInternal(null, null, autogenReaderList, autoGenJarOutput); if (autoGenCatalog == null) { Log.info("Did not verify catalog because it could not be compiled."); return; } FilteredCatalogDiffEngine diffEng = new FilteredCatalogDiffEngine(origCatalog, autoGenCatalog, false); String diffCmds = diffEng.commands(); if (diffCmds != null && !diffCmds.equals("")) { // This retry is disabled by default to avoid confusing the unwary developer // with a "pointless" replay of an apparently flawed catalog rebuild. // Enable it via this flag to provide a chance to set an early breakpoint // that is only triggered in hopeless cases. if (RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG) { autoGenCatalog = replayFailedCatalogRebuildUnderDebug( autoGenCompiler, autogenReaderList, autoGenJarOutput); } // Re-run a failed diff more verbosely as a pre-crash test diagnostic. diffEng = new FilteredCatalogDiffEngine(origCatalog, autoGenCatalog, true); diffCmds = diffEng.commands(); String crashAdvice = "Catalog Verification from Generated DDL failed! " + "VoltDB dev: Consider" + (RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG ? "" : " setting VoltCompiler.RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG = true and") + " setting a breakpoint in VoltCompiler.replayFailedCatalogRebuildUnderDebug" + " to debug a replay of the faulty catalog rebuild roundtrip. "; VoltDB.crashLocalVoltDB(crashAdvice + "The offending diffcmds were: " + diffCmds); } else { Log.info("Catalog verification completed successfuly."); } }
java
private void debugVerifyCatalog(InMemoryJarfile origJarFile, Catalog origCatalog) { final VoltCompiler autoGenCompiler = new VoltCompiler(m_isXDCR); // Make the new compiler use the original jarfile's classloader so it can // pull in the class files for procedures and imports autoGenCompiler.m_classLoader = origJarFile.getLoader(); List<VoltCompilerReader> autogenReaderList = new ArrayList<>(1); autogenReaderList.add(new VoltCompilerJarFileReader(origJarFile, AUTOGEN_DDL_FILE_NAME)); InMemoryJarfile autoGenJarOutput = new InMemoryJarfile(); autoGenCompiler.m_currentFilename = AUTOGEN_DDL_FILE_NAME; // This call is purposely replicated in retryFailedCatalogRebuildUnderDebug, // where it provides an opportunity to set a breakpoint on a do-over when this // mainline call produces a flawed catalog that fails the catalog diff. // Keep the two calls in synch to allow debugging under the same exact conditions. Catalog autoGenCatalog = autoGenCompiler.compileCatalogInternal(null, null, autogenReaderList, autoGenJarOutput); if (autoGenCatalog == null) { Log.info("Did not verify catalog because it could not be compiled."); return; } FilteredCatalogDiffEngine diffEng = new FilteredCatalogDiffEngine(origCatalog, autoGenCatalog, false); String diffCmds = diffEng.commands(); if (diffCmds != null && !diffCmds.equals("")) { // This retry is disabled by default to avoid confusing the unwary developer // with a "pointless" replay of an apparently flawed catalog rebuild. // Enable it via this flag to provide a chance to set an early breakpoint // that is only triggered in hopeless cases. if (RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG) { autoGenCatalog = replayFailedCatalogRebuildUnderDebug( autoGenCompiler, autogenReaderList, autoGenJarOutput); } // Re-run a failed diff more verbosely as a pre-crash test diagnostic. diffEng = new FilteredCatalogDiffEngine(origCatalog, autoGenCatalog, true); diffCmds = diffEng.commands(); String crashAdvice = "Catalog Verification from Generated DDL failed! " + "VoltDB dev: Consider" + (RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG ? "" : " setting VoltCompiler.RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG = true and") + " setting a breakpoint in VoltCompiler.replayFailedCatalogRebuildUnderDebug" + " to debug a replay of the faulty catalog rebuild roundtrip. "; VoltDB.crashLocalVoltDB(crashAdvice + "The offending diffcmds were: " + diffCmds); } else { Log.info("Catalog verification completed successfuly."); } }
[ "private", "void", "debugVerifyCatalog", "(", "InMemoryJarfile", "origJarFile", ",", "Catalog", "origCatalog", ")", "{", "final", "VoltCompiler", "autoGenCompiler", "=", "new", "VoltCompiler", "(", "m_isXDCR", ")", ";", "// Make the new compiler use the original jarfile's c...
Internal method that takes the generated DDL from the catalog and builds a new catalog. The generated catalog is diffed with the original catalog to verify compilation and catalog generation consistency.
[ "Internal", "method", "that", "takes", "the", "generated", "DDL", "from", "the", "catalog", "and", "builds", "a", "new", "catalog", ".", "The", "generated", "catalog", "is", "diffed", "with", "the", "original", "catalog", "to", "verify", "compilation", "and", ...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L647-L695
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.replayFailedCatalogRebuildUnderDebug
private Catalog replayFailedCatalogRebuildUnderDebug( VoltCompiler autoGenCompiler, List<VoltCompilerReader> autogenReaderList, InMemoryJarfile autoGenJarOutput) { // Be sure to set RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG = true to enable // this last ditch retry before crashing. // BREAKPOINT HERE! // Then step IN to debug the failed rebuild -- or, just as likely, the canonical ddl. // Or step OVER to debug just the catalog diff process, retried with verbose output -- // maybe it's just being too sensitive to immaterial changes? Catalog autoGenCatalog = autoGenCompiler.compileCatalogInternal(null, null, autogenReaderList, autoGenJarOutput); return autoGenCatalog; }
java
private Catalog replayFailedCatalogRebuildUnderDebug( VoltCompiler autoGenCompiler, List<VoltCompilerReader> autogenReaderList, InMemoryJarfile autoGenJarOutput) { // Be sure to set RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG = true to enable // this last ditch retry before crashing. // BREAKPOINT HERE! // Then step IN to debug the failed rebuild -- or, just as likely, the canonical ddl. // Or step OVER to debug just the catalog diff process, retried with verbose output -- // maybe it's just being too sensitive to immaterial changes? Catalog autoGenCatalog = autoGenCompiler.compileCatalogInternal(null, null, autogenReaderList, autoGenJarOutput); return autoGenCatalog; }
[ "private", "Catalog", "replayFailedCatalogRebuildUnderDebug", "(", "VoltCompiler", "autoGenCompiler", ",", "List", "<", "VoltCompilerReader", ">", "autogenReaderList", ",", "InMemoryJarfile", "autoGenJarOutput", ")", "{", "// Be sure to set RETRY_FAILED_CATALOG_REBUILD_UNDER_DEBUG ...
Take two steps back to retry and potentially debug a catalog rebuild that generated an unintended change. This code is PURPOSELY redundant with the mainline call in debugVerifyCatalog above. Keep the two calls in synch and only redirect through this function in the post-mortem replay after the other call created a flawed catalog.
[ "Take", "two", "steps", "back", "to", "retry", "and", "potentially", "debug", "a", "catalog", "rebuild", "that", "generated", "an", "unintended", "change", ".", "This", "code", "is", "PURPOSELY", "redundant", "with", "the", "mainline", "call", "in", "debugVeri...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L703-L717
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.getExplainPlans
HashMap<String, byte[]> getExplainPlans(Catalog catalog) { HashMap<String, byte[]> retval = new HashMap<>(); Database db = getCatalogDatabase(m_catalog); assert(db != null); for (Procedure proc : db.getProcedures()) { for (Statement stmt : proc.getStatements()) { String s = "SQL: " + stmt.getSqltext() + "\n"; s += "COST: " + Integer.toString(stmt.getCost()) + "\n"; s += "PLAN:\n\n"; s += Encoder.hexDecodeToString(stmt.getExplainplan()) + "\n"; byte[] b = s.getBytes(Constants.UTF8ENCODING); retval.put(proc.getTypeName() + "_" + stmt.getTypeName() + ".txt", b); } } return retval; }
java
HashMap<String, byte[]> getExplainPlans(Catalog catalog) { HashMap<String, byte[]> retval = new HashMap<>(); Database db = getCatalogDatabase(m_catalog); assert(db != null); for (Procedure proc : db.getProcedures()) { for (Statement stmt : proc.getStatements()) { String s = "SQL: " + stmt.getSqltext() + "\n"; s += "COST: " + Integer.toString(stmt.getCost()) + "\n"; s += "PLAN:\n\n"; s += Encoder.hexDecodeToString(stmt.getExplainplan()) + "\n"; byte[] b = s.getBytes(Constants.UTF8ENCODING); retval.put(proc.getTypeName() + "_" + stmt.getTypeName() + ".txt", b); } } return retval; }
[ "HashMap", "<", "String", ",", "byte", "[", "]", ">", "getExplainPlans", "(", "Catalog", "catalog", ")", "{", "HashMap", "<", "String", ",", "byte", "[", "]", ">", "retval", "=", "new", "HashMap", "<>", "(", ")", ";", "Database", "db", "=", "getCatal...
Get textual explain plan info for each plan from the catalog to be shoved into the catalog jarfile.
[ "Get", "textual", "explain", "plan", "info", "for", "each", "plan", "from", "the", "catalog", "to", "be", "shoved", "into", "the", "catalog", "jarfile", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L872-L887
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.compileCatalogInternal
private Catalog compileCatalogInternal( final VoltCompilerReader cannonicalDDLIfAny, final Catalog previousCatalogIfAny, final List<VoltCompilerReader> ddlReaderList, final InMemoryJarfile jarOutput) { m_catalog = new Catalog(); // Initialize the catalog for one cluster m_catalog.execute("add / clusters cluster"); m_catalog.getClusters().get("cluster").setSecurityenabled(false); // shutdown and make a new hsqldb try { Database previousDBIfAny = null; if (previousCatalogIfAny != null) { previousDBIfAny = previousCatalogIfAny.getClusters().get("cluster").getDatabases().get("database"); } compileDatabaseNode(cannonicalDDLIfAny, previousDBIfAny, ddlReaderList, jarOutput); } catch (final VoltCompilerException e) { return null; } assert(m_catalog != null); // add epoch info to catalog final int epoch = (int)(TransactionIdManager.getEpoch() / 1000); m_catalog.getClusters().get("cluster").setLocalepoch(epoch); return m_catalog; }
java
private Catalog compileCatalogInternal( final VoltCompilerReader cannonicalDDLIfAny, final Catalog previousCatalogIfAny, final List<VoltCompilerReader> ddlReaderList, final InMemoryJarfile jarOutput) { m_catalog = new Catalog(); // Initialize the catalog for one cluster m_catalog.execute("add / clusters cluster"); m_catalog.getClusters().get("cluster").setSecurityenabled(false); // shutdown and make a new hsqldb try { Database previousDBIfAny = null; if (previousCatalogIfAny != null) { previousDBIfAny = previousCatalogIfAny.getClusters().get("cluster").getDatabases().get("database"); } compileDatabaseNode(cannonicalDDLIfAny, previousDBIfAny, ddlReaderList, jarOutput); } catch (final VoltCompilerException e) { return null; } assert(m_catalog != null); // add epoch info to catalog final int epoch = (int)(TransactionIdManager.getEpoch() / 1000); m_catalog.getClusters().get("cluster").setLocalepoch(epoch); return m_catalog; }
[ "private", "Catalog", "compileCatalogInternal", "(", "final", "VoltCompilerReader", "cannonicalDDLIfAny", ",", "final", "Catalog", "previousCatalogIfAny", ",", "final", "List", "<", "VoltCompilerReader", ">", "ddlReaderList", ",", "final", "InMemoryJarfile", "jarOutput", ...
Internal method for compiling the catalog. @param database catalog-related info parsed from a project file @param ddlReaderList Reader objects for ddl files. @param jarOutput The in-memory jar to populate or null if the caller doesn't provide one. @return true if successful
[ "Internal", "method", "for", "compiling", "the", "catalog", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L932-L961
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.addExtraClasses
private void addExtraClasses(final InMemoryJarfile jarOutput) throws VoltCompilerException { List<String> addedClasses = new ArrayList<>(); for (String className : m_addedClasses) { /* * Only add the class if it isn't already in the output jar. * The jar will be pre-populated when performing an automatic * catalog version upgrade. */ if (!jarOutput.containsKey(className)) { try { Class<?> clz = Class.forName(className, true, m_classLoader); if (addClassToJar(jarOutput, clz)) { addedClasses.add(className); } } catch (Exception e) { String msg = "Class %s could not be loaded/found/added to the jar."; msg = String.format(msg, className); throw new VoltCompilerException(msg); } // reset the added classes to the actual added classes } } m_addedClasses = addedClasses.toArray(new String[0]); }
java
private void addExtraClasses(final InMemoryJarfile jarOutput) throws VoltCompilerException { List<String> addedClasses = new ArrayList<>(); for (String className : m_addedClasses) { /* * Only add the class if it isn't already in the output jar. * The jar will be pre-populated when performing an automatic * catalog version upgrade. */ if (!jarOutput.containsKey(className)) { try { Class<?> clz = Class.forName(className, true, m_classLoader); if (addClassToJar(jarOutput, clz)) { addedClasses.add(className); } } catch (Exception e) { String msg = "Class %s could not be loaded/found/added to the jar."; msg = String.format(msg, className); throw new VoltCompilerException(msg); } // reset the added classes to the actual added classes } } m_addedClasses = addedClasses.toArray(new String[0]); }
[ "private", "void", "addExtraClasses", "(", "final", "InMemoryJarfile", "jarOutput", ")", "throws", "VoltCompilerException", "{", "List", "<", "String", ">", "addedClasses", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "className", ":", "...
Once the DDL file is over, take all of the extra classes found and add them to the jar.
[ "Once", "the", "DDL", "file", "is", "over", "take", "all", "of", "the", "extra", "classes", "found", "and", "add", "them", "to", "the", "jar", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L1215-L1243
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.harvestCapturedDetail
public List<String> harvestCapturedDetail() { List<String> harvested = m_capturedDiagnosticDetail; m_capturedDiagnosticDetail = null; return harvested; }
java
public List<String> harvestCapturedDetail() { List<String> harvested = m_capturedDiagnosticDetail; m_capturedDiagnosticDetail = null; return harvested; }
[ "public", "List", "<", "String", ">", "harvestCapturedDetail", "(", ")", "{", "List", "<", "String", ">", "harvested", "=", "m_capturedDiagnosticDetail", ";", "m_capturedDiagnosticDetail", "=", "null", ";", "return", "harvested", ";", "}" ]
Access recent plan output, for diagnostic purposes
[ "Access", "recent", "plan", "output", "for", "diagnostic", "purposes" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L1321-L1325
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.getKeyPrefix
String getKeyPrefix(StatementPartitioning partitioning, DeterminismMode detMode, String joinOrder) { // no caching for inferred yet if (partitioning.isInferred()) { return null; } String joinOrderPrefix = "#"; if (joinOrder != null) { joinOrderPrefix += joinOrder; } boolean partitioned = partitioning.wasSpecifiedAsSingle(); return joinOrderPrefix + String.valueOf(detMode.toChar()) + (partitioned ? "P#" : "R#"); }
java
String getKeyPrefix(StatementPartitioning partitioning, DeterminismMode detMode, String joinOrder) { // no caching for inferred yet if (partitioning.isInferred()) { return null; } String joinOrderPrefix = "#"; if (joinOrder != null) { joinOrderPrefix += joinOrder; } boolean partitioned = partitioning.wasSpecifiedAsSingle(); return joinOrderPrefix + String.valueOf(detMode.toChar()) + (partitioned ? "P#" : "R#"); }
[ "String", "getKeyPrefix", "(", "StatementPartitioning", "partitioning", ",", "DeterminismMode", "detMode", ",", "String", "joinOrder", ")", "{", "// no caching for inferred yet", "if", "(", "partitioning", ".", "isInferred", "(", ")", ")", "{", "return", "null", ";"...
Key prefix includes attributes that make a cached statement usable if they match For example, if the SQL is the same, but the partitioning isn't, then the statements aren't actually interchangeable.
[ "Key", "prefix", "includes", "attributes", "that", "make", "a", "cached", "statement", "usable", "if", "they", "match" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L2266-L2280
train
VoltDB/voltdb
src/frontend/org/voltdb/compiler/VoltCompiler.java
VoltCompiler.getCachedStatement
Statement getCachedStatement(String keyPrefix, String sql) { String key = keyPrefix + sql; Statement candidate = m_previousCatalogStmts.get(key); if (candidate == null) { ++m_stmtCacheMisses; return null; } // check that no underlying tables have been modified since the proc had been compiled String[] tablesTouched = candidate.getTablesread().split(","); for (String tableName : tablesTouched) { if (isDirtyTable(tableName)) { ++m_stmtCacheMisses; return null; } } tablesTouched = candidate.getTablesupdated().split(","); for (String tableName : tablesTouched) { if (isDirtyTable(tableName)) { ++m_stmtCacheMisses; return null; } } ++m_stmtCacheHits; // easy debugging stmt //printStmtCacheStats(); return candidate; }
java
Statement getCachedStatement(String keyPrefix, String sql) { String key = keyPrefix + sql; Statement candidate = m_previousCatalogStmts.get(key); if (candidate == null) { ++m_stmtCacheMisses; return null; } // check that no underlying tables have been modified since the proc had been compiled String[] tablesTouched = candidate.getTablesread().split(","); for (String tableName : tablesTouched) { if (isDirtyTable(tableName)) { ++m_stmtCacheMisses; return null; } } tablesTouched = candidate.getTablesupdated().split(","); for (String tableName : tablesTouched) { if (isDirtyTable(tableName)) { ++m_stmtCacheMisses; return null; } } ++m_stmtCacheHits; // easy debugging stmt //printStmtCacheStats(); return candidate; }
[ "Statement", "getCachedStatement", "(", "String", "keyPrefix", ",", "String", "sql", ")", "{", "String", "key", "=", "keyPrefix", "+", "sql", ";", "Statement", "candidate", "=", "m_previousCatalogStmts", ".", "get", "(", "key", ")", ";", "if", "(", "candidat...
Look for a match from the previous catalog that matches the key + sql
[ "Look", "for", "a", "match", "from", "the", "previous", "catalog", "that", "matches", "the", "key", "+", "sql" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltCompiler.java#L2292-L2321
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/HashRangeExpressionBuilder.java
HashRangeExpressionBuilder.put
public HashRangeExpressionBuilder put(Integer value1, Integer value2) { m_builder.put(value1, value2); return this; }
java
public HashRangeExpressionBuilder put(Integer value1, Integer value2) { m_builder.put(value1, value2); return this; }
[ "public", "HashRangeExpressionBuilder", "put", "(", "Integer", "value1", ",", "Integer", "value2", ")", "{", "m_builder", ".", "put", "(", "value1", ",", "value2", ")", ";", "return", "this", ";", "}" ]
Add a value pair. @param value1 @param value2
[ "Add", "a", "value", "pair", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/HashRangeExpressionBuilder.java#L41-L44
train
VoltDB/voltdb
src/frontend/org/voltdb/expressions/HashRangeExpressionBuilder.java
HashRangeExpressionBuilder.build
public HashRangeExpression build(Integer hashColumnIndex) { Map<Integer, Integer> ranges = m_builder.build(); HashRangeExpression predicate = new HashRangeExpression(); predicate.setRanges(ranges); predicate.setHashColumnIndex(hashColumnIndex); return predicate; }
java
public HashRangeExpression build(Integer hashColumnIndex) { Map<Integer, Integer> ranges = m_builder.build(); HashRangeExpression predicate = new HashRangeExpression(); predicate.setRanges(ranges); predicate.setHashColumnIndex(hashColumnIndex); return predicate; }
[ "public", "HashRangeExpression", "build", "(", "Integer", "hashColumnIndex", ")", "{", "Map", "<", "Integer", ",", "Integer", ">", "ranges", "=", "m_builder", ".", "build", "(", ")", ";", "HashRangeExpression", "predicate", "=", "new", "HashRangeExpression", "("...
Generate a hash range expression. @return hash range expression
[ "Generate", "a", "hash", "range", "expression", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/HashRangeExpressionBuilder.java#L50-L56
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java
RestrictedPriorityQueue.poll
@Override public OrderableTransaction poll() { OrderableTransaction retval = null; updateQueueState(); if (m_state == QueueState.UNBLOCKED) { retval = super.peek(); super.poll(); // not BLOCKED_EMPTY assert(retval != null); } return retval; }
java
@Override public OrderableTransaction poll() { OrderableTransaction retval = null; updateQueueState(); if (m_state == QueueState.UNBLOCKED) { retval = super.peek(); super.poll(); // not BLOCKED_EMPTY assert(retval != null); } return retval; }
[ "@", "Override", "public", "OrderableTransaction", "poll", "(", ")", "{", "OrderableTransaction", "retval", "=", "null", ";", "updateQueueState", "(", ")", ";", "if", "(", "m_state", "==", "QueueState", ".", "UNBLOCKED", ")", "{", "retval", "=", "super", "."...
Only return transaction state objects that are ready to run.
[ "Only", "return", "transaction", "state", "objects", "that", "are", "ready", "to", "run", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java#L93-L104
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java
RestrictedPriorityQueue.add
@Override public boolean add(OrderableTransaction txnState) { if (m_initiatorData.containsKey(txnState.initiatorHSId) == false) { return false; } boolean retval = super.add(txnState); // update the queue state if (retval) updateQueueState(); return retval; }
java
@Override public boolean add(OrderableTransaction txnState) { if (m_initiatorData.containsKey(txnState.initiatorHSId) == false) { return false; } boolean retval = super.add(txnState); // update the queue state if (retval) updateQueueState(); return retval; }
[ "@", "Override", "public", "boolean", "add", "(", "OrderableTransaction", "txnState", ")", "{", "if", "(", "m_initiatorData", ".", "containsKey", "(", "txnState", ".", "initiatorHSId", ")", "==", "false", ")", "{", "return", "false", ";", "}", "boolean", "re...
Drop data for unknown initiators. This is the only valid add interface.
[ "Drop", "data", "for", "unknown", "initiators", ".", "This", "is", "the", "only", "valid", "add", "interface", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java#L124-L133
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java
RestrictedPriorityQueue.noteTransactionRecievedAndReturnLastSeen
public long noteTransactionRecievedAndReturnLastSeen(long initiatorHSId, long txnId, long lastSafeTxnIdFromInitiator) { // System.out.printf("Site %d got heartbeat message from initiator %d with txnid/safeid: %d/%d\n", // m_siteId, initiatorSiteId, txnId, lastSafeTxnIdFromInitiator); // this doesn't exclude dummy txnid but is also a sanity check assert(txnId != 0); // Drop old data from already-failed initiators. if (m_initiatorData.containsKey(initiatorHSId) == false) { //hostLog.info("Dropping txn " + txnId + " data from failed initiatorSiteId: " + initiatorSiteId); return DtxnConstants.DUMMY_LAST_SEEN_TXN_ID; } // update the latest transaction for the specified initiator LastInitiatorData lid = m_initiatorData.get(initiatorHSId); if (lid.m_lastSeenTxnId < txnId) lid.m_lastSeenTxnId = txnId; if (lid.m_lastSafeTxnId < lastSafeTxnIdFromInitiator) lid.m_lastSafeTxnId = lastSafeTxnIdFromInitiator; /* * Why aren't we asserting that the txnId is > then the last seen/last safe * It seems like this should be guaranteed by TCP ordering and we want to * know if it isn't! */ // find the minimum value across all latest transactions long min = Long.MAX_VALUE; for (LastInitiatorData l : m_initiatorData.values()) if (l.m_lastSeenTxnId < min) min = l.m_lastSeenTxnId; // This transaction is the guaranteed minimum // but is not yet necessarily 2PC'd to every site. m_newestCandidateTransaction = min; // this will update the state of the queue if needed updateQueueState(); // return the last seen id for the originating initiator return lid.m_lastSeenTxnId; }
java
public long noteTransactionRecievedAndReturnLastSeen(long initiatorHSId, long txnId, long lastSafeTxnIdFromInitiator) { // System.out.printf("Site %d got heartbeat message from initiator %d with txnid/safeid: %d/%d\n", // m_siteId, initiatorSiteId, txnId, lastSafeTxnIdFromInitiator); // this doesn't exclude dummy txnid but is also a sanity check assert(txnId != 0); // Drop old data from already-failed initiators. if (m_initiatorData.containsKey(initiatorHSId) == false) { //hostLog.info("Dropping txn " + txnId + " data from failed initiatorSiteId: " + initiatorSiteId); return DtxnConstants.DUMMY_LAST_SEEN_TXN_ID; } // update the latest transaction for the specified initiator LastInitiatorData lid = m_initiatorData.get(initiatorHSId); if (lid.m_lastSeenTxnId < txnId) lid.m_lastSeenTxnId = txnId; if (lid.m_lastSafeTxnId < lastSafeTxnIdFromInitiator) lid.m_lastSafeTxnId = lastSafeTxnIdFromInitiator; /* * Why aren't we asserting that the txnId is > then the last seen/last safe * It seems like this should be guaranteed by TCP ordering and we want to * know if it isn't! */ // find the minimum value across all latest transactions long min = Long.MAX_VALUE; for (LastInitiatorData l : m_initiatorData.values()) if (l.m_lastSeenTxnId < min) min = l.m_lastSeenTxnId; // This transaction is the guaranteed minimum // but is not yet necessarily 2PC'd to every site. m_newestCandidateTransaction = min; // this will update the state of the queue if needed updateQueueState(); // return the last seen id for the originating initiator return lid.m_lastSeenTxnId; }
[ "public", "long", "noteTransactionRecievedAndReturnLastSeen", "(", "long", "initiatorHSId", ",", "long", "txnId", ",", "long", "lastSafeTxnIdFromInitiator", ")", "{", "// System.out.printf(\"Site %d got heartbeat message from initiator %d with txnid/safeid: %d/%d\\n\",", "// ...
Update the information stored about the latest transaction seen from each initiator. Compute the newest safe transaction id.
[ "Update", "the", "information", "stored", "about", "the", "latest", "transaction", "seen", "from", "each", "initiator", ".", "Compute", "the", "newest", "safe", "transaction", "id", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java#L146-L188
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java
RestrictedPriorityQueue.gotFaultForInitiator
public void gotFaultForInitiator(long initiatorId) { // calculate the next minimum transaction w/o our dead friend noteTransactionRecievedAndReturnLastSeen(initiatorId, Long.MAX_VALUE, DtxnConstants.DUMMY_LAST_SEEN_TXN_ID); // remove initiator from minimum. txnid scoreboard LastInitiatorData remove = m_initiatorData.remove(initiatorId); assert(remove != null); }
java
public void gotFaultForInitiator(long initiatorId) { // calculate the next minimum transaction w/o our dead friend noteTransactionRecievedAndReturnLastSeen(initiatorId, Long.MAX_VALUE, DtxnConstants.DUMMY_LAST_SEEN_TXN_ID); // remove initiator from minimum. txnid scoreboard LastInitiatorData remove = m_initiatorData.remove(initiatorId); assert(remove != null); }
[ "public", "void", "gotFaultForInitiator", "(", "long", "initiatorId", ")", "{", "// calculate the next minimum transaction w/o our dead friend", "noteTransactionRecievedAndReturnLastSeen", "(", "initiatorId", ",", "Long", ".", "MAX_VALUE", ",", "DtxnConstants", ".", "DUMMY_LAST...
Remove all pending transactions from the specified initiator and do not require heartbeats from that initiator to proceed. @param initiatorId id of the failed initiator.
[ "Remove", "all", "pending", "transactions", "from", "the", "specified", "initiator", "and", "do", "not", "require", "heartbeats", "from", "that", "initiator", "to", "proceed", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java#L195-L202
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java
RestrictedPriorityQueue.ensureInitiatorIsKnown
public int ensureInitiatorIsKnown(long initiatorId) { int newInitiatorCount = 0; if (m_initiatorData.get(initiatorId) == null) { m_initiatorData.put(initiatorId, new LastInitiatorData()); newInitiatorCount++; } return newInitiatorCount; }
java
public int ensureInitiatorIsKnown(long initiatorId) { int newInitiatorCount = 0; if (m_initiatorData.get(initiatorId) == null) { m_initiatorData.put(initiatorId, new LastInitiatorData()); newInitiatorCount++; } return newInitiatorCount; }
[ "public", "int", "ensureInitiatorIsKnown", "(", "long", "initiatorId", ")", "{", "int", "newInitiatorCount", "=", "0", ";", "if", "(", "m_initiatorData", ".", "get", "(", "initiatorId", ")", "==", "null", ")", "{", "m_initiatorData", ".", "put", "(", "initia...
After a catalog change, double check that all initators in the catalog that are known to be "up" are here, in the RPQ's list. @param initiatorId Initiator present in the catalog. @return The number of initiators that weren't known
[ "After", "a", "catalog", "change", "double", "check", "that", "all", "initators", "in", "the", "catalog", "that", "are", "known", "to", "be", "up", "are", "here", "in", "the", "RPQ", "s", "list", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java#L214-L221
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java
RestrictedPriorityQueue.getNewestSafeTransactionForInitiator
public Long getNewestSafeTransactionForInitiator(Long initiatorId) { LastInitiatorData lid = m_initiatorData.get(initiatorId); if (lid == null) { return null; } return lid.m_lastSafeTxnId; }
java
public Long getNewestSafeTransactionForInitiator(Long initiatorId) { LastInitiatorData lid = m_initiatorData.get(initiatorId); if (lid == null) { return null; } return lid.m_lastSafeTxnId; }
[ "public", "Long", "getNewestSafeTransactionForInitiator", "(", "Long", "initiatorId", ")", "{", "LastInitiatorData", "lid", "=", "m_initiatorData", ".", "get", "(", "initiatorId", ")", ";", "if", "(", "lid", "==", "null", ")", "{", "return", "null", ";", "}", ...
Return the largest confirmed txn id for the initiator given. Used to figure out what to do after an initiator fails. @param initiatorId The id of the initiator that has failed.
[ "Return", "the", "largest", "confirmed", "txn", "id", "for", "the", "initiator", "given", ".", "Used", "to", "figure", "out", "what", "to", "do", "after", "an", "initiator", "fails", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java#L235-L241
train
VoltDB/voltdb
src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java
RestrictedPriorityQueue.safeToRecover
public Long safeToRecover() { boolean safe = true; for (LastInitiatorData data : m_initiatorData.values()) { final long lastSeenTxnId = data.m_lastSeenTxnId; if (lastSeenTxnId == DtxnConstants.DUMMY_LAST_SEEN_TXN_ID) { safe = false; } } if (!safe) { return null; } OrderableTransaction next = peek(); if (next == null) { // no work - have heard from all initiators. use a heartbeat if (m_state == QueueState.BLOCKED_EMPTY) { return m_newestCandidateTransaction; } // waiting for some txn to be 2pc to this site. else if (m_state == QueueState.BLOCKED_SAFETY) { return null; } else if (m_state == QueueState.BLOCKED_ORDERING){ return null; } m_recoveryLog.error("Unexpected RPQ state " + m_state + " when attempting to start recovery at " + " the source site. Consider killing the recovering node and trying again"); return null; // unreachable } else { // bingo - have a real transaction to return as the recovery point return next.txnId; } }
java
public Long safeToRecover() { boolean safe = true; for (LastInitiatorData data : m_initiatorData.values()) { final long lastSeenTxnId = data.m_lastSeenTxnId; if (lastSeenTxnId == DtxnConstants.DUMMY_LAST_SEEN_TXN_ID) { safe = false; } } if (!safe) { return null; } OrderableTransaction next = peek(); if (next == null) { // no work - have heard from all initiators. use a heartbeat if (m_state == QueueState.BLOCKED_EMPTY) { return m_newestCandidateTransaction; } // waiting for some txn to be 2pc to this site. else if (m_state == QueueState.BLOCKED_SAFETY) { return null; } else if (m_state == QueueState.BLOCKED_ORDERING){ return null; } m_recoveryLog.error("Unexpected RPQ state " + m_state + " when attempting to start recovery at " + " the source site. Consider killing the recovering node and trying again"); return null; // unreachable } else { // bingo - have a real transaction to return as the recovery point return next.txnId; } }
[ "public", "Long", "safeToRecover", "(", ")", "{", "boolean", "safe", "=", "true", ";", "for", "(", "LastInitiatorData", "data", ":", "m_initiatorData", ".", "values", "(", ")", ")", "{", "final", "long", "lastSeenTxnId", "=", "data", ".", "m_lastSeenTxnId", ...
Determine if it is safe to recover and if it is, what txnid it is safe to recover at. Recovery is initiated by the recovering source partition. It can't be initiated until the recovering partition has heard from every initiator. This is because it is not possible to pick a point in the global txn ordering for the recovery to start at where all subsequent procedure invocations that need to be applied after recovery are available unless every initiator has been heard from. Once the initiators have all been heard from it is necessary to pick the lowest txnid possible for all pending work. This means taking the min of the newest candidate transaction | the txnid of the next txn in the queue. The newest candidate transaction is used if there are no pending txns so recovery can start when the system is idle.
[ "Determine", "if", "it", "is", "safe", "to", "recover", "and", "if", "it", "is", "what", "txnid", "it", "is", "safe", "to", "recover", "at", ".", "Recovery", "is", "initiated", "by", "the", "recovering", "source", "partition", ".", "It", "can", "t", "b...
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/agreement/RestrictedPriorityQueue.java#L365-L397
train
VoltDB/voltdb
src/frontend/org/voltdb/HTTPClientInterface.java
HTTPClientInterface.unauthenticate
public void unauthenticate(HttpServletRequest request) { if (HTTP_DONT_USE_SESSION) return; HttpSession session = request.getSession(false); if (session != null) { session.removeAttribute(AUTH_USER_SESSION_KEY); session.invalidate(); } }
java
public void unauthenticate(HttpServletRequest request) { if (HTTP_DONT_USE_SESSION) return; HttpSession session = request.getSession(false); if (session != null) { session.removeAttribute(AUTH_USER_SESSION_KEY); session.invalidate(); } }
[ "public", "void", "unauthenticate", "(", "HttpServletRequest", "request", ")", "{", "if", "(", "HTTP_DONT_USE_SESSION", ")", "return", ";", "HttpSession", "session", "=", "request", ".", "getSession", "(", "false", ")", ";", "if", "(", "session", "!=", "null",...
reuses it and happily validates it.
[ "reuses", "it", "and", "happily", "validates", "it", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/HTTPClientInterface.java#L552-L559
train
VoltDB/voltdb
src/frontend/org/voltdb/HTTPClientInterface.java
HTTPClientInterface.authenticate
public AuthenticationResult authenticate(HttpServletRequest request) { HttpSession session = null; AuthenticationResult authResult = null; if (!HTTP_DONT_USE_SESSION && !m_dontUseSession) { try { session = request.getSession(); if (session != null) { if (session.isNew()) { session.setMaxInactiveInterval(MAX_SESSION_INACTIVITY_SECONDS); } authResult = (AuthenticationResult )session.getAttribute(AUTH_USER_SESSION_KEY); } } catch (Exception ex) { //Use no session mode meaning whatever VMC sends as hashed password is used to authenticate. session = null; m_rate_limited_log.log(EstTime.currentTimeMillis(), Level.ERROR, ex, "Failed to get or create HTTP Session. authenticating user explicitely."); } } if (authResult == null) { authResult = getAuthenticationResult(request); if (!authResult.isAuthenticated()) { if (session != null) { session.removeAttribute(AUTH_USER_SESSION_KEY); } m_rate_limited_log.log("JSON interface exception: " + authResult.m_message, EstTime.currentTimeMillis()); } else { if (session != null) { //Cache the authResult in session so we dont authenticate again. session.setAttribute(AUTH_USER_SESSION_KEY, authResult); } } } return authResult; }
java
public AuthenticationResult authenticate(HttpServletRequest request) { HttpSession session = null; AuthenticationResult authResult = null; if (!HTTP_DONT_USE_SESSION && !m_dontUseSession) { try { session = request.getSession(); if (session != null) { if (session.isNew()) { session.setMaxInactiveInterval(MAX_SESSION_INACTIVITY_SECONDS); } authResult = (AuthenticationResult )session.getAttribute(AUTH_USER_SESSION_KEY); } } catch (Exception ex) { //Use no session mode meaning whatever VMC sends as hashed password is used to authenticate. session = null; m_rate_limited_log.log(EstTime.currentTimeMillis(), Level.ERROR, ex, "Failed to get or create HTTP Session. authenticating user explicitely."); } } if (authResult == null) { authResult = getAuthenticationResult(request); if (!authResult.isAuthenticated()) { if (session != null) { session.removeAttribute(AUTH_USER_SESSION_KEY); } m_rate_limited_log.log("JSON interface exception: " + authResult.m_message, EstTime.currentTimeMillis()); } else { if (session != null) { //Cache the authResult in session so we dont authenticate again. session.setAttribute(AUTH_USER_SESSION_KEY, authResult); } } } return authResult; }
[ "public", "AuthenticationResult", "authenticate", "(", "HttpServletRequest", "request", ")", "{", "HttpSession", "session", "=", "null", ";", "AuthenticationResult", "authResult", "=", "null", ";", "if", "(", "!", "HTTP_DONT_USE_SESSION", "&&", "!", "m_dontUseSession"...
Look to get session if no session found or created fallback to always authenticate mode.
[ "Look", "to", "get", "session", "if", "no", "session", "found", "or", "created", "fallback", "to", "always", "authenticate", "mode", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/HTTPClientInterface.java#L562-L595
train
VoltDB/voltdb
src/hsqldb19b3/org/hsqldb_voltpatches/FunctionSQL.java
FunctionSQL.newSQLFunction
public static FunctionSQL newSQLFunction(String token, CompileContext context) { int id = regularFuncMap.get(token, -1); if (id == -1) { id = valueFuncMap.get(token, -1); } if (id == -1) { return null; } FunctionSQL function = new FunctionSQL(id); if (id == FUNC_VALUE) { if (context.currentDomain == null) { return null; } function.dataType = context.currentDomain; } return function; }
java
public static FunctionSQL newSQLFunction(String token, CompileContext context) { int id = regularFuncMap.get(token, -1); if (id == -1) { id = valueFuncMap.get(token, -1); } if (id == -1) { return null; } FunctionSQL function = new FunctionSQL(id); if (id == FUNC_VALUE) { if (context.currentDomain == null) { return null; } function.dataType = context.currentDomain; } return function; }
[ "public", "static", "FunctionSQL", "newSQLFunction", "(", "String", "token", ",", "CompileContext", "context", ")", "{", "int", "id", "=", "regularFuncMap", ".", "get", "(", "token", ",", "-", "1", ")", ";", "if", "(", "id", "==", "-", "1", ")", "{", ...
End of VoltDB extension
[ "End", "of", "VoltDB", "extension" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/FunctionSQL.java#L222-L246
train
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java
ZKDatabase.processTxn
public ProcessTxnResult processTxn(TxnHeader hdr, Record txn) { return dataTree.processTxn(hdr, txn); }
java
public ProcessTxnResult processTxn(TxnHeader hdr, Record txn) { return dataTree.processTxn(hdr, txn); }
[ "public", "ProcessTxnResult", "processTxn", "(", "TxnHeader", "hdr", ",", "Record", "txn", ")", "{", "return", "dataTree", ".", "processTxn", "(", "hdr", ",", "txn", ")", ";", "}" ]
the process txn on the data @param hdr the txnheader for the txn @param txn the transaction that needs to be processed @return the result of processing the transaction on this datatree/zkdatabase
[ "the", "process", "txn", "on", "the", "data" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java#L176-L178
train
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java
ZKDatabase.statNode
public Stat statNode(String path, ServerCnxn serverCnxn) throws KeeperException.NoNodeException { return dataTree.statNode(path, serverCnxn); }
java
public Stat statNode(String path, ServerCnxn serverCnxn) throws KeeperException.NoNodeException { return dataTree.statNode(path, serverCnxn); }
[ "public", "Stat", "statNode", "(", "String", "path", ",", "ServerCnxn", "serverCnxn", ")", "throws", "KeeperException", ".", "NoNodeException", "{", "return", "dataTree", ".", "statNode", "(", "path", ",", "serverCnxn", ")", ";", "}" ]
stat the path @param path the path for which stat is to be done @param serverCnxn the servercnxn attached to this request @return the stat of this node @throws KeeperException.NoNodeException
[ "stat", "the", "path" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java#L187-L189
train
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java
ZKDatabase.getData
public byte[] getData(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException { return dataTree.getData(path, stat, watcher); }
java
public byte[] getData(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException { return dataTree.getData(path, stat, watcher); }
[ "public", "byte", "[", "]", "getData", "(", "String", "path", ",", "Stat", "stat", ",", "Watcher", "watcher", ")", "throws", "KeeperException", ".", "NoNodeException", "{", "return", "dataTree", ".", "getData", "(", "path", ",", "stat", ",", "watcher", ")"...
get data and stat for a path @param path the path being queried @param stat the stat for this path @param watcher the watcher function @return @throws KeeperException.NoNodeException
[ "get", "data", "and", "stat", "for", "a", "path" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java#L217-L220
train
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java
ZKDatabase.setWatches
public void setWatches(long relativeZxid, List<String> dataWatches, List<String> existWatches, List<String> childWatches, Watcher watcher) { dataTree.setWatches(relativeZxid, dataWatches, existWatches, childWatches, watcher); }
java
public void setWatches(long relativeZxid, List<String> dataWatches, List<String> existWatches, List<String> childWatches, Watcher watcher) { dataTree.setWatches(relativeZxid, dataWatches, existWatches, childWatches, watcher); }
[ "public", "void", "setWatches", "(", "long", "relativeZxid", ",", "List", "<", "String", ">", "dataWatches", ",", "List", "<", "String", ">", "existWatches", ",", "List", "<", "String", ">", "childWatches", ",", "Watcher", "watcher", ")", "{", "dataTree", ...
set watches on the datatree @param relativeZxid the relative zxid that client has seen @param dataWatches the data watches the client wants to reset @param existWatches the exists watches the client wants to reset @param childWatches the child watches the client wants to reset @param watcher the watcher function
[ "set", "watches", "on", "the", "datatree" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java#L230-L233
train
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java
ZKDatabase.getACL
public List<ACL> getACL(String path, Stat stat) throws NoNodeException { return dataTree.getACL(path, stat); }
java
public List<ACL> getACL(String path, Stat stat) throws NoNodeException { return dataTree.getACL(path, stat); }
[ "public", "List", "<", "ACL", ">", "getACL", "(", "String", "path", ",", "Stat", "stat", ")", "throws", "NoNodeException", "{", "return", "dataTree", ".", "getACL", "(", "path", ",", "stat", ")", ";", "}" ]
get acl for a path @param path the path to query for acl @param stat the stat for the node @return the acl list for this path @throws NoNodeException
[ "get", "acl", "for", "a", "path" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java#L242-L244
train
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java
ZKDatabase.getChildren
public List<String> getChildren(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException { return dataTree.getChildren(path, stat, watcher); }
java
public List<String> getChildren(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException { return dataTree.getChildren(path, stat, watcher); }
[ "public", "List", "<", "String", ">", "getChildren", "(", "String", "path", ",", "Stat", "stat", ",", "Watcher", "watcher", ")", "throws", "KeeperException", ".", "NoNodeException", "{", "return", "dataTree", ".", "getChildren", "(", "path", ",", "stat", ","...
get children list for this path @param path the path of the node @param stat the stat of the node @param watcher the watcher function for this path @return the list of children for this path @throws KeeperException.NoNodeException
[ "get", "children", "list", "for", "this", "path" ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/ZKDatabase.java#L254-L257
train
VoltDB/voltdb
src/frontend/org/voltdb/iv2/SiteTaskerQueue.java
SiteTaskerQueue.take
public SiteTasker take() throws InterruptedException { SiteTasker task = m_tasks.poll(); if (task == null) { m_starvationTracker.beginStarvation(); } else { m_queueDepthTracker.pollUpdate(task.getQueueOfferTime()); return task; } try { task = CoreUtils.queueSpinTake(m_tasks); // task is never null m_queueDepthTracker.pollUpdate(task.getQueueOfferTime()); return task; } finally { m_starvationTracker.endStarvation(); } }
java
public SiteTasker take() throws InterruptedException { SiteTasker task = m_tasks.poll(); if (task == null) { m_starvationTracker.beginStarvation(); } else { m_queueDepthTracker.pollUpdate(task.getQueueOfferTime()); return task; } try { task = CoreUtils.queueSpinTake(m_tasks); // task is never null m_queueDepthTracker.pollUpdate(task.getQueueOfferTime()); return task; } finally { m_starvationTracker.endStarvation(); } }
[ "public", "SiteTasker", "take", "(", ")", "throws", "InterruptedException", "{", "SiteTasker", "task", "=", "m_tasks", ".", "poll", "(", ")", ";", "if", "(", "task", "==", "null", ")", "{", "m_starvationTracker", ".", "beginStarvation", "(", ")", ";", "}",...
Block on the site tasker queue.
[ "Block", "on", "the", "site", "tasker", "queue", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/iv2/SiteTaskerQueue.java#L54-L72
train
VoltDB/voltdb
src/frontend/org/voltdb/iv2/SiteTaskerQueue.java
SiteTaskerQueue.poll
public SiteTasker poll() { SiteTasker task = m_tasks.poll(); if (task != null) { m_queueDepthTracker.pollUpdate(task.getQueueOfferTime()); } return task; }
java
public SiteTasker poll() { SiteTasker task = m_tasks.poll(); if (task != null) { m_queueDepthTracker.pollUpdate(task.getQueueOfferTime()); } return task; }
[ "public", "SiteTasker", "poll", "(", ")", "{", "SiteTasker", "task", "=", "m_tasks", ".", "poll", "(", ")", ";", "if", "(", "task", "!=", "null", ")", "{", "m_queueDepthTracker", ".", "pollUpdate", "(", "task", ".", "getQueueOfferTime", "(", ")", ")", ...
Non-blocking poll on the site tasker queue.
[ "Non", "-", "blocking", "poll", "on", "the", "site", "tasker", "queue", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/iv2/SiteTaskerQueue.java#L75-L82
train
VoltDB/voltdb
third_party/java/src/com/google_voltpatches/common/io/Files.java
Files.newWriter
public static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException { checkNotNull(file); checkNotNull(charset); return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); }
java
public static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException { checkNotNull(file); checkNotNull(charset); return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); }
[ "public", "static", "BufferedWriter", "newWriter", "(", "File", "file", ",", "Charset", "charset", ")", "throws", "FileNotFoundException", "{", "checkNotNull", "(", "file", ")", ";", "checkNotNull", "(", "charset", ")", ";", "return", "new", "BufferedWriter", "(...
Returns a buffered writer that writes to a file using the given character set. @param file the file to write to @param charset the charset used to encode the output stream; see {@link StandardCharsets} for helpful predefined constants @return the buffered writer
[ "Returns", "a", "buffered", "writer", "that", "writes", "to", "a", "file", "using", "the", "given", "character", "set", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/io/Files.java#L95-L99
train
VoltDB/voltdb
third_party/java/src/com/google_voltpatches/common/io/Files.java
Files.write
private static void write(CharSequence from, File to, Charset charset, boolean append) throws IOException { asCharSink(to, charset, modes(append)).write(from); }
java
private static void write(CharSequence from, File to, Charset charset, boolean append) throws IOException { asCharSink(to, charset, modes(append)).write(from); }
[ "private", "static", "void", "write", "(", "CharSequence", "from", ",", "File", "to", ",", "Charset", "charset", ",", "boolean", "append", ")", "throws", "IOException", "{", "asCharSink", "(", "to", ",", "charset", ",", "modes", "(", "append", ")", ")", ...
Private helper method. Writes a character sequence to a file, optionally appending. @param from the character sequence to append @param to the destination file @param charset the charset used to encode the output stream; see {@link StandardCharsets} for helpful predefined constants @param append true to append, false to overwrite @throws IOException if an I/O error occurs
[ "Private", "helper", "method", ".", "Writes", "a", "character", "sequence", "to", "a", "file", "optionally", "appending", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/io/Files.java#L343-L346
train
VoltDB/voltdb
third_party/java/src/com/google_voltpatches/common/io/Files.java
Files.copy
public static void copy(File from, Charset charset, Appendable to) throws IOException { asCharSource(from, charset).copyTo(to); }
java
public static void copy(File from, Charset charset, Appendable to) throws IOException { asCharSource(from, charset).copyTo(to); }
[ "public", "static", "void", "copy", "(", "File", "from", ",", "Charset", "charset", ",", "Appendable", "to", ")", "throws", "IOException", "{", "asCharSource", "(", "from", ",", "charset", ")", ".", "copyTo", "(", "to", ")", ";", "}" ]
Copies all characters from a file to an appendable object, using the given character set. @param from the source file @param charset the charset used to decode the input stream; see {@link StandardCharsets} for helpful predefined constants @param to the appendable object @throws IOException if an I/O error occurs
[ "Copies", "all", "characters", "from", "a", "file", "to", "an", "appendable", "object", "using", "the", "given", "character", "set", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/io/Files.java#L357-L359
train
VoltDB/voltdb
third_party/java/src/com/google_voltpatches/common/io/Files.java
Files.equal
public static boolean equal(File file1, File file2) throws IOException { checkNotNull(file1); checkNotNull(file2); if (file1 == file2 || file1.equals(file2)) { return true; } /* * Some operating systems may return zero as the length for files denoting system-dependent * entities such as devices or pipes, in which case we must fall back on comparing the bytes * directly. */ long len1 = file1.length(); long len2 = file2.length(); if (len1 != 0 && len2 != 0 && len1 != len2) { return false; } return asByteSource(file1).contentEquals(asByteSource(file2)); }
java
public static boolean equal(File file1, File file2) throws IOException { checkNotNull(file1); checkNotNull(file2); if (file1 == file2 || file1.equals(file2)) { return true; } /* * Some operating systems may return zero as the length for files denoting system-dependent * entities such as devices or pipes, in which case we must fall back on comparing the bytes * directly. */ long len1 = file1.length(); long len2 = file2.length(); if (len1 != 0 && len2 != 0 && len1 != len2) { return false; } return asByteSource(file1).contentEquals(asByteSource(file2)); }
[ "public", "static", "boolean", "equal", "(", "File", "file1", ",", "File", "file2", ")", "throws", "IOException", "{", "checkNotNull", "(", "file1", ")", ";", "checkNotNull", "(", "file2", ")", ";", "if", "(", "file1", "==", "file2", "||", "file1", ".", ...
Returns true if the files contains the same bytes. @throws IOException if an I/O error occurs
[ "Returns", "true", "if", "the", "files", "contains", "the", "same", "bytes", "." ]
8afc1031e475835344b5497ea9e7203bc95475ac
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/io/Files.java#L366-L384
train