id
int32
0
165k
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
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
163,700
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
Bytes.endsWith
public boolean endsWith(Bytes suffix) { Objects.requireNonNull(suffix, "endsWith(Bytes suffix) cannot have null parameter"); int startOffset = this.length - suffix.length; if (startOffset < 0) { return false; } else { int end = startOffset + this.offset + suffix.length; for (int i = startOffset + this.offset, j = suffix.offset; i < end; i++, j++) { if (this.data[i] != suffix.data[j]) { return false; } } } return true; }
java
public boolean endsWith(Bytes suffix) { Objects.requireNonNull(suffix, "endsWith(Bytes suffix) cannot have null parameter"); int startOffset = this.length - suffix.length; if (startOffset < 0) { return false; } else { int end = startOffset + this.offset + suffix.length; for (int i = startOffset + this.offset, j = suffix.offset; i < end; i++, j++) { if (this.data[i] != suffix.data[j]) { return false; } } } return true; }
[ "public", "boolean", "endsWith", "(", "Bytes", "suffix", ")", "{", "Objects", ".", "requireNonNull", "(", "suffix", ",", "\"endsWith(Bytes suffix) cannot have null parameter\"", ")", ";", "int", "startOffset", "=", "this", ".", "length", "-", "suffix", ".", "length", ";", "if", "(", "startOffset", "<", "0", ")", "{", "return", "false", ";", "}", "else", "{", "int", "end", "=", "startOffset", "+", "this", ".", "offset", "+", "suffix", ".", "length", ";", "for", "(", "int", "i", "=", "startOffset", "+", "this", ".", "offset", ",", "j", "=", "suffix", ".", "offset", ";", "i", "<", "end", ";", "i", "++", ",", "j", "++", ")", "{", "if", "(", "this", ".", "data", "[", "i", "]", "!=", "suffix", ".", "data", "[", "j", "]", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Checks if this has the passed suffix @param suffix is a Bytes object to compare to this @return true or false @since 1.1.0
[ "Checks", "if", "this", "has", "the", "passed", "suffix" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L462-L477
163,701
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
Bytes.copyTo
public void copyTo(int start, int end, byte[] dest, int destPos) { // this.subSequence(start, end).copyTo(dest, destPos) would allocate another Bytes object arraycopy(start, dest, destPos, end - start); }
java
public void copyTo(int start, int end, byte[] dest, int destPos) { // this.subSequence(start, end).copyTo(dest, destPos) would allocate another Bytes object arraycopy(start, dest, destPos, end - start); }
[ "public", "void", "copyTo", "(", "int", "start", ",", "int", "end", ",", "byte", "[", "]", "dest", ",", "int", "destPos", ")", "{", "// this.subSequence(start, end).copyTo(dest, destPos) would allocate another Bytes object", "arraycopy", "(", "start", ",", "dest", ",", "destPos", ",", "end", "-", "start", ")", ";", "}" ]
Copy a subsequence of Bytes to specific byte array. Uses the specified offset in the dest byte array to start the copy. @param start index of subsequence start (inclusive) @param end index of subsequence end (exclusive) @param dest destination array @param destPos starting position in the destination data. @exception IndexOutOfBoundsException if copying would cause access of data outside array bounds. @exception NullPointerException if either <code>src</code> or <code>dest</code> is <code>null</code>. @since 1.1.0
[ "Copy", "a", "subsequence", "of", "Bytes", "to", "specific", "byte", "array", ".", "Uses", "the", "specified", "offset", "in", "the", "dest", "byte", "array", "to", "start", "the", "copy", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L674-L677
163,702
apache/fluo
modules/accumulo/src/main/java/org/apache/fluo/accumulo/iterators/ColumnBuffer.java
ColumnBuffer.copyTo
public void copyTo(ColumnBuffer dest, LongPredicate timestampTest) { dest.clear(); if (key != null) { dest.key = new Key(key); } for (int i = 0; i < timeStamps.size(); i++) { long time = timeStamps.get(i); if (timestampTest.test(time)) { dest.add(time, values.get(i)); } } }
java
public void copyTo(ColumnBuffer dest, LongPredicate timestampTest) { dest.clear(); if (key != null) { dest.key = new Key(key); } for (int i = 0; i < timeStamps.size(); i++) { long time = timeStamps.get(i); if (timestampTest.test(time)) { dest.add(time, values.get(i)); } } }
[ "public", "void", "copyTo", "(", "ColumnBuffer", "dest", ",", "LongPredicate", "timestampTest", ")", "{", "dest", ".", "clear", "(", ")", ";", "if", "(", "key", "!=", "null", ")", "{", "dest", ".", "key", "=", "new", "Key", "(", "key", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "timeStamps", ".", "size", "(", ")", ";", "i", "++", ")", "{", "long", "time", "=", "timeStamps", ".", "get", "(", "i", ")", ";", "if", "(", "timestampTest", ".", "test", "(", "time", ")", ")", "{", "dest", ".", "add", "(", "time", ",", "values", ".", "get", "(", "i", ")", ")", ";", "}", "}", "}" ]
Clears the dest ColumnBuffer and inserts all entries in dest where the timestamp passes the timestampTest. @param dest Destination ColumnBuffer @param timestampTest Test to determine which timestamps get added to dest
[ "Clears", "the", "dest", "ColumnBuffer", "and", "inserts", "all", "entries", "in", "dest", "where", "the", "timestamp", "passes", "the", "timestampTest", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/iterators/ColumnBuffer.java#L91-L104
163,703
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/AccumuloUtil.java
AccumuloUtil.getClient
public static AccumuloClient getClient(FluoConfiguration config) { return Accumulo.newClient().to(config.getAccumuloInstance(), config.getAccumuloZookeepers()) .as(config.getAccumuloUser(), config.getAccumuloPassword()).build(); }
java
public static AccumuloClient getClient(FluoConfiguration config) { return Accumulo.newClient().to(config.getAccumuloInstance(), config.getAccumuloZookeepers()) .as(config.getAccumuloUser(), config.getAccumuloPassword()).build(); }
[ "public", "static", "AccumuloClient", "getClient", "(", "FluoConfiguration", "config", ")", "{", "return", "Accumulo", ".", "newClient", "(", ")", ".", "to", "(", "config", ".", "getAccumuloInstance", "(", ")", ",", "config", ".", "getAccumuloZookeepers", "(", ")", ")", ".", "as", "(", "config", ".", "getAccumuloUser", "(", ")", ",", "config", ".", "getAccumuloPassword", "(", ")", ")", ".", "build", "(", ")", ";", "}" ]
Creates Accumulo connector given FluoConfiguration
[ "Creates", "Accumulo", "connector", "given", "FluoConfiguration" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/AccumuloUtil.java#L31-L34
163,704
apache/fluo
modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java
ByteArrayUtil.encode
public static byte[] encode(byte[] ba, int offset, long v) { ba[offset + 0] = (byte) (v >>> 56); ba[offset + 1] = (byte) (v >>> 48); ba[offset + 2] = (byte) (v >>> 40); ba[offset + 3] = (byte) (v >>> 32); ba[offset + 4] = (byte) (v >>> 24); ba[offset + 5] = (byte) (v >>> 16); ba[offset + 6] = (byte) (v >>> 8); ba[offset + 7] = (byte) (v >>> 0); return ba; }
java
public static byte[] encode(byte[] ba, int offset, long v) { ba[offset + 0] = (byte) (v >>> 56); ba[offset + 1] = (byte) (v >>> 48); ba[offset + 2] = (byte) (v >>> 40); ba[offset + 3] = (byte) (v >>> 32); ba[offset + 4] = (byte) (v >>> 24); ba[offset + 5] = (byte) (v >>> 16); ba[offset + 6] = (byte) (v >>> 8); ba[offset + 7] = (byte) (v >>> 0); return ba; }
[ "public", "static", "byte", "[", "]", "encode", "(", "byte", "[", "]", "ba", ",", "int", "offset", ",", "long", "v", ")", "{", "ba", "[", "offset", "+", "0", "]", "=", "(", "byte", ")", "(", "v", ">>>", "56", ")", ";", "ba", "[", "offset", "+", "1", "]", "=", "(", "byte", ")", "(", "v", ">>>", "48", ")", ";", "ba", "[", "offset", "+", "2", "]", "=", "(", "byte", ")", "(", "v", ">>>", "40", ")", ";", "ba", "[", "offset", "+", "3", "]", "=", "(", "byte", ")", "(", "v", ">>>", "32", ")", ";", "ba", "[", "offset", "+", "4", "]", "=", "(", "byte", ")", "(", "v", ">>>", "24", ")", ";", "ba", "[", "offset", "+", "5", "]", "=", "(", "byte", ")", "(", "v", ">>>", "16", ")", ";", "ba", "[", "offset", "+", "6", "]", "=", "(", "byte", ")", "(", "v", ">>>", "8", ")", ";", "ba", "[", "offset", "+", "7", "]", "=", "(", "byte", ")", "(", "v", ">>>", "0", ")", ";", "return", "ba", ";", "}" ]
Encode a long into a byte array at an offset @param ba Byte array @param offset Offset @param v Long value @return byte array given in input
[ "Encode", "a", "long", "into", "a", "byte", "array", "at", "an", "offset" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java#L57-L67
163,705
apache/fluo
modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java
ByteArrayUtil.decodeLong
public static long decodeLong(byte[] ba, int offset) { return ((((long) ba[offset + 0] << 56) + ((long) (ba[offset + 1] & 255) << 48) + ((long) (ba[offset + 2] & 255) << 40) + ((long) (ba[offset + 3] & 255) << 32) + ((long) (ba[offset + 4] & 255) << 24) + ((ba[offset + 5] & 255) << 16) + ((ba[offset + 6] & 255) << 8) + ((ba[offset + 7] & 255) << 0))); }
java
public static long decodeLong(byte[] ba, int offset) { return ((((long) ba[offset + 0] << 56) + ((long) (ba[offset + 1] & 255) << 48) + ((long) (ba[offset + 2] & 255) << 40) + ((long) (ba[offset + 3] & 255) << 32) + ((long) (ba[offset + 4] & 255) << 24) + ((ba[offset + 5] & 255) << 16) + ((ba[offset + 6] & 255) << 8) + ((ba[offset + 7] & 255) << 0))); }
[ "public", "static", "long", "decodeLong", "(", "byte", "[", "]", "ba", ",", "int", "offset", ")", "{", "return", "(", "(", "(", "(", "long", ")", "ba", "[", "offset", "+", "0", "]", "<<", "56", ")", "+", "(", "(", "long", ")", "(", "ba", "[", "offset", "+", "1", "]", "&", "255", ")", "<<", "48", ")", "+", "(", "(", "long", ")", "(", "ba", "[", "offset", "+", "2", "]", "&", "255", ")", "<<", "40", ")", "+", "(", "(", "long", ")", "(", "ba", "[", "offset", "+", "3", "]", "&", "255", ")", "<<", "32", ")", "+", "(", "(", "long", ")", "(", "ba", "[", "offset", "+", "4", "]", "&", "255", ")", "<<", "24", ")", "+", "(", "(", "ba", "[", "offset", "+", "5", "]", "&", "255", ")", "<<", "16", ")", "+", "(", "(", "ba", "[", "offset", "+", "6", "]", "&", "255", ")", "<<", "8", ")", "+", "(", "(", "ba", "[", "offset", "+", "7", "]", "&", "255", ")", "<<", "0", ")", ")", ")", ";", "}" ]
Decode long from byte array at offset @param ba byte array @param offset Offset @return long value
[ "Decode", "long", "from", "byte", "array", "at", "offset" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java#L76-L81
163,706
apache/fluo
modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java
ByteArrayUtil.concat
public static byte[] concat(Bytes... listOfBytes) { int offset = 0; int size = 0; for (Bytes b : listOfBytes) { size += b.length() + checkVlen(b.length()); } byte[] data = new byte[size]; for (Bytes b : listOfBytes) { offset = writeVint(data, offset, b.length()); b.copyTo(0, b.length(), data, offset); offset += b.length(); } return data; }
java
public static byte[] concat(Bytes... listOfBytes) { int offset = 0; int size = 0; for (Bytes b : listOfBytes) { size += b.length() + checkVlen(b.length()); } byte[] data = new byte[size]; for (Bytes b : listOfBytes) { offset = writeVint(data, offset, b.length()); b.copyTo(0, b.length(), data, offset); offset += b.length(); } return data; }
[ "public", "static", "byte", "[", "]", "concat", "(", "Bytes", "...", "listOfBytes", ")", "{", "int", "offset", "=", "0", ";", "int", "size", "=", "0", ";", "for", "(", "Bytes", "b", ":", "listOfBytes", ")", "{", "size", "+=", "b", ".", "length", "(", ")", "+", "checkVlen", "(", "b", ".", "length", "(", ")", ")", ";", "}", "byte", "[", "]", "data", "=", "new", "byte", "[", "size", "]", ";", "for", "(", "Bytes", "b", ":", "listOfBytes", ")", "{", "offset", "=", "writeVint", "(", "data", ",", "offset", ",", "b", ".", "length", "(", ")", ")", ";", "b", ".", "copyTo", "(", "0", ",", "b", ".", "length", "(", ")", ",", "data", ",", "offset", ")", ";", "offset", "+=", "b", ".", "length", "(", ")", ";", "}", "return", "data", ";", "}" ]
Concatenates of list of Bytes objects to create a byte array @param listOfBytes Bytes objects to concatenate @return Bytes
[ "Concatenates", "of", "list", "of", "Bytes", "objects", "to", "create", "a", "byte", "array" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java#L120-L135
163,707
apache/fluo
modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java
ByteArrayUtil.writeVint
public static int writeVint(byte[] dest, int offset, int i) { if (i >= -112 && i <= 127) { dest[offset++] = (byte) i; } else { int len = -112; if (i < 0) { i ^= -1L; // take one's complement' len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } dest[offset++] = (byte) len; len = (len < -120) ? -(len + 120) : -(len + 112); for (int idx = len; idx != 0; idx--) { int shiftbits = (idx - 1) * 8; long mask = 0xFFL << shiftbits; dest[offset++] = (byte) ((i & mask) >> shiftbits); } } return offset; }
java
public static int writeVint(byte[] dest, int offset, int i) { if (i >= -112 && i <= 127) { dest[offset++] = (byte) i; } else { int len = -112; if (i < 0) { i ^= -1L; // take one's complement' len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } dest[offset++] = (byte) len; len = (len < -120) ? -(len + 120) : -(len + 112); for (int idx = len; idx != 0; idx--) { int shiftbits = (idx - 1) * 8; long mask = 0xFFL << shiftbits; dest[offset++] = (byte) ((i & mask) >> shiftbits); } } return offset; }
[ "public", "static", "int", "writeVint", "(", "byte", "[", "]", "dest", ",", "int", "offset", ",", "int", "i", ")", "{", "if", "(", "i", ">=", "-", "112", "&&", "i", "<=", "127", ")", "{", "dest", "[", "offset", "++", "]", "=", "(", "byte", ")", "i", ";", "}", "else", "{", "int", "len", "=", "-", "112", ";", "if", "(", "i", "<", "0", ")", "{", "i", "^=", "-", "1L", ";", "// take one's complement'", "len", "=", "-", "120", ";", "}", "long", "tmp", "=", "i", ";", "while", "(", "tmp", "!=", "0", ")", "{", "tmp", "=", "tmp", ">>", "8", ";", "len", "--", ";", "}", "dest", "[", "offset", "++", "]", "=", "(", "byte", ")", "len", ";", "len", "=", "(", "len", "<", "-", "120", ")", "?", "-", "(", "len", "+", "120", ")", ":", "-", "(", "len", "+", "112", ")", ";", "for", "(", "int", "idx", "=", "len", ";", "idx", "!=", "0", ";", "idx", "--", ")", "{", "int", "shiftbits", "=", "(", "idx", "-", "1", ")", "*", "8", ";", "long", "mask", "=", "0xFF", "L", "<<", "shiftbits", ";", "dest", "[", "offset", "++", "]", "=", "(", "byte", ")", "(", "(", "i", "&", "mask", ")", ">>", "shiftbits", ")", ";", "}", "}", "return", "offset", ";", "}" ]
Writes a vInt directly to a byte array @param dest The destination array for the vInt to be written to @param offset The location where to write the vInt to @param i The Value being written into byte array @return Returns the new offset location
[ "Writes", "a", "vInt", "directly", "to", "a", "byte", "array" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java#L145-L173
163,708
apache/fluo
modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java
ByteArrayUtil.checkVlen
public static int checkVlen(int i) { int count = 0; if (i >= -112 && i <= 127) { return 1; } else { int len = -112; if (i < 0) { i ^= -1L; // take one's complement' len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } count++; len = (len < -120) ? -(len + 120) : -(len + 112); while (len != 0) { count++; len--; } return count; } }
java
public static int checkVlen(int i) { int count = 0; if (i >= -112 && i <= 127) { return 1; } else { int len = -112; if (i < 0) { i ^= -1L; // take one's complement' len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } count++; len = (len < -120) ? -(len + 120) : -(len + 112); while (len != 0) { count++; len--; } return count; } }
[ "public", "static", "int", "checkVlen", "(", "int", "i", ")", "{", "int", "count", "=", "0", ";", "if", "(", "i", ">=", "-", "112", "&&", "i", "<=", "127", ")", "{", "return", "1", ";", "}", "else", "{", "int", "len", "=", "-", "112", ";", "if", "(", "i", "<", "0", ")", "{", "i", "^=", "-", "1L", ";", "// take one's complement'", "len", "=", "-", "120", ";", "}", "long", "tmp", "=", "i", ";", "while", "(", "tmp", "!=", "0", ")", "{", "tmp", "=", "tmp", ">>", "8", ";", "len", "--", ";", "}", "count", "++", ";", "len", "=", "(", "len", "<", "-", "120", ")", "?", "-", "(", "len", "+", "120", ")", ":", "-", "(", "len", "+", "112", ")", ";", "while", "(", "len", "!=", "0", ")", "{", "count", "++", ";", "len", "--", ";", "}", "return", "count", ";", "}", "}" ]
Determines the number bytes required to store a variable length @param i length of Bytes @return number of bytes needed
[ "Determines", "the", "number", "bytes", "required", "to", "store", "a", "variable", "length" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java#L181-L209
163,709
apache/fluo
modules/cluster/src/main/java/org/apache/fluo/cluster/runner/YarnAppRunner.java
YarnAppRunner.getResourceReport
private ResourceReport getResourceReport(TwillController controller, int maxWaitMs) { ResourceReport report = controller.getResourceReport(); int elapsed = 0; while (report == null) { report = controller.getResourceReport(); try { Thread.sleep(500); } catch (InterruptedException e) { throw new IllegalStateException(e); } elapsed += 500; if ((maxWaitMs != -1) && (elapsed > maxWaitMs)) { String msg = String.format("Exceeded max wait time to retrieve ResourceReport from Twill." + " Elapsed time = %s ms", elapsed); log.error(msg); throw new IllegalStateException(msg); } if ((elapsed % 10000) == 0) { log.info("Waiting for ResourceReport from Twill. Elapsed time = {} ms", elapsed); } } return report; }
java
private ResourceReport getResourceReport(TwillController controller, int maxWaitMs) { ResourceReport report = controller.getResourceReport(); int elapsed = 0; while (report == null) { report = controller.getResourceReport(); try { Thread.sleep(500); } catch (InterruptedException e) { throw new IllegalStateException(e); } elapsed += 500; if ((maxWaitMs != -1) && (elapsed > maxWaitMs)) { String msg = String.format("Exceeded max wait time to retrieve ResourceReport from Twill." + " Elapsed time = %s ms", elapsed); log.error(msg); throw new IllegalStateException(msg); } if ((elapsed % 10000) == 0) { log.info("Waiting for ResourceReport from Twill. Elapsed time = {} ms", elapsed); } } return report; }
[ "private", "ResourceReport", "getResourceReport", "(", "TwillController", "controller", ",", "int", "maxWaitMs", ")", "{", "ResourceReport", "report", "=", "controller", ".", "getResourceReport", "(", ")", ";", "int", "elapsed", "=", "0", ";", "while", "(", "report", "==", "null", ")", "{", "report", "=", "controller", ".", "getResourceReport", "(", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "500", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "elapsed", "+=", "500", ";", "if", "(", "(", "maxWaitMs", "!=", "-", "1", ")", "&&", "(", "elapsed", ">", "maxWaitMs", ")", ")", "{", "String", "msg", "=", "String", ".", "format", "(", "\"Exceeded max wait time to retrieve ResourceReport from Twill.\"", "+", "\" Elapsed time = %s ms\"", ",", "elapsed", ")", ";", "log", ".", "error", "(", "msg", ")", ";", "throw", "new", "IllegalStateException", "(", "msg", ")", ";", "}", "if", "(", "(", "elapsed", "%", "10000", ")", "==", "0", ")", "{", "log", ".", "info", "(", "\"Waiting for ResourceReport from Twill. Elapsed time = {} ms\"", ",", "elapsed", ")", ";", "}", "}", "return", "report", ";", "}" ]
Attempts to retrieves ResourceReport until maxWaitMs time is reached. Set maxWaitMs to -1 to retry forever.
[ "Attempts", "to", "retrieves", "ResourceReport", "until", "maxWaitMs", "time", "is", "reached", ".", "Set", "maxWaitMs", "to", "-", "1", "to", "retry", "forever", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/cluster/src/main/java/org/apache/fluo/cluster/runner/YarnAppRunner.java#L290-L312
163,710
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.verifyApplicationName
private void verifyApplicationName(String name) { if (name == null) { throw new IllegalArgumentException("Application name cannot be null"); } if (name.isEmpty()) { throw new IllegalArgumentException("Application name length must be > 0"); } String reason = null; char[] chars = name.toCharArray(); char c; for (int i = 0; i < chars.length; i++) { c = chars[i]; if (c == 0) { reason = "null character not allowed @" + i; break; } else if (c == '/' || c == '.' || c == ':') { reason = "invalid character '" + c + "'"; break; } else if (c > '\u0000' && c <= '\u001f' || c >= '\u007f' && c <= '\u009F' || c >= '\ud800' && c <= '\uf8ff' || c >= '\ufff0' && c <= '\uffff') { reason = "invalid character @" + i; break; } } if (reason != null) { throw new IllegalArgumentException( "Invalid application name \"" + name + "\" caused by " + reason); } }
java
private void verifyApplicationName(String name) { if (name == null) { throw new IllegalArgumentException("Application name cannot be null"); } if (name.isEmpty()) { throw new IllegalArgumentException("Application name length must be > 0"); } String reason = null; char[] chars = name.toCharArray(); char c; for (int i = 0; i < chars.length; i++) { c = chars[i]; if (c == 0) { reason = "null character not allowed @" + i; break; } else if (c == '/' || c == '.' || c == ':') { reason = "invalid character '" + c + "'"; break; } else if (c > '\u0000' && c <= '\u001f' || c >= '\u007f' && c <= '\u009F' || c >= '\ud800' && c <= '\uf8ff' || c >= '\ufff0' && c <= '\uffff') { reason = "invalid character @" + i; break; } } if (reason != null) { throw new IllegalArgumentException( "Invalid application name \"" + name + "\" caused by " + reason); } }
[ "private", "void", "verifyApplicationName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Application name cannot be null\"", ")", ";", "}", "if", "(", "name", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Application name length must be > 0\"", ")", ";", "}", "String", "reason", "=", "null", ";", "char", "[", "]", "chars", "=", "name", ".", "toCharArray", "(", ")", ";", "char", "c", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "c", "=", "chars", "[", "i", "]", ";", "if", "(", "c", "==", "0", ")", "{", "reason", "=", "\"null character not allowed @\"", "+", "i", ";", "break", ";", "}", "else", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "{", "reason", "=", "\"invalid character '\"", "+", "c", "+", "\"'\"", ";", "break", ";", "}", "else", "if", "(", "c", ">", "'", "'", "&&", "c", "<=", "'", "'", "||", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", "||", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", "||", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", ")", "{", "reason", "=", "\"invalid character @\"", "+", "i", ";", "break", ";", "}", "}", "if", "(", "reason", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid application name \\\"\"", "+", "name", "+", "\"\\\" caused by \"", "+", "reason", ")", ";", "}", "}" ]
Verifies application name. Avoids characters that Zookeeper does not like in nodes & Hadoop does not like in HDFS paths. @param name Application name @throws IllegalArgumentException If name contains illegal characters
[ "Verifies", "application", "name", ".", "Avoids", "characters", "that", "Zookeeper", "does", "not", "like", "in", "nodes", "&", "Hadoop", "does", "not", "like", "in", "HDFS", "paths", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L318-L346
163,711
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.addObservers
@Deprecated public FluoConfiguration addObservers(Iterable<ObserverSpecification> observers) { int next = getNextObserverId(); for (ObserverSpecification oconf : observers) { addObserver(oconf, next++); } return this; }
java
@Deprecated public FluoConfiguration addObservers(Iterable<ObserverSpecification> observers) { int next = getNextObserverId(); for (ObserverSpecification oconf : observers) { addObserver(oconf, next++); } return this; }
[ "@", "Deprecated", "public", "FluoConfiguration", "addObservers", "(", "Iterable", "<", "ObserverSpecification", ">", "observers", ")", "{", "int", "next", "=", "getNextObserverId", "(", ")", ";", "for", "(", "ObserverSpecification", "oconf", ":", "observers", ")", "{", "addObserver", "(", "oconf", ",", "next", "++", ")", ";", "}", "return", "this", ";", "}" ]
Adds multiple observers using unique integer prefixes for each. @deprecated since 1.1.0. Replaced by {@link #setObserverProvider(String)} and {@link #getObserverProvider()}
[ "Adds", "multiple", "observers", "using", "unique", "integer", "prefixes", "for", "each", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L819-L826
163,712
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.clearObservers
@Deprecated public FluoConfiguration clearObservers() { Iterator<String> iter1 = getKeys(OBSERVER_PREFIX.substring(0, OBSERVER_PREFIX.length() - 1)); while (iter1.hasNext()) { String key = iter1.next(); clearProperty(key); } return this; }
java
@Deprecated public FluoConfiguration clearObservers() { Iterator<String> iter1 = getKeys(OBSERVER_PREFIX.substring(0, OBSERVER_PREFIX.length() - 1)); while (iter1.hasNext()) { String key = iter1.next(); clearProperty(key); } return this; }
[ "@", "Deprecated", "public", "FluoConfiguration", "clearObservers", "(", ")", "{", "Iterator", "<", "String", ">", "iter1", "=", "getKeys", "(", "OBSERVER_PREFIX", ".", "substring", "(", "0", ",", "OBSERVER_PREFIX", ".", "length", "(", ")", "-", "1", ")", ")", ";", "while", "(", "iter1", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "iter1", ".", "next", "(", ")", ";", "clearProperty", "(", "key", ")", ";", "}", "return", "this", ";", "}" ]
Removes any configured observers. @deprecated since 1.1.0. Replaced by {@link #setObserverProvider(String)} and {@link #getObserverProvider()}
[ "Removes", "any", "configured", "observers", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L834-L843
163,713
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.print
public void print() { Iterator<String> iter = getKeys(); while (iter.hasNext()) { String key = iter.next(); log.info(key + " = " + getRawString(key)); } }
java
public void print() { Iterator<String> iter = getKeys(); while (iter.hasNext()) { String key = iter.next(); log.info(key + " = " + getRawString(key)); } }
[ "public", "void", "print", "(", ")", "{", "Iterator", "<", "String", ">", "iter", "=", "getKeys", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "iter", ".", "next", "(", ")", ";", "log", ".", "info", "(", "key", "+", "\" = \"", "+", "getRawString", "(", "key", ")", ")", ";", "}", "}" ]
Logs all properties
[ "Logs", "all", "properties" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L976-L982
163,714
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.hasRequiredClientProps
public boolean hasRequiredClientProps() { boolean valid = true; valid &= verifyStringPropSet(CONNECTION_APPLICATION_NAME_PROP, CLIENT_APPLICATION_NAME_PROP); valid &= verifyStringPropSet(ACCUMULO_USER_PROP, CLIENT_ACCUMULO_USER_PROP); valid &= verifyStringPropSet(ACCUMULO_PASSWORD_PROP, CLIENT_ACCUMULO_PASSWORD_PROP); valid &= verifyStringPropSet(ACCUMULO_INSTANCE_PROP, CLIENT_ACCUMULO_INSTANCE_PROP); return valid; }
java
public boolean hasRequiredClientProps() { boolean valid = true; valid &= verifyStringPropSet(CONNECTION_APPLICATION_NAME_PROP, CLIENT_APPLICATION_NAME_PROP); valid &= verifyStringPropSet(ACCUMULO_USER_PROP, CLIENT_ACCUMULO_USER_PROP); valid &= verifyStringPropSet(ACCUMULO_PASSWORD_PROP, CLIENT_ACCUMULO_PASSWORD_PROP); valid &= verifyStringPropSet(ACCUMULO_INSTANCE_PROP, CLIENT_ACCUMULO_INSTANCE_PROP); return valid; }
[ "public", "boolean", "hasRequiredClientProps", "(", ")", "{", "boolean", "valid", "=", "true", ";", "valid", "&=", "verifyStringPropSet", "(", "CONNECTION_APPLICATION_NAME_PROP", ",", "CLIENT_APPLICATION_NAME_PROP", ")", ";", "valid", "&=", "verifyStringPropSet", "(", "ACCUMULO_USER_PROP", ",", "CLIENT_ACCUMULO_USER_PROP", ")", ";", "valid", "&=", "verifyStringPropSet", "(", "ACCUMULO_PASSWORD_PROP", ",", "CLIENT_ACCUMULO_PASSWORD_PROP", ")", ";", "valid", "&=", "verifyStringPropSet", "(", "ACCUMULO_INSTANCE_PROP", ",", "CLIENT_ACCUMULO_INSTANCE_PROP", ")", ";", "return", "valid", ";", "}" ]
Returns true if required properties for FluoClient are set
[ "Returns", "true", "if", "required", "properties", "for", "FluoClient", "are", "set" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L1018-L1025
163,715
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.hasRequiredAdminProps
public boolean hasRequiredAdminProps() { boolean valid = true; valid &= hasRequiredClientProps(); valid &= verifyStringPropSet(ACCUMULO_TABLE_PROP, ADMIN_ACCUMULO_TABLE_PROP); return valid; }
java
public boolean hasRequiredAdminProps() { boolean valid = true; valid &= hasRequiredClientProps(); valid &= verifyStringPropSet(ACCUMULO_TABLE_PROP, ADMIN_ACCUMULO_TABLE_PROP); return valid; }
[ "public", "boolean", "hasRequiredAdminProps", "(", ")", "{", "boolean", "valid", "=", "true", ";", "valid", "&=", "hasRequiredClientProps", "(", ")", ";", "valid", "&=", "verifyStringPropSet", "(", "ACCUMULO_TABLE_PROP", ",", "ADMIN_ACCUMULO_TABLE_PROP", ")", ";", "return", "valid", ";", "}" ]
Returns true if required properties for FluoAdmin are set
[ "Returns", "true", "if", "required", "properties", "for", "FluoAdmin", "are", "set" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L1030-L1035
163,716
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.hasRequiredMiniFluoProps
public boolean hasRequiredMiniFluoProps() { boolean valid = true; if (getMiniStartAccumulo()) { // ensure that client properties are not set since we are using MiniAccumulo valid &= verifyStringPropNotSet(ACCUMULO_USER_PROP, CLIENT_ACCUMULO_USER_PROP); valid &= verifyStringPropNotSet(ACCUMULO_PASSWORD_PROP, CLIENT_ACCUMULO_PASSWORD_PROP); valid &= verifyStringPropNotSet(ACCUMULO_INSTANCE_PROP, CLIENT_ACCUMULO_INSTANCE_PROP); valid &= verifyStringPropNotSet(ACCUMULO_ZOOKEEPERS_PROP, CLIENT_ACCUMULO_ZOOKEEPERS_PROP); valid &= verifyStringPropNotSet(CONNECTION_ZOOKEEPERS_PROP, CLIENT_ZOOKEEPER_CONNECT_PROP); if (valid == false) { log.error("Client properties should not be set in your configuration if MiniFluo is " + "configured to start its own accumulo (indicated by fluo.mini.start.accumulo being " + "set to true)"); } } else { valid &= hasRequiredClientProps(); valid &= hasRequiredAdminProps(); valid &= hasRequiredOracleProps(); valid &= hasRequiredWorkerProps(); } return valid; }
java
public boolean hasRequiredMiniFluoProps() { boolean valid = true; if (getMiniStartAccumulo()) { // ensure that client properties are not set since we are using MiniAccumulo valid &= verifyStringPropNotSet(ACCUMULO_USER_PROP, CLIENT_ACCUMULO_USER_PROP); valid &= verifyStringPropNotSet(ACCUMULO_PASSWORD_PROP, CLIENT_ACCUMULO_PASSWORD_PROP); valid &= verifyStringPropNotSet(ACCUMULO_INSTANCE_PROP, CLIENT_ACCUMULO_INSTANCE_PROP); valid &= verifyStringPropNotSet(ACCUMULO_ZOOKEEPERS_PROP, CLIENT_ACCUMULO_ZOOKEEPERS_PROP); valid &= verifyStringPropNotSet(CONNECTION_ZOOKEEPERS_PROP, CLIENT_ZOOKEEPER_CONNECT_PROP); if (valid == false) { log.error("Client properties should not be set in your configuration if MiniFluo is " + "configured to start its own accumulo (indicated by fluo.mini.start.accumulo being " + "set to true)"); } } else { valid &= hasRequiredClientProps(); valid &= hasRequiredAdminProps(); valid &= hasRequiredOracleProps(); valid &= hasRequiredWorkerProps(); } return valid; }
[ "public", "boolean", "hasRequiredMiniFluoProps", "(", ")", "{", "boolean", "valid", "=", "true", ";", "if", "(", "getMiniStartAccumulo", "(", ")", ")", "{", "// ensure that client properties are not set since we are using MiniAccumulo", "valid", "&=", "verifyStringPropNotSet", "(", "ACCUMULO_USER_PROP", ",", "CLIENT_ACCUMULO_USER_PROP", ")", ";", "valid", "&=", "verifyStringPropNotSet", "(", "ACCUMULO_PASSWORD_PROP", ",", "CLIENT_ACCUMULO_PASSWORD_PROP", ")", ";", "valid", "&=", "verifyStringPropNotSet", "(", "ACCUMULO_INSTANCE_PROP", ",", "CLIENT_ACCUMULO_INSTANCE_PROP", ")", ";", "valid", "&=", "verifyStringPropNotSet", "(", "ACCUMULO_ZOOKEEPERS_PROP", ",", "CLIENT_ACCUMULO_ZOOKEEPERS_PROP", ")", ";", "valid", "&=", "verifyStringPropNotSet", "(", "CONNECTION_ZOOKEEPERS_PROP", ",", "CLIENT_ZOOKEEPER_CONNECT_PROP", ")", ";", "if", "(", "valid", "==", "false", ")", "{", "log", ".", "error", "(", "\"Client properties should not be set in your configuration if MiniFluo is \"", "+", "\"configured to start its own accumulo (indicated by fluo.mini.start.accumulo being \"", "+", "\"set to true)\"", ")", ";", "}", "}", "else", "{", "valid", "&=", "hasRequiredClientProps", "(", ")", ";", "valid", "&=", "hasRequiredAdminProps", "(", ")", ";", "valid", "&=", "hasRequiredOracleProps", "(", ")", ";", "valid", "&=", "hasRequiredWorkerProps", "(", ")", ";", "}", "return", "valid", ";", "}" ]
Returns true if required properties for MiniFluo are set
[ "Returns", "true", "if", "required", "properties", "for", "MiniFluo", "are", "set" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L1058-L1079
163,717
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.getClientConfiguration
public SimpleConfiguration getClientConfiguration() { SimpleConfiguration clientConfig = new SimpleConfiguration(); Iterator<String> iter = getKeys(); while (iter.hasNext()) { String key = iter.next(); if (key.startsWith(CONNECTION_PREFIX) || key.startsWith(ACCUMULO_PREFIX) || key.startsWith(CLIENT_PREFIX)) { clientConfig.setProperty(key, getRawString(key)); } } return clientConfig; }
java
public SimpleConfiguration getClientConfiguration() { SimpleConfiguration clientConfig = new SimpleConfiguration(); Iterator<String> iter = getKeys(); while (iter.hasNext()) { String key = iter.next(); if (key.startsWith(CONNECTION_PREFIX) || key.startsWith(ACCUMULO_PREFIX) || key.startsWith(CLIENT_PREFIX)) { clientConfig.setProperty(key, getRawString(key)); } } return clientConfig; }
[ "public", "SimpleConfiguration", "getClientConfiguration", "(", ")", "{", "SimpleConfiguration", "clientConfig", "=", "new", "SimpleConfiguration", "(", ")", ";", "Iterator", "<", "String", ">", "iter", "=", "getKeys", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "key", ".", "startsWith", "(", "CONNECTION_PREFIX", ")", "||", "key", ".", "startsWith", "(", "ACCUMULO_PREFIX", ")", "||", "key", ".", "startsWith", "(", "CLIENT_PREFIX", ")", ")", "{", "clientConfig", ".", "setProperty", "(", "key", ",", "getRawString", "(", "key", ")", ")", ";", "}", "}", "return", "clientConfig", ";", "}" ]
Returns a SimpleConfiguration clientConfig with properties set from this configuration @return SimpleConfiguration
[ "Returns", "a", "SimpleConfiguration", "clientConfig", "with", "properties", "set", "from", "this", "configuration" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L1086-L1097
163,718
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.setDefaultConfiguration
public static void setDefaultConfiguration(SimpleConfiguration config) { config.setProperty(CONNECTION_ZOOKEEPERS_PROP, CONNECTION_ZOOKEEPERS_DEFAULT); config.setProperty(CONNECTION_ZOOKEEPER_TIMEOUT_PROP, CONNECTION_ZOOKEEPER_TIMEOUT_DEFAULT); config.setProperty(DFS_ROOT_PROP, DFS_ROOT_DEFAULT); config.setProperty(ACCUMULO_ZOOKEEPERS_PROP, ACCUMULO_ZOOKEEPERS_DEFAULT); config.setProperty(WORKER_NUM_THREADS_PROP, WORKER_NUM_THREADS_DEFAULT); config.setProperty(TRANSACTION_ROLLBACK_TIME_PROP, TRANSACTION_ROLLBACK_TIME_DEFAULT); config.setProperty(LOADER_NUM_THREADS_PROP, LOADER_NUM_THREADS_DEFAULT); config.setProperty(LOADER_QUEUE_SIZE_PROP, LOADER_QUEUE_SIZE_DEFAULT); config.setProperty(MINI_START_ACCUMULO_PROP, MINI_START_ACCUMULO_DEFAULT); config.setProperty(MINI_DATA_DIR_PROP, MINI_DATA_DIR_DEFAULT); }
java
public static void setDefaultConfiguration(SimpleConfiguration config) { config.setProperty(CONNECTION_ZOOKEEPERS_PROP, CONNECTION_ZOOKEEPERS_DEFAULT); config.setProperty(CONNECTION_ZOOKEEPER_TIMEOUT_PROP, CONNECTION_ZOOKEEPER_TIMEOUT_DEFAULT); config.setProperty(DFS_ROOT_PROP, DFS_ROOT_DEFAULT); config.setProperty(ACCUMULO_ZOOKEEPERS_PROP, ACCUMULO_ZOOKEEPERS_DEFAULT); config.setProperty(WORKER_NUM_THREADS_PROP, WORKER_NUM_THREADS_DEFAULT); config.setProperty(TRANSACTION_ROLLBACK_TIME_PROP, TRANSACTION_ROLLBACK_TIME_DEFAULT); config.setProperty(LOADER_NUM_THREADS_PROP, LOADER_NUM_THREADS_DEFAULT); config.setProperty(LOADER_QUEUE_SIZE_PROP, LOADER_QUEUE_SIZE_DEFAULT); config.setProperty(MINI_START_ACCUMULO_PROP, MINI_START_ACCUMULO_DEFAULT); config.setProperty(MINI_DATA_DIR_PROP, MINI_DATA_DIR_DEFAULT); }
[ "public", "static", "void", "setDefaultConfiguration", "(", "SimpleConfiguration", "config", ")", "{", "config", ".", "setProperty", "(", "CONNECTION_ZOOKEEPERS_PROP", ",", "CONNECTION_ZOOKEEPERS_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "CONNECTION_ZOOKEEPER_TIMEOUT_PROP", ",", "CONNECTION_ZOOKEEPER_TIMEOUT_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "DFS_ROOT_PROP", ",", "DFS_ROOT_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "ACCUMULO_ZOOKEEPERS_PROP", ",", "ACCUMULO_ZOOKEEPERS_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "WORKER_NUM_THREADS_PROP", ",", "WORKER_NUM_THREADS_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "TRANSACTION_ROLLBACK_TIME_PROP", ",", "TRANSACTION_ROLLBACK_TIME_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "LOADER_NUM_THREADS_PROP", ",", "LOADER_NUM_THREADS_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "LOADER_QUEUE_SIZE_PROP", ",", "LOADER_QUEUE_SIZE_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "MINI_START_ACCUMULO_PROP", ",", "MINI_START_ACCUMULO_DEFAULT", ")", ";", "config", ".", "setProperty", "(", "MINI_DATA_DIR_PROP", ",", "MINI_DATA_DIR_DEFAULT", ")", ";", "}" ]
Sets all Fluo properties to their default in the given configuration. NOTE - some properties do not have defaults and will not be set.
[ "Sets", "all", "Fluo", "properties", "to", "their", "default", "in", "the", "given", "configuration", ".", "NOTE", "-", "some", "properties", "do", "not", "have", "defaults", "and", "will", "not", "be", "set", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L1113-L1124
163,719
apache/fluo
modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoOutputFormat.java
FluoOutputFormat.configure
public static void configure(Job conf, SimpleConfiguration props) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); props.save(baos); conf.getConfiguration().set(PROPS_CONF_KEY, new String(baos.toByteArray(), StandardCharsets.UTF_8)); } catch (Exception e) { throw new RuntimeException(e); } }
java
public static void configure(Job conf, SimpleConfiguration props) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); props.save(baos); conf.getConfiguration().set(PROPS_CONF_KEY, new String(baos.toByteArray(), StandardCharsets.UTF_8)); } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "static", "void", "configure", "(", "Job", "conf", ",", "SimpleConfiguration", "props", ")", "{", "try", "{", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "props", ".", "save", "(", "baos", ")", ";", "conf", ".", "getConfiguration", "(", ")", ".", "set", "(", "PROPS_CONF_KEY", ",", "new", "String", "(", "baos", ".", "toByteArray", "(", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Call this method to initialize the Fluo connection props @param conf Job configuration @param props Use {@link org.apache.fluo.api.config.FluoConfiguration} to set props programmatically
[ "Call", "this", "method", "to", "initialize", "the", "Fluo", "connection", "props" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoOutputFormat.java#L118-L130
163,720
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/impl/TimestampTracker.java
TimestampTracker.allocateTimestamp
public Stamp allocateTimestamp() { synchronized (this) { Preconditions.checkState(!closed, "tracker closed "); if (node == null) { Preconditions.checkState(allocationsInProgress == 0, "expected allocationsInProgress == 0 when node == null"); Preconditions.checkState(!updatingZk, "unexpected concurrent ZK update"); createZkNode(getTimestamp().getTxTimestamp()); } allocationsInProgress++; } try { Stamp ts = getTimestamp(); synchronized (this) { timestamps.add(ts.getTxTimestamp()); } return ts; } catch (RuntimeException re) { synchronized (this) { allocationsInProgress--; } throw re; } }
java
public Stamp allocateTimestamp() { synchronized (this) { Preconditions.checkState(!closed, "tracker closed "); if (node == null) { Preconditions.checkState(allocationsInProgress == 0, "expected allocationsInProgress == 0 when node == null"); Preconditions.checkState(!updatingZk, "unexpected concurrent ZK update"); createZkNode(getTimestamp().getTxTimestamp()); } allocationsInProgress++; } try { Stamp ts = getTimestamp(); synchronized (this) { timestamps.add(ts.getTxTimestamp()); } return ts; } catch (RuntimeException re) { synchronized (this) { allocationsInProgress--; } throw re; } }
[ "public", "Stamp", "allocateTimestamp", "(", ")", "{", "synchronized", "(", "this", ")", "{", "Preconditions", ".", "checkState", "(", "!", "closed", ",", "\"tracker closed \"", ")", ";", "if", "(", "node", "==", "null", ")", "{", "Preconditions", ".", "checkState", "(", "allocationsInProgress", "==", "0", ",", "\"expected allocationsInProgress == 0 when node == null\"", ")", ";", "Preconditions", ".", "checkState", "(", "!", "updatingZk", ",", "\"unexpected concurrent ZK update\"", ")", ";", "createZkNode", "(", "getTimestamp", "(", ")", ".", "getTxTimestamp", "(", ")", ")", ";", "}", "allocationsInProgress", "++", ";", "}", "try", "{", "Stamp", "ts", "=", "getTimestamp", "(", ")", ";", "synchronized", "(", "this", ")", "{", "timestamps", ".", "add", "(", "ts", ".", "getTxTimestamp", "(", ")", ")", ";", "}", "return", "ts", ";", "}", "catch", "(", "RuntimeException", "re", ")", "{", "synchronized", "(", "this", ")", "{", "allocationsInProgress", "--", ";", "}", "throw", "re", ";", "}", "}" ]
Allocate a timestamp
[ "Allocate", "a", "timestamp" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/TimestampTracker.java#L125-L155
163,721
apache/fluo
modules/command/src/main/java/org/apache/fluo/command/FluoWait.java
FluoWait.waitTillNoNotifications
private static boolean waitTillNoNotifications(Environment env, TableRange range) throws TableNotFoundException { boolean sawNotifications = false; long retryTime = MIN_SLEEP_MS; log.debug("Scanning tablet {} for notifications", range); long start = System.currentTimeMillis(); while (hasNotifications(env, range)) { sawNotifications = true; long sleepTime = Math.max(System.currentTimeMillis() - start, retryTime); log.debug("Tablet {} had notfications, will rescan in {}ms", range, sleepTime); UtilWaitThread.sleep(sleepTime); retryTime = Math.min(MAX_SLEEP_MS, (long) (retryTime * 1.5)); start = System.currentTimeMillis(); } return sawNotifications; }
java
private static boolean waitTillNoNotifications(Environment env, TableRange range) throws TableNotFoundException { boolean sawNotifications = false; long retryTime = MIN_SLEEP_MS; log.debug("Scanning tablet {} for notifications", range); long start = System.currentTimeMillis(); while (hasNotifications(env, range)) { sawNotifications = true; long sleepTime = Math.max(System.currentTimeMillis() - start, retryTime); log.debug("Tablet {} had notfications, will rescan in {}ms", range, sleepTime); UtilWaitThread.sleep(sleepTime); retryTime = Math.min(MAX_SLEEP_MS, (long) (retryTime * 1.5)); start = System.currentTimeMillis(); } return sawNotifications; }
[ "private", "static", "boolean", "waitTillNoNotifications", "(", "Environment", "env", ",", "TableRange", "range", ")", "throws", "TableNotFoundException", "{", "boolean", "sawNotifications", "=", "false", ";", "long", "retryTime", "=", "MIN_SLEEP_MS", ";", "log", ".", "debug", "(", "\"Scanning tablet {} for notifications\"", ",", "range", ")", ";", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "hasNotifications", "(", "env", ",", "range", ")", ")", "{", "sawNotifications", "=", "true", ";", "long", "sleepTime", "=", "Math", ".", "max", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "start", ",", "retryTime", ")", ";", "log", ".", "debug", "(", "\"Tablet {} had notfications, will rescan in {}ms\"", ",", "range", ",", "sleepTime", ")", ";", "UtilWaitThread", ".", "sleep", "(", "sleepTime", ")", ";", "retryTime", "=", "Math", ".", "min", "(", "MAX_SLEEP_MS", ",", "(", "long", ")", "(", "retryTime", "*", "1.5", ")", ")", ";", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "}", "return", "sawNotifications", ";", "}" ]
Wait until a range has no notifications. @return true if notifications were ever seen while waiting
[ "Wait", "until", "a", "range", "has", "no", "notifications", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/command/src/main/java/org/apache/fluo/command/FluoWait.java#L66-L84
163,722
apache/fluo
modules/command/src/main/java/org/apache/fluo/command/FluoWait.java
FluoWait.waitUntilFinished
private static void waitUntilFinished(FluoConfiguration config) { try (Environment env = new Environment(config)) { List<TableRange> ranges = getRanges(env); outer: while (true) { long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); for (TableRange range : ranges) { boolean sawNotifications = waitTillNoNotifications(env, range); if (sawNotifications) { ranges = getRanges(env); // This range had notifications. Processing those notifications may have created // notifications in previously scanned ranges, so start over. continue outer; } } long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); // Check to ensure the Oracle issued no timestamps during the scan for notifications. if (ts2 - ts1 == 1) { break; } } } catch (Exception e) { log.error("An exception was thrown -", e); System.exit(-1); } }
java
private static void waitUntilFinished(FluoConfiguration config) { try (Environment env = new Environment(config)) { List<TableRange> ranges = getRanges(env); outer: while (true) { long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); for (TableRange range : ranges) { boolean sawNotifications = waitTillNoNotifications(env, range); if (sawNotifications) { ranges = getRanges(env); // This range had notifications. Processing those notifications may have created // notifications in previously scanned ranges, so start over. continue outer; } } long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); // Check to ensure the Oracle issued no timestamps during the scan for notifications. if (ts2 - ts1 == 1) { break; } } } catch (Exception e) { log.error("An exception was thrown -", e); System.exit(-1); } }
[ "private", "static", "void", "waitUntilFinished", "(", "FluoConfiguration", "config", ")", "{", "try", "(", "Environment", "env", "=", "new", "Environment", "(", "config", ")", ")", "{", "List", "<", "TableRange", ">", "ranges", "=", "getRanges", "(", "env", ")", ";", "outer", ":", "while", "(", "true", ")", "{", "long", "ts1", "=", "env", ".", "getSharedResources", "(", ")", ".", "getOracleClient", "(", ")", ".", "getStamp", "(", ")", ".", "getTxTimestamp", "(", ")", ";", "for", "(", "TableRange", "range", ":", "ranges", ")", "{", "boolean", "sawNotifications", "=", "waitTillNoNotifications", "(", "env", ",", "range", ")", ";", "if", "(", "sawNotifications", ")", "{", "ranges", "=", "getRanges", "(", "env", ")", ";", "// This range had notifications. Processing those notifications may have created", "// notifications in previously scanned ranges, so start over.", "continue", "outer", ";", "}", "}", "long", "ts2", "=", "env", ".", "getSharedResources", "(", ")", ".", "getOracleClient", "(", ")", ".", "getStamp", "(", ")", ".", "getTxTimestamp", "(", ")", ";", "// Check to ensure the Oracle issued no timestamps during the scan for notifications.", "if", "(", "ts2", "-", "ts1", "==", "1", ")", "{", "break", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"An exception was thrown -\"", ",", "e", ")", ";", "System", ".", "exit", "(", "-", "1", ")", ";", "}", "}" ]
Wait until a scan of the table completes without seeing notifications AND without the Oracle issuing any timestamps during the scan.
[ "Wait", "until", "a", "scan", "of", "the", "table", "completes", "without", "seeing", "notifications", "AND", "without", "the", "Oracle", "issuing", "any", "timestamps", "during", "the", "scan", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/command/src/main/java/org/apache/fluo/command/FluoWait.java#L90-L116
163,723
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java
SpanUtil.toRange
public static Range toRange(Span span) { return new Range(toKey(span.getStart()), span.isStartInclusive(), toKey(span.getEnd()), span.isEndInclusive()); }
java
public static Range toRange(Span span) { return new Range(toKey(span.getStart()), span.isStartInclusive(), toKey(span.getEnd()), span.isEndInclusive()); }
[ "public", "static", "Range", "toRange", "(", "Span", "span", ")", "{", "return", "new", "Range", "(", "toKey", "(", "span", ".", "getStart", "(", ")", ")", ",", "span", ".", "isStartInclusive", "(", ")", ",", "toKey", "(", "span", ".", "getEnd", "(", ")", ")", ",", "span", ".", "isEndInclusive", "(", ")", ")", ";", "}" ]
Converts a Fluo Span to Accumulo Range @param span Span @return Range
[ "Converts", "a", "Fluo", "Span", "to", "Accumulo", "Range" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java#L39-L42
163,724
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java
SpanUtil.toKey
public static Key toKey(RowColumn rc) { if ((rc == null) || (rc.getRow().equals(Bytes.EMPTY))) { return null; } Text row = ByteUtil.toText(rc.getRow()); if ((rc.getColumn().equals(Column.EMPTY)) || !rc.getColumn().isFamilySet()) { return new Key(row); } Text cf = ByteUtil.toText(rc.getColumn().getFamily()); if (!rc.getColumn().isQualifierSet()) { return new Key(row, cf); } Text cq = ByteUtil.toText(rc.getColumn().getQualifier()); if (!rc.getColumn().isVisibilitySet()) { return new Key(row, cf, cq); } Text cv = ByteUtil.toText(rc.getColumn().getVisibility()); return new Key(row, cf, cq, cv); }
java
public static Key toKey(RowColumn rc) { if ((rc == null) || (rc.getRow().equals(Bytes.EMPTY))) { return null; } Text row = ByteUtil.toText(rc.getRow()); if ((rc.getColumn().equals(Column.EMPTY)) || !rc.getColumn().isFamilySet()) { return new Key(row); } Text cf = ByteUtil.toText(rc.getColumn().getFamily()); if (!rc.getColumn().isQualifierSet()) { return new Key(row, cf); } Text cq = ByteUtil.toText(rc.getColumn().getQualifier()); if (!rc.getColumn().isVisibilitySet()) { return new Key(row, cf, cq); } Text cv = ByteUtil.toText(rc.getColumn().getVisibility()); return new Key(row, cf, cq, cv); }
[ "public", "static", "Key", "toKey", "(", "RowColumn", "rc", ")", "{", "if", "(", "(", "rc", "==", "null", ")", "||", "(", "rc", ".", "getRow", "(", ")", ".", "equals", "(", "Bytes", ".", "EMPTY", ")", ")", ")", "{", "return", "null", ";", "}", "Text", "row", "=", "ByteUtil", ".", "toText", "(", "rc", ".", "getRow", "(", ")", ")", ";", "if", "(", "(", "rc", ".", "getColumn", "(", ")", ".", "equals", "(", "Column", ".", "EMPTY", ")", ")", "||", "!", "rc", ".", "getColumn", "(", ")", ".", "isFamilySet", "(", ")", ")", "{", "return", "new", "Key", "(", "row", ")", ";", "}", "Text", "cf", "=", "ByteUtil", ".", "toText", "(", "rc", ".", "getColumn", "(", ")", ".", "getFamily", "(", ")", ")", ";", "if", "(", "!", "rc", ".", "getColumn", "(", ")", ".", "isQualifierSet", "(", ")", ")", "{", "return", "new", "Key", "(", "row", ",", "cf", ")", ";", "}", "Text", "cq", "=", "ByteUtil", ".", "toText", "(", "rc", ".", "getColumn", "(", ")", ".", "getQualifier", "(", ")", ")", ";", "if", "(", "!", "rc", ".", "getColumn", "(", ")", ".", "isVisibilitySet", "(", ")", ")", "{", "return", "new", "Key", "(", "row", ",", "cf", ",", "cq", ")", ";", "}", "Text", "cv", "=", "ByteUtil", ".", "toText", "(", "rc", ".", "getColumn", "(", ")", ".", "getVisibility", "(", ")", ")", ";", "return", "new", "Key", "(", "row", ",", "cf", ",", "cq", ",", "cv", ")", ";", "}" ]
Converts from a Fluo RowColumn to a Accumulo Key @param rc RowColumn @return Key
[ "Converts", "from", "a", "Fluo", "RowColumn", "to", "a", "Accumulo", "Key" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java#L50-L68
163,725
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java
SpanUtil.toSpan
public static Span toSpan(Range range) { return new Span(toRowColumn(range.getStartKey()), range.isStartKeyInclusive(), toRowColumn(range.getEndKey()), range.isEndKeyInclusive()); }
java
public static Span toSpan(Range range) { return new Span(toRowColumn(range.getStartKey()), range.isStartKeyInclusive(), toRowColumn(range.getEndKey()), range.isEndKeyInclusive()); }
[ "public", "static", "Span", "toSpan", "(", "Range", "range", ")", "{", "return", "new", "Span", "(", "toRowColumn", "(", "range", ".", "getStartKey", "(", ")", ")", ",", "range", ".", "isStartKeyInclusive", "(", ")", ",", "toRowColumn", "(", "range", ".", "getEndKey", "(", ")", ")", ",", "range", ".", "isEndKeyInclusive", "(", ")", ")", ";", "}" ]
Converts an Accumulo Range to a Fluo Span @param range Range @return Span
[ "Converts", "an", "Accumulo", "Range", "to", "a", "Fluo", "Span" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java#L76-L79
163,726
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java
SpanUtil.toRowColumn
public static RowColumn toRowColumn(Key key) { if (key == null) { return RowColumn.EMPTY; } if ((key.getRow() == null) || key.getRow().getLength() == 0) { return RowColumn.EMPTY; } Bytes row = ByteUtil.toBytes(key.getRow()); if ((key.getColumnFamily() == null) || key.getColumnFamily().getLength() == 0) { return new RowColumn(row); } Bytes cf = ByteUtil.toBytes(key.getColumnFamily()); if ((key.getColumnQualifier() == null) || key.getColumnQualifier().getLength() == 0) { return new RowColumn(row, new Column(cf)); } Bytes cq = ByteUtil.toBytes(key.getColumnQualifier()); if ((key.getColumnVisibility() == null) || key.getColumnVisibility().getLength() == 0) { return new RowColumn(row, new Column(cf, cq)); } Bytes cv = ByteUtil.toBytes(key.getColumnVisibility()); return new RowColumn(row, new Column(cf, cq, cv)); }
java
public static RowColumn toRowColumn(Key key) { if (key == null) { return RowColumn.EMPTY; } if ((key.getRow() == null) || key.getRow().getLength() == 0) { return RowColumn.EMPTY; } Bytes row = ByteUtil.toBytes(key.getRow()); if ((key.getColumnFamily() == null) || key.getColumnFamily().getLength() == 0) { return new RowColumn(row); } Bytes cf = ByteUtil.toBytes(key.getColumnFamily()); if ((key.getColumnQualifier() == null) || key.getColumnQualifier().getLength() == 0) { return new RowColumn(row, new Column(cf)); } Bytes cq = ByteUtil.toBytes(key.getColumnQualifier()); if ((key.getColumnVisibility() == null) || key.getColumnVisibility().getLength() == 0) { return new RowColumn(row, new Column(cf, cq)); } Bytes cv = ByteUtil.toBytes(key.getColumnVisibility()); return new RowColumn(row, new Column(cf, cq, cv)); }
[ "public", "static", "RowColumn", "toRowColumn", "(", "Key", "key", ")", "{", "if", "(", "key", "==", "null", ")", "{", "return", "RowColumn", ".", "EMPTY", ";", "}", "if", "(", "(", "key", ".", "getRow", "(", ")", "==", "null", ")", "||", "key", ".", "getRow", "(", ")", ".", "getLength", "(", ")", "==", "0", ")", "{", "return", "RowColumn", ".", "EMPTY", ";", "}", "Bytes", "row", "=", "ByteUtil", ".", "toBytes", "(", "key", ".", "getRow", "(", ")", ")", ";", "if", "(", "(", "key", ".", "getColumnFamily", "(", ")", "==", "null", ")", "||", "key", ".", "getColumnFamily", "(", ")", ".", "getLength", "(", ")", "==", "0", ")", "{", "return", "new", "RowColumn", "(", "row", ")", ";", "}", "Bytes", "cf", "=", "ByteUtil", ".", "toBytes", "(", "key", ".", "getColumnFamily", "(", ")", ")", ";", "if", "(", "(", "key", ".", "getColumnQualifier", "(", ")", "==", "null", ")", "||", "key", ".", "getColumnQualifier", "(", ")", ".", "getLength", "(", ")", "==", "0", ")", "{", "return", "new", "RowColumn", "(", "row", ",", "new", "Column", "(", "cf", ")", ")", ";", "}", "Bytes", "cq", "=", "ByteUtil", ".", "toBytes", "(", "key", ".", "getColumnQualifier", "(", ")", ")", ";", "if", "(", "(", "key", ".", "getColumnVisibility", "(", ")", "==", "null", ")", "||", "key", ".", "getColumnVisibility", "(", ")", ".", "getLength", "(", ")", "==", "0", ")", "{", "return", "new", "RowColumn", "(", "row", ",", "new", "Column", "(", "cf", ",", "cq", ")", ")", ";", "}", "Bytes", "cv", "=", "ByteUtil", ".", "toBytes", "(", "key", ".", "getColumnVisibility", "(", ")", ")", ";", "return", "new", "RowColumn", "(", "row", ",", "new", "Column", "(", "cf", ",", "cq", ",", "cv", ")", ")", ";", "}" ]
Converts from an Accumulo Key to a Fluo RowColumn @param key Key @return RowColumn
[ "Converts", "from", "an", "Accumulo", "Key", "to", "a", "Fluo", "RowColumn" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java#L87-L108
163,727
apache/fluo
modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoKeyValueGenerator.java
FluoKeyValueGenerator.set
public FluoKeyValueGenerator set(RowColumnValue rcv) { setRow(rcv.getRow()); setColumn(rcv.getColumn()); setValue(rcv.getValue()); return this; }
java
public FluoKeyValueGenerator set(RowColumnValue rcv) { setRow(rcv.getRow()); setColumn(rcv.getColumn()); setValue(rcv.getValue()); return this; }
[ "public", "FluoKeyValueGenerator", "set", "(", "RowColumnValue", "rcv", ")", "{", "setRow", "(", "rcv", ".", "getRow", "(", ")", ")", ";", "setColumn", "(", "rcv", ".", "getColumn", "(", ")", ")", ";", "setValue", "(", "rcv", ".", "getValue", "(", ")", ")", ";", "return", "this", ";", "}" ]
Set the row, column, and value @return this
[ "Set", "the", "row", "column", "and", "value" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoKeyValueGenerator.java#L176-L181
163,728
apache/fluo
modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoKeyValueGenerator.java
FluoKeyValueGenerator.getKeyValues
public FluoKeyValue[] getKeyValues() { FluoKeyValue kv = keyVals[0]; kv.setKey(new Key(row, fam, qual, vis, ColumnType.WRITE.encode(1))); kv.getValue().set(WriteValue.encode(0, false, false)); kv = keyVals[1]; kv.setKey(new Key(row, fam, qual, vis, ColumnType.DATA.encode(0))); kv.getValue().set(val); return keyVals; }
java
public FluoKeyValue[] getKeyValues() { FluoKeyValue kv = keyVals[0]; kv.setKey(new Key(row, fam, qual, vis, ColumnType.WRITE.encode(1))); kv.getValue().set(WriteValue.encode(0, false, false)); kv = keyVals[1]; kv.setKey(new Key(row, fam, qual, vis, ColumnType.DATA.encode(0))); kv.getValue().set(val); return keyVals; }
[ "public", "FluoKeyValue", "[", "]", "getKeyValues", "(", ")", "{", "FluoKeyValue", "kv", "=", "keyVals", "[", "0", "]", ";", "kv", ".", "setKey", "(", "new", "Key", "(", "row", ",", "fam", ",", "qual", ",", "vis", ",", "ColumnType", ".", "WRITE", ".", "encode", "(", "1", ")", ")", ")", ";", "kv", ".", "getValue", "(", ")", ".", "set", "(", "WriteValue", ".", "encode", "(", "0", ",", "false", ",", "false", ")", ")", ";", "kv", "=", "keyVals", "[", "1", "]", ";", "kv", ".", "setKey", "(", "new", "Key", "(", "row", ",", "fam", ",", "qual", ",", "vis", ",", "ColumnType", ".", "DATA", ".", "encode", "(", "0", ")", ")", ")", ";", "kv", ".", "getValue", "(", ")", ".", "set", "(", "val", ")", ";", "return", "keyVals", ";", "}" ]
Translates the Fluo row, column, and value set into the persistent format that is stored in Accumulo. <p> The objects returned by this method are reused each time its called. So each time this is called it invalidates what was returned by previous calls to this method. @return A an array of Accumulo key values in correct sorted order.
[ "Translates", "the", "Fluo", "row", "column", "and", "value", "set", "into", "the", "persistent", "format", "that", "is", "stored", "in", "Accumulo", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoKeyValueGenerator.java#L193-L203
163,729
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/data/RowColumn.java
RowColumn.following
public RowColumn following() { if (row.equals(Bytes.EMPTY)) { return RowColumn.EMPTY; } else if (col.equals(Column.EMPTY)) { return new RowColumn(followingBytes(row)); } else if (!col.isQualifierSet()) { return new RowColumn(row, new Column(followingBytes(col.getFamily()))); } else if (!col.isVisibilitySet()) { return new RowColumn(row, new Column(col.getFamily(), followingBytes(col.getQualifier()))); } else { return new RowColumn(row, new Column(col.getFamily(), col.getQualifier(), followingBytes(col.getVisibility()))); } }
java
public RowColumn following() { if (row.equals(Bytes.EMPTY)) { return RowColumn.EMPTY; } else if (col.equals(Column.EMPTY)) { return new RowColumn(followingBytes(row)); } else if (!col.isQualifierSet()) { return new RowColumn(row, new Column(followingBytes(col.getFamily()))); } else if (!col.isVisibilitySet()) { return new RowColumn(row, new Column(col.getFamily(), followingBytes(col.getQualifier()))); } else { return new RowColumn(row, new Column(col.getFamily(), col.getQualifier(), followingBytes(col.getVisibility()))); } }
[ "public", "RowColumn", "following", "(", ")", "{", "if", "(", "row", ".", "equals", "(", "Bytes", ".", "EMPTY", ")", ")", "{", "return", "RowColumn", ".", "EMPTY", ";", "}", "else", "if", "(", "col", ".", "equals", "(", "Column", ".", "EMPTY", ")", ")", "{", "return", "new", "RowColumn", "(", "followingBytes", "(", "row", ")", ")", ";", "}", "else", "if", "(", "!", "col", ".", "isQualifierSet", "(", ")", ")", "{", "return", "new", "RowColumn", "(", "row", ",", "new", "Column", "(", "followingBytes", "(", "col", ".", "getFamily", "(", ")", ")", ")", ")", ";", "}", "else", "if", "(", "!", "col", ".", "isVisibilitySet", "(", ")", ")", "{", "return", "new", "RowColumn", "(", "row", ",", "new", "Column", "(", "col", ".", "getFamily", "(", ")", ",", "followingBytes", "(", "col", ".", "getQualifier", "(", ")", ")", ")", ")", ";", "}", "else", "{", "return", "new", "RowColumn", "(", "row", ",", "new", "Column", "(", "col", ".", "getFamily", "(", ")", ",", "col", ".", "getQualifier", "(", ")", ",", "followingBytes", "(", "col", ".", "getVisibility", "(", ")", ")", ")", ")", ";", "}", "}" ]
Returns a RowColumn following the current one @return RowColumn following this one
[ "Returns", "a", "RowColumn", "following", "the", "current", "one" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/RowColumn.java#L143-L156
163,730
apache/fluo
modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoMutationGenerator.java
FluoMutationGenerator.put
public FluoMutationGenerator put(Column col, CharSequence value) { return put(col, value.toString().getBytes(StandardCharsets.UTF_8)); }
java
public FluoMutationGenerator put(Column col, CharSequence value) { return put(col, value.toString().getBytes(StandardCharsets.UTF_8)); }
[ "public", "FluoMutationGenerator", "put", "(", "Column", "col", ",", "CharSequence", "value", ")", "{", "return", "put", "(", "col", ",", "value", ".", "toString", "(", ")", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ")", ";", "}" ]
Puts value at given column @param value Will be encoded using UTF-8
[ "Puts", "value", "at", "given", "column" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoMutationGenerator.java#L73-L75
163,731
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
CuratorUtil.newAppCurator
public static CuratorFramework newAppCurator(FluoConfiguration config) { return newCurator(config.getAppZookeepers(), config.getZookeeperTimeout(), config.getZookeeperSecret()); }
java
public static CuratorFramework newAppCurator(FluoConfiguration config) { return newCurator(config.getAppZookeepers(), config.getZookeeperTimeout(), config.getZookeeperSecret()); }
[ "public", "static", "CuratorFramework", "newAppCurator", "(", "FluoConfiguration", "config", ")", "{", "return", "newCurator", "(", "config", ".", "getAppZookeepers", "(", ")", ",", "config", ".", "getZookeeperTimeout", "(", ")", ",", "config", ".", "getZookeeperSecret", "(", ")", ")", ";", "}" ]
Creates a curator built using Application's zookeeper connection string. Root path will start at Fluo application chroot.
[ "Creates", "a", "curator", "built", "using", "Application", "s", "zookeeper", "connection", "string", ".", "Root", "path", "will", "start", "at", "Fluo", "application", "chroot", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java#L56-L59
163,732
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
CuratorUtil.newFluoCurator
public static CuratorFramework newFluoCurator(FluoConfiguration config) { return newCurator(config.getInstanceZookeepers(), config.getZookeeperTimeout(), config.getZookeeperSecret()); }
java
public static CuratorFramework newFluoCurator(FluoConfiguration config) { return newCurator(config.getInstanceZookeepers(), config.getZookeeperTimeout(), config.getZookeeperSecret()); }
[ "public", "static", "CuratorFramework", "newFluoCurator", "(", "FluoConfiguration", "config", ")", "{", "return", "newCurator", "(", "config", ".", "getInstanceZookeepers", "(", ")", ",", "config", ".", "getZookeeperTimeout", "(", ")", ",", "config", ".", "getZookeeperSecret", "(", ")", ")", ";", "}" ]
Creates a curator built using Fluo's zookeeper connection string. Root path will start at Fluo chroot.
[ "Creates", "a", "curator", "built", "using", "Fluo", "s", "zookeeper", "connection", "string", ".", "Root", "path", "will", "start", "at", "Fluo", "chroot", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java#L65-L68
163,733
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
CuratorUtil.newCurator
public static CuratorFramework newCurator(String zookeepers, int timeout, String secret) { final ExponentialBackoffRetry retry = new ExponentialBackoffRetry(1000, 10); if (secret.isEmpty()) { return CuratorFrameworkFactory.newClient(zookeepers, timeout, timeout, retry); } else { return CuratorFrameworkFactory.builder().connectString(zookeepers) .connectionTimeoutMs(timeout).sessionTimeoutMs(timeout).retryPolicy(retry) .authorization("digest", ("fluo:" + secret).getBytes(StandardCharsets.UTF_8)) .aclProvider(new ACLProvider() { @Override public List<ACL> getDefaultAcl() { return CREATOR_ALL_ACL; } @Override public List<ACL> getAclForPath(String path) { switch (path) { case ZookeeperPath.ORACLE_GC_TIMESTAMP: // The garbage collection iterator running in Accumulo tservers needs to read this // value w/o authenticating. return PUBLICLY_READABLE_ACL; default: return CREATOR_ALL_ACL; } } }).build(); } }
java
public static CuratorFramework newCurator(String zookeepers, int timeout, String secret) { final ExponentialBackoffRetry retry = new ExponentialBackoffRetry(1000, 10); if (secret.isEmpty()) { return CuratorFrameworkFactory.newClient(zookeepers, timeout, timeout, retry); } else { return CuratorFrameworkFactory.builder().connectString(zookeepers) .connectionTimeoutMs(timeout).sessionTimeoutMs(timeout).retryPolicy(retry) .authorization("digest", ("fluo:" + secret).getBytes(StandardCharsets.UTF_8)) .aclProvider(new ACLProvider() { @Override public List<ACL> getDefaultAcl() { return CREATOR_ALL_ACL; } @Override public List<ACL> getAclForPath(String path) { switch (path) { case ZookeeperPath.ORACLE_GC_TIMESTAMP: // The garbage collection iterator running in Accumulo tservers needs to read this // value w/o authenticating. return PUBLICLY_READABLE_ACL; default: return CREATOR_ALL_ACL; } } }).build(); } }
[ "public", "static", "CuratorFramework", "newCurator", "(", "String", "zookeepers", ",", "int", "timeout", ",", "String", "secret", ")", "{", "final", "ExponentialBackoffRetry", "retry", "=", "new", "ExponentialBackoffRetry", "(", "1000", ",", "10", ")", ";", "if", "(", "secret", ".", "isEmpty", "(", ")", ")", "{", "return", "CuratorFrameworkFactory", ".", "newClient", "(", "zookeepers", ",", "timeout", ",", "timeout", ",", "retry", ")", ";", "}", "else", "{", "return", "CuratorFrameworkFactory", ".", "builder", "(", ")", ".", "connectString", "(", "zookeepers", ")", ".", "connectionTimeoutMs", "(", "timeout", ")", ".", "sessionTimeoutMs", "(", "timeout", ")", ".", "retryPolicy", "(", "retry", ")", ".", "authorization", "(", "\"digest\"", ",", "(", "\"fluo:\"", "+", "secret", ")", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ")", ".", "aclProvider", "(", "new", "ACLProvider", "(", ")", "{", "@", "Override", "public", "List", "<", "ACL", ">", "getDefaultAcl", "(", ")", "{", "return", "CREATOR_ALL_ACL", ";", "}", "@", "Override", "public", "List", "<", "ACL", ">", "getAclForPath", "(", "String", "path", ")", "{", "switch", "(", "path", ")", "{", "case", "ZookeeperPath", ".", "ORACLE_GC_TIMESTAMP", ":", "// The garbage collection iterator running in Accumulo tservers needs to read this", "// value w/o authenticating.", "return", "PUBLICLY_READABLE_ACL", ";", "default", ":", "return", "CREATOR_ALL_ACL", ";", "}", "}", "}", ")", ".", "build", "(", ")", ";", "}", "}" ]
Creates a curator built using the given zookeeper connection string and timeout
[ "Creates", "a", "curator", "built", "using", "the", "given", "zookeeper", "connection", "string", "and", "timeout" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java#L88-L116
163,734
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
CuratorUtil.startAndWait
public static void startAndWait(PersistentNode node, int maxWaitSec) { node.start(); int waitTime = 0; try { while (node.waitForInitialCreate(1, TimeUnit.SECONDS) == false) { waitTime += 1; log.info("Waited " + waitTime + " sec for ephemeral node to be created"); if (waitTime > maxWaitSec) { throw new IllegalStateException("Failed to create ephemeral node"); } } } catch (InterruptedException e) { throw new IllegalStateException(e); } }
java
public static void startAndWait(PersistentNode node, int maxWaitSec) { node.start(); int waitTime = 0; try { while (node.waitForInitialCreate(1, TimeUnit.SECONDS) == false) { waitTime += 1; log.info("Waited " + waitTime + " sec for ephemeral node to be created"); if (waitTime > maxWaitSec) { throw new IllegalStateException("Failed to create ephemeral node"); } } } catch (InterruptedException e) { throw new IllegalStateException(e); } }
[ "public", "static", "void", "startAndWait", "(", "PersistentNode", "node", ",", "int", "maxWaitSec", ")", "{", "node", ".", "start", "(", ")", ";", "int", "waitTime", "=", "0", ";", "try", "{", "while", "(", "node", ".", "waitForInitialCreate", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", "==", "false", ")", "{", "waitTime", "+=", "1", ";", "log", ".", "info", "(", "\"Waited \"", "+", "waitTime", "+", "\" sec for ephemeral node to be created\"", ")", ";", "if", "(", "waitTime", ">", "maxWaitSec", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Failed to create ephemeral node\"", ")", ";", "}", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Starts the ephemeral node and waits for it to be created @param node Node to start @param maxWaitSec Maximum time in seconds to wait
[ "Starts", "the", "ephemeral", "node", "and", "waits", "for", "it", "to", "be", "created" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java#L163-L177
163,735
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
CuratorUtil.startAppIdWatcher
public static NodeCache startAppIdWatcher(Environment env) { try { CuratorFramework curator = env.getSharedResources().getCurator(); byte[] uuidBytes = curator.getData().forPath(ZookeeperPath.CONFIG_FLUO_APPLICATION_ID); if (uuidBytes == null) { Halt.halt("Fluo Application UUID not found"); throw new RuntimeException(); // make findbugs happy } final String uuid = new String(uuidBytes, StandardCharsets.UTF_8); final NodeCache nodeCache = new NodeCache(curator, ZookeeperPath.CONFIG_FLUO_APPLICATION_ID); nodeCache.getListenable().addListener(() -> { ChildData node = nodeCache.getCurrentData(); if (node == null || !uuid.equals(new String(node.getData(), StandardCharsets.UTF_8))) { Halt.halt("Fluo Application UUID has changed or disappeared"); } }); nodeCache.start(); return nodeCache; } catch (Exception e) { throw new RuntimeException(e); } }
java
public static NodeCache startAppIdWatcher(Environment env) { try { CuratorFramework curator = env.getSharedResources().getCurator(); byte[] uuidBytes = curator.getData().forPath(ZookeeperPath.CONFIG_FLUO_APPLICATION_ID); if (uuidBytes == null) { Halt.halt("Fluo Application UUID not found"); throw new RuntimeException(); // make findbugs happy } final String uuid = new String(uuidBytes, StandardCharsets.UTF_8); final NodeCache nodeCache = new NodeCache(curator, ZookeeperPath.CONFIG_FLUO_APPLICATION_ID); nodeCache.getListenable().addListener(() -> { ChildData node = nodeCache.getCurrentData(); if (node == null || !uuid.equals(new String(node.getData(), StandardCharsets.UTF_8))) { Halt.halt("Fluo Application UUID has changed or disappeared"); } }); nodeCache.start(); return nodeCache; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "static", "NodeCache", "startAppIdWatcher", "(", "Environment", "env", ")", "{", "try", "{", "CuratorFramework", "curator", "=", "env", ".", "getSharedResources", "(", ")", ".", "getCurator", "(", ")", ";", "byte", "[", "]", "uuidBytes", "=", "curator", ".", "getData", "(", ")", ".", "forPath", "(", "ZookeeperPath", ".", "CONFIG_FLUO_APPLICATION_ID", ")", ";", "if", "(", "uuidBytes", "==", "null", ")", "{", "Halt", ".", "halt", "(", "\"Fluo Application UUID not found\"", ")", ";", "throw", "new", "RuntimeException", "(", ")", ";", "// make findbugs happy", "}", "final", "String", "uuid", "=", "new", "String", "(", "uuidBytes", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "final", "NodeCache", "nodeCache", "=", "new", "NodeCache", "(", "curator", ",", "ZookeeperPath", ".", "CONFIG_FLUO_APPLICATION_ID", ")", ";", "nodeCache", ".", "getListenable", "(", ")", ".", "addListener", "(", "(", ")", "->", "{", "ChildData", "node", "=", "nodeCache", ".", "getCurrentData", "(", ")", ";", "if", "(", "node", "==", "null", "||", "!", "uuid", ".", "equals", "(", "new", "String", "(", "node", ".", "getData", "(", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ")", ")", "{", "Halt", ".", "halt", "(", "\"Fluo Application UUID has changed or disappeared\"", ")", ";", "}", "}", ")", ";", "nodeCache", ".", "start", "(", ")", ";", "return", "nodeCache", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Start watching the fluo app uuid. If it changes or goes away then halt the process.
[ "Start", "watching", "the", "fluo", "app", "uuid", ".", "If", "it", "changes", "or", "goes", "away", "then", "halt", "the", "process", "." ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java#L182-L206
163,736
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/impl/Environment.java
Environment.readZookeeperConfig
private void readZookeeperConfig() { try (CuratorFramework curator = CuratorUtil.newAppCurator(config)) { curator.start(); accumuloInstance = new String(curator.getData().forPath(ZookeeperPath.CONFIG_ACCUMULO_INSTANCE_NAME), StandardCharsets.UTF_8); accumuloInstanceID = new String(curator.getData().forPath(ZookeeperPath.CONFIG_ACCUMULO_INSTANCE_ID), StandardCharsets.UTF_8); fluoApplicationID = new String(curator.getData().forPath(ZookeeperPath.CONFIG_FLUO_APPLICATION_ID), StandardCharsets.UTF_8); table = new String(curator.getData().forPath(ZookeeperPath.CONFIG_ACCUMULO_TABLE), StandardCharsets.UTF_8); observers = ObserverUtil.load(curator); config = FluoAdminImpl.mergeZookeeperConfig(config); // make sure not to include config passed to env, only want config from zookeeper appConfig = config.getAppConfiguration(); } catch (Exception e) { throw new IllegalStateException(e); } }
java
private void readZookeeperConfig() { try (CuratorFramework curator = CuratorUtil.newAppCurator(config)) { curator.start(); accumuloInstance = new String(curator.getData().forPath(ZookeeperPath.CONFIG_ACCUMULO_INSTANCE_NAME), StandardCharsets.UTF_8); accumuloInstanceID = new String(curator.getData().forPath(ZookeeperPath.CONFIG_ACCUMULO_INSTANCE_ID), StandardCharsets.UTF_8); fluoApplicationID = new String(curator.getData().forPath(ZookeeperPath.CONFIG_FLUO_APPLICATION_ID), StandardCharsets.UTF_8); table = new String(curator.getData().forPath(ZookeeperPath.CONFIG_ACCUMULO_TABLE), StandardCharsets.UTF_8); observers = ObserverUtil.load(curator); config = FluoAdminImpl.mergeZookeeperConfig(config); // make sure not to include config passed to env, only want config from zookeeper appConfig = config.getAppConfiguration(); } catch (Exception e) { throw new IllegalStateException(e); } }
[ "private", "void", "readZookeeperConfig", "(", ")", "{", "try", "(", "CuratorFramework", "curator", "=", "CuratorUtil", ".", "newAppCurator", "(", "config", ")", ")", "{", "curator", ".", "start", "(", ")", ";", "accumuloInstance", "=", "new", "String", "(", "curator", ".", "getData", "(", ")", ".", "forPath", "(", "ZookeeperPath", ".", "CONFIG_ACCUMULO_INSTANCE_NAME", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "accumuloInstanceID", "=", "new", "String", "(", "curator", ".", "getData", "(", ")", ".", "forPath", "(", "ZookeeperPath", ".", "CONFIG_ACCUMULO_INSTANCE_ID", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "fluoApplicationID", "=", "new", "String", "(", "curator", ".", "getData", "(", ")", ".", "forPath", "(", "ZookeeperPath", ".", "CONFIG_FLUO_APPLICATION_ID", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "table", "=", "new", "String", "(", "curator", ".", "getData", "(", ")", ".", "forPath", "(", "ZookeeperPath", ".", "CONFIG_ACCUMULO_TABLE", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "observers", "=", "ObserverUtil", ".", "load", "(", "curator", ")", ";", "config", "=", "FluoAdminImpl", ".", "mergeZookeeperConfig", "(", "config", ")", ";", "// make sure not to include config passed to env, only want config from zookeeper", "appConfig", "=", "config", ".", "getAppConfiguration", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Read configuration from zookeeper
[ "Read", "configuration", "from", "zookeeper" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/Environment.java#L133-L160
163,737
apache/fluo
modules/core/src/main/java/org/apache/fluo/core/impl/TransactorNode.java
TransactorNode.close
@Override public void close() { status = TrStatus.CLOSED; try { node.close(); } catch (IOException e) { log.error("Failed to close ephemeral node"); throw new IllegalStateException(e); } }
java
@Override public void close() { status = TrStatus.CLOSED; try { node.close(); } catch (IOException e) { log.error("Failed to close ephemeral node"); throw new IllegalStateException(e); } }
[ "@", "Override", "public", "void", "close", "(", ")", "{", "status", "=", "TrStatus", ".", "CLOSED", ";", "try", "{", "node", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"Failed to close ephemeral node\"", ")", ";", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Closes the transactor node by removing its node in Zookeeper
[ "Closes", "the", "transactor", "node", "by", "removing", "its", "node", "in", "Zookeeper" ]
8e06204d4167651e2d3b5219b8c1397644e6ba6e
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorNode.java#L89-L98
163,738
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/bean/BeanInfoIntrospector.java
BeanInfoIntrospector.expand
private static Map<String, Set<String>> expand(Map<String, Set<String>> viewToPropNames) { Set<String> baseProps = viewToPropNames.get(PropertyView.BASE_VIEW); if (baseProps == null) { baseProps = ImmutableSet.of(); } if (!SquigglyConfig.isFilterImplicitlyIncludeBaseFieldsInView()) { // make an exception for full view Set<String> fullView = viewToPropNames.get(PropertyView.FULL_VIEW); if (fullView != null) { fullView.addAll(baseProps); } return viewToPropNames; } for (Map.Entry<String, Set<String>> entry : viewToPropNames.entrySet()) { String viewName = entry.getKey(); Set<String> propNames = entry.getValue(); if (!PropertyView.BASE_VIEW.equals(viewName)) { propNames.addAll(baseProps); } } return viewToPropNames; }
java
private static Map<String, Set<String>> expand(Map<String, Set<String>> viewToPropNames) { Set<String> baseProps = viewToPropNames.get(PropertyView.BASE_VIEW); if (baseProps == null) { baseProps = ImmutableSet.of(); } if (!SquigglyConfig.isFilterImplicitlyIncludeBaseFieldsInView()) { // make an exception for full view Set<String> fullView = viewToPropNames.get(PropertyView.FULL_VIEW); if (fullView != null) { fullView.addAll(baseProps); } return viewToPropNames; } for (Map.Entry<String, Set<String>> entry : viewToPropNames.entrySet()) { String viewName = entry.getKey(); Set<String> propNames = entry.getValue(); if (!PropertyView.BASE_VIEW.equals(viewName)) { propNames.addAll(baseProps); } } return viewToPropNames; }
[ "private", "static", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "expand", "(", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "viewToPropNames", ")", "{", "Set", "<", "String", ">", "baseProps", "=", "viewToPropNames", ".", "get", "(", "PropertyView", ".", "BASE_VIEW", ")", ";", "if", "(", "baseProps", "==", "null", ")", "{", "baseProps", "=", "ImmutableSet", ".", "of", "(", ")", ";", "}", "if", "(", "!", "SquigglyConfig", ".", "isFilterImplicitlyIncludeBaseFieldsInView", "(", ")", ")", "{", "// make an exception for full view", "Set", "<", "String", ">", "fullView", "=", "viewToPropNames", ".", "get", "(", "PropertyView", ".", "FULL_VIEW", ")", ";", "if", "(", "fullView", "!=", "null", ")", "{", "fullView", ".", "addAll", "(", "baseProps", ")", ";", "}", "return", "viewToPropNames", ";", "}", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Set", "<", "String", ">", ">", "entry", ":", "viewToPropNames", ".", "entrySet", "(", ")", ")", "{", "String", "viewName", "=", "entry", ".", "getKey", "(", ")", ";", "Set", "<", "String", ">", "propNames", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "!", "PropertyView", ".", "BASE_VIEW", ".", "equals", "(", "viewName", ")", ")", "{", "propNames", ".", "addAll", "(", "baseProps", ")", ";", "}", "}", "return", "viewToPropNames", ";", "}" ]
apply the base fields to other views if configured to do so.
[ "apply", "the", "base", "fields", "to", "other", "views", "if", "configured", "to", "do", "so", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/bean/BeanInfoIntrospector.java#L191-L221
163,739
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/parser/SquigglyParser.java
SquigglyParser.parse
public List<SquigglyNode> parse(String filter) { filter = StringUtils.trim(filter); if (StringUtils.isEmpty(filter)) { return Collections.emptyList(); } // get it from the cache if we can List<SquigglyNode> cachedNodes = CACHE.getIfPresent(filter); if (cachedNodes != null) { return cachedNodes; } SquigglyExpressionLexer lexer = ThrowingErrorListener.overwrite(new SquigglyExpressionLexer(new ANTLRInputStream(filter))); SquigglyExpressionParser parser = ThrowingErrorListener.overwrite(new SquigglyExpressionParser(new CommonTokenStream(lexer))); Visitor visitor = new Visitor(); List<SquigglyNode> nodes = Collections.unmodifiableList(visitor.visit(parser.parse())); CACHE.put(filter, nodes); return nodes; }
java
public List<SquigglyNode> parse(String filter) { filter = StringUtils.trim(filter); if (StringUtils.isEmpty(filter)) { return Collections.emptyList(); } // get it from the cache if we can List<SquigglyNode> cachedNodes = CACHE.getIfPresent(filter); if (cachedNodes != null) { return cachedNodes; } SquigglyExpressionLexer lexer = ThrowingErrorListener.overwrite(new SquigglyExpressionLexer(new ANTLRInputStream(filter))); SquigglyExpressionParser parser = ThrowingErrorListener.overwrite(new SquigglyExpressionParser(new CommonTokenStream(lexer))); Visitor visitor = new Visitor(); List<SquigglyNode> nodes = Collections.unmodifiableList(visitor.visit(parser.parse())); CACHE.put(filter, nodes); return nodes; }
[ "public", "List", "<", "SquigglyNode", ">", "parse", "(", "String", "filter", ")", "{", "filter", "=", "StringUtils", ".", "trim", "(", "filter", ")", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "filter", ")", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "// get it from the cache if we can", "List", "<", "SquigglyNode", ">", "cachedNodes", "=", "CACHE", ".", "getIfPresent", "(", "filter", ")", ";", "if", "(", "cachedNodes", "!=", "null", ")", "{", "return", "cachedNodes", ";", "}", "SquigglyExpressionLexer", "lexer", "=", "ThrowingErrorListener", ".", "overwrite", "(", "new", "SquigglyExpressionLexer", "(", "new", "ANTLRInputStream", "(", "filter", ")", ")", ")", ";", "SquigglyExpressionParser", "parser", "=", "ThrowingErrorListener", ".", "overwrite", "(", "new", "SquigglyExpressionParser", "(", "new", "CommonTokenStream", "(", "lexer", ")", ")", ")", ";", "Visitor", "visitor", "=", "new", "Visitor", "(", ")", ";", "List", "<", "SquigglyNode", ">", "nodes", "=", "Collections", ".", "unmodifiableList", "(", "visitor", ".", "visit", "(", "parser", ".", "parse", "(", ")", ")", ")", ";", "CACHE", ".", "put", "(", "filter", ",", "nodes", ")", ";", "return", "nodes", ";", "}" ]
Parse a filter expression. @param filter the filter expression @return compiled nodes
[ "Parse", "a", "filter", "expression", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/parser/SquigglyParser.java#L43-L66
163,740
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.collectify
public static <E> Collection<E> collectify(ObjectMapper mapper, Object source, Class<? extends Collection> targetCollectionType, Class<E> targetElementType) { CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(targetCollectionType, targetElementType); return objectify(mapper, convertToCollection(source), collectionType); }
java
public static <E> Collection<E> collectify(ObjectMapper mapper, Object source, Class<? extends Collection> targetCollectionType, Class<E> targetElementType) { CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(targetCollectionType, targetElementType); return objectify(mapper, convertToCollection(source), collectionType); }
[ "public", "static", "<", "E", ">", "Collection", "<", "E", ">", "collectify", "(", "ObjectMapper", "mapper", ",", "Object", "source", ",", "Class", "<", "?", "extends", "Collection", ">", "targetCollectionType", ",", "Class", "<", "E", ">", "targetElementType", ")", "{", "CollectionType", "collectionType", "=", "mapper", ".", "getTypeFactory", "(", ")", ".", "constructCollectionType", "(", "targetCollectionType", ",", "targetElementType", ")", ";", "return", "objectify", "(", "mapper", ",", "convertToCollection", "(", "source", ")", ",", "collectionType", ")", ";", "}" ]
Convert an object to a collection. @param mapper the object mapper @param source the source object @param targetCollectionType the target collection type @param targetElementType the target collection element type @return collection
[ "Convert", "an", "object", "to", "a", "collection", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L45-L48
163,741
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.listify
public static List<Map<String, Object>> listify(ObjectMapper mapper, Object source) { return (List<Map<String, Object>>) collectify(mapper, source, List.class); }
java
public static List<Map<String, Object>> listify(ObjectMapper mapper, Object source) { return (List<Map<String, Object>>) collectify(mapper, source, List.class); }
[ "public", "static", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listify", "(", "ObjectMapper", "mapper", ",", "Object", "source", ")", "{", "return", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "collectify", "(", "mapper", ",", "source", ",", "List", ".", "class", ")", ";", "}" ]
Convert an object to a list of maps. @param mapper the object mapper @param source the source object @return list
[ "Convert", "an", "object", "to", "a", "list", "of", "maps", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L99-L101
163,742
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.listify
public static <E> List<E> listify(ObjectMapper mapper, Object source, Class<E> targetElementType) { return (List<E>) collectify(mapper, source, List.class, targetElementType); }
java
public static <E> List<E> listify(ObjectMapper mapper, Object source, Class<E> targetElementType) { return (List<E>) collectify(mapper, source, List.class, targetElementType); }
[ "public", "static", "<", "E", ">", "List", "<", "E", ">", "listify", "(", "ObjectMapper", "mapper", ",", "Object", "source", ",", "Class", "<", "E", ">", "targetElementType", ")", "{", "return", "(", "List", "<", "E", ">", ")", "collectify", "(", "mapper", ",", "source", ",", "List", ".", "class", ",", "targetElementType", ")", ";", "}" ]
Convert an object to a list. @param mapper the object mapper @param source the source object @param targetElementType the target list element type @return list
[ "Convert", "an", "object", "to", "a", "list", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L111-L113
163,743
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.objectify
public static Object objectify(ObjectMapper mapper, Object source) { return objectify(mapper, source, Object.class); }
java
public static Object objectify(ObjectMapper mapper, Object source) { return objectify(mapper, source, Object.class); }
[ "public", "static", "Object", "objectify", "(", "ObjectMapper", "mapper", ",", "Object", "source", ")", "{", "return", "objectify", "(", "mapper", ",", "source", ",", "Object", ".", "class", ")", ";", "}" ]
Converts an object to an object, with squiggly filters applied. @param mapper the object mapper @param source the source to convert @return target instance @see SquigglyUtils#objectify(ObjectMapper, Object, Class)
[ "Converts", "an", "object", "to", "an", "object", "with", "squiggly", "filters", "applied", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L148-L150
163,744
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.objectify
public static <T> T objectify(ObjectMapper mapper, Object source, JavaType targetType) { try { return mapper.readValue(mapper.writeValueAsBytes(source), targetType); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
java
public static <T> T objectify(ObjectMapper mapper, Object source, JavaType targetType) { try { return mapper.readValue(mapper.writeValueAsBytes(source), targetType); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "static", "<", "T", ">", "T", "objectify", "(", "ObjectMapper", "mapper", ",", "Object", "source", ",", "JavaType", "targetType", ")", "{", "try", "{", "return", "mapper", ".", "readValue", "(", "mapper", ".", "writeValueAsBytes", "(", "source", ")", ",", "targetType", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Converts an object to an instance of the target type. @param mapper the object mapper @param source the source to convert @param targetType the target class type @return target instance @see SquigglyUtils#objectify(ObjectMapper, Object, Class)
[ "Converts", "an", "object", "to", "an", "instance", "of", "the", "target", "type", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L176-L184
163,745
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.setify
public static Set<Map<String, Object>> setify(ObjectMapper mapper, Object source) { return (Set<Map<String, Object>>) collectify(mapper, source, Set.class); }
java
public static Set<Map<String, Object>> setify(ObjectMapper mapper, Object source) { return (Set<Map<String, Object>>) collectify(mapper, source, Set.class); }
[ "public", "static", "Set", "<", "Map", "<", "String", ",", "Object", ">", ">", "setify", "(", "ObjectMapper", "mapper", ",", "Object", "source", ")", "{", "return", "(", "Set", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "collectify", "(", "mapper", ",", "source", ",", "Set", ".", "class", ")", ";", "}" ]
Convert an object to a set of maps. @param mapper the object mapper @param source the source object @return set
[ "Convert", "an", "object", "to", "a", "set", "of", "maps", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L193-L195
163,746
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.setify
public static <E> Set<E> setify(ObjectMapper mapper, Object source, Class<E> targetElementType) { return (Set<E>) collectify(mapper, source, Set.class, targetElementType); }
java
public static <E> Set<E> setify(ObjectMapper mapper, Object source, Class<E> targetElementType) { return (Set<E>) collectify(mapper, source, Set.class, targetElementType); }
[ "public", "static", "<", "E", ">", "Set", "<", "E", ">", "setify", "(", "ObjectMapper", "mapper", ",", "Object", "source", ",", "Class", "<", "E", ">", "targetElementType", ")", "{", "return", "(", "Set", "<", "E", ">", ")", "collectify", "(", "mapper", ",", "source", ",", "Set", ".", "class", ",", "targetElementType", ")", ";", "}" ]
Convert an object to a set. @param mapper the object mapper @param source the source object @param targetElementType the target set element type @return set
[ "Convert", "an", "object", "to", "a", "set", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L205-L207
163,747
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java
SquigglyUtils.stringify
public static String stringify(ObjectMapper mapper, Object object) { try { return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { throw new IllegalArgumentException(e); } }
java
public static String stringify(ObjectMapper mapper, Object object) { try { return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { throw new IllegalArgumentException(e); } }
[ "public", "static", "String", "stringify", "(", "ObjectMapper", "mapper", ",", "Object", "object", ")", "{", "try", "{", "return", "mapper", ".", "writeValueAsString", "(", "object", ")", ";", "}", "catch", "(", "JsonProcessingException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "}" ]
Takes an object and converts it to a string. @param mapper the object mapper @param object the object to convert @return json string
[ "Takes", "an", "object", "and", "converts", "it", "to", "a", "string", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/util/SquigglyUtils.java#L241-L247
163,748
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/filter/SquigglyPropertyFilter.java
SquigglyPropertyFilter.getPath
private Path getPath(PropertyWriter writer, JsonStreamContext sc) { LinkedList<PathElement> elements = new LinkedList<>(); if (sc != null) { elements.add(new PathElement(writer.getName(), sc.getCurrentValue())); sc = sc.getParent(); } while (sc != null) { if (sc.getCurrentName() != null && sc.getCurrentValue() != null) { elements.addFirst(new PathElement(sc.getCurrentName(), sc.getCurrentValue())); } sc = sc.getParent(); } return new Path(elements); }
java
private Path getPath(PropertyWriter writer, JsonStreamContext sc) { LinkedList<PathElement> elements = new LinkedList<>(); if (sc != null) { elements.add(new PathElement(writer.getName(), sc.getCurrentValue())); sc = sc.getParent(); } while (sc != null) { if (sc.getCurrentName() != null && sc.getCurrentValue() != null) { elements.addFirst(new PathElement(sc.getCurrentName(), sc.getCurrentValue())); } sc = sc.getParent(); } return new Path(elements); }
[ "private", "Path", "getPath", "(", "PropertyWriter", "writer", ",", "JsonStreamContext", "sc", ")", "{", "LinkedList", "<", "PathElement", ">", "elements", "=", "new", "LinkedList", "<>", "(", ")", ";", "if", "(", "sc", "!=", "null", ")", "{", "elements", ".", "add", "(", "new", "PathElement", "(", "writer", ".", "getName", "(", ")", ",", "sc", ".", "getCurrentValue", "(", ")", ")", ")", ";", "sc", "=", "sc", ".", "getParent", "(", ")", ";", "}", "while", "(", "sc", "!=", "null", ")", "{", "if", "(", "sc", ".", "getCurrentName", "(", ")", "!=", "null", "&&", "sc", ".", "getCurrentValue", "(", ")", "!=", "null", ")", "{", "elements", ".", "addFirst", "(", "new", "PathElement", "(", "sc", ".", "getCurrentName", "(", ")", ",", "sc", ".", "getCurrentValue", "(", ")", ")", ")", ";", "}", "sc", "=", "sc", ".", "getParent", "(", ")", ";", "}", "return", "new", "Path", "(", "elements", ")", ";", "}" ]
create a path structure representing the object graph
[ "create", "a", "path", "structure", "representing", "the", "object", "graph" ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/filter/SquigglyPropertyFilter.java#L110-L126
163,749
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/filter/SquigglyPropertyFilter.java
SquigglyPropertyFilter.pathMatches
private boolean pathMatches(Path path, SquigglyContext context) { List<SquigglyNode> nodes = context.getNodes(); Set<String> viewStack = null; SquigglyNode viewNode = null; int pathSize = path.getElements().size(); int lastIdx = pathSize - 1; for (int i = 0; i < pathSize; i++) { PathElement element = path.getElements().get(i); if (viewNode != null && !viewNode.isSquiggly()) { Class beanClass = element.getBeanClass(); if (beanClass != null && !Map.class.isAssignableFrom(beanClass)) { Set<String> propertyNames = getPropertyNamesFromViewStack(element, viewStack); if (!propertyNames.contains(element.getName())) { return false; } } } else if (nodes.isEmpty()) { return false; } else { SquigglyNode match = findBestSimpleNode(element, nodes); if (match == null) { match = findBestViewNode(element, nodes); if (match != null) { viewNode = match; viewStack = addToViewStack(viewStack, viewNode); } } else if (match.isAnyShallow()) { viewNode = match; } else if (match.isAnyDeep()) { return true; } if (match == null) { if (isJsonUnwrapped(element)) { continue; } return false; } if (match.isNegated()) { return false; } nodes = match.getChildren(); if (i < lastIdx && nodes.isEmpty() && !match.isEmptyNested() && SquigglyConfig.isFilterImplicitlyIncludeBaseFields()) { nodes = BASE_VIEW_NODES; } } } return true; }
java
private boolean pathMatches(Path path, SquigglyContext context) { List<SquigglyNode> nodes = context.getNodes(); Set<String> viewStack = null; SquigglyNode viewNode = null; int pathSize = path.getElements().size(); int lastIdx = pathSize - 1; for (int i = 0; i < pathSize; i++) { PathElement element = path.getElements().get(i); if (viewNode != null && !viewNode.isSquiggly()) { Class beanClass = element.getBeanClass(); if (beanClass != null && !Map.class.isAssignableFrom(beanClass)) { Set<String> propertyNames = getPropertyNamesFromViewStack(element, viewStack); if (!propertyNames.contains(element.getName())) { return false; } } } else if (nodes.isEmpty()) { return false; } else { SquigglyNode match = findBestSimpleNode(element, nodes); if (match == null) { match = findBestViewNode(element, nodes); if (match != null) { viewNode = match; viewStack = addToViewStack(viewStack, viewNode); } } else if (match.isAnyShallow()) { viewNode = match; } else if (match.isAnyDeep()) { return true; } if (match == null) { if (isJsonUnwrapped(element)) { continue; } return false; } if (match.isNegated()) { return false; } nodes = match.getChildren(); if (i < lastIdx && nodes.isEmpty() && !match.isEmptyNested() && SquigglyConfig.isFilterImplicitlyIncludeBaseFields()) { nodes = BASE_VIEW_NODES; } } } return true; }
[ "private", "boolean", "pathMatches", "(", "Path", "path", ",", "SquigglyContext", "context", ")", "{", "List", "<", "SquigglyNode", ">", "nodes", "=", "context", ".", "getNodes", "(", ")", ";", "Set", "<", "String", ">", "viewStack", "=", "null", ";", "SquigglyNode", "viewNode", "=", "null", ";", "int", "pathSize", "=", "path", ".", "getElements", "(", ")", ".", "size", "(", ")", ";", "int", "lastIdx", "=", "pathSize", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pathSize", ";", "i", "++", ")", "{", "PathElement", "element", "=", "path", ".", "getElements", "(", ")", ".", "get", "(", "i", ")", ";", "if", "(", "viewNode", "!=", "null", "&&", "!", "viewNode", ".", "isSquiggly", "(", ")", ")", "{", "Class", "beanClass", "=", "element", ".", "getBeanClass", "(", ")", ";", "if", "(", "beanClass", "!=", "null", "&&", "!", "Map", ".", "class", ".", "isAssignableFrom", "(", "beanClass", ")", ")", "{", "Set", "<", "String", ">", "propertyNames", "=", "getPropertyNamesFromViewStack", "(", "element", ",", "viewStack", ")", ";", "if", "(", "!", "propertyNames", ".", "contains", "(", "element", ".", "getName", "(", ")", ")", ")", "{", "return", "false", ";", "}", "}", "}", "else", "if", "(", "nodes", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "else", "{", "SquigglyNode", "match", "=", "findBestSimpleNode", "(", "element", ",", "nodes", ")", ";", "if", "(", "match", "==", "null", ")", "{", "match", "=", "findBestViewNode", "(", "element", ",", "nodes", ")", ";", "if", "(", "match", "!=", "null", ")", "{", "viewNode", "=", "match", ";", "viewStack", "=", "addToViewStack", "(", "viewStack", ",", "viewNode", ")", ";", "}", "}", "else", "if", "(", "match", ".", "isAnyShallow", "(", ")", ")", "{", "viewNode", "=", "match", ";", "}", "else", "if", "(", "match", ".", "isAnyDeep", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "match", "==", "null", ")", "{", "if", "(", "isJsonUnwrapped", "(", "element", ")", ")", "{", "continue", ";", "}", "return", "false", ";", "}", "if", "(", "match", ".", "isNegated", "(", ")", ")", "{", "return", "false", ";", "}", "nodes", "=", "match", ".", "getChildren", "(", ")", ";", "if", "(", "i", "<", "lastIdx", "&&", "nodes", ".", "isEmpty", "(", ")", "&&", "!", "match", ".", "isEmptyNested", "(", ")", "&&", "SquigglyConfig", ".", "isFilterImplicitlyIncludeBaseFields", "(", ")", ")", "{", "nodes", "=", "BASE_VIEW_NODES", ";", "}", "}", "}", "return", "true", ";", "}" ]
perform the actual matching
[ "perform", "the", "actual", "matching" ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/filter/SquigglyPropertyFilter.java#L180-L242
163,750
bohnman/squiggly-java
src/main/java/com/github/bohnman/squiggly/metric/SquigglyMetrics.java
SquigglyMetrics.asMap
public static SortedMap<String, Object> asMap() { SortedMap<String, Object> metrics = Maps.newTreeMap(); METRICS_SOURCE.applyMetrics(metrics); return metrics; }
java
public static SortedMap<String, Object> asMap() { SortedMap<String, Object> metrics = Maps.newTreeMap(); METRICS_SOURCE.applyMetrics(metrics); return metrics; }
[ "public", "static", "SortedMap", "<", "String", ",", "Object", ">", "asMap", "(", ")", "{", "SortedMap", "<", "String", ",", "Object", ">", "metrics", "=", "Maps", ".", "newTreeMap", "(", ")", ";", "METRICS_SOURCE", ".", "applyMetrics", "(", "metrics", ")", ";", "return", "metrics", ";", "}" ]
Gets the metrics as a map whose keys are the metric name and whose values are the metric values. @return map
[ "Gets", "the", "metrics", "as", "a", "map", "whose", "keys", "are", "the", "metric", "name", "and", "whose", "values", "are", "the", "metric", "values", "." ]
ba0c0b924ab718225d1ad180273ee63ea6c4f55a
https://github.com/bohnman/squiggly-java/blob/ba0c0b924ab718225d1ad180273ee63ea6c4f55a/src/main/java/com/github/bohnman/squiggly/metric/SquigglyMetrics.java#L37-L41
163,751
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/UnsafeUtil.java
UnsafeUtil.newDirectByteBuffer
public static ByteBuffer newDirectByteBuffer(long addr, int size, Object att) { dbbCC.setAccessible(true); Object b = null; try { b = dbbCC.newInstance(new Long(addr), new Integer(size), att); return ByteBuffer.class.cast(b); } catch(Exception e) { throw new IllegalStateException(String.format("Failed to create DirectByteBuffer: %s", e.getMessage())); } }
java
public static ByteBuffer newDirectByteBuffer(long addr, int size, Object att) { dbbCC.setAccessible(true); Object b = null; try { b = dbbCC.newInstance(new Long(addr), new Integer(size), att); return ByteBuffer.class.cast(b); } catch(Exception e) { throw new IllegalStateException(String.format("Failed to create DirectByteBuffer: %s", e.getMessage())); } }
[ "public", "static", "ByteBuffer", "newDirectByteBuffer", "(", "long", "addr", ",", "int", "size", ",", "Object", "att", ")", "{", "dbbCC", ".", "setAccessible", "(", "true", ")", ";", "Object", "b", "=", "null", ";", "try", "{", "b", "=", "dbbCC", ".", "newInstance", "(", "new", "Long", "(", "addr", ")", ",", "new", "Integer", "(", "size", ")", ",", "att", ")", ";", "return", "ByteBuffer", ".", "class", ".", "cast", "(", "b", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"Failed to create DirectByteBuffer: %s\"", ",", "e", ".", "getMessage", "(", ")", ")", ")", ";", "}", "}" ]
Create a new DirectByteBuffer from a given address and size. The returned DirectByteBuffer does not release the memory by itself. @param addr @param size @param att object holding the underlying memory to attach to the buffer. This will prevent the garbage collection of the memory area that's associated with the new <code>DirectByteBuffer</code> @return
[ "Create", "a", "new", "DirectByteBuffer", "from", "a", "given", "address", "and", "size", ".", "The", "returned", "DirectByteBuffer", "does", "not", "release", "the", "memory", "by", "itself", "." ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/UnsafeUtil.java#L57-L67
163,752
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/DefaultMemoryAllocator.java
DefaultMemoryAllocator.releaseAll
public void releaseAll() { synchronized(this) { Object[] refSet = allocatedMemoryReferences.values().toArray(); if(refSet.length != 0) { logger.finer("Releasing allocated memory regions"); } for(Object ref : refSet) { release((MemoryReference) ref); } } }
java
public void releaseAll() { synchronized(this) { Object[] refSet = allocatedMemoryReferences.values().toArray(); if(refSet.length != 0) { logger.finer("Releasing allocated memory regions"); } for(Object ref : refSet) { release((MemoryReference) ref); } } }
[ "public", "void", "releaseAll", "(", ")", "{", "synchronized", "(", "this", ")", "{", "Object", "[", "]", "refSet", "=", "allocatedMemoryReferences", ".", "values", "(", ")", ".", "toArray", "(", ")", ";", "if", "(", "refSet", ".", "length", "!=", "0", ")", "{", "logger", ".", "finer", "(", "\"Releasing allocated memory regions\"", ")", ";", "}", "for", "(", "Object", "ref", ":", "refSet", ")", "{", "release", "(", "(", "MemoryReference", ")", "ref", ")", ";", "}", "}", "}" ]
Release all memory addresses taken by this allocator. Be careful in using this method, since all of the memory addresses become invalid.
[ "Release", "all", "memory", "addresses", "taken", "by", "this", "allocator", ".", "Be", "careful", "in", "using", "this", "method", "since", "all", "of", "the", "memory", "addresses", "become", "invalid", "." ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/DefaultMemoryAllocator.java#L88-L98
163,753
xerial/larray
larray-mmap/src/main/java/xerial/larray/impl/LArrayLoader.java
LArrayLoader.md5sum
public static String md5sum(InputStream input) throws IOException { InputStream in = new BufferedInputStream(input); try { MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); DigestInputStream digestInputStream = new DigestInputStream(in, digest); while(digestInputStream.read() >= 0) { } OutputStream md5out = new ByteArrayOutputStream(); md5out.write(digest.digest()); return md5out.toString(); } catch(NoSuchAlgorithmException e) { throw new IllegalStateException("MD5 algorithm is not available: " + e.getMessage()); } finally { in.close(); } }
java
public static String md5sum(InputStream input) throws IOException { InputStream in = new BufferedInputStream(input); try { MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); DigestInputStream digestInputStream = new DigestInputStream(in, digest); while(digestInputStream.read() >= 0) { } OutputStream md5out = new ByteArrayOutputStream(); md5out.write(digest.digest()); return md5out.toString(); } catch(NoSuchAlgorithmException e) { throw new IllegalStateException("MD5 algorithm is not available: " + e.getMessage()); } finally { in.close(); } }
[ "public", "static", "String", "md5sum", "(", "InputStream", "input", ")", "throws", "IOException", "{", "InputStream", "in", "=", "new", "BufferedInputStream", "(", "input", ")", ";", "try", "{", "MessageDigest", "digest", "=", "java", ".", "security", ".", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ";", "DigestInputStream", "digestInputStream", "=", "new", "DigestInputStream", "(", "in", ",", "digest", ")", ";", "while", "(", "digestInputStream", ".", "read", "(", ")", ">=", "0", ")", "{", "}", "OutputStream", "md5out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "md5out", ".", "write", "(", "digest", ".", "digest", "(", ")", ")", ";", "return", "md5out", ".", "toString", "(", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"MD5 algorithm is not available: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "finally", "{", "in", ".", "close", "(", ")", ";", "}", "}" ]
Computes the MD5 value of the input stream @param input @return @throws IOException @throws IllegalStateException
[ "Computes", "the", "MD5", "value", "of", "the", "input", "stream" ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-mmap/src/main/java/xerial/larray/impl/LArrayLoader.java#L103-L120
163,754
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.fill
public void fill(long offset, long length, byte value) { unsafe.setMemory(address() + offset, length, value); }
java
public void fill(long offset, long length, byte value) { unsafe.setMemory(address() + offset, length, value); }
[ "public", "void", "fill", "(", "long", "offset", ",", "long", "length", ",", "byte", "value", ")", "{", "unsafe", ".", "setMemory", "(", "address", "(", ")", "+", "offset", ",", "length", ",", "value", ")", ";", "}" ]
Fill the buffer of the specified range with a given value @param offset @param length @param value
[ "Fill", "the", "buffer", "of", "the", "specified", "range", "with", "a", "given", "value" ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L113-L115
163,755
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.copyTo
public void copyTo(int srcOffset, byte[] destArray, int destOffset, int size) { int cursor = destOffset; for (ByteBuffer bb : toDirectByteBuffers(srcOffset, size)) { int bbSize = bb.remaining(); if ((cursor + bbSize) > destArray.length) throw new ArrayIndexOutOfBoundsException(String.format("cursor + bbSize = %,d", cursor + bbSize)); bb.get(destArray, cursor, bbSize); cursor += bbSize; } }
java
public void copyTo(int srcOffset, byte[] destArray, int destOffset, int size) { int cursor = destOffset; for (ByteBuffer bb : toDirectByteBuffers(srcOffset, size)) { int bbSize = bb.remaining(); if ((cursor + bbSize) > destArray.length) throw new ArrayIndexOutOfBoundsException(String.format("cursor + bbSize = %,d", cursor + bbSize)); bb.get(destArray, cursor, bbSize); cursor += bbSize; } }
[ "public", "void", "copyTo", "(", "int", "srcOffset", ",", "byte", "[", "]", "destArray", ",", "int", "destOffset", ",", "int", "size", ")", "{", "int", "cursor", "=", "destOffset", ";", "for", "(", "ByteBuffer", "bb", ":", "toDirectByteBuffers", "(", "srcOffset", ",", "size", ")", ")", "{", "int", "bbSize", "=", "bb", ".", "remaining", "(", ")", ";", "if", "(", "(", "cursor", "+", "bbSize", ")", ">", "destArray", ".", "length", ")", "throw", "new", "ArrayIndexOutOfBoundsException", "(", "String", ".", "format", "(", "\"cursor + bbSize = %,d\"", ",", "cursor", "+", "bbSize", ")", ")", ";", "bb", ".", "get", "(", "destArray", ",", "cursor", ",", "bbSize", ")", ";", "cursor", "+=", "bbSize", ";", "}", "}" ]
Copy the contents of this buffer begginning from the srcOffset to a destination byte array @param srcOffset @param destArray @param destOffset @param size
[ "Copy", "the", "contents", "of", "this", "buffer", "begginning", "from", "the", "srcOffset", "to", "a", "destination", "byte", "array" ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L237-L246
163,756
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.copyTo
public void copyTo(long srcOffset, LBufferAPI dest, long destOffset, long size) { unsafe.copyMemory(address() + srcOffset, dest.address() + destOffset, size); }
java
public void copyTo(long srcOffset, LBufferAPI dest, long destOffset, long size) { unsafe.copyMemory(address() + srcOffset, dest.address() + destOffset, size); }
[ "public", "void", "copyTo", "(", "long", "srcOffset", ",", "LBufferAPI", "dest", ",", "long", "destOffset", ",", "long", "size", ")", "{", "unsafe", ".", "copyMemory", "(", "address", "(", ")", "+", "srcOffset", ",", "dest", ".", "address", "(", ")", "+", "destOffset", ",", "size", ")", ";", "}" ]
Copy the contents of this buffer to the destination LBuffer @param srcOffset @param dest @param destOffset @param size
[ "Copy", "the", "contents", "of", "this", "buffer", "to", "the", "destination", "LBuffer" ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L255-L257
163,757
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.slice
public LBuffer slice(long from, long to) { if(from > to) throw new IllegalArgumentException(String.format("invalid range %,d to %,d", from, to)); long size = to - from; LBuffer b = new LBuffer(size); copyTo(from, b, 0, size); return b; }
java
public LBuffer slice(long from, long to) { if(from > to) throw new IllegalArgumentException(String.format("invalid range %,d to %,d", from, to)); long size = to - from; LBuffer b = new LBuffer(size); copyTo(from, b, 0, size); return b; }
[ "public", "LBuffer", "slice", "(", "long", "from", ",", "long", "to", ")", "{", "if", "(", "from", ">", "to", ")", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"invalid range %,d to %,d\"", ",", "from", ",", "to", ")", ")", ";", "long", "size", "=", "to", "-", "from", ";", "LBuffer", "b", "=", "new", "LBuffer", "(", "size", ")", ";", "copyTo", "(", "from", ",", "b", ",", "0", ",", "size", ")", ";", "return", "b", ";", "}" ]
Extract a slice [from, to) of this buffer. This methods creates a copy of the specified region. @param from @param to @return
[ "Extract", "a", "slice", "[", "from", "to", ")", "of", "this", "buffer", ".", "This", "methods", "creates", "a", "copy", "of", "the", "specified", "region", "." ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L265-L273
163,758
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.toArray
public byte[] toArray() { if (size() > Integer.MAX_VALUE) throw new IllegalStateException("Cannot create byte array of more than 2GB"); int len = (int) size(); ByteBuffer bb = toDirectByteBuffer(0L, len); byte[] b = new byte[len]; // Copy data to the array bb.get(b, 0, len); return b; }
java
public byte[] toArray() { if (size() > Integer.MAX_VALUE) throw new IllegalStateException("Cannot create byte array of more than 2GB"); int len = (int) size(); ByteBuffer bb = toDirectByteBuffer(0L, len); byte[] b = new byte[len]; // Copy data to the array bb.get(b, 0, len); return b; }
[ "public", "byte", "[", "]", "toArray", "(", ")", "{", "if", "(", "size", "(", ")", ">", "Integer", ".", "MAX_VALUE", ")", "throw", "new", "IllegalStateException", "(", "\"Cannot create byte array of more than 2GB\"", ")", ";", "int", "len", "=", "(", "int", ")", "size", "(", ")", ";", "ByteBuffer", "bb", "=", "toDirectByteBuffer", "(", "0L", ",", "len", ")", ";", "byte", "[", "]", "b", "=", "new", "byte", "[", "len", "]", ";", "// Copy data to the array", "bb", ".", "get", "(", "b", ",", "0", ",", "len", ")", ";", "return", "b", ";", "}" ]
Convert this buffer to a java array. @return
[ "Convert", "this", "buffer", "to", "a", "java", "array", "." ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L293-L303
163,759
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.writeTo
public void writeTo(WritableByteChannel channel) throws IOException { for (ByteBuffer buffer : toDirectByteBuffers()) { channel.write(buffer); } }
java
public void writeTo(WritableByteChannel channel) throws IOException { for (ByteBuffer buffer : toDirectByteBuffers()) { channel.write(buffer); } }
[ "public", "void", "writeTo", "(", "WritableByteChannel", "channel", ")", "throws", "IOException", "{", "for", "(", "ByteBuffer", "buffer", ":", "toDirectByteBuffers", "(", ")", ")", "{", "channel", ".", "write", "(", "buffer", ")", ";", "}", "}" ]
Writes the buffer contents to the given byte channel. @param channel @throws IOException
[ "Writes", "the", "buffer", "contents", "to", "the", "given", "byte", "channel", "." ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L331-L335
163,760
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.writeTo
public void writeTo(File file) throws IOException { FileChannel channel = new FileOutputStream(file).getChannel(); try { writeTo(channel); } finally { channel.close(); } }
java
public void writeTo(File file) throws IOException { FileChannel channel = new FileOutputStream(file).getChannel(); try { writeTo(channel); } finally { channel.close(); } }
[ "public", "void", "writeTo", "(", "File", "file", ")", "throws", "IOException", "{", "FileChannel", "channel", "=", "new", "FileOutputStream", "(", "file", ")", ".", "getChannel", "(", ")", ";", "try", "{", "writeTo", "(", "channel", ")", ";", "}", "finally", "{", "channel", ".", "close", "(", ")", ";", "}", "}" ]
Dump the buffer contents to a file @param file @throws IOException
[ "Dump", "the", "buffer", "contents", "to", "a", "file" ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L342-L349
163,761
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.readFrom
public int readFrom(byte[] src, int srcOffset, long destOffset, int length) { int readLen = (int) Math.min(src.length - srcOffset, Math.min(size() - destOffset, length)); ByteBuffer b = toDirectByteBuffer(destOffset, readLen); b.position(0); b.put(src, srcOffset, readLen); return readLen; }
java
public int readFrom(byte[] src, int srcOffset, long destOffset, int length) { int readLen = (int) Math.min(src.length - srcOffset, Math.min(size() - destOffset, length)); ByteBuffer b = toDirectByteBuffer(destOffset, readLen); b.position(0); b.put(src, srcOffset, readLen); return readLen; }
[ "public", "int", "readFrom", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ",", "long", "destOffset", ",", "int", "length", ")", "{", "int", "readLen", "=", "(", "int", ")", "Math", ".", "min", "(", "src", ".", "length", "-", "srcOffset", ",", "Math", ".", "min", "(", "size", "(", ")", "-", "destOffset", ",", "length", ")", ")", ";", "ByteBuffer", "b", "=", "toDirectByteBuffer", "(", "destOffset", ",", "readLen", ")", ";", "b", ".", "position", "(", "0", ")", ";", "b", ".", "put", "(", "src", ",", "srcOffset", ",", "readLen", ")", ";", "return", "readLen", ";", "}" ]
Read the given source byte array, then overwrite this buffer's contents @param src source byte array @param srcOffset offset in source byte array to read from @param destOffset offset in this buffer to read to @param length max number of bytes to read @return the number of bytes read
[ "Read", "the", "given", "source", "byte", "array", "then", "overwrite", "this", "buffer", "s", "contents" ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L371-L377
163,762
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.readFrom
public int readFrom(ByteBuffer src, long destOffset) { if (src.remaining() + destOffset >= size()) throw new BufferOverflowException(); int readLen = src.remaining(); ByteBuffer b = toDirectByteBuffer(destOffset, readLen); b.position(0); b.put(src); return readLen; }
java
public int readFrom(ByteBuffer src, long destOffset) { if (src.remaining() + destOffset >= size()) throw new BufferOverflowException(); int readLen = src.remaining(); ByteBuffer b = toDirectByteBuffer(destOffset, readLen); b.position(0); b.put(src); return readLen; }
[ "public", "int", "readFrom", "(", "ByteBuffer", "src", ",", "long", "destOffset", ")", "{", "if", "(", "src", ".", "remaining", "(", ")", "+", "destOffset", ">=", "size", "(", ")", ")", "throw", "new", "BufferOverflowException", "(", ")", ";", "int", "readLen", "=", "src", ".", "remaining", "(", ")", ";", "ByteBuffer", "b", "=", "toDirectByteBuffer", "(", "destOffset", ",", "readLen", ")", ";", "b", ".", "position", "(", "0", ")", ";", "b", ".", "put", "(", "src", ")", ";", "return", "readLen", ";", "}" ]
Reads the given source byte buffer into this buffer at the given offset @param src source byte buffer @param destOffset offset in this buffer to read to @return the number of bytes read
[ "Reads", "the", "given", "source", "byte", "buffer", "into", "this", "buffer", "at", "the", "given", "offset" ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L385-L393
163,763
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.loadFrom
public static LBuffer loadFrom(File file) throws IOException { FileChannel fin = new FileInputStream(file).getChannel(); long fileSize = fin.size(); if (fileSize > Integer.MAX_VALUE) throw new IllegalArgumentException("Cannot load from file more than 2GB: " + file); LBuffer b = new LBuffer((int) fileSize); long pos = 0L; WritableChannelWrap ch = new WritableChannelWrap(b); while (pos < fileSize) { pos += fin.transferTo(0, fileSize, ch); } return b; }
java
public static LBuffer loadFrom(File file) throws IOException { FileChannel fin = new FileInputStream(file).getChannel(); long fileSize = fin.size(); if (fileSize > Integer.MAX_VALUE) throw new IllegalArgumentException("Cannot load from file more than 2GB: " + file); LBuffer b = new LBuffer((int) fileSize); long pos = 0L; WritableChannelWrap ch = new WritableChannelWrap(b); while (pos < fileSize) { pos += fin.transferTo(0, fileSize, ch); } return b; }
[ "public", "static", "LBuffer", "loadFrom", "(", "File", "file", ")", "throws", "IOException", "{", "FileChannel", "fin", "=", "new", "FileInputStream", "(", "file", ")", ".", "getChannel", "(", ")", ";", "long", "fileSize", "=", "fin", ".", "size", "(", ")", ";", "if", "(", "fileSize", ">", "Integer", ".", "MAX_VALUE", ")", "throw", "new", "IllegalArgumentException", "(", "\"Cannot load from file more than 2GB: \"", "+", "file", ")", ";", "LBuffer", "b", "=", "new", "LBuffer", "(", "(", "int", ")", "fileSize", ")", ";", "long", "pos", "=", "0L", ";", "WritableChannelWrap", "ch", "=", "new", "WritableChannelWrap", "(", "b", ")", ";", "while", "(", "pos", "<", "fileSize", ")", "{", "pos", "+=", "fin", ".", "transferTo", "(", "0", ",", "fileSize", ",", "ch", ")", ";", "}", "return", "b", ";", "}" ]
Create an LBuffer from a given file. @param file @return @throws IOException
[ "Create", "an", "LBuffer", "from", "a", "given", "file", "." ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L401-L413
163,764
xerial/larray
larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java
LBufferAPI.toDirectByteBuffers
public ByteBuffer[] toDirectByteBuffers(long offset, long size) { long pos = offset; long blockSize = Integer.MAX_VALUE; long limit = offset + size; int numBuffers = (int) ((size + (blockSize - 1)) / blockSize); ByteBuffer[] result = new ByteBuffer[numBuffers]; int index = 0; while (pos < limit) { long blockLength = Math.min(limit - pos, blockSize); result[index++] = UnsafeUtil.newDirectByteBuffer(address() + pos, (int) blockLength, this) .order(ByteOrder.nativeOrder()); pos += blockLength; } return result; }
java
public ByteBuffer[] toDirectByteBuffers(long offset, long size) { long pos = offset; long blockSize = Integer.MAX_VALUE; long limit = offset + size; int numBuffers = (int) ((size + (blockSize - 1)) / blockSize); ByteBuffer[] result = new ByteBuffer[numBuffers]; int index = 0; while (pos < limit) { long blockLength = Math.min(limit - pos, blockSize); result[index++] = UnsafeUtil.newDirectByteBuffer(address() + pos, (int) blockLength, this) .order(ByteOrder.nativeOrder()); pos += blockLength; } return result; }
[ "public", "ByteBuffer", "[", "]", "toDirectByteBuffers", "(", "long", "offset", ",", "long", "size", ")", "{", "long", "pos", "=", "offset", ";", "long", "blockSize", "=", "Integer", ".", "MAX_VALUE", ";", "long", "limit", "=", "offset", "+", "size", ";", "int", "numBuffers", "=", "(", "int", ")", "(", "(", "size", "+", "(", "blockSize", "-", "1", ")", ")", "/", "blockSize", ")", ";", "ByteBuffer", "[", "]", "result", "=", "new", "ByteBuffer", "[", "numBuffers", "]", ";", "int", "index", "=", "0", ";", "while", "(", "pos", "<", "limit", ")", "{", "long", "blockLength", "=", "Math", ".", "min", "(", "limit", "-", "pos", ",", "blockSize", ")", ";", "result", "[", "index", "++", "]", "=", "UnsafeUtil", ".", "newDirectByteBuffer", "(", "address", "(", ")", "+", "pos", ",", "(", "int", ")", "blockLength", ",", "this", ")", ".", "order", "(", "ByteOrder", ".", "nativeOrder", "(", ")", ")", ";", "pos", "+=", "blockLength", ";", "}", "return", "result", ";", "}" ]
Gives an sequence of ByteBuffers of a specified range. Writing to these ByteBuffers modifies the contents of this LBuffer. @param offset @param size @return
[ "Gives", "an", "sequence", "of", "ByteBuffers", "of", "a", "specified", "range", ".", "Writing", "to", "these", "ByteBuffers", "modifies", "the", "contents", "of", "this", "LBuffer", "." ]
9a1462623c0e56ca67c5341ea29832963c29479f
https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L430-L445
163,765
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/checkers/hint/WrappingHint.java
WrappingHint.getWrappingHint
public String getWrappingHint(String fieldName) { if (isEmpty()) { return ""; } return String.format(" You can use this expression: %s(%s(%s))", formatMethod(wrappingMethodOwnerName, wrappingMethodName, ""), formatMethod(copyMethodOwnerName, copyMethodName, copyTypeParameterName), fieldName); }
java
public String getWrappingHint(String fieldName) { if (isEmpty()) { return ""; } return String.format(" You can use this expression: %s(%s(%s))", formatMethod(wrappingMethodOwnerName, wrappingMethodName, ""), formatMethod(copyMethodOwnerName, copyMethodName, copyTypeParameterName), fieldName); }
[ "public", "String", "getWrappingHint", "(", "String", "fieldName", ")", "{", "if", "(", "isEmpty", "(", ")", ")", "{", "return", "\"\"", ";", "}", "return", "String", ".", "format", "(", "\" You can use this expression: %s(%s(%s))\"", ",", "formatMethod", "(", "wrappingMethodOwnerName", ",", "wrappingMethodName", ",", "\"\"", ")", ",", "formatMethod", "(", "copyMethodOwnerName", ",", "copyMethodName", ",", "copyTypeParameterName", ")", ",", "fieldName", ")", ";", "}" ]
For given field name get the actual hint message
[ "For", "given", "field", "name", "get", "the", "actual", "hint", "message" ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/checkers/hint/WrappingHint.java#L64-L73
163,766
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/checkers/settermethod/EffectiveAssignmentInsnFinder.java
EffectiveAssignmentInsnFinder.newInstance
public static EffectiveAssignmentInsnFinder newInstance(final FieldNode targetVariable, final Collection<ControlFlowBlock> controlFlowBlocks) { return new EffectiveAssignmentInsnFinder(checkNotNull(targetVariable), checkNotNull(controlFlowBlocks)); }
java
public static EffectiveAssignmentInsnFinder newInstance(final FieldNode targetVariable, final Collection<ControlFlowBlock> controlFlowBlocks) { return new EffectiveAssignmentInsnFinder(checkNotNull(targetVariable), checkNotNull(controlFlowBlocks)); }
[ "public", "static", "EffectiveAssignmentInsnFinder", "newInstance", "(", "final", "FieldNode", "targetVariable", ",", "final", "Collection", "<", "ControlFlowBlock", ">", "controlFlowBlocks", ")", "{", "return", "new", "EffectiveAssignmentInsnFinder", "(", "checkNotNull", "(", "targetVariable", ")", ",", "checkNotNull", "(", "controlFlowBlocks", ")", ")", ";", "}" ]
Static factory method. @param targetVariable the variable to find the effective {@code putfield} or {@code putstatic} instruction for. @param controlFlowBlocks all control flow blocks of an initialising constructor or method. @return a new instance of this class.
[ "Static", "factory", "method", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/checkers/settermethod/EffectiveAssignmentInsnFinder.java#L69-L72
163,767
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/checkers/settermethod/CandidatesInitialisersMapping.java
CandidatesInitialisersMapping.removeAndGetCandidatesWithoutInitialisingMethod
public Collection<FieldNode> removeAndGetCandidatesWithoutInitialisingMethod() { final List<FieldNode> result = new ArrayList<FieldNode>(); for (final Map.Entry<FieldNode, Initialisers> entry : candidatesAndInitialisers.entrySet()) { final Initialisers setters = entry.getValue(); final List<MethodNode> initialisingMethods = setters.getMethods(); if (initialisingMethods.isEmpty()) { result.add(entry.getKey()); } } for (final FieldNode unassociatedVariable : result) { candidatesAndInitialisers.remove(unassociatedVariable); } return result; }
java
public Collection<FieldNode> removeAndGetCandidatesWithoutInitialisingMethod() { final List<FieldNode> result = new ArrayList<FieldNode>(); for (final Map.Entry<FieldNode, Initialisers> entry : candidatesAndInitialisers.entrySet()) { final Initialisers setters = entry.getValue(); final List<MethodNode> initialisingMethods = setters.getMethods(); if (initialisingMethods.isEmpty()) { result.add(entry.getKey()); } } for (final FieldNode unassociatedVariable : result) { candidatesAndInitialisers.remove(unassociatedVariable); } return result; }
[ "public", "Collection", "<", "FieldNode", ">", "removeAndGetCandidatesWithoutInitialisingMethod", "(", ")", "{", "final", "List", "<", "FieldNode", ">", "result", "=", "new", "ArrayList", "<", "FieldNode", ">", "(", ")", ";", "for", "(", "final", "Map", ".", "Entry", "<", "FieldNode", ",", "Initialisers", ">", "entry", ":", "candidatesAndInitialisers", ".", "entrySet", "(", ")", ")", "{", "final", "Initialisers", "setters", "=", "entry", ".", "getValue", "(", ")", ";", "final", "List", "<", "MethodNode", ">", "initialisingMethods", "=", "setters", ".", "getMethods", "(", ")", ";", "if", "(", "initialisingMethods", ".", "isEmpty", "(", ")", ")", "{", "result", ".", "add", "(", "entry", ".", "getKey", "(", ")", ")", ";", "}", "}", "for", "(", "final", "FieldNode", "unassociatedVariable", ":", "result", ")", "{", "candidatesAndInitialisers", ".", "remove", "(", "unassociatedVariable", ")", ";", "}", "return", "result", ";", "}" ]
Removes all candidates from this collection which are not associated with an initialising method. @return a {@code Collection} containing the removed unassociated candidates. This list is empty if none were removed, i. e. the result is never {@code null}.
[ "Removes", "all", "candidates", "from", "this", "collection", "which", "are", "not", "associated", "with", "an", "initialising", "method", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/checkers/settermethod/CandidatesInitialisersMapping.java#L413-L426
163,768
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/checkers/settermethod/AbstractSetterMethodChecker.java
AbstractSetterMethodChecker.verify
protected final void verify() { collectInitialisers(); verifyCandidates(); verifyInitialisers(); collectPossibleInitialValues(); verifyPossibleInitialValues(); collectEffectiveAssignmentInstructions(); verifyEffectiveAssignmentInstructions(); collectAssignmentGuards(); verifyAssignmentGuards(); end(); }
java
protected final void verify() { collectInitialisers(); verifyCandidates(); verifyInitialisers(); collectPossibleInitialValues(); verifyPossibleInitialValues(); collectEffectiveAssignmentInstructions(); verifyEffectiveAssignmentInstructions(); collectAssignmentGuards(); verifyAssignmentGuards(); end(); }
[ "protected", "final", "void", "verify", "(", ")", "{", "collectInitialisers", "(", ")", ";", "verifyCandidates", "(", ")", ";", "verifyInitialisers", "(", ")", ";", "collectPossibleInitialValues", "(", ")", ";", "verifyPossibleInitialValues", "(", ")", ";", "collectEffectiveAssignmentInstructions", "(", ")", ";", "verifyEffectiveAssignmentInstructions", "(", ")", ";", "collectAssignmentGuards", "(", ")", ";", "verifyAssignmentGuards", "(", ")", ";", "end", "(", ")", ";", "}" ]
Template method for verification of lazy initialisation.
[ "Template", "method", "for", "verification", "of", "lazy", "initialisation", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/checkers/settermethod/AbstractSetterMethodChecker.java#L132-L143
163,769
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/ConfigurationBuilder.java
ConfigurationBuilder.mergeHardcodedResultsFrom
protected void mergeHardcodedResultsFrom(Configuration otherConfiguration) { Map<Dotted, AnalysisResult> resultsMap = hardcodedResults.build().stream() .collect(Collectors.toMap(r -> r.className, r -> r)); resultsMap.putAll(otherConfiguration.hardcodedResults()); hardcodedResults = ImmutableSet.<AnalysisResult>builder().addAll(resultsMap.values()); }
java
protected void mergeHardcodedResultsFrom(Configuration otherConfiguration) { Map<Dotted, AnalysisResult> resultsMap = hardcodedResults.build().stream() .collect(Collectors.toMap(r -> r.className, r -> r)); resultsMap.putAll(otherConfiguration.hardcodedResults()); hardcodedResults = ImmutableSet.<AnalysisResult>builder().addAll(resultsMap.values()); }
[ "protected", "void", "mergeHardcodedResultsFrom", "(", "Configuration", "otherConfiguration", ")", "{", "Map", "<", "Dotted", ",", "AnalysisResult", ">", "resultsMap", "=", "hardcodedResults", ".", "build", "(", ")", ".", "stream", "(", ")", ".", "collect", "(", "Collectors", ".", "toMap", "(", "r", "->", "r", ".", "className", ",", "r", "->", "r", ")", ")", ";", "resultsMap", ".", "putAll", "(", "otherConfiguration", ".", "hardcodedResults", "(", ")", ")", ";", "hardcodedResults", "=", "ImmutableSet", ".", "<", "AnalysisResult", ">", "builder", "(", ")", ".", "addAll", "(", "resultsMap", ".", "values", "(", ")", ")", ";", "}" ]
Merges the hardcoded results of this Configuration with the given Configuration. The resultant hardcoded results will be the union of the two sets of hardcoded results. Where the AnalysisResult for a class is found in both Configurations, the result from otherConfiguration will replace the existing result in this Configuration. This replacement behaviour will occur for subsequent calls to {@link #mergeHardcodedResultsFrom(Configuration)}. @param otherConfiguration - Configuration to merge hardcoded results with.
[ "Merges", "the", "hardcoded", "results", "of", "this", "Configuration", "with", "the", "given", "Configuration", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/ConfigurationBuilder.java#L355-L360
163,770
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/ConfigurationBuilder.java
ConfigurationBuilder.mergeImmutableContainerTypesFrom
protected void mergeImmutableContainerTypesFrom(Configuration otherConfiguration) { Set<Dotted> union = Sets.union(hardcodedImmutableContainerClasses.build(), otherConfiguration.immutableContainerClasses()); hardcodedImmutableContainerClasses = ImmutableSet.<Dotted>builder().addAll(union); }
java
protected void mergeImmutableContainerTypesFrom(Configuration otherConfiguration) { Set<Dotted> union = Sets.union(hardcodedImmutableContainerClasses.build(), otherConfiguration.immutableContainerClasses()); hardcodedImmutableContainerClasses = ImmutableSet.<Dotted>builder().addAll(union); }
[ "protected", "void", "mergeImmutableContainerTypesFrom", "(", "Configuration", "otherConfiguration", ")", "{", "Set", "<", "Dotted", ">", "union", "=", "Sets", ".", "union", "(", "hardcodedImmutableContainerClasses", ".", "build", "(", ")", ",", "otherConfiguration", ".", "immutableContainerClasses", "(", ")", ")", ";", "hardcodedImmutableContainerClasses", "=", "ImmutableSet", ".", "<", "Dotted", ">", "builder", "(", ")", ".", "addAll", "(", "union", ")", ";", "}" ]
Merges the immutable container types of this Configuration with the given Configuration. The resultant immutable container types results will be the union of the two sets of immutable container types. Where the type is found in both Configurations, the result from otherConfiguration will replace the existing result in this Configuration. This replacement behaviour will occur for subsequent calls to {@link #mergeImmutableContainerTypesFrom(Configuration)} . @param otherConfiguration - Configuration to merge immutable container types with.
[ "Merges", "the", "immutable", "container", "types", "of", "this", "Configuration", "with", "the", "given", "Configuration", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/ConfigurationBuilder.java#L375-L380
163,771
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/ConfigurationBuilder.java
ConfigurationBuilder.hardcodeValidCopyMethod
protected final void hardcodeValidCopyMethod(Class<?> fieldType, String fullyQualifiedMethodName, Class<?> argType) { if (argType==null || fieldType==null || fullyQualifiedMethodName==null) { throw new IllegalArgumentException("All parameters must be supplied - no nulls"); } String className = fullyQualifiedMethodName.substring(0, fullyQualifiedMethodName.lastIndexOf(".")); String methodName = fullyQualifiedMethodName.substring(fullyQualifiedMethodName.lastIndexOf(".")+1); String desc = null; try { if (MethodIs.aConstructor(methodName)) { Constructor<?> ctor = Class.forName(className).getDeclaredConstructor(argType); desc = Type.getConstructorDescriptor(ctor); } else { Method method = Class.forName(className).getMethod(methodName, argType); desc = Type.getMethodDescriptor(method); } } catch (NoSuchMethodException e) { rethrow("No such method", e); } catch (SecurityException e) { rethrow("Security error", e); } catch (ClassNotFoundException e) { rethrow("Class not found", e); } CopyMethod copyMethod = new CopyMethod(dotted(className), methodName, desc); hardcodeValidCopyMethod(fieldType, copyMethod); }
java
protected final void hardcodeValidCopyMethod(Class<?> fieldType, String fullyQualifiedMethodName, Class<?> argType) { if (argType==null || fieldType==null || fullyQualifiedMethodName==null) { throw new IllegalArgumentException("All parameters must be supplied - no nulls"); } String className = fullyQualifiedMethodName.substring(0, fullyQualifiedMethodName.lastIndexOf(".")); String methodName = fullyQualifiedMethodName.substring(fullyQualifiedMethodName.lastIndexOf(".")+1); String desc = null; try { if (MethodIs.aConstructor(methodName)) { Constructor<?> ctor = Class.forName(className).getDeclaredConstructor(argType); desc = Type.getConstructorDescriptor(ctor); } else { Method method = Class.forName(className).getMethod(methodName, argType); desc = Type.getMethodDescriptor(method); } } catch (NoSuchMethodException e) { rethrow("No such method", e); } catch (SecurityException e) { rethrow("Security error", e); } catch (ClassNotFoundException e) { rethrow("Class not found", e); } CopyMethod copyMethod = new CopyMethod(dotted(className), methodName, desc); hardcodeValidCopyMethod(fieldType, copyMethod); }
[ "protected", "final", "void", "hardcodeValidCopyMethod", "(", "Class", "<", "?", ">", "fieldType", ",", "String", "fullyQualifiedMethodName", ",", "Class", "<", "?", ">", "argType", ")", "{", "if", "(", "argType", "==", "null", "||", "fieldType", "==", "null", "||", "fullyQualifiedMethodName", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"All parameters must be supplied - no nulls\"", ")", ";", "}", "String", "className", "=", "fullyQualifiedMethodName", ".", "substring", "(", "0", ",", "fullyQualifiedMethodName", ".", "lastIndexOf", "(", "\".\"", ")", ")", ";", "String", "methodName", "=", "fullyQualifiedMethodName", ".", "substring", "(", "fullyQualifiedMethodName", ".", "lastIndexOf", "(", "\".\"", ")", "+", "1", ")", ";", "String", "desc", "=", "null", ";", "try", "{", "if", "(", "MethodIs", ".", "aConstructor", "(", "methodName", ")", ")", "{", "Constructor", "<", "?", ">", "ctor", "=", "Class", ".", "forName", "(", "className", ")", ".", "getDeclaredConstructor", "(", "argType", ")", ";", "desc", "=", "Type", ".", "getConstructorDescriptor", "(", "ctor", ")", ";", "}", "else", "{", "Method", "method", "=", "Class", ".", "forName", "(", "className", ")", ".", "getMethod", "(", "methodName", ",", "argType", ")", ";", "desc", "=", "Type", ".", "getMethodDescriptor", "(", "method", ")", ";", "}", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "rethrow", "(", "\"No such method\"", ",", "e", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "rethrow", "(", "\"Security error\"", ",", "e", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "rethrow", "(", "\"Class not found\"", ",", "e", ")", ";", "}", "CopyMethod", "copyMethod", "=", "new", "CopyMethod", "(", "dotted", "(", "className", ")", ",", "methodName", ",", "desc", ")", ";", "hardcodeValidCopyMethod", "(", "fieldType", ",", "copyMethod", ")", ";", "}" ]
Hardcode a copy method as being valid. This should be used to tell Mutability Detector about a method which copies a collection, and when the copy can be wrapped in an immutable wrapper we can consider the assignment immutable. Useful for allowing Mutability Detector to correctly work with other collections frameworks such as Google Guava. Reflection is used to obtain the method's descriptor and to verify the method's existence. @param fieldType - the type of the field to which the result of the copy is assigned @param fullyQualifiedMethodName - the fully qualified method name @param argType - the type of the argument passed to the copy method @throws MutabilityAnalysisException - if the specified class or method does not exist @throws IllegalArgumentException - if any of the arguments are null
[ "Hardcode", "a", "copy", "method", "as", "being", "valid", ".", "This", "should", "be", "used", "to", "tell", "Mutability", "Detector", "about", "a", "method", "which", "copies", "a", "collection", "and", "when", "the", "copy", "can", "be", "wrapped", "in", "an", "immutable", "wrapper", "we", "can", "consider", "the", "assignment", "immutable", ".", "Useful", "for", "allowing", "Mutability", "Detector", "to", "correctly", "work", "with", "other", "collections", "frameworks", "such", "as", "Google", "Guava", ".", "Reflection", "is", "used", "to", "obtain", "the", "method", "s", "descriptor", "and", "to", "verify", "the", "method", "s", "existence", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/ConfigurationBuilder.java#L430-L456
163,772
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/checkers/settermethod/AliasFinder.java
AliasFinder.newInstance
public static AliasFinder newInstance(final String variableName, final ControlFlowBlock controlFlowBlockToExamine) { checkArgument(!variableName.isEmpty()); return new AliasFinder(variableName, checkNotNull(controlFlowBlockToExamine)); }
java
public static AliasFinder newInstance(final String variableName, final ControlFlowBlock controlFlowBlockToExamine) { checkArgument(!variableName.isEmpty()); return new AliasFinder(variableName, checkNotNull(controlFlowBlockToExamine)); }
[ "public", "static", "AliasFinder", "newInstance", "(", "final", "String", "variableName", ",", "final", "ControlFlowBlock", "controlFlowBlockToExamine", ")", "{", "checkArgument", "(", "!", "variableName", ".", "isEmpty", "(", ")", ")", ";", "return", "new", "AliasFinder", "(", "variableName", ",", "checkNotNull", "(", "controlFlowBlockToExamine", ")", ")", ";", "}" ]
Creates a new instance of this class. @param variableName name of the instance variable to search aliases for. Must neither be {@code null} nor empty. @param controlFlowBlockToExamine a {@link ControlFlowBlock} which possibly contains the setup of an alias for a lazy variable. This method thereby examines predecessors of {@code block}, too. This parameter must not be {@code null}. @return a new instance of this class.
[ "Creates", "a", "new", "instance", "of", "this", "class", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/checkers/settermethod/AliasFinder.java#L74-L77
163,773
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/checkers/hint/WrappingHintGenerator.java
WrappingHintGenerator.generateCopyingPart
private void generateCopyingPart(WrappingHint.Builder builder) { ImmutableCollection<CopyMethod> copyMethods = ImmutableMultimap.<String, CopyMethod>builder() .putAll(configuration.FIELD_TYPE_TO_COPY_METHODS) .putAll(userDefinedCopyMethods) .build() .get(typeAssignedToField); if (copyMethods.isEmpty()) { throw new WrappingHintGenerationException(); } CopyMethod firstSuitable = copyMethods.iterator().next(); builder.setCopyMethodOwnerName(firstSuitable.owner.toString()) .setCopyMethodName(firstSuitable.name); if (firstSuitable.isGeneric && typeSignature != null) { CollectionField withRemovedWildcards = CollectionField.from(typeAssignedToField, typeSignature) .transformGenericTree(GenericType::withoutWildcard); builder.setCopyTypeParameterName(formatTypeParameter(withRemovedWildcards.asSimpleString())); } }
java
private void generateCopyingPart(WrappingHint.Builder builder) { ImmutableCollection<CopyMethod> copyMethods = ImmutableMultimap.<String, CopyMethod>builder() .putAll(configuration.FIELD_TYPE_TO_COPY_METHODS) .putAll(userDefinedCopyMethods) .build() .get(typeAssignedToField); if (copyMethods.isEmpty()) { throw new WrappingHintGenerationException(); } CopyMethod firstSuitable = copyMethods.iterator().next(); builder.setCopyMethodOwnerName(firstSuitable.owner.toString()) .setCopyMethodName(firstSuitable.name); if (firstSuitable.isGeneric && typeSignature != null) { CollectionField withRemovedWildcards = CollectionField.from(typeAssignedToField, typeSignature) .transformGenericTree(GenericType::withoutWildcard); builder.setCopyTypeParameterName(formatTypeParameter(withRemovedWildcards.asSimpleString())); } }
[ "private", "void", "generateCopyingPart", "(", "WrappingHint", ".", "Builder", "builder", ")", "{", "ImmutableCollection", "<", "CopyMethod", ">", "copyMethods", "=", "ImmutableMultimap", ".", "<", "String", ",", "CopyMethod", ">", "builder", "(", ")", ".", "putAll", "(", "configuration", ".", "FIELD_TYPE_TO_COPY_METHODS", ")", ".", "putAll", "(", "userDefinedCopyMethods", ")", ".", "build", "(", ")", ".", "get", "(", "typeAssignedToField", ")", ";", "if", "(", "copyMethods", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WrappingHintGenerationException", "(", ")", ";", "}", "CopyMethod", "firstSuitable", "=", "copyMethods", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "builder", ".", "setCopyMethodOwnerName", "(", "firstSuitable", ".", "owner", ".", "toString", "(", ")", ")", ".", "setCopyMethodName", "(", "firstSuitable", ".", "name", ")", ";", "if", "(", "firstSuitable", ".", "isGeneric", "&&", "typeSignature", "!=", "null", ")", "{", "CollectionField", "withRemovedWildcards", "=", "CollectionField", ".", "from", "(", "typeAssignedToField", ",", "typeSignature", ")", ".", "transformGenericTree", "(", "GenericType", "::", "withoutWildcard", ")", ";", "builder", ".", "setCopyTypeParameterName", "(", "formatTypeParameter", "(", "withRemovedWildcards", ".", "asSimpleString", "(", ")", ")", ")", ";", "}", "}" ]
Pick arbitrary copying method from available configuration and don't forget to set generic method type if required. @param builder
[ "Pick", "arbitrary", "copying", "method", "from", "available", "configuration", "and", "don", "t", "forget", "to", "set", "generic", "method", "type", "if", "required", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/checkers/hint/WrappingHintGenerator.java#L71-L91
163,774
MutabilityDetector/MutabilityDetector
src/main/java/org/mutabilitydetector/checkers/hint/WrappingHintGenerator.java
WrappingHintGenerator.generateWrappingPart
private void generateWrappingPart(WrappingHint.Builder builder) { builder.setWrappingMethodOwnerName(configuration.UNMODIFIABLE_METHOD_OWNER) .setWrappingMethodName(configuration.FIELD_TYPE_TO_UNMODIFIABLE_METHOD.get(typeAssignedToField)); }
java
private void generateWrappingPart(WrappingHint.Builder builder) { builder.setWrappingMethodOwnerName(configuration.UNMODIFIABLE_METHOD_OWNER) .setWrappingMethodName(configuration.FIELD_TYPE_TO_UNMODIFIABLE_METHOD.get(typeAssignedToField)); }
[ "private", "void", "generateWrappingPart", "(", "WrappingHint", ".", "Builder", "builder", ")", "{", "builder", ".", "setWrappingMethodOwnerName", "(", "configuration", ".", "UNMODIFIABLE_METHOD_OWNER", ")", ".", "setWrappingMethodName", "(", "configuration", ".", "FIELD_TYPE_TO_UNMODIFIABLE_METHOD", ".", "get", "(", "typeAssignedToField", ")", ")", ";", "}" ]
Pick arbitrary wrapping method. No generics should be set. @param builder
[ "Pick", "arbitrary", "wrapping", "method", ".", "No", "generics", "should", "be", "set", "." ]
36014d2f9e45cf0cc6d67b81395942cd39c4f6ae
https://github.com/MutabilityDetector/MutabilityDetector/blob/36014d2f9e45cf0cc6d67b81395942cd39c4f6ae/src/main/java/org/mutabilitydetector/checkers/hint/WrappingHintGenerator.java#L97-L100
163,775
Pkmmte/CircularImageView
circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java
CircularImageView.setBorderWidth
public void setBorderWidth(int borderWidth) { this.borderWidth = borderWidth; if(paintBorder != null) paintBorder.setStrokeWidth(borderWidth); requestLayout(); invalidate(); }
java
public void setBorderWidth(int borderWidth) { this.borderWidth = borderWidth; if(paintBorder != null) paintBorder.setStrokeWidth(borderWidth); requestLayout(); invalidate(); }
[ "public", "void", "setBorderWidth", "(", "int", "borderWidth", ")", "{", "this", ".", "borderWidth", "=", "borderWidth", ";", "if", "(", "paintBorder", "!=", "null", ")", "paintBorder", ".", "setStrokeWidth", "(", "borderWidth", ")", ";", "requestLayout", "(", ")", ";", "invalidate", "(", ")", ";", "}" ]
Sets the CircularImageView's border width in pixels. @param borderWidth Width in pixels for the border.
[ "Sets", "the", "CircularImageView", "s", "border", "width", "in", "pixels", "." ]
aca59f32d9267c943eb6c930bdaed59c417a4d16
https://github.com/Pkmmte/CircularImageView/blob/aca59f32d9267c943eb6c930bdaed59c417a4d16/circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java#L143-L149
163,776
Pkmmte/CircularImageView
circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java
CircularImageView.setShadow
public void setShadow(float radius, float dx, float dy, int color) { shadowRadius = radius; shadowDx = dx; shadowDy = dy; shadowColor = color; updateShadow(); }
java
public void setShadow(float radius, float dx, float dy, int color) { shadowRadius = radius; shadowDx = dx; shadowDy = dy; shadowColor = color; updateShadow(); }
[ "public", "void", "setShadow", "(", "float", "radius", ",", "float", "dx", ",", "float", "dy", ",", "int", "color", ")", "{", "shadowRadius", "=", "radius", ";", "shadowDx", "=", "dx", ";", "shadowDy", "=", "dy", ";", "shadowColor", "=", "color", ";", "updateShadow", "(", ")", ";", "}" ]
Enables a dark shadow for this CircularImageView. If the radius is set to 0, the shadow is removed. @param radius Radius for the shadow to extend to. @param dx Horizontal shadow offset. @param dy Vertical shadow offset. @param color The color of the shadow to apply.
[ "Enables", "a", "dark", "shadow", "for", "this", "CircularImageView", ".", "If", "the", "radius", "is", "set", "to", "0", "the", "shadow", "is", "removed", "." ]
aca59f32d9267c943eb6c930bdaed59c417a4d16
https://github.com/Pkmmte/CircularImageView/blob/aca59f32d9267c943eb6c930bdaed59c417a4d16/circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java#L210-L216
163,777
Pkmmte/CircularImageView
circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java
CircularImageView.drawableToBitmap
public Bitmap drawableToBitmap(Drawable drawable) { if (drawable == null) // Don't do anything without a proper drawable return null; else if (drawable instanceof BitmapDrawable) { // Use the getBitmap() method instead if BitmapDrawable Log.i(TAG, "Bitmap drawable!"); return ((BitmapDrawable) drawable).getBitmap(); } int intrinsicWidth = drawable.getIntrinsicWidth(); int intrinsicHeight = drawable.getIntrinsicHeight(); if (!(intrinsicWidth > 0 && intrinsicHeight > 0)) return null; try { // Create Bitmap object out of the drawable Bitmap bitmap = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; } catch (OutOfMemoryError e) { // Simply return null of failed bitmap creations Log.e(TAG, "Encountered OutOfMemoryError while generating bitmap!"); return null; } }
java
public Bitmap drawableToBitmap(Drawable drawable) { if (drawable == null) // Don't do anything without a proper drawable return null; else if (drawable instanceof BitmapDrawable) { // Use the getBitmap() method instead if BitmapDrawable Log.i(TAG, "Bitmap drawable!"); return ((BitmapDrawable) drawable).getBitmap(); } int intrinsicWidth = drawable.getIntrinsicWidth(); int intrinsicHeight = drawable.getIntrinsicHeight(); if (!(intrinsicWidth > 0 && intrinsicHeight > 0)) return null; try { // Create Bitmap object out of the drawable Bitmap bitmap = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; } catch (OutOfMemoryError e) { // Simply return null of failed bitmap creations Log.e(TAG, "Encountered OutOfMemoryError while generating bitmap!"); return null; } }
[ "public", "Bitmap", "drawableToBitmap", "(", "Drawable", "drawable", ")", "{", "if", "(", "drawable", "==", "null", ")", "// Don't do anything without a proper drawable", "return", "null", ";", "else", "if", "(", "drawable", "instanceof", "BitmapDrawable", ")", "{", "// Use the getBitmap() method instead if BitmapDrawable", "Log", ".", "i", "(", "TAG", ",", "\"Bitmap drawable!\"", ")", ";", "return", "(", "(", "BitmapDrawable", ")", "drawable", ")", ".", "getBitmap", "(", ")", ";", "}", "int", "intrinsicWidth", "=", "drawable", ".", "getIntrinsicWidth", "(", ")", ";", "int", "intrinsicHeight", "=", "drawable", ".", "getIntrinsicHeight", "(", ")", ";", "if", "(", "!", "(", "intrinsicWidth", ">", "0", "&&", "intrinsicHeight", ">", "0", ")", ")", "return", "null", ";", "try", "{", "// Create Bitmap object out of the drawable", "Bitmap", "bitmap", "=", "Bitmap", ".", "createBitmap", "(", "intrinsicWidth", ",", "intrinsicHeight", ",", "Bitmap", ".", "Config", ".", "ARGB_8888", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "bitmap", ")", ";", "drawable", ".", "setBounds", "(", "0", ",", "0", ",", "canvas", ".", "getWidth", "(", ")", ",", "canvas", ".", "getHeight", "(", ")", ")", ";", "drawable", ".", "draw", "(", "canvas", ")", ";", "return", "bitmap", ";", "}", "catch", "(", "OutOfMemoryError", "e", ")", "{", "// Simply return null of failed bitmap creations", "Log", ".", "e", "(", "TAG", ",", "\"Encountered OutOfMemoryError while generating bitmap!\"", ")", ";", "return", "null", ";", "}", "}" ]
Convert a drawable object into a Bitmap. @param drawable Drawable to extract a Bitmap from. @return A Bitmap created from the drawable parameter.
[ "Convert", "a", "drawable", "object", "into", "a", "Bitmap", "." ]
aca59f32d9267c943eb6c930bdaed59c417a4d16
https://github.com/Pkmmte/CircularImageView/blob/aca59f32d9267c943eb6c930bdaed59c417a4d16/circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java#L393-L419
163,778
Pkmmte/CircularImageView
circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java
CircularImageView.updateBitmapShader
public void updateBitmapShader() { if (image == null) return; shader = new BitmapShader(image, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); if(canvasSize != image.getWidth() || canvasSize != image.getHeight()) { Matrix matrix = new Matrix(); float scale = (float) canvasSize / (float) image.getWidth(); matrix.setScale(scale, scale); shader.setLocalMatrix(matrix); } }
java
public void updateBitmapShader() { if (image == null) return; shader = new BitmapShader(image, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); if(canvasSize != image.getWidth() || canvasSize != image.getHeight()) { Matrix matrix = new Matrix(); float scale = (float) canvasSize / (float) image.getWidth(); matrix.setScale(scale, scale); shader.setLocalMatrix(matrix); } }
[ "public", "void", "updateBitmapShader", "(", ")", "{", "if", "(", "image", "==", "null", ")", "return", ";", "shader", "=", "new", "BitmapShader", "(", "image", ",", "Shader", ".", "TileMode", ".", "CLAMP", ",", "Shader", ".", "TileMode", ".", "CLAMP", ")", ";", "if", "(", "canvasSize", "!=", "image", ".", "getWidth", "(", ")", "||", "canvasSize", "!=", "image", ".", "getHeight", "(", ")", ")", "{", "Matrix", "matrix", "=", "new", "Matrix", "(", ")", ";", "float", "scale", "=", "(", "float", ")", "canvasSize", "/", "(", "float", ")", "image", ".", "getWidth", "(", ")", ";", "matrix", ".", "setScale", "(", "scale", ",", "scale", ")", ";", "shader", ".", "setLocalMatrix", "(", "matrix", ")", ";", "}", "}" ]
Re-initializes the shader texture used to fill in the Circle upon drawing.
[ "Re", "-", "initializes", "the", "shader", "texture", "used", "to", "fill", "in", "the", "Circle", "upon", "drawing", "." ]
aca59f32d9267c943eb6c930bdaed59c417a4d16
https://github.com/Pkmmte/CircularImageView/blob/aca59f32d9267c943eb6c930bdaed59c417a4d16/circularimageview/src/main/java/com/pkmmte/view/CircularImageView.java#L428-L440
163,779
Pkmmte/CircularImageView
circularimageview-eclipse/CircularImageView/src/com/pkmmte/circularimageview/CircularImageView.java
CircularImageView.refreshBitmapShader
public void refreshBitmapShader() { shader = new BitmapShader(Bitmap.createScaledBitmap(image, canvasSize, canvasSize, false), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); }
java
public void refreshBitmapShader() { shader = new BitmapShader(Bitmap.createScaledBitmap(image, canvasSize, canvasSize, false), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); }
[ "public", "void", "refreshBitmapShader", "(", ")", "{", "shader", "=", "new", "BitmapShader", "(", "Bitmap", ".", "createScaledBitmap", "(", "image", ",", "canvasSize", ",", "canvasSize", ",", "false", ")", ",", "Shader", ".", "TileMode", ".", "CLAMP", ",", "Shader", ".", "TileMode", ".", "CLAMP", ")", ";", "}" ]
Reinitializes the shader texture used to fill in the Circle upon drawing.
[ "Reinitializes", "the", "shader", "texture", "used", "to", "fill", "in", "the", "Circle", "upon", "drawing", "." ]
aca59f32d9267c943eb6c930bdaed59c417a4d16
https://github.com/Pkmmte/CircularImageView/blob/aca59f32d9267c943eb6c930bdaed59c417a4d16/circularimageview-eclipse/CircularImageView/src/com/pkmmte/circularimageview/CircularImageView.java#L354-L357
163,780
Cleveroad/LoopBar
LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/OrientationStateHorizontalBottom.java
OrientationStateHorizontalBottom.calcItemWidth
private int calcItemWidth(RecyclerView rvCategories) { if (itemWidth == null || itemWidth == 0) { for (int i = 0; i < rvCategories.getChildCount(); i++) { itemWidth = rvCategories.getChildAt(i).getWidth(); if (itemWidth != 0) { break; } } } // in case of call before view was created if (itemWidth == null) { itemWidth = 0; } return itemWidth; }
java
private int calcItemWidth(RecyclerView rvCategories) { if (itemWidth == null || itemWidth == 0) { for (int i = 0; i < rvCategories.getChildCount(); i++) { itemWidth = rvCategories.getChildAt(i).getWidth(); if (itemWidth != 0) { break; } } } // in case of call before view was created if (itemWidth == null) { itemWidth = 0; } return itemWidth; }
[ "private", "int", "calcItemWidth", "(", "RecyclerView", "rvCategories", ")", "{", "if", "(", "itemWidth", "==", "null", "||", "itemWidth", "==", "0", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rvCategories", ".", "getChildCount", "(", ")", ";", "i", "++", ")", "{", "itemWidth", "=", "rvCategories", ".", "getChildAt", "(", "i", ")", ".", "getWidth", "(", ")", ";", "if", "(", "itemWidth", "!=", "0", ")", "{", "break", ";", "}", "}", "}", "// in case of call before view was created", "if", "(", "itemWidth", "==", "null", ")", "{", "itemWidth", "=", "0", ";", "}", "return", "itemWidth", ";", "}" ]
very big duct tape
[ "very", "big", "duct", "tape" ]
6ff5e0b35e637202202f9b4ca141195bdcfd5697
https://github.com/Cleveroad/LoopBar/blob/6ff5e0b35e637202202f9b4ca141195bdcfd5697/LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/OrientationStateHorizontalBottom.java#L87-L101
163,781
Cleveroad/LoopBar
LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/LoopBarView.java
LoopBarView.setOrientation
public final void setOrientation(int orientation) { mOrientation = orientation; mOrientationState = getOrientationStateFromParam(mOrientation); invalidate(); if (mOuterAdapter != null) { mOuterAdapter.setOrientation(mOrientation); } }
java
public final void setOrientation(int orientation) { mOrientation = orientation; mOrientationState = getOrientationStateFromParam(mOrientation); invalidate(); if (mOuterAdapter != null) { mOuterAdapter.setOrientation(mOrientation); } }
[ "public", "final", "void", "setOrientation", "(", "int", "orientation", ")", "{", "mOrientation", "=", "orientation", ";", "mOrientationState", "=", "getOrientationStateFromParam", "(", "mOrientation", ")", ";", "invalidate", "(", ")", ";", "if", "(", "mOuterAdapter", "!=", "null", ")", "{", "mOuterAdapter", ".", "setOrientation", "(", "mOrientation", ")", ";", "}", "}" ]
Sets orientation of loopbar @param orientation int value of orientation. Must be one of {@link Orientation}
[ "Sets", "orientation", "of", "loopbar" ]
6ff5e0b35e637202202f9b4ca141195bdcfd5697
https://github.com/Cleveroad/LoopBar/blob/6ff5e0b35e637202202f9b4ca141195bdcfd5697/LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/LoopBarView.java#L256-L264
163,782
Cleveroad/LoopBar
LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/LoopBarView.java
LoopBarView.selectItem
@SuppressWarnings("unused") public void selectItem(int position, boolean invokeListeners) { IOperationItem item = mOuterAdapter.getItem(position); IOperationItem oldHidedItem = mOuterAdapter.getItem(mRealHidedPosition); int realPosition = mOuterAdapter.normalizePosition(position); //do nothing if position not changed if (realPosition == mCurrentItemPosition) { return; } int itemToShowAdapterPosition = position - realPosition + mRealHidedPosition; item.setVisible(false); startSelectedViewOutAnimation(position); mOuterAdapter.notifyRealItemChanged(position); mRealHidedPosition = realPosition; oldHidedItem.setVisible(true); mFlContainerSelected.requestLayout(); mOuterAdapter.notifyRealItemChanged(itemToShowAdapterPosition); mCurrentItemPosition = realPosition; if (invokeListeners) { notifyItemClickListeners(realPosition); } if (BuildConfig.DEBUG) { Log.i(TAG, "clicked on position =" + position); } }
java
@SuppressWarnings("unused") public void selectItem(int position, boolean invokeListeners) { IOperationItem item = mOuterAdapter.getItem(position); IOperationItem oldHidedItem = mOuterAdapter.getItem(mRealHidedPosition); int realPosition = mOuterAdapter.normalizePosition(position); //do nothing if position not changed if (realPosition == mCurrentItemPosition) { return; } int itemToShowAdapterPosition = position - realPosition + mRealHidedPosition; item.setVisible(false); startSelectedViewOutAnimation(position); mOuterAdapter.notifyRealItemChanged(position); mRealHidedPosition = realPosition; oldHidedItem.setVisible(true); mFlContainerSelected.requestLayout(); mOuterAdapter.notifyRealItemChanged(itemToShowAdapterPosition); mCurrentItemPosition = realPosition; if (invokeListeners) { notifyItemClickListeners(realPosition); } if (BuildConfig.DEBUG) { Log.i(TAG, "clicked on position =" + position); } }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "void", "selectItem", "(", "int", "position", ",", "boolean", "invokeListeners", ")", "{", "IOperationItem", "item", "=", "mOuterAdapter", ".", "getItem", "(", "position", ")", ";", "IOperationItem", "oldHidedItem", "=", "mOuterAdapter", ".", "getItem", "(", "mRealHidedPosition", ")", ";", "int", "realPosition", "=", "mOuterAdapter", ".", "normalizePosition", "(", "position", ")", ";", "//do nothing if position not changed", "if", "(", "realPosition", "==", "mCurrentItemPosition", ")", "{", "return", ";", "}", "int", "itemToShowAdapterPosition", "=", "position", "-", "realPosition", "+", "mRealHidedPosition", ";", "item", ".", "setVisible", "(", "false", ")", ";", "startSelectedViewOutAnimation", "(", "position", ")", ";", "mOuterAdapter", ".", "notifyRealItemChanged", "(", "position", ")", ";", "mRealHidedPosition", "=", "realPosition", ";", "oldHidedItem", ".", "setVisible", "(", "true", ")", ";", "mFlContainerSelected", ".", "requestLayout", "(", ")", ";", "mOuterAdapter", ".", "notifyRealItemChanged", "(", "itemToShowAdapterPosition", ")", ";", "mCurrentItemPosition", "=", "realPosition", ";", "if", "(", "invokeListeners", ")", "{", "notifyItemClickListeners", "(", "realPosition", ")", ";", "}", "if", "(", "BuildConfig", ".", "DEBUG", ")", "{", "Log", ".", "i", "(", "TAG", ",", "\"clicked on position =\"", "+", "position", ")", ";", "}", "}" ]
Select item by it's position @param position int value of item position to select @param invokeListeners boolean value for invoking listeners
[ "Select", "item", "by", "it", "s", "position" ]
6ff5e0b35e637202202f9b4ca141195bdcfd5697
https://github.com/Cleveroad/LoopBar/blob/6ff5e0b35e637202202f9b4ca141195bdcfd5697/LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/LoopBarView.java#L778-L810
163,783
Cleveroad/LoopBar
LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/LoopBarView.java
LoopBarView.getOrientationStateFromParam
public IOrientationState getOrientationStateFromParam(int orientation) { switch (orientation) { case Orientation.ORIENTATION_HORIZONTAL_BOTTOM: return new OrientationStateHorizontalBottom(); case Orientation.ORIENTATION_HORIZONTAL_TOP: return new OrientationStateHorizontalTop(); case Orientation.ORIENTATION_VERTICAL_LEFT: return new OrientationStateVerticalLeft(); case Orientation.ORIENTATION_VERTICAL_RIGHT: return new OrientationStateVerticalRight(); default: return new OrientationStateHorizontalBottom(); } }
java
public IOrientationState getOrientationStateFromParam(int orientation) { switch (orientation) { case Orientation.ORIENTATION_HORIZONTAL_BOTTOM: return new OrientationStateHorizontalBottom(); case Orientation.ORIENTATION_HORIZONTAL_TOP: return new OrientationStateHorizontalTop(); case Orientation.ORIENTATION_VERTICAL_LEFT: return new OrientationStateVerticalLeft(); case Orientation.ORIENTATION_VERTICAL_RIGHT: return new OrientationStateVerticalRight(); default: return new OrientationStateHorizontalBottom(); } }
[ "public", "IOrientationState", "getOrientationStateFromParam", "(", "int", "orientation", ")", "{", "switch", "(", "orientation", ")", "{", "case", "Orientation", ".", "ORIENTATION_HORIZONTAL_BOTTOM", ":", "return", "new", "OrientationStateHorizontalBottom", "(", ")", ";", "case", "Orientation", ".", "ORIENTATION_HORIZONTAL_TOP", ":", "return", "new", "OrientationStateHorizontalTop", "(", ")", ";", "case", "Orientation", ".", "ORIENTATION_VERTICAL_LEFT", ":", "return", "new", "OrientationStateVerticalLeft", "(", ")", ";", "case", "Orientation", ".", "ORIENTATION_VERTICAL_RIGHT", ":", "return", "new", "OrientationStateVerticalRight", "(", ")", ";", "default", ":", "return", "new", "OrientationStateHorizontalBottom", "(", ")", ";", "}", "}" ]
orientation state factory method
[ "orientation", "state", "factory", "method" ]
6ff5e0b35e637202202f9b4ca141195bdcfd5697
https://github.com/Cleveroad/LoopBar/blob/6ff5e0b35e637202202f9b4ca141195bdcfd5697/LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/LoopBarView.java#L823-L836
163,784
Cleveroad/LoopBar
LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/AbstractOrientationState.java
AbstractOrientationState.setSelectionMargin
@Override public <T extends ViewGroup.MarginLayoutParams> T setSelectionMargin(int marginPx, T layoutParams) { return mSelectionGravityState.setSelectionMargin(marginPx, layoutParams); }
java
@Override public <T extends ViewGroup.MarginLayoutParams> T setSelectionMargin(int marginPx, T layoutParams) { return mSelectionGravityState.setSelectionMargin(marginPx, layoutParams); }
[ "@", "Override", "public", "<", "T", "extends", "ViewGroup", ".", "MarginLayoutParams", ">", "T", "setSelectionMargin", "(", "int", "marginPx", ",", "T", "layoutParams", ")", "{", "return", "mSelectionGravityState", ".", "setSelectionMargin", "(", "marginPx", ",", "layoutParams", ")", ";", "}" ]
dispatch to gravity state
[ "dispatch", "to", "gravity", "state" ]
6ff5e0b35e637202202f9b4ca141195bdcfd5697
https://github.com/Cleveroad/LoopBar/blob/6ff5e0b35e637202202f9b4ca141195bdcfd5697/LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/AbstractOrientationState.java#L31-L34
163,785
FINRAOS/DataGenerator
dg-core/src/main/java/org/finra/datagenerator/consumer/RepeatingDataConsumer.java
RepeatingDataConsumer.consume
public int consume(Map<String, String> initialVars) { int result = 0; for (int i = 0; i < repeatNumber; i++) { result += super.consume(initialVars); } return result; }
java
public int consume(Map<String, String> initialVars) { int result = 0; for (int i = 0; i < repeatNumber; i++) { result += super.consume(initialVars); } return result; }
[ "public", "int", "consume", "(", "Map", "<", "String", ",", "String", ">", "initialVars", ")", "{", "int", "result", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "repeatNumber", ";", "i", "++", ")", "{", "result", "+=", "super", ".", "consume", "(", "initialVars", ")", ";", "}", "return", "result", ";", "}" ]
Overridden 'consume' method. Corresponding parent method will be called necessary number of times @param initialVars - a map containing the initial variables assignments @return the number of lines written
[ "Overridden", "consume", "method", ".", "Corresponding", "parent", "method", "will", "be", "called", "necessary", "number", "of", "times" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/consumer/RepeatingDataConsumer.java#L41-L49
163,786
FINRAOS/DataGenerator
dg-simple-csv/src/main/java/org/finra/datagenerator/simplecsv/CmdLine.java
CmdLine.main
public static void main(String[] args) { String modelFile = ""; String outputFile = ""; int numberOfRows = 0; try { modelFile = args[0]; outputFile = args[1]; numberOfRows = Integer.valueOf(args[2]); } catch (IndexOutOfBoundsException | NumberFormatException e) { System.out.println("ERROR! Invalid command line arguments, expecting: <scxml model file> " + "<desired csv output file> <desired number of output rows>"); return; } FileInputStream model = null; try { model = new FileInputStream(modelFile); } catch (FileNotFoundException e) { System.out.println("ERROR! Model file not found"); return; } SCXMLEngine engine = new SCXMLEngine(); engine.setModelByInputFileStream(model); engine.setBootstrapMin(5); DataConsumer consumer = new DataConsumer(); CSVFileWriter writer; try { writer = new CSVFileWriter(outputFile); } catch (IOException e) { System.out.println("ERROR! Can not write to output csv file"); return; } consumer.addDataWriter(writer); DefaultDistributor dist = new DefaultDistributor(); dist.setThreadCount(5); dist.setMaxNumberOfLines(numberOfRows); dist.setDataConsumer(consumer); engine.process(dist); writer.closeCSVFile(); System.out.println("COMPLETE!"); }
java
public static void main(String[] args) { String modelFile = ""; String outputFile = ""; int numberOfRows = 0; try { modelFile = args[0]; outputFile = args[1]; numberOfRows = Integer.valueOf(args[2]); } catch (IndexOutOfBoundsException | NumberFormatException e) { System.out.println("ERROR! Invalid command line arguments, expecting: <scxml model file> " + "<desired csv output file> <desired number of output rows>"); return; } FileInputStream model = null; try { model = new FileInputStream(modelFile); } catch (FileNotFoundException e) { System.out.println("ERROR! Model file not found"); return; } SCXMLEngine engine = new SCXMLEngine(); engine.setModelByInputFileStream(model); engine.setBootstrapMin(5); DataConsumer consumer = new DataConsumer(); CSVFileWriter writer; try { writer = new CSVFileWriter(outputFile); } catch (IOException e) { System.out.println("ERROR! Can not write to output csv file"); return; } consumer.addDataWriter(writer); DefaultDistributor dist = new DefaultDistributor(); dist.setThreadCount(5); dist.setMaxNumberOfLines(numberOfRows); dist.setDataConsumer(consumer); engine.process(dist); writer.closeCSVFile(); System.out.println("COMPLETE!"); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "String", "modelFile", "=", "\"\"", ";", "String", "outputFile", "=", "\"\"", ";", "int", "numberOfRows", "=", "0", ";", "try", "{", "modelFile", "=", "args", "[", "0", "]", ";", "outputFile", "=", "args", "[", "1", "]", ";", "numberOfRows", "=", "Integer", ".", "valueOf", "(", "args", "[", "2", "]", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "|", "NumberFormatException", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"ERROR! Invalid command line arguments, expecting: <scxml model file> \"", "+", "\"<desired csv output file> <desired number of output rows>\"", ")", ";", "return", ";", "}", "FileInputStream", "model", "=", "null", ";", "try", "{", "model", "=", "new", "FileInputStream", "(", "modelFile", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"ERROR! Model file not found\"", ")", ";", "return", ";", "}", "SCXMLEngine", "engine", "=", "new", "SCXMLEngine", "(", ")", ";", "engine", ".", "setModelByInputFileStream", "(", "model", ")", ";", "engine", ".", "setBootstrapMin", "(", "5", ")", ";", "DataConsumer", "consumer", "=", "new", "DataConsumer", "(", ")", ";", "CSVFileWriter", "writer", ";", "try", "{", "writer", "=", "new", "CSVFileWriter", "(", "outputFile", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"ERROR! Can not write to output csv file\"", ")", ";", "return", ";", "}", "consumer", ".", "addDataWriter", "(", "writer", ")", ";", "DefaultDistributor", "dist", "=", "new", "DefaultDistributor", "(", ")", ";", "dist", ".", "setThreadCount", "(", "5", ")", ";", "dist", ".", "setMaxNumberOfLines", "(", "numberOfRows", ")", ";", "dist", ".", "setDataConsumer", "(", "consumer", ")", ";", "engine", ".", "process", "(", "dist", ")", ";", "writer", ".", "closeCSVFile", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"COMPLETE!\"", ")", ";", "}" ]
Main method, handles all the setup tasks for DataGenerator a user would normally do themselves @param args command line arguments
[ "Main", "method", "handles", "all", "the", "setup", "tasks", "for", "DataGenerator", "a", "user", "would", "normally", "do", "themselves" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-simple-csv/src/main/java/org/finra/datagenerator/simplecsv/CmdLine.java#L42-L87
163,787
FINRAOS/DataGenerator
dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java
SocialNetworkUtilities.getRandomGeographicalLocation
public static Tuple2<Double, Double> getRandomGeographicalLocation() { return new Tuple2<>( (double) (RandomHelper.randWithConfiguredSeed().nextInt(999) + 1) / 100, (double) (RandomHelper.randWithConfiguredSeed().nextInt(999) + 1) / 100); }
java
public static Tuple2<Double, Double> getRandomGeographicalLocation() { return new Tuple2<>( (double) (RandomHelper.randWithConfiguredSeed().nextInt(999) + 1) / 100, (double) (RandomHelper.randWithConfiguredSeed().nextInt(999) + 1) / 100); }
[ "public", "static", "Tuple2", "<", "Double", ",", "Double", ">", "getRandomGeographicalLocation", "(", ")", "{", "return", "new", "Tuple2", "<>", "(", "(", "double", ")", "(", "RandomHelper", ".", "randWithConfiguredSeed", "(", ")", ".", "nextInt", "(", "999", ")", "+", "1", ")", "/", "100", ",", "(", "double", ")", "(", "RandomHelper", ".", "randWithConfiguredSeed", "(", ")", ".", "nextInt", "(", "999", ")", "+", "1", ")", "/", "100", ")", ";", "}" ]
Get random geographical location @return 2-Tuple of ints (latitude, longitude)
[ "Get", "random", "geographical", "location" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java#L48-L52
163,788
FINRAOS/DataGenerator
dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java
SocialNetworkUtilities.getDistanceBetweenCoordinates
public static Double getDistanceBetweenCoordinates(Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) { // sqrt( (x2-x1)^2 + (y2-y2)^2 ) Double xDiff = point1._1() - point2._1(); Double yDiff = point1._2() - point2._2(); return Math.sqrt(xDiff * xDiff + yDiff * yDiff); }
java
public static Double getDistanceBetweenCoordinates(Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) { // sqrt( (x2-x1)^2 + (y2-y2)^2 ) Double xDiff = point1._1() - point2._1(); Double yDiff = point1._2() - point2._2(); return Math.sqrt(xDiff * xDiff + yDiff * yDiff); }
[ "public", "static", "Double", "getDistanceBetweenCoordinates", "(", "Tuple2", "<", "Double", ",", "Double", ">", "point1", ",", "Tuple2", "<", "Double", ",", "Double", ">", "point2", ")", "{", "// sqrt( (x2-x1)^2 + (y2-y2)^2 )\r", "Double", "xDiff", "=", "point1", ".", "_1", "(", ")", "-", "point2", ".", "_1", "(", ")", ";", "Double", "yDiff", "=", "point1", ".", "_2", "(", ")", "-", "point2", ".", "_2", "(", ")", ";", "return", "Math", ".", "sqrt", "(", "xDiff", "*", "xDiff", "+", "yDiff", "*", "yDiff", ")", ";", "}" ]
Get distance between geographical coordinates @param point1 Point1 @param point2 Point2 @return Distance (double)
[ "Get", "distance", "between", "geographical", "coordinates" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java#L60-L65
163,789
FINRAOS/DataGenerator
dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java
SocialNetworkUtilities.getDistanceWithinThresholdOfCoordinates
public static Double getDistanceWithinThresholdOfCoordinates( Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) { throw new NotImplementedError(); }
java
public static Double getDistanceWithinThresholdOfCoordinates( Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) { throw new NotImplementedError(); }
[ "public", "static", "Double", "getDistanceWithinThresholdOfCoordinates", "(", "Tuple2", "<", "Double", ",", "Double", ">", "point1", ",", "Tuple2", "<", "Double", ",", "Double", ">", "point2", ")", "{", "throw", "new", "NotImplementedError", "(", ")", ";", "}" ]
Not implemented. @param point1 Point1 @param point2 Point2 @return Throws an exception.
[ "Not", "implemented", "." ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java#L73-L76
163,790
FINRAOS/DataGenerator
dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java
SocialNetworkUtilities.areCoordinatesWithinThreshold
public static Boolean areCoordinatesWithinThreshold(Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) { return getDistanceBetweenCoordinates(point1, point2) < COORDINATE_THRESHOLD; }
java
public static Boolean areCoordinatesWithinThreshold(Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) { return getDistanceBetweenCoordinates(point1, point2) < COORDINATE_THRESHOLD; }
[ "public", "static", "Boolean", "areCoordinatesWithinThreshold", "(", "Tuple2", "<", "Double", ",", "Double", ">", "point1", ",", "Tuple2", "<", "Double", ",", "Double", ">", "point2", ")", "{", "return", "getDistanceBetweenCoordinates", "(", "point1", ",", "point2", ")", "<", "COORDINATE_THRESHOLD", ";", "}" ]
Whether or not points are within some threshold. @param point1 Point 1 @param point2 Point 2 @return True or false
[ "Whether", "or", "not", "points", "are", "within", "some", "threshold", "." ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/SocialNetworkUtilities.java#L94-L96
163,791
FINRAOS/DataGenerator
dg-example-default/src/main/java/org/finra/datagenerator/samples/CmdLine.java
CmdLine.main
public static void main(String[] args) { //Adding custom equivalence class generation transformer - NOTE this will get applied during graph traversal--> //MODEL USAGE EXAMPLE: <assign name="var_out_V1_2" expr="%ssn"/> <dg:transform name="EQ"/> Map<String, DataTransformer> transformers = new HashMap<String, DataTransformer>(); transformers.put("EQ", new EquivalenceClassTransformer()); Vector<CustomTagExtension> cte = new Vector<CustomTagExtension>(); cte.add(new InLineTransformerExtension(transformers)); Engine engine = new SCXMLEngine(cte); //will default to samplemachine, but you could specify a different file if you choose to InputStream is = CmdLine.class.getResourceAsStream("/" + (args.length == 0 ? "samplemachine" : args[0]) + ".xml"); engine.setModelByInputFileStream(is); // Usually, this should be more than the number of threads you intend to run engine.setBootstrapMin(1); //Prepare the consumer with the proper writer and transformer DataConsumer consumer = new DataConsumer(); consumer.addDataTransformer(new SampleMachineTransformer()); //Adding custom equivalence class generation transformer - NOTE this will get applied post data generation. //MODEL USAGE EXAMPLE: <dg:assign name="var_out_V2" set="%regex([0-9]{3}[A-Z0-9]{5})"/> consumer.addDataTransformer(new EquivalenceClassTransformer()); consumer.addDataWriter(new DefaultWriter(System.out, new String[]{"var_1_1", "var_1_2", "var_1_3", "var_1_4", "var_1_5", "var_1_6", "var_1_7", "var_2_1", "var_2_2", "var_2_3", "var_2_4", "var_2_5", "var_2_6", "var_2_7", "var_2_8"})); //Prepare the distributor DefaultDistributor defaultDistributor = new DefaultDistributor(); defaultDistributor.setThreadCount(1); defaultDistributor.setDataConsumer(consumer); Logger.getLogger("org.apache").setLevel(Level.WARN); engine.process(defaultDistributor); }
java
public static void main(String[] args) { //Adding custom equivalence class generation transformer - NOTE this will get applied during graph traversal--> //MODEL USAGE EXAMPLE: <assign name="var_out_V1_2" expr="%ssn"/> <dg:transform name="EQ"/> Map<String, DataTransformer> transformers = new HashMap<String, DataTransformer>(); transformers.put("EQ", new EquivalenceClassTransformer()); Vector<CustomTagExtension> cte = new Vector<CustomTagExtension>(); cte.add(new InLineTransformerExtension(transformers)); Engine engine = new SCXMLEngine(cte); //will default to samplemachine, but you could specify a different file if you choose to InputStream is = CmdLine.class.getResourceAsStream("/" + (args.length == 0 ? "samplemachine" : args[0]) + ".xml"); engine.setModelByInputFileStream(is); // Usually, this should be more than the number of threads you intend to run engine.setBootstrapMin(1); //Prepare the consumer with the proper writer and transformer DataConsumer consumer = new DataConsumer(); consumer.addDataTransformer(new SampleMachineTransformer()); //Adding custom equivalence class generation transformer - NOTE this will get applied post data generation. //MODEL USAGE EXAMPLE: <dg:assign name="var_out_V2" set="%regex([0-9]{3}[A-Z0-9]{5})"/> consumer.addDataTransformer(new EquivalenceClassTransformer()); consumer.addDataWriter(new DefaultWriter(System.out, new String[]{"var_1_1", "var_1_2", "var_1_3", "var_1_4", "var_1_5", "var_1_6", "var_1_7", "var_2_1", "var_2_2", "var_2_3", "var_2_4", "var_2_5", "var_2_6", "var_2_7", "var_2_8"})); //Prepare the distributor DefaultDistributor defaultDistributor = new DefaultDistributor(); defaultDistributor.setThreadCount(1); defaultDistributor.setDataConsumer(consumer); Logger.getLogger("org.apache").setLevel(Level.WARN); engine.process(defaultDistributor); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "//Adding custom equivalence class generation transformer - NOTE this will get applied during graph traversal-->\r", "//MODEL USAGE EXAMPLE: <assign name=\"var_out_V1_2\" expr=\"%ssn\"/> <dg:transform name=\"EQ\"/>\r", "Map", "<", "String", ",", "DataTransformer", ">", "transformers", "=", "new", "HashMap", "<", "String", ",", "DataTransformer", ">", "(", ")", ";", "transformers", ".", "put", "(", "\"EQ\"", ",", "new", "EquivalenceClassTransformer", "(", ")", ")", ";", "Vector", "<", "CustomTagExtension", ">", "cte", "=", "new", "Vector", "<", "CustomTagExtension", ">", "(", ")", ";", "cte", ".", "add", "(", "new", "InLineTransformerExtension", "(", "transformers", ")", ")", ";", "Engine", "engine", "=", "new", "SCXMLEngine", "(", "cte", ")", ";", "//will default to samplemachine, but you could specify a different file if you choose to\r", "InputStream", "is", "=", "CmdLine", ".", "class", ".", "getResourceAsStream", "(", "\"/\"", "+", "(", "args", ".", "length", "==", "0", "?", "\"samplemachine\"", ":", "args", "[", "0", "]", ")", "+", "\".xml\"", ")", ";", "engine", ".", "setModelByInputFileStream", "(", "is", ")", ";", "// Usually, this should be more than the number of threads you intend to run\r", "engine", ".", "setBootstrapMin", "(", "1", ")", ";", "//Prepare the consumer with the proper writer and transformer\r", "DataConsumer", "consumer", "=", "new", "DataConsumer", "(", ")", ";", "consumer", ".", "addDataTransformer", "(", "new", "SampleMachineTransformer", "(", ")", ")", ";", "//Adding custom equivalence class generation transformer - NOTE this will get applied post data generation.\r", "//MODEL USAGE EXAMPLE: <dg:assign name=\"var_out_V2\" set=\"%regex([0-9]{3}[A-Z0-9]{5})\"/>\r", "consumer", ".", "addDataTransformer", "(", "new", "EquivalenceClassTransformer", "(", ")", ")", ";", "consumer", ".", "addDataWriter", "(", "new", "DefaultWriter", "(", "System", ".", "out", ",", "new", "String", "[", "]", "{", "\"var_1_1\"", ",", "\"var_1_2\"", ",", "\"var_1_3\"", ",", "\"var_1_4\"", ",", "\"var_1_5\"", ",", "\"var_1_6\"", ",", "\"var_1_7\"", ",", "\"var_2_1\"", ",", "\"var_2_2\"", ",", "\"var_2_3\"", ",", "\"var_2_4\"", ",", "\"var_2_5\"", ",", "\"var_2_6\"", ",", "\"var_2_7\"", ",", "\"var_2_8\"", "}", ")", ")", ";", "//Prepare the distributor\r", "DefaultDistributor", "defaultDistributor", "=", "new", "DefaultDistributor", "(", ")", ";", "defaultDistributor", ".", "setThreadCount", "(", "1", ")", ";", "defaultDistributor", ".", "setDataConsumer", "(", "consumer", ")", ";", "Logger", ".", "getLogger", "(", "\"org.apache\"", ")", ".", "setLevel", "(", "Level", ".", "WARN", ")", ";", "engine", ".", "process", "(", "defaultDistributor", ")", ";", "}" ]
Entry point for the example. @param args Command-line arguments for the example. To use samplemachine.xml from resources, send no arguments. To use other file, send a filename without xml extension).
[ "Entry", "point", "for", "the", "example", "." ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-example-default/src/main/java/org/finra/datagenerator/samples/CmdLine.java#L54-L90
163,792
FINRAOS/DataGenerator
dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/UserStub.java
UserStub.getStubWithRandomParams
public static UserStub getStubWithRandomParams(UserTypeVal userType) { // Java coerces the return type as a Tuple2 of Objects -- but it's declared as a Tuple2 of Doubles! // Oh the joys of type erasure. Tuple2<Double, Double> tuple = SocialNetworkUtilities.getRandomGeographicalLocation(); return new UserStub(userType, new Tuple2<>((Double) tuple._1(), (Double) tuple._2()), SocialNetworkUtilities.getRandomIsSecret()); }
java
public static UserStub getStubWithRandomParams(UserTypeVal userType) { // Java coerces the return type as a Tuple2 of Objects -- but it's declared as a Tuple2 of Doubles! // Oh the joys of type erasure. Tuple2<Double, Double> tuple = SocialNetworkUtilities.getRandomGeographicalLocation(); return new UserStub(userType, new Tuple2<>((Double) tuple._1(), (Double) tuple._2()), SocialNetworkUtilities.getRandomIsSecret()); }
[ "public", "static", "UserStub", "getStubWithRandomParams", "(", "UserTypeVal", "userType", ")", "{", "// Java coerces the return type as a Tuple2 of Objects -- but it's declared as a Tuple2 of Doubles!\r", "// Oh the joys of type erasure.\r", "Tuple2", "<", "Double", ",", "Double", ">", "tuple", "=", "SocialNetworkUtilities", ".", "getRandomGeographicalLocation", "(", ")", ";", "return", "new", "UserStub", "(", "userType", ",", "new", "Tuple2", "<>", "(", "(", "Double", ")", "tuple", ".", "_1", "(", ")", ",", "(", "Double", ")", "tuple", ".", "_2", "(", ")", ")", ",", "SocialNetworkUtilities", ".", "getRandomIsSecret", "(", ")", ")", ";", "}" ]
Get random stub matching this user type @param userType User type @return Random stub
[ "Get", "random", "stub", "matching", "this", "user", "type" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-common/src/main/java/org/finra/datagenerator/common/SocialNetwork_Example_Java/UserStub.java#L116-L122
163,793
FINRAOS/DataGenerator
dg-simple-csv/src/main/java/org/finra/datagenerator/simplecsv/writer/CSVFileWriter.java
CSVFileWriter.writeOutput
public void writeOutput(DataPipe cr) { String[] nextLine = new String[cr.getDataMap().entrySet().size()]; int count = 0; for (Map.Entry<String, String> entry : cr.getDataMap().entrySet()) { nextLine[count] = entry.getValue(); count++; } csvFile.writeNext(nextLine); }
java
public void writeOutput(DataPipe cr) { String[] nextLine = new String[cr.getDataMap().entrySet().size()]; int count = 0; for (Map.Entry<String, String> entry : cr.getDataMap().entrySet()) { nextLine[count] = entry.getValue(); count++; } csvFile.writeNext(nextLine); }
[ "public", "void", "writeOutput", "(", "DataPipe", "cr", ")", "{", "String", "[", "]", "nextLine", "=", "new", "String", "[", "cr", ".", "getDataMap", "(", ")", ".", "entrySet", "(", ")", ".", "size", "(", ")", "]", ";", "int", "count", "=", "0", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "cr", ".", "getDataMap", "(", ")", ".", "entrySet", "(", ")", ")", "{", "nextLine", "[", "count", "]", "=", "entry", ".", "getValue", "(", ")", ";", "count", "++", ";", "}", "csvFile", ".", "writeNext", "(", "nextLine", ")", ";", "}" ]
Prints one line to the csv file @param cr data pipe with search results
[ "Prints", "one", "line", "to", "the", "csv", "file" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-simple-csv/src/main/java/org/finra/datagenerator/simplecsv/writer/CSVFileWriter.java#L49-L59
163,794
FINRAOS/DataGenerator
dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java
BoundaryDate.isHoliday
public boolean isHoliday(String dateString) { boolean isHoliday = false; for (Holiday date : EquivalenceClassTransformer.HOLIDAYS) { if (convertToReadableDate(date.forYear(Integer.parseInt(dateString.substring(0, 4)))).equals(dateString)) { isHoliday = true; } } return isHoliday; }
java
public boolean isHoliday(String dateString) { boolean isHoliday = false; for (Holiday date : EquivalenceClassTransformer.HOLIDAYS) { if (convertToReadableDate(date.forYear(Integer.parseInt(dateString.substring(0, 4)))).equals(dateString)) { isHoliday = true; } } return isHoliday; }
[ "public", "boolean", "isHoliday", "(", "String", "dateString", ")", "{", "boolean", "isHoliday", "=", "false", ";", "for", "(", "Holiday", "date", ":", "EquivalenceClassTransformer", ".", "HOLIDAYS", ")", "{", "if", "(", "convertToReadableDate", "(", "date", ".", "forYear", "(", "Integer", ".", "parseInt", "(", "dateString", ".", "substring", "(", "0", ",", "4", ")", ")", ")", ")", ".", "equals", "(", "dateString", ")", ")", "{", "isHoliday", "=", "true", ";", "}", "}", "return", "isHoliday", ";", "}" ]
Checks if the date is a holiday @param dateString the date @return true if it is a holiday, false otherwise
[ "Checks", "if", "the", "date", "is", "a", "holiday" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java#L81-L89
163,795
FINRAOS/DataGenerator
dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java
BoundaryDate.getNextDay
public String getNextDay(String dateString, boolean onlyBusinessDays) { DateTimeFormatter parser = ISODateTimeFormat.date(); DateTime date = parser.parseDateTime(dateString).plusDays(1); Calendar cal = Calendar.getInstance(); cal.setTime(date.toDate()); if (onlyBusinessDays) { if (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7 || isHoliday(date.toString().substring(0, 10))) { return getNextDay(date.toString().substring(0, 10), true); } else { return parser.print(date); } } else { return parser.print(date); } }
java
public String getNextDay(String dateString, boolean onlyBusinessDays) { DateTimeFormatter parser = ISODateTimeFormat.date(); DateTime date = parser.parseDateTime(dateString).plusDays(1); Calendar cal = Calendar.getInstance(); cal.setTime(date.toDate()); if (onlyBusinessDays) { if (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7 || isHoliday(date.toString().substring(0, 10))) { return getNextDay(date.toString().substring(0, 10), true); } else { return parser.print(date); } } else { return parser.print(date); } }
[ "public", "String", "getNextDay", "(", "String", "dateString", ",", "boolean", "onlyBusinessDays", ")", "{", "DateTimeFormatter", "parser", "=", "ISODateTimeFormat", ".", "date", "(", ")", ";", "DateTime", "date", "=", "parser", ".", "parseDateTime", "(", "dateString", ")", ".", "plusDays", "(", "1", ")", ";", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTime", "(", "date", ".", "toDate", "(", ")", ")", ";", "if", "(", "onlyBusinessDays", ")", "{", "if", "(", "cal", ".", "get", "(", "Calendar", ".", "DAY_OF_WEEK", ")", "==", "1", "||", "cal", ".", "get", "(", "Calendar", ".", "DAY_OF_WEEK", ")", "==", "7", "||", "isHoliday", "(", "date", ".", "toString", "(", ")", ".", "substring", "(", "0", ",", "10", ")", ")", ")", "{", "return", "getNextDay", "(", "date", ".", "toString", "(", ")", ".", "substring", "(", "0", ",", "10", ")", ",", "true", ")", ";", "}", "else", "{", "return", "parser", ".", "print", "(", "date", ")", ";", "}", "}", "else", "{", "return", "parser", ".", "print", "(", "date", ")", ";", "}", "}" ]
Takes a date, and retrieves the next business day @param dateString the date @param onlyBusinessDays only business days @return a string containing the next business day
[ "Takes", "a", "date", "and", "retrieves", "the", "next", "business", "day" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java#L98-L114
163,796
FINRAOS/DataGenerator
dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java
BoundaryDate.toDate
public Date toDate(String dateString) { Date date = null; DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); try { date = df.parse(dateString); } catch (ParseException ex) { System.out.println(ex.fillInStackTrace()); } return date; }
java
public Date toDate(String dateString) { Date date = null; DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); try { date = df.parse(dateString); } catch (ParseException ex) { System.out.println(ex.fillInStackTrace()); } return date; }
[ "public", "Date", "toDate", "(", "String", "dateString", ")", "{", "Date", "date", "=", "null", ";", "DateFormat", "df", "=", "new", "SimpleDateFormat", "(", "\"yyyy-MM-dd\"", ")", ";", "try", "{", "date", "=", "df", ".", "parse", "(", "dateString", ")", ";", "}", "catch", "(", "ParseException", "ex", ")", "{", "System", ".", "out", ".", "println", "(", "ex", ".", "fillInStackTrace", "(", ")", ")", ";", "}", "return", "date", ";", "}" ]
Takes a String and converts it to a Date @param dateString the date @return Date denoted by dateString
[ "Takes", "a", "String", "and", "converts", "it", "to", "a", "Date" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java#L212-L221
163,797
FINRAOS/DataGenerator
dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java
BoundaryDate.getRandomHoliday
public String getRandomHoliday(String earliest, String latest) { String dateString = ""; DateTimeFormatter parser = ISODateTimeFormat.date(); DateTime earlyDate = parser.parseDateTime(earliest); DateTime lateDate = parser.parseDateTime(latest); List<Holiday> holidays = new LinkedList<>(); int min = Integer.parseInt(earlyDate.toString().substring(0, 4)); int max = Integer.parseInt(lateDate.toString().substring(0, 4)); int range = max - min + 1; int randomYear = (int) (Math.random() * range) + min; for (Holiday s : EquivalenceClassTransformer.HOLIDAYS) { holidays.add(s); } Collections.shuffle(holidays); for (Holiday holiday : holidays) { dateString = convertToReadableDate(holiday.forYear(randomYear)); if (toDate(dateString).after(toDate(earliest)) && toDate(dateString).before(toDate(latest))) { break; } } return dateString; }
java
public String getRandomHoliday(String earliest, String latest) { String dateString = ""; DateTimeFormatter parser = ISODateTimeFormat.date(); DateTime earlyDate = parser.parseDateTime(earliest); DateTime lateDate = parser.parseDateTime(latest); List<Holiday> holidays = new LinkedList<>(); int min = Integer.parseInt(earlyDate.toString().substring(0, 4)); int max = Integer.parseInt(lateDate.toString().substring(0, 4)); int range = max - min + 1; int randomYear = (int) (Math.random() * range) + min; for (Holiday s : EquivalenceClassTransformer.HOLIDAYS) { holidays.add(s); } Collections.shuffle(holidays); for (Holiday holiday : holidays) { dateString = convertToReadableDate(holiday.forYear(randomYear)); if (toDate(dateString).after(toDate(earliest)) && toDate(dateString).before(toDate(latest))) { break; } } return dateString; }
[ "public", "String", "getRandomHoliday", "(", "String", "earliest", ",", "String", "latest", ")", "{", "String", "dateString", "=", "\"\"", ";", "DateTimeFormatter", "parser", "=", "ISODateTimeFormat", ".", "date", "(", ")", ";", "DateTime", "earlyDate", "=", "parser", ".", "parseDateTime", "(", "earliest", ")", ";", "DateTime", "lateDate", "=", "parser", ".", "parseDateTime", "(", "latest", ")", ";", "List", "<", "Holiday", ">", "holidays", "=", "new", "LinkedList", "<>", "(", ")", ";", "int", "min", "=", "Integer", ".", "parseInt", "(", "earlyDate", ".", "toString", "(", ")", ".", "substring", "(", "0", ",", "4", ")", ")", ";", "int", "max", "=", "Integer", ".", "parseInt", "(", "lateDate", ".", "toString", "(", ")", ".", "substring", "(", "0", ",", "4", ")", ")", ";", "int", "range", "=", "max", "-", "min", "+", "1", ";", "int", "randomYear", "=", "(", "int", ")", "(", "Math", ".", "random", "(", ")", "*", "range", ")", "+", "min", ";", "for", "(", "Holiday", "s", ":", "EquivalenceClassTransformer", ".", "HOLIDAYS", ")", "{", "holidays", ".", "add", "(", "s", ")", ";", "}", "Collections", ".", "shuffle", "(", "holidays", ")", ";", "for", "(", "Holiday", "holiday", ":", "holidays", ")", "{", "dateString", "=", "convertToReadableDate", "(", "holiday", ".", "forYear", "(", "randomYear", ")", ")", ";", "if", "(", "toDate", "(", "dateString", ")", ".", "after", "(", "toDate", "(", "earliest", ")", ")", "&&", "toDate", "(", "dateString", ")", ".", "before", "(", "toDate", "(", "latest", ")", ")", ")", "{", "break", ";", "}", "}", "return", "dateString", ";", "}" ]
Grab random holiday from the equivalence class that falls between the two dates @param earliest the earliest date parameter as defined in the model @param latest the latest date parameter as defined in the model @return a holiday that falls between the dates
[ "Grab", "random", "holiday", "from", "the", "equivalence", "class", "that", "falls", "between", "the", "two", "dates" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java#L230-L254
163,798
FINRAOS/DataGenerator
dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java
BoundaryDate.numOccurrences
public int numOccurrences(int year, int month, int day) { DateTimeFormatter parser = ISODateTimeFormat.date(); DateTime date = parser.parseDateTime(year + "-" + month + "-" + "01"); Calendar cal = Calendar.getInstance(); cal.setTime(date.toDate()); GregorianChronology calendar = GregorianChronology.getInstance(); DateTimeField field = calendar.dayOfMonth(); int days = 0; int count = 0; int num = field.getMaximumValue(new LocalDate(year, month, day, calendar)); while (days < num) { if (cal.get(Calendar.DAY_OF_WEEK) == day) { count++; } date = date.plusDays(1); cal.setTime(date.toDate()); days++; } return count; }
java
public int numOccurrences(int year, int month, int day) { DateTimeFormatter parser = ISODateTimeFormat.date(); DateTime date = parser.parseDateTime(year + "-" + month + "-" + "01"); Calendar cal = Calendar.getInstance(); cal.setTime(date.toDate()); GregorianChronology calendar = GregorianChronology.getInstance(); DateTimeField field = calendar.dayOfMonth(); int days = 0; int count = 0; int num = field.getMaximumValue(new LocalDate(year, month, day, calendar)); while (days < num) { if (cal.get(Calendar.DAY_OF_WEEK) == day) { count++; } date = date.plusDays(1); cal.setTime(date.toDate()); days++; } return count; }
[ "public", "int", "numOccurrences", "(", "int", "year", ",", "int", "month", ",", "int", "day", ")", "{", "DateTimeFormatter", "parser", "=", "ISODateTimeFormat", ".", "date", "(", ")", ";", "DateTime", "date", "=", "parser", ".", "parseDateTime", "(", "year", "+", "\"-\"", "+", "month", "+", "\"-\"", "+", "\"01\"", ")", ";", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTime", "(", "date", ".", "toDate", "(", ")", ")", ";", "GregorianChronology", "calendar", "=", "GregorianChronology", ".", "getInstance", "(", ")", ";", "DateTimeField", "field", "=", "calendar", ".", "dayOfMonth", "(", ")", ";", "int", "days", "=", "0", ";", "int", "count", "=", "0", ";", "int", "num", "=", "field", ".", "getMaximumValue", "(", "new", "LocalDate", "(", "year", ",", "month", ",", "day", ",", "calendar", ")", ")", ";", "while", "(", "days", "<", "num", ")", "{", "if", "(", "cal", ".", "get", "(", "Calendar", ".", "DAY_OF_WEEK", ")", "==", "day", ")", "{", "count", "++", ";", "}", "date", "=", "date", ".", "plusDays", "(", "1", ")", ";", "cal", ".", "setTime", "(", "date", ".", "toDate", "(", ")", ")", ";", "days", "++", ";", "}", "return", "count", ";", "}" ]
Given a year, month, and day, find the number of occurrences of that day in the month @param year the year @param month the month @param day the day @return the number of occurrences of the day in the month
[ "Given", "a", "year", "month", "and", "day", "find", "the", "number", "of", "occurrences", "of", "that", "day", "in", "the", "month" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java#L264-L285
163,799
FINRAOS/DataGenerator
dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java
BoundaryDate.convertToReadableDate
public String convertToReadableDate(Holiday holiday) { DateTimeFormatter parser = ISODateTimeFormat.date(); if (holiday.isInDateForm()) { String month = Integer.toString(holiday.getMonth()).length() < 2 ? "0" + holiday.getMonth() : Integer.toString(holiday.getMonth()); String day = Integer.toString(holiday.getDayOfMonth()).length() < 2 ? "0" + holiday.getDayOfMonth() : Integer.toString(holiday.getDayOfMonth()); return holiday.getYear() + "-" + month + "-" + day; } else { /* * 5 denotes the final occurrence of the day in the month. Need to find actual * number of occurrences */ if (holiday.getOccurrence() == 5) { holiday.setOccurrence(numOccurrences(holiday.getYear(), holiday.getMonth(), holiday.getDayOfWeek())); } DateTime date = parser.parseDateTime(holiday.getYear() + "-" + holiday.getMonth() + "-" + "01"); Calendar calendar = Calendar.getInstance(); calendar.setTime(date.toDate()); int count = 0; while (count < holiday.getOccurrence()) { if (calendar.get(Calendar.DAY_OF_WEEK) == holiday.getDayOfWeek()) { count++; if (count == holiday.getOccurrence()) { break; } } date = date.plusDays(1); calendar.setTime(date.toDate()); } return date.toString().substring(0, 10); } }
java
public String convertToReadableDate(Holiday holiday) { DateTimeFormatter parser = ISODateTimeFormat.date(); if (holiday.isInDateForm()) { String month = Integer.toString(holiday.getMonth()).length() < 2 ? "0" + holiday.getMonth() : Integer.toString(holiday.getMonth()); String day = Integer.toString(holiday.getDayOfMonth()).length() < 2 ? "0" + holiday.getDayOfMonth() : Integer.toString(holiday.getDayOfMonth()); return holiday.getYear() + "-" + month + "-" + day; } else { /* * 5 denotes the final occurrence of the day in the month. Need to find actual * number of occurrences */ if (holiday.getOccurrence() == 5) { holiday.setOccurrence(numOccurrences(holiday.getYear(), holiday.getMonth(), holiday.getDayOfWeek())); } DateTime date = parser.parseDateTime(holiday.getYear() + "-" + holiday.getMonth() + "-" + "01"); Calendar calendar = Calendar.getInstance(); calendar.setTime(date.toDate()); int count = 0; while (count < holiday.getOccurrence()) { if (calendar.get(Calendar.DAY_OF_WEEK) == holiday.getDayOfWeek()) { count++; if (count == holiday.getOccurrence()) { break; } } date = date.plusDays(1); calendar.setTime(date.toDate()); } return date.toString().substring(0, 10); } }
[ "public", "String", "convertToReadableDate", "(", "Holiday", "holiday", ")", "{", "DateTimeFormatter", "parser", "=", "ISODateTimeFormat", ".", "date", "(", ")", ";", "if", "(", "holiday", ".", "isInDateForm", "(", ")", ")", "{", "String", "month", "=", "Integer", ".", "toString", "(", "holiday", ".", "getMonth", "(", ")", ")", ".", "length", "(", ")", "<", "2", "?", "\"0\"", "+", "holiday", ".", "getMonth", "(", ")", ":", "Integer", ".", "toString", "(", "holiday", ".", "getMonth", "(", ")", ")", ";", "String", "day", "=", "Integer", ".", "toString", "(", "holiday", ".", "getDayOfMonth", "(", ")", ")", ".", "length", "(", ")", "<", "2", "?", "\"0\"", "+", "holiday", ".", "getDayOfMonth", "(", ")", ":", "Integer", ".", "toString", "(", "holiday", ".", "getDayOfMonth", "(", ")", ")", ";", "return", "holiday", ".", "getYear", "(", ")", "+", "\"-\"", "+", "month", "+", "\"-\"", "+", "day", ";", "}", "else", "{", "/*\n * 5 denotes the final occurrence of the day in the month. Need to find actual\n * number of occurrences\n */", "if", "(", "holiday", ".", "getOccurrence", "(", ")", "==", "5", ")", "{", "holiday", ".", "setOccurrence", "(", "numOccurrences", "(", "holiday", ".", "getYear", "(", ")", ",", "holiday", ".", "getMonth", "(", ")", ",", "holiday", ".", "getDayOfWeek", "(", ")", ")", ")", ";", "}", "DateTime", "date", "=", "parser", ".", "parseDateTime", "(", "holiday", ".", "getYear", "(", ")", "+", "\"-\"", "+", "holiday", ".", "getMonth", "(", ")", "+", "\"-\"", "+", "\"01\"", ")", ";", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "calendar", ".", "setTime", "(", "date", ".", "toDate", "(", ")", ")", ";", "int", "count", "=", "0", ";", "while", "(", "count", "<", "holiday", ".", "getOccurrence", "(", ")", ")", "{", "if", "(", "calendar", ".", "get", "(", "Calendar", ".", "DAY_OF_WEEK", ")", "==", "holiday", ".", "getDayOfWeek", "(", ")", ")", "{", "count", "++", ";", "if", "(", "count", "==", "holiday", ".", "getOccurrence", "(", ")", ")", "{", "break", ";", "}", "}", "date", "=", "date", ".", "plusDays", "(", "1", ")", ";", "calendar", ".", "setTime", "(", "date", ".", "toDate", "(", ")", ")", ";", "}", "return", "date", ".", "toString", "(", ")", ".", "substring", "(", "0", ",", "10", ")", ";", "}", "}" ]
Convert the holiday format from EquivalenceClassTransformer into a date format @param holiday the date @return a date String in the format yyyy-MM-dd
[ "Convert", "the", "holiday", "format", "from", "EquivalenceClassTransformer", "into", "a", "date", "format" ]
1f69f949401cbed4db4f553c3eb8350832c4d45a
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/engine/scxml/tags/boundary/BoundaryDate.java#L293-L330