code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public boolean hasDeletedSlots() {
long blkNum = (Long) getVal(OFFSET_LDS_BLOCKID, BIGINT).asJavaVal();
return blkNum != NO_SLOT_BLOCKID ? true : false;
} | 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());
} | 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());
} | java |
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 setTailSolt(RecordId rid) {
setVal(OFFSET_TS_BLOCKID, new BigIntConstant(rid.block().number()));
setVal(OFFSET_TS_RID, new IntegerConstant(rid.id()));
} | 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 nul... | 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);
} | 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 uPla... | java |
public void addField(String fldName, Type type) {
fields.put(fldName, type);
if (myFieldSet != null)
myFieldSet.add(fldName);
} | java |
public void add(String fldName, Schema sch) {
Type type = sch.type(fldName);
addField(fldName, type);
} | java |
public void addAll(Schema sch) {
fields.putAll(sch.fields);
if (myFieldSet != null)
myFieldSet = new TreeSet<String>(fields.keySet());
} | java |
public SortedSet<String> fields() {
// Optimization: Materialize the fields set
if (myFieldSet == null)
myFieldSet = new TreeSet<String>(fields.keySet());
return myFieldSet;
} | 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);
} | 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);
} | java |
@Override
public long blocksAccessed() {
return Index.searchCost(ii.indexType(), new SearchKeyType(schema(), ii.fieldNames()),
tp.recordsOutput(), recordsOutput()) + recordsOutput();
} | 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 fil... | java |
public static Planner newPlanner() {
QueryPlanner qplanner;
UpdatePlanner uplanner;
try {
qplanner = (QueryPlanner) queryPlannerCls.newInstance();
uplanner = (UpdatePlanner) updatePlannerCls.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
r... | 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 o... | 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 Runtim... | 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 n... | 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(fileN... | 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);
}
} | 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, ... | 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 (Do... | java |
@Override
public Scan open() {
Scan s1 = p1.open();
Scan s2 = p2.open();
return new ProductScan(s1, s2);
} | java |
@Override
public boolean next() {
boolean ok = idx.next();
if (ok) {
RecordId rid = idx.getDataRecordId();
ts.moveToRecordId(rid);
}
return ok;
} | java |
@Override
public void beforeFirst() {
currentScan = null;
s1.beforeFirst();
hasMore1 = s1.next();
if (s2 != null) {
s2.beforeFirst();
hasMore2 = s2.next();
}
} | 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.... | java |
public void savePosition() {
RecordId rid1 = s1.getRecordId();
RecordId rid2 = (s2 == null) ? null : s2.getRecordId();
savedPosition = Arrays.asList(rid1, rid2);
} | java |
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 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(t... | 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)
plan... | 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... | 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 BigI... | java |
public void rollback() {
for (TransactionLifecycleListener l : lifecycleListeners) {
l.onTxRollback(this);
}
if (logger.isLoggable(Level.FINE))
logger.fine("transaction " + txNum + " rolled back");
} | java |
@Override
public void setVal(String fldName, Constant val) {
rf.setVal(fldName, val);
} | java |
@Override
public Scan open() {
SortScan ss1 = (SortScan) sp1.open();
SortScan ss2 = (SortScan) sp2.open();
return new MergeJoinScan(ss1, ss2, fldName1, fldName2);
} | 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);
}
} | java |
public void flush(LogSeqNum lsn) {
logMgrLock.lock();
try {
if (lsn.compareTo(lastFlushedLsn) >= 0)
flush();
} finally {
logMgrLock.unlock();
}
} | java |
@Override
public ReversibleIterator<BasicLogRecord> iterator() {
logMgrLock.lock();
try {
flush();
return new LogIterator(currentBlk);
} 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 + rec... | 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
appendNewBloc... | java |
private void appendVal(Constant val) {
myPage.setVal(currentPos, val);
currentPos += Page.size(val);
} | java |
private void finalizeRecord() {
myPage.setVal(currentPos, new IntegerConstant(getLastRecordPosition()));
setPreviousNextRecordPosition(currentPos + pointerSize);
setLastRecordPosition(currentPos);
currentPos += pointerSize;
setNextRecordPosition(currentPos);
// leave for next pointer
currentPos +... | 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));
}... | 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;
} | 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);
} | 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 (i... | 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... | java |
@Override
public boolean next() {
if (prodScan == null)
return false;
while (!prodScan.next())
if (!useNextChunk())
return false;
return true;
} | 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;
} | 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)... | 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 = currentPa... | 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(byteVa... | 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... | 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);
... | 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("Unsppor... | 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 tra... | 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);
}
} | 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;
} | 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;
} | 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;
} | 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);
conti... | 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, search... | 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.curre... | 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 = currentP... | 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;... | 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 = ne... | 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 = getNextCorre... | 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()) {
Con... | 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 = ne... | 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 ... | 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> t... | 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 =... | java |
@Override
public Scan open() {
Scan s = p.open();
return new SelectScan(s, pred);
} | java |
public Retrofit.Builder create(String baseUrl, ObjectMapper objectMapper) {
return new Retrofit.Builder()
.baseUrl(baseUrl)
.client(_okHttpClient)
.addConverterFactory(JacksonConverterFactory.create(objectMapper));
} | java |
public boolean isSatisfied(Record rec) {
for (Term t : terms)
if (!t.isSatisfied(rec))
return false;
return true;
} | 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;
} | 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... | 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) : c... | java |
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 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);
... | 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();
... | java |
boolean isModifiedBy(long txNum) {
internalLock.writeLock().lock();
try {
return modifiedBy.contains(txNum);
} 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();
}
} | 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();
}
} | java |
protected IOException toIoException(Exception e) {
if (e instanceof IOException) {
return (IOException) e;
} else {
return new IOException("Unexpected failure", e);
}
} | 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.TRANSACTIO... | java |
public boolean matchKeyword(String keyword) {
return tok.ttype == StreamTokenizer.TT_WORD && tok.sval.equals(keyword)
&& keywords.contains(tok.sval);
} | 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 = ... | java |
public String eatId() {
if (!matchId())
throw new BadSyntaxException();
String s = tok.sval;
nextToken();
return s;
} | 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),
ne... | java |
@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 boolean next() throws RemoteException {
try {
return s.next();
} 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;
}
} | 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;
}
} | 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;
}
} | 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;
}
} | java |
@Override
public void close() throws RemoteException {
s.close();
if (rconn.getAutoCommit())
rconn.commit();
else
rconn.endStatement();
} | java |
@Override
public boolean next() {
while (true) {
if (rp.next())
return true;
if (current == endBlkNum)
return false;
moveToBlock(current + 1);
}
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.