repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
baratine/baratine
web/src/main/java/com/caucho/v5/io/StreamImplTee.java
StreamImplTee.read
@Override public int read(byte []buffer, int offset, int length) throws IOException { int sublen = getDelegate().read(buffer, offset, length); if (sublen > 0) { logStream().write(buffer, offset, sublen); } return sublen; }
java
@Override public int read(byte []buffer, int offset, int length) throws IOException { int sublen = getDelegate().read(buffer, offset, length); if (sublen > 0) { logStream().write(buffer, offset, sublen); } return sublen; }
[ "@", "Override", "public", "int", "read", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "int", "sublen", "=", "getDelegate", "(", ")", ".", "read", "(", "buffer", ",", "offset", ",", "...
Reads the next chunk from the stream. @param buffer byte array receiving the data. @param offset starting offset into the array. @param length number of bytes to read. @return the number of bytes read or -1 on end of file.
[ "Reads", "the", "next", "chunk", "from", "the", "stream", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/StreamImplTee.java#L124-L134
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/StreamImplTee.java
StreamImplTee.readTimeout
@Override public int readTimeout(byte []buffer, int offset, int length, long timeout) throws IOException { int sublen = getDelegate().readTimeout(buffer, offset, length, timeout); if (sublen > 0) { logStream().write(buffer, offset, sublen); } return sublen; }
java
@Override public int readTimeout(byte []buffer, int offset, int length, long timeout) throws IOException { int sublen = getDelegate().readTimeout(buffer, offset, length, timeout); if (sublen > 0) { logStream().write(buffer, offset, sublen); } return sublen; }
[ "@", "Override", "public", "int", "readTimeout", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ",", "long", "timeout", ")", "throws", "IOException", "{", "int", "sublen", "=", "getDelegate", "(", ")", ".", "readTimeout", "(...
Reads the next chunk from the stream in non-blocking mode. @param buffer byte array receiving the data. @param offset starting offset into the array. @param length number of bytes to read. @return the number of bytes read, -1 on end of file, or 0 on timeout.
[ "Reads", "the", "next", "chunk", "from", "the", "stream", "in", "non", "-", "blocking", "mode", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/StreamImplTee.java#L167-L178
train
SeaCloudsEU/SeaCloudsPlatform
dashboard/src/main/java/eu/seaclouds/platform/dashboard/util/ObjectMapperHelpers.java
ObjectMapperHelpers.ObjectToXml
public static String ObjectToXml(Object object) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); Marshaller marshaller = jaxbContext.createMarshaller(); StringWriter sw = new StringWriter(); marshaller.marshal(object, sw); return sw.toString(); }
java
public static String ObjectToXml(Object object) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); Marshaller marshaller = jaxbContext.createMarshaller(); StringWriter sw = new StringWriter(); marshaller.marshal(object, sw); return sw.toString(); }
[ "public", "static", "String", "ObjectToXml", "(", "Object", "object", ")", "throws", "JAXBException", "{", "JAXBContext", "jaxbContext", "=", "JAXBContext", ".", "newInstance", "(", "object", ".", "getClass", "(", ")", ")", ";", "Marshaller", "marshaller", "=", ...
Transforms an annotated Object to a XML string using javax.xml.bind.Marshaller @param object to transform to a XML String @return a XML string representing the object @throws IOException if is not possible to parse the object
[ "Transforms", "an", "annotated", "Object", "to", "a", "XML", "string", "using", "javax", ".", "xml", ".", "bind", ".", "Marshaller" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/util/ObjectMapperHelpers.java#L128-L134
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java
ByteToCharBase.setEncoding
public void setEncoding(String encoding) throws UnsupportedEncodingException { if (encoding != null) { _readEncoding = Encoding.getReadEncoding(this, encoding); _readEncodingName = Encoding.getMimeName(encoding); } else { _readEncoding = null; _readEncodingName = null; } }
java
public void setEncoding(String encoding) throws UnsupportedEncodingException { if (encoding != null) { _readEncoding = Encoding.getReadEncoding(this, encoding); _readEncodingName = Encoding.getMimeName(encoding); } else { _readEncoding = null; _readEncodingName = null; } }
[ "public", "void", "setEncoding", "(", "String", "encoding", ")", "throws", "UnsupportedEncodingException", "{", "if", "(", "encoding", "!=", "null", ")", "{", "_readEncoding", "=", "Encoding", ".", "getReadEncoding", "(", "this", ",", "encoding", ")", ";", "_r...
Sets the encoding for the converter.
[ "Sets", "the", "encoding", "for", "the", "converter", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java#L72-L83
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java
ByteToCharBase.addByte
public void addByte(int b) throws IOException { int nextHead = (_byteHead + 1) % _byteBuffer.length; while (nextHead == _byteTail) { int ch = readChar(); if (ch < 0) { break; } outputChar(ch); } _byteBuffer[_byteHead] = (byte) b; _byteHead = nextHead; }
java
public void addByte(int b) throws IOException { int nextHead = (_byteHead + 1) % _byteBuffer.length; while (nextHead == _byteTail) { int ch = readChar(); if (ch < 0) { break; } outputChar(ch); } _byteBuffer[_byteHead] = (byte) b; _byteHead = nextHead; }
[ "public", "void", "addByte", "(", "int", "b", ")", "throws", "IOException", "{", "int", "nextHead", "=", "(", "_byteHead", "+", "1", ")", "%", "_byteBuffer", ".", "length", ";", "while", "(", "nextHead", "==", "_byteTail", ")", "{", "int", "ch", "=", ...
Adds the next byte. @param b the byte to write
[ "Adds", "the", "next", "byte", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java#L99-L116
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java
ByteToCharBase.addChar
public void addChar(char nextCh) throws IOException { int ch; while ((ch = readChar()) >= 0) { outputChar((char) ch); } outputChar(nextCh); }
java
public void addChar(char nextCh) throws IOException { int ch; while ((ch = readChar()) >= 0) { outputChar((char) ch); } outputChar(nextCh); }
[ "public", "void", "addChar", "(", "char", "nextCh", ")", "throws", "IOException", "{", "int", "ch", ";", "while", "(", "(", "ch", "=", "readChar", "(", ")", ")", ">=", "0", ")", "{", "outputChar", "(", "(", "char", ")", "ch", ")", ";", "}", "outp...
Adds the next character. @param nextCh the character to write
[ "Adds", "the", "next", "character", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java#L123-L133
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java
ByteToCharBase.readChar
private int readChar() throws IOException { Reader readEncoding = _readEncoding; if (readEncoding == null) return read(); else { if (readEncoding.read(_charBuffer, 0, 1) == 1) { return _charBuffer[0]; } else { return -1; } } }
java
private int readChar() throws IOException { Reader readEncoding = _readEncoding; if (readEncoding == null) return read(); else { if (readEncoding.read(_charBuffer, 0, 1) == 1) { return _charBuffer[0]; } else { return -1; } } }
[ "private", "int", "readChar", "(", ")", "throws", "IOException", "{", "Reader", "readEncoding", "=", "_readEncoding", ";", "if", "(", "readEncoding", "==", "null", ")", "return", "read", "(", ")", ";", "else", "{", "if", "(", "readEncoding", ".", "read", ...
Reads the next converted character.
[ "Reads", "the", "next", "converted", "character", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java#L151-L166
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java
ByteToCharBase.read
public int read() throws IOException { if (_byteHead == _byteTail) { return -1; } int b = _byteBuffer[_byteTail] & 0xff; _byteTail = (_byteTail + 1) % _byteBuffer.length; return b; }
java
public int read() throws IOException { if (_byteHead == _byteTail) { return -1; } int b = _byteBuffer[_byteTail] & 0xff; _byteTail = (_byteTail + 1) % _byteBuffer.length; return b; }
[ "public", "int", "read", "(", ")", "throws", "IOException", "{", "if", "(", "_byteHead", "==", "_byteTail", ")", "{", "return", "-", "1", ";", "}", "int", "b", "=", "_byteBuffer", "[", "_byteTail", "]", "&", "0xff", ";", "_byteTail", "=", "(", "_byte...
For internal use only. Reads the next byte from the byte buffer. @return the next byte
[ "For", "internal", "use", "only", ".", "Reads", "the", "next", "byte", "from", "the", "byte", "buffer", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/i18n/ByteToCharBase.java#L173-L184
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/cpool/InterfaceMethodRefConstant.java
InterfaceMethodRefConstant.setNameAndType
public void setNameAndType(String name, String type) { _nameAndTypeIndex = getConstantPool().addNameAndType(name, type).getIndex(); }
java
public void setNameAndType(String name, String type) { _nameAndTypeIndex = getConstantPool().addNameAndType(name, type).getIndex(); }
[ "public", "void", "setNameAndType", "(", "String", "name", ",", "String", "type", ")", "{", "_nameAndTypeIndex", "=", "getConstantPool", "(", ")", ".", "addNameAndType", "(", "name", ",", "type", ")", ".", "getIndex", "(", ")", ";", "}" ]
Sets the method name and type
[ "Sets", "the", "method", "name", "and", "type" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/cpool/InterfaceMethodRefConstant.java#L81-L84
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableKelp.java
TableKelp.putWithVersion
public void putWithVersion(RowCursor cursor, Result<Boolean> cont) { _tableService.put(cursor, PutType.PUT, cont); }
java
public void putWithVersion(RowCursor cursor, Result<Boolean> cont) { _tableService.put(cursor, PutType.PUT, cont); }
[ "public", "void", "putWithVersion", "(", "RowCursor", "cursor", ",", "Result", "<", "Boolean", ">", "cont", ")", "{", "_tableService", ".", "put", "(", "cursor", ",", "PutType", ".", "PUT", ",", "cont", ")", ";", "}" ]
Put using the version in the cursor, instead of clearing it.
[ "Put", "using", "the", "version", "in", "the", "cursor", "instead", "of", "clearing", "it", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableKelp.java#L403-L406
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/DateFormatter.java
DateFormatter.format
void format(StringBuilder sb, Temporal localDate) { //Instant localDate = ClockCurrent.GMT.instant(); int len = _timestamp.length; for (int j = 0; j < len; j++) { _timestamp[j].format(sb, localDate); } }
java
void format(StringBuilder sb, Temporal localDate) { //Instant localDate = ClockCurrent.GMT.instant(); int len = _timestamp.length; for (int j = 0; j < len; j++) { _timestamp[j].format(sb, localDate); } }
[ "void", "format", "(", "StringBuilder", "sb", ",", "Temporal", "localDate", ")", "{", "//Instant localDate = ClockCurrent.GMT.instant();", "int", "len", "=", "_timestamp", ".", "length", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "len", ";", "j", ...
Formats the timestamp
[ "Formats", "the", "timestamp" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/DateFormatter.java#L80-L88
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.writePage
@InService(TableWriterService.class) public void writePage(Page page, SegmentStream sOut, long oldSequence, int saveLength, int saveTail, int sequenceWrite, Result<Integer> result) { try { sOut.writePage(this, page, saveLength, saveTail, sequenceWrite, result); } catch (Exception e) { e.printStackTrace(); } }
java
@InService(TableWriterService.class) public void writePage(Page page, SegmentStream sOut, long oldSequence, int saveLength, int saveTail, int sequenceWrite, Result<Integer> result) { try { sOut.writePage(this, page, saveLength, saveTail, sequenceWrite, result); } catch (Exception e) { e.printStackTrace(); } }
[ "@", "InService", "(", "TableWriterService", ".", "class", ")", "public", "void", "writePage", "(", "Page", "page", ",", "SegmentStream", "sOut", ",", "long", "oldSequence", ",", "int", "saveLength", ",", "int", "saveTail", ",", "int", "sequenceWrite", ",", ...
Writes a page to the current segment @param page @param sOut @param oldSequence @param saveLength @param saveTail @param sequenceWrite page sequence to correlate write requests with flush completions
[ "Writes", "a", "page", "to", "the", "current", "segment" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L419-L434
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.writeBlobPage
@InService(TableWriterService.class) public void writeBlobPage(PageBlob page, int saveSequence, Result<Integer> result) { SegmentStream sOut = getBlobStream(); int saveLength = 0; int saveTail = 0; if (_blobSizeMax < page.getLength()) { _blobSizeMax = page.getLength(); calculateSegmentSize(); } sOut.writePage(this, page, saveLength, saveTail, saveSequence, result); _isBlobDirty = true; }
java
@InService(TableWriterService.class) public void writeBlobPage(PageBlob page, int saveSequence, Result<Integer> result) { SegmentStream sOut = getBlobStream(); int saveLength = 0; int saveTail = 0; if (_blobSizeMax < page.getLength()) { _blobSizeMax = page.getLength(); calculateSegmentSize(); } sOut.writePage(this, page, saveLength, saveTail, saveSequence, result); _isBlobDirty = true; }
[ "@", "InService", "(", "TableWriterService", ".", "class", ")", "public", "void", "writeBlobPage", "(", "PageBlob", "page", ",", "int", "saveSequence", ",", "Result", "<", "Integer", ">", "result", ")", "{", "SegmentStream", "sOut", "=", "getBlobStream", "(", ...
Writes a blob page to the current output segment. @param page the blob to be written @param saveSequence @return true on completion
[ "Writes", "a", "blob", "page", "to", "the", "current", "output", "segment", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L443-L461
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.openWriter
public OutSegment openWriter() { if (isGcRequired()) { // _gcSequence = _seqGen.get(); _table.getGcService().gc(_seqGen.get()); _seqSinceGcCount = 0; } _seqSinceGcCount++; long sequence = _seqGen.get(); return openWriterSeq(sequence); }
java
public OutSegment openWriter() { if (isGcRequired()) { // _gcSequence = _seqGen.get(); _table.getGcService().gc(_seqGen.get()); _seqSinceGcCount = 0; } _seqSinceGcCount++; long sequence = _seqGen.get(); return openWriterSeq(sequence); }
[ "public", "OutSegment", "openWriter", "(", ")", "{", "if", "(", "isGcRequired", "(", ")", ")", "{", "// _gcSequence = _seqGen.get();", "_table", ".", "getGcService", "(", ")", ".", "gc", "(", "_seqGen", ".", "get", "(", ")", ")", ";", "_seqSinceGcCount", "...
Opens a new segment writer. The segment's sequence id will be the next sequence number. @return the new segment writer
[ "Opens", "a", "new", "segment", "writer", ".", "The", "segment", "s", "sequence", "id", "will", "be", "the", "next", "sequence", "number", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L503-L515
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.calculateSegmentSize
private void calculateSegmentSize() { DatabaseKelp db = _table.database(); _segmentSizeNew = calculateSegmentSize(db.getSegmentSizeFactorNew(), _segmentSizeNew); _segmentSizeGc = calculateSegmentSize(db.getSegmentSizeFactorGc(), _segmentSizeGc); }
java
private void calculateSegmentSize() { DatabaseKelp db = _table.database(); _segmentSizeNew = calculateSegmentSize(db.getSegmentSizeFactorNew(), _segmentSizeNew); _segmentSizeGc = calculateSegmentSize(db.getSegmentSizeFactorGc(), _segmentSizeGc); }
[ "private", "void", "calculateSegmentSize", "(", ")", "{", "DatabaseKelp", "db", "=", "_table", ".", "database", "(", ")", ";", "_segmentSizeNew", "=", "calculateSegmentSize", "(", "db", ".", "getSegmentSizeFactorNew", "(", ")", ",", "_segmentSizeNew", ")", ";", ...
Calculates the dynamic segment size based on the current table size. Small tables use small segments and large tables use large segments to improve efficiency. A small table will have about 5 active segments because of GC, which means a table with 64k live entries will still use 5 * minSegmentSize. new segments: 1/64 of total table size gc segments: 1/8 of total table size
[ "Calculates", "the", "dynamic", "segment", "size", "based", "on", "the", "current", "table", "size", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L581-L590
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.calculateSegmentSize
private int calculateSegmentSize(int factor, int segmentSizeOld) { DatabaseKelp db = _table.database(); long segmentFactor = _tableLength / db.getSegmentSizeMin(); long segmentFactorNew = segmentFactor / factor; // segment size is (tableSize / factor), restricted to a power of 4 // over the min segment size. if (segmentFactorNew > 0) { int bit = 63 - Long.numberOfLeadingZeros(segmentFactorNew); bit &= ~0x1; long segmentFactorPower = (1 << bit); if (segmentFactorPower < segmentFactorNew) { segmentFactorNew = 4 * segmentFactorPower; } } long segmentSizeNew = segmentFactorNew * db.getSegmentSizeMin(); segmentSizeNew = Math.max(db.getSegmentSizeMin(), segmentSizeNew); long segmentSizeBlob = _blobSizeMax * 4; while (segmentSizeNew < segmentSizeBlob) { segmentSizeNew *= 4; } segmentSizeNew = Math.min(db.getSegmentSizeMax(), segmentSizeNew); return (int) Math.max(segmentSizeNew, segmentSizeOld); }
java
private int calculateSegmentSize(int factor, int segmentSizeOld) { DatabaseKelp db = _table.database(); long segmentFactor = _tableLength / db.getSegmentSizeMin(); long segmentFactorNew = segmentFactor / factor; // segment size is (tableSize / factor), restricted to a power of 4 // over the min segment size. if (segmentFactorNew > 0) { int bit = 63 - Long.numberOfLeadingZeros(segmentFactorNew); bit &= ~0x1; long segmentFactorPower = (1 << bit); if (segmentFactorPower < segmentFactorNew) { segmentFactorNew = 4 * segmentFactorPower; } } long segmentSizeNew = segmentFactorNew * db.getSegmentSizeMin(); segmentSizeNew = Math.max(db.getSegmentSizeMin(), segmentSizeNew); long segmentSizeBlob = _blobSizeMax * 4; while (segmentSizeNew < segmentSizeBlob) { segmentSizeNew *= 4; } segmentSizeNew = Math.min(db.getSegmentSizeMax(), segmentSizeNew); return (int) Math.max(segmentSizeNew, segmentSizeOld); }
[ "private", "int", "calculateSegmentSize", "(", "int", "factor", ",", "int", "segmentSizeOld", ")", "{", "DatabaseKelp", "db", "=", "_table", ".", "database", "(", ")", ";", "long", "segmentFactor", "=", "_tableLength", "/", "db", ".", "getSegmentSizeMin", "(",...
Calculate the dynamic segment size. The new segment size is a fraction of the current table size. @param factor the target ratio compared to the table size @param segmentSizeOld the previous segment size
[ "Calculate", "the", "dynamic", "segment", "size", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L600-L635
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.fsync
public void fsync(Result<Boolean> result) throws IOException { SegmentStream nodeStream = _nodeStream; // FlushCompletion cont = new FlushCompletion(result, nodeStream, blobStream); if (nodeStream != null) { nodeStream.fsync(result); } else { result.ok(true); } }
java
public void fsync(Result<Boolean> result) throws IOException { SegmentStream nodeStream = _nodeStream; // FlushCompletion cont = new FlushCompletion(result, nodeStream, blobStream); if (nodeStream != null) { nodeStream.fsync(result); } else { result.ok(true); } }
[ "public", "void", "fsync", "(", "Result", "<", "Boolean", ">", "result", ")", "throws", "IOException", "{", "SegmentStream", "nodeStream", "=", "_nodeStream", ";", "// FlushCompletion cont = new FlushCompletion(result, nodeStream, blobStream);", "if", "(", "nodeStream", "...
sync the output stream with the filesystem when possible.
[ "sync", "the", "output", "stream", "with", "the", "filesystem", "when", "possible", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L667-L680
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.afterDeliver
@AfterBatch public void afterDeliver() { SegmentStream nodeStream = _nodeStream; if (nodeStream != null) { if (_isBlobDirty) { _isBlobDirty = false; // nodeStream.flush(null); nodeStream.fsync(Result.ignore()); } else { nodeStream.flush(Result.ignore()); } } /* if (blobWriter != null) { try { blobWriter.flushSegment(); } catch (IOException e) { e.printStackTrace(); } } */ }
java
@AfterBatch public void afterDeliver() { SegmentStream nodeStream = _nodeStream; if (nodeStream != null) { if (_isBlobDirty) { _isBlobDirty = false; // nodeStream.flush(null); nodeStream.fsync(Result.ignore()); } else { nodeStream.flush(Result.ignore()); } } /* if (blobWriter != null) { try { blobWriter.flushSegment(); } catch (IOException e) { e.printStackTrace(); } } */ }
[ "@", "AfterBatch", "public", "void", "afterDeliver", "(", ")", "{", "SegmentStream", "nodeStream", "=", "_nodeStream", ";", "if", "(", "nodeStream", "!=", "null", ")", "{", "if", "(", "_isBlobDirty", ")", "{", "_isBlobDirty", "=", "false", ";", "// nodeStrea...
Flushes the stream after a batch of writes. If the writes included a blob write, the segment must be fsynced because the blob is not saved in the journal.
[ "Flushes", "the", "stream", "after", "a", "batch", "of", "writes", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L695-L721
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java
TableWriterServiceImpl.close
public void close(Result<Boolean> result) { _lifecycle.toDestroy(); SegmentStream nodeStream = _nodeStream; _nodeStream = null; if (nodeStream != null) { nodeStream.closeFsync(result.then(v->closeImpl())); } else { result.ok(true); } }
java
public void close(Result<Boolean> result) { _lifecycle.toDestroy(); SegmentStream nodeStream = _nodeStream; _nodeStream = null; if (nodeStream != null) { nodeStream.closeFsync(result.then(v->closeImpl())); } else { result.ok(true); } }
[ "public", "void", "close", "(", "Result", "<", "Boolean", ">", "result", ")", "{", "_lifecycle", ".", "toDestroy", "(", ")", ";", "SegmentStream", "nodeStream", "=", "_nodeStream", ";", "_nodeStream", "=", "null", ";", "if", "(", "nodeStream", "!=", "null"...
Closes the store.
[ "Closes", "the", "store", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableWriterServiceImpl.java#L726-L739
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.writePage
@InService(SegmentServiceImpl.class) public Page writePage(Page page, long oldSequence, int saveLength, int saveTail, int saveSequence, Result<Integer> result) { if (isClosed()) { return null; } // Type type = page.getType(); int pid = page.getId(); int nextPid = page.getNextId(); WriteStream out = out(); int head = (int) out.position(); try { int available = getAvailable(); if (available < head + page.size()) { return null; } Page newPage = page.writeCheckpoint(_table, this, oldSequence, saveLength, saveTail, saveSequence); if (newPage == null) { return null; } newPage.setSequence(getSequence()); out = out(); int tail = (int) out.position(); if (addIndex(out, page, newPage, saveSequence, newPage.getLastWriteType(), pid, nextPid, head, tail - head, result)) { return newPage; } else { return null; } } catch (Exception e) { e.printStackTrace(); return null; } }
java
@InService(SegmentServiceImpl.class) public Page writePage(Page page, long oldSequence, int saveLength, int saveTail, int saveSequence, Result<Integer> result) { if (isClosed()) { return null; } // Type type = page.getType(); int pid = page.getId(); int nextPid = page.getNextId(); WriteStream out = out(); int head = (int) out.position(); try { int available = getAvailable(); if (available < head + page.size()) { return null; } Page newPage = page.writeCheckpoint(_table, this, oldSequence, saveLength, saveTail, saveSequence); if (newPage == null) { return null; } newPage.setSequence(getSequence()); out = out(); int tail = (int) out.position(); if (addIndex(out, page, newPage, saveSequence, newPage.getLastWriteType(), pid, nextPid, head, tail - head, result)) { return newPage; } else { return null; } } catch (Exception e) { e.printStackTrace(); return null; } }
[ "@", "InService", "(", "SegmentServiceImpl", ".", "class", ")", "public", "Page", "writePage", "(", "Page", "page", ",", "long", "oldSequence", ",", "int", "saveLength", ",", "int", "saveTail", ",", "int", "saveSequence", ",", "Result", "<", "Integer", ">", ...
Writes the page to the segment. @param page @param oldSequence @param saveLength @param saveTail @param saveSequence @return
[ "Writes", "the", "page", "to", "the", "segment", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L228-L282
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.flushData
public void flushData() { if (isClosed()) { if (_pendingFlushEntries.size() > 0) { System.out.println("PENDING_FLUSH"); } return; } WriteStream out = _out; if (out != null) { try { out.flush(); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } } // flush entries to allow for stubs to replace buffers completePendingFlush(); }
java
public void flushData() { if (isClosed()) { if (_pendingFlushEntries.size() > 0) { System.out.println("PENDING_FLUSH"); } return; } WriteStream out = _out; if (out != null) { try { out.flush(); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } } // flush entries to allow for stubs to replace buffers completePendingFlush(); }
[ "public", "void", "flushData", "(", ")", "{", "if", "(", "isClosed", "(", ")", ")", "{", "if", "(", "_pendingFlushEntries", ".", "size", "(", ")", ">", "0", ")", "{", "System", ".", "out", ".", "println", "(", "\"PENDING_FLUSH\"", ")", ";", "}", "r...
Flushes the buffered data to the segment. After the flush, pending entries are notified, allowing page stubs to replace buffered pages. Since the written data is now in the mmap, the buffered page can be gc'ed and replaced with a stub read.
[ "Flushes", "the", "buffered", "data", "to", "the", "segment", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L359-L380
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.write
@Override public void write(byte []buffer, int offset, int length, boolean isEnd) throws IOException { int position = _position; if (length < 0) { throw new IllegalArgumentException(); } if (_indexAddress < position + length) { throw new IllegalArgumentException(L.l("Segment write overflow pos=0x{0} len=0x{1} entry-head=0x{2} seg-len=0x{3}. {4}", Long.toHexString(_position), Long.toHexString(length), Long.toHexString(_indexAddress), Long.toHexString(_segment.length()), _segment)); } //try (StoreWrite sOut = _readWrite.openWrite(_segment.getAddress(), // _segment.getLength())) { _sOut.write(_segment.getAddress() + position, buffer, offset, length); _position = position + length; _isDirty = true; }
java
@Override public void write(byte []buffer, int offset, int length, boolean isEnd) throws IOException { int position = _position; if (length < 0) { throw new IllegalArgumentException(); } if (_indexAddress < position + length) { throw new IllegalArgumentException(L.l("Segment write overflow pos=0x{0} len=0x{1} entry-head=0x{2} seg-len=0x{3}. {4}", Long.toHexString(_position), Long.toHexString(length), Long.toHexString(_indexAddress), Long.toHexString(_segment.length()), _segment)); } //try (StoreWrite sOut = _readWrite.openWrite(_segment.getAddress(), // _segment.getLength())) { _sOut.write(_segment.getAddress() + position, buffer, offset, length); _position = position + length; _isDirty = true; }
[ "@", "Override", "public", "void", "write", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ",", "boolean", "isEnd", ")", "throws", "IOException", "{", "int", "position", "=", "_position", ";", "if", "(", "length", "<", "0"...
Writes to the file from the WriteStream flush. After the write, a read from the mmap will succeed, but the headers cannot be written until after the fsync.
[ "Writes", "to", "the", "file", "from", "the", "WriteStream", "flush", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L388-L417
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.completePendingFlush
private void completePendingFlush() { int size = _pendingFlushEntries.size(); if (size == 0) { return; } // ArrayList<TableService.PageFlush> pageList = new ArrayList<>(); for (int i = 0; i < size; i++) { PendingEntry entry = _pendingFlushEntries.get(i); entry.afterFlush(); _pendingFsyncEntries.add(entry); } // _tableService.afterDataFlush(pageList); _pendingFlushEntries.clear(); }
java
private void completePendingFlush() { int size = _pendingFlushEntries.size(); if (size == 0) { return; } // ArrayList<TableService.PageFlush> pageList = new ArrayList<>(); for (int i = 0; i < size; i++) { PendingEntry entry = _pendingFlushEntries.get(i); entry.afterFlush(); _pendingFsyncEntries.add(entry); } // _tableService.afterDataFlush(pageList); _pendingFlushEntries.clear(); }
[ "private", "void", "completePendingFlush", "(", ")", "{", "int", "size", "=", "_pendingFlushEntries", ".", "size", "(", ")", ";", "if", "(", "size", "==", "0", ")", "{", "return", ";", "}", "// ArrayList<TableService.PageFlush> pageList = new ArrayList<>();", "for...
Notifies the calling service after the entry is written to the mmap. The entries will be added to the pending sync list.
[ "Notifies", "the", "calling", "service", "after", "the", "entry", "is", "written", "to", "the", "mmap", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L424-L445
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.fsyncImpl
private void fsyncImpl(Result<Boolean> result, FsyncType fsyncType) { try { flushData(); ArrayList<SegmentFsyncCallback> fsyncListeners = new ArrayList<>(_fsyncListeners); _fsyncListeners.clear(); Result<Boolean> resultNext = result.then((v,r)-> afterDataFsync(r, _position, fsyncType, fsyncListeners)); if (_isDirty || ! fsyncType.isSchedule()) { _isDirty = false; try (OutStore sOut = _readWrite.openWrite(_segment.extent())) { if (fsyncType.isSchedule()) { sOut.fsyncSchedule(resultNext); } else { sOut.fsync(resultNext); } } } else { resultNext.ok(true); } } catch (Throwable e) { e.printStackTrace(); result.fail(e); } }
java
private void fsyncImpl(Result<Boolean> result, FsyncType fsyncType) { try { flushData(); ArrayList<SegmentFsyncCallback> fsyncListeners = new ArrayList<>(_fsyncListeners); _fsyncListeners.clear(); Result<Boolean> resultNext = result.then((v,r)-> afterDataFsync(r, _position, fsyncType, fsyncListeners)); if (_isDirty || ! fsyncType.isSchedule()) { _isDirty = false; try (OutStore sOut = _readWrite.openWrite(_segment.extent())) { if (fsyncType.isSchedule()) { sOut.fsyncSchedule(resultNext); } else { sOut.fsync(resultNext); } } } else { resultNext.ok(true); } } catch (Throwable e) { e.printStackTrace(); result.fail(e); } }
[ "private", "void", "fsyncImpl", "(", "Result", "<", "Boolean", ">", "result", ",", "FsyncType", "fsyncType", ")", "{", "try", "{", "flushData", "(", ")", ";", "ArrayList", "<", "SegmentFsyncCallback", ">", "fsyncListeners", "=", "new", "ArrayList", "<>", "("...
Syncs the segment to the disk. After the segment's data is synced, the headers can be written. A second sync is needed to complete the header writes.
[ "Syncs", "the", "segment", "to", "the", "disk", ".", "After", "the", "segment", "s", "data", "is", "synced", "the", "headers", "can", "be", "written", ".", "A", "second", "sync", "is", "needed", "to", "complete", "the", "header", "writes", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L476-L507
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.afterDataFsync
private void afterDataFsync(Result<Boolean> result, int position, FsyncType fsyncType, ArrayList<SegmentFsyncCallback> listeners) { try { completeIndex(position); Result<Boolean> cont = result.then((v,r)-> afterIndexFsync(r, fsyncType, listeners)); if (fsyncType.isSchedule()) { _sOut.fsyncSchedule(cont); } else { _sOut.fsync(cont); } } catch (Throwable e) { result.fail(e); } }
java
private void afterDataFsync(Result<Boolean> result, int position, FsyncType fsyncType, ArrayList<SegmentFsyncCallback> listeners) { try { completeIndex(position); Result<Boolean> cont = result.then((v,r)-> afterIndexFsync(r, fsyncType, listeners)); if (fsyncType.isSchedule()) { _sOut.fsyncSchedule(cont); } else { _sOut.fsync(cont); } } catch (Throwable e) { result.fail(e); } }
[ "private", "void", "afterDataFsync", "(", "Result", "<", "Boolean", ">", "result", ",", "int", "position", ",", "FsyncType", "fsyncType", ",", "ArrayList", "<", "SegmentFsyncCallback", ">", "listeners", ")", "{", "try", "{", "completeIndex", "(", "position", "...
Callback after the page data has been fynced, so the index can be written. The page write is split in two, so the index is always written after the data is guaranteed to be flushed to disk.
[ "Callback", "after", "the", "page", "data", "has", "been", "fynced", "so", "the", "index", "can", "be", "written", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L516-L537
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.afterIndexFsync
private void afterIndexFsync(Result<Boolean> result, FsyncType fsyncType, ArrayList<SegmentFsyncCallback> fsyncListeners) { try { // completePendingEntries(_position); if (fsyncType.isClose()) { _isClosed = true; _segment.finishWriting(); if (_pendingFlushEntries.size() > 0 || _pendingFsyncEntries.size() > 0) { System.out.println("BROKEN_PEND: flush=" + _pendingFlushEntries.size() + " fsync=" + _pendingFsyncEntries.size() + " " + _pendingFlushEntries); } _readWrite.afterSequenceClose(_segment.getSequence()); } for (SegmentFsyncCallback listener : _fsyncListeners) { listener.onFsync(); } result.ok(true); } catch (Throwable exn) { result.fail(exn); } }
java
private void afterIndexFsync(Result<Boolean> result, FsyncType fsyncType, ArrayList<SegmentFsyncCallback> fsyncListeners) { try { // completePendingEntries(_position); if (fsyncType.isClose()) { _isClosed = true; _segment.finishWriting(); if (_pendingFlushEntries.size() > 0 || _pendingFsyncEntries.size() > 0) { System.out.println("BROKEN_PEND: flush=" + _pendingFlushEntries.size() + " fsync=" + _pendingFsyncEntries.size() + " " + _pendingFlushEntries); } _readWrite.afterSequenceClose(_segment.getSequence()); } for (SegmentFsyncCallback listener : _fsyncListeners) { listener.onFsync(); } result.ok(true); } catch (Throwable exn) { result.fail(exn); } }
[ "private", "void", "afterIndexFsync", "(", "Result", "<", "Boolean", ">", "result", ",", "FsyncType", "fsyncType", ",", "ArrayList", "<", "SegmentFsyncCallback", ">", "fsyncListeners", ")", "{", "try", "{", "// completePendingEntries(_position);", "if", "(", "fsyncT...
Callback after the index has been flushed.
[ "Callback", "after", "the", "index", "has", "been", "flushed", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L542-L570
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java
OutSegment.writeIndex
private void writeIndex(int entryAddress, byte []entryBuffer, int offset, int length) { long address = _segment.getAddress() + entryAddress; if (_segment.length() < entryAddress + length) { throw new IllegalStateException(L.l("offset=0x{0} length={1}", entryAddress, length)); } //try (StoreWrite os = _readWrite.openWrite(address, BLOCK_SIZE)) { _sOut.write(address, entryBuffer, offset, length); _isDirty = true; // } }
java
private void writeIndex(int entryAddress, byte []entryBuffer, int offset, int length) { long address = _segment.getAddress() + entryAddress; if (_segment.length() < entryAddress + length) { throw new IllegalStateException(L.l("offset=0x{0} length={1}", entryAddress, length)); } //try (StoreWrite os = _readWrite.openWrite(address, BLOCK_SIZE)) { _sOut.write(address, entryBuffer, offset, length); _isDirty = true; // } }
[ "private", "void", "writeIndex", "(", "int", "entryAddress", ",", "byte", "[", "]", "entryBuffer", ",", "int", "offset", ",", "int", "length", ")", "{", "long", "address", "=", "_segment", ".", "getAddress", "(", ")", "+", "entryAddress", ";", "if", "(",...
Write the current header to the output.
[ "Write", "the", "current", "header", "to", "the", "output", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/OutSegment.java#L687-L700
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/vault/ClassGeneratorVault.java
ClassGeneratorVault.createImpl
private static Constructor<?> createImpl(Class<?> cl, ClassLoader loader) { /** if (! Modifier.isAbstract(cl.getModifiers())) { throw new IllegalArgumentException(); } */ ClassGeneratorVault<?> generator = new ClassGeneratorVault<>(cl, loader); Class<?> proxyClass = generator.generate(); return proxyClass.getConstructors()[0]; }
java
private static Constructor<?> createImpl(Class<?> cl, ClassLoader loader) { /** if (! Modifier.isAbstract(cl.getModifiers())) { throw new IllegalArgumentException(); } */ ClassGeneratorVault<?> generator = new ClassGeneratorVault<>(cl, loader); Class<?> proxyClass = generator.generate(); return proxyClass.getConstructors()[0]; }
[ "private", "static", "Constructor", "<", "?", ">", "createImpl", "(", "Class", "<", "?", ">", "cl", ",", "ClassLoader", "loader", ")", "{", "/**\n if (! Modifier.isAbstract(cl.getModifiers())) {\n throw new IllegalArgumentException();\n }\n */", "ClassGeneratorVau...
Must return Constructor, not MethodHandle because MethodHandles cache the type in the permgen.
[ "Must", "return", "Constructor", "not", "MethodHandle", "because", "MethodHandles", "cache", "the", "type", "in", "the", "permgen", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/vault/ClassGeneratorVault.java#L160-L175
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/vault/ClassGeneratorVault.java
ClassGeneratorVault.introspectMethods
private void introspectMethods(JavaClass jClass) { for (Method method : getMethods()) { Class<?> []paramTypes = method.getParameterTypes(); int paramLen = paramTypes.length; if (! Modifier.isAbstract(method.getModifiers())) { continue; } if (Modifier.isStatic(method.getModifiers())) { continue; } if (Modifier.isFinal(method.getModifiers())) { continue; } /* if (! Modifier.isPublic(method.getModifiers())) { throw new IllegalArgumentException("Method must be public {0}", method); } */ if (method.getDeclaringClass().equals(Object.class)) { continue; } if (method.getName().equals("toString") && paramLen == 0) { continue; } if (method.getName().equals("hashCode") && paramLen == 0) { continue; } if (method.getName().equals("equals") && paramLen == 1 && paramTypes[0].equals(Object.class)) { continue; } // XXX: Need QA int ampResult = findAmpResult(paramTypes, Result.class); if (isCreate(method) || isFind(method)) { if (ampResult < 0) { throw new IllegalStateException(L.l("Result argument is required {0}", method)); } if (! void.class.equals(method.getReturnType())) { throw new IllegalArgumentException(L.l("method must return void {0}", method)); } } if (paramLen > 0 && ampResult >= 0) { /* if (ampResult != paramTypes.length - 1) { throw new IllegalStateException(L.l("invalid Result position. Result must be the final argument.")); } */ createAmpResultMethod(jClass, method, ampResult); } else if (ampResult < 0) { createAmpSendMethod(jClass, method); } else { throw new IllegalStateException(method.toString()); } } }
java
private void introspectMethods(JavaClass jClass) { for (Method method : getMethods()) { Class<?> []paramTypes = method.getParameterTypes(); int paramLen = paramTypes.length; if (! Modifier.isAbstract(method.getModifiers())) { continue; } if (Modifier.isStatic(method.getModifiers())) { continue; } if (Modifier.isFinal(method.getModifiers())) { continue; } /* if (! Modifier.isPublic(method.getModifiers())) { throw new IllegalArgumentException("Method must be public {0}", method); } */ if (method.getDeclaringClass().equals(Object.class)) { continue; } if (method.getName().equals("toString") && paramLen == 0) { continue; } if (method.getName().equals("hashCode") && paramLen == 0) { continue; } if (method.getName().equals("equals") && paramLen == 1 && paramTypes[0].equals(Object.class)) { continue; } // XXX: Need QA int ampResult = findAmpResult(paramTypes, Result.class); if (isCreate(method) || isFind(method)) { if (ampResult < 0) { throw new IllegalStateException(L.l("Result argument is required {0}", method)); } if (! void.class.equals(method.getReturnType())) { throw new IllegalArgumentException(L.l("method must return void {0}", method)); } } if (paramLen > 0 && ampResult >= 0) { /* if (ampResult != paramTypes.length - 1) { throw new IllegalStateException(L.l("invalid Result position. Result must be the final argument.")); } */ createAmpResultMethod(jClass, method, ampResult); } else if (ampResult < 0) { createAmpSendMethod(jClass, method); } else { throw new IllegalStateException(method.toString()); } } }
[ "private", "void", "introspectMethods", "(", "JavaClass", "jClass", ")", "{", "for", "(", "Method", "method", ":", "getMethods", "(", ")", ")", "{", "Class", "<", "?", ">", "[", "]", "paramTypes", "=", "method", ".", "getParameterTypes", "(", ")", ";", ...
Introspect the methods to find abstract methods.
[ "Introspect", "the", "methods", "to", "find", "abstract", "methods", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/vault/ClassGeneratorVault.java#L363-L440
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.create
public static DynamicClassLoader create(PathImpl path) { DynamicClassLoader loader = new DynamicClassLoader(null); CompilingLoader compilingLoader = new CompilingLoader(loader, path); compilingLoader.init(); loader.init(); return loader; }
java
public static DynamicClassLoader create(PathImpl path) { DynamicClassLoader loader = new DynamicClassLoader(null); CompilingLoader compilingLoader = new CompilingLoader(loader, path); compilingLoader.init(); loader.init(); return loader; }
[ "public", "static", "DynamicClassLoader", "create", "(", "PathImpl", "path", ")", "{", "DynamicClassLoader", "loader", "=", "new", "DynamicClassLoader", "(", "null", ")", ";", "CompilingLoader", "compilingLoader", "=", "new", "CompilingLoader", "(", "loader", ",", ...
Create a class loader based on the compiling loader @param path traditional classpath @return the new ClassLoader
[ "Create", "a", "class", "loader", "based", "on", "the", "compiling", "loader" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L160-L170
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.create
public static DynamicClassLoader create(ClassLoader parent, PathImpl classDir, PathImpl sourceDir, String args, String encoding) { DynamicClassLoader loader = new DynamicClassLoader(parent); loader.addLoader(new CompilingLoader(loader, classDir, sourceDir, args, encoding)); loader.init(); return loader; }
java
public static DynamicClassLoader create(ClassLoader parent, PathImpl classDir, PathImpl sourceDir, String args, String encoding) { DynamicClassLoader loader = new DynamicClassLoader(parent); loader.addLoader(new CompilingLoader(loader, classDir, sourceDir, args, encoding)); loader.init(); return loader; }
[ "public", "static", "DynamicClassLoader", "create", "(", "ClassLoader", "parent", ",", "PathImpl", "classDir", ",", "PathImpl", "sourceDir", ",", "String", "args", ",", "String", "encoding", ")", "{", "DynamicClassLoader", "loader", "=", "new", "DynamicClassLoader",...
Creates a new compiling class loader @param classDir generated class directory root @param sourceDir Java source directory root @param args Javac arguments @param encoding javac encoding
[ "Creates", "a", "new", "compiling", "class", "loader" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L180-L190
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.make
@Override public void make() { synchronized (this) { if (CurrentTime.currentTime() < _lastMakeTime + 2000) return; try { makeImpl(); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } _lastMakeTime = CurrentTime.currentTime(); } }
java
@Override public void make() { synchronized (this) { if (CurrentTime.currentTime() < _lastMakeTime + 2000) return; try { makeImpl(); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } _lastMakeTime = CurrentTime.currentTime(); } }
[ "@", "Override", "public", "void", "make", "(", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "CurrentTime", ".", "currentTime", "(", ")", "<", "_lastMakeTime", "+", "2000", ")", "return", ";", "try", "{", "makeImpl", "(", ")", ";", "}"...
Compiles all changed files in the class directory.
[ "Compiles", "all", "changed", "files", "in", "the", "class", "directory", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L380-L395
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.findAllModifiedClasses
private void findAllModifiedClasses(String name, PathImpl sourceDir, PathImpl classDir, String sourcePath, ArrayList<String> sources) throws IOException, ClassNotFoundException { String []list; try { list = sourceDir.list(); } catch (IOException e) { return; } for (int i = 0; list != null && i < list.length; i++) { if (list[i].startsWith(".")) continue; if (_excludedDirectories.contains(list[i])) continue; PathImpl subSource = sourceDir.lookup(list[i]); if (subSource.isDirectory()) { findAllModifiedClasses(name + list[i] + "/", subSource, classDir.lookup(list[i]), sourcePath, sources); } else if (list[i].endsWith(_sourceExt)) { int tail = list[i].length() - _sourceExt.length(); String prefix = list[i].substring(0, tail); PathImpl subClass = classDir.lookup(prefix + ".class"); if (subClass.getLastModified() < subSource.getLastModified()) { sources.add(name + list[i]); } } } if (! _requireSource) return; try { list = classDir.list(); } catch (IOException e) { return; } for (int i = 0; list != null && i < list.length; i++) { if (list[i].startsWith(".")) continue; if (_excludedDirectories.contains(list[i])) continue; PathImpl subClass = classDir.lookup(list[i]); if (list[i].endsWith(".class")) { String prefix = list[i].substring(0, list[i].length() - 6); PathImpl subSource = sourceDir.lookup(prefix + _sourceExt); if (! subSource.exists()) { String tail = subSource.getTail(); boolean doRemove = true; if (tail.indexOf('$') > 0) { String subTail = tail.substring(0, tail.indexOf('$')) + _sourceExt; PathImpl subJava = subSource.getParent().lookup(subTail); if (subJava.exists()) doRemove = false; } if (doRemove) { log.finer(L.l("removing obsolete class '{0}'.", subClass.getPath())); subClass.remove(); } } } } }
java
private void findAllModifiedClasses(String name, PathImpl sourceDir, PathImpl classDir, String sourcePath, ArrayList<String> sources) throws IOException, ClassNotFoundException { String []list; try { list = sourceDir.list(); } catch (IOException e) { return; } for (int i = 0; list != null && i < list.length; i++) { if (list[i].startsWith(".")) continue; if (_excludedDirectories.contains(list[i])) continue; PathImpl subSource = sourceDir.lookup(list[i]); if (subSource.isDirectory()) { findAllModifiedClasses(name + list[i] + "/", subSource, classDir.lookup(list[i]), sourcePath, sources); } else if (list[i].endsWith(_sourceExt)) { int tail = list[i].length() - _sourceExt.length(); String prefix = list[i].substring(0, tail); PathImpl subClass = classDir.lookup(prefix + ".class"); if (subClass.getLastModified() < subSource.getLastModified()) { sources.add(name + list[i]); } } } if (! _requireSource) return; try { list = classDir.list(); } catch (IOException e) { return; } for (int i = 0; list != null && i < list.length; i++) { if (list[i].startsWith(".")) continue; if (_excludedDirectories.contains(list[i])) continue; PathImpl subClass = classDir.lookup(list[i]); if (list[i].endsWith(".class")) { String prefix = list[i].substring(0, list[i].length() - 6); PathImpl subSource = sourceDir.lookup(prefix + _sourceExt); if (! subSource.exists()) { String tail = subSource.getTail(); boolean doRemove = true; if (tail.indexOf('$') > 0) { String subTail = tail.substring(0, tail.indexOf('$')) + _sourceExt; PathImpl subJava = subSource.getParent().lookup(subTail); if (subJava.exists()) doRemove = false; } if (doRemove) { log.finer(L.l("removing obsolete class '{0}'.", subClass.getPath())); subClass.remove(); } } } } }
[ "private", "void", "findAllModifiedClasses", "(", "String", "name", ",", "PathImpl", "sourceDir", ",", "PathImpl", "classDir", ",", "String", "sourcePath", ",", "ArrayList", "<", "String", ">", "sources", ")", "throws", "IOException", ",", "ClassNotFoundException", ...
Returns the classes which need compilation.
[ "Returns", "the", "classes", "which", "need", "compilation", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L430-L511
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.getClassEntry
@Override protected ClassEntry getClassEntry(String name, String pathName) throws ClassNotFoundException { PathImpl classFile = _classDir.lookup(pathName); /* Path classDir = classFile.getParent(); if (! classDir.isDirectory()) return null; */ String javaName = name.replace('.', '/') + _sourceExt; PathImpl javaFile = _sourceDir.lookup(javaName); for (int i = 0; i < INNER_CLASS_SEPARATORS.length; i++) { char sep = INNER_CLASS_SEPARATORS[i]; if (name.indexOf(sep) > 0) { String subName = name.substring(0, name.indexOf(sep)); String subJavaName = subName.replace('.', '/') + _sourceExt; PathImpl subJava = _sourceDir.lookup(subJavaName); if (subJava.exists()) { javaFile = subJava; } } } synchronized (this) { if (_requireSource && ! javaFile.exists()) { boolean doRemove = true; if (doRemove) { log.finer(L.l("removing obsolete class `{0}'.", classFile.getPath())); try { classFile.remove(); } catch (IOException e) { log.log(Level.WARNING, e.toString(), e); } return null; } } if (! classFile.canRead() && ! javaFile.canRead()) return null; return new CompilingClassEntry(this, getClassLoader(), name, javaFile, classFile, getCodeSource(classFile)); } }
java
@Override protected ClassEntry getClassEntry(String name, String pathName) throws ClassNotFoundException { PathImpl classFile = _classDir.lookup(pathName); /* Path classDir = classFile.getParent(); if (! classDir.isDirectory()) return null; */ String javaName = name.replace('.', '/') + _sourceExt; PathImpl javaFile = _sourceDir.lookup(javaName); for (int i = 0; i < INNER_CLASS_SEPARATORS.length; i++) { char sep = INNER_CLASS_SEPARATORS[i]; if (name.indexOf(sep) > 0) { String subName = name.substring(0, name.indexOf(sep)); String subJavaName = subName.replace('.', '/') + _sourceExt; PathImpl subJava = _sourceDir.lookup(subJavaName); if (subJava.exists()) { javaFile = subJava; } } } synchronized (this) { if (_requireSource && ! javaFile.exists()) { boolean doRemove = true; if (doRemove) { log.finer(L.l("removing obsolete class `{0}'.", classFile.getPath())); try { classFile.remove(); } catch (IOException e) { log.log(Level.WARNING, e.toString(), e); } return null; } } if (! classFile.canRead() && ! javaFile.canRead()) return null; return new CompilingClassEntry(this, getClassLoader(), name, javaFile, classFile, getCodeSource(classFile)); } }
[ "@", "Override", "protected", "ClassEntry", "getClassEntry", "(", "String", "name", ",", "String", "pathName", ")", "throws", "ClassNotFoundException", "{", "PathImpl", "classFile", "=", "_classDir", ".", "lookup", "(", "pathName", ")", ";", "/*\n Path classDir =...
Loads the specified class, compiling if necessary.
[ "Loads", "the", "specified", "class", "compiling", "if", "necessary", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L516-L569
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.checkSource
boolean checkSource(PathImpl sourceDir, String javaName) { try { while (javaName != null && ! javaName.equals("")) { int p = javaName.indexOf('/'); String head; if (p >= 0) { head = javaName.substring(0, p); javaName = javaName.substring(p + 1); } else { head = javaName; javaName = null; } String []names = sourceDir.list(); int i; for (i = 0; i < names.length; i++) { if (names[i].equals(head)) break; } if (i == names.length) return false; sourceDir = sourceDir.lookup(head); } } catch (IOException e) { log.log(Level.FINE, e.toString(), e); return false; } return true; }
java
boolean checkSource(PathImpl sourceDir, String javaName) { try { while (javaName != null && ! javaName.equals("")) { int p = javaName.indexOf('/'); String head; if (p >= 0) { head = javaName.substring(0, p); javaName = javaName.substring(p + 1); } else { head = javaName; javaName = null; } String []names = sourceDir.list(); int i; for (i = 0; i < names.length; i++) { if (names[i].equals(head)) break; } if (i == names.length) return false; sourceDir = sourceDir.lookup(head); } } catch (IOException e) { log.log(Level.FINE, e.toString(), e); return false; } return true; }
[ "boolean", "checkSource", "(", "PathImpl", "sourceDir", ",", "String", "javaName", ")", "{", "try", "{", "while", "(", "javaName", "!=", "null", "&&", "!", "javaName", ".", "equals", "(", "\"\"", ")", ")", "{", "int", "p", "=", "javaName", ".", "indexO...
Checks that the case is okay for the source.
[ "Checks", "that", "the", "case", "is", "okay", "for", "the", "source", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L584-L619
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.getPath
@Override public PathImpl getPath(String name) { PathImpl path = _classDir.lookup(name); if (path != null && path.exists()) return path; path = _sourceDir.lookup(name); if (path != null && path.exists()) return path; return null; }
java
@Override public PathImpl getPath(String name) { PathImpl path = _classDir.lookup(name); if (path != null && path.exists()) return path; path = _sourceDir.lookup(name); if (path != null && path.exists()) return path; return null; }
[ "@", "Override", "public", "PathImpl", "getPath", "(", "String", "name", ")", "{", "PathImpl", "path", "=", "_classDir", ".", "lookup", "(", "name", ")", ";", "if", "(", "path", "!=", "null", "&&", "path", ".", "exists", "(", ")", ")", "return", "pat...
Returns the path for the given name. @param name the name of the class
[ "Returns", "the", "path", "for", "the", "given", "name", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L715-L729
train
baratine/baratine
framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java
CompilingLoader.buildClassPath
@Override protected void buildClassPath(ArrayList<String> pathList) { if (! _classDir.getScheme().equals("file")) return; try { if (! _classDir.isDirectory() && _sourceDir.isDirectory()) { try { _classDir.mkdirs(); } catch (IOException e) { } } if (_classDir.isDirectory()) { String path = _classDir.getNativePath(); if (! pathList.contains(path)) pathList.add(path); } if (! _classDir.equals(_sourceDir)) { String path = _sourceDir.getNativePath(); if (! pathList.contains(path)) pathList.add(path); } } catch (java.security.AccessControlException e) { log.log(Level.WARNING, e.toString(), e); } }
java
@Override protected void buildClassPath(ArrayList<String> pathList) { if (! _classDir.getScheme().equals("file")) return; try { if (! _classDir.isDirectory() && _sourceDir.isDirectory()) { try { _classDir.mkdirs(); } catch (IOException e) { } } if (_classDir.isDirectory()) { String path = _classDir.getNativePath(); if (! pathList.contains(path)) pathList.add(path); } if (! _classDir.equals(_sourceDir)) { String path = _sourceDir.getNativePath(); if (! pathList.contains(path)) pathList.add(path); } } catch (java.security.AccessControlException e) { log.log(Level.WARNING, e.toString(), e); } }
[ "@", "Override", "protected", "void", "buildClassPath", "(", "ArrayList", "<", "String", ">", "pathList", ")", "{", "if", "(", "!", "_classDir", ".", "getScheme", "(", ")", ".", "equals", "(", "\"file\"", ")", ")", "return", ";", "try", "{", "if", "(",...
Adds the classpath we're responsible for to the classpath @param head the overriding classpath @return the new classpath
[ "Adds", "the", "classpath", "we", "re", "responsible", "for", "to", "the", "classpath" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/loader/CompilingLoader.java#L745-L775
train
baratine/baratine
web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java
RequestBaratineImpl.session
@Override public ServiceRefAmp session(String name) { String address = "session:///" + name + "/"; return sessionImpl(address); }
java
@Override public ServiceRefAmp session(String name) { String address = "session:///" + name + "/"; return sessionImpl(address); }
[ "@", "Override", "public", "ServiceRefAmp", "session", "(", "String", "name", ")", "{", "String", "address", "=", "\"session:///\"", "+", "name", "+", "\"/\"", ";", "return", "sessionImpl", "(", "address", ")", ";", "}" ]
Find the session by its service name. If the session doesn't exist, create it.
[ "Find", "the", "session", "by", "its", "service", "name", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java#L257-L263
train
baratine/baratine
web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java
RequestBaratineImpl.session
@Override public <X> X session(Class<X> type) { String address = services().address(type); if (address.startsWith("/")) { address = "session://" + address; } return sessionImpl(address + "/").as(type); }
java
@Override public <X> X session(Class<X> type) { String address = services().address(type); if (address.startsWith("/")) { address = "session://" + address; } return sessionImpl(address + "/").as(type); }
[ "@", "Override", "public", "<", "X", ">", "X", "session", "(", "Class", "<", "X", ">", "type", ")", "{", "String", "address", "=", "services", "(", ")", ".", "address", "(", "type", ")", ";", "if", "(", "address", ".", "startsWith", "(", "\"/\"", ...
Find the session by its service type. If the session doesn't exist, create it.
[ "Find", "the", "session", "by", "its", "service", "type", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java#L270-L280
train
baratine/baratine
web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java
RequestBaratineImpl.sessionImpl
private ServiceRefAmp sessionImpl(String address) { if (! address.startsWith("session:") || ! address.endsWith("/")) { throw new IllegalArgumentException(address); } String sessionId = cookie("JSESSIONID"); if (sessionId == null) { sessionId = generateSessionId(); cookie("JSESSIONID", sessionId); } return services().service(address + sessionId); }
java
private ServiceRefAmp sessionImpl(String address) { if (! address.startsWith("session:") || ! address.endsWith("/")) { throw new IllegalArgumentException(address); } String sessionId = cookie("JSESSIONID"); if (sessionId == null) { sessionId = generateSessionId(); cookie("JSESSIONID", sessionId); } return services().service(address + sessionId); }
[ "private", "ServiceRefAmp", "sessionImpl", "(", "String", "address", ")", "{", "if", "(", "!", "address", ".", "startsWith", "(", "\"session:\"", ")", "||", "!", "address", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "throw", "new", "IllegalArgumentExcepti...
Find or create a session cookie as the session id and find or create a session with the generated address.
[ "Find", "or", "create", "a", "session", "cookie", "as", "the", "session", "id", "and", "find", "or", "create", "a", "session", "with", "the", "generated", "address", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java#L286-L301
train
baratine/baratine
web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java
RequestBaratineImpl.upgrade
@Override public void upgrade(Object protocol) { Objects.requireNonNull(protocol); if (protocol instanceof ServiceWebSocket) { ServiceWebSocket<?,?> webSocket = (ServiceWebSocket<?,?>) protocol; upgradeWebSocket(webSocket); } else { throw new IllegalArgumentException(protocol.toString()); } }
java
@Override public void upgrade(Object protocol) { Objects.requireNonNull(protocol); if (protocol instanceof ServiceWebSocket) { ServiceWebSocket<?,?> webSocket = (ServiceWebSocket<?,?>) protocol; upgradeWebSocket(webSocket); } else { throw new IllegalArgumentException(protocol.toString()); } }
[ "@", "Override", "public", "void", "upgrade", "(", "Object", "protocol", ")", "{", "Objects", ".", "requireNonNull", "(", "protocol", ")", ";", "if", "(", "protocol", "instanceof", "ServiceWebSocket", ")", "{", "ServiceWebSocket", "<", "?", ",", "?", ">", ...
Starts an upgrade of the HTTP request to a protocol on raw TCP.
[ "Starts", "an", "upgrade", "of", "the", "HTTP", "request", "to", "a", "protocol", "on", "raw", "TCP", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/web/webapp/RequestBaratineImpl.java#L363-L376
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JClassWrapper.java
JClassWrapper.getMethods
public JMethod []getMethods() { Method []methods = _class.getMethods(); JMethod []jMethods = new JMethod[methods.length]; for (int i = 0; i < methods.length; i++) { jMethods[i] = new JMethodWrapper(methods[i], getClassLoader()); } return jMethods; }
java
public JMethod []getMethods() { Method []methods = _class.getMethods(); JMethod []jMethods = new JMethod[methods.length]; for (int i = 0; i < methods.length; i++) { jMethods[i] = new JMethodWrapper(methods[i], getClassLoader()); } return jMethods; }
[ "public", "JMethod", "[", "]", "getMethods", "(", ")", "{", "Method", "[", "]", "methods", "=", "_class", ".", "getMethods", "(", ")", ";", "JMethod", "[", "]", "jMethods", "=", "new", "JMethod", "[", "methods", ".", "length", "]", ";", "for", "(", ...
Returns the public methods.
[ "Returns", "the", "public", "methods", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JClassWrapper.java#L241-L252
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JClassWrapper.java
JClassWrapper.getMethod
public JMethod getMethod(String name, JClass []types) { JClassLoader jClassLoader = getClassLoader(); return getMethod(_class, name, types, jClassLoader); }
java
public JMethod getMethod(String name, JClass []types) { JClassLoader jClassLoader = getClassLoader(); return getMethod(_class, name, types, jClassLoader); }
[ "public", "JMethod", "getMethod", "(", "String", "name", ",", "JClass", "[", "]", "types", ")", "{", "JClassLoader", "jClassLoader", "=", "getClassLoader", "(", ")", ";", "return", "getMethod", "(", "_class", ",", "name", ",", "types", ",", "jClassLoader", ...
Returns the matching methods.
[ "Returns", "the", "matching", "methods", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JClassWrapper.java#L257-L262
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JClassWrapper.java
JClassWrapper.getConstructors
public JMethod []getConstructors() { Constructor []methods = _class.getConstructors(); JMethod []jMethods = new JMethod[methods.length]; for (int i = 0; i < methods.length; i++) { jMethods[i] = new JConstructorWrapper(methods[i], getClassLoader()); } return jMethods; }
java
public JMethod []getConstructors() { Constructor []methods = _class.getConstructors(); JMethod []jMethods = new JMethod[methods.length]; for (int i = 0; i < methods.length; i++) { jMethods[i] = new JConstructorWrapper(methods[i], getClassLoader()); } return jMethods; }
[ "public", "JMethod", "[", "]", "getConstructors", "(", ")", "{", "Constructor", "[", "]", "methods", "=", "_class", ".", "getConstructors", "(", ")", ";", "JMethod", "[", "]", "jMethods", "=", "new", "JMethod", "[", "methods", ".", "length", "]", ";", ...
Returns the public constructors.
[ "Returns", "the", "public", "constructors", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JClassWrapper.java#L300-L311
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/h3/io/InRawH3Impl.java
InRawH3Impl.scan
@Override public void scan(InH3Amp in, PathH3Amp path, Object[] values) { int ch = read(); switch (ch) { case 0xd0: readDefinition(in); scan(in, path, values); return; case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7: case 0xd8: case 0xd9: case 0xda: case 0xdb: case 0xdc: case 0xdd: case 0xde: case 0xdf: { int id = ch - 0xd0; in.serializer(id).scan(this, path, in, values); return; } case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: case 0xe6: case 0xe7: case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef: { int id = (int) readLong(ch - 0xe0, 4); in.serializer(id).scan(this, path, in, values); return; } default: throw error(L.l("Unexpected opcode 0x{0} while scanning for {1}", Integer.toHexString(ch), path)); } }
java
@Override public void scan(InH3Amp in, PathH3Amp path, Object[] values) { int ch = read(); switch (ch) { case 0xd0: readDefinition(in); scan(in, path, values); return; case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7: case 0xd8: case 0xd9: case 0xda: case 0xdb: case 0xdc: case 0xdd: case 0xde: case 0xdf: { int id = ch - 0xd0; in.serializer(id).scan(this, path, in, values); return; } case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: case 0xe6: case 0xe7: case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef: { int id = (int) readLong(ch - 0xe0, 4); in.serializer(id).scan(this, path, in, values); return; } default: throw error(L.l("Unexpected opcode 0x{0} while scanning for {1}", Integer.toHexString(ch), path)); } }
[ "@", "Override", "public", "void", "scan", "(", "InH3Amp", "in", ",", "PathH3Amp", "path", ",", "Object", "[", "]", "values", ")", "{", "int", "ch", "=", "read", "(", ")", ";", "switch", "(", "ch", ")", "{", "case", "0xd0", ":", "readDefinition", "...
Scan for a query.
[ "Scan", "for", "a", "query", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/InRawH3Impl.java#L415-L452
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.setParent
@Override public void setParent(Logger parent) { if (parent.equals(_parent)) return; super.setParent(parent); if (parent instanceof EnvironmentLogger) { _parent = (EnvironmentLogger) parent; _parent.addChild(this); } updateEffectiveLevel(_systemClassLoader); }
java
@Override public void setParent(Logger parent) { if (parent.equals(_parent)) return; super.setParent(parent); if (parent instanceof EnvironmentLogger) { _parent = (EnvironmentLogger) parent; _parent.addChild(this); } updateEffectiveLevel(_systemClassLoader); }
[ "@", "Override", "public", "void", "setParent", "(", "Logger", "parent", ")", "{", "if", "(", "parent", ".", "equals", "(", "_parent", ")", ")", "return", ";", "super", ".", "setParent", "(", "parent", ")", ";", "if", "(", "parent", "instanceof", "Envi...
Sets the logger's parent. This should only be called by the LogManager code.
[ "Sets", "the", "logger", "s", "parent", ".", "This", "should", "only", "be", "called", "by", "the", "LogManager", "code", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L104-L119
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.getLevel
@Override public Level getLevel() { if (_localLevel != null) { Level level = _localLevel.get(); if (level != null) { return level; } } return _systemLevel; }
java
@Override public Level getLevel() { if (_localLevel != null) { Level level = _localLevel.get(); if (level != null) { return level; } } return _systemLevel; }
[ "@", "Override", "public", "Level", "getLevel", "(", ")", "{", "if", "(", "_localLevel", "!=", "null", ")", "{", "Level", "level", "=", "_localLevel", ".", "get", "(", ")", ";", "if", "(", "level", "!=", "null", ")", "{", "return", "level", ";", "}...
Returns the logger's assigned level.
[ "Returns", "the", "logger", "s", "assigned", "level", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L128-L140
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.setLevel
@Override public void setLevel(Level level) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { loader = _systemClassLoader; } if (loader != _systemClassLoader) { if (_localLevel == null) _localLevel = new EnvironmentLocal<Level>(); _localLevel.set(level); if (level != null) { addLoader(loader); } } else { _systemLevel = level; } updateEffectiveLevel(loader); }
java
@Override public void setLevel(Level level) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { loader = _systemClassLoader; } if (loader != _systemClassLoader) { if (_localLevel == null) _localLevel = new EnvironmentLocal<Level>(); _localLevel.set(level); if (level != null) { addLoader(loader); } } else { _systemLevel = level; } updateEffectiveLevel(loader); }
[ "@", "Override", "public", "void", "setLevel", "(", "Level", "level", ")", "{", "ClassLoader", "loader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", "loader", "==", "null", ")", "{", "loader", "=...
Application API to set the level. @param level the logging level to set for the logger.
[ "Application", "API", "to", "set", "the", "level", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L147-L171
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.getHandlers
@Override public Handler []getHandlers() { Handler []handlers = _localHandlers.get(); if (handlers != null) return handlers; else return EMPTY_HANDLERS; }
java
@Override public Handler []getHandlers() { Handler []handlers = _localHandlers.get(); if (handlers != null) return handlers; else return EMPTY_HANDLERS; }
[ "@", "Override", "public", "Handler", "[", "]", "getHandlers", "(", ")", "{", "Handler", "[", "]", "handlers", "=", "_localHandlers", ".", "get", "(", ")", ";", "if", "(", "handlers", "!=", "null", ")", "return", "handlers", ";", "else", "return", "EMP...
Returns the handlers.
[ "Returns", "the", "handlers", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L180-L189
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.removeHandler
@Override public void removeHandler(Handler handler) { synchronized (this) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { loader = _systemClassLoader; } for (int i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader refLoader = ref.get(); if (refLoader == null) { _loaders.remove(i); } if (isParentLoader(loader, refLoader)) { removeHandler(handler, refLoader); } } HandlerEntry ownHandlers = _ownHandlers.get(); if (ownHandlers != null) ownHandlers.removeHandler(handler); } }
java
@Override public void removeHandler(Handler handler) { synchronized (this) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { loader = _systemClassLoader; } for (int i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader refLoader = ref.get(); if (refLoader == null) { _loaders.remove(i); } if (isParentLoader(loader, refLoader)) { removeHandler(handler, refLoader); } } HandlerEntry ownHandlers = _ownHandlers.get(); if (ownHandlers != null) ownHandlers.removeHandler(handler); } }
[ "@", "Override", "public", "void", "removeHandler", "(", "Handler", "handler", ")", "{", "synchronized", "(", "this", ")", "{", "ClassLoader", "loader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", ...
Removes a handler.
[ "Removes", "a", "handler", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L238-L265
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.isLoggable
@Override public final boolean isLoggable(Level level) { if (level == null) return false; int intValue = level.intValue(); if (intValue < _finestEffectiveLevelValue) return false; else if (! _hasLocalEffectiveLevel) { return true; } else { Integer localValue = _localEffectiveLevel.get(); if (localValue != null) { int localIntValue = localValue.intValue(); if (localIntValue == Level.OFF.intValue()) return false; else return localIntValue <= intValue; } else { if (_systemEffectiveLevelValue == Level.OFF.intValue()) return false; else return _systemEffectiveLevelValue <= intValue; } } }
java
@Override public final boolean isLoggable(Level level) { if (level == null) return false; int intValue = level.intValue(); if (intValue < _finestEffectiveLevelValue) return false; else if (! _hasLocalEffectiveLevel) { return true; } else { Integer localValue = _localEffectiveLevel.get(); if (localValue != null) { int localIntValue = localValue.intValue(); if (localIntValue == Level.OFF.intValue()) return false; else return localIntValue <= intValue; } else { if (_systemEffectiveLevelValue == Level.OFF.intValue()) return false; else return _systemEffectiveLevelValue <= intValue; } } }
[ "@", "Override", "public", "final", "boolean", "isLoggable", "(", "Level", "level", ")", "{", "if", "(", "level", "==", "null", ")", "return", "false", ";", "int", "intValue", "=", "level", ".", "intValue", "(", ")", ";", "if", "(", "intValue", "<", ...
True if the level is loggable
[ "True", "if", "the", "level", "is", "loggable" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L274-L305
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.getUseParentHandlers
@Override public boolean getUseParentHandlers() { Boolean value = _useParentHandlers.get(); if (value != null) return Boolean.TRUE.equals(value); else return true; }
java
@Override public boolean getUseParentHandlers() { Boolean value = _useParentHandlers.get(); if (value != null) return Boolean.TRUE.equals(value); else return true; }
[ "@", "Override", "public", "boolean", "getUseParentHandlers", "(", ")", "{", "Boolean", "value", "=", "_useParentHandlers", ".", "get", "(", ")", ";", "if", "(", "value", "!=", "null", ")", "return", "Boolean", ".", "TRUE", ".", "equals", "(", "value", "...
Returns the use-parent-handlers
[ "Returns", "the", "use", "-", "parent", "-", "handlers" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L310-L319
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.log
@Override public void log(LogRecord record) { if (record == null) return; Level recordLevel = record.getLevel(); if (! isLoggable(recordLevel)) return; for (Logger ptr = this; ptr != null; ptr = ptr.getParent()) { Handler handlers[] = ptr.getHandlers(); if (handlers != null) { for (int i = 0; i < handlers.length; i++) { handlers[i].publish(record); } } if (! ptr.getUseParentHandlers()) break; } }
java
@Override public void log(LogRecord record) { if (record == null) return; Level recordLevel = record.getLevel(); if (! isLoggable(recordLevel)) return; for (Logger ptr = this; ptr != null; ptr = ptr.getParent()) { Handler handlers[] = ptr.getHandlers(); if (handlers != null) { for (int i = 0; i < handlers.length; i++) { handlers[i].publish(record); } } if (! ptr.getUseParentHandlers()) break; } }
[ "@", "Override", "public", "void", "log", "(", "LogRecord", "record", ")", "{", "if", "(", "record", "==", "null", ")", "return", ";", "Level", "recordLevel", "=", "record", ".", "getLevel", "(", ")", ";", "if", "(", "!", "isLoggable", "(", "recordLeve...
Logs the message.
[ "Logs", "the", "message", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L333-L356
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.addHandler
private void addHandler(Handler handler, ClassLoader loader) { // handlers ordered by level ArrayList<Handler> handlers = new ArrayList<Handler>(); handlers.add(handler); for (ClassLoader ptr = loader; ptr != null; ptr = ptr.getParent()) { Handler []localHandlers = _localHandlers.getLevel(ptr); if (localHandlers != null) { for (int i = 0; i < localHandlers.length; i++) { int p = handlers.indexOf(localHandlers[i]); if (p < 0) { handlers.add(localHandlers[i]); } else { Handler oldHandler = handlers.get(p); if (localHandlers[i].getLevel().intValue() < oldHandler.getLevel().intValue()) { handlers.set(p, localHandlers[i]); } } } } } Handler []newHandlers = new Handler[handlers.size()]; handlers.toArray(newHandlers); if (loader == _systemClassLoader) loader = null; _localHandlers.set(newHandlers, loader); }
java
private void addHandler(Handler handler, ClassLoader loader) { // handlers ordered by level ArrayList<Handler> handlers = new ArrayList<Handler>(); handlers.add(handler); for (ClassLoader ptr = loader; ptr != null; ptr = ptr.getParent()) { Handler []localHandlers = _localHandlers.getLevel(ptr); if (localHandlers != null) { for (int i = 0; i < localHandlers.length; i++) { int p = handlers.indexOf(localHandlers[i]); if (p < 0) { handlers.add(localHandlers[i]); } else { Handler oldHandler = handlers.get(p); if (localHandlers[i].getLevel().intValue() < oldHandler.getLevel().intValue()) { handlers.set(p, localHandlers[i]); } } } } } Handler []newHandlers = new Handler[handlers.size()]; handlers.toArray(newHandlers); if (loader == _systemClassLoader) loader = null; _localHandlers.set(newHandlers, loader); }
[ "private", "void", "addHandler", "(", "Handler", "handler", ",", "ClassLoader", "loader", ")", "{", "// handlers ordered by level", "ArrayList", "<", "Handler", ">", "handlers", "=", "new", "ArrayList", "<", "Handler", ">", "(", ")", ";", "handlers", ".", "add...
Adds a new handler with a given classloader context.
[ "Adds", "a", "new", "handler", "with", "a", "given", "classloader", "context", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L375-L411
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.isParentLoader
private boolean isParentLoader(ClassLoader parent, ClassLoader child) { for (; child != null; child = child.getParent()) { if (child == parent) return true; } return false; }
java
private boolean isParentLoader(ClassLoader parent, ClassLoader child) { for (; child != null; child = child.getParent()) { if (child == parent) return true; } return false; }
[ "private", "boolean", "isParentLoader", "(", "ClassLoader", "parent", ",", "ClassLoader", "child", ")", "{", "for", "(", ";", "child", "!=", "null", ";", "child", "=", "child", ".", "getParent", "(", ")", ")", "{", "if", "(", "child", "==", "parent", "...
Returns true if 'parent' is a parent classloader of 'child'. @param parent the classloader to test as a parent. @param child the classloader to test as a child.
[ "Returns", "true", "if", "parent", "is", "a", "parent", "classloader", "of", "child", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L453-L461
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.addCustomLogger
public boolean addCustomLogger(Logger logger) { if (logger.getClass().getName().startsWith("java")) return false; Logger oldLogger = _localLoggers.get(); if (oldLogger != null) return false; _localLoggers.set(logger); if (_parent != null) { logger.setParent(_parent); } return true; }
java
public boolean addCustomLogger(Logger logger) { if (logger.getClass().getName().startsWith("java")) return false; Logger oldLogger = _localLoggers.get(); if (oldLogger != null) return false; _localLoggers.set(logger); if (_parent != null) { logger.setParent(_parent); } return true; }
[ "public", "boolean", "addCustomLogger", "(", "Logger", "logger", ")", "{", "if", "(", "logger", ".", "getClass", "(", ")", ".", "getName", "(", ")", ".", "startsWith", "(", "\"java\"", ")", ")", "return", "false", ";", "Logger", "oldLogger", "=", "_local...
Sets a custom logger if possible
[ "Sets", "a", "custom", "logger", "if", "possible" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L466-L483
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.addLoader
private void addLoader(ClassLoader loader) { for (int i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader refLoader = ref.get(); if (refLoader == null) _loaders.remove(i); if (refLoader == loader) return; } _loaders.add(new WeakReference<ClassLoader>(loader)); EnvLoader.addClassLoaderListener(this, loader); }
java
private void addLoader(ClassLoader loader) { for (int i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader refLoader = ref.get(); if (refLoader == null) _loaders.remove(i); if (refLoader == loader) return; } _loaders.add(new WeakReference<ClassLoader>(loader)); EnvLoader.addClassLoaderListener(this, loader); }
[ "private", "void", "addLoader", "(", "ClassLoader", "loader", ")", "{", "for", "(", "int", "i", "=", "_loaders", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WeakReference", "<", "ClassLoader", ">", "ref", "=", ...
Adds a class loader to the list of dependency loaders.
[ "Adds", "a", "class", "loader", "to", "the", "list", "of", "dependency", "loaders", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L496-L511
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.updateEffectiveLevel
private synchronized void updateEffectiveLevel(ClassLoader loader) { if (loader == null) loader = _systemClassLoader; int oldEffectiveLevel = getEffectiveLevel(loader); Level newEffectiveLevel = calculateEffectiveLevel(loader); /* if (loader == _systemClassLoader) { _finestEffectiveLevel = newEffectiveLevel; _finestEffectiveLevelValue = newEffectiveLevel.intValue(); super.setLevel(_finestEffectiveLevel); } */ if (oldEffectiveLevel == newEffectiveLevel.intValue() && loader != _systemClassLoader) return; _finestEffectiveLevel = newEffectiveLevel; _hasLocalEffectiveLevel = false; updateEffectiveLevelPart(_systemClassLoader); updateEffectiveLevelPart(loader); for (int i = 0; i < _loaders.size(); i++) { WeakReference<ClassLoader> loaderRef = _loaders.get(i); ClassLoader classLoader = loaderRef.get(); if (classLoader != null) updateEffectiveLevelPart(classLoader); } super.setLevel(_finestEffectiveLevel); _finestEffectiveLevelValue = _finestEffectiveLevel.intValue(); updateChildren(); }
java
private synchronized void updateEffectiveLevel(ClassLoader loader) { if (loader == null) loader = _systemClassLoader; int oldEffectiveLevel = getEffectiveLevel(loader); Level newEffectiveLevel = calculateEffectiveLevel(loader); /* if (loader == _systemClassLoader) { _finestEffectiveLevel = newEffectiveLevel; _finestEffectiveLevelValue = newEffectiveLevel.intValue(); super.setLevel(_finestEffectiveLevel); } */ if (oldEffectiveLevel == newEffectiveLevel.intValue() && loader != _systemClassLoader) return; _finestEffectiveLevel = newEffectiveLevel; _hasLocalEffectiveLevel = false; updateEffectiveLevelPart(_systemClassLoader); updateEffectiveLevelPart(loader); for (int i = 0; i < _loaders.size(); i++) { WeakReference<ClassLoader> loaderRef = _loaders.get(i); ClassLoader classLoader = loaderRef.get(); if (classLoader != null) updateEffectiveLevelPart(classLoader); } super.setLevel(_finestEffectiveLevel); _finestEffectiveLevelValue = _finestEffectiveLevel.intValue(); updateChildren(); }
[ "private", "synchronized", "void", "updateEffectiveLevel", "(", "ClassLoader", "loader", ")", "{", "if", "(", "loader", "==", "null", ")", "loader", "=", "_systemClassLoader", ";", "int", "oldEffectiveLevel", "=", "getEffectiveLevel", "(", "loader", ")", ";", "L...
Recalculate the dynamic assigned levels.
[ "Recalculate", "the", "dynamic", "assigned", "levels", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L534-L575
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.getFinestLevel
private Level getFinestLevel() { Level level; if (_parent == null) level = Level.INFO; else if (_parent.isLocalLevel()) level = selectFinestLevel(_systemLevel, _parent.getFinestLevel()); else if (_systemLevel != null) level = _systemLevel; else level = _parent.getFinestLevel(); if (_localLevel == null) return level; for (int i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader loader = ref.get(); if (loader == null) _loaders.remove(i); level = selectFinestLevel(level, _localLevel.get(loader)); } return level; }
java
private Level getFinestLevel() { Level level; if (_parent == null) level = Level.INFO; else if (_parent.isLocalLevel()) level = selectFinestLevel(_systemLevel, _parent.getFinestLevel()); else if (_systemLevel != null) level = _systemLevel; else level = _parent.getFinestLevel(); if (_localLevel == null) return level; for (int i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader loader = ref.get(); if (loader == null) _loaders.remove(i); level = selectFinestLevel(level, _localLevel.get(loader)); } return level; }
[ "private", "Level", "getFinestLevel", "(", ")", "{", "Level", "level", ";", "if", "(", "_parent", "==", "null", ")", "level", "=", "Level", ".", "INFO", ";", "else", "if", "(", "_parent", ".", "isLocalLevel", "(", ")", ")", "level", "=", "selectFinestL...
Returns the finest assigned level for any classloader environment.
[ "Returns", "the", "finest", "assigned", "level", "for", "any", "classloader", "environment", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L689-L716
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.selectFinestLevel
private Level selectFinestLevel(Level a, Level b) { if (a == null) return b; else if (b == null) return a; else if (b.intValue() < a.intValue()) return b; else return a; }
java
private Level selectFinestLevel(Level a, Level b) { if (a == null) return b; else if (b == null) return a; else if (b.intValue() < a.intValue()) return b; else return a; }
[ "private", "Level", "selectFinestLevel", "(", "Level", "a", ",", "Level", "b", ")", "{", "if", "(", "a", "==", "null", ")", "return", "b", ";", "else", "if", "(", "b", "==", "null", ")", "return", "a", ";", "else", "if", "(", "b", ".", "intValue"...
Returns the finest of the two levels.
[ "Returns", "the", "finest", "of", "the", "two", "levels", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L731-L741
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.getAssignedLevel
private Level getAssignedLevel(ClassLoader loader) { Level level = null; if (_localLevel != null) { return _localLevel.get(loader); } return null; }
java
private Level getAssignedLevel(ClassLoader loader) { Level level = null; if (_localLevel != null) { return _localLevel.get(loader); } return null; }
[ "private", "Level", "getAssignedLevel", "(", "ClassLoader", "loader", ")", "{", "Level", "level", "=", "null", ";", "if", "(", "_localLevel", "!=", "null", ")", "{", "return", "_localLevel", ".", "get", "(", "loader", ")", ";", "}", "return", "null", ";"...
Returns the most specific assigned level for the given classloader, i.e. children override parents.
[ "Returns", "the", "most", "specific", "assigned", "level", "for", "the", "given", "classloader", "i", ".", "e", ".", "children", "override", "parents", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L747-L756
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.removeLoader
private synchronized void removeLoader(ClassLoader loader) { int i; for (i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader refLoader = ref.get(); if (refLoader == null) _loaders.remove(i); else if (refLoader == loader) _loaders.remove(i); } }
java
private synchronized void removeLoader(ClassLoader loader) { int i; for (i = _loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref = _loaders.get(i); ClassLoader refLoader = ref.get(); if (refLoader == null) _loaders.remove(i); else if (refLoader == loader) _loaders.remove(i); } }
[ "private", "synchronized", "void", "removeLoader", "(", "ClassLoader", "loader", ")", "{", "int", "i", ";", "for", "(", "i", "=", "_loaders", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WeakReference", "<", "Cla...
Removes the specified loader.
[ "Removes", "the", "specified", "loader", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L794-L806
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java
EnvironmentLogger.classLoaderDestroy
@Override public void classLoaderDestroy(DynamicClassLoader loader) { removeLoader(loader); _localHandlers.remove(loader); HandlerEntry ownHandlers = _ownHandlers.getLevel(loader); if (ownHandlers != null) _ownHandlers.remove(loader); if (ownHandlers != null) ownHandlers.destroy(); if (_localLevel != null) _localLevel.remove(loader); updateEffectiveLevel(_systemClassLoader); }
java
@Override public void classLoaderDestroy(DynamicClassLoader loader) { removeLoader(loader); _localHandlers.remove(loader); HandlerEntry ownHandlers = _ownHandlers.getLevel(loader); if (ownHandlers != null) _ownHandlers.remove(loader); if (ownHandlers != null) ownHandlers.destroy(); if (_localLevel != null) _localLevel.remove(loader); updateEffectiveLevel(_systemClassLoader); }
[ "@", "Override", "public", "void", "classLoaderDestroy", "(", "DynamicClassLoader", "loader", ")", "{", "removeLoader", "(", "loader", ")", ";", "_localHandlers", ".", "remove", "(", "loader", ")", ";", "HandlerEntry", "ownHandlers", "=", "_ownHandlers", ".", "g...
Classloader destroy callback
[ "Classloader", "destroy", "callback" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentLogger.java#L818-L836
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/TempCharReader.java
TempCharReader.init
public void init(TempCharBuffer head) { _top = head; _head = head; if (head != null) { _buffer = head.buffer(); _length = head.getLength(); } else _length = 0; _offset = 0; }
java
public void init(TempCharBuffer head) { _top = head; _head = head; if (head != null) { _buffer = head.buffer(); _length = head.getLength(); } else _length = 0; _offset = 0; }
[ "public", "void", "init", "(", "TempCharBuffer", "head", ")", "{", "_top", "=", "head", ";", "_head", "=", "head", ";", "if", "(", "head", "!=", "null", ")", "{", "_buffer", "=", "head", ".", "buffer", "(", ")", ";", "_length", "=", "head", ".", ...
Initialize the reader.
[ "Initialize", "the", "reader", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/TempCharReader.java#L70-L83
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/TempCharReader.java
TempCharReader.close
public void close() { if (_isFree) TempCharBuffer.freeAll(_head); _head = null; _buffer = null; _offset = 0; _length = 0; }
java
public void close() { if (_isFree) TempCharBuffer.freeAll(_head); _head = null; _buffer = null; _offset = 0; _length = 0; }
[ "public", "void", "close", "(", ")", "{", "if", "(", "_isFree", ")", "TempCharBuffer", ".", "freeAll", "(", "_head", ")", ";", "_head", "=", "null", ";", "_buffer", "=", "null", ";", "_offset", "=", "0", ";", "_length", "=", "0", ";", "}" ]
Closes the reader.
[ "Closes", "the", "reader", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/TempCharReader.java#L176-L185
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/service/ValidatorVault.java
ValidatorVault.createValidation
private void createValidation(Class<?> vaultClass, Class<?> assetClass, Class<?> idClass) { for (Method method : vaultClass.getMethods()) { if (! method.getName().startsWith("create")) { continue; } if (! Modifier.isAbstract(method.getModifiers())) { continue; } TypeRef resultRef = findResult(method.getParameters()); if (resultRef == null) { continue; } TypeRef typeRef = resultRef.to(Result.class).param(0); Class<?> typeClass = typeRef.rawClass(); // id return type if (unbox(idClass).equals(unbox(typeClass))) { continue; } if (void.class.equals(unbox(typeClass))) { continue; } try { new ShimConverter<>(assetClass, typeClass); } catch (Exception e) { throw error(e, "{0}.{1}: {2}", vaultClass.getSimpleName(), method.getName(), e.getMessage()); } } }
java
private void createValidation(Class<?> vaultClass, Class<?> assetClass, Class<?> idClass) { for (Method method : vaultClass.getMethods()) { if (! method.getName().startsWith("create")) { continue; } if (! Modifier.isAbstract(method.getModifiers())) { continue; } TypeRef resultRef = findResult(method.getParameters()); if (resultRef == null) { continue; } TypeRef typeRef = resultRef.to(Result.class).param(0); Class<?> typeClass = typeRef.rawClass(); // id return type if (unbox(idClass).equals(unbox(typeClass))) { continue; } if (void.class.equals(unbox(typeClass))) { continue; } try { new ShimConverter<>(assetClass, typeClass); } catch (Exception e) { throw error(e, "{0}.{1}: {2}", vaultClass.getSimpleName(), method.getName(), e.getMessage()); } } }
[ "private", "void", "createValidation", "(", "Class", "<", "?", ">", "vaultClass", ",", "Class", "<", "?", ">", "assetClass", ",", "Class", "<", "?", ">", "idClass", ")", "{", "for", "(", "Method", "method", ":", "vaultClass", ".", "getMethods", "(", ")...
Validate the create methods.
[ "Validate", "the", "create", "methods", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/service/ValidatorVault.java#L116-L157
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/service/ValidatorVault.java
ValidatorVault.findValidation
private void findValidation(Class<?> vaultClass, Class<?> assetClass, Class<?> idClass) { for (Method method : vaultClass.getMethods()) { if (! method.getName().startsWith("find")) { continue; } if (! Modifier.isAbstract(method.getModifiers())) { continue; } TypeRef resultRef = findResult(method.getParameters()); if (resultRef == null) { continue; } TypeRef typeRef = resultRef.to(Result.class).param(0); Class<?> typeClass = typeRef.rawClass(); // id return type if (unbox(idClass).equals(unbox(typeClass))) { continue; } if (Collection.class.isAssignableFrom(typeClass)) { continue; } else if (Stream.class.isAssignableFrom(typeClass)) { continue; } else if (Modifier.isAbstract(typeClass.getModifiers())) { // assumed to be proxy continue; } new ShimConverter<>(assetClass, typeClass); } }
java
private void findValidation(Class<?> vaultClass, Class<?> assetClass, Class<?> idClass) { for (Method method : vaultClass.getMethods()) { if (! method.getName().startsWith("find")) { continue; } if (! Modifier.isAbstract(method.getModifiers())) { continue; } TypeRef resultRef = findResult(method.getParameters()); if (resultRef == null) { continue; } TypeRef typeRef = resultRef.to(Result.class).param(0); Class<?> typeClass = typeRef.rawClass(); // id return type if (unbox(idClass).equals(unbox(typeClass))) { continue; } if (Collection.class.isAssignableFrom(typeClass)) { continue; } else if (Stream.class.isAssignableFrom(typeClass)) { continue; } else if (Modifier.isAbstract(typeClass.getModifiers())) { // assumed to be proxy continue; } new ShimConverter<>(assetClass, typeClass); } }
[ "private", "void", "findValidation", "(", "Class", "<", "?", ">", "vaultClass", ",", "Class", "<", "?", ">", "assetClass", ",", "Class", "<", "?", ">", "idClass", ")", "{", "for", "(", "Method", "method", ":", "vaultClass", ".", "getMethods", "(", ")",...
Validate the find methods.
[ "Validate", "the", "find", "methods", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/service/ValidatorVault.java#L162-L202
train
baratine/baratine
web/src/main/java/com/caucho/v5/deploy2/Strategy2StartManualRedeployManual.java
Strategy2StartManualRedeployManual.startOnInit
@Override public void startOnInit(DeployService2Impl<I> deploy, Result<I> result) { deploy.startImpl(result); }
java
@Override public void startOnInit(DeployService2Impl<I> deploy, Result<I> result) { deploy.startImpl(result); }
[ "@", "Override", "public", "void", "startOnInit", "(", "DeployService2Impl", "<", "I", ">", "deploy", ",", "Result", "<", "I", ">", "result", ")", "{", "deploy", ".", "startImpl", "(", "result", ")", ";", "}" ]
Called at initialization time for automatic start. @param deploy the owning controller
[ "Called", "at", "initialization", "time", "for", "automatic", "start", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/deploy2/Strategy2StartManualRedeployManual.java#L83-L87
train
baratine/baratine
web/src/main/java/com/caucho/v5/deploy2/Strategy2StartManualRedeployManual.java
Strategy2StartManualRedeployManual.update
@Override public void update(DeployService2Impl<I> deploy, Result<I> result) { LifecycleState state = deploy.getState(); if (state.isStopped()) { deploy.startImpl(result); } else if (state.isError()) { deploy.restartImpl(result); } else if (deploy.isModifiedNow()) { deploy.restartImpl(result); } else { /* active */ result.ok(deploy.get()); } }
java
@Override public void update(DeployService2Impl<I> deploy, Result<I> result) { LifecycleState state = deploy.getState(); if (state.isStopped()) { deploy.startImpl(result); } else if (state.isError()) { deploy.restartImpl(result); } else if (deploy.isModifiedNow()) { deploy.restartImpl(result); } else { /* active */ result.ok(deploy.get()); } }
[ "@", "Override", "public", "void", "update", "(", "DeployService2Impl", "<", "I", ">", "deploy", ",", "Result", "<", "I", ">", "result", ")", "{", "LifecycleState", "state", "=", "deploy", ".", "getState", "(", ")", ";", "if", "(", "state", ".", "isSto...
Checks for updates from an admin command. The target state will be the initial state, i.e. update will not start a lazy instance. @param deploy the owning controller
[ "Checks", "for", "updates", "from", "an", "admin", "command", ".", "The", "target", "state", "will", "be", "the", "initial", "state", "i", ".", "e", ".", "update", "will", "not", "start", "a", "lazy", "instance", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/deploy2/Strategy2StartManualRedeployManual.java#L95-L112
train
baratine/baratine
web/src/main/java/com/caucho/v5/deploy2/Strategy2StartManualRedeployManual.java
Strategy2StartManualRedeployManual.request
@Override public void request(DeployService2Impl<I> deploy, Result<I> result) { result.ok(deploy.get()); }
java
@Override public void request(DeployService2Impl<I> deploy, Result<I> result) { result.ok(deploy.get()); }
[ "@", "Override", "public", "void", "request", "(", "DeployService2Impl", "<", "I", ">", "deploy", ",", "Result", "<", "I", ">", "result", ")", "{", "result", ".", "ok", "(", "deploy", ".", "get", "(", ")", ")", ";", "}" ]
Returns the current instance. This strategy does not lazily restart the instance. @param deploy the owning controller @return the current deploy instance
[ "Returns", "the", "current", "instance", ".", "This", "strategy", "does", "not", "lazily", "restart", "the", "instance", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/deploy2/Strategy2StartManualRedeployManual.java#L122-L127
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/table/TableKraken.java
TableKraken.getPodHash
public static int getPodHash(String key) { byte []buffer = new byte[16]; int sublen = Math.min(key.length(), 8); for (int i = 0; i < sublen; i++) { buffer[i] = (byte) key.charAt(i); } long hash = Murmur64.generate(Murmur64.SEED, key); BitsUtil.writeLong(buffer, 8, hash); return calculatePodHash(buffer, 0, 16); }
java
public static int getPodHash(String key) { byte []buffer = new byte[16]; int sublen = Math.min(key.length(), 8); for (int i = 0; i < sublen; i++) { buffer[i] = (byte) key.charAt(i); } long hash = Murmur64.generate(Murmur64.SEED, key); BitsUtil.writeLong(buffer, 8, hash); return calculatePodHash(buffer, 0, 16); }
[ "public", "static", "int", "getPodHash", "(", "String", "key", ")", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "16", "]", ";", "int", "sublen", "=", "Math", ".", "min", "(", "key", ".", "length", "(", ")", ",", "8", ")", ";", "fo...
Convenience for calculating the pod hash for a string.
[ "Convenience", "for", "calculating", "the", "pod", "hash", "for", "a", "string", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/table/TableKraken.java#L215-L230
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/table/TableKraken.java
TableKraken.get
public void get(RowCursor cursor, Result<Boolean> result) { TablePod tablePod = getTablePod(); int hash = getPodHash(cursor); if (tablePod.getNode(hash).isSelfCopy()) { _tableKelp.getDirect(cursor, result); } else { getTablePod().get(cursor.getKey(), result.then((v,r)->getResult(v, cursor, r))); } }
java
public void get(RowCursor cursor, Result<Boolean> result) { TablePod tablePod = getTablePod(); int hash = getPodHash(cursor); if (tablePod.getNode(hash).isSelfCopy()) { _tableKelp.getDirect(cursor, result); } else { getTablePod().get(cursor.getKey(), result.then((v,r)->getResult(v, cursor, r))); } }
[ "public", "void", "get", "(", "RowCursor", "cursor", ",", "Result", "<", "Boolean", ">", "result", ")", "{", "TablePod", "tablePod", "=", "getTablePod", "(", ")", ";", "int", "hash", "=", "getPodHash", "(", "cursor", ")", ";", "if", "(", "tablePod", "....
Gets a row from the table when the primary key is known. @param cursor the request cursor containing the key @param result return true when the row exists.
[ "Gets", "a", "row", "from", "the", "table", "when", "the", "primary", "key", "is", "known", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/table/TableKraken.java#L420-L433
train
baratine/baratine
web/src/main/java/com/caucho/v5/http/protocol/InContentLength.java
InContentLength.read
@Override public int read(byte []buffer, int offset, int length) throws IOException { try { if (_length < length) length = (int) _length; if (length <= 0) return -1; int len = _next.read(buffer, offset, length); if (len > 0) { _length -= len; } else { _length = -1; } return len; } catch (SocketTimeoutException e) { throw new ClientDisconnectException(e); } }
java
@Override public int read(byte []buffer, int offset, int length) throws IOException { try { if (_length < length) length = (int) _length; if (length <= 0) return -1; int len = _next.read(buffer, offset, length); if (len > 0) { _length -= len; } else { _length = -1; } return len; } catch (SocketTimeoutException e) { throw new ClientDisconnectException(e); } }
[ "@", "Override", "public", "int", "read", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "try", "{", "if", "(", "_length", "<", "length", ")", "length", "=", "(", "int", ")", "_length",...
Reads from the buffer, limiting to the content length. @param buffer the buffer containing the results. @param offset the offset into the result buffer @param length the length of the buffer. @return the number of bytes read or -1 for the end of the file.
[ "Reads", "from", "the", "buffer", "limiting", "to", "the", "content", "length", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/InContentLength.java#L92-L116
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/PatternFormatter.java
PatternFormatter.format
@Override public String format(LogRecord log) { StringBuilder sb = new StringBuilder(); int mark = 0; for (FormatItem item : _formatList) { item.format(sb, log, mark); if (item instanceof PrettyPrintMarkItem) { mark = sb.length(); } } return sb.toString(); }
java
@Override public String format(LogRecord log) { StringBuilder sb = new StringBuilder(); int mark = 0; for (FormatItem item : _formatList) { item.format(sb, log, mark); if (item instanceof PrettyPrintMarkItem) { mark = sb.length(); } } return sb.toString(); }
[ "@", "Override", "public", "String", "format", "(", "LogRecord", "log", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "mark", "=", "0", ";", "for", "(", "FormatItem", "item", ":", "_formatList", ")", "{", "item", "...
Formats the record
[ "Formats", "the", "record" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/PatternFormatter.java#L105-L121
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/stream/StreamBuilderImpl.java
StreamBuilderImpl.reduce
@Override public StreamBuilderImpl<T,U> reduce(T init, BinaryOperatorSync<T> op) { return new ReduceOpInitSync<>(this, init, op); }
java
@Override public StreamBuilderImpl<T,U> reduce(T init, BinaryOperatorSync<T> op) { return new ReduceOpInitSync<>(this, init, op); }
[ "@", "Override", "public", "StreamBuilderImpl", "<", "T", ",", "U", ">", "reduce", "(", "T", "init", ",", "BinaryOperatorSync", "<", "T", ">", "op", ")", "{", "return", "new", "ReduceOpInitSync", "<>", "(", "this", ",", "init", ",", "op", ")", ";", "...
Reduce with a binary function <code><pre> s = init; s = op(s, t1); s = op(s, t2); result = s; </pre></code>
[ "Reduce", "with", "a", "binary", "function" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/stream/StreamBuilderImpl.java#L214-L219
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/stream/StreamBuilderImpl.java
StreamBuilderImpl.reduce
@Override public <R> StreamBuilderImpl<R,U> reduce(R identity, BiFunctionSync<R, ? super T, R> accumulator, BinaryOperatorSync<R> combiner) { return new ReduceAccumSync<>(this, identity, accumulator, combiner); }
java
@Override public <R> StreamBuilderImpl<R,U> reduce(R identity, BiFunctionSync<R, ? super T, R> accumulator, BinaryOperatorSync<R> combiner) { return new ReduceAccumSync<>(this, identity, accumulator, combiner); }
[ "@", "Override", "public", "<", "R", ">", "StreamBuilderImpl", "<", "R", ",", "U", ">", "reduce", "(", "R", "identity", ",", "BiFunctionSync", "<", "R", ",", "?", "super", "T", ",", "R", ">", "accumulator", ",", "BinaryOperatorSync", "<", "R", ">", "...
Reduce with an accumulator and combiner
[ "Reduce", "with", "an", "accumulator", "and", "combiner" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/stream/StreamBuilderImpl.java#L240-L247
train
baratine/baratine
core/src/main/java/com/caucho/v5/loader/DependencyContainer.java
DependencyContainer.setModified
public void setModified(boolean isModified) { _isModified = isModified; if (_isModified) _checkExpiresTime = Long.MAX_VALUE / 2; else _checkExpiresTime = CurrentTime.currentTime() + _checkInterval; if (! isModified) _isModifiedLog = false; }
java
public void setModified(boolean isModified) { _isModified = isModified; if (_isModified) _checkExpiresTime = Long.MAX_VALUE / 2; else _checkExpiresTime = CurrentTime.currentTime() + _checkInterval; if (! isModified) _isModifiedLog = false; }
[ "public", "void", "setModified", "(", "boolean", "isModified", ")", "{", "_isModified", "=", "isModified", ";", "if", "(", "_isModified", ")", "_checkExpiresTime", "=", "Long", ".", "MAX_VALUE", "/", "2", ";", "else", "_checkExpiresTime", "=", "CurrentTime", "...
Sets the modified.
[ "Sets", "the", "modified", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/DependencyContainer.java#L195-L206
train
baratine/baratine
web/src/main/java/com/caucho/v5/web/builder/IncludeWebClass.java
IncludeWebClass.buildWebService
private static ServiceWeb buildWebService(WebBuilder builder, Function<RequestWeb,Object> beanFactory, Method method) { Parameter []params = method.getParameters(); WebParam []webParam = new WebParam[params.length]; for (int i = 0; i < params.length; i++) { webParam[i] = buildParam(builder, params[i]); } return new WebServiceMethod(beanFactory, method, webParam); }
java
private static ServiceWeb buildWebService(WebBuilder builder, Function<RequestWeb,Object> beanFactory, Method method) { Parameter []params = method.getParameters(); WebParam []webParam = new WebParam[params.length]; for (int i = 0; i < params.length; i++) { webParam[i] = buildParam(builder, params[i]); } return new WebServiceMethod(beanFactory, method, webParam); }
[ "private", "static", "ServiceWeb", "buildWebService", "(", "WebBuilder", "builder", ",", "Function", "<", "RequestWeb", ",", "Object", ">", "beanFactory", ",", "Method", "method", ")", "{", "Parameter", "[", "]", "params", "=", "method", ".", "getParameters", ...
Builds a HTTP service from a method. <pre><code> &#64;Get void myMethod(&64;Query("id") id, Result&lt;String&gt; result); </code></pre> Method parameters are filled from the request. @param builder called to create the service @param beanFactory factory for the bean instance @param method method for the service
[ "Builds", "a", "HTTP", "service", "from", "a", "method", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/web/builder/IncludeWebClass.java#L402-L416
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/MultipartStream.java
MultipartStream.getAttribute
public String getAttribute(String key) { List<String> values = _headers.get(key.toLowerCase(Locale.ENGLISH)); if (values != null && values.size() > 0) return values.get(0); return null; }
java
public String getAttribute(String key) { List<String> values = _headers.get(key.toLowerCase(Locale.ENGLISH)); if (values != null && values.size() > 0) return values.get(0); return null; }
[ "public", "String", "getAttribute", "(", "String", "key", ")", "{", "List", "<", "String", ">", "values", "=", "_headers", ".", "get", "(", "key", ".", "toLowerCase", "(", "Locale", ".", "ENGLISH", ")", ")", ";", "if", "(", "values", "!=", "null", "&...
Returns a read attribute from the multipart mime.
[ "Returns", "a", "read", "attribute", "from", "the", "multipart", "mime", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/MultipartStream.java#L196-L204
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/MultipartStream.java
MultipartStream.getAvailable
public int getAvailable() throws IOException { if (_isPartDone) return 0; else if (_peekOffset < _peekLength) return _peekLength - _peekOffset; else { int ch = read(); if (ch < 0) return 0; _peekOffset = 0; _peekLength = 1; _peek[0] = (byte) ch; return 1; } }
java
public int getAvailable() throws IOException { if (_isPartDone) return 0; else if (_peekOffset < _peekLength) return _peekLength - _peekOffset; else { int ch = read(); if (ch < 0) return 0; _peekOffset = 0; _peekLength = 1; _peek[0] = (byte) ch; return 1; } }
[ "public", "int", "getAvailable", "(", ")", "throws", "IOException", "{", "if", "(", "_isPartDone", ")", "return", "0", ";", "else", "if", "(", "_peekOffset", "<", "_peekLength", ")", "return", "_peekLength", "-", "_peekOffset", ";", "else", "{", "int", "ch...
Returns the number of available bytes.
[ "Returns", "the", "number", "of", "available", "bytes", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/MultipartStream.java#L291-L308
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/MultipartStream.java
MultipartStream.read
@Override public int read(byte[] buffer, int offset, int length) throws IOException { int b = -1; if (_isPartDone) return -1; int i = 0; // Need the last peek or would miss the initial '\n' while (_peekOffset + 1 < _peekLength && length > 0) { buffer[offset + i++] = _peek[_peekOffset++]; length--; } while (i < length && (b = read()) >= 0) { boolean hasCr = false; if (b == '\r') { hasCr = true; b = read(); // XXX: Macintosh? if (b != '\n') { buffer[offset + i++] = (byte) '\r'; _peek[0] = (byte) b; _peekOffset = 0; _peekLength = 1; continue; } } else if (b != '\n') { buffer[offset + i++] = (byte) b; continue; } int j; for (j = 0; j < _boundaryLength && (b = read()) >= 0 && _boundaryBuffer[j] == b; j++) { } if (j == _boundaryLength) { _isPartDone = true; if ((b = read()) == '-') { if ((b = read()) == '-') { _isDone = true; _isComplete = true; } } for (; b > 0 && b != '\r' && b != '\n'; b = read()) { } if (b == '\r' && (b = read()) != '\n') { _peek[0] = (byte) b; _peekOffset = 0; _peekLength = 1; } return i > 0 ? i : -1; } _peekLength = 0; if (hasCr && i + 1 < length) { buffer[offset + i++] = (byte) '\r'; buffer[offset + i++] = (byte) '\n'; } else if (hasCr) { buffer[offset + i++] = (byte) '\r'; _peek[_peekLength++] = (byte) '\n'; } else { buffer[offset + i++] = (byte) '\n'; } int k = 0; while (k < j && i + 1 < length) buffer[offset + i++] = _boundaryBuffer[k++]; while (k < j) _peek[_peekLength++] = _boundaryBuffer[k++]; _peek[_peekLength++] = (byte) b; _peekOffset = 0; } if (i <= 0) { _isPartDone = true; if (b < 0) _isDone = true; return -1; } else { return i; } }
java
@Override public int read(byte[] buffer, int offset, int length) throws IOException { int b = -1; if (_isPartDone) return -1; int i = 0; // Need the last peek or would miss the initial '\n' while (_peekOffset + 1 < _peekLength && length > 0) { buffer[offset + i++] = _peek[_peekOffset++]; length--; } while (i < length && (b = read()) >= 0) { boolean hasCr = false; if (b == '\r') { hasCr = true; b = read(); // XXX: Macintosh? if (b != '\n') { buffer[offset + i++] = (byte) '\r'; _peek[0] = (byte) b; _peekOffset = 0; _peekLength = 1; continue; } } else if (b != '\n') { buffer[offset + i++] = (byte) b; continue; } int j; for (j = 0; j < _boundaryLength && (b = read()) >= 0 && _boundaryBuffer[j] == b; j++) { } if (j == _boundaryLength) { _isPartDone = true; if ((b = read()) == '-') { if ((b = read()) == '-') { _isDone = true; _isComplete = true; } } for (; b > 0 && b != '\r' && b != '\n'; b = read()) { } if (b == '\r' && (b = read()) != '\n') { _peek[0] = (byte) b; _peekOffset = 0; _peekLength = 1; } return i > 0 ? i : -1; } _peekLength = 0; if (hasCr && i + 1 < length) { buffer[offset + i++] = (byte) '\r'; buffer[offset + i++] = (byte) '\n'; } else if (hasCr) { buffer[offset + i++] = (byte) '\r'; _peek[_peekLength++] = (byte) '\n'; } else { buffer[offset + i++] = (byte) '\n'; } int k = 0; while (k < j && i + 1 < length) buffer[offset + i++] = _boundaryBuffer[k++]; while (k < j) _peek[_peekLength++] = _boundaryBuffer[k++]; _peek[_peekLength++] = (byte) b; _peekOffset = 0; } if (i <= 0) { _isPartDone = true; if (b < 0) _isDone = true; return -1; } else { return i; } }
[ "@", "Override", "public", "int", "read", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "int", "b", "=", "-", "1", ";", "if", "(", "_isPartDone", ")", "return", "-", "1", ";", "int",...
Reads from the multipart mime buffer.
[ "Reads", "from", "the", "multipart", "mime", "buffer", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/MultipartStream.java#L313-L408
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/service/ServiceBuilderImpl.java
ServiceBuilderImpl.ref
@Override public ServiceRefAmp ref() { if (_isForeign) { return null; } if (workers() > 1) { return buildWorkers(); } if (_worker != null) { return buildWorker(); } else { //throw new IllegalStateException(L.l("build() requires a worker or resource.")); return buildService(); } }
java
@Override public ServiceRefAmp ref() { if (_isForeign) { return null; } if (workers() > 1) { return buildWorkers(); } if (_worker != null) { return buildWorker(); } else { //throw new IllegalStateException(L.l("build() requires a worker or resource.")); return buildService(); } }
[ "@", "Override", "public", "ServiceRefAmp", "ref", "(", ")", "{", "if", "(", "_isForeign", ")", "{", "return", "null", ";", "}", "if", "(", "workers", "(", ")", ">", "1", ")", "{", "return", "buildWorkers", "(", ")", ";", "}", "if", "(", "_worker",...
Build the service and return the service ref.
[ "Build", "the", "service", "and", "return", "the", "service", "ref", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/service/ServiceBuilderImpl.java#L758-L776
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/service/ServiceBuilderImpl.java
ServiceBuilderImpl.service
private ServiceRefAmp service(StubFactoryAmp stubFactory) { validateOpen(); Thread thread = Thread.currentThread(); ClassLoader oldLoader = thread.getContextClassLoader(); OutboxAmp outbox = OutboxAmp.current(); Object oldContext = null; try { thread.setContextClassLoader(_services.classLoader()); if (outbox != null) { oldContext = outbox.getAndSetContext(_services.inboxSystem()); } //return serviceImpl(beanFactory, address, config); ServiceRefAmp serviceRef = serviceImpl(stubFactory); String address = stubFactory.address(); if (address != null) { _services.bind(serviceRef, address); } if (serviceRef.stub().isAutoStart() || stubFactory.config().isAutoStart()) { _services.addAutoStart(serviceRef); } return serviceRef; } finally { thread.setContextClassLoader(oldLoader); if (outbox != null) { outbox.getAndSetContext(oldContext); } } }
java
private ServiceRefAmp service(StubFactoryAmp stubFactory) { validateOpen(); Thread thread = Thread.currentThread(); ClassLoader oldLoader = thread.getContextClassLoader(); OutboxAmp outbox = OutboxAmp.current(); Object oldContext = null; try { thread.setContextClassLoader(_services.classLoader()); if (outbox != null) { oldContext = outbox.getAndSetContext(_services.inboxSystem()); } //return serviceImpl(beanFactory, address, config); ServiceRefAmp serviceRef = serviceImpl(stubFactory); String address = stubFactory.address(); if (address != null) { _services.bind(serviceRef, address); } if (serviceRef.stub().isAutoStart() || stubFactory.config().isAutoStart()) { _services.addAutoStart(serviceRef); } return serviceRef; } finally { thread.setContextClassLoader(oldLoader); if (outbox != null) { outbox.getAndSetContext(oldContext); } } }
[ "private", "ServiceRefAmp", "service", "(", "StubFactoryAmp", "stubFactory", ")", "{", "validateOpen", "(", ")", ";", "Thread", "thread", "=", "Thread", ".", "currentThread", "(", ")", ";", "ClassLoader", "oldLoader", "=", "thread", ".", "getContextClassLoader", ...
Main service builder. Called from ServiceBuilder and ServiceRefBean.
[ "Main", "service", "builder", ".", "Called", "from", "ServiceBuilder", "and", "ServiceRefBean", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/service/ServiceBuilderImpl.java#L943-L981
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/service/ServiceBuilderImpl.java
ServiceBuilderImpl.service
ServiceRefAmp service(QueueServiceFactoryInbox serviceFactory, ServiceConfig config) { QueueDeliverBuilderImpl<MessageAmp> queueBuilder = new QueueDeliverBuilderImpl<>(); //queueBuilder.setOutboxFactory(OutboxAmpFactory.newFactory()); queueBuilder.setClassLoader(_services.classLoader()); queueBuilder.sizeMax(config.queueSizeMax()); queueBuilder.size(config.queueSize()); InboxAmp inbox = new InboxQueue(_services, queueBuilder, serviceFactory, config); return inbox.serviceRef(); }
java
ServiceRefAmp service(QueueServiceFactoryInbox serviceFactory, ServiceConfig config) { QueueDeliverBuilderImpl<MessageAmp> queueBuilder = new QueueDeliverBuilderImpl<>(); //queueBuilder.setOutboxFactory(OutboxAmpFactory.newFactory()); queueBuilder.setClassLoader(_services.classLoader()); queueBuilder.sizeMax(config.queueSizeMax()); queueBuilder.size(config.queueSize()); InboxAmp inbox = new InboxQueue(_services, queueBuilder, serviceFactory, config); return inbox.serviceRef(); }
[ "ServiceRefAmp", "service", "(", "QueueServiceFactoryInbox", "serviceFactory", ",", "ServiceConfig", "config", ")", "{", "QueueDeliverBuilderImpl", "<", "MessageAmp", ">", "queueBuilder", "=", "new", "QueueDeliverBuilderImpl", "<>", "(", ")", ";", "//queueBuilder.setOutbo...
Used by journal builder.
[ "Used", "by", "journal", "builder", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/service/ServiceBuilderImpl.java#L1101-L1119
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parse
public QueryBuilderKraken parse() { Token token = scanToken(); switch (token) { case CREATE: return parseCreate(); case EXPLAIN: return parseExplain(); case INSERT: return parseInsert(); case REPLACE: return parseReplace(); case SELECT: return parseSelect(); case SELECT_LOCAL: return parseSelectLocal(); case MAP: return parseMap(); case SHOW: return parseShow(); case UPDATE: return parseUpdate(); case DELETE: return parseDelete(); case WATCH: return parseWatch(); /* case NOTIFY: return parseNotify(); */ /* case VALIDATE: return parseValidate(); case DROP: return parseDrop(); */ case IDENTIFIER: if (_lexeme.equalsIgnoreCase("checkpoint")) { return parseCheckpoint(); } default: throw error("unknown query at {0}", token); } }
java
public QueryBuilderKraken parse() { Token token = scanToken(); switch (token) { case CREATE: return parseCreate(); case EXPLAIN: return parseExplain(); case INSERT: return parseInsert(); case REPLACE: return parseReplace(); case SELECT: return parseSelect(); case SELECT_LOCAL: return parseSelectLocal(); case MAP: return parseMap(); case SHOW: return parseShow(); case UPDATE: return parseUpdate(); case DELETE: return parseDelete(); case WATCH: return parseWatch(); /* case NOTIFY: return parseNotify(); */ /* case VALIDATE: return parseValidate(); case DROP: return parseDrop(); */ case IDENTIFIER: if (_lexeme.equalsIgnoreCase("checkpoint")) { return parseCheckpoint(); } default: throw error("unknown query at {0}", token); } }
[ "public", "QueryBuilderKraken", "parse", "(", ")", "{", "Token", "token", "=", "scanToken", "(", ")", ";", "switch", "(", "token", ")", "{", "case", "CREATE", ":", "return", "parseCreate", "(", ")", ";", "case", "EXPLAIN", ":", "return", "parseExplain", ...
Parses the query.
[ "Parses", "the", "query", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L163-L222
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseSelectExpr
private ExprKraken parseSelectExpr() { Token token = scanToken(); if (token == Token.STAR) { // return new UnboundStarExpr(); throw new UnsupportedOperationException(getClass().getName()); } else { _token = token; return parseExpr(); } }
java
private ExprKraken parseSelectExpr() { Token token = scanToken(); if (token == Token.STAR) { // return new UnboundStarExpr(); throw new UnsupportedOperationException(getClass().getName()); } else { _token = token; return parseExpr(); } }
[ "private", "ExprKraken", "parseSelectExpr", "(", ")", "{", "Token", "token", "=", "scanToken", "(", ")", ";", "if", "(", "token", "==", "Token", ".", "STAR", ")", "{", "// return new UnboundStarExpr();", "throw", "new", "UnsupportedOperationException", "(", "get...
Parses a select expression.
[ "Parses", "a", "select", "expression", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L792-L806
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseCreate
private QueryBuilderKraken parseCreate() { Token token; // TableBuilderKraken factory = null;// = _database.createTableFactory(); if ((token = scanToken()) != Token.TABLE) throw error("expected TABLE at '{0}'", token); if ((token = scanToken()) != Token.IDENTIFIER) throw error("expected identifier at '{0}'", token); String name = _lexeme; String pod = null; while (peekToken() == Token.DOT) { scanToken(); if ((token = scanToken()) != Token.IDENTIFIER) { throw error("expected identifier at '{0}'", token); } if (pod == null) { pod = name; } else { pod = pod + '.' + name; } name = _lexeme; } if (pod == null) { pod = getPodName(); } TableBuilderKraken factory = new TableBuilderKraken(pod, name, _sql); // factory.startTable(_lexeme); if ((token = scanToken()) != Token.LPAREN) { throw error("expected '(' at '{0}'", token); } do { token = scanToken(); switch (token) { case IDENTIFIER: parseCreateColumn(factory, _lexeme); break; /* case UNIQUE: token = scanToken(); if (token != KEY) { _token = token; } factory.addUnique(parseColumnNames()); break; */ case PRIMARY: token = scanToken(); if (token != Token.KEY) throw error("expected 'key' at {0}", token); factory.addPrimaryKey(parseColumnNames()); break; case KEY: //String key = parseIdentifier(); factory.addPrimaryKey(parseColumnNames()); // factory.addPrimaryKey(parseColumnNames()); break; /* case CHECK: if ((token = scanToken()) != '(') throw error(L.l("Expected '(' at '{0}'", tokenName(token))); parseExpr(); if ((token = scanToken()) != ')') throw error(L.l("Expected ')' at '{0}'", tokenName(token))); break; */ default: throw error("unexpected token '{0}'", token); } token = scanToken(); } while (token == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } token = scanToken(); HashMap<String,String> propMap = new HashMap<>(); if (token == Token.WITH) { do { String key = parseIdentifier(); ExprKraken expr = parseExpr(); if (! (expr instanceof LiteralExpr)) { throw error("WITH expression must be a literal at '{0}'", expr); } String value = expr.evalString(null); propMap.put(key, value); } while ((token = scanToken()) == Token.COMMA); } if (token != Token.EOF) { throw error("Expected end of file at '{0}'", token); } return new CreateQueryBuilder(_tableManager, factory, _sql, propMap); }
java
private QueryBuilderKraken parseCreate() { Token token; // TableBuilderKraken factory = null;// = _database.createTableFactory(); if ((token = scanToken()) != Token.TABLE) throw error("expected TABLE at '{0}'", token); if ((token = scanToken()) != Token.IDENTIFIER) throw error("expected identifier at '{0}'", token); String name = _lexeme; String pod = null; while (peekToken() == Token.DOT) { scanToken(); if ((token = scanToken()) != Token.IDENTIFIER) { throw error("expected identifier at '{0}'", token); } if (pod == null) { pod = name; } else { pod = pod + '.' + name; } name = _lexeme; } if (pod == null) { pod = getPodName(); } TableBuilderKraken factory = new TableBuilderKraken(pod, name, _sql); // factory.startTable(_lexeme); if ((token = scanToken()) != Token.LPAREN) { throw error("expected '(' at '{0}'", token); } do { token = scanToken(); switch (token) { case IDENTIFIER: parseCreateColumn(factory, _lexeme); break; /* case UNIQUE: token = scanToken(); if (token != KEY) { _token = token; } factory.addUnique(parseColumnNames()); break; */ case PRIMARY: token = scanToken(); if (token != Token.KEY) throw error("expected 'key' at {0}", token); factory.addPrimaryKey(parseColumnNames()); break; case KEY: //String key = parseIdentifier(); factory.addPrimaryKey(parseColumnNames()); // factory.addPrimaryKey(parseColumnNames()); break; /* case CHECK: if ((token = scanToken()) != '(') throw error(L.l("Expected '(' at '{0}'", tokenName(token))); parseExpr(); if ((token = scanToken()) != ')') throw error(L.l("Expected ')' at '{0}'", tokenName(token))); break; */ default: throw error("unexpected token '{0}'", token); } token = scanToken(); } while (token == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } token = scanToken(); HashMap<String,String> propMap = new HashMap<>(); if (token == Token.WITH) { do { String key = parseIdentifier(); ExprKraken expr = parseExpr(); if (! (expr instanceof LiteralExpr)) { throw error("WITH expression must be a literal at '{0}'", expr); } String value = expr.evalString(null); propMap.put(key, value); } while ((token = scanToken()) == Token.COMMA); } if (token != Token.EOF) { throw error("Expected end of file at '{0}'", token); } return new CreateQueryBuilder(_tableManager, factory, _sql, propMap); }
[ "private", "QueryBuilderKraken", "parseCreate", "(", ")", "{", "Token", "token", ";", "// TableBuilderKraken factory = null;// = _database.createTableFactory();", "if", "(", "(", "token", "=", "scanToken", "(", ")", ")", "!=", "Token", ".", "TABLE", ")", "throw", "e...
Parses the create.
[ "Parses", "the", "create", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L984-L1108
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseReferences
public void parseReferences(ArrayList<String> name) { String foreignTable = parseIdentifier(); Token token = scanToken(); ArrayList<String> foreignColumns = new ArrayList<String>(); if (token == Token.LPAREN) { _token = token; foreignColumns = parseColumnNames(); } else { _token = token; } }
java
public void parseReferences(ArrayList<String> name) { String foreignTable = parseIdentifier(); Token token = scanToken(); ArrayList<String> foreignColumns = new ArrayList<String>(); if (token == Token.LPAREN) { _token = token; foreignColumns = parseColumnNames(); } else { _token = token; } }
[ "public", "void", "parseReferences", "(", "ArrayList", "<", "String", ">", "name", ")", "{", "String", "foreignTable", "=", "parseIdentifier", "(", ")", ";", "Token", "token", "=", "scanToken", "(", ")", ";", "ArrayList", "<", "String", ">", "foreignColumns"...
Parses the references clause.
[ "Parses", "the", "references", "clause", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L1411-L1427
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseColumnNames
public ArrayList<String> parseColumnNames() { ArrayList<String> columns = new ArrayList<String>(); Token token = scanToken(); if (token == Token.LPAREN) { do { columns.add(parseIdentifier()); token = scanToken(); } while (token == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } } else if (token == Token.IDENTIFIER) { columns.add(_lexeme); _token = token; } else { throw error("expected '(' at '{0}'", token); } return columns; }
java
public ArrayList<String> parseColumnNames() { ArrayList<String> columns = new ArrayList<String>(); Token token = scanToken(); if (token == Token.LPAREN) { do { columns.add(parseIdentifier()); token = scanToken(); } while (token == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } } else if (token == Token.IDENTIFIER) { columns.add(_lexeme); _token = token; } else { throw error("expected '(' at '{0}'", token); } return columns; }
[ "public", "ArrayList", "<", "String", ">", "parseColumnNames", "(", ")", "{", "ArrayList", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Token", "token", "=", "scanToken", "(", ")", ";", "if", "(", "token",...
Parses a list of column names
[ "Parses", "a", "list", "of", "column", "names" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L1432-L1458
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseInsert
private QueryBuilderKraken parseInsert() { Token token; if ((token = scanToken()) != Token.INTO) { throw error("expected INTO at '{0}'", token); } TableKraken table = parseTable(); Objects.requireNonNull(table); TableKelp tableKelp = table.getTableKelp(); ArrayList<Column> columns = new ArrayList<>(); boolean isKeyHash = false; if ((token = scanToken()) == Token.LPAREN) { do { String columnName = parseIdentifier(); Column column = tableKelp.getColumn(columnName); if (column == null) { throw error("'{0}' is not a valid column in {1}", columnName, table.getName()); } columns.add(column); } while ((token = scanToken()) == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } token = scanToken(); } else { for (Column column : tableKelp.getColumns()) { if (column.name().startsWith(":")) { continue; } columns.add(column); } } if (token != Token.VALUES) throw error("expected VALUES at '{0}'", token); if ((token = scanToken()) != Token.LPAREN) { throw error("expected '(' at '{0}'", token); } ArrayList<ExprKraken> values = new ArrayList<>(); InsertQueryBuilder query; query = new InsertQueryBuilder(this, _sql, table, columns); _query = query; do { ExprKraken expr = parseExpr(); //expr = expr.bind(new TempQueryBuilder(table)); values.add(expr); } while ((token = scanToken()) == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } if (columns.size() != values.size()) { throw error("number of columns does not match number of values"); } ParamExpr []params = _params.toArray(new ParamExpr[_params.size()]); query.setParams(params); query.setValues(values); // query.init(); return query; }
java
private QueryBuilderKraken parseInsert() { Token token; if ((token = scanToken()) != Token.INTO) { throw error("expected INTO at '{0}'", token); } TableKraken table = parseTable(); Objects.requireNonNull(table); TableKelp tableKelp = table.getTableKelp(); ArrayList<Column> columns = new ArrayList<>(); boolean isKeyHash = false; if ((token = scanToken()) == Token.LPAREN) { do { String columnName = parseIdentifier(); Column column = tableKelp.getColumn(columnName); if (column == null) { throw error("'{0}' is not a valid column in {1}", columnName, table.getName()); } columns.add(column); } while ((token = scanToken()) == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } token = scanToken(); } else { for (Column column : tableKelp.getColumns()) { if (column.name().startsWith(":")) { continue; } columns.add(column); } } if (token != Token.VALUES) throw error("expected VALUES at '{0}'", token); if ((token = scanToken()) != Token.LPAREN) { throw error("expected '(' at '{0}'", token); } ArrayList<ExprKraken> values = new ArrayList<>(); InsertQueryBuilder query; query = new InsertQueryBuilder(this, _sql, table, columns); _query = query; do { ExprKraken expr = parseExpr(); //expr = expr.bind(new TempQueryBuilder(table)); values.add(expr); } while ((token = scanToken()) == Token.COMMA); if (token != Token.RPAREN) { throw error("expected ')' at '{0}'", token); } if (columns.size() != values.size()) { throw error("number of columns does not match number of values"); } ParamExpr []params = _params.toArray(new ParamExpr[_params.size()]); query.setParams(params); query.setValues(values); // query.init(); return query; }
[ "private", "QueryBuilderKraken", "parseInsert", "(", ")", "{", "Token", "token", ";", "if", "(", "(", "token", "=", "scanToken", "(", ")", ")", "!=", "Token", ".", "INTO", ")", "{", "throw", "error", "(", "\"expected INTO at '{0}'\"", ",", "token", ")", ...
Parses the insert.
[ "Parses", "the", "insert", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L1463-L1548
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseUpdate
private QueryBuilderKraken parseUpdate() { Token token; UpdateQueryBuilder query = new UpdateQueryBuilder(_tableManager, _sql); String tableName = parseTableName(); query.setTableName(tableName); _query = query; if ((token = scanToken()) != Token.SET) { throw error(L.l("expected SET at {0}", token)); } do { parseSetItem(query); } while ((token = scanToken()) == Token.COMMA); _token = token; //query.setUpdateBuilder(new SetUpdateBuilder(setItems)); ExprKraken whereExpr = null; token = scanToken(); if (token == Token.WHERE) { whereExpr = parseExpr(); } else if (token != null && token != Token.EOF) { throw error("expected WHERE at '{0}'", token); } ParamExpr []params = _params.toArray(new ParamExpr[_params.size()]); query.setParams(params); query.setWhereExpr(whereExpr); return query; }
java
private QueryBuilderKraken parseUpdate() { Token token; UpdateQueryBuilder query = new UpdateQueryBuilder(_tableManager, _sql); String tableName = parseTableName(); query.setTableName(tableName); _query = query; if ((token = scanToken()) != Token.SET) { throw error(L.l("expected SET at {0}", token)); } do { parseSetItem(query); } while ((token = scanToken()) == Token.COMMA); _token = token; //query.setUpdateBuilder(new SetUpdateBuilder(setItems)); ExprKraken whereExpr = null; token = scanToken(); if (token == Token.WHERE) { whereExpr = parseExpr(); } else if (token != null && token != Token.EOF) { throw error("expected WHERE at '{0}'", token); } ParamExpr []params = _params.toArray(new ParamExpr[_params.size()]); query.setParams(params); query.setWhereExpr(whereExpr); return query; }
[ "private", "QueryBuilderKraken", "parseUpdate", "(", ")", "{", "Token", "token", ";", "UpdateQueryBuilder", "query", "=", "new", "UpdateQueryBuilder", "(", "_tableManager", ",", "_sql", ")", ";", "String", "tableName", "=", "parseTableName", "(", ")", ";", "quer...
Parses the update. UPDATE table_name SET a=?,b=? WHERE expr
[ "Parses", "the", "update", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L1852-L1893
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseSetItem
private void parseSetItem(UpdateQueryBuilder query) { Token token; if ((token = scanToken()) != Token.IDENTIFIER) { throw error(L.l("expected identifier at '{0}'", token)); } String columnName = _lexeme; if ((token = scanToken()) != Token.EQ) { throw error("expected '=' at {0}", token); } ExprKraken expr = parseExpr(); query.addItem(columnName, expr); }
java
private void parseSetItem(UpdateQueryBuilder query) { Token token; if ((token = scanToken()) != Token.IDENTIFIER) { throw error(L.l("expected identifier at '{0}'", token)); } String columnName = _lexeme; if ((token = scanToken()) != Token.EQ) { throw error("expected '=' at {0}", token); } ExprKraken expr = parseExpr(); query.addItem(columnName, expr); }
[ "private", "void", "parseSetItem", "(", "UpdateQueryBuilder", "query", ")", "{", "Token", "token", ";", "if", "(", "(", "token", "=", "scanToken", "(", ")", ")", "!=", "Token", ".", "IDENTIFIER", ")", "{", "throw", "error", "(", "L", ".", "l", "(", "...
Parses a set item.
[ "Parses", "a", "set", "item", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L1917-L1934
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseAndExpr
private ExprKraken parseAndExpr() { // AndExpr oldAndExpr = _andExpr; AndExpr andExpr = new AndExpr(); // _andExpr = andExpr; andExpr.add(parseNotExpr()); while (true) { Token token = scanToken(); switch (token) { case AND: andExpr.add(parseNotExpr()); break; default: _token = token; // _andExpr = oldAndExpr; return andExpr.getSingleExpr(); } } }
java
private ExprKraken parseAndExpr() { // AndExpr oldAndExpr = _andExpr; AndExpr andExpr = new AndExpr(); // _andExpr = andExpr; andExpr.add(parseNotExpr()); while (true) { Token token = scanToken(); switch (token) { case AND: andExpr.add(parseNotExpr()); break; default: _token = token; // _andExpr = oldAndExpr; return andExpr.getSingleExpr(); } } }
[ "private", "ExprKraken", "parseAndExpr", "(", ")", "{", "// AndExpr oldAndExpr = _andExpr;", "AndExpr", "andExpr", "=", "new", "AndExpr", "(", ")", ";", "// _andExpr = andExpr;", "andExpr", ".", "add", "(", "parseNotExpr", "(", ")", ")", ";", "while", "(", "true...
Parses an AND expression.
[ "Parses", "an", "AND", "expression", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L1970-L1994
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseCmpExpr
private ExprKraken parseCmpExpr() { // Expr left = parseConcatExpr(); ExprKraken left = parseAddExpr(); Token token = scanToken(); boolean isNot = false; /* if (token == NOT) { isNot = true; token = scanToken(); if (token != BETWEEN && token != LIKE && token != IN) { _token = token; return left; } } */ switch (token) { case EQ: return new BinaryExpr(BinaryOp.EQ, left, parseAddExpr()); case NE: return new BinaryExpr(BinaryOp.NE, left, parseAddExpr()); case LT: return new BinaryExpr(BinaryOp.LT, left, parseAddExpr()); case LE: return new BinaryExpr(BinaryOp.LE, left, parseAddExpr()); case GT: return new BinaryExpr(BinaryOp.GT, left, parseAddExpr()); case GE: return new BinaryExpr(BinaryOp.GE, left, parseAddExpr()); case BETWEEN: { ExprKraken min = parseAddExpr(); token = scanToken(); if (token != Token.AND) throw error(L.l("expected AND at '{0}'", token)); ExprKraken max = parseAddExpr(); return new BetweenExpr(left, min, max, isNot); } /* case LT: case LE: case GT: case GE: case NE: return new CmpExpr(left, parseConcatExpr(), token); case BETWEEN: { Expr min = parseConcatExpr(); token = scanToken(); if (token != AND) throw error(L.l("expected AND at '{0}'", tokenName(token))); Expr max = parseConcatExpr(); return new BetweenExpr(left, min, max, isNot); } case IS: { token = scanToken(); isNot = false; if (token == NOT) { token = scanToken(); isNot = true; } if (token == NULL) return new IsNullExpr(left, isNot); else throw error(L.l("expected NULL at '{0}'", tokenName(token))); } case LIKE: { token = scanToken(); if (token == STRING) return new LikeExpr(left, _lexeme, isNot); else throw error(L.l("expected string at '{0}'", tokenName(token))); } case IN: { HashSet<String> values = parseInValues(); return new InExpr(left, values, isNot); } */ default: _token = token; return left; } }
java
private ExprKraken parseCmpExpr() { // Expr left = parseConcatExpr(); ExprKraken left = parseAddExpr(); Token token = scanToken(); boolean isNot = false; /* if (token == NOT) { isNot = true; token = scanToken(); if (token != BETWEEN && token != LIKE && token != IN) { _token = token; return left; } } */ switch (token) { case EQ: return new BinaryExpr(BinaryOp.EQ, left, parseAddExpr()); case NE: return new BinaryExpr(BinaryOp.NE, left, parseAddExpr()); case LT: return new BinaryExpr(BinaryOp.LT, left, parseAddExpr()); case LE: return new BinaryExpr(BinaryOp.LE, left, parseAddExpr()); case GT: return new BinaryExpr(BinaryOp.GT, left, parseAddExpr()); case GE: return new BinaryExpr(BinaryOp.GE, left, parseAddExpr()); case BETWEEN: { ExprKraken min = parseAddExpr(); token = scanToken(); if (token != Token.AND) throw error(L.l("expected AND at '{0}'", token)); ExprKraken max = parseAddExpr(); return new BetweenExpr(left, min, max, isNot); } /* case LT: case LE: case GT: case GE: case NE: return new CmpExpr(left, parseConcatExpr(), token); case BETWEEN: { Expr min = parseConcatExpr(); token = scanToken(); if (token != AND) throw error(L.l("expected AND at '{0}'", tokenName(token))); Expr max = parseConcatExpr(); return new BetweenExpr(left, min, max, isNot); } case IS: { token = scanToken(); isNot = false; if (token == NOT) { token = scanToken(); isNot = true; } if (token == NULL) return new IsNullExpr(left, isNot); else throw error(L.l("expected NULL at '{0}'", tokenName(token))); } case LIKE: { token = scanToken(); if (token == STRING) return new LikeExpr(left, _lexeme, isNot); else throw error(L.l("expected string at '{0}'", tokenName(token))); } case IN: { HashSet<String> values = parseInValues(); return new InExpr(left, values, isNot); } */ default: _token = token; return left; } }
[ "private", "ExprKraken", "parseCmpExpr", "(", ")", "{", "// Expr left = parseConcatExpr();", "ExprKraken", "left", "=", "parseAddExpr", "(", ")", ";", "Token", "token", "=", "scanToken", "(", ")", ";", "boolean", "isNot", "=", "false", ";", "/*\n\n if (token ==...
Parses a CMP expression.
[ "Parses", "a", "CMP", "expression", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L2024-L2136
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseSimpleTerm
private ExprKraken parseSimpleTerm() { Token token = scanToken(); switch (token) { case MINUS: return new UnaryExpr(UnaryOp.MINUS, parseSimpleTerm()); case LPAREN: { ExprKraken expr = parseExpr(); if ((token = scanToken()) != Token.RPAREN) { throw error("Expected ')' at '{0}'", token); } return expr; } case IDENTIFIER: { String name = _lexeme; if ((token = peekToken()) == Token.DOT) { return parsePath(name); } else if (token == Token.LPAREN) { FunExpr fun = null; /* if (name.equalsIgnoreCase("max")) fun = new MaxExpr(); else if (name.equalsIgnoreCase("min")) fun = new MinExpr(); else if (name.equalsIgnoreCase("sum")) fun = new SumExpr(); else if (name.equalsIgnoreCase("avg")) fun = new AvgExpr(); else if (name.equalsIgnoreCase("count")) { fun = new CountExpr(); token = scanToken(); if (token == '*') { fun.addArg(new UnboundStarExpr()); } else _token = token; } else */ { String funName = (Character.toUpperCase(name.charAt(0)) + name.substring(1).toLowerCase(Locale.ENGLISH)); funName = "com.caucho.v5.kraken.fun." + funName + "Expr"; try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?> cl = Class.forName(funName, false, loader); fun = (FunExpr) cl.newInstance(); } catch (ClassNotFoundException e) { log.finer(e.toString()); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); throw error(e.toString()); } if (fun == null) { throw error(L.l("'{0}' is an unknown function.", name)); } } scanToken(); token = peekToken(); while (token != null && token != Token.RPAREN) { ExprKraken arg = parseExpr(); fun.addArg(arg); token = peekToken(); if (token == Token.COMMA) { scanToken(); token = peekToken(); } } scanToken(); return fun; } else { return new IdExprBuilder(name); } } case STRING: return new LiteralExpr(_lexeme); case DOUBLE: return new LiteralExpr(Double.parseDouble(_lexeme)); case INTEGER: return new LiteralExpr(Long.parseLong(_lexeme)); case LONG: return new LiteralExpr(Long.parseLong(_lexeme)); case NULL: return new NullExpr(); case TRUE: return new LiteralExpr(true); case FALSE: return new LiteralExpr(false); case QUESTION_MARK: ParamExpr param = new ParamExpr(_params.size()); _params.add(param); return param; default: throw error("unexpected term {0}", token); } }
java
private ExprKraken parseSimpleTerm() { Token token = scanToken(); switch (token) { case MINUS: return new UnaryExpr(UnaryOp.MINUS, parseSimpleTerm()); case LPAREN: { ExprKraken expr = parseExpr(); if ((token = scanToken()) != Token.RPAREN) { throw error("Expected ')' at '{0}'", token); } return expr; } case IDENTIFIER: { String name = _lexeme; if ((token = peekToken()) == Token.DOT) { return parsePath(name); } else if (token == Token.LPAREN) { FunExpr fun = null; /* if (name.equalsIgnoreCase("max")) fun = new MaxExpr(); else if (name.equalsIgnoreCase("min")) fun = new MinExpr(); else if (name.equalsIgnoreCase("sum")) fun = new SumExpr(); else if (name.equalsIgnoreCase("avg")) fun = new AvgExpr(); else if (name.equalsIgnoreCase("count")) { fun = new CountExpr(); token = scanToken(); if (token == '*') { fun.addArg(new UnboundStarExpr()); } else _token = token; } else */ { String funName = (Character.toUpperCase(name.charAt(0)) + name.substring(1).toLowerCase(Locale.ENGLISH)); funName = "com.caucho.v5.kraken.fun." + funName + "Expr"; try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?> cl = Class.forName(funName, false, loader); fun = (FunExpr) cl.newInstance(); } catch (ClassNotFoundException e) { log.finer(e.toString()); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); throw error(e.toString()); } if (fun == null) { throw error(L.l("'{0}' is an unknown function.", name)); } } scanToken(); token = peekToken(); while (token != null && token != Token.RPAREN) { ExprKraken arg = parseExpr(); fun.addArg(arg); token = peekToken(); if (token == Token.COMMA) { scanToken(); token = peekToken(); } } scanToken(); return fun; } else { return new IdExprBuilder(name); } } case STRING: return new LiteralExpr(_lexeme); case DOUBLE: return new LiteralExpr(Double.parseDouble(_lexeme)); case INTEGER: return new LiteralExpr(Long.parseLong(_lexeme)); case LONG: return new LiteralExpr(Long.parseLong(_lexeme)); case NULL: return new NullExpr(); case TRUE: return new LiteralExpr(true); case FALSE: return new LiteralExpr(false); case QUESTION_MARK: ParamExpr param = new ParamExpr(_params.size()); _params.add(param); return param; default: throw error("unexpected term {0}", token); } }
[ "private", "ExprKraken", "parseSimpleTerm", "(", ")", "{", "Token", "token", "=", "scanToken", "(", ")", ";", "switch", "(", "token", ")", "{", "case", "MINUS", ":", "return", "new", "UnaryExpr", "(", "UnaryOp", ".", "MINUS", ",", "parseSimpleTerm", "(", ...
Parses a simple term.
[ "Parses", "a", "simple", "term", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L2279-L2406
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java
QueryParserKraken.parseIdentifier
private String parseIdentifier() { Token token = scanToken(); if (token != Token.IDENTIFIER) { throw error("expected identifier at {0}", token); } return _lexeme; }
java
private String parseIdentifier() { Token token = scanToken(); if (token != Token.IDENTIFIER) { throw error("expected identifier at {0}", token); } return _lexeme; }
[ "private", "String", "parseIdentifier", "(", ")", "{", "Token", "token", "=", "scanToken", "(", ")", ";", "if", "(", "token", "!=", "Token", ".", "IDENTIFIER", ")", "{", "throw", "error", "(", "\"expected identifier at {0}\"", ",", "token", ")", ";", "}", ...
Parses an identifier.
[ "Parses", "an", "identifier", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/QueryParserKraken.java#L2437-L2446
train
baratine/baratine
web/src/main/java/com/caucho/v5/deploy2/DeployHandle2Base.java
DeployHandle2Base.get
@Override public I get() { I instance = _instance; if (instance == null || instance.isModified()) { _instance = instance = service().get(); } return instance; }
java
@Override public I get() { I instance = _instance; if (instance == null || instance.isModified()) { _instance = instance = service().get(); } return instance; }
[ "@", "Override", "public", "I", "get", "(", ")", "{", "I", "instance", "=", "_instance", ";", "if", "(", "instance", "==", "null", "||", "instance", ".", "isModified", "(", ")", ")", "{", "_instance", "=", "instance", "=", "service", "(", ")", ".", ...
Returns the current instance.
[ "Returns", "the", "current", "instance", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/deploy2/DeployHandle2Base.java#L95-L105
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/TimedCache.java
TimedCache.put
public V put(K key, V value) { Entry<V> oldValue = _cache.put(key, new Entry<V>(_expireInterval, value)); if (oldValue != null) return oldValue.getValue(); else return null; }
java
public V put(K key, V value) { Entry<V> oldValue = _cache.put(key, new Entry<V>(_expireInterval, value)); if (oldValue != null) return oldValue.getValue(); else return null; }
[ "public", "V", "put", "(", "K", "key", ",", "V", "value", ")", "{", "Entry", "<", "V", ">", "oldValue", "=", "_cache", ".", "put", "(", "key", ",", "new", "Entry", "<", "V", ">", "(", "_expireInterval", ",", "value", ")", ")", ";", "if", "(", ...
Put a new item in the cache.
[ "Put", "a", "new", "item", "in", "the", "cache", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/TimedCache.java#L71-L79
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/TimedCache.java
TimedCache.get
public V get(K key) { Entry<V> entry = _cache.get(key); if (entry == null) return null; if (entry.isValid()) return entry.getValue(); else { _cache.remove(key); return null; } }
java
public V get(K key) { Entry<V> entry = _cache.get(key); if (entry == null) return null; if (entry.isValid()) return entry.getValue(); else { _cache.remove(key); return null; } }
[ "public", "V", "get", "(", "K", "key", ")", "{", "Entry", "<", "V", ">", "entry", "=", "_cache", ".", "get", "(", "key", ")", ";", "if", "(", "entry", "==", "null", ")", "return", "null", ";", "if", "(", "entry", ".", "isValid", "(", ")", ")"...
Gets an item from the cache, returning null if expired.
[ "Gets", "an", "item", "from", "the", "cache", "returning", "null", "if", "expired", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/TimedCache.java#L84-L98
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/ByteCodeClassScanner.java
ByteCodeClassScanner.parseUtf8
private int parseUtf8(InputStream is, int length) throws IOException { if (length <= 0) return 0; if (length > 256) { is.skip(length); return 0; } int offset = _charBufferOffset; if (_charBuffer.length <= offset + length) { char []buffer = new char[2 * _charBuffer.length]; System.arraycopy(_charBuffer, 0, buffer, 0, _charBuffer.length); _charBuffer = buffer; } char []buffer = _charBuffer; boolean []isJavaIdentifier = IS_JAVA_IDENTIFIER; boolean isIdentifier = true; while (length > 0) { int d1 = is.read(); char ch; if (d1 == '/') { ch = '.'; length--; } else if (d1 < 0x80) { ch = (char) d1; length--; } else if (d1 < 0xe0) { int d2 = is.read() & 0x3f; ch = (char) (((d1 & 0x1f) << 6) + (d2)); length -= 2; } else if (d1 < 0xf0) { int d2 = is.read() & 0x3f; int d3 = is.read() & 0x3f; ch = (char) (((d1 & 0xf) << 12) + (d2 << 6) + d3); length -= 3; } else throw new IllegalStateException(); if (isIdentifier && isJavaIdentifier[ch]) { buffer[offset++] = ch; } else { isIdentifier = false; } } if (! isIdentifier) return 0; int charLength = offset - _charBufferOffset; _charBufferOffset = offset; return charLength; }
java
private int parseUtf8(InputStream is, int length) throws IOException { if (length <= 0) return 0; if (length > 256) { is.skip(length); return 0; } int offset = _charBufferOffset; if (_charBuffer.length <= offset + length) { char []buffer = new char[2 * _charBuffer.length]; System.arraycopy(_charBuffer, 0, buffer, 0, _charBuffer.length); _charBuffer = buffer; } char []buffer = _charBuffer; boolean []isJavaIdentifier = IS_JAVA_IDENTIFIER; boolean isIdentifier = true; while (length > 0) { int d1 = is.read(); char ch; if (d1 == '/') { ch = '.'; length--; } else if (d1 < 0x80) { ch = (char) d1; length--; } else if (d1 < 0xe0) { int d2 = is.read() & 0x3f; ch = (char) (((d1 & 0x1f) << 6) + (d2)); length -= 2; } else if (d1 < 0xf0) { int d2 = is.read() & 0x3f; int d3 = is.read() & 0x3f; ch = (char) (((d1 & 0xf) << 12) + (d2 << 6) + d3); length -= 3; } else throw new IllegalStateException(); if (isIdentifier && isJavaIdentifier[ch]) { buffer[offset++] = ch; } else { isIdentifier = false; } } if (! isIdentifier) return 0; int charLength = offset - _charBufferOffset; _charBufferOffset = offset; return charLength; }
[ "private", "int", "parseUtf8", "(", "InputStream", "is", ",", "int", "length", ")", "throws", "IOException", "{", "if", "(", "length", "<=", "0", ")", "return", "0", ";", "if", "(", "length", ">", "256", ")", "{", "is", ".", "skip", "(", "length", ...
Parses the UTF.
[ "Parses", "the", "UTF", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/ByteCodeClassScanner.java#L307-L379
train