code
stringlengths
73
34.1k
label
stringclasses
1 value
public static void setCatalogProcedurePartitionInfo(VoltCompiler compiler, Database db, Procedure procedure, ProcedurePartitionData partitionData) throws VoltCompilerException { ParititonDataReturnType partitionClauseData = resolvePartitionData(compiler, db, procedure, partitionData....
java
private KafkaInternalConsumerRunner createConsumerRunner(Properties properties) throws Exception { ClassLoader previous = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); try { Consumer<ByteBuffer, ByteBuffer...
java
void createSchema(HsqlName name, Grantee owner) { SqlInvariants.checkSchemaNameNotSystem(name.name); Schema schema = new Schema(name, owner); schemaMap.add(name.name, schema); }
java
public HsqlName getSchemaHsqlName(String name) { if (name == null) { return defaultSchemaHsqlName; } if (SqlInvariants.INFORMATION_SCHEMA.equals(name)) { return SqlInvariants.INFORMATION_SCHEMA_HSQLNAME; } Schema schema = ((Schema) schemaMap.get(name));...
java
boolean isSchemaAuthorisation(Grantee grantee) { Iterator schemas = allSchemaNameIterator(); while (schemas.hasNext()) { String schemaName = (String) schemas.next(); if (grantee.equals(toSchemaOwner(schemaName))) { return true; } } ...
java
void dropSchemas(Grantee grantee, boolean cascade) { HsqlArrayList list = getSchemas(grantee); Iterator it = list.iterator(); while (it.hasNext()) { Schema schema = (Schema) it.next(); dropSchema(schema.name.name, cascade); } }
java
public HsqlArrayList getAllTables() { Iterator schemas = allSchemaNameIterator(); HsqlArrayList alltables = new HsqlArrayList(); while (schemas.hasNext()) { String name = (String) schemas.next(); HashMappedList current = getTables(name); a...
java
public Table getTable(Session session, String name, String schema) { Table t = null; if (schema == null) { t = findSessionTable(session, name, schema); } if (t == null) { schema = session.getSchemaName(schema); t = findUserTable(session, name, ...
java
public Table getUserTable(Session session, String name, String schema) { Table t = findUserTable(session, name, schema); if (t == null) { throw Error.error(ErrorCode.X_42501, name); } return t; }
java
public Table findUserTable(Session session, String name, String schemaName) { Schema schema = (Schema) schemaMap.get(schemaName); if (schema == null) { return null; } if (session != null) { Table table = session.getLocalTable(name...
java
public Table findSessionTable(Session session, String name, String schemaName) { return session.findSessionTable(name); }
java
void dropTableOrView(Session session, Table table, boolean cascade) { // ft - concurrent session.commit(false); if (table.isView()) { removeSchemaObject(table.getName(), cascade); } else { dropTable(session, table, cascade); } }
java
int getTableIndex(Table table) { Schema schema = (Schema) schemaMap.get(table.getSchemaName().name); if (schema == null) { return -1; } HsqlName name = table.getName(); return schema.tableList.getIndex(name.name); }
java
void recompileDependentObjects(Table table) { OrderedHashSet set = getReferencingObjects(table.getName()); Session session = database.sessionManager.getSysSession(); for (int i = 0; i < set.size(); i++) { HsqlName name = (HsqlName) set.get(i); switch (name.t...
java
Table findUserTableForIndex(Session session, String name, String schemaName) { Schema schema = (Schema) schemaMap.get(schemaName); HsqlName indexName = schema.indexLookup.getName(name); if (indexName == null) { return null; } re...
java
public HsqlName getSchemaHsqlNameNoThrow(String name, HsqlName defaultName) { if (name == null) { return defaultSchemaHsqlName; } if (SqlInvariants.INFORMATION_SCHEMA.equals(name)) { return SqlInvariants.INFORMATION_SCHEMA_HSQLNAME; } Schema schema = ((...
java
public InitiateResponseMessage dedupe(long inUniqueId, TransactionInfoBaseMessage in) { if (in instanceof Iv2InitiateTaskMessage) { final Iv2InitiateTaskMessage init = (Iv2InitiateTaskMessage) in; final StoredProcedureInvocation invocation = init.getStoredProcedureInvocation(); ...
java
public void updateLastSeenUniqueId(long inUniqueId, TransactionInfoBaseMessage in) { if (in instanceof Iv2InitiateTaskMessage && inUniqueId > m_lastSeenUniqueId) { m_lastSeenUniqueId = inUniqueId; } }
java
public VoltMessage poll() { if (m_mustDrain || m_replayEntries.isEmpty()) { return null; } if (m_replayEntries.firstEntry().getValue().isEmpty()) { m_replayEntries.pollFirstEntry(); } // All the drain conditions depend on being blocked, which /...
java
public boolean offer(long inUniqueId, TransactionInfoBaseMessage in) { ReplayEntry found = m_replayEntries.get(inUniqueId); if (in instanceof Iv2EndOfLogMessage) { m_mpiEOLReached = true; return true; } if (in instanceof MultiPartitionParticipantMessage) { ...
java
private void verifyDataCapacity(int size) { if (size+4 > m_dataNetwork.capacity()) { m_dataNetworkOrigin.discard(); m_dataNetworkOrigin = org.voltcore.utils.DBBPool.allocateDirect(size+4); m_dataNetwork = m_dataNetworkOrigin.b(); m_dataNetwork.position(4); ...
java
public void initialize( final int clusterIndex, final long siteId, final int partitionId, final int sitesPerHost, final int hostId, final String hostname, final int drClusterId, final int defaultDrBufferSize, fin...
java
@Override protected void coreLoadCatalog(final long timestamp, final byte[] catalogBytes) throws EEException { int result = ExecutionEngine.ERRORCODE_ERROR; verifyDataCapacity(catalogBytes.length + 100); m_data.clear(); m_data.putInt(Commands.LoadCatalog.m_id); m_data.putLong...
java
@Override public void coreUpdateCatalog(final long timestamp, final boolean isStreamUpdate, final String catalogDiffs) throws EEException { int result = ExecutionEngine.ERRORCODE_ERROR; try { final byte catalogBytes[] = catalogDiffs.getBytes("UTF-8"); verifyDataCapacity(cata...
java
private void sendDependencyTable(final int dependencyId) throws IOException{ final byte[] dependencyBytes = nextDependencyAsBytes(dependencyId); if (dependencyBytes == null) { m_connection.m_socket.getOutputStream().write(Connection.kErrorCode_DependencyNotFound); return; ...
java
boolean enableScoreboard() { assert (s_barrier != null); try { s_barrier.await(3L, TimeUnit.MINUTES); } catch (InterruptedException | BrokenBarrierException |TimeoutException e) { hostLog.error("Cannot re-enable the scoreboard."); s_barrier.reset(); ...
java
synchronized void offer(TransactionTask task) { Iv2Trace.logTransactionTaskQueueOffer(task); TransactionState txnState = task.getTransactionState(); if (!m_backlog.isEmpty()) { /* * This branch happens during regular execution when a multi-part is in progress. ...
java
synchronized int flush(long txnId) { if (tmLog.isDebugEnabled()) { tmLog.debug("Flush backlog with txnId:" + TxnEgo.txnIdToString(txnId) + ", backlog head txnId is:" + (m_backlog.isEmpty()? "empty" : TxnEgo.txnIdToString(m_backlog.getFirst().getTxnId())) )...
java
public synchronized List<TransactionTask> getBacklogTasks() { List<TransactionTask> pendingTasks = new ArrayList<>(); Iterator<TransactionTask> iter = m_backlog.iterator(); // skip the first fragments which is streaming snapshot TransactionTask mpTask = iter.next(); assert (!mpTa...
java
public synchronized void removeMPReadTransactions() { TransactionTask task = m_backlog.peekFirst(); while (task != null && task.getTransactionState().isReadOnly()) { task.getTransactionState().setDone(); flush(task.getTxnId()); task = m_backlog.peekFirst(); }...
java
public List<List<GeographyPointValue>> getRings() { /* * Gets the loops that make up the polygon, with the outer loop first. * Note that we need to convert from XYZPoint to GeographyPointValue. * * Include the loop back to the first vertex. Also, since WKT wants * h...
java
public String toWKT() { StringBuffer sb = new StringBuffer(); sb.append("POLYGON ("); boolean isFirstLoop = true; for (List<XYZPoint> loop : m_loops) { if (!isFirstLoop) { sb.append(", "); } sb.append("("); int startIdx = ...
java
public int getLengthInBytes() { long length = polygonOverheadInBytes(); for (List<XYZPoint> loop : m_loops) { length += loopLengthInBytes(loop.size()); } return (int)length; }
java
private static <T> void diagnoseLoop(List<T> loop, String excpMsgPrf) throws IllegalArgumentException { if (loop == null) { throw new IllegalArgumentException(excpMsgPrf + "a polygon must contain at least one ring " + "(with each ring at least 4 points, including repeated closing...
java
@Deprecated public GeographyValue add(GeographyPointValue offset) { List<List<GeographyPointValue>> newLoops = new ArrayList<>(); for (List<XYZPoint> oneLoop : m_loops) { List<GeographyPointValue> loop = new ArrayList<>(); for (XYZPoint p : oneLoop) { loop.add...
java
public void sync() { if (isClosed) { return; } synchronized (fileStreamOut) { if (needsSync) { if (busyWriting) { forceSync = true; return; } try { fileStreamOu...
java
protected void openFile() { try { FileAccess fa = isDump ? FileUtil.getDefaultInstance() : database.getFileAccess(); OutputStream fos = fa.openOutputStreamElement(outFile); outDescriptor = fa.getFileSync(fos); fileStreamO...
java
private Runnable createRunnableLoggingTask(final Level level, final Object message, final Throwable t) { // While logging, the logger thread temporarily disguises itself as its caller. final String callerThreadName = Thread.currentThread().getName(); final Runnable runnableLoggingTa...
java
private Runnable createRunnableL7dLoggingTask(final Level level, final String key, final Object[] params, final Throwable t) { // While logging, the logger thread temporarily disguises itself as its caller. final String callerThreadName = Thread.currentThread().getName(); final Runn...
java
public static void configure(String xmlConfig, File voltroot) { try { Class<?> loggerClz = Class.forName("org.voltcore.logging.VoltLog4jLogger"); assert(loggerClz != null); Method configureMethod = loggerClz.getMethod("configure", String.class, File.class); config...
java
public T get(String name) { if (m_items == null) { return null; } return m_items.get(name.toUpperCase()); }
java
@Override public Iterator<T> iterator() { if (m_items == null) { m_items = new TreeMap<String, T>(); } return m_items.values().iterator(); }
java
private static void validateMigrateStmt(String sql, VoltXMLElement xmlSQL, Database db) { final Map<String, String> attributes = xmlSQL.attributes; assert attributes.size() == 1; final Table targetTable = db.getTables().get(attributes.get("table")); assert targetTable != null; fi...
java
public String parameterize() { Set<Integer> paramIds = new HashSet<>(); ParameterizationInfo.findUserParametersRecursively(m_xmlSQL, paramIds); m_adhocUserParamsCount = paramIds.size(); m_paramzInfo = null; if (paramIds.size() == 0) { m_paramzInfo = ParameterizationI...
java
public CompiledPlan plan() throws PlanningErrorException { // reset any error message m_recentErrorMsg = null; // what's going to happen next: // If a parameterized statement exists, try to make a plan with it // On success return the plan. // On failure, try the plan...
java
private void harmonizeCommonTableSchemas(CompiledPlan plan) { List<AbstractPlanNode> seqScanNodes = plan.rootPlanGraph.findAllNodesOfClass(SeqScanPlanNode.class); for (AbstractPlanNode planNode : seqScanNodes) { SeqScanPlanNode seqScanNode = (SeqScanPlanNode)planNode; StmtCommonT...
java
public void resetCapacity(int newCapacity, int newPolicy) throws IllegalArgumentException { if (newCapacity != 0 && hashIndex.elementCount > newCapacity) { int surplus = hashIndex.elementCount - newCapacity; surplus += (surplus >> 5); if (surp...
java
protected void initParams(Database database, String baseFileName) { fileName = baseFileName + ".data.tmp"; this.database = database; fa = FileUtil.getDefaultInstance(); int cacheSizeScale = 10; cacheFileScale = 8; Error.printSystemOut("cache_size_scale...
java
public synchronized void close(boolean write) { try { if (dataFile != null) { dataFile.close(); dataFile = null; fa.removeElement(fileName); } } catch (Throwable e) { database.logger.appLog.logContext(e, null); ...
java
private AbstractPlanNode recursivelyApply(AbstractPlanNode plan, int childIdx) { // If this is an insert plan node, then try to // inline it. There will only ever by one insert // node, so if we can't inline it we just return the // given plan. if (plan instanceof InsertPlanNode...
java
static void updateTableNames(List<ParsedColInfo> src, String tblName) { src.forEach(ci -> ci.updateTableName(tblName, tblName).toTVE(ci.m_index, ci.m_index)); }
java
ParsedSelectStmt rewriteAsMV(Table view) { m_groupByColumns.clear(); m_distinctGroupByColumns = null; m_groupByExpressions.clear(); m_distinctProjectSchema = null; m_distinct = m_hasAggregateExpression = m_hasComplexGroupby = m_hasComplexAgg = false; // Resets paramsBy* f...
java
public StmtTargetTableScan generateStmtTableScan(Table view) { StmtTargetTableScan st = new StmtTargetTableScan(view); m_displayColumns.forEach(ci -> st.resolveTVE((TupleValueExpression)(ci.m_expression))); defineTableScanByAlias(view.getTypeName(), st); return st; }
java
public void switchOptimalSuiteForAvgPushdown () { m_displayColumns = m_avgPushdownDisplayColumns; m_aggResultColumns = m_avgPushdownAggResultColumns; m_groupByColumns = m_avgPushdownGroupByColumns; m_distinctGroupByColumns = m_avgPushdownDistinctGroupByColumns; m_orderColumns = m...
java
private void prepareMVBasedQueryFix() { // ENG-5386: Edge cases query returning correct answers with // aggregation push down does not need reAggregation work. if (m_hasComplexGroupby) { m_mvFixInfo.setEdgeCaseQueryNoFixNeeded(false); } // Handle joined query case c...
java
private void placeTVEsinColumns () { // Build the association between the table column with its index Map<AbstractExpression, Integer> aggTableIndexMap = new HashMap<>(); Map<Integer, ParsedColInfo> indexToColumnMap = new HashMap<>(); int index = 0; for (ParsedColInfo col : m_agg...
java
private void insertAggExpressionsToAggResultColumns ( List<AbstractExpression> aggColumns, ParsedColInfo cookedCol) { for (AbstractExpression expr: aggColumns) { assert(expr instanceof AggregateExpression); if (expr.hasSubquerySubexpression()) { throw new Plan...
java
private static void insertToColumnList( List<ParsedColInfo> columnList, List<ParsedColInfo> newCols) { for (ParsedColInfo col : newCols) { if (!columnList.contains(col)) { columnList.add(col); } } }
java
private void findAllTVEs( AbstractExpression expr, List<TupleValueExpression> tveList) { if (!isNewtoColumnList(m_aggResultColumns, expr)) { return; } if (expr instanceof TupleValueExpression) { tveList.add((TupleValueExpression) expr.clone()); re...
java
private void verifyWindowFunctionExpressions() { // Check for windowed expressions. if (m_windowFunctionExpressions.size() > 0) { if (m_windowFunctionExpressions.size() > 1) { throw new PlanningErrorException( "Only one windowed function call may appea...
java
private boolean canPushdownLimit() { boolean limitCanPushdown = (m_limitOffset.hasLimit() && !m_distinct); if (limitCanPushdown) { for (ParsedColInfo col : m_displayColumns) { AbstractExpression rootExpr = col.m_expression; if (rootExpr instanceof AggregateExp...
java
private boolean isValidJoinOrder(List<String> tableAliases) { assert(m_joinTree != null); // Split the original tree into the sub-trees // having the same join type for all nodes List<JoinNode> subTrees = m_joinTree.extractSubTrees(); // For a sub-tree with inner joins only, an...
java
@Override public boolean isOrderDeterministic() { if ( ! hasTopLevelScans()) { // This currently applies to parent queries that do all their // scanning in subqueries and so take on the order determinism of // their subqueries. This might have to be rethought to allow ...
java
public boolean orderByColumnsDetermineAllDisplayColumnsForUnion( List<ParsedColInfo> orderColumns) { Set<AbstractExpression> orderExprs = new HashSet<>(); for (ParsedColInfo col : orderColumns) { orderExprs.add(col.m_expression); } for (ParsedColInfo col : m_disp...
java
public boolean isPartitionColumnInWindowedAggregatePartitionByList() { if (getWindowFunctionExpressions().size() == 0) { return false; } // We can't really have more than one Windowed Aggregate Expression. // If we ever do, this should fail gracelessly. assert(getWind...
java
@Deprecated public static GeographyValue CreateRegularConvex( GeographyPointValue center, GeographyPointValue firstVertex, int numVertices, double sizeOfHole) { assert(0 <= sizeOfHole && sizeOfHole < 1.0); double phi = 360.0/numVertices; Geogra...
java
@Deprecated public static GeographyValue reverseLoops(GeographyValue goodPolygon) { List<List<GeographyPointValue>> newLoops = new ArrayList<>(); List<List<GeographyPointValue>> oldLoops = goodPolygon.getRings(); for (List<GeographyPointValue> loop : oldLoops) { // Copy loop, but...
java
public void grant(String granteeName, String roleName, Grantee grantor) { Grantee grantee = get(granteeName); if (grantee == null) { throw Error.error(ErrorCode.X_28501, granteeName); } if (isImmutable(granteeName)) { throw Error.error(ErrorCode.X_28502, grante...
java
public void revoke(String granteeName, String roleName, Grantee grantor) { if (!grantor.isAdmin()) { throw Error.error(ErrorCode.X_42507); } Grantee grantee = get(granteeName); if (grantee == null) { throw Error.error(ErrorCode.X_28000, granteeName); } ...
java
void removeEmptyRole(Grantee role) { for (int i = 0; i < map.size(); i++) { Grantee grantee = (Grantee) map.get(i); grantee.roles.remove(role); } }
java
public void removeDbObject(HsqlName name) { for (int i = 0; i < map.size(); i++) { Grantee g = (Grantee) map.get(i); g.revokeDbObject(name); } }
java
void updateAllRights(Grantee role) { for (int i = 0; i < map.size(); i++) { Grantee grantee = (Grantee) map.get(i); if (grantee.isRole) { grantee.updateNestedRoles(role); } } for (int i = 0; i < map.size(); i++) { Grantee grantee...
java
public Grantee getRole(String name) { Grantee g = (Grantee) roleMap.get(name); if (g == null) { throw Error.error(ErrorCode.X_0P000, name); } return g; }
java
private void connect(Session session, boolean withReadOnlyData) { // Open new cache: if ((dataSource.length() == 0) || isConnected) { // nothing to do return; } PersistentStore store = database.persistentStoreCollection.getStore(this); this...
java
public void disconnect() { this.store = null; PersistentStore store = database.persistentStoreCollection.getStore(this); store.release(); isConnected = false; }
java
private void openCache(Session session, String dataSourceNew, boolean isReversedNew, boolean isReadOnlyNew) { String dataSourceOld = dataSource; boolean isReversedOld = isReversed; boolean isReadOnlyOld = isReadOnly; if (dataSourceNew == null) { ...
java
protected void setDataSource(Session session, String dataSourceNew, boolean isReversedNew, boolean createFile) { if (getTableType() == Table.TEMP_TEXT_TABLE) { ; } else { session.getGrantee().checkSchemaUpdateOrGrantRights( getSch...
java
void checkDataReadOnly() { if (dataSource.length() == 0) { throw Error.error(ErrorCode.TEXT_TABLE_UNKNOWN_DATA_SOURCE); } if (isReadOnly) { throw Error.error(ErrorCode.DATA_IS_READONLY); } }
java
@Override public void addBatch() throws SQLException { checkClosed(); if (this.Query.isOfType(VoltSQL.TYPE_EXEC,VoltSQL.TYPE_SELECT)) { throw SQLError.get(SQLError.ILLEGAL_STATEMENT, this.Query.toSqlString()); } this.addBatch(this.Query.getExecutableQuery(this.paramet...
java
@Override public boolean execute() throws SQLException { checkClosed(); boolean result = this.execute(this.Query.getExecutableQuery(this.parameters)); this.parameters = this.Query.getParameterArray(); return result; }
java
@Override public ResultSet executeQuery() throws SQLException { checkClosed(); if (!this.Query.isOfType(VoltSQL.TYPE_EXEC,VoltSQL.TYPE_SELECT)) { throw SQLError.get(SQLError.ILLEGAL_STATEMENT, this.Query.toSqlString()); } ResultSet result = this.executeQuery(this.Quer...
java
@Override public void setArray(int parameterIndex, Array x) throws SQLException { checkParameterBounds(parameterIndex); throw SQLError.noSupport(); }
java
@Override public void setByte(int parameterIndex, byte x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x; }
java
@Override public void setBytes(int parameterIndex, byte[] x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x; }
java
@Override public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { checkParameterBounds(parameterIndex); throw SQLError.noSupport(); }
java
@Override public void setDouble(int parameterIndex, double x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x; }
java
@Override public void setFloat(int parameterIndex, float x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = (double) x; }
java
@Override public void setInt(int parameterIndex, int x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x; }
java
@Override public void setLong(int parameterIndex, long x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x; }
java
@Override public void setNString(int parameterIndex, String value) throws SQLException { checkParameterBounds(parameterIndex); throw SQLError.noSupport(); }
java
@Override public void setNull(int parameterIndex, int sqlType) throws SQLException { checkParameterBounds(parameterIndex); switch(sqlType) { case Types.TINYINT: this.parameters[parameterIndex-1] = VoltType.NULL_TINYINT; break; case ...
java
@Override public void setObject(int parameterIndex, Object x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x; }
java
@Override public void setShort(int parameterIndex, short x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x; }
java
@Override public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { checkParameterBounds(parameterIndex); throw SQLError.noSupport(); }
java
@Override public void setURL(int parameterIndex, URL x) throws SQLException { checkParameterBounds(parameterIndex); this.parameters[parameterIndex-1] = x == null ? VoltType.NULL_STRING_OR_VARBINARY : x.toString(); }
java
public final AbstractImporter createImporter(ImporterConfig config) { AbstractImporter importer = create(config); importer.setImportServerAdapter(m_importServerAdapter); return importer; }
java
private static final byte[] expandToLength16(byte scaledValue[], final boolean isNegative) { if (scaledValue.length == 16) { return scaledValue; } byte replacement[] = new byte[16]; if (isNegative) { Arrays.fill(replacement, (byte)-1); } int shift ...
java
public static BigDecimal deserializeBigDecimalFromString(String decimal) throws IOException { if (decimal == null) { return null; } BigDecimal bd = new BigDecimal(decimal); // if the scale is too large, check for trailing zeros if (bd.scale() > kDefaultScale) { ...
java
private static boolean isFileModifiedInCollectionPeriod(File file){ long diff = m_currentTimeMillis - file.lastModified(); if(diff >= 0) { return TimeUnit.MILLISECONDS.toDays(diff)+1 <= m_config.days; } return false; }
java
public static boolean voltMutateToBigintType(Expression maybeConstantNode, Expression parent, int childIndex) { if (maybeConstantNode.opType == OpTypes.VALUE && maybeConstantNode.dataType != null && maybeConstantNode.dataType.isBinaryType()) { ExpressionValue exprVal ...
java