id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
139,800
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java
FileHeaderPage.close
public void close() { if (blk != null) { tx.bufferMgr().unpin(currentBuff); blk = null; currentBuff = null; } }
java
public void close() { if (blk != null) { tx.bufferMgr().unpin(currentBuff); blk = null; currentBuff = null; } }
[ "public", "void", "close", "(", ")", "{", "if", "(", "blk", "!=", "null", ")", "{", "tx", ".", "bufferMgr", "(", ")", ".", "unpin", "(", "currentBuff", ")", ";", "blk", "=", "null", ";", "currentBuff", "=", "null", ";", "}", "}" ]
Closes the header manager, by unpinning the block.
[ "Closes", "the", "header", "manager", "by", "unpinning", "the", "block", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java#L73-L79
139,801
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java
FileHeaderPage.hasDataRecords
public boolean hasDataRecords() { long blkNum = (Long) getVal(OFFSET_TS_BLOCKID, BIGINT).asJavaVal(); return blkNum != NO_SLOT_BLOCKID ? true : false; }
java
public boolean hasDataRecords() { long blkNum = (Long) getVal(OFFSET_TS_BLOCKID, BIGINT).asJavaVal(); return blkNum != NO_SLOT_BLOCKID ? true : false; }
[ "public", "boolean", "hasDataRecords", "(", ")", "{", "long", "blkNum", "=", "(", "Long", ")", "getVal", "(", "OFFSET_TS_BLOCKID", ",", "BIGINT", ")", ".", "asJavaVal", "(", ")", ";", "return", "blkNum", "!=", "NO_SLOT_BLOCKID", "?", "true", ":", "false", ";", "}" ]
Return true if this file has inserted data records. @return true if this file has inserted data records
[ "Return", "true", "if", "this", "file", "has", "inserted", "data", "records", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java#L86-L89
139,802
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java
FileHeaderPage.hasDeletedSlots
public boolean hasDeletedSlots() { long blkNum = (Long) getVal(OFFSET_LDS_BLOCKID, BIGINT).asJavaVal(); return blkNum != NO_SLOT_BLOCKID ? true : false; }
java
public boolean hasDeletedSlots() { long blkNum = (Long) getVal(OFFSET_LDS_BLOCKID, BIGINT).asJavaVal(); return blkNum != NO_SLOT_BLOCKID ? true : false; }
[ "public", "boolean", "hasDeletedSlots", "(", ")", "{", "long", "blkNum", "=", "(", "Long", ")", "getVal", "(", "OFFSET_LDS_BLOCKID", ",", "BIGINT", ")", ".", "asJavaVal", "(", ")", ";", "return", "blkNum", "!=", "NO_SLOT_BLOCKID", "?", "true", ":", "false", ";", "}" ]
Return true if this file has deleted data records. @return true if this file has deleted data records
[ "Return", "true", "if", "this", "file", "has", "deleted", "data", "records", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java#L96-L99
139,803
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java
FileHeaderPage.getLastDeletedSlot
public RecordId getLastDeletedSlot() { Constant blkNum = getVal(OFFSET_LDS_BLOCKID, BIGINT); Constant rid = getVal(OFFSET_LDS_RID, INTEGER); BlockId bid = new BlockId(fileName, (Long) blkNum.asJavaVal()); return new RecordId(bid, (Integer) rid.asJavaVal()); }
java
public RecordId getLastDeletedSlot() { Constant blkNum = getVal(OFFSET_LDS_BLOCKID, BIGINT); Constant rid = getVal(OFFSET_LDS_RID, INTEGER); BlockId bid = new BlockId(fileName, (Long) blkNum.asJavaVal()); return new RecordId(bid, (Integer) rid.asJavaVal()); }
[ "public", "RecordId", "getLastDeletedSlot", "(", ")", "{", "Constant", "blkNum", "=", "getVal", "(", "OFFSET_LDS_BLOCKID", ",", "BIGINT", ")", ";", "Constant", "rid", "=", "getVal", "(", "OFFSET_LDS_RID", ",", "INTEGER", ")", ";", "BlockId", "bid", "=", "new", "BlockId", "(", "fileName", ",", "(", "Long", ")", "blkNum", ".", "asJavaVal", "(", ")", ")", ";", "return", "new", "RecordId", "(", "bid", ",", "(", "Integer", ")", "rid", ".", "asJavaVal", "(", ")", ")", ";", "}" ]
Returns the id of last deleted record. @return the id of last deleted record
[ "Returns", "the", "id", "of", "last", "deleted", "record", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java#L106-L111
139,804
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java
FileHeaderPage.getTailSolt
public RecordId getTailSolt() { Constant blkNum = getVal(OFFSET_TS_BLOCKID, BIGINT); Constant rid = getVal(OFFSET_TS_RID, INTEGER); BlockId bid = new BlockId(fileName, (Long) blkNum.asJavaVal()); return new RecordId(bid, (Integer) rid.asJavaVal()); }
java
public RecordId getTailSolt() { Constant blkNum = getVal(OFFSET_TS_BLOCKID, BIGINT); Constant rid = getVal(OFFSET_TS_RID, INTEGER); BlockId bid = new BlockId(fileName, (Long) blkNum.asJavaVal()); return new RecordId(bid, (Integer) rid.asJavaVal()); }
[ "public", "RecordId", "getTailSolt", "(", ")", "{", "Constant", "blkNum", "=", "getVal", "(", "OFFSET_TS_BLOCKID", ",", "BIGINT", ")", ";", "Constant", "rid", "=", "getVal", "(", "OFFSET_TS_RID", ",", "INTEGER", ")", ";", "BlockId", "bid", "=", "new", "BlockId", "(", "fileName", ",", "(", "Long", ")", "blkNum", ".", "asJavaVal", "(", ")", ")", ";", "return", "new", "RecordId", "(", "bid", ",", "(", "Integer", ")", "rid", ".", "asJavaVal", "(", ")", ")", ";", "}" ]
Returns the id of tail slot. @return the id of tail slot
[ "Returns", "the", "id", "of", "tail", "slot", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java#L118-L123
139,805
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java
FileHeaderPage.setLastDeletedSlot
public void setLastDeletedSlot(RecordId rid) { setVal(OFFSET_LDS_BLOCKID, new BigIntConstant(rid.block().number())); setVal(OFFSET_LDS_RID, new IntegerConstant(rid.id())); }
java
public void setLastDeletedSlot(RecordId rid) { setVal(OFFSET_LDS_BLOCKID, new BigIntConstant(rid.block().number())); setVal(OFFSET_LDS_RID, new IntegerConstant(rid.id())); }
[ "public", "void", "setLastDeletedSlot", "(", "RecordId", "rid", ")", "{", "setVal", "(", "OFFSET_LDS_BLOCKID", ",", "new", "BigIntConstant", "(", "rid", ".", "block", "(", ")", ".", "number", "(", ")", ")", ")", ";", "setVal", "(", "OFFSET_LDS_RID", ",", "new", "IntegerConstant", "(", "rid", ".", "id", "(", ")", ")", ")", ";", "}" ]
Set the id of last deleted record. @param rid the id of last deleted record
[ "Set", "the", "id", "of", "last", "deleted", "record", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java#L131-L134
139,806
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java
FileHeaderPage.setTailSolt
public void setTailSolt(RecordId rid) { setVal(OFFSET_TS_BLOCKID, new BigIntConstant(rid.block().number())); setVal(OFFSET_TS_RID, new IntegerConstant(rid.id())); }
java
public void setTailSolt(RecordId rid) { setVal(OFFSET_TS_BLOCKID, new BigIntConstant(rid.block().number())); setVal(OFFSET_TS_RID, new IntegerConstant(rid.id())); }
[ "public", "void", "setTailSolt", "(", "RecordId", "rid", ")", "{", "setVal", "(", "OFFSET_TS_BLOCKID", ",", "new", "BigIntConstant", "(", "rid", ".", "block", "(", ")", ".", "number", "(", ")", ")", ")", ";", "setVal", "(", "OFFSET_TS_RID", ",", "new", "IntegerConstant", "(", "rid", ".", "id", "(", ")", ")", ")", ";", "}" ]
Set the id of last tail slot. @param rid the id of tail slot
[ "Set", "the", "id", "of", "last", "tail", "slot", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/FileHeaderPage.java#L142-L145
139,807
jbossas/remoting-jmx
src/main/java/org/jboss/remotingjmx/Util.java
Util.getInteger
public static Integer getInteger(Object object) { try { if(object instanceof Integer) return (Integer) object; if(object instanceof String) return Integer.valueOf((String) object); } catch(NumberFormatException nfe) { } return null; }
java
public static Integer getInteger(Object object) { try { if(object instanceof Integer) return (Integer) object; if(object instanceof String) return Integer.valueOf((String) object); } catch(NumberFormatException nfe) { } return null; }
[ "public", "static", "Integer", "getInteger", "(", "Object", "object", ")", "{", "try", "{", "if", "(", "object", "instanceof", "Integer", ")", "return", "(", "Integer", ")", "object", ";", "if", "(", "object", "instanceof", "String", ")", "return", "Integer", ".", "valueOf", "(", "(", "String", ")", "object", ")", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "}", "return", "null", ";", "}" ]
Return an integer if it is an Integer or can get Integer from String, else null
[ "Return", "an", "integer", "if", "it", "is", "an", "Integer", "or", "can", "get", "Integer", "from", "String", "else", "null" ]
dbc87bfed47e5bb9e37c355a77ca0ae9a6ea1363
https://github.com/jbossas/remoting-jmx/blob/dbc87bfed47e5bb9e37c355a77ca0ae9a6ea1363/src/main/java/org/jboss/remotingjmx/Util.java#L145-L155
139,808
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/planner/Planner.java
Planner.createQueryPlan
public Plan createQueryPlan(String qry, Transaction tx) { Parser parser = new Parser(qry); QueryData data = parser.queryCommand(); Verifier.verifyQueryData(data, tx); return qPlanner.createPlan(data, tx); }
java
public Plan createQueryPlan(String qry, Transaction tx) { Parser parser = new Parser(qry); QueryData data = parser.queryCommand(); Verifier.verifyQueryData(data, tx); return qPlanner.createPlan(data, tx); }
[ "public", "Plan", "createQueryPlan", "(", "String", "qry", ",", "Transaction", "tx", ")", "{", "Parser", "parser", "=", "new", "Parser", "(", "qry", ")", ";", "QueryData", "data", "=", "parser", ".", "queryCommand", "(", ")", ";", "Verifier", ".", "verifyQueryData", "(", "data", ",", "tx", ")", ";", "return", "qPlanner", ".", "createPlan", "(", "data", ",", "tx", ")", ";", "}" ]
Creates a plan for an SQL select statement, using the supplied planner. @param qry the SQL query string @param tx the transaction @return the scan corresponding to the query plan
[ "Creates", "a", "plan", "for", "an", "SQL", "select", "statement", "using", "the", "supplied", "planner", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/Planner.java#L55-L60
139,809
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/planner/Planner.java
Planner.executeUpdate
public int executeUpdate(String cmd, Transaction tx) { if (tx.isReadOnly()) throw new UnsupportedOperationException(); Parser parser = new Parser(cmd); Object obj = parser.updateCommand(); if (obj.getClass().equals(InsertData.class)) { Verifier.verifyInsertData((InsertData) obj, tx); return uPlanner.executeInsert((InsertData) obj, tx); } else if (obj.getClass().equals(DeleteData.class)) { Verifier.verifyDeleteData((DeleteData) obj, tx); return uPlanner.executeDelete((DeleteData) obj, tx); } else if (obj.getClass().equals(ModifyData.class)) { Verifier.verifyModifyData((ModifyData) obj, tx); return uPlanner.executeModify((ModifyData) obj, tx); } else if (obj.getClass().equals(CreateTableData.class)) { Verifier.verifyCreateTableData((CreateTableData) obj, tx); return uPlanner.executeCreateTable((CreateTableData) obj, tx); } else if (obj.getClass().equals(CreateViewData.class)) { Verifier.verifyCreateViewData((CreateViewData) obj, tx); return uPlanner.executeCreateView((CreateViewData) obj, tx); } else if (obj.getClass().equals(CreateIndexData.class)) { Verifier.verifyCreateIndexData((CreateIndexData) obj, tx); return uPlanner.executeCreateIndex((CreateIndexData) obj, tx); } else if (obj.getClass().equals(DropTableData.class)) { Verifier.verifyDropTableData((DropTableData) obj, tx); return uPlanner.executeDropTable((DropTableData) obj, tx); } else if (obj.getClass().equals(DropViewData.class)) { Verifier.verifyDropViewData((DropViewData) obj, tx); return uPlanner.executeDropView((DropViewData) obj, tx); } else if (obj.getClass().equals(DropIndexData.class)) { Verifier.verifyDropIndexData((DropIndexData) obj, tx); return uPlanner.executeDropIndex((DropIndexData) obj, tx); } else throw new UnsupportedOperationException(); }
java
public int executeUpdate(String cmd, Transaction tx) { if (tx.isReadOnly()) throw new UnsupportedOperationException(); Parser parser = new Parser(cmd); Object obj = parser.updateCommand(); if (obj.getClass().equals(InsertData.class)) { Verifier.verifyInsertData((InsertData) obj, tx); return uPlanner.executeInsert((InsertData) obj, tx); } else if (obj.getClass().equals(DeleteData.class)) { Verifier.verifyDeleteData((DeleteData) obj, tx); return uPlanner.executeDelete((DeleteData) obj, tx); } else if (obj.getClass().equals(ModifyData.class)) { Verifier.verifyModifyData((ModifyData) obj, tx); return uPlanner.executeModify((ModifyData) obj, tx); } else if (obj.getClass().equals(CreateTableData.class)) { Verifier.verifyCreateTableData((CreateTableData) obj, tx); return uPlanner.executeCreateTable((CreateTableData) obj, tx); } else if (obj.getClass().equals(CreateViewData.class)) { Verifier.verifyCreateViewData((CreateViewData) obj, tx); return uPlanner.executeCreateView((CreateViewData) obj, tx); } else if (obj.getClass().equals(CreateIndexData.class)) { Verifier.verifyCreateIndexData((CreateIndexData) obj, tx); return uPlanner.executeCreateIndex((CreateIndexData) obj, tx); } else if (obj.getClass().equals(DropTableData.class)) { Verifier.verifyDropTableData((DropTableData) obj, tx); return uPlanner.executeDropTable((DropTableData) obj, tx); } else if (obj.getClass().equals(DropViewData.class)) { Verifier.verifyDropViewData((DropViewData) obj, tx); return uPlanner.executeDropView((DropViewData) obj, tx); } else if (obj.getClass().equals(DropIndexData.class)) { Verifier.verifyDropIndexData((DropIndexData) obj, tx); return uPlanner.executeDropIndex((DropIndexData) obj, tx); } else throw new UnsupportedOperationException(); }
[ "public", "int", "executeUpdate", "(", "String", "cmd", ",", "Transaction", "tx", ")", "{", "if", "(", "tx", ".", "isReadOnly", "(", ")", ")", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "Parser", "parser", "=", "new", "Parser", "(", "cmd", ")", ";", "Object", "obj", "=", "parser", ".", "updateCommand", "(", ")", ";", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "InsertData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyInsertData", "(", "(", "InsertData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeInsert", "(", "(", "InsertData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "DeleteData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyDeleteData", "(", "(", "DeleteData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeDelete", "(", "(", "DeleteData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "ModifyData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyModifyData", "(", "(", "ModifyData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeModify", "(", "(", "ModifyData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "CreateTableData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyCreateTableData", "(", "(", "CreateTableData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeCreateTable", "(", "(", "CreateTableData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "CreateViewData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyCreateViewData", "(", "(", "CreateViewData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeCreateView", "(", "(", "CreateViewData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "CreateIndexData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyCreateIndexData", "(", "(", "CreateIndexData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeCreateIndex", "(", "(", "CreateIndexData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "DropTableData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyDropTableData", "(", "(", "DropTableData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeDropTable", "(", "(", "DropTableData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "DropViewData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyDropViewData", "(", "(", "DropViewData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeDropView", "(", "(", "DropViewData", ")", "obj", ",", "tx", ")", ";", "}", "else", "if", "(", "obj", ".", "getClass", "(", ")", ".", "equals", "(", "DropIndexData", ".", "class", ")", ")", "{", "Verifier", ".", "verifyDropIndexData", "(", "(", "DropIndexData", ")", "obj", ",", "tx", ")", ";", "return", "uPlanner", ".", "executeDropIndex", "(", "(", "DropIndexData", ")", "obj", ",", "tx", ")", ";", "}", "else", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}" ]
Executes an SQL insert, delete, modify, or create statement. The method dispatches to the appropriate method of the supplied update planner, depending on what the parser returns. @param cmd the SQL update string @param tx the transaction @return an integer denoting the number of affected records
[ "Executes", "an", "SQL", "insert", "delete", "modify", "or", "create", "statement", ".", "The", "method", "dispatches", "to", "the", "appropriate", "method", "of", "the", "supplied", "update", "planner", "depending", "on", "what", "the", "parser", "returns", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/Planner.java#L73-L107
139,810
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/Schema.java
Schema.addField
public void addField(String fldName, Type type) { fields.put(fldName, type); if (myFieldSet != null) myFieldSet.add(fldName); }
java
public void addField(String fldName, Type type) { fields.put(fldName, type); if (myFieldSet != null) myFieldSet.add(fldName); }
[ "public", "void", "addField", "(", "String", "fldName", ",", "Type", "type", ")", "{", "fields", ".", "put", "(", "fldName", ",", "type", ")", ";", "if", "(", "myFieldSet", "!=", "null", ")", "myFieldSet", ".", "add", "(", "fldName", ")", ";", "}" ]
Adds a field to this schema having a specified name and type. @param fldName the name of the field @param type the type of the field, according to the constants in {@link Type}
[ "Adds", "a", "field", "to", "this", "schema", "having", "a", "specified", "name", "and", "type", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/Schema.java#L55-L59
139,811
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/Schema.java
Schema.add
public void add(String fldName, Schema sch) { Type type = sch.type(fldName); addField(fldName, type); }
java
public void add(String fldName, Schema sch) { Type type = sch.type(fldName); addField(fldName, type); }
[ "public", "void", "add", "(", "String", "fldName", ",", "Schema", "sch", ")", "{", "Type", "type", "=", "sch", ".", "type", "(", "fldName", ")", ";", "addField", "(", "fldName", ",", "type", ")", ";", "}" ]
Adds a field in another schema having the specified name to this schema. @param fldName the name of the field @param sch the other schema
[ "Adds", "a", "field", "in", "another", "schema", "having", "the", "specified", "name", "to", "this", "schema", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/Schema.java#L69-L72
139,812
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/Schema.java
Schema.addAll
public void addAll(Schema sch) { fields.putAll(sch.fields); if (myFieldSet != null) myFieldSet = new TreeSet<String>(fields.keySet()); }
java
public void addAll(Schema sch) { fields.putAll(sch.fields); if (myFieldSet != null) myFieldSet = new TreeSet<String>(fields.keySet()); }
[ "public", "void", "addAll", "(", "Schema", "sch", ")", "{", "fields", ".", "putAll", "(", "sch", ".", "fields", ")", ";", "if", "(", "myFieldSet", "!=", "null", ")", "myFieldSet", "=", "new", "TreeSet", "<", "String", ">", "(", "fields", ".", "keySet", "(", ")", ")", ";", "}" ]
Adds all of the fields in the specified schema to this schema. @param sch the other schema
[ "Adds", "all", "of", "the", "fields", "in", "the", "specified", "schema", "to", "this", "schema", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/Schema.java#L80-L84
139,813
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/Schema.java
Schema.fields
public SortedSet<String> fields() { // Optimization: Materialize the fields set if (myFieldSet == null) myFieldSet = new TreeSet<String>(fields.keySet()); return myFieldSet; }
java
public SortedSet<String> fields() { // Optimization: Materialize the fields set if (myFieldSet == null) myFieldSet = new TreeSet<String>(fields.keySet()); return myFieldSet; }
[ "public", "SortedSet", "<", "String", ">", "fields", "(", ")", "{", "// Optimization: Materialize the fields set\r", "if", "(", "myFieldSet", "==", "null", ")", "myFieldSet", "=", "new", "TreeSet", "<", "String", ">", "(", "fields", ".", "keySet", "(", ")", ")", ";", "return", "myFieldSet", ";", "}" ]
Returns a sorted set containing the field names in this schema, sorted by their natural ordering. @return the sorted set of the schema's field names
[ "Returns", "a", "sorted", "set", "containing", "the", "field", "names", "in", "this", "schema", "sorted", "by", "their", "natural", "ordering", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/Schema.java#L92-L97
139,814
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/index/IndexJoinPlan.java
IndexJoinPlan.open
@Override public Scan open() { Scan s = p1.open(); // throws an exception if p2 is not a tableplan TableScan ts = (TableScan) tp2.open(); Index idx = ii.open(tx); return new IndexJoinScan(s, idx, joinFields, ts); }
java
@Override public Scan open() { Scan s = p1.open(); // throws an exception if p2 is not a tableplan TableScan ts = (TableScan) tp2.open(); Index idx = ii.open(tx); return new IndexJoinScan(s, idx, joinFields, ts); }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "Scan", "s", "=", "p1", ".", "open", "(", ")", ";", "// throws an exception if p2 is not a tableplan\r", "TableScan", "ts", "=", "(", "TableScan", ")", "tp2", ".", "open", "(", ")", ";", "Index", "idx", "=", "ii", ".", "open", "(", "tx", ")", ";", "return", "new", "IndexJoinScan", "(", "s", ",", "idx", ",", "joinFields", ",", "ts", ")", ";", "}" ]
Opens an index-join scan for this query @see Plan#open()
[ "Opens", "an", "index", "-", "join", "scan", "for", "this", "query" ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/index/IndexJoinPlan.java#L82-L89
139,815
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/index/IndexSelectPlan.java
IndexSelectPlan.open
@Override public Scan open() { // throws an exception if p is not a tableplan. TableScan ts = (TableScan) tp.open(); Index idx = ii.open(tx); return new IndexSelectScan(idx, new SearchRange(ii.fieldNames(), schema(), searchRanges), ts); }
java
@Override public Scan open() { // throws an exception if p is not a tableplan. TableScan ts = (TableScan) tp.open(); Index idx = ii.open(tx); return new IndexSelectScan(idx, new SearchRange(ii.fieldNames(), schema(), searchRanges), ts); }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "// throws an exception if p is not a tableplan.\r", "TableScan", "ts", "=", "(", "TableScan", ")", "tp", ".", "open", "(", ")", ";", "Index", "idx", "=", "ii", ".", "open", "(", "tx", ")", ";", "return", "new", "IndexSelectScan", "(", "idx", ",", "new", "SearchRange", "(", "ii", ".", "fieldNames", "(", ")", ",", "schema", "(", ")", ",", "searchRanges", ")", ",", "ts", ")", ";", "}" ]
Creates a new index-select scan for this query @see Plan#open()
[ "Creates", "a", "new", "index", "-", "select", "scan", "for", "this", "query" ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/index/IndexSelectPlan.java#L72-L79
139,816
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/index/IndexSelectPlan.java
IndexSelectPlan.blocksAccessed
@Override public long blocksAccessed() { return Index.searchCost(ii.indexType(), new SearchKeyType(schema(), ii.fieldNames()), tp.recordsOutput(), recordsOutput()) + recordsOutput(); }
java
@Override public long blocksAccessed() { return Index.searchCost(ii.indexType(), new SearchKeyType(schema(), ii.fieldNames()), tp.recordsOutput(), recordsOutput()) + recordsOutput(); }
[ "@", "Override", "public", "long", "blocksAccessed", "(", ")", "{", "return", "Index", ".", "searchCost", "(", "ii", ".", "indexType", "(", ")", ",", "new", "SearchKeyType", "(", "schema", "(", ")", ",", "ii", ".", "fieldNames", "(", ")", ")", ",", "tp", ".", "recordsOutput", "(", ")", ",", "recordsOutput", "(", ")", ")", "+", "recordsOutput", "(", ")", ";", "}" ]
Estimates the number of block accesses to compute the index selection, which is the same as the index traversal cost plus the number of matching data records. @see Plan#blocksAccessed()
[ "Estimates", "the", "number", "of", "block", "accesses", "to", "compute", "the", "index", "selection", "which", "is", "the", "same", "as", "the", "index", "traversal", "cost", "plus", "the", "number", "of", "matching", "data", "records", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/index/IndexSelectPlan.java#L88-L92
139,817
vanilladb/vanillacore
src/main/java/org/vanilladb/core/server/VanillaDb.java
VanillaDb.init
public static void init(String dirName, StoredProcedureFactory factory) { if (inited) { if (logger.isLoggable(Level.WARNING)) logger.warning("discarding duplicated init request"); return; } // Set the stored procedure factory spFactory = factory; /* * Note: We read properties file here before, but we moved it to a * utility class, PropertiesFetcher, for safety reason. */ // read classes queryPlannerCls = CoreProperties.getLoader().getPropertyAsClass( VanillaDb.class.getName() + ".QUERYPLANNER", HeuristicQueryPlanner.class, QueryPlanner.class); updatePlannerCls = CoreProperties.getLoader().getPropertyAsClass( VanillaDb.class.getName() + ".UPDATEPLANNER", IndexUpdatePlanner.class, UpdatePlanner.class); // initialize storage engine initFileAndLogMgr(dirName); initTaskMgr(); initTxMgr(); // the first transaction for initializing the system Transaction initTx = txMgr.newTransaction( Connection.TRANSACTION_SERIALIZABLE, false); /* * initialize the catalog manager to ensure the recovery process can get * the index info (required for index logical recovery) */ boolean isDbNew = fileMgr.isNew(); initCatalogMgr(isDbNew, initTx); if (isDbNew) { if (logger.isLoggable(Level.INFO)) logger.info("creating new database..."); } else { if (logger.isLoggable(Level.INFO)) logger.info("recovering existing database"); // add a checkpoint record to limit rollback RecoveryMgr.initializeSystem(initTx); } // initialize the statistics manager to build the histogram initStatMgr(initTx); // create a checkpoint txMgr.createCheckpoint(initTx); // commit the initializing transaction initTx.commit(); // initializing checkpointing task boolean doCheckpointing = CoreProperties.getLoader().getPropertyAsBoolean( VanillaDb.class.getName() + ".DO_CHECKPOINT", true); if (doCheckpointing) initCheckpointingTask(); // finish initialization inited = true; }
java
public static void init(String dirName, StoredProcedureFactory factory) { if (inited) { if (logger.isLoggable(Level.WARNING)) logger.warning("discarding duplicated init request"); return; } // Set the stored procedure factory spFactory = factory; /* * Note: We read properties file here before, but we moved it to a * utility class, PropertiesFetcher, for safety reason. */ // read classes queryPlannerCls = CoreProperties.getLoader().getPropertyAsClass( VanillaDb.class.getName() + ".QUERYPLANNER", HeuristicQueryPlanner.class, QueryPlanner.class); updatePlannerCls = CoreProperties.getLoader().getPropertyAsClass( VanillaDb.class.getName() + ".UPDATEPLANNER", IndexUpdatePlanner.class, UpdatePlanner.class); // initialize storage engine initFileAndLogMgr(dirName); initTaskMgr(); initTxMgr(); // the first transaction for initializing the system Transaction initTx = txMgr.newTransaction( Connection.TRANSACTION_SERIALIZABLE, false); /* * initialize the catalog manager to ensure the recovery process can get * the index info (required for index logical recovery) */ boolean isDbNew = fileMgr.isNew(); initCatalogMgr(isDbNew, initTx); if (isDbNew) { if (logger.isLoggable(Level.INFO)) logger.info("creating new database..."); } else { if (logger.isLoggable(Level.INFO)) logger.info("recovering existing database"); // add a checkpoint record to limit rollback RecoveryMgr.initializeSystem(initTx); } // initialize the statistics manager to build the histogram initStatMgr(initTx); // create a checkpoint txMgr.createCheckpoint(initTx); // commit the initializing transaction initTx.commit(); // initializing checkpointing task boolean doCheckpointing = CoreProperties.getLoader().getPropertyAsBoolean( VanillaDb.class.getName() + ".DO_CHECKPOINT", true); if (doCheckpointing) initCheckpointingTask(); // finish initialization inited = true; }
[ "public", "static", "void", "init", "(", "String", "dirName", ",", "StoredProcedureFactory", "factory", ")", "{", "if", "(", "inited", ")", "{", "if", "(", "logger", ".", "isLoggable", "(", "Level", ".", "WARNING", ")", ")", "logger", ".", "warning", "(", "\"discarding duplicated init request\"", ")", ";", "return", ";", "}", "// Set the stored procedure factory\r", "spFactory", "=", "factory", ";", "/*\r\n\t\t * Note: We read properties file here before, but we moved it to a\r\n\t\t * utility class, PropertiesFetcher, for safety reason.\r\n\t\t */", "// read classes\r", "queryPlannerCls", "=", "CoreProperties", ".", "getLoader", "(", ")", ".", "getPropertyAsClass", "(", "VanillaDb", ".", "class", ".", "getName", "(", ")", "+", "\".QUERYPLANNER\"", ",", "HeuristicQueryPlanner", ".", "class", ",", "QueryPlanner", ".", "class", ")", ";", "updatePlannerCls", "=", "CoreProperties", ".", "getLoader", "(", ")", ".", "getPropertyAsClass", "(", "VanillaDb", ".", "class", ".", "getName", "(", ")", "+", "\".UPDATEPLANNER\"", ",", "IndexUpdatePlanner", ".", "class", ",", "UpdatePlanner", ".", "class", ")", ";", "// initialize storage engine\r", "initFileAndLogMgr", "(", "dirName", ")", ";", "initTaskMgr", "(", ")", ";", "initTxMgr", "(", ")", ";", "// the first transaction for initializing the system\r", "Transaction", "initTx", "=", "txMgr", ".", "newTransaction", "(", "Connection", ".", "TRANSACTION_SERIALIZABLE", ",", "false", ")", ";", "/*\r\n\t\t * initialize the catalog manager to ensure the recovery process can get\r\n\t\t * the index info (required for index logical recovery)\r\n\t\t */", "boolean", "isDbNew", "=", "fileMgr", ".", "isNew", "(", ")", ";", "initCatalogMgr", "(", "isDbNew", ",", "initTx", ")", ";", "if", "(", "isDbNew", ")", "{", "if", "(", "logger", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "logger", ".", "info", "(", "\"creating new database...\"", ")", ";", "}", "else", "{", "if", "(", "logger", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "logger", ".", "info", "(", "\"recovering existing database\"", ")", ";", "// add a checkpoint record to limit rollback\r", "RecoveryMgr", ".", "initializeSystem", "(", "initTx", ")", ";", "}", "// initialize the statistics manager to build the histogram\r", "initStatMgr", "(", "initTx", ")", ";", "// create a checkpoint\r", "txMgr", ".", "createCheckpoint", "(", "initTx", ")", ";", "// commit the initializing transaction\r", "initTx", ".", "commit", "(", ")", ";", "// initializing checkpointing task\r", "boolean", "doCheckpointing", "=", "CoreProperties", ".", "getLoader", "(", ")", ".", "getPropertyAsBoolean", "(", "VanillaDb", ".", "class", ".", "getName", "(", ")", "+", "\".DO_CHECKPOINT\"", ",", "true", ")", ";", "if", "(", "doCheckpointing", ")", "initCheckpointingTask", "(", ")", ";", "// finish initialization\r", "inited", "=", "true", ";", "}" ]
Initializes the system. This method is called during system startup. @param dirName the name of the database directory @param factory the stored procedure factory for generating stored procedures
[ "Initializes", "the", "system", ".", "This", "method", "is", "called", "during", "system", "startup", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/server/VanillaDb.java#L100-L166
139,818
vanilladb/vanillacore
src/main/java/org/vanilladb/core/server/VanillaDb.java
VanillaDb.newPlanner
public static Planner newPlanner() { QueryPlanner qplanner; UpdatePlanner uplanner; try { qplanner = (QueryPlanner) queryPlannerCls.newInstance(); uplanner = (UpdatePlanner) updatePlannerCls.newInstance(); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); return null; } return new Planner(qplanner, uplanner); }
java
public static Planner newPlanner() { QueryPlanner qplanner; UpdatePlanner uplanner; try { qplanner = (QueryPlanner) queryPlannerCls.newInstance(); uplanner = (UpdatePlanner) updatePlannerCls.newInstance(); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); return null; } return new Planner(qplanner, uplanner); }
[ "public", "static", "Planner", "newPlanner", "(", ")", "{", "QueryPlanner", "qplanner", ";", "UpdatePlanner", "uplanner", ";", "try", "{", "qplanner", "=", "(", "QueryPlanner", ")", "queryPlannerCls", ".", "newInstance", "(", ")", ";", "uplanner", "=", "(", "UpdatePlanner", ")", "updatePlannerCls", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "InstantiationException", "|", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "return", "new", "Planner", "(", "qplanner", ",", "uplanner", ")", ";", "}" ]
Creates a planner for SQL commands. To change how the planner works, modify this method. @return the system's planner for SQL commands
[ "Creates", "a", "planner", "for", "SQL", "commands", ".", "To", "change", "how", "the", "planner", "works", "modify", "this", "method", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/server/VanillaDb.java#L283-L296
139,819
vanilladb/vanillacore
src/main/java/org/vanilladb/core/server/VanillaDb.java
VanillaDb.stopProfilerAndReport
public static void stopProfilerAndReport() { profiler.stopCollecting(); // Write a report file try { // Get path from property file String path = CoreProperties.getLoader().getPropertyAsString( VanillaDb.class.getName() + ".PROFILE_OUTPUT_DIR", System.getProperty("user.home")); File out = new File(path, System.currentTimeMillis() + "_profile.txt"); FileWriter wrFile = new FileWriter(out); BufferedWriter bwrFile = new BufferedWriter(wrFile); // Write Profiling Report bwrFile.write(profiler.getTopPackages(30)); bwrFile.newLine(); bwrFile.write(profiler.getTopMethods(30)); bwrFile.newLine(); bwrFile.write(profiler.getTopLines(30)); /* * I should write a more careful code here. I didn't do it, because * of the same reason above. */ bwrFile.close(); } catch (IOException e) { e.printStackTrace(); } }
java
public static void stopProfilerAndReport() { profiler.stopCollecting(); // Write a report file try { // Get path from property file String path = CoreProperties.getLoader().getPropertyAsString( VanillaDb.class.getName() + ".PROFILE_OUTPUT_DIR", System.getProperty("user.home")); File out = new File(path, System.currentTimeMillis() + "_profile.txt"); FileWriter wrFile = new FileWriter(out); BufferedWriter bwrFile = new BufferedWriter(wrFile); // Write Profiling Report bwrFile.write(profiler.getTopPackages(30)); bwrFile.newLine(); bwrFile.write(profiler.getTopMethods(30)); bwrFile.newLine(); bwrFile.write(profiler.getTopLines(30)); /* * I should write a more careful code here. I didn't do it, because * of the same reason above. */ bwrFile.close(); } catch (IOException e) { e.printStackTrace(); } }
[ "public", "static", "void", "stopProfilerAndReport", "(", ")", "{", "profiler", ".", "stopCollecting", "(", ")", ";", "// Write a report file\r", "try", "{", "// Get path from property file\r", "String", "path", "=", "CoreProperties", ".", "getLoader", "(", ")", ".", "getPropertyAsString", "(", "VanillaDb", ".", "class", ".", "getName", "(", ")", "+", "\".PROFILE_OUTPUT_DIR\"", ",", "System", ".", "getProperty", "(", "\"user.home\"", ")", ")", ";", "File", "out", "=", "new", "File", "(", "path", ",", "System", ".", "currentTimeMillis", "(", ")", "+", "\"_profile.txt\"", ")", ";", "FileWriter", "wrFile", "=", "new", "FileWriter", "(", "out", ")", ";", "BufferedWriter", "bwrFile", "=", "new", "BufferedWriter", "(", "wrFile", ")", ";", "// Write Profiling Report\r", "bwrFile", ".", "write", "(", "profiler", ".", "getTopPackages", "(", "30", ")", ")", ";", "bwrFile", ".", "newLine", "(", ")", ";", "bwrFile", ".", "write", "(", "profiler", ".", "getTopMethods", "(", "30", ")", ")", ";", "bwrFile", ".", "newLine", "(", ")", ";", "bwrFile", ".", "write", "(", "profiler", ".", "getTopLines", "(", "30", ")", ")", ";", "/*\r\n\t\t\t * I should write a more careful code here. I didn't do it, because\r\n\t\t\t * of the same reason above.\r\n\t\t\t */", "bwrFile", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Stop profiler and generate report file.
[ "Stop", "profiler", "and", "generate", "report", "file", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/server/VanillaDb.java#L309-L338
139,820
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/file/FileMgr.java
FileMgr.read
void read(BlockId blk, IoBuffer buffer) { try { IoChannel fileChannel = getFileChannel(blk.fileName()); // clear the buffer buffer.clear(); // read a block from file fileChannel.read(buffer, blk.number() * BLOCK_SIZE); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("cannot read block " + blk); } }
java
void read(BlockId blk, IoBuffer buffer) { try { IoChannel fileChannel = getFileChannel(blk.fileName()); // clear the buffer buffer.clear(); // read a block from file fileChannel.read(buffer, blk.number() * BLOCK_SIZE); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("cannot read block " + blk); } }
[ "void", "read", "(", "BlockId", "blk", ",", "IoBuffer", "buffer", ")", "{", "try", "{", "IoChannel", "fileChannel", "=", "getFileChannel", "(", "blk", ".", "fileName", "(", ")", ")", ";", "// clear the buffer\r", "buffer", ".", "clear", "(", ")", ";", "// read a block from file\r", "fileChannel", ".", "read", "(", "buffer", ",", "blk", ".", "number", "(", ")", "*", "BLOCK_SIZE", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "\"cannot read block \"", "+", "blk", ")", ";", "}", "}" ]
Reads the contents of a disk block into a byte buffer. @param blk a block ID @param buffer the byte buffer
[ "Reads", "the", "contents", "of", "a", "disk", "block", "into", "a", "byte", "buffer", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/file/FileMgr.java#L137-L150
139,821
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/file/FileMgr.java
FileMgr.write
void write(BlockId blk, IoBuffer buffer) { try { IoChannel fileChannel = getFileChannel(blk.fileName()); // rewind the buffer buffer.rewind(); // write the block to the file fileChannel.write(buffer, blk.number() * BLOCK_SIZE); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("cannot write block" + blk); } }
java
void write(BlockId blk, IoBuffer buffer) { try { IoChannel fileChannel = getFileChannel(blk.fileName()); // rewind the buffer buffer.rewind(); // write the block to the file fileChannel.write(buffer, blk.number() * BLOCK_SIZE); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("cannot write block" + blk); } }
[ "void", "write", "(", "BlockId", "blk", ",", "IoBuffer", "buffer", ")", "{", "try", "{", "IoChannel", "fileChannel", "=", "getFileChannel", "(", "blk", ".", "fileName", "(", ")", ")", ";", "// rewind the buffer\r", "buffer", ".", "rewind", "(", ")", ";", "// write the block to the file\r", "fileChannel", ".", "write", "(", "buffer", ",", "blk", ".", "number", "(", ")", "*", "BLOCK_SIZE", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "\"cannot write block\"", "+", "blk", ")", ";", "}", "}" ]
Writes the contents of a byte buffer into a disk block. @param blk a block ID @param buffer the byte buffer
[ "Writes", "the", "contents", "of", "a", "byte", "buffer", "into", "a", "disk", "block", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/file/FileMgr.java#L160-L173
139,822
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/file/FileMgr.java
FileMgr.append
BlockId append(String fileName, IoBuffer buffer) { try { IoChannel fileChannel = getFileChannel(fileName); // Rewind the buffer for writing buffer.rewind(); // Append the block to the file long newSize = fileChannel.append(buffer); // Return the new block id return new BlockId(fileName, newSize / BLOCK_SIZE - 1); } catch (IOException e) { e.printStackTrace(); return null; } }
java
BlockId append(String fileName, IoBuffer buffer) { try { IoChannel fileChannel = getFileChannel(fileName); // Rewind the buffer for writing buffer.rewind(); // Append the block to the file long newSize = fileChannel.append(buffer); // Return the new block id return new BlockId(fileName, newSize / BLOCK_SIZE - 1); } catch (IOException e) { e.printStackTrace(); return null; } }
[ "BlockId", "append", "(", "String", "fileName", ",", "IoBuffer", "buffer", ")", "{", "try", "{", "IoChannel", "fileChannel", "=", "getFileChannel", "(", "fileName", ")", ";", "// Rewind the buffer for writing\r", "buffer", ".", "rewind", "(", ")", ";", "// Append the block to the file\r", "long", "newSize", "=", "fileChannel", ".", "append", "(", "buffer", ")", ";", "// Return the new block id\r", "return", "new", "BlockId", "(", "fileName", ",", "newSize", "/", "BLOCK_SIZE", "-", "1", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Appends the contents of a byte buffer to the end of the specified file. @param fileName the name of the file @param buffer the byte buffer @return a block ID refers to the newly-created block.
[ "Appends", "the", "contents", "of", "a", "byte", "buffer", "to", "the", "end", "of", "the", "specified", "file", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/file/FileMgr.java#L184-L201
139,823
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/file/FileMgr.java
FileMgr.size
public long size(String fileName) { try { IoChannel fileChannel = getFileChannel(fileName); return fileChannel.size() / BLOCK_SIZE; } catch (IOException e) { throw new RuntimeException("cannot access " + fileName); } }
java
public long size(String fileName) { try { IoChannel fileChannel = getFileChannel(fileName); return fileChannel.size() / BLOCK_SIZE; } catch (IOException e) { throw new RuntimeException("cannot access " + fileName); } }
[ "public", "long", "size", "(", "String", "fileName", ")", "{", "try", "{", "IoChannel", "fileChannel", "=", "getFileChannel", "(", "fileName", ")", ";", "return", "fileChannel", ".", "size", "(", ")", "/", "BLOCK_SIZE", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"cannot access \"", "+", "fileName", ")", ";", "}", "}" ]
Returns the number of blocks in the specified file. @param fileName the name of the file @return the number of blocks in the file
[ "Returns", "the", "number", "of", "blocks", "in", "the", "specified", "file", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/file/FileMgr.java#L211-L218
139,824
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/file/FileMgr.java
FileMgr.getFileChannel
private IoChannel getFileChannel(String fileName) throws IOException { synchronized (prepareAnchor(fileName)) { IoChannel fileChannel = openFiles.get(fileName); if (fileChannel == null) { File dbFile = fileName.equals(DEFAULT_LOG_FILE) ? new File(logDirectory, fileName) : new File(dbDirectory, fileName); fileChannel = IoAllocator.newIoChannel(dbFile); openFiles.put(fileName, fileChannel); } return fileChannel; } }
java
private IoChannel getFileChannel(String fileName) throws IOException { synchronized (prepareAnchor(fileName)) { IoChannel fileChannel = openFiles.get(fileName); if (fileChannel == null) { File dbFile = fileName.equals(DEFAULT_LOG_FILE) ? new File(logDirectory, fileName) : new File(dbDirectory, fileName); fileChannel = IoAllocator.newIoChannel(dbFile); openFiles.put(fileName, fileChannel); } return fileChannel; } }
[ "private", "IoChannel", "getFileChannel", "(", "String", "fileName", ")", "throws", "IOException", "{", "synchronized", "(", "prepareAnchor", "(", "fileName", ")", ")", "{", "IoChannel", "fileChannel", "=", "openFiles", ".", "get", "(", "fileName", ")", ";", "if", "(", "fileChannel", "==", "null", ")", "{", "File", "dbFile", "=", "fileName", ".", "equals", "(", "DEFAULT_LOG_FILE", ")", "?", "new", "File", "(", "logDirectory", ",", "fileName", ")", ":", "new", "File", "(", "dbDirectory", ",", "fileName", ")", ";", "fileChannel", "=", "IoAllocator", ".", "newIoChannel", "(", "dbFile", ")", ";", "openFiles", ".", "put", "(", "fileName", ",", "fileChannel", ")", ";", "}", "return", "fileChannel", ";", "}", "}" ]
Returns the file channel for the specified filename. The file channel is stored in a map keyed on the filename. If the file is not open, then it is opened and the file channel is added to the map. @param fileName the specified filename @return the file channel associated with the open file. @throws IOException
[ "Returns", "the", "file", "channel", "for", "the", "specified", "filename", ".", "The", "file", "channel", "is", "stored", "in", "a", "map", "keyed", "on", "the", "filename", ".", "If", "the", "file", "is", "not", "open", "then", "it", "is", "opened", "and", "the", "file", "channel", "is", "added", "to", "the", "map", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/file/FileMgr.java#L241-L255
139,825
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/ProductPlan.java
ProductPlan.productHistogram
public static Histogram productHistogram(Histogram hist1, Histogram hist2) { Set<String> prodFlds = new HashSet<String>(hist1.fields()); prodFlds.addAll(hist2.fields()); Histogram prodHist = new Histogram(prodFlds); double numRec1 = hist1.recordsOutput(); double numRec2 = hist2.recordsOutput(); if (Double.compare(numRec1, 1.0) < 0 || Double.compare(numRec2, 1.0) < 0) return prodHist; for (String fld : hist1.fields()) for (Bucket bkt : hist1.buckets(fld)) prodHist.addBucket(fld, new Bucket(bkt.valueRange(), bkt.frequency() * numRec2, bkt.distinctValues(), bkt.valuePercentiles())); for (String fld : hist2.fields()) for (Bucket bkt : hist2.buckets(fld)) prodHist.addBucket(fld, new Bucket(bkt.valueRange(), bkt.frequency() * numRec1, bkt.distinctValues(), bkt.valuePercentiles())); return prodHist; }
java
public static Histogram productHistogram(Histogram hist1, Histogram hist2) { Set<String> prodFlds = new HashSet<String>(hist1.fields()); prodFlds.addAll(hist2.fields()); Histogram prodHist = new Histogram(prodFlds); double numRec1 = hist1.recordsOutput(); double numRec2 = hist2.recordsOutput(); if (Double.compare(numRec1, 1.0) < 0 || Double.compare(numRec2, 1.0) < 0) return prodHist; for (String fld : hist1.fields()) for (Bucket bkt : hist1.buckets(fld)) prodHist.addBucket(fld, new Bucket(bkt.valueRange(), bkt.frequency() * numRec2, bkt.distinctValues(), bkt.valuePercentiles())); for (String fld : hist2.fields()) for (Bucket bkt : hist2.buckets(fld)) prodHist.addBucket(fld, new Bucket(bkt.valueRange(), bkt.frequency() * numRec1, bkt.distinctValues(), bkt.valuePercentiles())); return prodHist; }
[ "public", "static", "Histogram", "productHistogram", "(", "Histogram", "hist1", ",", "Histogram", "hist2", ")", "{", "Set", "<", "String", ">", "prodFlds", "=", "new", "HashSet", "<", "String", ">", "(", "hist1", ".", "fields", "(", ")", ")", ";", "prodFlds", ".", "addAll", "(", "hist2", ".", "fields", "(", ")", ")", ";", "Histogram", "prodHist", "=", "new", "Histogram", "(", "prodFlds", ")", ";", "double", "numRec1", "=", "hist1", ".", "recordsOutput", "(", ")", ";", "double", "numRec2", "=", "hist2", ".", "recordsOutput", "(", ")", ";", "if", "(", "Double", ".", "compare", "(", "numRec1", ",", "1.0", ")", "<", "0", "||", "Double", ".", "compare", "(", "numRec2", ",", "1.0", ")", "<", "0", ")", "return", "prodHist", ";", "for", "(", "String", "fld", ":", "hist1", ".", "fields", "(", ")", ")", "for", "(", "Bucket", "bkt", ":", "hist1", ".", "buckets", "(", "fld", ")", ")", "prodHist", ".", "addBucket", "(", "fld", ",", "new", "Bucket", "(", "bkt", ".", "valueRange", "(", ")", ",", "bkt", ".", "frequency", "(", ")", "*", "numRec2", ",", "bkt", ".", "distinctValues", "(", ")", ",", "bkt", ".", "valuePercentiles", "(", ")", ")", ")", ";", "for", "(", "String", "fld", ":", "hist2", ".", "fields", "(", ")", ")", "for", "(", "Bucket", "bkt", ":", "hist2", ".", "buckets", "(", "fld", ")", ")", "prodHist", ".", "addBucket", "(", "fld", ",", "new", "Bucket", "(", "bkt", ".", "valueRange", "(", ")", ",", "bkt", ".", "frequency", "(", ")", "*", "numRec1", ",", "bkt", ".", "distinctValues", "(", ")", ",", "bkt", ".", "valuePercentiles", "(", ")", ")", ")", ";", "return", "prodHist", ";", "}" ]
Returns a histogram that, for each field, approximates the value distribution of products from the specified histograms. @param hist1 the left-hand-side histogram @param hist2 the right-hand-side histogram @return a histogram that, for each field, approximates the value distribution of the products
[ "Returns", "a", "histogram", "that", "for", "each", "field", "approximates", "the", "value", "distribution", "of", "products", "from", "the", "specified", "histograms", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/ProductPlan.java#L41-L61
139,826
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/ProductPlan.java
ProductPlan.open
@Override public Scan open() { Scan s1 = p1.open(); Scan s2 = p2.open(); return new ProductScan(s1, s2); }
java
@Override public Scan open() { Scan s1 = p1.open(); Scan s2 = p2.open(); return new ProductScan(s1, s2); }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "Scan", "s1", "=", "p1", ".", "open", "(", ")", ";", "Scan", "s2", "=", "p2", ".", "open", "(", ")", ";", "return", "new", "ProductScan", "(", "s1", ",", "s2", ")", ";", "}" ]
Creates a product scan for this query. @see Plan#open()
[ "Creates", "a", "product", "scan", "for", "this", "query", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/ProductPlan.java#L89-L94
139,827
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/index/IndexSelectScan.java
IndexSelectScan.next
@Override public boolean next() { boolean ok = idx.next(); if (ok) { RecordId rid = idx.getDataRecordId(); ts.moveToRecordId(rid); } return ok; }
java
@Override public boolean next() { boolean ok = idx.next(); if (ok) { RecordId rid = idx.getDataRecordId(); ts.moveToRecordId(rid); } return ok; }
[ "@", "Override", "public", "boolean", "next", "(", ")", "{", "boolean", "ok", "=", "idx", ".", "next", "(", ")", ";", "if", "(", "ok", ")", "{", "RecordId", "rid", "=", "idx", ".", "getDataRecordId", "(", ")", ";", "ts", ".", "moveToRecordId", "(", "rid", ")", ";", "}", "return", "ok", ";", "}" ]
Moves to the next record, which in this case means moving the index to the next record satisfying the selection constant, and returning false if there are no more such index records. If there is a next record, the method moves the tablescan to the corresponding data record. @see Scan#next()
[ "Moves", "to", "the", "next", "record", "which", "in", "this", "case", "means", "moving", "the", "index", "to", "the", "next", "record", "satisfying", "the", "selection", "constant", "and", "returning", "false", "if", "there", "are", "no", "more", "such", "index", "records", ".", "If", "there", "is", "a", "next", "record", "the", "method", "moves", "the", "tablescan", "to", "the", "corresponding", "data", "record", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/index/IndexSelectScan.java#L71-L79
139,828
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java
SortScan.beforeFirst
@Override public void beforeFirst() { currentScan = null; s1.beforeFirst(); hasMore1 = s1.next(); if (s2 != null) { s2.beforeFirst(); hasMore2 = s2.next(); } }
java
@Override public void beforeFirst() { currentScan = null; s1.beforeFirst(); hasMore1 = s1.next(); if (s2 != null) { s2.beforeFirst(); hasMore2 = s2.next(); } }
[ "@", "Override", "public", "void", "beforeFirst", "(", ")", "{", "currentScan", "=", "null", ";", "s1", ".", "beforeFirst", "(", ")", ";", "hasMore1", "=", "s1", ".", "next", "(", ")", ";", "if", "(", "s2", "!=", "null", ")", "{", "s2", ".", "beforeFirst", "(", ")", ";", "hasMore2", "=", "s2", ".", "next", "(", ")", ";", "}", "}" ]
Positions the scan before the first record in sorted order. Internally, it moves to the first record of each underlying scan. The variable currentScan is set to null, indicating that there is no current scan. @see Scan#beforeFirst()
[ "Positions", "the", "scan", "before", "the", "first", "record", "in", "sorted", "order", ".", "Internally", "it", "moves", "to", "the", "first", "record", "of", "each", "underlying", "scan", ".", "The", "variable", "currentScan", "is", "set", "to", "null", "indicating", "that", "there", "is", "no", "current", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java#L65-L74
139,829
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java
SortScan.next
@Override public boolean next() { if (currentScan != null) { if (currentScan == s1) hasMore1 = s1.next(); else if (currentScan == s2) hasMore2 = s2.next(); } if (!hasMore1 && !hasMore2) return false; else if (hasMore1 && hasMore2) { // update currentScan currentScan = comp.compare(s1, s2) < 0 ? s1 : s2; } else if (hasMore1) currentScan = s1; else if (hasMore2) currentScan = s2; return true; }
java
@Override public boolean next() { if (currentScan != null) { if (currentScan == s1) hasMore1 = s1.next(); else if (currentScan == s2) hasMore2 = s2.next(); } if (!hasMore1 && !hasMore2) return false; else if (hasMore1 && hasMore2) { // update currentScan currentScan = comp.compare(s1, s2) < 0 ? s1 : s2; } else if (hasMore1) currentScan = s1; else if (hasMore2) currentScan = s2; return true; }
[ "@", "Override", "public", "boolean", "next", "(", ")", "{", "if", "(", "currentScan", "!=", "null", ")", "{", "if", "(", "currentScan", "==", "s1", ")", "hasMore1", "=", "s1", ".", "next", "(", ")", ";", "else", "if", "(", "currentScan", "==", "s2", ")", "hasMore2", "=", "s2", ".", "next", "(", ")", ";", "}", "if", "(", "!", "hasMore1", "&&", "!", "hasMore2", ")", "return", "false", ";", "else", "if", "(", "hasMore1", "&&", "hasMore2", ")", "{", "// update currentScan\r", "currentScan", "=", "comp", ".", "compare", "(", "s1", ",", "s2", ")", "<", "0", "?", "s1", ":", "s2", ";", "}", "else", "if", "(", "hasMore1", ")", "currentScan", "=", "s1", ";", "else", "if", "(", "hasMore2", ")", "currentScan", "=", "s2", ";", "return", "true", ";", "}" ]
Moves to the next record in sorted order. First, the current scan is moved to the next record. Then the lowest record of the two scans is found, and that scan is chosen to be the new current scan. @see Scan#next()
[ "Moves", "to", "the", "next", "record", "in", "sorted", "order", ".", "First", "the", "current", "scan", "is", "moved", "to", "the", "next", "record", ".", "Then", "the", "lowest", "record", "of", "the", "two", "scans", "is", "found", "and", "that", "scan", "is", "chosen", "to", "be", "the", "new", "current", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java#L83-L102
139,830
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java
SortScan.savePosition
public void savePosition() { RecordId rid1 = s1.getRecordId(); RecordId rid2 = (s2 == null) ? null : s2.getRecordId(); savedPosition = Arrays.asList(rid1, rid2); }
java
public void savePosition() { RecordId rid1 = s1.getRecordId(); RecordId rid2 = (s2 == null) ? null : s2.getRecordId(); savedPosition = Arrays.asList(rid1, rid2); }
[ "public", "void", "savePosition", "(", ")", "{", "RecordId", "rid1", "=", "s1", ".", "getRecordId", "(", ")", ";", "RecordId", "rid2", "=", "(", "s2", "==", "null", ")", "?", "null", ":", "s2", ".", "getRecordId", "(", ")", ";", "savedPosition", "=", "Arrays", ".", "asList", "(", "rid1", ",", "rid2", ")", ";", "}" ]
Saves the position of the current record, so that it can be restored at a later time.
[ "Saves", "the", "position", "of", "the", "current", "record", "so", "that", "it", "can", "be", "restored", "at", "a", "later", "time", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java#L140-L144
139,831
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java
SortScan.restorePosition
public void restorePosition() { RecordId rid1 = savedPosition.get(0); RecordId rid2 = savedPosition.get(1); s1.moveToRecordId(rid1); if (rid2 != null) s2.moveToRecordId(rid2); }
java
public void restorePosition() { RecordId rid1 = savedPosition.get(0); RecordId rid2 = savedPosition.get(1); s1.moveToRecordId(rid1); if (rid2 != null) s2.moveToRecordId(rid2); }
[ "public", "void", "restorePosition", "(", ")", "{", "RecordId", "rid1", "=", "savedPosition", ".", "get", "(", "0", ")", ";", "RecordId", "rid2", "=", "savedPosition", ".", "get", "(", "1", ")", ";", "s1", ".", "moveToRecordId", "(", "rid1", ")", ";", "if", "(", "rid2", "!=", "null", ")", "s2", ".", "moveToRecordId", "(", "rid2", ")", ";", "}" ]
Moves the scan to its previously-saved position.
[ "Moves", "the", "scan", "to", "its", "previously", "-", "saved", "position", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/SortScan.java#L149-L155
139,832
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/TransactionMgr.java
TransactionMgr.createCheckpoint
public void createCheckpoint(Transaction checkpointTx) { // stop access new tx request and find out active txs by using a write // lock on threadTxNums List<Long> txNums; // for (Transaction tx : activeTxs) // if (tx.getTransactionNumber() != checkpointTx // .getTransactionNumber()) // txNums.add(tx.getTransactionNumber()); // activeTxsLock.writeLock().lock(); // try { // for (Long l : threadTxNums) { // if (l >= 0) { // txNums.add(l); // } // } // // // flush all buffers // // CT : Pick a tx and call its bufferMgr flushAll, or get // // bufferPoolMgr (init it at VanillaDb) // checkpointTx.bufferMgr().flushAll(); // // wrtie a checkpoint record and flush to disk // LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums); // VanillaDb.logMgr().flush(lsn); // System.out.println("Chkpnt :" + txNums); // } finally { // activeTxsLock.writeLock().unlock(); // } // Old method synchronized (this) { txNums = new LinkedList<Long>(activeTxs); checkpointTx.bufferMgr().flushAll(); LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums); VanillaDb.logMgr().flush(lsn); } }
java
public void createCheckpoint(Transaction checkpointTx) { // stop access new tx request and find out active txs by using a write // lock on threadTxNums List<Long> txNums; // for (Transaction tx : activeTxs) // if (tx.getTransactionNumber() != checkpointTx // .getTransactionNumber()) // txNums.add(tx.getTransactionNumber()); // activeTxsLock.writeLock().lock(); // try { // for (Long l : threadTxNums) { // if (l >= 0) { // txNums.add(l); // } // } // // // flush all buffers // // CT : Pick a tx and call its bufferMgr flushAll, or get // // bufferPoolMgr (init it at VanillaDb) // checkpointTx.bufferMgr().flushAll(); // // wrtie a checkpoint record and flush to disk // LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums); // VanillaDb.logMgr().flush(lsn); // System.out.println("Chkpnt :" + txNums); // } finally { // activeTxsLock.writeLock().unlock(); // } // Old method synchronized (this) { txNums = new LinkedList<Long>(activeTxs); checkpointTx.bufferMgr().flushAll(); LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums); VanillaDb.logMgr().flush(lsn); } }
[ "public", "void", "createCheckpoint", "(", "Transaction", "checkpointTx", ")", "{", "// stop access new tx request and find out active txs by using a write\r", "// lock on threadTxNums\r", "List", "<", "Long", ">", "txNums", ";", "// for (Transaction tx : activeTxs)\r", "// if (tx.getTransactionNumber() != checkpointTx\r", "// .getTransactionNumber())\r", "// txNums.add(tx.getTransactionNumber());\r", "// activeTxsLock.writeLock().lock();\r", "// try {\r", "// for (Long l : threadTxNums) {\r", "// if (l >= 0) {\r", "// txNums.add(l);\r", "// }\r", "// }\r", "//\r", "// // flush all buffers\r", "// // CT : Pick a tx and call its bufferMgr flushAll, or get\r", "// // bufferPoolMgr (init it at VanillaDb)\r", "// checkpointTx.bufferMgr().flushAll();\r", "// // wrtie a checkpoint record and flush to disk\r", "// LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums);\r", "// VanillaDb.logMgr().flush(lsn);\r", "// System.out.println(\"Chkpnt :\" + txNums);\r", "// } finally {\r", "// activeTxsLock.writeLock().unlock();\r", "// }\r", "// Old method\r", "synchronized", "(", "this", ")", "{", "txNums", "=", "new", "LinkedList", "<", "Long", ">", "(", "activeTxs", ")", ";", "checkpointTx", ".", "bufferMgr", "(", ")", ".", "flushAll", "(", ")", ";", "LogSeqNum", "lsn", "=", "checkpointTx", ".", "recoveryMgr", "(", ")", ".", "checkpoint", "(", "txNums", ")", ";", "VanillaDb", ".", "logMgr", "(", ")", ".", "flush", "(", "lsn", ")", ";", "}", "}" ]
Creates non-quiescent checkpoint record. @param checkpointTx the transaction that performs checkpointing
[ "Creates", "non", "-", "quiescent", "checkpoint", "record", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/TransactionMgr.java#L125-L161
139,833
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/planner/BasicQueryPlanner.java
BasicQueryPlanner.createPlan
@Override public Plan createPlan(QueryData data, Transaction tx) { // Step 1: Create a plan for each mentioned table or view List<Plan> plans = new ArrayList<Plan>(); for (String tblname : data.tables()) { String viewdef = VanillaDb.catalogMgr().getViewDef(tblname, tx); if (viewdef != null) plans.add(VanillaDb.newPlanner().createQueryPlan(viewdef, tx)); else plans.add(new TablePlan(tblname, tx)); } // Step 2: Create the product of all table plans Plan p = plans.remove(0); for (Plan nextplan : plans) p = new ProductPlan(p, nextplan); // Step 3: Add a selection plan for the predicate p = new SelectPlan(p, data.pred()); // Step 4: Add a group-by plan if specified if (data.groupFields() != null) { p = new GroupByPlan(p, data.groupFields(), data.aggregationFn(), tx); } // Step 5: Project onto the specified fields p = new ProjectPlan(p, data.projectFields()); // Step 6: Add a sort plan if specified if (data.sortFields() != null) p = new SortPlan(p, data.sortFields(), data.sortDirections(), tx); // Step 7: Add a explain plan if the query is explain statement if (data.isExplain()) p = new ExplainPlan(p); return p; }
java
@Override public Plan createPlan(QueryData data, Transaction tx) { // Step 1: Create a plan for each mentioned table or view List<Plan> plans = new ArrayList<Plan>(); for (String tblname : data.tables()) { String viewdef = VanillaDb.catalogMgr().getViewDef(tblname, tx); if (viewdef != null) plans.add(VanillaDb.newPlanner().createQueryPlan(viewdef, tx)); else plans.add(new TablePlan(tblname, tx)); } // Step 2: Create the product of all table plans Plan p = plans.remove(0); for (Plan nextplan : plans) p = new ProductPlan(p, nextplan); // Step 3: Add a selection plan for the predicate p = new SelectPlan(p, data.pred()); // Step 4: Add a group-by plan if specified if (data.groupFields() != null) { p = new GroupByPlan(p, data.groupFields(), data.aggregationFn(), tx); } // Step 5: Project onto the specified fields p = new ProjectPlan(p, data.projectFields()); // Step 6: Add a sort plan if specified if (data.sortFields() != null) p = new SortPlan(p, data.sortFields(), data.sortDirections(), tx); // Step 7: Add a explain plan if the query is explain statement if (data.isExplain()) p = new ExplainPlan(p); return p; }
[ "@", "Override", "public", "Plan", "createPlan", "(", "QueryData", "data", ",", "Transaction", "tx", ")", "{", "// Step 1: Create a plan for each mentioned table or view\r", "List", "<", "Plan", ">", "plans", "=", "new", "ArrayList", "<", "Plan", ">", "(", ")", ";", "for", "(", "String", "tblname", ":", "data", ".", "tables", "(", ")", ")", "{", "String", "viewdef", "=", "VanillaDb", ".", "catalogMgr", "(", ")", ".", "getViewDef", "(", "tblname", ",", "tx", ")", ";", "if", "(", "viewdef", "!=", "null", ")", "plans", ".", "add", "(", "VanillaDb", ".", "newPlanner", "(", ")", ".", "createQueryPlan", "(", "viewdef", ",", "tx", ")", ")", ";", "else", "plans", ".", "add", "(", "new", "TablePlan", "(", "tblname", ",", "tx", ")", ")", ";", "}", "// Step 2: Create the product of all table plans\r", "Plan", "p", "=", "plans", ".", "remove", "(", "0", ")", ";", "for", "(", "Plan", "nextplan", ":", "plans", ")", "p", "=", "new", "ProductPlan", "(", "p", ",", "nextplan", ")", ";", "// Step 3: Add a selection plan for the predicate\r", "p", "=", "new", "SelectPlan", "(", "p", ",", "data", ".", "pred", "(", ")", ")", ";", "// Step 4: Add a group-by plan if specified\r", "if", "(", "data", ".", "groupFields", "(", ")", "!=", "null", ")", "{", "p", "=", "new", "GroupByPlan", "(", "p", ",", "data", ".", "groupFields", "(", ")", ",", "data", ".", "aggregationFn", "(", ")", ",", "tx", ")", ";", "}", "// Step 5: Project onto the specified fields\r", "p", "=", "new", "ProjectPlan", "(", "p", ",", "data", ".", "projectFields", "(", ")", ")", ";", "// Step 6: Add a sort plan if specified\r", "if", "(", "data", ".", "sortFields", "(", ")", "!=", "null", ")", "p", "=", "new", "SortPlan", "(", "p", ",", "data", ".", "sortFields", "(", ")", ",", "data", ".", "sortDirections", "(", ")", ",", "tx", ")", ";", "// Step 7: Add a explain plan if the query is explain statement\r", "if", "(", "data", ".", "isExplain", "(", ")", ")", "p", "=", "new", "ExplainPlan", "(", "p", ")", ";", "return", "p", ";", "}" ]
Creates a query plan as follows. It first takes the product of all tables and views; it then selects on the predicate; and finally it projects on the field list.
[ "Creates", "a", "query", "plan", "as", "follows", ".", "It", "first", "takes", "the", "product", "of", "all", "tables", "and", "views", ";", "it", "then", "selects", "on", "the", "predicate", ";", "and", "finally", "it", "projects", "on", "the", "field", "list", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/BasicQueryPlanner.java#L43-L73
139,834
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/planner/opt/SelingerLikeQueryPlanner.java
SelingerLikeQueryPlanner.createPlan
@Override public Plan createPlan(QueryData data, Transaction tx) { // Step 1: Create a TablePlanner object for each mentioned table/view int id = 0; for (String tbl : data.tables()) { String viewdef = VanillaDb.catalogMgr().getViewDef(tbl, tx); if (viewdef != null) views.add(VanillaDb.newPlanner().createQueryPlan(viewdef, tx)); else { TablePlanner tp = new TablePlanner(tbl, data.pred(), tx, id); tablePlanners.add(tp); id += 1; } } // step 2: Use Selinger optimization to find join access path Plan trunk = getAccessPath(); // Step 3: Add a group by plan if specified if (data.groupFields() != null) trunk = new GroupByPlan(trunk, data.groupFields(), data.aggregationFn(), tx); // Step 4. Project on the field names trunk = new ProjectPlan(trunk, data.projectFields()); // Step 5: Add a sort plan if specified if (data.sortFields() != null) trunk = new SortPlan(trunk, data.sortFields(), data.sortDirections(), tx); // Step 6: Add a explain plan if the query is explain statement if (data.isExplain()) trunk = new ExplainPlan(trunk); return trunk; }
java
@Override public Plan createPlan(QueryData data, Transaction tx) { // Step 1: Create a TablePlanner object for each mentioned table/view int id = 0; for (String tbl : data.tables()) { String viewdef = VanillaDb.catalogMgr().getViewDef(tbl, tx); if (viewdef != null) views.add(VanillaDb.newPlanner().createQueryPlan(viewdef, tx)); else { TablePlanner tp = new TablePlanner(tbl, data.pred(), tx, id); tablePlanners.add(tp); id += 1; } } // step 2: Use Selinger optimization to find join access path Plan trunk = getAccessPath(); // Step 3: Add a group by plan if specified if (data.groupFields() != null) trunk = new GroupByPlan(trunk, data.groupFields(), data.aggregationFn(), tx); // Step 4. Project on the field names trunk = new ProjectPlan(trunk, data.projectFields()); // Step 5: Add a sort plan if specified if (data.sortFields() != null) trunk = new SortPlan(trunk, data.sortFields(), data.sortDirections(), tx); // Step 6: Add a explain plan if the query is explain statement if (data.isExplain()) trunk = new ExplainPlan(trunk); return trunk; }
[ "@", "Override", "public", "Plan", "createPlan", "(", "QueryData", "data", ",", "Transaction", "tx", ")", "{", "// Step 1: Create a TablePlanner object for each mentioned table/view\r", "int", "id", "=", "0", ";", "for", "(", "String", "tbl", ":", "data", ".", "tables", "(", ")", ")", "{", "String", "viewdef", "=", "VanillaDb", ".", "catalogMgr", "(", ")", ".", "getViewDef", "(", "tbl", ",", "tx", ")", ";", "if", "(", "viewdef", "!=", "null", ")", "views", ".", "add", "(", "VanillaDb", ".", "newPlanner", "(", ")", ".", "createQueryPlan", "(", "viewdef", ",", "tx", ")", ")", ";", "else", "{", "TablePlanner", "tp", "=", "new", "TablePlanner", "(", "tbl", ",", "data", ".", "pred", "(", ")", ",", "tx", ",", "id", ")", ";", "tablePlanners", ".", "add", "(", "tp", ")", ";", "id", "+=", "1", ";", "}", "}", "// step 2: Use Selinger optimization to find join access path\r", "Plan", "trunk", "=", "getAccessPath", "(", ")", ";", "// Step 3: Add a group by plan if specified\r", "if", "(", "data", ".", "groupFields", "(", ")", "!=", "null", ")", "trunk", "=", "new", "GroupByPlan", "(", "trunk", ",", "data", ".", "groupFields", "(", ")", ",", "data", ".", "aggregationFn", "(", ")", ",", "tx", ")", ";", "// Step 4. Project on the field names\r", "trunk", "=", "new", "ProjectPlan", "(", "trunk", ",", "data", ".", "projectFields", "(", ")", ")", ";", "// Step 5: Add a sort plan if specified\r", "if", "(", "data", ".", "sortFields", "(", ")", "!=", "null", ")", "trunk", "=", "new", "SortPlan", "(", "trunk", ",", "data", ".", "sortFields", "(", ")", ",", "data", ".", "sortDirections", "(", ")", ",", "tx", ")", ";", "// Step 6: Add a explain plan if the query is explain statement\r", "if", "(", "data", ".", "isExplain", "(", ")", ")", "trunk", "=", "new", "ExplainPlan", "(", "trunk", ")", ";", "return", "trunk", ";", "}" ]
Creates a left-deep query plan using the Selinger optimization. Main idea is to find all permutation of table join order and to choose the cheapest plan. However, all permutation can be too much for us to go through all. So we use DP and left-deep only to optimize this process.
[ "Creates", "a", "left", "-", "deep", "query", "plan", "using", "the", "Selinger", "optimization", ".", "Main", "idea", "is", "to", "find", "all", "permutation", "of", "table", "join", "order", "and", "to", "choose", "the", "cheapest", "plan", ".", "However", "all", "permutation", "can", "be", "too", "much", "for", "us", "to", "go", "through", "all", ".", "So", "we", "use", "DP", "and", "left", "-", "deep", "only", "to", "optimize", "this", "process", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/opt/SelingerLikeQueryPlanner.java#L48-L78
139,835
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTPageFormatter.java
BTPageFormatter.format
@Override public void format(Buffer buf) { int pos = 0; // initial the number of records as 0 setVal(buf, pos, Constant.defaultInstance(INTEGER)); int flagSize = Page.maxSize(BIGINT); pos += Page.maxSize(INTEGER); // set flags for (int i = 0; i < flags.length; i++) { setVal(buf, pos, new BigIntConstant(flags[i])); pos += flagSize; } int slotSize = BTreePage.slotSize(sch); for (int p = pos; p + slotSize <= Buffer.BUFFER_SIZE; p += slotSize) makeDefaultRecord(buf, p); }
java
@Override public void format(Buffer buf) { int pos = 0; // initial the number of records as 0 setVal(buf, pos, Constant.defaultInstance(INTEGER)); int flagSize = Page.maxSize(BIGINT); pos += Page.maxSize(INTEGER); // set flags for (int i = 0; i < flags.length; i++) { setVal(buf, pos, new BigIntConstant(flags[i])); pos += flagSize; } int slotSize = BTreePage.slotSize(sch); for (int p = pos; p + slotSize <= Buffer.BUFFER_SIZE; p += slotSize) makeDefaultRecord(buf, p); }
[ "@", "Override", "public", "void", "format", "(", "Buffer", "buf", ")", "{", "int", "pos", "=", "0", ";", "// initial the number of records as 0\r", "setVal", "(", "buf", ",", "pos", ",", "Constant", ".", "defaultInstance", "(", "INTEGER", ")", ")", ";", "int", "flagSize", "=", "Page", ".", "maxSize", "(", "BIGINT", ")", ";", "pos", "+=", "Page", ".", "maxSize", "(", "INTEGER", ")", ";", "// set flags\r", "for", "(", "int", "i", "=", "0", ";", "i", "<", "flags", ".", "length", ";", "i", "++", ")", "{", "setVal", "(", "buf", ",", "pos", ",", "new", "BigIntConstant", "(", "flags", "[", "i", "]", ")", ")", ";", "pos", "+=", "flagSize", ";", "}", "int", "slotSize", "=", "BTreePage", ".", "slotSize", "(", "sch", ")", ";", "for", "(", "int", "p", "=", "pos", ";", "p", "+", "slotSize", "<=", "Buffer", ".", "BUFFER_SIZE", ";", "p", "+=", "slotSize", ")", "makeDefaultRecord", "(", "buf", ",", "p", ")", ";", "}" ]
Formats the page by initializing as many index-record slots as possible to have default values. @see PageFormatter#format(Buffer)
[ "Formats", "the", "page", "by", "initializing", "as", "many", "index", "-", "record", "slots", "as", "possible", "to", "have", "default", "values", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTPageFormatter.java#L60-L75
139,836
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/Transaction.java
Transaction.rollback
public void rollback() { for (TransactionLifecycleListener l : lifecycleListeners) { l.onTxRollback(this); } if (logger.isLoggable(Level.FINE)) logger.fine("transaction " + txNum + " rolled back"); }
java
public void rollback() { for (TransactionLifecycleListener l : lifecycleListeners) { l.onTxRollback(this); } if (logger.isLoggable(Level.FINE)) logger.fine("transaction " + txNum + " rolled back"); }
[ "public", "void", "rollback", "(", ")", "{", "for", "(", "TransactionLifecycleListener", "l", ":", "lifecycleListeners", ")", "{", "l", ".", "onTxRollback", "(", "this", ")", ";", "}", "if", "(", "logger", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "logger", ".", "fine", "(", "\"transaction \"", "+", "txNum", "+", "\" rolled back\"", ")", ";", "}" ]
Rolls back the current transaction. Undoes any modified values, flushes those blocks, writes and flushes a rollback record to the log, releases all locks, and unpins any pinned blocks.
[ "Rolls", "back", "the", "current", "transaction", ".", "Undoes", "any", "modified", "values", "flushes", "those", "blocks", "writes", "and", "flushes", "a", "rollback", "record", "to", "the", "log", "releases", "all", "locks", "and", "unpins", "any", "pinned", "blocks", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/Transaction.java#L116-L124
139,837
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/TableScan.java
TableScan.setVal
@Override public void setVal(String fldName, Constant val) { rf.setVal(fldName, val); }
java
@Override public void setVal(String fldName, Constant val) { rf.setVal(fldName, val); }
[ "@", "Override", "public", "void", "setVal", "(", "String", "fldName", ",", "Constant", "val", ")", "{", "rf", ".", "setVal", "(", "fldName", ",", "val", ")", ";", "}" ]
Sets the value of the specified field, as a Constant. @param val the constant to be set. Will be casted to the correct type specified in the schema of the table. @see UpdateScan#setVal(java.lang.String, Constant)
[ "Sets", "the", "value", "of", "the", "specified", "field", "as", "a", "Constant", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/TableScan.java#L90-L93
139,838
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/MergeJoinPlan.java
MergeJoinPlan.open
@Override public Scan open() { SortScan ss1 = (SortScan) sp1.open(); SortScan ss2 = (SortScan) sp2.open(); return new MergeJoinScan(ss1, ss2, fldName1, fldName2); }
java
@Override public Scan open() { SortScan ss1 = (SortScan) sp1.open(); SortScan ss2 = (SortScan) sp2.open(); return new MergeJoinScan(ss1, ss2, fldName1, fldName2); }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "SortScan", "ss1", "=", "(", "SortScan", ")", "sp1", ".", "open", "(", ")", ";", "SortScan", "ss2", "=", "(", "SortScan", ")", "sp2", ".", "open", "(", ")", ";", "return", "new", "MergeJoinScan", "(", "ss1", ",", "ss2", ",", "fldName1", ",", "fldName2", ")", ";", "}" ]
The method first sorts its two underlying scans on their join field. It then returns a mergejoin scan of the two sorted table scans. @see Plan#open()
[ "The", "method", "first", "sorts", "its", "two", "underlying", "scans", "on", "their", "join", "field", ".", "It", "then", "returns", "a", "mergejoin", "scan", "of", "the", "two", "sorted", "table", "scans", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/MergeJoinPlan.java#L74-L79
139,839
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/record/RecordFormatter.java
RecordFormatter.format
@Override public void format(Buffer buf) { int slotSize = RecordPage.slotSize(ti.schema()); Constant emptyFlag = new IntegerConstant(EMPTY); for (int pos = 0; pos + slotSize <= Buffer.BUFFER_SIZE; pos += slotSize) { setVal(buf, pos, emptyFlag); makeDefaultRecord(buf, pos); } }
java
@Override public void format(Buffer buf) { int slotSize = RecordPage.slotSize(ti.schema()); Constant emptyFlag = new IntegerConstant(EMPTY); for (int pos = 0; pos + slotSize <= Buffer.BUFFER_SIZE; pos += slotSize) { setVal(buf, pos, emptyFlag); makeDefaultRecord(buf, pos); } }
[ "@", "Override", "public", "void", "format", "(", "Buffer", "buf", ")", "{", "int", "slotSize", "=", "RecordPage", ".", "slotSize", "(", "ti", ".", "schema", "(", ")", ")", ";", "Constant", "emptyFlag", "=", "new", "IntegerConstant", "(", "EMPTY", ")", ";", "for", "(", "int", "pos", "=", "0", ";", "pos", "+", "slotSize", "<=", "Buffer", ".", "BUFFER_SIZE", ";", "pos", "+=", "slotSize", ")", "{", "setVal", "(", "buf", ",", "pos", ",", "emptyFlag", ")", ";", "makeDefaultRecord", "(", "buf", ",", "pos", ")", ";", "}", "}" ]
Formats the page by allocating as many record slots as possible, given the record size. Each record slot is assigned a flag of EMPTY. Each numeric field is given a value of 0, and each string field is given a value of "". @see org.vanilladb.core.storage.buffer.PageFormatter#format(org.vanilladb.core.storage.buffer.Buffer)
[ "Formats", "the", "page", "by", "allocating", "as", "many", "record", "slots", "as", "possible", "given", "the", "record", "size", ".", "Each", "record", "slot", "is", "assigned", "a", "flag", "of", "EMPTY", ".", "Each", "numeric", "field", "is", "given", "a", "value", "of", "0", "and", "each", "string", "field", "is", "given", "a", "value", "of", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/record/RecordFormatter.java#L58-L66
139,840
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/log/LogMgr.java
LogMgr.flush
public void flush(LogSeqNum lsn) { logMgrLock.lock(); try { if (lsn.compareTo(lastFlushedLsn) >= 0) flush(); } finally { logMgrLock.unlock(); } }
java
public void flush(LogSeqNum lsn) { logMgrLock.lock(); try { if (lsn.compareTo(lastFlushedLsn) >= 0) flush(); } finally { logMgrLock.unlock(); } }
[ "public", "void", "flush", "(", "LogSeqNum", "lsn", ")", "{", "logMgrLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "lsn", ".", "compareTo", "(", "lastFlushedLsn", ")", ">=", "0", ")", "flush", "(", ")", ";", "}", "finally", "{", "logMgrLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Ensures that the log records corresponding to the specified LSN has been written to disk. All earlier log records will also be written to disk. @param lsn the LSN of a log record
[ "Ensures", "that", "the", "log", "records", "corresponding", "to", "the", "specified", "LSN", "has", "been", "written", "to", "disk", ".", "All", "earlier", "log", "records", "will", "also", "be", "written", "to", "disk", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/log/LogMgr.java#L97-L105
139,841
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/log/LogMgr.java
LogMgr.iterator
@Override public ReversibleIterator<BasicLogRecord> iterator() { logMgrLock.lock(); try { flush(); return new LogIterator(currentBlk); } finally { logMgrLock.unlock(); } }
java
@Override public ReversibleIterator<BasicLogRecord> iterator() { logMgrLock.lock(); try { flush(); return new LogIterator(currentBlk); } finally { logMgrLock.unlock(); } }
[ "@", "Override", "public", "ReversibleIterator", "<", "BasicLogRecord", ">", "iterator", "(", ")", "{", "logMgrLock", ".", "lock", "(", ")", ";", "try", "{", "flush", "(", ")", ";", "return", "new", "LogIterator", "(", "currentBlk", ")", ";", "}", "finally", "{", "logMgrLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Returns an iterator for the log records, which will be returned in reverse order starting with the most recent. @see java.lang.Iterable#iterator()
[ "Returns", "an", "iterator", "for", "the", "log", "records", "which", "will", "be", "returned", "in", "reverse", "order", "starting", "with", "the", "most", "recent", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/log/LogMgr.java#L113-L122
139,842
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/log/LogMgr.java
LogMgr.append
public LogSeqNum append(Constant[] rec) { logMgrLock.lock(); try { // two integers that point to the previous and next log records int recsize = pointerSize * 2; for (Constant c : rec) recsize += Page.size(c); // if the log record doesn't fit, move to the next block if (currentPos + recsize >= BLOCK_SIZE) { flush(); appendNewBlock(); } // Get the current LSN LogSeqNum lsn = currentLSN(); // Append a record for (Constant c : rec) appendVal(c); finalizeRecord(); // Remember this LSN lastLsn = lsn; return lsn; } finally { logMgrLock.unlock(); } }
java
public LogSeqNum append(Constant[] rec) { logMgrLock.lock(); try { // two integers that point to the previous and next log records int recsize = pointerSize * 2; for (Constant c : rec) recsize += Page.size(c); // if the log record doesn't fit, move to the next block if (currentPos + recsize >= BLOCK_SIZE) { flush(); appendNewBlock(); } // Get the current LSN LogSeqNum lsn = currentLSN(); // Append a record for (Constant c : rec) appendVal(c); finalizeRecord(); // Remember this LSN lastLsn = lsn; return lsn; } finally { logMgrLock.unlock(); } }
[ "public", "LogSeqNum", "append", "(", "Constant", "[", "]", "rec", ")", "{", "logMgrLock", ".", "lock", "(", ")", ";", "try", "{", "// two integers that point to the previous and next log records\r", "int", "recsize", "=", "pointerSize", "*", "2", ";", "for", "(", "Constant", "c", ":", "rec", ")", "recsize", "+=", "Page", ".", "size", "(", ")", ";", "// if the log record doesn't fit, move to the next block\r", "if", "(", "currentPos", "+", "recsize", ">=", "BLOCK_SIZE", ")", "{", "flush", "(", ")", ";", "appendNewBlock", "(", ")", ";", "}", "// Get the current LSN\r", "LogSeqNum", "lsn", "=", "currentLSN", "(", ")", ";", "// Append a record\r", "for", "(", "Constant", "c", ":", "rec", ")", "appendVal", "(", ")", ";", "finalizeRecord", "(", ")", ";", "// Remember this LSN\r", "lastLsn", "=", "lsn", ";", "return", "lsn", ";", "}", "finally", "{", "logMgrLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Appends a log record to the file. The record contains an arbitrary array of values. The method also writes an integer to the end of each log record whose value is the offset of the corresponding integer for the previous log record. These integers allow log records to be read in reverse order. @param rec the list of values @return the LSN of the log record
[ "Appends", "a", "log", "record", "to", "the", "file", ".", "The", "record", "contains", "an", "arbitrary", "array", "of", "values", ".", "The", "method", "also", "writes", "an", "integer", "to", "the", "end", "of", "each", "log", "record", "whose", "value", "is", "the", "offset", "of", "the", "corresponding", "integer", "for", "the", "previous", "log", "record", ".", "These", "integers", "allow", "log", "records", "to", "be", "read", "in", "reverse", "order", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/log/LogMgr.java#L135-L164
139,843
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/log/LogMgr.java
LogMgr.removeAndCreateNewLog
public void removeAndCreateNewLog() { logMgrLock.lock(); try { VanillaDb.fileMgr().delete(logFile); // Reset all the data lastLsn = LogSeqNum.DEFAULT_VALUE; lastFlushedLsn = LogSeqNum.DEFAULT_VALUE; // 'myPage', 'currentBlk' and 'currentPos' are reset in this method appendNewBlock(); } finally { logMgrLock.unlock(); } }
java
public void removeAndCreateNewLog() { logMgrLock.lock(); try { VanillaDb.fileMgr().delete(logFile); // Reset all the data lastLsn = LogSeqNum.DEFAULT_VALUE; lastFlushedLsn = LogSeqNum.DEFAULT_VALUE; // 'myPage', 'currentBlk' and 'currentPos' are reset in this method appendNewBlock(); } finally { logMgrLock.unlock(); } }
[ "public", "void", "removeAndCreateNewLog", "(", ")", "{", "logMgrLock", ".", "lock", "(", ")", ";", "try", "{", "VanillaDb", ".", "fileMgr", "(", ")", ".", "delete", "(", "logFile", ")", ";", "// Reset all the data\r", "lastLsn", "=", "LogSeqNum", ".", "DEFAULT_VALUE", ";", "lastFlushedLsn", "=", "LogSeqNum", ".", "DEFAULT_VALUE", ";", "// 'myPage', 'currentBlk' and 'currentPos' are reset in this method\r", "appendNewBlock", "(", ")", ";", "}", "finally", "{", "logMgrLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Remove the old log file and create a new one.
[ "Remove", "the", "old", "log", "file", "and", "create", "a", "new", "one", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/log/LogMgr.java#L169-L183
139,844
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/log/LogMgr.java
LogMgr.appendVal
private void appendVal(Constant val) { myPage.setVal(currentPos, val); currentPos += Page.size(val); }
java
private void appendVal(Constant val) { myPage.setVal(currentPos, val); currentPos += Page.size(val); }
[ "private", "void", "appendVal", "(", "Constant", "val", ")", "{", "myPage", ".", "setVal", "(", "currentPos", ",", "val", ")", ";", "currentPos", "+=", "Page", ".", "size", "(", "val", ")", ";", "}" ]
Adds the specified value to the page at the position denoted by currentPos. Then increments currentPos by the size of the value. @param val the value to be added to the page
[ "Adds", "the", "specified", "value", "to", "the", "page", "at", "the", "position", "denoted", "by", "currentPos", ".", "Then", "increments", "currentPos", "by", "the", "size", "of", "the", "value", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/log/LogMgr.java#L192-L195
139,845
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/log/LogMgr.java
LogMgr.finalizeRecord
private void finalizeRecord() { myPage.setVal(currentPos, new IntegerConstant(getLastRecordPosition())); setPreviousNextRecordPosition(currentPos + pointerSize); setLastRecordPosition(currentPos); currentPos += pointerSize; setNextRecordPosition(currentPos); // leave for next pointer currentPos += pointerSize; }
java
private void finalizeRecord() { myPage.setVal(currentPos, new IntegerConstant(getLastRecordPosition())); setPreviousNextRecordPosition(currentPos + pointerSize); setLastRecordPosition(currentPos); currentPos += pointerSize; setNextRecordPosition(currentPos); // leave for next pointer currentPos += pointerSize; }
[ "private", "void", "finalizeRecord", "(", ")", "{", "myPage", ".", "setVal", "(", "currentPos", ",", "new", "IntegerConstant", "(", "getLastRecordPosition", "(", ")", ")", ")", ";", "setPreviousNextRecordPosition", "(", "currentPos", "+", "pointerSize", ")", ";", "setLastRecordPosition", "(", "currentPos", ")", ";", "currentPos", "+=", "pointerSize", ";", "setNextRecordPosition", "(", "currentPos", ")", ";", "// leave for next pointer\r", "currentPos", "+=", "pointerSize", ";", "}" ]
Sets up a circular chain of pointers to the records in the page. There is an integer added to the end of each log record whose value is the offset of the previous log record. The first four bytes of the page contain an integer whose value is the offset of the integer for the last log record in the page.
[ "Sets", "up", "a", "circular", "chain", "of", "pointers", "to", "the", "records", "in", "the", "page", ".", "There", "is", "an", "integer", "added", "to", "the", "end", "of", "each", "log", "record", "whose", "value", "is", "the", "offset", "of", "the", "previous", "log", "record", ".", "The", "first", "four", "bytes", "of", "the", "page", "contain", "an", "integer", "whose", "value", "is", "the", "offset", "of", "the", "integer", "for", "the", "last", "log", "record", "in", "the", "page", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/log/LogMgr.java#L231-L240
139,846
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/MaterializePlan.java
MaterializePlan.open
@Override public Scan open() { Schema sch = p.schema(); TempTable temp = new TempTable(sch, tx); Scan src = p.open(); UpdateScan dest = temp.open(); src.beforeFirst(); while (src.next()) { dest.insert(); for (String fldname : sch.fields()) dest.setVal(fldname, src.getVal(fldname)); } src.close(); dest.beforeFirst(); return dest; }
java
@Override public Scan open() { Schema sch = p.schema(); TempTable temp = new TempTable(sch, tx); Scan src = p.open(); UpdateScan dest = temp.open(); src.beforeFirst(); while (src.next()) { dest.insert(); for (String fldname : sch.fields()) dest.setVal(fldname, src.getVal(fldname)); } src.close(); dest.beforeFirst(); return dest; }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "Schema", "sch", "=", "p", ".", "schema", "(", ")", ";", "TempTable", "temp", "=", "new", "TempTable", "(", "sch", ",", "tx", ")", ";", "Scan", "src", "=", "p", ".", "open", "(", ")", ";", "UpdateScan", "dest", "=", "temp", ".", "open", "(", ")", ";", "src", ".", "beforeFirst", "(", ")", ";", "while", "(", "src", ".", "next", "(", ")", ")", "{", "dest", ".", "insert", "(", ")", ";", "for", "(", "String", "fldname", ":", "sch", ".", "fields", "(", ")", ")", "dest", ".", "setVal", "(", "fldname", ",", "src", ".", "getVal", "(", "fldname", ")", ")", ";", "}", "src", ".", "close", "(", ")", ";", "dest", ".", "beforeFirst", "(", ")", ";", "return", "dest", ";", "}" ]
This method loops through the underlying query, copying its output records into a temporary table. It then returns a table scan for that table. @see Plan#open()
[ "This", "method", "loops", "through", "the", "underlying", "query", "copying", "its", "output", "records", "into", "a", "temporary", "table", ".", "It", "then", "returns", "a", "table", "scan", "for", "that", "table", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/MaterializePlan.java#L54-L69
139,847
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java
HashIndex.schema
private static Schema schema(SearchKeyType keyType) { Schema sch = new Schema(); for (int i = 0; i < keyType.length(); i++) sch.addField(keyFieldName(i), keyType.get(i)); sch.addField(SCHEMA_RID_BLOCK, BIGINT); sch.addField(SCHEMA_RID_ID, INTEGER); return sch; }
java
private static Schema schema(SearchKeyType keyType) { Schema sch = new Schema(); for (int i = 0; i < keyType.length(); i++) sch.addField(keyFieldName(i), keyType.get(i)); sch.addField(SCHEMA_RID_BLOCK, BIGINT); sch.addField(SCHEMA_RID_ID, INTEGER); return sch; }
[ "private", "static", "Schema", "schema", "(", "SearchKeyType", "keyType", ")", "{", "Schema", "sch", "=", "new", "Schema", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "keyType", ".", "length", "(", ")", ";", "i", "++", ")", "sch", ".", "addField", "(", "keyFieldName", "(", "i", ")", ",", "keyType", ".", "get", "(", "i", ")", ")", ";", "sch", ".", "addField", "(", "SCHEMA_RID_BLOCK", ",", "BIGINT", ")", ";", "sch", ".", "addField", "(", "SCHEMA_RID_ID", ",", "INTEGER", ")", ";", "return", "sch", ";", "}" ]
Returns the schema of the index records. @param fldType the type of the indexed field @return the schema of the index records
[ "Returns", "the", "schema", "of", "the", "index", "records", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java#L76-L83
139,848
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java
HashIndex.getDataRecordId
@Override public RecordId getDataRecordId() { long blkNum = (Long) rf.getVal(SCHEMA_RID_BLOCK).asJavaVal(); int id = (Integer) rf.getVal(SCHEMA_RID_ID).asJavaVal(); return new RecordId(new BlockId(dataFileName, blkNum), id); }
java
@Override public RecordId getDataRecordId() { long blkNum = (Long) rf.getVal(SCHEMA_RID_BLOCK).asJavaVal(); int id = (Integer) rf.getVal(SCHEMA_RID_ID).asJavaVal(); return new RecordId(new BlockId(dataFileName, blkNum), id); }
[ "@", "Override", "public", "RecordId", "getDataRecordId", "(", ")", "{", "long", "blkNum", "=", "(", "Long", ")", "rf", ".", "getVal", "(", "SCHEMA_RID_BLOCK", ")", ".", "asJavaVal", "(", ")", ";", "int", "id", "=", "(", "Integer", ")", "rf", ".", "getVal", "(", "SCHEMA_RID_ID", ")", ".", "asJavaVal", "(", ")", ";", "return", "new", "RecordId", "(", "new", "BlockId", "(", "dataFileName", ",", "blkNum", ")", ",", "id", ")", ";", "}" ]
Retrieves the data record ID from the current index record. @see Index#getDataRecordId()
[ "Retrieves", "the", "data", "record", "ID", "from", "the", "current", "index", "record", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java#L162-L167
139,849
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java
HashIndex.insert
@Override public void insert(SearchKey key, RecordId dataRecordId, boolean doLogicalLogging) { // search the position beforeFirst(new SearchRange(key)); // log the logical operation starts if (doLogicalLogging) tx.recoveryMgr().logLogicalStart(); // insert the data rf.insert(); for (int i = 0; i < keyType.length(); i++) rf.setVal(keyFieldName(i), key.get(i)); rf.setVal(SCHEMA_RID_BLOCK, new BigIntConstant(dataRecordId.block() .number())); rf.setVal(SCHEMA_RID_ID, new IntegerConstant(dataRecordId.id())); // log the logical operation ends if (doLogicalLogging) tx.recoveryMgr().logIndexInsertionEnd(ii.indexName(), key, dataRecordId.block().number(), dataRecordId.id()); }
java
@Override public void insert(SearchKey key, RecordId dataRecordId, boolean doLogicalLogging) { // search the position beforeFirst(new SearchRange(key)); // log the logical operation starts if (doLogicalLogging) tx.recoveryMgr().logLogicalStart(); // insert the data rf.insert(); for (int i = 0; i < keyType.length(); i++) rf.setVal(keyFieldName(i), key.get(i)); rf.setVal(SCHEMA_RID_BLOCK, new BigIntConstant(dataRecordId.block() .number())); rf.setVal(SCHEMA_RID_ID, new IntegerConstant(dataRecordId.id())); // log the logical operation ends if (doLogicalLogging) tx.recoveryMgr().logIndexInsertionEnd(ii.indexName(), key, dataRecordId.block().number(), dataRecordId.id()); }
[ "@", "Override", "public", "void", "insert", "(", "SearchKey", "key", ",", "RecordId", "dataRecordId", ",", "boolean", "doLogicalLogging", ")", "{", "// search the position\r", "beforeFirst", "(", "new", "SearchRange", "(", "key", ")", ")", ";", "// log the logical operation starts\r", "if", "(", "doLogicalLogging", ")", "tx", ".", "recoveryMgr", "(", ")", ".", "logLogicalStart", "(", ")", ";", "// insert the data\r", "rf", ".", "insert", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "keyType", ".", "length", "(", ")", ";", "i", "++", ")", "rf", ".", "setVal", "(", "keyFieldName", "(", "i", ")", ",", "key", ".", "get", "(", "i", ")", ")", ";", "rf", ".", "setVal", "(", "SCHEMA_RID_BLOCK", ",", "new", "BigIntConstant", "(", "dataRecordId", ".", "block", "(", ")", ".", "number", "(", ")", ")", ")", ";", "rf", ".", "setVal", "(", "SCHEMA_RID_ID", ",", "new", "IntegerConstant", "(", "dataRecordId", ".", "id", "(", ")", ")", ")", ";", "// log the logical operation ends\r", "if", "(", "doLogicalLogging", ")", "tx", ".", "recoveryMgr", "(", ")", ".", "logIndexInsertionEnd", "(", "ii", ".", "indexName", "(", ")", ",", "key", ",", "dataRecordId", ".", "block", "(", ")", ".", "number", "(", ")", ",", "dataRecordId", ".", "id", "(", ")", ")", ";", "}" ]
Inserts a new index record into this index. @see Index#insert(SearchKey, RecordId, boolean)
[ "Inserts", "a", "new", "index", "record", "into", "this", "index", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java#L174-L195
139,850
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java
HashIndex.delete
@Override public void delete(SearchKey key, RecordId dataRecordId, boolean doLogicalLogging) { // search the position beforeFirst(new SearchRange(key)); // log the logical operation starts if (doLogicalLogging) tx.recoveryMgr().logLogicalStart(); // delete the specified entry while (next()) if (getDataRecordId().equals(dataRecordId)) { rf.delete(); return; } // log the logical operation ends if (doLogicalLogging) tx.recoveryMgr().logIndexDeletionEnd(ii.indexName(), key, dataRecordId.block().number(), dataRecordId.id()); }
java
@Override public void delete(SearchKey key, RecordId dataRecordId, boolean doLogicalLogging) { // search the position beforeFirst(new SearchRange(key)); // log the logical operation starts if (doLogicalLogging) tx.recoveryMgr().logLogicalStart(); // delete the specified entry while (next()) if (getDataRecordId().equals(dataRecordId)) { rf.delete(); return; } // log the logical operation ends if (doLogicalLogging) tx.recoveryMgr().logIndexDeletionEnd(ii.indexName(), key, dataRecordId.block().number(), dataRecordId.id()); }
[ "@", "Override", "public", "void", "delete", "(", "SearchKey", "key", ",", "RecordId", "dataRecordId", ",", "boolean", "doLogicalLogging", ")", "{", "// search the position\r", "beforeFirst", "(", "new", "SearchRange", "(", "key", ")", ")", ";", "// log the logical operation starts\r", "if", "(", "doLogicalLogging", ")", "tx", ".", "recoveryMgr", "(", ")", ".", "logLogicalStart", "(", ")", ";", "// delete the specified entry\r", "while", "(", "next", "(", ")", ")", "if", "(", "getDataRecordId", "(", ")", ".", "equals", "(", "dataRecordId", ")", ")", "{", "rf", ".", "delete", "(", ")", ";", "return", ";", "}", "// log the logical operation ends\r", "if", "(", "doLogicalLogging", ")", "tx", ".", "recoveryMgr", "(", ")", ".", "logIndexDeletionEnd", "(", "ii", ".", "indexName", "(", ")", ",", "key", ",", "dataRecordId", ".", "block", "(", ")", ".", "number", "(", ")", ",", "dataRecordId", ".", "id", "(", ")", ")", ";", "}" ]
Deletes the specified index record. @see Index#delete(SearchKey, RecordId, boolean)
[ "Deletes", "the", "specified", "index", "record", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/hash/HashIndex.java#L202-L222
139,851
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/multibuffer/MultiBufferProductScan.java
MultiBufferProductScan.next
@Override public boolean next() { if (prodScan == null) return false; while (!prodScan.next()) if (!useNextChunk()) return false; return true; }
java
@Override public boolean next() { if (prodScan == null) return false; while (!prodScan.next()) if (!useNextChunk()) return false; return true; }
[ "@", "Override", "public", "boolean", "next", "(", ")", "{", "if", "(", "prodScan", "==", "null", ")", "return", "false", ";", "while", "(", "!", "prodScan", ".", "next", "(", ")", ")", "if", "(", "!", "useNextChunk", "(", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Moves to the next record in the current scan. If there are no more records in the current chunk, then move to the next LHS record and the beginning of that chunk. If there are no more LHS records, then move to the next chunk and begin again. @see Scan#next()
[ "Moves", "to", "the", "next", "record", "in", "the", "current", "scan", ".", "If", "there", "are", "no", "more", "records", "in", "the", "current", "chunk", "then", "move", "to", "the", "next", "LHS", "record", "and", "the", "beginning", "of", "that", "chunk", ".", "If", "there", "are", "no", "more", "LHS", "records", "then", "move", "to", "the", "next", "chunk", "and", "begin", "again", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/multibuffer/MultiBufferProductScan.java#L75-L83
139,852
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeDir.java
BTreeDir.schema
static Schema schema(SearchKeyType keyType) { Schema sch = new Schema(); for (int i = 0; i < keyType.length(); i++) sch.addField(keyFieldName(i), keyType.get(i)); sch.addField(SCH_CHILD, BIGINT); return sch; }
java
static Schema schema(SearchKeyType keyType) { Schema sch = new Schema(); for (int i = 0; i < keyType.length(); i++) sch.addField(keyFieldName(i), keyType.get(i)); sch.addField(SCH_CHILD, BIGINT); return sch; }
[ "static", "Schema", "schema", "(", "SearchKeyType", "keyType", ")", "{", "Schema", "sch", "=", "new", "Schema", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "keyType", ".", "length", "(", ")", ";", "i", "++", ")", "sch", ".", "addField", "(", "keyFieldName", "(", "i", ")", ",", "keyType", ".", "get", "(", "i", ")", ")", ";", "sch", ".", "addField", "(", "SCH_CHILD", ",", "BIGINT", ")", ";", "return", "sch", ";", "}" ]
Returns the schema of the B-tree directory records. @param keyType the type of the indexed field @return the schema of the index records
[ "Returns", "the", "schema", "of", "the", "B", "-", "tree", "directory", "records", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeDir.java#L89-L95
139,853
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeDir.java
BTreeDir.search
public BlockId search(SearchKey searchKey, String leafFileName, SearchPurpose purpose) { if (purpose == SearchPurpose.READ) return searchForRead(searchKey, leafFileName); else if (purpose == SearchPurpose.INSERT) return searchForInsert(searchKey, leafFileName); else if (purpose == SearchPurpose.DELETE) return searchForDelete(searchKey, leafFileName); else throw new UnsupportedOperationException(); }
java
public BlockId search(SearchKey searchKey, String leafFileName, SearchPurpose purpose) { if (purpose == SearchPurpose.READ) return searchForRead(searchKey, leafFileName); else if (purpose == SearchPurpose.INSERT) return searchForInsert(searchKey, leafFileName); else if (purpose == SearchPurpose.DELETE) return searchForDelete(searchKey, leafFileName); else throw new UnsupportedOperationException(); }
[ "public", "BlockId", "search", "(", "SearchKey", "searchKey", ",", "String", "leafFileName", ",", "SearchPurpose", "purpose", ")", "{", "if", "(", "purpose", "==", "SearchPurpose", ".", "READ", ")", "return", "searchForRead", "(", "searchKey", ",", "leafFileName", ")", ";", "else", "if", "(", "purpose", "==", "SearchPurpose", ".", "INSERT", ")", "return", "searchForInsert", "(", "searchKey", ",", "leafFileName", ")", ";", "else", "if", "(", "purpose", "==", "SearchPurpose", ".", "DELETE", ")", "return", "searchForDelete", "(", "searchKey", ",", "leafFileName", ")", ";", "else", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}" ]
Returns the block number of the B-tree leaf block that contains the specified search key. @param searchKey the search key @param leafFileName the file name of the B-tree leaf file @param purpose the purpose of searching (defined in BTreeIndex) @return the BlockId of the leaf block containing that search key
[ "Returns", "the", "block", "number", "of", "the", "B", "-", "tree", "leaf", "block", "that", "contains", "the", "specified", "search", "key", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeDir.java#L162-L171
139,854
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeDir.java
BTreeDir.findSlotBefore
private int findSlotBefore(SearchKey searchKey) { /* * int slot = 0; while (slot < contents.getNumRecords() && * getKey(contents, slot).compareTo(searchKey) < 0) slot++; return slot * - 1; */ // Optimization: Use binary search rather than sequential search int startSlot = 0, endSlot = currentPage.getNumRecords() - 1; int middleSlot = (startSlot + endSlot) / 2; if (endSlot >= 0) { while (middleSlot != startSlot) { if (getKey(currentPage, middleSlot, keyType.length()) .compareTo(searchKey) < 0) startSlot = middleSlot; else endSlot = middleSlot; middleSlot = (startSlot + endSlot) / 2; } if (getKey(currentPage, endSlot, keyType.length()).compareTo(searchKey) < 0) return endSlot; else if (getKey(currentPage, startSlot, keyType.length()) .compareTo(searchKey) < 0) return startSlot; else return startSlot - 1; } else return -1; }
java
private int findSlotBefore(SearchKey searchKey) { /* * int slot = 0; while (slot < contents.getNumRecords() && * getKey(contents, slot).compareTo(searchKey) < 0) slot++; return slot * - 1; */ // Optimization: Use binary search rather than sequential search int startSlot = 0, endSlot = currentPage.getNumRecords() - 1; int middleSlot = (startSlot + endSlot) / 2; if (endSlot >= 0) { while (middleSlot != startSlot) { if (getKey(currentPage, middleSlot, keyType.length()) .compareTo(searchKey) < 0) startSlot = middleSlot; else endSlot = middleSlot; middleSlot = (startSlot + endSlot) / 2; } if (getKey(currentPage, endSlot, keyType.length()).compareTo(searchKey) < 0) return endSlot; else if (getKey(currentPage, startSlot, keyType.length()) .compareTo(searchKey) < 0) return startSlot; else return startSlot - 1; } else return -1; }
[ "private", "int", "findSlotBefore", "(", "SearchKey", "searchKey", ")", "{", "/*\r\n\t\t * int slot = 0; while (slot < contents.getNumRecords() &&\r\n\t\t * getKey(contents, slot).compareTo(searchKey) < 0) slot++; return slot\r\n\t\t * - 1;\r\n\t\t */", "// Optimization: Use binary search rather than sequential search\r", "int", "startSlot", "=", "0", ",", "endSlot", "=", "currentPage", ".", "getNumRecords", "(", ")", "-", "1", ";", "int", "middleSlot", "=", "(", "startSlot", "+", "endSlot", ")", "/", "2", ";", "if", "(", "endSlot", ">=", "0", ")", "{", "while", "(", "middleSlot", "!=", "startSlot", ")", "{", "if", "(", "getKey", "(", "currentPage", ",", "middleSlot", ",", "keyType", ".", "length", "(", ")", ")", ".", "compareTo", "(", "searchKey", ")", "<", "0", ")", "startSlot", "=", "middleSlot", ";", "else", "endSlot", "=", "middleSlot", ";", "middleSlot", "=", "(", "startSlot", "+", "endSlot", ")", "/", "2", ";", "}", "if", "(", "getKey", "(", "currentPage", ",", "endSlot", ",", "keyType", ".", "length", "(", ")", ")", ".", "compareTo", "(", "searchKey", ")", "<", "0", ")", "return", "endSlot", ";", "else", "if", "(", "getKey", "(", "currentPage", ",", "startSlot", ",", "keyType", ".", "length", "(", ")", ")", ".", "compareTo", "(", "searchKey", ")", "<", "0", ")", "return", "startSlot", ";", "else", "return", "startSlot", "-", "1", ";", "}", "else", "return", "-", "1", ";", "}" ]
Calculates the slot right before the one having the specified search key. @param searchKey the search key @return the position before where the search key goes
[ "Calculates", "the", "slot", "right", "before", "the", "one", "having", "the", "specified", "search", "key", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeDir.java#L333-L363
139,855
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/file/Page.java
Page.getVal
public synchronized Constant getVal(int offset, Type type) { int size; byte[] byteVal = null; // Check the length of bytes if (type.isFixedSize()) { size = type.maxSize(); } else { byteVal = new byte[ByteHelper.INT_SIZE]; contents.get(offset, byteVal); size = ByteHelper.toInteger(byteVal); offset += ByteHelper.INT_SIZE; } // Get bytes and translate it to Constant byteVal = new byte[size]; contents.get(offset, byteVal); return Constant.newInstance(type, byteVal); }
java
public synchronized Constant getVal(int offset, Type type) { int size; byte[] byteVal = null; // Check the length of bytes if (type.isFixedSize()) { size = type.maxSize(); } else { byteVal = new byte[ByteHelper.INT_SIZE]; contents.get(offset, byteVal); size = ByteHelper.toInteger(byteVal); offset += ByteHelper.INT_SIZE; } // Get bytes and translate it to Constant byteVal = new byte[size]; contents.get(offset, byteVal); return Constant.newInstance(type, byteVal); }
[ "public", "synchronized", "Constant", "getVal", "(", "int", "offset", ",", "Type", "type", ")", "{", "int", "size", ";", "byte", "[", "]", "byteVal", "=", "null", ";", "// Check the length of bytes\r", "if", "(", "type", ".", "isFixedSize", "(", ")", ")", "{", "size", "=", "type", ".", "maxSize", "(", ")", ";", "}", "else", "{", "byteVal", "=", "new", "byte", "[", "ByteHelper", ".", "INT_SIZE", "]", ";", "contents", ".", "get", "(", "offset", ",", "byteVal", ")", ";", "size", "=", "ByteHelper", ".", "toInteger", "(", "byteVal", ")", ";", "offset", "+=", "ByteHelper", ".", "INT_SIZE", ";", "}", "// Get bytes and translate it to Constant\r", "byteVal", "=", "new", "byte", "[", "size", "]", ";", "contents", ".", "get", "(", "offset", ",", "byteVal", ")", ";", "return", "Constant", ".", "newInstance", "(", "type", ",", "byteVal", ")", ";", "}" ]
Returns the value at a specified offset of this page. If a constant was not stored at that offset, the behavior of the method is unpredictable. @param offset the byte offset within the page @param type the type of the value @return the constant value at that offset
[ "Returns", "the", "value", "at", "a", "specified", "offset", "of", "this", "page", ".", "If", "a", "constant", "was", "not", "stored", "at", "that", "offset", "the", "behavior", "of", "the", "method", "is", "unpredictable", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/file/Page.java#L150-L168
139,856
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/file/Page.java
Page.setVal
public synchronized void setVal(int offset, Constant val) { byte[] byteval = val.asBytes(); // Append the size of value if it is not fixed size if (!val.getType().isFixedSize()) { // check the field capacity and value size if (offset + ByteHelper.INT_SIZE + byteval.length > BLOCK_SIZE) throw new BufferOverflowException(); byte[] sizeBytes = ByteHelper.toBytes(byteval.length); contents.put(offset, sizeBytes); offset += sizeBytes.length; } // Put bytes contents.put(offset, byteval); }
java
public synchronized void setVal(int offset, Constant val) { byte[] byteval = val.asBytes(); // Append the size of value if it is not fixed size if (!val.getType().isFixedSize()) { // check the field capacity and value size if (offset + ByteHelper.INT_SIZE + byteval.length > BLOCK_SIZE) throw new BufferOverflowException(); byte[] sizeBytes = ByteHelper.toBytes(byteval.length); contents.put(offset, sizeBytes); offset += sizeBytes.length; } // Put bytes contents.put(offset, byteval); }
[ "public", "synchronized", "void", "setVal", "(", "int", "offset", ",", "Constant", "val", ")", "{", "byte", "[", "]", "byteval", "=", "val", ".", "asBytes", "(", ")", ";", "// Append the size of value if it is not fixed size\r", "if", "(", "!", "val", ".", "getType", "(", ")", ".", "isFixedSize", "(", ")", ")", "{", "// check the field capacity and value size\r", "if", "(", "offset", "+", "ByteHelper", ".", "INT_SIZE", "+", "byteval", ".", "length", ">", "BLOCK_SIZE", ")", "throw", "new", "BufferOverflowException", "(", ")", ";", "byte", "[", "]", "sizeBytes", "=", "ByteHelper", ".", "toBytes", "(", "byteval", ".", "length", ")", ";", "contents", ".", "put", "(", "offset", ",", "sizeBytes", ")", ";", "offset", "+=", "sizeBytes", ".", "length", ";", "}", "// Put bytes\r", "contents", ".", "put", "(", "offset", ",", "byteval", ")", ";", "}" ]
Writes a constant value to the specified offset on the page. @param offset the byte offset within the page @param val the constant value to be written to the page
[ "Writes", "a", "constant", "value", "to", "the", "specified", "offset", "on", "the", "page", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/file/Page.java#L179-L195
139,857
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/Constant.java
Constant.newInstance
public static Constant newInstance(Type type, byte[] val) { switch (type.getSqlType()) { case (INTEGER): return new IntegerConstant(val); case (BIGINT): return new BigIntConstant(val); case (DOUBLE): return new DoubleConstant(val); case (VARCHAR): return new VarcharConstant(val, type); } throw new UnsupportedOperationException("Unspported SQL type: " + type.getSqlType()); }
java
public static Constant newInstance(Type type, byte[] val) { switch (type.getSqlType()) { case (INTEGER): return new IntegerConstant(val); case (BIGINT): return new BigIntConstant(val); case (DOUBLE): return new DoubleConstant(val); case (VARCHAR): return new VarcharConstant(val, type); } throw new UnsupportedOperationException("Unspported SQL type: " + type.getSqlType()); }
[ "public", "static", "Constant", "newInstance", "(", "Type", "type", ",", "byte", "[", "]", "val", ")", "{", "switch", "(", "type", ".", "getSqlType", "(", ")", ")", "{", "case", "(", "INTEGER", ")", ":", "return", "new", "IntegerConstant", "(", "val", ")", ";", "case", "(", "BIGINT", ")", ":", "return", "new", "BigIntConstant", "(", "val", ")", ";", "case", "(", "DOUBLE", ")", ":", "return", "new", "DoubleConstant", "(", "val", ")", ";", "case", "(", "VARCHAR", ")", ":", "return", "new", "VarcharConstant", "(", "val", ",", "type", ")", ";", "}", "throw", "new", "UnsupportedOperationException", "(", "\"Unspported SQL type: \"", "+", "type", ".", "getSqlType", "(", ")", ")", ";", "}" ]
Constructs a new instance of the specified type with value converted from the input byte array. @param type the specified type @param val the byte array contains the value @return a constant of specified type with value converted from the byte array
[ "Constructs", "a", "new", "instance", "of", "the", "specified", "type", "with", "value", "converted", "from", "the", "input", "byte", "array", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/Constant.java#L44-L56
139,858
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/Constant.java
Constant.defaultInstance
public static Constant defaultInstance(Type type) { switch (type.getSqlType()) { case (INTEGER): return defaultInteger; case (BIGINT): return defaultBigInt; case (DOUBLE): return defaultDouble; case (VARCHAR): return defaultVarchar; } throw new UnsupportedOperationException("Unspported SQL type: " + type.getSqlType()); }
java
public static Constant defaultInstance(Type type) { switch (type.getSqlType()) { case (INTEGER): return defaultInteger; case (BIGINT): return defaultBigInt; case (DOUBLE): return defaultDouble; case (VARCHAR): return defaultVarchar; } throw new UnsupportedOperationException("Unspported SQL type: " + type.getSqlType()); }
[ "public", "static", "Constant", "defaultInstance", "(", "Type", "type", ")", "{", "switch", "(", "type", ".", "getSqlType", "(", ")", ")", "{", "case", "(", "INTEGER", ")", ":", "return", "defaultInteger", ";", "case", "(", "BIGINT", ")", ":", "return", "defaultBigInt", ";", "case", "(", "DOUBLE", ")", ":", "return", "defaultDouble", ";", "case", "(", "VARCHAR", ")", ":", "return", "defaultVarchar", ";", "}", "throw", "new", "UnsupportedOperationException", "(", "\"Unspported SQL type: \"", "+", "type", ".", "getSqlType", "(", ")", ")", ";", "}" ]
Constructs a new instance of the specified type with default value. For all numeric constants, the default value is 0; for string constants, the default value is an empty string. @param type the specified type @return the constant of specified type with default value
[ "Constructs", "a", "new", "instance", "of", "the", "specified", "type", "with", "default", "value", ".", "For", "all", "numeric", "constants", "the", "default", "value", "is", "0", ";", "for", "string", "constants", "the", "default", "value", "is", "an", "empty", "string", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/Constant.java#L67-L79
139,859
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/jdbc/RemoteConnectionImpl.java
RemoteConnectionImpl.setReadOnly
@Override public void setReadOnly(boolean readOnly) throws RemoteException { if (this.readOnly != readOnly) { tx.commit(); this.readOnly = readOnly; try { tx = VanillaDb.txMgr().newTransaction(isolationLevel, readOnly); } catch (Exception e) { throw new RemoteException("error creating transaction ", e); } } }
java
@Override public void setReadOnly(boolean readOnly) throws RemoteException { if (this.readOnly != readOnly) { tx.commit(); this.readOnly = readOnly; try { tx = VanillaDb.txMgr().newTransaction(isolationLevel, readOnly); } catch (Exception e) { throw new RemoteException("error creating transaction ", e); } } }
[ "@", "Override", "public", "void", "setReadOnly", "(", "boolean", "readOnly", ")", "throws", "RemoteException", "{", "if", "(", "this", ".", "readOnly", "!=", "readOnly", ")", "{", "tx", ".", "commit", "(", ")", ";", "this", ".", "readOnly", "=", "readOnly", ";", "try", "{", "tx", "=", "VanillaDb", ".", "txMgr", "(", ")", ".", "newTransaction", "(", "isolationLevel", ",", "readOnly", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RemoteException", "(", "\"error creating transaction \"", ",", "e", ")", ";", "}", "}", "}" ]
Sets this connection's auto-commit mode to the given state. The default setting of auto-commit mode is true. This method may commit current transaction and start a new transaction.
[ "Sets", "this", "connection", "s", "auto", "-", "commit", "mode", "to", "the", "given", "state", ".", "The", "default", "setting", "of", "auto", "-", "commit", "mode", "is", "true", ".", "This", "method", "may", "commit", "current", "transaction", "and", "start", "a", "new", "transaction", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/jdbc/RemoteConnectionImpl.java#L91-L102
139,860
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/jdbc/RemoteConnectionImpl.java
RemoteConnectionImpl.commit
@Override public void commit() throws RemoteException { tx.commit(); try { tx = VanillaDb.txMgr().newTransaction(isolationLevel, readOnly); } catch (Exception e) { throw new RemoteException("error creating transaction ", e); } }
java
@Override public void commit() throws RemoteException { tx.commit(); try { tx = VanillaDb.txMgr().newTransaction(isolationLevel, readOnly); } catch (Exception e) { throw new RemoteException("error creating transaction ", e); } }
[ "@", "Override", "public", "void", "commit", "(", ")", "throws", "RemoteException", "{", "tx", ".", "commit", "(", ")", ";", "try", "{", "tx", "=", "VanillaDb", ".", "txMgr", "(", ")", ".", "newTransaction", "(", "isolationLevel", ",", "readOnly", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RemoteException", "(", "\"error creating transaction \"", ",", "e", ")", ";", "}", "}" ]
Commits the current transaction, and begins a new one. @throws Exception
[ "Commits", "the", "current", "transaction", "and", "begins", "a", "new", "one", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/jdbc/RemoteConnectionImpl.java#L158-L166
139,861
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/TempRecordPage.java
TempRecordPage.insertFromScan
public int insertFromScan(Scan s) { if (!super.insertIntoNextEmptySlot()) { return 0; } for (String fldName : sch.fields()) { Constant val = s.getVal(fldName); this.setVal(fldName, val); } if (s.next()) return 1; else return -1; }
java
public int insertFromScan(Scan s) { if (!super.insertIntoNextEmptySlot()) { return 0; } for (String fldName : sch.fields()) { Constant val = s.getVal(fldName); this.setVal(fldName, val); } if (s.next()) return 1; else return -1; }
[ "public", "int", "insertFromScan", "(", "Scan", "s", ")", "{", "if", "(", "!", "super", ".", "insertIntoNextEmptySlot", "(", ")", ")", "{", "return", "0", ";", "}", "for", "(", "String", "fldName", ":", "sch", ".", "fields", "(", ")", ")", "{", "Constant", "val", "=", "s", ".", "getVal", "(", "fldName", ")", ";", "this", ".", "setVal", "(", "fldName", ",", "val", ")", ";", "}", "if", "(", "s", ".", "next", "(", ")", ")", "return", "1", ";", "else", "return", "-", "1", ";", "}" ]
Insert records to TempRecordFile for sorting, at most one block long @param s the source scan @return true if another record is inserted false if block is full of records
[ "Insert", "records", "to", "TempRecordFile", "for", "sorting", "at", "most", "one", "block", "long" ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/TempRecordPage.java#L48-L60
139,862
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/TempRecordPage.java
TempRecordPage.copyToScan
public boolean copyToScan(UpdateScan s) { if (!this.next()) return false; s.insert(); for (String fldName : sch.fields()) { s.setVal(fldName, this.getVal(fldName)); } return true; }
java
public boolean copyToScan(UpdateScan s) { if (!this.next()) return false; s.insert(); for (String fldName : sch.fields()) { s.setVal(fldName, this.getVal(fldName)); } return true; }
[ "public", "boolean", "copyToScan", "(", "UpdateScan", "s", ")", "{", "if", "(", "!", "this", ".", "next", "(", ")", ")", "return", "false", ";", "s", ".", "insert", "(", ")", ";", "for", "(", "String", "fldName", ":", "sch", ".", "fields", "(", ")", ")", "{", "s", ".", "setVal", "(", "fldName", ",", "this", ".", "getVal", "(", "fldName", ")", ")", ";", "}", "return", "true", ";", "}" ]
Copy sorted records to UpdateScan @param s the target scan @return true if still record in TempRecordPage
[ "Copy", "sorted", "records", "to", "UpdateScan" ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/TempRecordPage.java#L69-L77
139,863
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java
BTreeLeaf.schema
static Schema schema(SearchKeyType keyType) { Schema sch = new Schema(); for (int i = 0; i < keyType.length(); i++) sch.addField(keyFieldName(i), keyType.get(i)); sch.addField(SCH_RID_BLOCK, BIGINT); sch.addField(SCH_RID_ID, INTEGER); return sch; }
java
static Schema schema(SearchKeyType keyType) { Schema sch = new Schema(); for (int i = 0; i < keyType.length(); i++) sch.addField(keyFieldName(i), keyType.get(i)); sch.addField(SCH_RID_BLOCK, BIGINT); sch.addField(SCH_RID_ID, INTEGER); return sch; }
[ "static", "Schema", "schema", "(", "SearchKeyType", "keyType", ")", "{", "Schema", "sch", "=", "new", "Schema", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "keyType", ".", "length", "(", ")", ";", "i", "++", ")", "sch", ".", "addField", "(", "keyFieldName", "(", "i", ")", ",", "keyType", ".", "get", "(", "i", ")", ")", ";", "sch", ".", "addField", "(", "SCH_RID_BLOCK", ",", "BIGINT", ")", ";", "sch", ".", "addField", "(", "SCH_RID_ID", ",", "INTEGER", ")", ";", "return", "sch", ";", "}" ]
Returns the schema of the B-tree leaf records. @param keyType the type of the indexed field @return the schema of the index records
[ "Returns", "the", "schema", "of", "the", "B", "-", "tree", "leaf", "records", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java#L99-L106
139,864
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java
BTreeLeaf.next
public boolean next() { while (true) { currentSlot++; if (!isOverflowing) { // not in an overflow block // if it reached the end of the block if (currentSlot >= currentPage.getNumRecords()) { if (getSiblingFlag(currentPage) != -1) { moveTo(getSiblingFlag(currentPage), -1); continue; } return false; // if the key of this slot match what we want } else if (searchRange.match(getKey(currentPage, currentSlot, keyType.length()))) { /* * Move to records in overflow blocks first. An overflow block * cannot be empty. */ if (currentSlot == 0 && getOverflowFlag(currentPage) != -1) { isOverflowing = true; overflowFrom = currentPage.currentBlk().number(); moveTo(getOverflowFlag(currentPage), 0); } return true; } else if (searchRange.betweenMinAndMax(getKey(currentPage, currentSlot, keyType.length()))) { continue; } else return false; } else { // in an overflow block // All the records in an overflow block have the same key // so that we do not need to check the key in an overflow block. if (currentSlot >= currentPage.getNumRecords()) { moveTo(getOverflowFlag(currentPage), 0); /* * Move back to the first record in the regular block finally. */ if (currentPage.currentBlk().number() == overflowFrom) { isOverflowing = false; overflowFrom = -1; } } return true; } } }
java
public boolean next() { while (true) { currentSlot++; if (!isOverflowing) { // not in an overflow block // if it reached the end of the block if (currentSlot >= currentPage.getNumRecords()) { if (getSiblingFlag(currentPage) != -1) { moveTo(getSiblingFlag(currentPage), -1); continue; } return false; // if the key of this slot match what we want } else if (searchRange.match(getKey(currentPage, currentSlot, keyType.length()))) { /* * Move to records in overflow blocks first. An overflow block * cannot be empty. */ if (currentSlot == 0 && getOverflowFlag(currentPage) != -1) { isOverflowing = true; overflowFrom = currentPage.currentBlk().number(); moveTo(getOverflowFlag(currentPage), 0); } return true; } else if (searchRange.betweenMinAndMax(getKey(currentPage, currentSlot, keyType.length()))) { continue; } else return false; } else { // in an overflow block // All the records in an overflow block have the same key // so that we do not need to check the key in an overflow block. if (currentSlot >= currentPage.getNumRecords()) { moveTo(getOverflowFlag(currentPage), 0); /* * Move back to the first record in the regular block finally. */ if (currentPage.currentBlk().number() == overflowFrom) { isOverflowing = false; overflowFrom = -1; } } return true; } } }
[ "public", "boolean", "next", "(", ")", "{", "while", "(", "true", ")", "{", "currentSlot", "++", ";", "if", "(", "!", "isOverflowing", ")", "{", "// not in an overflow block\r", "// if it reached the end of the block\r", "if", "(", "currentSlot", ">=", "currentPage", ".", "getNumRecords", "(", ")", ")", "{", "if", "(", "getSiblingFlag", "(", "currentPage", ")", "!=", "-", "1", ")", "{", "moveTo", "(", "getSiblingFlag", "(", "currentPage", ")", ",", "-", "1", ")", ";", "continue", ";", "}", "return", "false", ";", "// if the key of this slot match what we want\r", "}", "else", "if", "(", "searchRange", ".", "match", "(", "getKey", "(", "currentPage", ",", "currentSlot", ",", "keyType", ".", "length", "(", ")", ")", ")", ")", "{", "/*\r\n\t\t\t\t\t * Move to records in overflow blocks first. An overflow block\r\n\t\t\t\t\t * cannot be empty.\r\n\t\t\t\t\t */", "if", "(", "currentSlot", "==", "0", "&&", "getOverflowFlag", "(", "currentPage", ")", "!=", "-", "1", ")", "{", "isOverflowing", "=", "true", ";", "overflowFrom", "=", "currentPage", ".", "currentBlk", "(", ")", ".", "number", "(", ")", ";", "moveTo", "(", "getOverflowFlag", "(", "currentPage", ")", ",", "0", ")", ";", "}", "return", "true", ";", "}", "else", "if", "(", "searchRange", ".", "betweenMinAndMax", "(", "getKey", "(", "currentPage", ",", "currentSlot", ",", "keyType", ".", "length", "(", ")", ")", ")", ")", "{", "continue", ";", "}", "else", "return", "false", ";", "}", "else", "{", "// in an overflow block\r", "// All the records in an overflow block have the same key\r", "// so that we do not need to check the key in an overflow block.\r", "if", "(", "currentSlot", ">=", "currentPage", ".", "getNumRecords", "(", ")", ")", "{", "moveTo", "(", "getOverflowFlag", "(", "currentPage", ")", ",", "0", ")", ";", "/*\r\n\t\t\t\t\t * Move back to the first record in the regular block finally.\r\n\t\t\t\t\t */", "if", "(", "currentPage", ".", "currentBlk", "(", ")", ".", "number", "(", ")", "==", "overflowFrom", ")", "{", "isOverflowing", "=", "false", ";", "overflowFrom", "=", "-", "1", ";", "}", "}", "return", "true", ";", "}", "}", "}" ]
Moves to the next B-tree leaf record matching the search key. @return false if there are no more leaf records for the search key
[ "Moves", "to", "the", "next", "B", "-", "tree", "leaf", "record", "matching", "the", "search", "key", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java#L211-L256
139,865
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java
BTreeLeaf.insert
public DirEntry insert(RecordId dataRecordId) { // search range must be a constant if (!searchRange.isSingleValue()) throw new IllegalStateException(); // ccMgr.modifyLeafBlock(currentPage.currentBlk()); currentSlot++; SearchKey searchKey = searchRange.asSearchKey(); insert(currentSlot, searchKey, dataRecordId); /* * If the inserted key is less than the key stored in the overflow * blocks, split this block to make sure that the key of the first * record in every block will be the same as the key of records in * the overflow blocks. */ if (currentSlot == 0 && getOverflowFlag(currentPage) != -1 && !getKey(currentPage, 1, keyType.length()).equals(searchKey)) { SearchKey splitKey = getKey(currentPage, 1, keyType.length()); long newBlkNum = currentPage.split(1, new long[] { getOverflowFlag(currentPage), getSiblingFlag(currentPage) }); setOverflowFlag(currentPage, -1); setSiblingFlag(currentPage, newBlkNum); return new DirEntry(splitKey, newBlkNum); } if (!currentPage.isFull()) return null; /* * If this block is full, then split the block and return the directory * entry of the new block. */ SearchKey firstKey = getKey(currentPage, 0, keyType.length()); SearchKey lastKey = getKey(currentPage, currentPage.getNumRecords() - 1, keyType.length()); if (lastKey.equals(firstKey)) { /* * If all of the records in the page have the same key, then the * block does not split; instead, all but one of the records are * placed into an overflow block. */ long overflowFlag = (getOverflowFlag(currentPage) == -1) ? currentPage.currentBlk().number() : getOverflowFlag(currentPage); long newBlkNum = currentPage.split(1, new long[] { overflowFlag, -1 }); setOverflowFlag(currentPage, newBlkNum); return null; } else { int splitPos = currentPage.getNumRecords() / 2; SearchKey splitKey = getKey(currentPage, splitPos, keyType.length()); // records having the same key must be in the same block if (splitKey.equals(firstKey)) { // move right, looking for a different key while (getKey(currentPage, splitPos, keyType.length()).equals(splitKey)) splitPos++; splitKey = getKey(currentPage, splitPos, keyType.length()); } else { // move left, looking for first entry having that key while (getKey(currentPage, splitPos - 1, keyType.length()) .equals(splitKey)) splitPos--; } // split the block long newBlkNum = currentPage.split(splitPos, new long[] { -1, getSiblingFlag(currentPage) }); setSiblingFlag(currentPage, newBlkNum); return new DirEntry(splitKey, newBlkNum); } }
java
public DirEntry insert(RecordId dataRecordId) { // search range must be a constant if (!searchRange.isSingleValue()) throw new IllegalStateException(); // ccMgr.modifyLeafBlock(currentPage.currentBlk()); currentSlot++; SearchKey searchKey = searchRange.asSearchKey(); insert(currentSlot, searchKey, dataRecordId); /* * If the inserted key is less than the key stored in the overflow * blocks, split this block to make sure that the key of the first * record in every block will be the same as the key of records in * the overflow blocks. */ if (currentSlot == 0 && getOverflowFlag(currentPage) != -1 && !getKey(currentPage, 1, keyType.length()).equals(searchKey)) { SearchKey splitKey = getKey(currentPage, 1, keyType.length()); long newBlkNum = currentPage.split(1, new long[] { getOverflowFlag(currentPage), getSiblingFlag(currentPage) }); setOverflowFlag(currentPage, -1); setSiblingFlag(currentPage, newBlkNum); return new DirEntry(splitKey, newBlkNum); } if (!currentPage.isFull()) return null; /* * If this block is full, then split the block and return the directory * entry of the new block. */ SearchKey firstKey = getKey(currentPage, 0, keyType.length()); SearchKey lastKey = getKey(currentPage, currentPage.getNumRecords() - 1, keyType.length()); if (lastKey.equals(firstKey)) { /* * If all of the records in the page have the same key, then the * block does not split; instead, all but one of the records are * placed into an overflow block. */ long overflowFlag = (getOverflowFlag(currentPage) == -1) ? currentPage.currentBlk().number() : getOverflowFlag(currentPage); long newBlkNum = currentPage.split(1, new long[] { overflowFlag, -1 }); setOverflowFlag(currentPage, newBlkNum); return null; } else { int splitPos = currentPage.getNumRecords() / 2; SearchKey splitKey = getKey(currentPage, splitPos, keyType.length()); // records having the same key must be in the same block if (splitKey.equals(firstKey)) { // move right, looking for a different key while (getKey(currentPage, splitPos, keyType.length()).equals(splitKey)) splitPos++; splitKey = getKey(currentPage, splitPos, keyType.length()); } else { // move left, looking for first entry having that key while (getKey(currentPage, splitPos - 1, keyType.length()) .equals(splitKey)) splitPos--; } // split the block long newBlkNum = currentPage.split(splitPos, new long[] { -1, getSiblingFlag(currentPage) }); setSiblingFlag(currentPage, newBlkNum); return new DirEntry(splitKey, newBlkNum); } }
[ "public", "DirEntry", "insert", "(", "RecordId", "dataRecordId", ")", "{", "// search range must be a constant\r", "if", "(", "!", "searchRange", ".", "isSingleValue", "(", ")", ")", "throw", "new", "IllegalStateException", "(", ")", ";", "// ccMgr.modifyLeafBlock(currentPage.currentBlk());\r", "currentSlot", "++", ";", "SearchKey", "searchKey", "=", "searchRange", ".", "asSearchKey", "(", ")", ";", "insert", "(", "currentSlot", ",", "searchKey", ",", "dataRecordId", ")", ";", "/*\r\n\t\t * If the inserted key is less than the key stored in the overflow\r\n\t\t * blocks, split this block to make sure that the key of the first\r\n\t\t * record in every block will be the same as the key of records in\r\n\t\t * the overflow blocks.\r\n\t\t */", "if", "(", "currentSlot", "==", "0", "&&", "getOverflowFlag", "(", "currentPage", ")", "!=", "-", "1", "&&", "!", "getKey", "(", "currentPage", ",", "1", ",", "keyType", ".", "length", "(", ")", ")", ".", "equals", "(", "searchKey", ")", ")", "{", "SearchKey", "splitKey", "=", "getKey", "(", "currentPage", ",", "1", ",", "keyType", ".", "length", "(", ")", ")", ";", "long", "newBlkNum", "=", "currentPage", ".", "split", "(", "1", ",", "new", "long", "[", "]", "{", "getOverflowFlag", "(", "currentPage", ")", ",", "getSiblingFlag", "(", "currentPage", ")", "}", ")", ";", "setOverflowFlag", "(", "currentPage", ",", "-", "1", ")", ";", "setSiblingFlag", "(", "currentPage", ",", "newBlkNum", ")", ";", "return", "new", "DirEntry", "(", "splitKey", ",", "newBlkNum", ")", ";", "}", "if", "(", "!", "currentPage", ".", "isFull", "(", ")", ")", "return", "null", ";", "/*\r\n\t\t * If this block is full, then split the block and return the directory\r\n\t\t * entry of the new block.\r\n\t\t */", "SearchKey", "firstKey", "=", "getKey", "(", "currentPage", ",", "0", ",", "keyType", ".", "length", "(", ")", ")", ";", "SearchKey", "lastKey", "=", "getKey", "(", "currentPage", ",", "currentPage", ".", "getNumRecords", "(", ")", "-", "1", ",", "keyType", ".", "length", "(", ")", ")", ";", "if", "(", "lastKey", ".", "equals", "(", "firstKey", ")", ")", "{", "/*\r\n\t\t\t * If all of the records in the page have the same key, then the\r\n\t\t\t * block does not split; instead, all but one of the records are\r\n\t\t\t * placed into an overflow block.\r\n\t\t\t */", "long", "overflowFlag", "=", "(", "getOverflowFlag", "(", "currentPage", ")", "==", "-", "1", ")", "?", "currentPage", ".", "currentBlk", "(", ")", ".", "number", "(", ")", ":", "getOverflowFlag", "(", "currentPage", ")", ";", "long", "newBlkNum", "=", "currentPage", ".", "split", "(", "1", ",", "new", "long", "[", "]", "{", "overflowFlag", ",", "-", "1", "}", ")", ";", "setOverflowFlag", "(", "currentPage", ",", "newBlkNum", ")", ";", "return", "null", ";", "}", "else", "{", "int", "splitPos", "=", "currentPage", ".", "getNumRecords", "(", ")", "/", "2", ";", "SearchKey", "splitKey", "=", "getKey", "(", "currentPage", ",", "splitPos", ",", "keyType", ".", "length", "(", ")", ")", ";", "// records having the same key must be in the same block\r", "if", "(", "splitKey", ".", "equals", "(", "firstKey", ")", ")", "{", "// move right, looking for a different key\r", "while", "(", "getKey", "(", "currentPage", ",", "splitPos", ",", "keyType", ".", "length", "(", ")", ")", ".", "equals", "(", "splitKey", ")", ")", "splitPos", "++", ";", "splitKey", "=", "getKey", "(", "currentPage", ",", "splitPos", ",", "keyType", ".", "length", "(", ")", ")", ";", "}", "else", "{", "// move left, looking for first entry having that key\r", "while", "(", "getKey", "(", "currentPage", ",", "splitPos", "-", "1", ",", "keyType", ".", "length", "(", ")", ")", ".", "equals", "(", "splitKey", ")", ")", "splitPos", "--", ";", "}", "// split the block\r", "long", "newBlkNum", "=", "currentPage", ".", "split", "(", "splitPos", ",", "new", "long", "[", "]", "{", "-", "1", ",", "getSiblingFlag", "(", "currentPage", ")", "}", ")", ";", "setSiblingFlag", "(", "currentPage", ",", "newBlkNum", ")", ";", "return", "new", "DirEntry", "(", "splitKey", ",", "newBlkNum", ")", ";", "}", "}" ]
Inserts a new B-tree leaf record having the specified data record ID and the previously-specified search key. This method can only be called once, immediately after construction. @param dataRecordId the data record ID of the new record @return the directory entry of the newly-split page or null of there is no split
[ "Inserts", "a", "new", "B", "-", "tree", "leaf", "record", "having", "the", "specified", "data", "record", "ID", "and", "the", "previously", "-", "specified", "search", "key", ".", "This", "method", "can", "only", "be", "called", "once", "immediately", "after", "construction", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java#L277-L349
139,866
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java
BTreeLeaf.delete
public void delete(RecordId dataRecordId) { // search range must be a constant if (!searchRange.isSingleValue()) throw new IllegalStateException(); // delete all entry with the specific key while (next()) if (getDataRecordId().equals(dataRecordId)) { // ccMgr.modifyLeafBlock(currentPage.currentBlk()); delete(currentSlot); break; } if (!isOverflowing) { /* * If the current regular block is empty or the key of the first * record is not equal to that of records in overflow blocks, * transfer one record from a overflow block to here (if any). */ if (getOverflowFlag(currentPage) != -1) { // get overflow page BlockId blk = new BlockId(currentPage.currentBlk().fileName(), getOverflowFlag(currentPage)); ccMgr.modifyLeafBlock(blk); BTreePage overflowPage = new BTreePage(blk, NUM_FLAGS, schema, tx); SearchKey firstKey = getKey(currentPage, 0, keyType.length()); if ((currentPage.getNumRecords() == 0 || (overflowPage.getNumRecords() != 0 && getKey(overflowPage, 0, keyType.length()) != firstKey))) { overflowPage.transferRecords(overflowPage.getNumRecords() - 1, currentPage, 0, 1); // if the overflow block is empty, make it a dead block if (overflowPage.getNumRecords() == 0) { long overflowFlag = (getOverflowFlag(overflowPage) == currentPage.currentBlk().number()) ? -1 : getOverflowFlag(overflowPage); setOverflowFlag(currentPage, overflowFlag); } overflowPage.close(); } } } else { /* * If the current overflow block is empty, make it a dead block. */ if (currentPage.getNumRecords() == 0) { // reset the overflow flag of original page BlockId blk = new BlockId(currentPage.currentBlk().fileName(), moveFrom); // ccMgr.modifyLeafBlock(blk); BTreePage prePage = new BTreePage(blk, NUM_FLAGS, schema, tx); long overflowFlag = (getOverflowFlag(currentPage) == prePage.currentBlk().number()) ? -1 : getOverflowFlag(currentPage); setOverflowFlag(prePage, overflowFlag); prePage.close(); } } }
java
public void delete(RecordId dataRecordId) { // search range must be a constant if (!searchRange.isSingleValue()) throw new IllegalStateException(); // delete all entry with the specific key while (next()) if (getDataRecordId().equals(dataRecordId)) { // ccMgr.modifyLeafBlock(currentPage.currentBlk()); delete(currentSlot); break; } if (!isOverflowing) { /* * If the current regular block is empty or the key of the first * record is not equal to that of records in overflow blocks, * transfer one record from a overflow block to here (if any). */ if (getOverflowFlag(currentPage) != -1) { // get overflow page BlockId blk = new BlockId(currentPage.currentBlk().fileName(), getOverflowFlag(currentPage)); ccMgr.modifyLeafBlock(blk); BTreePage overflowPage = new BTreePage(blk, NUM_FLAGS, schema, tx); SearchKey firstKey = getKey(currentPage, 0, keyType.length()); if ((currentPage.getNumRecords() == 0 || (overflowPage.getNumRecords() != 0 && getKey(overflowPage, 0, keyType.length()) != firstKey))) { overflowPage.transferRecords(overflowPage.getNumRecords() - 1, currentPage, 0, 1); // if the overflow block is empty, make it a dead block if (overflowPage.getNumRecords() == 0) { long overflowFlag = (getOverflowFlag(overflowPage) == currentPage.currentBlk().number()) ? -1 : getOverflowFlag(overflowPage); setOverflowFlag(currentPage, overflowFlag); } overflowPage.close(); } } } else { /* * If the current overflow block is empty, make it a dead block. */ if (currentPage.getNumRecords() == 0) { // reset the overflow flag of original page BlockId blk = new BlockId(currentPage.currentBlk().fileName(), moveFrom); // ccMgr.modifyLeafBlock(blk); BTreePage prePage = new BTreePage(blk, NUM_FLAGS, schema, tx); long overflowFlag = (getOverflowFlag(currentPage) == prePage.currentBlk().number()) ? -1 : getOverflowFlag(currentPage); setOverflowFlag(prePage, overflowFlag); prePage.close(); } } }
[ "public", "void", "delete", "(", "RecordId", "dataRecordId", ")", "{", "// search range must be a constant\r", "if", "(", "!", "searchRange", ".", "isSingleValue", "(", ")", ")", "throw", "new", "IllegalStateException", "(", ")", ";", "// delete all entry with the specific key\r", "while", "(", "next", "(", ")", ")", "if", "(", "getDataRecordId", "(", ")", ".", "equals", "(", "dataRecordId", ")", ")", "{", "// ccMgr.modifyLeafBlock(currentPage.currentBlk());\r", "delete", "(", "currentSlot", ")", ";", "break", ";", "}", "if", "(", "!", "isOverflowing", ")", "{", "/*\r\n\t\t\t * If the current regular block is empty or the key of the first\r\n\t\t\t * record is not equal to that of records in overflow blocks,\r\n\t\t\t * transfer one record from a overflow block to here (if any).\r\n\t\t\t */", "if", "(", "getOverflowFlag", "(", "currentPage", ")", "!=", "-", "1", ")", "{", "// get overflow page\r", "BlockId", "blk", "=", "new", "BlockId", "(", "currentPage", ".", "currentBlk", "(", ")", ".", "fileName", "(", ")", ",", "getOverflowFlag", "(", "currentPage", ")", ")", ";", "ccMgr", ".", "modifyLeafBlock", "(", "blk", ")", ";", "BTreePage", "overflowPage", "=", "new", "BTreePage", "(", "blk", ",", "NUM_FLAGS", ",", "schema", ",", "tx", ")", ";", "SearchKey", "firstKey", "=", "getKey", "(", "currentPage", ",", "0", ",", "keyType", ".", "length", "(", ")", ")", ";", "if", "(", "(", "currentPage", ".", "getNumRecords", "(", ")", "==", "0", "||", "(", "overflowPage", ".", "getNumRecords", "(", ")", "!=", "0", "&&", "getKey", "(", "overflowPage", ",", "0", ",", "keyType", ".", "length", "(", ")", ")", "!=", "firstKey", ")", ")", ")", "{", "overflowPage", ".", "transferRecords", "(", "overflowPage", ".", "getNumRecords", "(", ")", "-", "1", ",", "currentPage", ",", "0", ",", "1", ")", ";", "// if the overflow block is empty, make it a dead block\r", "if", "(", "overflowPage", ".", "getNumRecords", "(", ")", "==", "0", ")", "{", "long", "overflowFlag", "=", "(", "getOverflowFlag", "(", "overflowPage", ")", "==", "currentPage", ".", "currentBlk", "(", ")", ".", "number", "(", ")", ")", "?", "-", "1", ":", "getOverflowFlag", "(", "overflowPage", ")", ";", "setOverflowFlag", "(", "currentPage", ",", "overflowFlag", ")", ";", "}", "overflowPage", ".", "close", "(", ")", ";", "}", "}", "}", "else", "{", "/*\r\n\t\t\t * If the current overflow block is empty, make it a dead block.\r\n\t\t\t */", "if", "(", "currentPage", ".", "getNumRecords", "(", ")", "==", "0", ")", "{", "// reset the overflow flag of original page\r", "BlockId", "blk", "=", "new", "BlockId", "(", "currentPage", ".", "currentBlk", "(", ")", ".", "fileName", "(", ")", ",", "moveFrom", ")", ";", "// ccMgr.modifyLeafBlock(blk);\r", "BTreePage", "prePage", "=", "new", "BTreePage", "(", "blk", ",", "NUM_FLAGS", ",", "schema", ",", "tx", ")", ";", "long", "overflowFlag", "=", "(", "getOverflowFlag", "(", "currentPage", ")", "==", "prePage", ".", "currentBlk", "(", ")", ".", "number", "(", ")", ")", "?", "-", "1", ":", "getOverflowFlag", "(", "currentPage", ")", ";", "setOverflowFlag", "(", "prePage", ",", "overflowFlag", ")", ";", "prePage", ".", "close", "(", ")", ";", "}", "}", "}" ]
Deletes the B-tree leaf record having the specified data record ID and the previously-specified search key. This method can only be called once, immediately after construction. @param dataRecordId the data record ID whose record is to be deleted
[ "Deletes", "the", "B", "-", "tree", "leaf", "record", "having", "the", "specified", "data", "record", "ID", "and", "the", "previously", "-", "specified", "search", "key", ".", "This", "method", "can", "only", "be", "called", "once", "immediately", "after", "construction", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java#L359-L415
139,867
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java
BTreeLeaf.moveSlotBefore
private void moveSlotBefore() { /* * int slot = 0; while (slot < currentPage.getNumRecords() && * searchRange.largerThan(getKey(currentPage, slot))) slot++; * * currentSlot = slot - 1; */ // Optimization: Use binary search rather than sequential search int startSlot = 0, endSlot = currentPage.getNumRecords() - 1; int middleSlot = (startSlot + endSlot) / 2; SearchKey searchMin = searchRange.getMin(); if (endSlot >= 0) { while (middleSlot != startSlot) { if (searchMin.compareTo( getKey(currentPage, middleSlot, keyType.length())) > 0) startSlot = middleSlot; else endSlot = middleSlot; middleSlot = (startSlot + endSlot) / 2; } if (searchMin.compareTo( getKey(currentPage, endSlot, keyType.length())) > 0) currentSlot = endSlot; else if (searchMin.compareTo( getKey(currentPage, startSlot, keyType.length())) > 0) currentSlot = startSlot; else currentSlot = startSlot - 1; } else currentSlot = -1; }
java
private void moveSlotBefore() { /* * int slot = 0; while (slot < currentPage.getNumRecords() && * searchRange.largerThan(getKey(currentPage, slot))) slot++; * * currentSlot = slot - 1; */ // Optimization: Use binary search rather than sequential search int startSlot = 0, endSlot = currentPage.getNumRecords() - 1; int middleSlot = (startSlot + endSlot) / 2; SearchKey searchMin = searchRange.getMin(); if (endSlot >= 0) { while (middleSlot != startSlot) { if (searchMin.compareTo( getKey(currentPage, middleSlot, keyType.length())) > 0) startSlot = middleSlot; else endSlot = middleSlot; middleSlot = (startSlot + endSlot) / 2; } if (searchMin.compareTo( getKey(currentPage, endSlot, keyType.length())) > 0) currentSlot = endSlot; else if (searchMin.compareTo( getKey(currentPage, startSlot, keyType.length())) > 0) currentSlot = startSlot; else currentSlot = startSlot - 1; } else currentSlot = -1; }
[ "private", "void", "moveSlotBefore", "(", ")", "{", "/*\r\n\t\t * int slot = 0; while (slot < currentPage.getNumRecords() &&\r\n\t\t * searchRange.largerThan(getKey(currentPage, slot))) slot++;\r\n\t\t * \r\n\t\t * currentSlot = slot - 1;\r\n\t\t */", "// Optimization: Use binary search rather than sequential search\r", "int", "startSlot", "=", "0", ",", "endSlot", "=", "currentPage", ".", "getNumRecords", "(", ")", "-", "1", ";", "int", "middleSlot", "=", "(", "startSlot", "+", "endSlot", ")", "/", "2", ";", "SearchKey", "searchMin", "=", "searchRange", ".", "getMin", "(", ")", ";", "if", "(", "endSlot", ">=", "0", ")", "{", "while", "(", "middleSlot", "!=", "startSlot", ")", "{", "if", "(", "searchMin", ".", "compareTo", "(", "getKey", "(", "currentPage", ",", "middleSlot", ",", "keyType", ".", "length", "(", ")", ")", ")", ">", "0", ")", "startSlot", "=", "middleSlot", ";", "else", "endSlot", "=", "middleSlot", ";", "middleSlot", "=", "(", "startSlot", "+", "endSlot", ")", "/", "2", ";", "}", "if", "(", "searchMin", ".", "compareTo", "(", "getKey", "(", "currentPage", ",", "endSlot", ",", "keyType", ".", "length", "(", ")", ")", ")", ">", "0", ")", "currentSlot", "=", "endSlot", ";", "else", "if", "(", "searchMin", ".", "compareTo", "(", "getKey", "(", "currentPage", ",", "startSlot", ",", "keyType", ".", "length", "(", ")", ")", ")", ">", "0", ")", "currentSlot", "=", "startSlot", ";", "else", "currentSlot", "=", "startSlot", "-", "1", ";", "}", "else", "currentSlot", "=", "-", "1", ";", "}" ]
Positions the current slot right before the first index record that matches the specified search range.
[ "Positions", "the", "current", "slot", "right", "before", "the", "first", "index", "record", "that", "matches", "the", "specified", "search", "range", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java#L425-L458
139,868
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java
BTreeLeaf.moveTo
private void moveTo(long blkNum, int slot) { moveFrom = currentPage.currentBlk().number(); // for deletion BlockId blk = new BlockId(currentPage.currentBlk().fileName(), blkNum); ccMgr.readLeafBlock(blk); currentPage.close(); currentPage = new BTreePage(blk, NUM_FLAGS, schema, tx); currentSlot = slot; }
java
private void moveTo(long blkNum, int slot) { moveFrom = currentPage.currentBlk().number(); // for deletion BlockId blk = new BlockId(currentPage.currentBlk().fileName(), blkNum); ccMgr.readLeafBlock(blk); currentPage.close(); currentPage = new BTreePage(blk, NUM_FLAGS, schema, tx); currentSlot = slot; }
[ "private", "void", "moveTo", "(", "long", "blkNum", ",", "int", "slot", ")", "{", "moveFrom", "=", "currentPage", ".", "currentBlk", "(", ")", ".", "number", "(", ")", ";", "// for deletion\r", "BlockId", "blk", "=", "new", "BlockId", "(", "currentPage", ".", "currentBlk", "(", ")", ".", "fileName", "(", ")", ",", "blkNum", ")", ";", "ccMgr", ".", "readLeafBlock", "(", "blk", ")", ";", "currentPage", ".", "close", "(", ")", ";", "currentPage", "=", "new", "BTreePage", "(", "blk", ",", "NUM_FLAGS", ",", "schema", ",", "tx", ")", ";", "currentSlot", "=", "slot", ";", "}" ]
Opens the page for the specified block and moves the current slot to the specified position.
[ "Opens", "the", "page", "for", "the", "specified", "block", "and", "moves", "the", "current", "slot", "to", "the", "specified", "position", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/index/btree/BTreeLeaf.java#L464-L471
139,869
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/ReduceRecordsPlan.java
ReduceRecordsPlan.syncHistogram
public static Histogram syncHistogram(Histogram hist) { double maxRecs = 0.0; for (String fld : hist.fields()) { double numRecs = 0.0; for (Bucket bkt : hist.buckets(fld)) numRecs += bkt.frequency(); if (Double.compare(numRecs, maxRecs) > 0) maxRecs = numRecs; } Histogram syncHist = new Histogram(hist.fields()); for (String fld : hist.fields()) { double numRecs = 0.0; for (Bucket bkt : hist.buckets(fld)) numRecs += bkt.frequency(); double extrapolation = maxRecs / numRecs; for (Bucket bkt : hist.buckets(fld)) syncHist.addBucket(fld, new Bucket(bkt.valueRange(), extrapolation * bkt.frequency(), bkt.distinctValues(), bkt.valuePercentiles())); } return syncHist; }
java
public static Histogram syncHistogram(Histogram hist) { double maxRecs = 0.0; for (String fld : hist.fields()) { double numRecs = 0.0; for (Bucket bkt : hist.buckets(fld)) numRecs += bkt.frequency(); if (Double.compare(numRecs, maxRecs) > 0) maxRecs = numRecs; } Histogram syncHist = new Histogram(hist.fields()); for (String fld : hist.fields()) { double numRecs = 0.0; for (Bucket bkt : hist.buckets(fld)) numRecs += bkt.frequency(); double extrapolation = maxRecs / numRecs; for (Bucket bkt : hist.buckets(fld)) syncHist.addBucket(fld, new Bucket(bkt.valueRange(), extrapolation * bkt.frequency(), bkt.distinctValues(), bkt.valuePercentiles())); } return syncHist; }
[ "public", "static", "Histogram", "syncHistogram", "(", "Histogram", "hist", ")", "{", "double", "maxRecs", "=", "0.0", ";", "for", "(", "String", "fld", ":", "hist", ".", "fields", "(", ")", ")", "{", "double", "numRecs", "=", "0.0", ";", "for", "(", "Bucket", "bkt", ":", "hist", ".", "buckets", "(", "fld", ")", ")", "numRecs", "+=", "bkt", ".", "frequency", "(", ")", ";", "if", "(", "Double", ".", "compare", "(", "numRecs", ",", "maxRecs", ")", ">", "0", ")", "maxRecs", "=", "numRecs", ";", "}", "Histogram", "syncHist", "=", "new", "Histogram", "(", "hist", ".", "fields", "(", ")", ")", ";", "for", "(", "String", "fld", ":", "hist", ".", "fields", "(", ")", ")", "{", "double", "numRecs", "=", "0.0", ";", "for", "(", "Bucket", "bkt", ":", "hist", ".", "buckets", "(", "fld", ")", ")", "numRecs", "+=", "bkt", ".", "frequency", "(", ")", ";", "double", "extrapolation", "=", "maxRecs", "/", "numRecs", ";", "for", "(", "Bucket", "bkt", ":", "hist", ".", "buckets", "(", "fld", ")", ")", "syncHist", ".", "addBucket", "(", "fld", ",", "new", "Bucket", "(", "bkt", ".", "valueRange", "(", ")", ",", "extrapolation", "*", "bkt", ".", "frequency", "(", ")", ",", "bkt", ".", "distinctValues", "(", ")", ",", "bkt", ".", "valuePercentiles", "(", ")", ")", ")", ";", "}", "return", "syncHist", ";", "}" ]
Buckets of a field may be discarded during the cost estimation if its frequency is less than 1. As a result, the total frequencies of buckets may be diverse in different fields. This method synchronizes the total frequencies of different fields in the specified histogram. @param hist the histogram @return a histogram whose total frequencies in different fields are synchronized
[ "Buckets", "of", "a", "field", "may", "be", "discarded", "during", "the", "cost", "estimation", "if", "its", "frequency", "is", "less", "than", "1", ".", "As", "a", "result", "the", "total", "frequencies", "of", "buckets", "may", "be", "diverse", "in", "different", "fields", ".", "This", "method", "synchronizes", "the", "total", "frequencies", "of", "different", "fields", "in", "the", "specified", "histogram", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/ReduceRecordsPlan.java#L38-L59
139,870
jbossas/remoting-jmx
src/main/java/org/jboss/remotingjmx/protocol/v2/ClientRequestManager.java
ClientRequestManager.reserveNextCorrelationId
synchronized int reserveNextCorrelationId(VersionedIoFuture future) { Integer next = getNextCorrelationId(); // Not likely but possible to use all IDs and start back at beginning while // old request still in progress. while (requests.containsKey(next)) { next = getNextCorrelationId(); } requests.put(next, future); return next; }
java
synchronized int reserveNextCorrelationId(VersionedIoFuture future) { Integer next = getNextCorrelationId(); // Not likely but possible to use all IDs and start back at beginning while // old request still in progress. while (requests.containsKey(next)) { next = getNextCorrelationId(); } requests.put(next, future); return next; }
[ "synchronized", "int", "reserveNextCorrelationId", "(", "VersionedIoFuture", "future", ")", "{", "Integer", "next", "=", "getNextCorrelationId", "(", ")", ";", "// Not likely but possible to use all IDs and start back at beginning while", "// old request still in progress.", "while", "(", "requests", ".", "containsKey", "(", "next", ")", ")", "{", "next", "=", "getNextCorrelationId", "(", ")", ";", "}", "requests", ".", "put", "(", "next", ",", "future", ")", ";", "return", "next", ";", "}" ]
Reserves a correlation ID by taking the next value and ensuring it is stored in the Map. @return the next reserved correlation ID
[ "Reserves", "a", "correlation", "ID", "by", "taking", "the", "next", "value", "and", "ensuring", "it", "is", "stored", "in", "the", "Map", "." ]
dbc87bfed47e5bb9e37c355a77ca0ae9a6ea1363
https://github.com/jbossas/remoting-jmx/blob/dbc87bfed47e5bb9e37c355a77ca0ae9a6ea1363/src/main/java/org/jboss/remotingjmx/protocol/v2/ClientRequestManager.java#L65-L76
139,871
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java
SelectPlan.predHistogram
public static Histogram predHistogram(Histogram hist, Predicate pred) { if (Double.compare(hist.recordsOutput(), 1.0) < 0) return new Histogram(hist.fields()); // apply constant ranges Map<String, ConstantRange> cRanges = new HashMap<String, ConstantRange>(); for (String fld : hist.fields()) { ConstantRange cr = pred.constantRange(fld); if (cr != null) cRanges.put(fld, cr); } Histogram crHist = constantRangeHistogram(hist, cRanges); // apply field joins Histogram jfHist = crHist; Deque<String> flds = new LinkedList<String>(jfHist.fields()); while (!flds.isEmpty()) { String fld = flds.removeFirst(); Set<String> group = pred.joinFields(fld); if (group != null) { flds.removeAll(group); group.add(fld); jfHist = joinFieldsHistogram(jfHist, group); } } return jfHist; }
java
public static Histogram predHistogram(Histogram hist, Predicate pred) { if (Double.compare(hist.recordsOutput(), 1.0) < 0) return new Histogram(hist.fields()); // apply constant ranges Map<String, ConstantRange> cRanges = new HashMap<String, ConstantRange>(); for (String fld : hist.fields()) { ConstantRange cr = pred.constantRange(fld); if (cr != null) cRanges.put(fld, cr); } Histogram crHist = constantRangeHistogram(hist, cRanges); // apply field joins Histogram jfHist = crHist; Deque<String> flds = new LinkedList<String>(jfHist.fields()); while (!flds.isEmpty()) { String fld = flds.removeFirst(); Set<String> group = pred.joinFields(fld); if (group != null) { flds.removeAll(group); group.add(fld); jfHist = joinFieldsHistogram(jfHist, group); } } return jfHist; }
[ "public", "static", "Histogram", "predHistogram", "(", "Histogram", "hist", ",", "Predicate", "pred", ")", "{", "if", "(", "Double", ".", "compare", "(", "hist", ".", "recordsOutput", "(", ")", ",", "1.0", ")", "<", "0", ")", "return", "new", "Histogram", "(", "hist", ".", "fields", "(", ")", ")", ";", "// apply constant ranges\r", "Map", "<", "String", ",", "ConstantRange", ">", "cRanges", "=", "new", "HashMap", "<", "String", ",", "ConstantRange", ">", "(", ")", ";", "for", "(", "String", "fld", ":", "hist", ".", "fields", "(", ")", ")", "{", "ConstantRange", "cr", "=", "pred", ".", "constantRange", "(", "fld", ")", ";", "if", "(", "cr", "!=", "null", ")", "cRanges", ".", "put", "(", "fld", ",", "cr", ")", ";", "}", "Histogram", "crHist", "=", "constantRangeHistogram", "(", "hist", ",", "cRanges", ")", ";", "// apply field joins\r", "Histogram", "jfHist", "=", "crHist", ";", "Deque", "<", "String", ">", "flds", "=", "new", "LinkedList", "<", "String", ">", "(", "jfHist", ".", "fields", "(", ")", ")", ";", "while", "(", "!", "flds", ".", "isEmpty", "(", ")", ")", "{", "String", "fld", "=", "flds", ".", "removeFirst", "(", ")", ";", "Set", "<", "String", ">", "group", "=", "pred", ".", "joinFields", "(", "fld", ")", ";", "if", "(", "group", "!=", "null", ")", "{", "flds", ".", "removeAll", "(", "group", ")", ";", "group", ".", "add", "(", "fld", ")", ";", "jfHist", "=", "joinFieldsHistogram", "(", "jfHist", ",", "group", ")", ";", "}", "}", "return", "jfHist", ";", "}" ]
Returns a histogram that, for each field, approximates the distribution of field values from the specified histogram satisfying the specified predicate. <p> Assumes that: <ul> <li>Equality selection always finds matching records</li> <li>Values in a bucket have the same frequency (uniform frequency)</li> <li>Given values within two equal ranges (of two joinable fields), all values in the range having smaller number of values appear in the range having larger number of values</li> <li>Distributions of values in different fields are independent with each other</li> </ul> @param hist the input join distribution of field values @param pred the predicate @return a histogram that, for each field, approximates the distribution of field values satisfying the predicate
[ "Returns", "a", "histogram", "that", "for", "each", "field", "approximates", "the", "distribution", "of", "field", "values", "from", "the", "specified", "histogram", "satisfying", "the", "specified", "predicate", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java#L63-L89
139,872
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java
SelectPlan.constantRangeHistogram
public static Histogram constantRangeHistogram(Histogram hist, Map<String, ConstantRange> cRanges) { if (Double.compare(hist.recordsOutput(), 1.0) < 0) return new Histogram(hist.fields()); Histogram crHist = new Histogram(hist); for (String fld : cRanges.keySet()) { Collection<Bucket> crBkts = new ArrayList<Bucket>(crHist.buckets( fld).size()); ConstantRange cr = cRanges.get(fld); double freqSum = 0.0; for (Bucket bkt : crHist.buckets(fld)) { Bucket crBkt = constantRangeBucket(bkt, cr); if (crBkt != null) { crBkts.add(crBkt); freqSum += crBkt.frequency(); } } if (Double.compare(freqSum, 1.0) < 0) // no bucket in range return new Histogram(hist.fields()); double crReduction = freqSum / crHist.recordsOutput(); if (Double.compare(crReduction, 1.0) == 0) continue; // update this field's buckets crHist.setBuckets(fld, crBkts); /* * update other fields' buckets to ensure that all fields have the * same total frequencies. */ for (String restFld : crHist.fields()) { if (restFld.equals(fld)) continue; Collection<Bucket> restBkts = new ArrayList<Bucket>(crHist .buckets(restFld).size()); for (Bucket bkt : crHist.buckets(restFld)) { double restFreq = bkt.frequency() * crReduction; if (Double.compare(restFreq, 1.0) < 0) continue; double restDistVals = Math.min(bkt.distinctValues(), restFreq); Bucket restBkt = new Bucket(bkt.valueRange(), restFreq, restDistVals, bkt.valuePercentiles()); restBkts.add(restBkt); } crHist.setBuckets(restFld, restBkts); } } return syncHistogram(crHist); }
java
public static Histogram constantRangeHistogram(Histogram hist, Map<String, ConstantRange> cRanges) { if (Double.compare(hist.recordsOutput(), 1.0) < 0) return new Histogram(hist.fields()); Histogram crHist = new Histogram(hist); for (String fld : cRanges.keySet()) { Collection<Bucket> crBkts = new ArrayList<Bucket>(crHist.buckets( fld).size()); ConstantRange cr = cRanges.get(fld); double freqSum = 0.0; for (Bucket bkt : crHist.buckets(fld)) { Bucket crBkt = constantRangeBucket(bkt, cr); if (crBkt != null) { crBkts.add(crBkt); freqSum += crBkt.frequency(); } } if (Double.compare(freqSum, 1.0) < 0) // no bucket in range return new Histogram(hist.fields()); double crReduction = freqSum / crHist.recordsOutput(); if (Double.compare(crReduction, 1.0) == 0) continue; // update this field's buckets crHist.setBuckets(fld, crBkts); /* * update other fields' buckets to ensure that all fields have the * same total frequencies. */ for (String restFld : crHist.fields()) { if (restFld.equals(fld)) continue; Collection<Bucket> restBkts = new ArrayList<Bucket>(crHist .buckets(restFld).size()); for (Bucket bkt : crHist.buckets(restFld)) { double restFreq = bkt.frequency() * crReduction; if (Double.compare(restFreq, 1.0) < 0) continue; double restDistVals = Math.min(bkt.distinctValues(), restFreq); Bucket restBkt = new Bucket(bkt.valueRange(), restFreq, restDistVals, bkt.valuePercentiles()); restBkts.add(restBkt); } crHist.setBuckets(restFld, restBkts); } } return syncHistogram(crHist); }
[ "public", "static", "Histogram", "constantRangeHistogram", "(", "Histogram", "hist", ",", "Map", "<", "String", ",", "ConstantRange", ">", "cRanges", ")", "{", "if", "(", "Double", ".", "compare", "(", "hist", ".", "recordsOutput", "(", ")", ",", "1.0", ")", "<", "0", ")", "return", "new", "Histogram", "(", "hist", ".", "fields", "(", ")", ")", ";", "Histogram", "crHist", "=", "new", "Histogram", "(", "hist", ")", ";", "for", "(", "String", "fld", ":", "cRanges", ".", "keySet", "(", ")", ")", "{", "Collection", "<", "Bucket", ">", "crBkts", "=", "new", "ArrayList", "<", "Bucket", ">", "(", "crHist", ".", "buckets", "(", "fld", ")", ".", "size", "(", ")", ")", ";", "ConstantRange", "cr", "=", "cRanges", ".", "get", "(", "fld", ")", ";", "double", "freqSum", "=", "0.0", ";", "for", "(", "Bucket", "bkt", ":", "crHist", ".", "buckets", "(", "fld", ")", ")", "{", "Bucket", "crBkt", "=", "constantRangeBucket", "(", "bkt", ",", "cr", ")", ";", "if", "(", "crBkt", "!=", "null", ")", "{", "crBkts", ".", "add", "(", "crBkt", ")", ";", "freqSum", "+=", "crBkt", ".", "frequency", "(", ")", ";", "}", "}", "if", "(", "Double", ".", "compare", "(", "freqSum", ",", "1.0", ")", "<", "0", ")", "// no bucket in range\r", "return", "new", "Histogram", "(", "hist", ".", "fields", "(", ")", ")", ";", "double", "crReduction", "=", "freqSum", "/", "crHist", ".", "recordsOutput", "(", ")", ";", "if", "(", "Double", ".", "compare", "(", "crReduction", ",", "1.0", ")", "==", "0", ")", "continue", ";", "// update this field's buckets\r", "crHist", ".", "setBuckets", "(", "fld", ",", "crBkts", ")", ";", "/*\r\n\t\t\t * update other fields' buckets to ensure that all fields have the\r\n\t\t\t * same total frequencies.\r\n\t\t\t */", "for", "(", "String", "restFld", ":", "crHist", ".", "fields", "(", ")", ")", "{", "if", "(", "restFld", ".", "equals", "(", "fld", ")", ")", "continue", ";", "Collection", "<", "Bucket", ">", "restBkts", "=", "new", "ArrayList", "<", "Bucket", ">", "(", "crHist", ".", "buckets", "(", "restFld", ")", ".", "size", "(", ")", ")", ";", "for", "(", "Bucket", "bkt", ":", "crHist", ".", "buckets", "(", "restFld", ")", ")", "{", "double", "restFreq", "=", "bkt", ".", "frequency", "(", ")", "*", "crReduction", ";", "if", "(", "Double", ".", "compare", "(", "restFreq", ",", "1.0", ")", "<", "0", ")", "continue", ";", "double", "restDistVals", "=", "Math", ".", "min", "(", "bkt", ".", "distinctValues", "(", ")", ",", "restFreq", ")", ";", "Bucket", "restBkt", "=", "new", "Bucket", "(", "bkt", ".", "valueRange", "(", ")", ",", "restFreq", ",", "restDistVals", ",", "bkt", ".", "valuePercentiles", "(", ")", ")", ";", "restBkts", ".", "add", "(", "restBkt", ")", ";", "}", "crHist", ".", "setBuckets", "(", "restFld", ",", "restBkts", ")", ";", "}", "}", "return", "syncHistogram", "(", "crHist", ")", ";", "}" ]
Returns a histogram that, for each field, approximates the distribution of values from the specified histogram falling within the specified search range. <p> Assumes that: <ul> <li>Equality selection always finds matching records</li> <li>Values in a bucket have the same frequency (uniform frequency)</li> <li>Distributions of values in different fields are independent with each other</li> </ul> @param hist the input histogram @param cRanges a map from fields to search ranges @return a histogram that, for each field, approximates the distribution of values from the specified histogram falling within the specified search range
[ "Returns", "a", "histogram", "that", "for", "each", "field", "approximates", "the", "distribution", "of", "values", "from", "the", "specified", "histogram", "falling", "within", "the", "specified", "search", "range", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java#L113-L161
139,873
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java
SelectPlan.constantRangeBucket
public static Bucket constantRangeBucket(Bucket bkt, ConstantRange cRange) { ConstantRange newRange = bkt.valueRange().intersect(cRange); if (!newRange.isValid()) return null; double newDistVals = bkt.distinctValues(newRange); if (Double.compare(newDistVals, 1.0) < 0) return null; double newFreq = bkt.frequency() * newDistVals / bkt.distinctValues(); if (bkt.valuePercentiles() == null) return new Bucket(newRange, newFreq, newDistVals); Percentiles newPcts = bkt.valuePercentiles().percentiles(newRange); return new Bucket(newRange, newFreq, newDistVals, newPcts); }
java
public static Bucket constantRangeBucket(Bucket bkt, ConstantRange cRange) { ConstantRange newRange = bkt.valueRange().intersect(cRange); if (!newRange.isValid()) return null; double newDistVals = bkt.distinctValues(newRange); if (Double.compare(newDistVals, 1.0) < 0) return null; double newFreq = bkt.frequency() * newDistVals / bkt.distinctValues(); if (bkt.valuePercentiles() == null) return new Bucket(newRange, newFreq, newDistVals); Percentiles newPcts = bkt.valuePercentiles().percentiles(newRange); return new Bucket(newRange, newFreq, newDistVals, newPcts); }
[ "public", "static", "Bucket", "constantRangeBucket", "(", "Bucket", "bkt", ",", "ConstantRange", "cRange", ")", "{", "ConstantRange", "newRange", "=", "bkt", ".", "valueRange", "(", ")", ".", "intersect", "(", "cRange", ")", ";", "if", "(", "!", "newRange", ".", "isValid", "(", ")", ")", "return", "null", ";", "double", "newDistVals", "=", "bkt", ".", "distinctValues", "(", "newRange", ")", ";", "if", "(", "Double", ".", "compare", "(", "newDistVals", ",", "1.0", ")", "<", "0", ")", "return", "null", ";", "double", "newFreq", "=", "bkt", ".", "frequency", "(", ")", "*", "newDistVals", "/", "bkt", ".", "distinctValues", "(", ")", ";", "if", "(", "bkt", ".", "valuePercentiles", "(", ")", "==", "null", ")", "return", "new", "Bucket", "(", "newRange", ",", "newFreq", ",", "newDistVals", ")", ";", "Percentiles", "newPcts", "=", "bkt", ".", "valuePercentiles", "(", ")", ".", "percentiles", "(", "newRange", ")", ";", "return", "new", "Bucket", "(", "newRange", ",", "newFreq", ",", "newDistVals", ",", "newPcts", ")", ";", "}" ]
Creates a new bucket by keeping the statistics of records and values in the specified bucket falling within the specified search range. <p> Assumes that: <ul> <li>Equality selection always finds matching records</li> <li>Values in a bucket have the same frequency (uniform frequency)</li> </ul> @param bkt the input bucket @param cRange the search range @return a new bucket that keeps the statistics of records and values falling within the specified search range
[ "Creates", "a", "new", "bucket", "by", "keeping", "the", "statistics", "of", "records", "and", "values", "in", "the", "specified", "bucket", "falling", "within", "the", "specified", "search", "range", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java#L181-L193
139,874
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java
SelectPlan.joinFieldsHistogram
public static Histogram joinFieldsHistogram(Histogram hist, Set<String> group) { if (group.size() < 2) return new Histogram(hist); List<String> flds = new ArrayList<String>(group); Collection<Bucket> jfBkts = hist.buckets(flds.get(0)); for (int i = 1; i < flds.size(); i++) { Collection<Bucket> temp = jfBkts; jfBkts = new ArrayList<Bucket>(2 * jfBkts.size()); for (Bucket bkt1 : temp) { for (Bucket bkt2 : hist.buckets(flds.get(i))) { Bucket jfBkt = joinFieldBucket(bkt1, bkt2, hist.recordsOutput()); if (jfBkt != null) jfBkts.add(jfBkt); } } } double freqSum = 0.0; for (Bucket bkt : jfBkts) freqSum += bkt.frequency(); if (Double.compare(freqSum, 1.0) < 0) // no joined bucket return new Histogram(hist.fields()); double jfReduction = freqSum / hist.recordsOutput(); if (Double.compare(jfReduction, 1.0) == 0) return new Histogram(hist); Histogram jfHist = new Histogram(hist.fields()); for (String fld : hist.fields()) { if (group.contains(fld)) jfHist.setBuckets(fld, jfBkts); else { for (Bucket bkt : hist.buckets(fld)) { double restFreq = bkt.frequency() * jfReduction; if (Double.compare(restFreq, 1.0) < 0) continue; double restDistVals = Math.min(bkt.distinctValues(), restFreq); Bucket restBkt = new Bucket(bkt.valueRange(), restFreq, restDistVals, bkt.valuePercentiles()); jfHist.addBucket(fld, restBkt); } } } return syncHistogram(jfHist); }
java
public static Histogram joinFieldsHistogram(Histogram hist, Set<String> group) { if (group.size() < 2) return new Histogram(hist); List<String> flds = new ArrayList<String>(group); Collection<Bucket> jfBkts = hist.buckets(flds.get(0)); for (int i = 1; i < flds.size(); i++) { Collection<Bucket> temp = jfBkts; jfBkts = new ArrayList<Bucket>(2 * jfBkts.size()); for (Bucket bkt1 : temp) { for (Bucket bkt2 : hist.buckets(flds.get(i))) { Bucket jfBkt = joinFieldBucket(bkt1, bkt2, hist.recordsOutput()); if (jfBkt != null) jfBkts.add(jfBkt); } } } double freqSum = 0.0; for (Bucket bkt : jfBkts) freqSum += bkt.frequency(); if (Double.compare(freqSum, 1.0) < 0) // no joined bucket return new Histogram(hist.fields()); double jfReduction = freqSum / hist.recordsOutput(); if (Double.compare(jfReduction, 1.0) == 0) return new Histogram(hist); Histogram jfHist = new Histogram(hist.fields()); for (String fld : hist.fields()) { if (group.contains(fld)) jfHist.setBuckets(fld, jfBkts); else { for (Bucket bkt : hist.buckets(fld)) { double restFreq = bkt.frequency() * jfReduction; if (Double.compare(restFreq, 1.0) < 0) continue; double restDistVals = Math.min(bkt.distinctValues(), restFreq); Bucket restBkt = new Bucket(bkt.valueRange(), restFreq, restDistVals, bkt.valuePercentiles()); jfHist.addBucket(fld, restBkt); } } } return syncHistogram(jfHist); }
[ "public", "static", "Histogram", "joinFieldsHistogram", "(", "Histogram", "hist", ",", "Set", "<", "String", ">", "group", ")", "{", "if", "(", "group", ".", "size", "(", ")", "<", "2", ")", "return", "new", "Histogram", "(", "hist", ")", ";", "List", "<", "String", ">", "flds", "=", "new", "ArrayList", "<", "String", ">", "(", "group", ")", ";", "Collection", "<", "Bucket", ">", "jfBkts", "=", "hist", ".", "buckets", "(", "flds", ".", "get", "(", "0", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "flds", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Collection", "<", "Bucket", ">", "temp", "=", "jfBkts", ";", "jfBkts", "=", "new", "ArrayList", "<", "Bucket", ">", "(", "2", "*", "jfBkts", ".", "size", "(", ")", ")", ";", "for", "(", "Bucket", "bkt1", ":", "temp", ")", "{", "for", "(", "Bucket", "bkt2", ":", "hist", ".", "buckets", "(", "flds", ".", "get", "(", "i", ")", ")", ")", "{", "Bucket", "jfBkt", "=", "joinFieldBucket", "(", "bkt1", ",", "bkt2", ",", "hist", ".", "recordsOutput", "(", ")", ")", ";", "if", "(", "jfBkt", "!=", "null", ")", "jfBkts", ".", "add", "(", "jfBkt", ")", ";", "}", "}", "}", "double", "freqSum", "=", "0.0", ";", "for", "(", "Bucket", "bkt", ":", "jfBkts", ")", "freqSum", "+=", "bkt", ".", "frequency", "(", ")", ";", "if", "(", "Double", ".", "compare", "(", "freqSum", ",", "1.0", ")", "<", "0", ")", "// no joined bucket\r", "return", "new", "Histogram", "(", "hist", ".", "fields", "(", ")", ")", ";", "double", "jfReduction", "=", "freqSum", "/", "hist", ".", "recordsOutput", "(", ")", ";", "if", "(", "Double", ".", "compare", "(", "jfReduction", ",", "1.0", ")", "==", "0", ")", "return", "new", "Histogram", "(", "hist", ")", ";", "Histogram", "jfHist", "=", "new", "Histogram", "(", "hist", ".", "fields", "(", ")", ")", ";", "for", "(", "String", "fld", ":", "hist", ".", "fields", "(", ")", ")", "{", "if", "(", "group", ".", "contains", "(", "fld", ")", ")", "jfHist", ".", "setBuckets", "(", "fld", ",", "jfBkts", ")", ";", "else", "{", "for", "(", "Bucket", "bkt", ":", "hist", ".", "buckets", "(", "fld", ")", ")", "{", "double", "restFreq", "=", "bkt", ".", "frequency", "(", ")", "*", "jfReduction", ";", "if", "(", "Double", ".", "compare", "(", "restFreq", ",", "1.0", ")", "<", "0", ")", "continue", ";", "double", "restDistVals", "=", "Math", ".", "min", "(", "bkt", ".", "distinctValues", "(", ")", ",", "restFreq", ")", ";", "Bucket", "restBkt", "=", "new", "Bucket", "(", "bkt", ".", "valueRange", "(", ")", ",", "restFreq", ",", "restDistVals", ",", "bkt", ".", "valuePercentiles", "(", ")", ")", ";", "jfHist", ".", "addBucket", "(", "fld", ",", "restBkt", ")", ";", "}", "}", "}", "return", "syncHistogram", "(", "jfHist", ")", ";", "}" ]
Returns a histogram that, for each field, approximates the distribution of values from the specified histogram joining with other fields in the specified group. <p> Assumes that: <ul> <li>Values in a bucket have the same frequency (uniform frequency)</li> <li>Given values within two equal ranges (of two joinable fields), all values in the range having smaller number of values appear in the range having larger number of values</li> <li>Distributions of values in different fields are independent with each other</li> </ul> @param hist the input histogram @param group the group of joining fields @return a histogram that, for each field, approximates the distribution of values from the specified histogram joining with other fields in the specified group
[ "Returns", "a", "histogram", "that", "for", "each", "field", "approximates", "the", "distribution", "of", "values", "from", "the", "specified", "histogram", "joining", "with", "other", "fields", "in", "the", "specified", "group", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java#L219-L263
139,875
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java
SelectPlan.joinFieldBucket
public static Bucket joinFieldBucket(Bucket bkt1, Bucket bkt2, double numRec) { ConstantRange newRange = bkt1.valueRange().intersect(bkt2.valueRange()); if (!newRange.isValid()) return null; double rdv1 = bkt1.distinctValues(newRange); double rdv2 = bkt2.distinctValues(newRange); double newDistVals = Math.min(rdv1, rdv2); if (Double.compare(newDistVals, 1.0) < 0) return null; double newFreq = Math.min( bkt1.frequency() * (bkt2.frequency() / numRec) * (newDistVals / bkt1.distinctValues()) / rdv2, bkt2.frequency() * (bkt1.frequency() / numRec) * (newDistVals / bkt2.distinctValues()) / rdv1); if (Double.compare(newFreq, 1.0) < 0) return null; Bucket smaller = rdv1 < rdv2 ? bkt1 : bkt2; if (smaller.valuePercentiles() == null) return new Bucket(newRange, newFreq, newDistVals); Percentiles newPcts = smaller.valuePercentiles().percentiles(newRange); return new Bucket(newRange, newFreq, newDistVals, newPcts); }
java
public static Bucket joinFieldBucket(Bucket bkt1, Bucket bkt2, double numRec) { ConstantRange newRange = bkt1.valueRange().intersect(bkt2.valueRange()); if (!newRange.isValid()) return null; double rdv1 = bkt1.distinctValues(newRange); double rdv2 = bkt2.distinctValues(newRange); double newDistVals = Math.min(rdv1, rdv2); if (Double.compare(newDistVals, 1.0) < 0) return null; double newFreq = Math.min( bkt1.frequency() * (bkt2.frequency() / numRec) * (newDistVals / bkt1.distinctValues()) / rdv2, bkt2.frequency() * (bkt1.frequency() / numRec) * (newDistVals / bkt2.distinctValues()) / rdv1); if (Double.compare(newFreq, 1.0) < 0) return null; Bucket smaller = rdv1 < rdv2 ? bkt1 : bkt2; if (smaller.valuePercentiles() == null) return new Bucket(newRange, newFreq, newDistVals); Percentiles newPcts = smaller.valuePercentiles().percentiles(newRange); return new Bucket(newRange, newFreq, newDistVals, newPcts); }
[ "public", "static", "Bucket", "joinFieldBucket", "(", "Bucket", "bkt1", ",", "Bucket", "bkt2", ",", "double", "numRec", ")", "{", "ConstantRange", "newRange", "=", "bkt1", ".", "valueRange", "(", ")", ".", "intersect", "(", "bkt2", ".", "valueRange", "(", ")", ")", ";", "if", "(", "!", "newRange", ".", "isValid", "(", ")", ")", "return", "null", ";", "double", "rdv1", "=", "bkt1", ".", "distinctValues", "(", "newRange", ")", ";", "double", "rdv2", "=", "bkt2", ".", "distinctValues", "(", "newRange", ")", ";", "double", "newDistVals", "=", "Math", ".", "min", "(", "rdv1", ",", "rdv2", ")", ";", "if", "(", "Double", ".", "compare", "(", "newDistVals", ",", "1.0", ")", "<", "0", ")", "return", "null", ";", "double", "newFreq", "=", "Math", ".", "min", "(", "bkt1", ".", "frequency", "(", ")", "*", "(", "bkt2", ".", "frequency", "(", ")", "/", "numRec", ")", "*", "(", "newDistVals", "/", "bkt1", ".", "distinctValues", "(", ")", ")", "/", "rdv2", ",", "bkt2", ".", "frequency", "(", ")", "*", "(", "bkt1", ".", "frequency", "(", ")", "/", "numRec", ")", "*", "(", "newDistVals", "/", "bkt2", ".", "distinctValues", "(", ")", ")", "/", "rdv1", ")", ";", "if", "(", "Double", ".", "compare", "(", "newFreq", ",", "1.0", ")", "<", "0", ")", "return", "null", ";", "Bucket", "smaller", "=", "rdv1", "<", "rdv2", "?", "bkt1", ":", "bkt2", ";", "if", "(", "smaller", ".", "valuePercentiles", "(", ")", "==", "null", ")", "return", "new", "Bucket", "(", "newRange", ",", "newFreq", ",", "newDistVals", ")", ";", "Percentiles", "newPcts", "=", "smaller", ".", "valuePercentiles", "(", ")", ".", "percentiles", "(", "newRange", ")", ";", "return", "new", "Bucket", "(", "newRange", ",", "newFreq", ",", "newDistVals", ",", "newPcts", ")", ";", "}" ]
Creates a new bucket by keeping the statistics of joining records and values from the two specified buckets. <p> Assumes that: <ul> <li>Values in a bucket have the same frequency (uniform frequency)</li> <li>Given values within two equal ranges (of two joinable fields), all values in the range having smaller number of values appear in the range having larger number of values</li> <li>Distributions of values in different fields are independent with each other</li> </ul> @param bkt1 the input bucket 1 @param bkt2 the input bucket 2 @param numRec the total number of records in the histogram where <code>bkt1</code> and <code>bkt2</code> belong to @return a new bucket that keeps the statistics of joining records and values from the two specified buckets
[ "Creates", "a", "new", "bucket", "by", "keeping", "the", "statistics", "of", "joining", "records", "and", "values", "from", "the", "two", "specified", "buckets", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java#L290-L311
139,876
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java
SelectPlan.open
@Override public Scan open() { Scan s = p.open(); return new SelectScan(s, pred); }
java
@Override public Scan open() { Scan s = p.open(); return new SelectScan(s, pred); }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "Scan", "s", "=", "p", ".", "open", "(", ")", ";", "return", "new", "SelectScan", "(", "s", ",", "pred", ")", ";", "}" ]
Creates a select scan for this query. @see Plan#open()
[ "Creates", "a", "select", "scan", "for", "this", "query", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/SelectPlan.java#L337-L341
139,877
constantcontact/java-sdk
components/src/main/java/com/constantcontact/v2/DefaultRetrofitBuilderFactory.java
DefaultRetrofitBuilderFactory.create
public Retrofit.Builder create(String baseUrl, ObjectMapper objectMapper) { return new Retrofit.Builder() .baseUrl(baseUrl) .client(_okHttpClient) .addConverterFactory(JacksonConverterFactory.create(objectMapper)); }
java
public Retrofit.Builder create(String baseUrl, ObjectMapper objectMapper) { return new Retrofit.Builder() .baseUrl(baseUrl) .client(_okHttpClient) .addConverterFactory(JacksonConverterFactory.create(objectMapper)); }
[ "public", "Retrofit", ".", "Builder", "create", "(", "String", "baseUrl", ",", "ObjectMapper", "objectMapper", ")", "{", "return", "new", "Retrofit", ".", "Builder", "(", ")", ".", "baseUrl", "(", "baseUrl", ")", ".", "client", "(", "_okHttpClient", ")", ".", "addConverterFactory", "(", "JacksonConverterFactory", ".", "create", "(", "objectMapper", ")", ")", ";", "}" ]
Creates a new builder instance with the provided base url. Initialized with a Jackson JSON converter using the provided object mapper. @param baseUrl the base url @param objectMapper the object mapper @return a builder instance initialized for use with service classes
[ "Creates", "a", "new", "builder", "instance", "with", "the", "provided", "base", "url", ".", "Initialized", "with", "a", "Jackson", "JSON", "converter", "using", "the", "provided", "object", "mapper", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/components/src/main/java/com/constantcontact/v2/DefaultRetrofitBuilderFactory.java#L72-L77
139,878
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/predicate/Predicate.java
Predicate.isSatisfied
public boolean isSatisfied(Record rec) { for (Term t : terms) if (!t.isSatisfied(rec)) return false; return true; }
java
public boolean isSatisfied(Record rec) { for (Term t : terms) if (!t.isSatisfied(rec)) return false; return true; }
[ "public", "boolean", "isSatisfied", "(", "Record", "rec", ")", "{", "for", "(", "Term", "t", ":", "terms", ")", "if", "(", "!", "t", ".", "isSatisfied", "(", "rec", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Returns true if this predicate evaluates to true with respect to the specified record. @param rec the record @return true if the predicate evaluates to true
[ "Returns", "true", "if", "this", "predicate", "evaluates", "to", "true", "with", "respect", "to", "the", "specified", "record", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/predicate/Predicate.java#L79-L84
139,879
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/predicate/Predicate.java
Predicate.selectPredicate
public Predicate selectPredicate(Schema sch) { Predicate result = new Predicate(); for (Term t : terms) if (t.isApplicableTo(sch)) result.terms.add(t); if (result.terms.size() == 0) return null; else return result; }
java
public Predicate selectPredicate(Schema sch) { Predicate result = new Predicate(); for (Term t : terms) if (t.isApplicableTo(sch)) result.terms.add(t); if (result.terms.size() == 0) return null; else return result; }
[ "public", "Predicate", "selectPredicate", "(", "Schema", "sch", ")", "{", "Predicate", "result", "=", "new", "Predicate", "(", ")", ";", "for", "(", "Term", "t", ":", "terms", ")", "if", "(", "t", ".", "isApplicableTo", "(", "sch", ")", ")", "result", ".", "terms", ".", "add", "(", "t", ")", ";", "if", "(", "result", ".", "terms", ".", "size", "(", ")", "==", "0", ")", "return", "null", ";", "else", "return", "result", ";", "}" ]
Returns the sub-predicate that applies to the specified schema. @param sch the schema @return the sub-predicate applying to the schema
[ "Returns", "the", "sub", "-", "predicate", "that", "applies", "to", "the", "specified", "schema", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/predicate/Predicate.java#L93-L102
139,880
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/predicate/Predicate.java
Predicate.joinPredicate
public Predicate joinPredicate(Schema sch1, Schema sch2) { Predicate result = new Predicate(); Schema newsch = new Schema(); newsch.addAll(sch1); newsch.addAll(sch2); for (Term t : terms) if (!t.isApplicableTo(sch1) && !t.isApplicableTo(sch2) && t.isApplicableTo(newsch)) result.terms.add(t); return result.terms.size() == 0 ? null : result; }
java
public Predicate joinPredicate(Schema sch1, Schema sch2) { Predicate result = new Predicate(); Schema newsch = new Schema(); newsch.addAll(sch1); newsch.addAll(sch2); for (Term t : terms) if (!t.isApplicableTo(sch1) && !t.isApplicableTo(sch2) && t.isApplicableTo(newsch)) result.terms.add(t); return result.terms.size() == 0 ? null : result; }
[ "public", "Predicate", "joinPredicate", "(", "Schema", "sch1", ",", "Schema", "sch2", ")", "{", "Predicate", "result", "=", "new", "Predicate", "(", ")", ";", "Schema", "newsch", "=", "new", "Schema", "(", ")", ";", "newsch", ".", "addAll", "(", "sch1", ")", ";", "newsch", ".", "addAll", "(", "sch2", ")", ";", "for", "(", "Term", "t", ":", "terms", ")", "if", "(", "!", "t", ".", "isApplicableTo", "(", "sch1", ")", "&&", "!", "t", ".", "isApplicableTo", "(", "sch2", ")", "&&", "t", ".", "isApplicableTo", "(", "newsch", ")", ")", "result", ".", "terms", ".", "add", "(", "t", ")", ";", "return", "result", ".", "terms", ".", "size", "(", ")", "==", "0", "?", "null", ":", "result", ";", "}" ]
Returns the sub-predicate consisting of terms that applies to the union of the two specified schemas, but not to either schema separately. @param sch1 the first schema @param sch2 the second schema @return the sub-predicate whose terms apply to the union of the two schemas but not either schema separately.
[ "Returns", "the", "sub", "-", "predicate", "consisting", "of", "terms", "that", "applies", "to", "the", "union", "of", "the", "two", "specified", "schemas", "but", "not", "to", "either", "schema", "separately", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/predicate/Predicate.java#L115-L125
139,881
vanilladb/vanillacore
src/main/java/org/vanilladb/core/sql/predicate/Predicate.java
Predicate.constantRange
public ConstantRange constantRange(String fldName) { ConstantRange cr = null; for (Term t : terms) { Constant c = t.oppositeConstant(fldName); if (c != null) { Operator op = t.operator(fldName); if (op == OP_GT) cr = cr == null ? ConstantRange.newInstance(c, false, null, false) : cr.applyLow(c, false); else if (op == OP_GTE) cr = cr == null ? ConstantRange.newInstance(c, true, null, false) : cr.applyLow(c, true); else if (op == OP_EQ) cr = cr == null ? ConstantRange.newInstance(c) : cr .applyConstant(c); else if (op == OP_LTE) cr = cr == null ? ConstantRange.newInstance(null, false, c, true) : cr.applyHigh(c, true); else if (op == OP_LT) cr = cr == null ? ConstantRange.newInstance(null, false, c, false) : cr.applyHigh(c, false); } } // validate the constant range if (cr != null && cr.isValid() && (cr.hasLowerBound() || cr.hasUpperBound())) return cr; return null; }
java
public ConstantRange constantRange(String fldName) { ConstantRange cr = null; for (Term t : terms) { Constant c = t.oppositeConstant(fldName); if (c != null) { Operator op = t.operator(fldName); if (op == OP_GT) cr = cr == null ? ConstantRange.newInstance(c, false, null, false) : cr.applyLow(c, false); else if (op == OP_GTE) cr = cr == null ? ConstantRange.newInstance(c, true, null, false) : cr.applyLow(c, true); else if (op == OP_EQ) cr = cr == null ? ConstantRange.newInstance(c) : cr .applyConstant(c); else if (op == OP_LTE) cr = cr == null ? ConstantRange.newInstance(null, false, c, true) : cr.applyHigh(c, true); else if (op == OP_LT) cr = cr == null ? ConstantRange.newInstance(null, false, c, false) : cr.applyHigh(c, false); } } // validate the constant range if (cr != null && cr.isValid() && (cr.hasLowerBound() || cr.hasUpperBound())) return cr; return null; }
[ "public", "ConstantRange", "constantRange", "(", "String", "fldName", ")", "{", "ConstantRange", "cr", "=", "null", ";", "for", "(", "Term", "t", ":", "terms", ")", "{", "Constant", "c", "=", "t", ".", "oppositeConstant", "(", "fldName", ")", ";", "if", "(", "c", "!=", "null", ")", "{", "Operator", "op", "=", "t", ".", "operator", "(", "fldName", ")", ";", "if", "(", "op", "==", "OP_GT", ")", "cr", "=", "cr", "==", "null", "?", "ConstantRange", ".", "newInstance", "(", "c", ",", "false", ",", "null", ",", "false", ")", ":", "cr", ".", "applyLow", "(", "c", ",", "false", ")", ";", "else", "if", "(", "op", "==", "OP_GTE", ")", "cr", "=", "cr", "==", "null", "?", "ConstantRange", ".", "newInstance", "(", "c", ",", "true", ",", "null", ",", "false", ")", ":", "cr", ".", "applyLow", "(", "c", ",", "true", ")", ";", "else", "if", "(", "op", "==", "OP_EQ", ")", "cr", "=", "cr", "==", "null", "?", "ConstantRange", ".", "newInstance", "(", "c", ")", ":", "cr", ".", "applyConstant", "(", "c", ")", ";", "else", "if", "(", "op", "==", "OP_LTE", ")", "cr", "=", "cr", "==", "null", "?", "ConstantRange", ".", "newInstance", "(", "null", ",", "false", ",", "c", ",", "true", ")", ":", "cr", ".", "applyHigh", "(", "c", ",", "true", ")", ";", "else", "if", "(", "op", "==", "OP_LT", ")", "cr", "=", "cr", "==", "null", "?", "ConstantRange", ".", "newInstance", "(", "null", ",", "false", ",", "c", ",", "false", ")", ":", "cr", ".", "applyHigh", "(", "c", ",", "false", ")", ";", "}", "}", "// validate the constant range\r", "if", "(", "cr", "!=", "null", "&&", "cr", ".", "isValid", "(", ")", "&&", "(", "cr", ".", "hasLowerBound", "(", ")", "||", "cr", ".", "hasUpperBound", "(", ")", ")", ")", "return", "cr", ";", "return", "null", ";", "}" ]
Determines if the specified field is constrained by a constant range in this predicate. If so, the method returns that range. If not, the method returns null. @param fldName the name of the field @return either the constant range or null
[ "Determines", "if", "the", "specified", "field", "is", "constrained", "by", "a", "constant", "range", "in", "this", "predicate", ".", "If", "so", "the", "method", "returns", "that", "range", ".", "If", "not", "the", "method", "returns", "null", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/sql/predicate/Predicate.java#L136-L164
139,882
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/buffer/Buffer.java
Buffer.getVal
public Constant getVal(int offset, Type type) { internalLock.readLock().lock(); try { return contents.getVal(DATA_START_OFFSET + offset, type); } finally { internalLock.readLock().unlock(); } }
java
public Constant getVal(int offset, Type type) { internalLock.readLock().lock(); try { return contents.getVal(DATA_START_OFFSET + offset, type); } finally { internalLock.readLock().unlock(); } }
[ "public", "Constant", "getVal", "(", "int", "offset", ",", "Type", "type", ")", "{", "internalLock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "return", "contents", ".", "getVal", "(", "DATA_START_OFFSET", "+", "offset", ",", "type", ")", ";", "}", "finally", "{", "internalLock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Returns the value at the specified offset of this buffer's page. If an integer was not stored at that location, the behavior of the method is unpredictable. @param offset the byte offset of the page @param type the type of the value @return the constant value at that offset
[ "Returns", "the", "value", "at", "the", "specified", "offset", "of", "this", "buffer", "s", "page", ".", "If", "an", "integer", "was", "not", "stored", "at", "that", "location", "the", "behavior", "of", "the", "method", "is", "unpredictable", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/buffer/Buffer.java#L87-L94
139,883
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/buffer/Buffer.java
Buffer.setVal
public void setVal(int offset, Constant val, long txNum, LogSeqNum lsn) { internalLock.writeLock().lock(); try { modifiedBy.add(txNum); if (lsn != null && lsn.compareTo(lastLsn) > 0) lastLsn = lsn; // Put the last LSN in front of the data lastLsn.writeToPage(contents, LAST_LSN_OFFSET); contents.setVal(DATA_START_OFFSET + offset, val); } finally { internalLock.writeLock().unlock(); } }
java
public void setVal(int offset, Constant val, long txNum, LogSeqNum lsn) { internalLock.writeLock().lock(); try { modifiedBy.add(txNum); if (lsn != null && lsn.compareTo(lastLsn) > 0) lastLsn = lsn; // Put the last LSN in front of the data lastLsn.writeToPage(contents, LAST_LSN_OFFSET); contents.setVal(DATA_START_OFFSET + offset, val); } finally { internalLock.writeLock().unlock(); } }
[ "public", "void", "setVal", "(", "int", "offset", ",", "Constant", "val", ",", "long", "txNum", ",", "LogSeqNum", "lsn", ")", "{", "internalLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "modifiedBy", ".", "add", "(", "txNum", ")", ";", "if", "(", "lsn", "!=", "null", "&&", "lsn", ".", "compareTo", "(", "lastLsn", ")", ">", "0", ")", "lastLsn", "=", "lsn", ";", "// Put the last LSN in front of the data\r", "lastLsn", ".", "writeToPage", "(", "contents", ",", "LAST_LSN_OFFSET", ")", ";", "contents", ".", "setVal", "(", "DATA_START_OFFSET", "+", "offset", ",", "val", ")", ";", "}", "finally", "{", "internalLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Writes a value to the specified offset of this buffer's page. This method assumes that the transaction has already written an appropriate log record. The buffer saves the id of the transaction and the LSN of the log record. A negative lsn value indicates that a log record was not necessary. @param offset the byte offset within the page @param val the new value to be written @param txNum the id of the transaction performing the modification @param lsn the LSN of the corresponding log record
[ "Writes", "a", "value", "to", "the", "specified", "offset", "of", "this", "buffer", "s", "page", ".", "This", "method", "assumes", "that", "the", "transaction", "has", "already", "written", "an", "appropriate", "log", "record", ".", "The", "buffer", "saves", "the", "id", "of", "the", "transaction", "and", "the", "LSN", "of", "the", "log", "record", ".", "A", "negative", "lsn", "value", "indicates", "that", "a", "log", "record", "was", "not", "necessary", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/buffer/Buffer.java#L121-L134
139,884
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/buffer/Buffer.java
Buffer.flush
void flush() { internalLock.writeLock().lock(); flushLock.lock(); try { if (isNew || modifiedBy.size() > 0) { VanillaDb.logMgr().flush(lastLsn); contents.write(blk); modifiedBy.clear(); isNew = false; } } finally { flushLock.unlock(); internalLock.writeLock().unlock(); } }
java
void flush() { internalLock.writeLock().lock(); flushLock.lock(); try { if (isNew || modifiedBy.size() > 0) { VanillaDb.logMgr().flush(lastLsn); contents.write(blk); modifiedBy.clear(); isNew = false; } } finally { flushLock.unlock(); internalLock.writeLock().unlock(); } }
[ "void", "flush", "(", ")", "{", "internalLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "flushLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "isNew", "||", "modifiedBy", ".", "size", "(", ")", ">", "0", ")", "{", "VanillaDb", ".", "logMgr", "(", ")", ".", "flush", "(", "lastLsn", ")", ";", "contents", ".", "write", "(", "blk", ")", ";", "modifiedBy", ".", "clear", "(", ")", ";", "isNew", "=", "false", ";", "}", "}", "finally", "{", "flushLock", ".", "unlock", "(", ")", ";", "internalLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Writes the page to its disk block if the page is dirty. The method ensures that the corresponding log record has been written to disk prior to writing the page to disk.
[ "Writes", "the", "page", "to", "its", "disk", "block", "if", "the", "page", "is", "dirty", ".", "The", "method", "ensures", "that", "the", "corresponding", "log", "record", "has", "been", "written", "to", "disk", "prior", "to", "writing", "the", "page", "to", "disk", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/buffer/Buffer.java#L206-L220
139,885
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/buffer/Buffer.java
Buffer.isModifiedBy
boolean isModifiedBy(long txNum) { internalLock.writeLock().lock(); try { return modifiedBy.contains(txNum); } finally { internalLock.writeLock().unlock(); } }
java
boolean isModifiedBy(long txNum) { internalLock.writeLock().lock(); try { return modifiedBy.contains(txNum); } finally { internalLock.writeLock().unlock(); } }
[ "boolean", "isModifiedBy", "(", "long", "txNum", ")", "{", "internalLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "return", "modifiedBy", ".", "contains", "(", "txNum", ")", ";", "}", "finally", "{", "internalLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Returns true if the buffer is dirty due to a modification by the specified transaction. @param txNum the id of the transaction @return true if the transaction modified the buffer
[ "Returns", "true", "if", "the", "buffer", "is", "dirty", "due", "to", "a", "modification", "by", "the", "specified", "transaction", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/buffer/Buffer.java#L269-L276
139,886
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/buffer/Buffer.java
Buffer.assignToBlock
void assignToBlock(BlockId blk) { internalLock.writeLock().lock(); try { flush(); this.blk = blk; contents.read(blk); pins = 0; lastLsn = LogSeqNum.readFromPage(contents, LAST_LSN_OFFSET); } finally { internalLock.writeLock().unlock(); } }
java
void assignToBlock(BlockId blk) { internalLock.writeLock().lock(); try { flush(); this.blk = blk; contents.read(blk); pins = 0; lastLsn = LogSeqNum.readFromPage(contents, LAST_LSN_OFFSET); } finally { internalLock.writeLock().unlock(); } }
[ "void", "assignToBlock", "(", "BlockId", "blk", ")", "{", "internalLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "flush", "(", ")", ";", "this", ".", "blk", "=", "blk", ";", "contents", ".", "read", "(", "blk", ")", ";", "pins", "=", "0", ";", "lastLsn", "=", "LogSeqNum", ".", "readFromPage", "(", "contents", ",", "LAST_LSN_OFFSET", ")", ";", "}", "finally", "{", "internalLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Reads the contents of the specified block into the buffer's page. If the buffer was dirty, then the contents of the previous page are first written to disk. @param blk a block ID
[ "Reads", "the", "contents", "of", "the", "specified", "block", "into", "the", "buffer", "s", "page", ".", "If", "the", "buffer", "was", "dirty", "then", "the", "contents", "of", "the", "previous", "page", "are", "first", "written", "to", "disk", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/buffer/Buffer.java#L286-L297
139,887
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/buffer/Buffer.java
Buffer.assignToNew
void assignToNew(String fileName, PageFormatter fmtr) { internalLock.writeLock().lock(); try { flush(); fmtr.format(this); blk = contents.append(fileName); pins = 0; isNew = true; lastLsn = LogSeqNum.DEFAULT_VALUE; } finally { internalLock.writeLock().unlock(); } }
java
void assignToNew(String fileName, PageFormatter fmtr) { internalLock.writeLock().lock(); try { flush(); fmtr.format(this); blk = contents.append(fileName); pins = 0; isNew = true; lastLsn = LogSeqNum.DEFAULT_VALUE; } finally { internalLock.writeLock().unlock(); } }
[ "void", "assignToNew", "(", "String", "fileName", ",", "PageFormatter", "fmtr", ")", "{", "internalLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "flush", "(", ")", ";", "fmtr", ".", "format", "(", "this", ")", ";", "blk", "=", "contents", ".", "append", "(", "fileName", ")", ";", "pins", "=", "0", ";", "isNew", "=", "true", ";", "lastLsn", "=", "LogSeqNum", ".", "DEFAULT_VALUE", ";", "}", "finally", "{", "internalLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Initializes the buffer's page according to the specified formatter, and appends the page to the specified file. If the buffer was dirty, then the contents of the previous page are first written to disk. @param filename the name of the file @param fmtr a page formatter, used to initialize the page
[ "Initializes", "the", "buffer", "s", "page", "according", "to", "the", "specified", "formatter", "and", "appends", "the", "page", "to", "the", "specified", "file", ".", "If", "the", "buffer", "was", "dirty", "then", "the", "contents", "of", "the", "previous", "page", "are", "first", "written", "to", "disk", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/buffer/Buffer.java#L309-L321
139,888
jbossas/remoting-jmx
src/main/java/org/jboss/remotingjmx/protocol/v2/ClientCommon.java
ClientCommon.toIoException
protected IOException toIoException(Exception e) { if (e instanceof IOException) { return (IOException) e; } else { return new IOException("Unexpected failure", e); } }
java
protected IOException toIoException(Exception e) { if (e instanceof IOException) { return (IOException) e; } else { return new IOException("Unexpected failure", e); } }
[ "protected", "IOException", "toIoException", "(", "Exception", "e", ")", "{", "if", "(", "e", "instanceof", "IOException", ")", "{", "return", "(", "IOException", ")", "e", ";", "}", "else", "{", "return", "new", "IOException", "(", "\"Unexpected failure\"", ",", "e", ")", ";", "}", "}" ]
This Exception conversion needs to return the IOException instead of throwing it, this is so that the compiler can detect that for the final Exception check something is actually thrown.
[ "This", "Exception", "conversion", "needs", "to", "return", "the", "IOException", "instead", "of", "throwing", "it", "this", "is", "so", "that", "the", "compiler", "can", "detect", "that", "for", "the", "final", "Exception", "check", "something", "is", "actually", "thrown", "." ]
dbc87bfed47e5bb9e37c355a77ca0ae9a6ea1363
https://github.com/jbossas/remoting-jmx/blob/dbc87bfed47e5bb9e37c355a77ca0ae9a6ea1363/src/main/java/org/jboss/remotingjmx/protocol/v2/ClientCommon.java#L81-L87
139,889
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/recovery/CheckpointTask.java
CheckpointTask.createCheckpoint
public void createCheckpoint() { if (logger.isLoggable(Level.INFO)) logger.info("Start creating checkpoint"); if (MY_METHOD == METHOD_MONITOR) { if (VanillaDb.txMgr().getNextTxNum() - lastTxNum > TX_COUNT_TO_CHECKPOINT) { Transaction tx = VanillaDb.txMgr().newTransaction( Connection.TRANSACTION_SERIALIZABLE, false); VanillaDb.txMgr().createCheckpoint(tx); tx.commit(); lastTxNum = VanillaDb.txMgr().getNextTxNum(); } } else if (MY_METHOD == METHOD_PERIODIC) { Transaction tx = VanillaDb.txMgr().newTransaction( Connection.TRANSACTION_SERIALIZABLE, false); VanillaDb.txMgr().createCheckpoint(tx); tx.commit(); } if (logger.isLoggable(Level.INFO)) logger.info("A checkpoint created"); }
java
public void createCheckpoint() { if (logger.isLoggable(Level.INFO)) logger.info("Start creating checkpoint"); if (MY_METHOD == METHOD_MONITOR) { if (VanillaDb.txMgr().getNextTxNum() - lastTxNum > TX_COUNT_TO_CHECKPOINT) { Transaction tx = VanillaDb.txMgr().newTransaction( Connection.TRANSACTION_SERIALIZABLE, false); VanillaDb.txMgr().createCheckpoint(tx); tx.commit(); lastTxNum = VanillaDb.txMgr().getNextTxNum(); } } else if (MY_METHOD == METHOD_PERIODIC) { Transaction tx = VanillaDb.txMgr().newTransaction( Connection.TRANSACTION_SERIALIZABLE, false); VanillaDb.txMgr().createCheckpoint(tx); tx.commit(); } if (logger.isLoggable(Level.INFO)) logger.info("A checkpoint created"); }
[ "public", "void", "createCheckpoint", "(", ")", "{", "if", "(", "logger", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "logger", ".", "info", "(", "\"Start creating checkpoint\"", ")", ";", "if", "(", "MY_METHOD", "==", "METHOD_MONITOR", ")", "{", "if", "(", "VanillaDb", ".", "txMgr", "(", ")", ".", "getNextTxNum", "(", ")", "-", "lastTxNum", ">", "TX_COUNT_TO_CHECKPOINT", ")", "{", "Transaction", "tx", "=", "VanillaDb", ".", "txMgr", "(", ")", ".", "newTransaction", "(", "Connection", ".", "TRANSACTION_SERIALIZABLE", ",", "false", ")", ";", "VanillaDb", ".", "txMgr", "(", ")", ".", "createCheckpoint", "(", "tx", ")", ";", "tx", ".", "commit", "(", ")", ";", "lastTxNum", "=", "VanillaDb", ".", "txMgr", "(", ")", ".", "getNextTxNum", "(", ")", ";", "}", "}", "else", "if", "(", "MY_METHOD", "==", "METHOD_PERIODIC", ")", "{", "Transaction", "tx", "=", "VanillaDb", ".", "txMgr", "(", ")", ".", "newTransaction", "(", "Connection", ".", "TRANSACTION_SERIALIZABLE", ",", "false", ")", ";", "VanillaDb", ".", "txMgr", "(", ")", ".", "createCheckpoint", "(", "tx", ")", ";", "tx", ".", "commit", "(", ")", ";", "}", "if", "(", "logger", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "logger", ".", "info", "(", "\"A checkpoint created\"", ")", ";", "}" ]
Create a non-quiescent checkpoint.
[ "Create", "a", "non", "-", "quiescent", "checkpoint", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/recovery/CheckpointTask.java#L57-L76
139,890
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/parse/Lexer.java
Lexer.matchKeyword
public boolean matchKeyword(String keyword) { return tok.ttype == StreamTokenizer.TT_WORD && tok.sval.equals(keyword) && keywords.contains(tok.sval); }
java
public boolean matchKeyword(String keyword) { return tok.ttype == StreamTokenizer.TT_WORD && tok.sval.equals(keyword) && keywords.contains(tok.sval); }
[ "public", "boolean", "matchKeyword", "(", "String", "keyword", ")", "{", "return", "tok", ".", "ttype", "==", "StreamTokenizer", ".", "TT_WORD", "&&", "tok", ".", "sval", ".", "equals", "(", "keyword", ")", "&&", "keywords", ".", "contains", "(", "tok", ".", "sval", ")", ";", "}" ]
Returns true if the current token is the specified keyword. @param keyword the keyword string @return true if that keyword is the current token
[ "Returns", "true", "if", "the", "current", "token", "is", "the", "specified", "keyword", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/parse/Lexer.java#L90-L93
139,891
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/parse/Lexer.java
Lexer.eatStringConstant
public String eatStringConstant() { if (!matchStringConstant()) throw new BadSyntaxException(); /* * The input string constant is a quoted string token likes 'str', and * its token type (ttype) is the quote character. So the string * constants are not converted to lower case. */ String s = tok.sval; nextToken(); return s; }
java
public String eatStringConstant() { if (!matchStringConstant()) throw new BadSyntaxException(); /* * The input string constant is a quoted string token likes 'str', and * its token type (ttype) is the quote character. So the string * constants are not converted to lower case. */ String s = tok.sval; nextToken(); return s; }
[ "public", "String", "eatStringConstant", "(", ")", "{", "if", "(", "!", "matchStringConstant", "(", ")", ")", "throw", "new", "BadSyntaxException", "(", ")", ";", "/*\r\n\t\t * The input string constant is a quoted string token likes 'str', and\r\n\t\t * its token type (ttype) is the quote character. So the string\r\n\t\t * constants are not converted to lower case.\r\n\t\t */", "String", "s", "=", "tok", ".", "sval", ";", "nextToken", "(", ")", ";", "return", "s", ";", "}" ]
Throws an exception if the current token is not a string. Otherwise, returns that string and moves to the next token. @return the string value of the current token
[ "Throws", "an", "exception", "if", "the", "current", "token", "is", "not", "a", "string", ".", "Otherwise", "returns", "that", "string", "and", "moves", "to", "the", "next", "token", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/parse/Lexer.java#L142-L153
139,892
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/parse/Lexer.java
Lexer.eatId
public String eatId() { if (!matchId()) throw new BadSyntaxException(); String s = tok.sval; nextToken(); return s; }
java
public String eatId() { if (!matchId()) throw new BadSyntaxException(); String s = tok.sval; nextToken(); return s; }
[ "public", "String", "eatId", "(", ")", "{", "if", "(", "!", "matchId", "(", ")", ")", "throw", "new", "BadSyntaxException", "(", ")", ";", "String", "s", "=", "tok", ".", "sval", ";", "nextToken", "(", ")", ";", "return", "s", ";", "}" ]
Throws an exception if the current token is not an identifier. Otherwise, returns the identifier string and moves to the next token. @return the string value of the current token
[ "Throws", "an", "exception", "if", "the", "current", "token", "is", "not", "an", "identifier", ".", "Otherwise", "returns", "the", "identifier", "string", "and", "moves", "to", "the", "next", "token", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/parse/Lexer.java#L174-L180
139,893
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/metadata/statistics/SampledHistogramBuilder.java
SampledHistogramBuilder.sample
public void sample(Record rec) { totalRecs++; if (samples.size() < MAX_SAMPLES) { samples.add(new Sample(rec, schema)); updateNewValueInterval(rec); } else { double flip = random.nextDouble(); if (flip < (double) MAX_SAMPLES / totalRecs) { samples.set(random.nextInt(MAX_SAMPLES), new Sample(rec, schema)); updateNewValueInterval(rec); } } }
java
public void sample(Record rec) { totalRecs++; if (samples.size() < MAX_SAMPLES) { samples.add(new Sample(rec, schema)); updateNewValueInterval(rec); } else { double flip = random.nextDouble(); if (flip < (double) MAX_SAMPLES / totalRecs) { samples.set(random.nextInt(MAX_SAMPLES), new Sample(rec, schema)); updateNewValueInterval(rec); } } }
[ "public", "void", "sample", "(", "Record", "rec", ")", "{", "totalRecs", "++", ";", "if", "(", "samples", ".", "size", "(", ")", "<", "MAX_SAMPLES", ")", "{", "samples", ".", "add", "(", "new", "Sample", "(", "rec", ",", "schema", ")", ")", ";", "updateNewValueInterval", "(", "rec", ")", ";", "}", "else", "{", "double", "flip", "=", "random", ".", "nextDouble", "(", ")", ";", "if", "(", "flip", "<", "(", "double", ")", "MAX_SAMPLES", "/", "totalRecs", ")", "{", "samples", ".", "set", "(", "random", ".", "nextInt", "(", "MAX_SAMPLES", ")", ",", "new", "Sample", "(", "rec", ",", "schema", ")", ")", ";", "updateNewValueInterval", "(", "rec", ")", ";", "}", "}", "}" ]
Keep a record as a sample, with certain probability. This method is designed to uniformly sample all records of a table under the situation where the total number of records is unknown in advance. A client should call this method when iterating through each record of a table. @param rec the record
[ "Keep", "a", "record", "as", "a", "sample", "with", "certain", "probability", ".", "This", "method", "is", "designed", "to", "uniformly", "sample", "all", "records", "of", "a", "table", "under", "the", "situation", "where", "the", "total", "number", "of", "records", "is", "unknown", "in", "advance", ".", "A", "client", "should", "call", "this", "method", "when", "iterating", "through", "each", "record", "of", "a", "table", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/metadata/statistics/SampledHistogramBuilder.java#L355-L368
139,894
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/multibuffer/MultiBufferProductPlan.java
MultiBufferProductPlan.open
@Override public Scan open() { TempTable tt = copyRecordsFrom(rhs); TableInfo ti = tt.getTableInfo(); Scan leftscan = lhs.open(); return new MultiBufferProductScan(leftscan, ti, tx); }
java
@Override public Scan open() { TempTable tt = copyRecordsFrom(rhs); TableInfo ti = tt.getTableInfo(); Scan leftscan = lhs.open(); return new MultiBufferProductScan(leftscan, ti, tx); }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "TempTable", "tt", "=", "copyRecordsFrom", "(", "rhs", ")", ";", "TableInfo", "ti", "=", "tt", ".", "getTableInfo", "(", ")", ";", "Scan", "leftscan", "=", "lhs", ".", "open", "(", ")", ";", "return", "new", "MultiBufferProductScan", "(", "leftscan", ",", "ti", ",", "tx", ")", ";", "}" ]
A scan for this query is created and returned, as follows. First, the method materializes its RHS query. It then determines the optimal chunk size, based on the size of the materialized file and the number of available buffers. It creates a chunk plan for each chunk, saving them in a list. Finally, it creates a multiscan for this list of plans, and returns that scan. @see Plan#open()
[ "A", "scan", "for", "this", "query", "is", "created", "and", "returned", "as", "follows", ".", "First", "the", "method", "materializes", "its", "RHS", "query", ".", "It", "then", "determines", "the", "optimal", "chunk", "size", "based", "on", "the", "size", "of", "the", "materialized", "file", "and", "the", "number", "of", "available", "buffers", ".", "It", "creates", "a", "chunk", "plan", "for", "each", "chunk", "saving", "them", "in", "a", "list", ".", "Finally", "it", "creates", "a", "multiscan", "for", "this", "list", "of", "plans", "and", "returns", "that", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/multibuffer/MultiBufferProductPlan.java#L69-L75
139,895
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java
RemoteResultSetImpl.next
@Override public boolean next() throws RemoteException { try { return s.next(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
java
@Override public boolean next() throws RemoteException { try { return s.next(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
[ "@", "Override", "public", "boolean", "next", "(", ")", "throws", "RemoteException", "{", "try", "{", "return", "s", ".", "next", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "rconn", ".", "rollback", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Moves to the next record in the result set, by moving to the next record in the saved scan. @see org.vanilladb.core.remote.jdbc.RemoteResultSet#next()
[ "Moves", "to", "the", "next", "record", "in", "the", "result", "set", "by", "moving", "to", "the", "next", "record", "in", "the", "saved", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java#L63-L71
139,896
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java
RemoteResultSetImpl.getInt
@Override public int getInt(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (Integer) s.getVal(fldName).castTo(INTEGER).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
java
@Override public int getInt(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (Integer) s.getVal(fldName).castTo(INTEGER).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
[ "@", "Override", "public", "int", "getInt", "(", "String", "fldName", ")", "throws", "RemoteException", "{", "try", "{", "fldName", "=", "fldName", ".", "toLowerCase", "(", ")", ";", "// to ensure case-insensitivity\r", "return", "(", "Integer", ")", "s", ".", "getVal", "(", "fldName", ")", ".", "castTo", "(", "INTEGER", ")", ".", "asJavaVal", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "rconn", ".", "rollback", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Returns the integer value of the specified field, by returning the corresponding value on the saved scan. @see org.vanilladb.core.remote.jdbc.RemoteResultSet#getInt(java.lang.String)
[ "Returns", "the", "integer", "value", "of", "the", "specified", "field", "by", "returning", "the", "corresponding", "value", "on", "the", "saved", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java#L79-L88
139,897
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java
RemoteResultSetImpl.getLong
@Override public long getLong(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (Long) s.getVal(fldName).castTo(BIGINT).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
java
@Override public long getLong(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (Long) s.getVal(fldName).castTo(BIGINT).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
[ "@", "Override", "public", "long", "getLong", "(", "String", "fldName", ")", "throws", "RemoteException", "{", "try", "{", "fldName", "=", "fldName", ".", "toLowerCase", "(", ")", ";", "// to ensure case-insensitivity\r", "return", "(", "Long", ")", "s", ".", "getVal", "(", "fldName", ")", ".", "castTo", "(", "BIGINT", ")", ".", "asJavaVal", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "rconn", ".", "rollback", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Returns the long value of the specified field, by returning the corresponding value on the saved scan. @see org.vanilladb.core.remote.jdbc.RemoteResultSet#getLong(java.lang.String)
[ "Returns", "the", "long", "value", "of", "the", "specified", "field", "by", "returning", "the", "corresponding", "value", "on", "the", "saved", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java#L96-L105
139,898
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java
RemoteResultSetImpl.getDouble
@Override public double getDouble(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (Double) s.getVal(fldName).castTo(DOUBLE).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
java
@Override public double getDouble(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (Double) s.getVal(fldName).castTo(DOUBLE).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
[ "@", "Override", "public", "double", "getDouble", "(", "String", "fldName", ")", "throws", "RemoteException", "{", "try", "{", "fldName", "=", "fldName", ".", "toLowerCase", "(", ")", ";", "// to ensure case-insensitivity\r", "return", "(", "Double", ")", "s", ".", "getVal", "(", "fldName", ")", ".", "castTo", "(", "DOUBLE", ")", ".", "asJavaVal", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "rconn", ".", "rollback", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Returns the double value of the specified field, by returning the corresponding value on the saved scan. @see org.vanilladb.core.remote.jdbc.RemoteResultSet#getDouble(java.lang.String)
[ "Returns", "the", "double", "value", "of", "the", "specified", "field", "by", "returning", "the", "corresponding", "value", "on", "the", "saved", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java#L113-L122
139,899
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java
RemoteResultSetImpl.getString
@Override public String getString(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (String) s.getVal(fldName).castTo(VARCHAR).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
java
@Override public String getString(String fldName) throws RemoteException { try { fldName = fldName.toLowerCase(); // to ensure case-insensitivity return (String) s.getVal(fldName).castTo(VARCHAR).asJavaVal(); } catch (RuntimeException e) { rconn.rollback(); throw e; } }
[ "@", "Override", "public", "String", "getString", "(", "String", "fldName", ")", "throws", "RemoteException", "{", "try", "{", "fldName", "=", "fldName", ".", "toLowerCase", "(", ")", ";", "// to ensure case-insensitivity\r", "return", "(", "String", ")", "s", ".", "getVal", "(", "fldName", ")", ".", "castTo", "(", "VARCHAR", ")", ".", "asJavaVal", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "rconn", ".", "rollback", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Returns the string value of the specified field, by returning the corresponding value on the saved scan. @see org.vanilladb.core.remote.jdbc.RemoteResultSet#getInt(java.lang.String)
[ "Returns", "the", "string", "value", "of", "the", "specified", "field", "by", "returning", "the", "corresponding", "value", "on", "the", "saved", "scan", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/jdbc/RemoteResultSetImpl.java#L130-L139