code
stringlengths
73
34.1k
label
stringclasses
1 value
protected void shutdown() throws InterruptedException { if (m_deadConnectionFuture != null) { m_deadConnectionFuture.cancel(false); try {m_deadConnectionFuture.get();} catch (Throwable t) {} } if (m_topologyCheckFuture != null) { m_topologyCheckFuture.cancel(f...
java
public void sendEOLMessage(int partitionId) { final long initiatorHSId = m_cartographer.getHSIdForMaster(partitionId); Iv2EndOfLogMessage message = new Iv2EndOfLogMessage(partitionId); m_mailbox.send(initiatorHSId, message); }
java
private ClientResponseImpl getMispartitionedErrorResponse(StoredProcedureInvocation task, Procedure catProc, Exception ex) { Object invocationParameter = null; try { invocationParameter = task.getParameterAtIndex(catProc.getPartitionparameter()); } catch (Exception ex2) {...
java
public boolean ceaseAllPublicFacingTrafficImmediately() { try { if (m_acceptor != null) { // This call seems to block until the shutdown is done // which is good becasue we assume there will be no new // connections afterward m_acceptor...
java
void processMigratePartitionLeaderTask(MigratePartitionLeaderMessage message) { synchronized(m_lock) { //start MigratePartitionLeader service if (message.startMigratingPartitionLeaders()) { if (m_migratePartitionLeaderExecutor == null) { m_migrateParti...
java
public VoltTable[] run(SystemProcedureExecutionContext ctx) { // Choose the lowest site ID on this host to actually flip the bit VoltDBInterface voltdb = VoltDB.instance(); OperationMode opMode = voltdb.getMode(); if (ctx.isLowestSiteId()) { ZooKeeper zk = voltdb.getHostMess...
java
private static File getNativeLibraryFile(String libname) { // for now, arch is always x86_64 String pathFormat = "/org/voltdb/native/%s/x86_64"; String libPath = null; String osName = System.getProperty("os.name").toLowerCase(); if (osName.contains("mac")) { libPath ...
java
public static void writeString(String value, ByteBuffer buf) { if (value == null) { buf.putInt(VoltType.NULL_STRING_LENGTH); return; } byte[] strbytes = value.getBytes(Constants.UTF8ENCODING); int len = strbytes.length; buf.putInt(len); buf.put(s...
java
public static void writeVarbinary(byte[] bytes, ByteBuffer buf) throws IOException { if (bytes == null) { buf.putInt(VoltType.NULL_STRING_LENGTH); return; } buf.putInt(bytes.length); buf.put(bytes); }
java
private static long getMaxBidId(Client client) { long currentMaxBidId = 0; try { VoltTable vt = client.callProcedure("@AdHoc", "select max(id) from bids").getResults()[0]; vt.advanceRow(); currentMaxBidId = vt.getLong(0); if (vt.wasNull()) { ...
java
@Override public void run() { long bidId = m_bidId++; long advertiserId = Math.abs(m_rand.nextLong()) % NUM_ADVERTISERS; GeographyValue bidRegion = Regions.pickRandomRegion(); TimestampType bidStartTime = new TimestampType(); TimestampType bidEndTime = new TimestampType( ...
java
String getName() { int idx = mName.lastIndexOf('/'); return (idx > 0) ? mName.substring(idx) : mName; }
java
public AbstractExpression singlePartitioningExpression() { AbstractExpression e = singlePartitioningExpressionForReport(); if (e != null && isUsefulPartitioningExpression(e)) { return e; } return null; }
java
void analyzeTablePartitioning(Collection<StmtTableScan> collection) throws PlanningErrorException { m_countOfPartitionedTables = 0; // Do we have a need for a distributed scan at all? // Iterate over the tables to collect partition columns. for (StmtTableScan tableScan : ...
java
public void resetAnalysisState() { m_countOfIndependentlyPartitionedTables = -1; m_countOfPartitionedTables = -1; m_fullColumnName = null; m_inferredExpression.clear(); m_inferredParameterIndex = -1; m_inferredValue = null; m_isDML = false; setJoinValid(tr...
java
public boolean callProcedure(Invocation invocation, ProcedureCallback callback) { try { boolean result = m_importServerAdapter.callProcedure(this, m_backPressurePredicate, ...
java
@Override public void rateLimitedLog(Level level, Throwable cause, String format, Object... args) { m_logger.rateLimitedLog(LOG_SUPPRESSION_INTERVAL_SECONDS, level, cause, format, args); }
java
protected void trace(Throwable t, String msgFormat, Object... args) { m_logger.trace(String.format(msgFormat, args), t); }
java
@Override public void warn(Throwable t, String msgFormat, Object... args) { m_logger.warn(String.format(msgFormat, args), t); }
java
public void add(Right right) { if (isFull) { return; } if (right.isFull) { clear(); isFull = true; return; } isFullSelect |= right.isFullSelect; isFullInsert |= right.isFullInsert; isFullUpdate |= ri...
java
public void remove(SchemaObject object, Right right) { if (right.isFull) { clear(); return; } if (isFull) { isFull = false; isFullSelect = isFullInsert = isFullUpdate = isFullReferences = isFullDelete = true; } i...
java
static boolean containsAllColumns(OrderedHashSet columnSet, Table table, boolean[] columnCheckList) { for (int i = 0; i < columnCheckList.length; i++) { if (columnCheckList[i]) { if (columnSet == null) { return false; ...
java
String getTableRightsSQL(Table table) { StringBuffer sb = new StringBuffer(); if (isFull) { return Tokens.T_ALL; } if (isFullSelect) { sb.append(Tokens.T_SELECT); sb.append(','); } else if (selectColumnSet != null) { sb.append(To...
java
public synchronized int next() { while(nextPort <= MAX_STATIC_PORT) { int port = nextPort++; if (MiscUtils.isBindable(port)) { return port; } } throw new RuntimeException("Exhausted all possible ports"); }
java
static Range<Long> range(long start, long end) { return Range.closed(start, end).canonical(DiscreteDomain.longs()); }
java
private static long start(Range<Long> range) { if (range.lowerBoundType() == BoundType.OPEN) { return DiscreteDomain.longs().next(range.lowerEndpoint()); } else { return range.lowerEndpoint(); } }
java
private static long end(Range<Long> range) { if (range.upperBoundType() == BoundType.OPEN) { return DiscreteDomain.longs().previous(range.upperEndpoint()); } else { return range.upperEndpoint(); } }
java
public void append(long start, long end) { assert(start <= end && (m_map.isEmpty() || start > end(m_map.span()))); addRange(start, end); }
java
public int truncate(long newTruncationPoint) { int truncated = 0; if (m_map.isEmpty()) { m_map.add(range(newTruncationPoint, newTruncationPoint)); m_hasSentinel = true; return truncated; } if (newTruncationPoint < getFirstSeqNo()) { return ...
java
public void truncateAfter(long newTruncationPoint) { if (size() == 0) { m_map.add(range(newTruncationPoint, newTruncationPoint)); m_hasSentinel = true; return; } if (newTruncationPoint > getLastSeqNo()) { return; } final Iterator<Ra...
java
public Pair<Long, Long> getRangeContaining(long seq) { Range<Long> range = m_map.rangeContaining(seq); if (range != null) { return new Pair<Long, Long>(start(range), end(range)); } return null; }
java
public Pair<Long, Long> getFirstGap() { if (m_map.isEmpty() || size() < 2) { return null; } Iterator<Range<Long>> iter = m_map.asRanges().iterator(); long start = end(iter.next()) + 1; long end = start(iter.next()) - 1; return new Pair<Long, Long>(start, end);...
java
public int sizeInSequence() { int sequence = 0; if (m_map.isEmpty()) { return sequence; } final Iterator<Range<Long>> iter = m_map.asRanges().iterator(); while (iter.hasNext()) { Range<Long> range = iter.next(); sequence += end(range) - start(r...
java
void sendEvent(CallEvent call) throws NoConnectionsException, IOException, ProcCallException { if (call.endTS == null) { assert(call.startTS != null); // null callback isn't ideal for production code, but errors are tracked // here through client stats so we'll let it slide ...
java
public void write(char[] c, int off, int len) { ensureRoom(len * 2); for (int i = off; i < len; i++) { int v = c[i]; buffer[count++] = (byte) (v >>> 8); buffer[count++] = (byte) v; } }
java
long executeSQL(boolean isFinal) throws VoltAbortException { long count = 0; VoltTable[] results = voltExecuteSQL(isFinal); for (VoltTable result : results) { long dmlUpdated = result.asScalarLong(); if (dmlUpdated == 0) { throw new VoltAbortException("Ins...
java
protected static boolean _isCloseSurrogateMethod(final Class clazz, final Method method) { return ((Connection.class.isAssignableFrom( clazz) || Statement.class.isAssignableFrom( clazz)) && "close".equals(method.getName())); }
java
protected static Class[] _computeProxiedInterface(Object delegate) { // NOTE: Order is important for XXXStatement. if (delegate instanceof Array) { return arrayInterface; } else if (delegate instanceof Connection) { return connectionInterface; } else if (delegat...
java
protected void closeConnectionSurrogate() throws Throwable { ConnectionPool connectionPool = this.connectionPool; if (connectionPool == null) { // CHECKME: policy? // pool has "disapeared" or was never provided (why?): should // "really" close the connection since ...
java
public static String jsonifyClusterTrackers(Pair<Long, Long> lastConsumerUniqueIds, Map<Integer, Map<Integer, DRSiteDrIdTracker>> allProducerTrackers) throws JSONException { JSONStringer stringer = new JSONStringer(); stringer.object(); stringe...
java
public static Map<Integer, Map<Integer, DRSiteDrIdTracker>> dejsonifyClusterTrackers(final String jsonData, boolean resetLastReceivedLogIds) throws JSONException { Map<Integer, Map<Integer, DRSiteDrIdTracker>> producerTrackers = new HashMap<>(); JSONObject clusterData = new JSONObject(jsonData)...
java
public static void mergeTrackers(Map<Integer, Map<Integer, DRSiteDrIdTracker>> base, Map<Integer, Map<Integer, DRSiteDrIdTracker>> add) { for (Map.Entry<Integer, Map<Integer, DRSiteDrIdTracker>> clusterEntry : add.entrySet()) { final Map<Integer, DRSiteDrIdTr...
java
public JSONWriter array(Iterable<? extends JSONString> iter) throws JSONException { array(); for (JSONString element : iter) { value(element); } endArray(); return this; }
java
public JSONWriter keySymbolValuePair(String aKey, String aValue) throws JSONException { assert(aKey != null); assert(m_mode == 'k'); // The key should not have already been seen in this scope. assert(m_scopeStack[m_top].add(aKey)); try { m_writer.write(m_...
java
public static byte[] gunzipBytes(byte[] compressedBytes) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream((int)(compressedBytes.length * 1.5)); InflaterOutputStream dos = new InflaterOutputStream(bos); dos.write(compressedBytes); dos.close(); return ...
java
public Object[] getGroupData(Object[] data) { if (isSimpleAggregate) { if (simpleAggregateData == null) { simpleAggregateData = data; return null; } return simpleAggregateData; } RowIterator it = groupIndex.findFirstRow(sess...
java
public void addConstraint(Constraint c) { int index = c.getConstraintType() == Constraint.PRIMARY_KEY ? 0 : constraintList .length; constraintList = (...
java
Constraint getUniqueConstraintForColumns(int[] cols) { for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.isUniqueWithColumns(cols)) { return c; } } return null; }
java
Constraint getUniqueConstraintForColumns(int[] mainTableCols, int[] refTableCols) { for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; // A VoltDB extension -- Don't consider non-column expression indexes for this purpose ...
java
Constraint getFKConstraintForColumns(Table tableMain, int[] mainCols, int[] refCols) { for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.isEquivalent(tableMain, mainCols, this, refCols)) { ...
java
public Constraint getUniqueOrPKConstraintForIndex(Index index) { for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.getMainIndex() == index && (c.getConstraintType() == Constraint.UNIQUE || ...
java
int getNextConstraintIndex(int from, int type) { for (int i = from, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.getConstraintType() == type) { return i; } } return -1; }
java
public void addColumn(ColumnSchema column) { String name = column.getName().name; if (findColumn(name) >= 0) { throw Error.error(ErrorCode.X_42504, name); } if (column.isIdentity()) { if (identityColumn != -1) { throw Error.error(ErrorCode.X_425...
java
void checkColumnsMatch(int[] col, Table other, int[] othercol) { for (int i = 0; i < col.length; i++) { Type type = colTypes[col[i]]; Type otherType = other.colTypes[othercol[i]]; if (type.typeComparisonGroup != otherType.typeComparisonGroup) { throw Er...
java
OrderedHashSet getDependentConstraints(int colIndex) { OrderedHashSet set = new OrderedHashSet(); for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.hasColumnOnly(colIndex)) { set.add(c); } ...
java
OrderedHashSet getContainingConstraints(int colIndex) { OrderedHashSet set = new OrderedHashSet(); for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.hasColumnPlus(colIndex)) { set.add(c); } ...
java
OrderedHashSet getDependentConstraints(Constraint constraint) { OrderedHashSet set = new OrderedHashSet(); for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.getConstraintType() == Constraint.MAIN) { if (c.cor...
java
void checkColumnInFKConstraint(int colIndex, int actionType) { for (int i = 0, size = constraintList.length; i < size; i++) { Constraint c = constraintList[i]; if (c.getConstraintType() == Constraint.FOREIGN_KEY && c.hasColumn(colIndex) && (actio...
java
public int getColumnIndex(String name) { int i = findColumn(name); if (i == -1) { throw Error.error(ErrorCode.X_42501, name); } return i; }
java
void setDefaultExpression(int columnIndex, Expression def) { ColumnSchema column = getColumn(columnIndex); column.setDefaultExpression(def); setColumnTypeVars(columnIndex); }
java
void resetDefaultsFlag() { hasDefaultValues = false; for (int i = 0; i < colDefaults.length; i++) { hasDefaultValues = hasDefaultValues || colDefaults[i] != null; } }
java
Index getIndexForColumn(int col) { int i = bestIndexForColumn[col]; return i == -1 ? null : this.indexList[i]; }
java
public void createPrimaryKey(HsqlName indexName, int[] columns, boolean columnsNotNull) { if (primaryKeyCols != null) { throw Error.runtimeError(ErrorCode.U_S0500, "Table"); } if (columns == null) { columns = ValuePool.emptyIntArray; ...
java
void addTrigger(TriggerDef td, HsqlName otherName) { int index = triggerList.length; if (otherName != null) { int pos = getTriggerIndex(otherName.name); if (pos != -1) { index = pos + 1; } } triggerList = (TriggerDef[]) ArrayUtil.to...
java
TriggerDef getTrigger(String name) { for (int i = triggerList.length - 1; i >= 0; i--) { if (triggerList[i].name.name.equals(name)) { return triggerList[i]; } } return null; }
java
void removeTrigger(String name) { TriggerDef td = null; for (int i = 0; i < triggerList.length; i++) { td = triggerList[i]; if (td.name.name.equals(name)) { td.terminate(); triggerList = (TriggerDef[]) ArrayUtil.toAdjustedAr...
java
void releaseTriggers() { // look in each trigger list of each type of trigger for (int i = 0; i < TriggerDef.NUM_TRIGS; i++) { for (int j = 0; j < triggerLists[i].length; j++) { triggerLists[i][j].terminate(); } triggerLists[i] = TriggerDef.emptyArra...
java
int getIndexIndex(String indexName) { Index[] indexes = indexList; for (int i = 0; i < indexes.length; i++) { if (indexName.equals(indexes[i].getName().name)) { return i; } } // no such index return -1; }
java
Index getIndex(String indexName) { Index[] indexes = indexList; int i = getIndexIndex(indexName); return i == -1 ? null : indexes[i]; }
java
int getConstraintIndex(String constraintName) { for (int i = 0, size = constraintList.length; i < size; i++) { if (constraintList[i].getName().name.equals(constraintName)) { return i; } } return -1; }
java
public Constraint getConstraint(String constraintName) { int i = getConstraintIndex(constraintName); return (i < 0) ? null : constraintList[i]; }
java
Index createIndexForColumns(int[] columns) { HsqlName indexName = database.nameManager.newAutoName("IDX_T", getSchemaName(), getName(), SchemaObject.INDEX); try { Index index = createAndAddIndexStructure(indexName, columns, null, null, false, false, false, false...
java
void enforceRowConstraints(Session session, Object[] data) { for (int i = 0; i < defaultColumnMap.length; i++) { Type type = colTypes[i]; data[i] = type.convertToTypeLimits(session, data[i]); if (type.isDomainType()) { Constraint[] constraints = ...
java
Index getIndexForColumns(int[] cols) { int i = bestIndexForColumn[cols[0]]; if (i > -1) { return indexList[i]; } switch (tableType) { case TableBase.SYSTEM_SUBQUERY : case TableBase.SYSTEM_TABLE : case TableBase.VIEW_TABLE : ...
java
Index getIndexForColumns(OrderedIntHashSet set) { int maxMatchCount = 0; Index selected = null; if (set.isEmpty()) { return null; } for (int i = 0, count = indexList.length; i < count; i++) { Index currentindex = getIndex(i); int[] in...
java
public final int[] getIndexRootsArray() { PersistentStore store = database.persistentStoreCollection.getStore(this); int[] roots = new int[getIndexCount()]; for (int i = 0; i < getIndexCount(); i++) { CachedObject accessor = store.getAccessor(indexList[i]); ...
java
void setIndexRoots(Session session, String s) { if (!isCached) { throw Error.error(ErrorCode.X_42501, tableName.name); } ParserDQL p = new ParserDQL(session, new Scanner(s)); int[] roots = new int[getIndexCount()]; p.read(); for (int i = 0; i < get...
java
public void dropIndex(Session session, String indexname) { // find the array index for indexname and remove int todrop = getIndexIndex(indexname); indexList = (Index[]) ArrayUtil.toAdjustedArray(indexList, null, todrop, -1); for (int i = 0; i < indexList.length; i++) {...
java
void insertRow(Session session, PersistentStore store, Object[] data) { setIdentityColumn(session, data); if (triggerLists[Trigger.INSERT_BEFORE].length != 0) { fireBeforeTriggers(session, Trigger.INSERT_BEFORE, null, data, null); } if (isVie...
java
void insertIntoTable(Session session, Result result) { PersistentStore store = session.sessionData.getRowStore(this); RowSetNavigator nav = result.initialiseNavigator(); while (nav.hasNext()) { Object[] data = nav.getNext(); Object[] newData = (Object[...
java
private Row insertNoCheck(Session session, PersistentStore store, Object[] data) { Row row = (Row) store.getNewCachedObject(session, data); store.indexRow(session, row); session.addInsertAction(this, row); return row; }
java
public int insertSys(PersistentStore store, Result ins) { RowSetNavigator nav = ins.getNavigator(); int count = 0; while (nav.hasNext()) { insertSys(store, nav.getNext()); count++; } return count; }
java
void insertResult(PersistentStore store, Result ins) { RowSetNavigator nav = ins.initialiseNavigator(); while (nav.hasNext()) { Object[] data = nav.getNext(); Object[] newData = (Object[]) ArrayUtil.resizeArrayIfDifferent(data, getColumnCount...
java
public void insertFromScript(PersistentStore store, Object[] data) { systemUpdateIdentityValue(data); insertData(store, data); }
java
protected void systemUpdateIdentityValue(Object[] data) { if (identityColumn != -1) { Number id = (Number) data[identityColumn]; if (id != null) { identitySequence.systemUpdate(id.longValue()); } } }
java
void deleteNoRefCheck(Session session, Row row) { Object[] data = row.getData(); fireBeforeTriggers(session, Trigger.DELETE_BEFORE, data, null, null); if (isView) { return; } deleteNoCheck(session, row); }
java
private void deleteNoCheck(Session session, Row row) { if (row.isDeleted(session)) { return; } session.addDeleteAction(this, row); }
java
public void deleteNoCheckFromLog(Session session, Object[] data) { Row row = null; PersistentStore store = session.sessionData.getRowStore(this); if (hasPrimaryKey()) { RowIterator it = getPrimaryIndex().findFirstRow(session, store, data, primaryKeyCol...
java
public void addTTL(int ttlValue, String ttlUnit, String ttlColumn, int batchSize, int maxFrequency, String streamName) { dropTTL(); timeToLive = new TimeToLiveVoltDB(ttlValue, ttlUnit, getColumn(findColumn(ttlColumn)), batchSize, maxFrequency, streamName); }
java
static public int getStart(int field) { Integer iObject = (Integer) starts.get(new Integer(field)); if (iObject == null) { throw new IllegalArgumentException( RB.singleton.getString(RB.UNEXPECTED_HEADER_KEY, field)); } return iObject.intValue(); }
java
VoltTable executePrecompiledSQL(Statement catStmt, Object[] params, boolean replicated) throws VoltAbortException { // Create a SQLStmt instance on the fly // This is unusual to do, as they are typically required to be final instance variables. // This only works because the SQL text...
java
protected static void printLogStatic(String className, String msg, Object...args) { if (args != null) { msg = String.format(msg, args); } String header = String.format("%s [%s] ", ZonedDateTime.now().format(TIME_FORMAT), className); System.out...
java
StatementSimple compileSetStatement(RangeVariable rangeVars[]) { read(); OrderedHashSet colNames = new OrderedHashSet(); HsqlArrayList exprList = new HsqlArrayList(); readSetClauseList(rangeVars, colNames, exprList); if (exprList.size() > 1) { throw Error.error(E...
java
StatementSchema compileCreateProcedureOrFunction() { int routineType = token.tokenType == Tokens.PROCEDURE ? SchemaObject.PROCEDURE : SchemaObject.FUNCTION; HsqlName name; read(); name = readNewSchemaObjectNameNoCheck(routineType); ...
java
void close(boolean script) { closeLog(); deleteNewAndOldFiles(); writeScript(script); closeAllTextCaches(script); if (cache != null) { cache.close(true); } properties.setProperty(HsqlDatabaseProperties.db_version, Hsql...
java
void deleteNewAndOldFiles() { fa.removeElement(fileName + ".data" + ".old"); fa.removeElement(fileName + ".data" + ".new"); fa.removeElement(fileName + ".backup" + ".new"); fa.removeElement(scriptFileName + ".new"); }
java
boolean forceDefrag() { long megas = properties.getIntegerProperty( HsqlDatabaseProperties.hsqldb_defrag_limit, 200); long defraglimit = megas * 1024L * 1024; long lostSize = cache.freeBlocks.getLostBlocksSize(); return lostSize > defraglimit; }
java
DataFileCache getCache() { /* if (database.isFilesInJar()) { return null; } */ if (cache == null) { cache = new DataFileCache(database, fileName); cache.open(filesReadOnly); } return cache; }
java
void setScriptType(int type) { // OOo related code if (database.isStoredFileAccess()) { return; } // OOo end boolean needsCheckpoint = scriptFormat != type; scriptFormat = type; properties.setProperty(HsqlDatabaseProperties.hsqldb_script_format, ...
java
private void writeScript(boolean full) { deleteNewScript(); //fredt - to do - flag for chache set index ScriptWriterBase scw = ScriptWriterBase.newScriptWriter(database, scriptFileName + ".new", full, true, scriptFormat); scw.writeAll(); scw.close(); }
java