code
stringlengths
73
34.1k
label
stringclasses
1 value
public void closeForeignHostSocket(int hostId) { Iterator<ForeignHost> it = m_foreignHosts.get(hostId).iterator(); while (it.hasNext()) { ForeignHost fh = it.next(); if (fh.isUp()) { fh.killSocket(); } } reportForeignHostFailed(hostId);...
java
public void cutLink(int hostIdA, int hostIdB) { if (m_localHostId == hostIdA) { Iterator<ForeignHost> it = m_foreignHosts.get(hostIdB).iterator(); while (it.hasNext()) { ForeignHost fh = it.next(); fh.cutLink(); } } if (m_localH...
java
void execute() { String sCmd = null; if (4096 <= ifHuge.length()) { sCmd = ifHuge; } else { sCmd = txtCommand.getText(); } if (sCmd.startsWith("-->>>TEST<<<--")) { testPerformance(); return; } String[] g = new S...
java
public void writeAll(java.sql.ResultSet rs, boolean includeColumnNames) throws SQLException, IOException { if (includeColumnNames) { writeColumnNames(rs); } while (rs.next()) { writeNext(resultService.getColumnValues(rs)); } }
java
public void addRecord(String key, String value) throws TarMalformatException, IOException { if (key == null || value == null || key.length() < 1 || value.length() < 1) { throw new TarMalformatException( RB.singleton...
java
synchronized public void shutdown() { m_shutdown.set(true); if (m_isExecutorServiceLocal) { try { m_es.shutdown(); m_es.awaitTermination(365, TimeUnit.DAYS); } catch (InterruptedException e) { repairLog.warn("Unexpected interrup...
java
public static Pair<BabySitter, List<String>> blockingFactory(ZooKeeper zk, String dir, Callback cb) throws InterruptedException, ExecutionException { ExecutorService es = CoreUtils.getCachedSingleThreadExecutor("Babysitter-" + dir, 15000); Pair<BabySitter, List<String>> babySitter = blocking...
java
public static Pair<BabySitter, List<String>> blockingFactory(ZooKeeper zk, String dir, Callback cb, ExecutorService es) throws InterruptedException, ExecutionException { BabySitter bs = new BabySitter(zk, dir, cb, es); List<String> initialChildren; try { initi...
java
public static BabySitter nonblockingFactory(ZooKeeper zk, String dir, Callback cb, ExecutorService es) throws InterruptedException, ExecutionException { BabySitter bs = new BabySitter(zk, dir, cb, es); bs.m_es.submit(bs.m_eventHandler); ...
java
void checkClosed() throws SQLException { if (isClosed) { throw Util.sqlException(ErrorCode.X_07501); } if (connection.isClosed) { close(); throw Util.sqlException(ErrorCode.X_08503); } }
java
void performPostExecute() throws SQLException { resultOut.clearLobResults(); generatedResult = null; if (resultIn == null) { return; } Result current = resultIn; while (current.getChainedResult() != null) { current = current.getUnlinkChainedRe...
java
boolean getMoreResults(int current) throws SQLException { checkClosed(); if (resultIn == null || !resultIn.isData()) { return false; } if (resultSetCounter == 0) { resultSetCounter++; return true; } if (currentResultSet != null && cu...
java
void closeResultData() throws SQLException { if (currentResultSet != null) { currentResultSet.close(); } if (generatedResultSet != null) { generatedResultSet.close(); } generatedResultSet = null; generatedResult = null; resultIn ...
java
public boolean compatibleWithTable(VoltTable table) { String candidateName = getTableName(table); // table can't have the same name as the view if (candidateName.equals(viewName)) { return false; } // view is for a different table i...
java
@Beta @GwtIncompatible // concurrency public static ThreadFactory platformThreadFactory() { if (!isAppEngine()) { return Executors.defaultThreadFactory(); } try { return (ThreadFactory) Class.forName("com.google_voltpatches.appengine.api.ThreadManager") .getMethod("cu...
java
public static void verifySnapshots( final List<String> directories, final Set<String> snapshotNames) { FileFilter filter = new SnapshotFilter(); if (!snapshotNames.isEmpty()) { filter = new SpecificSnapshotFilter(snapshotNames); } Map<String, Snapshot> snapshots...
java
public long lowestEquivalentValue(final long value) { final int bucketIndex = getBucketIndex(value); final int subBucketIndex = getSubBucketIndex(value, bucketIndex); long thisValueBaseLevel = valueFromIndex(bucketIndex, subBucketIndex); return thisValueBaseLevel; }
java
public double getMean() { if (getTotalCount() == 0) { return 0.0; } recordedValuesIterator.reset(); double totalValue = 0; while (recordedValuesIterator.hasNext()) { HistogramIterationValue iterationValue = recordedValuesIterator.next(); totalV...
java
public double getStdDeviation() { if (getTotalCount() == 0) { return 0.0; } final double mean = getMean(); double geometric_deviation_total = 0.0; recordedValuesIterator.reset(); while (recordedValuesIterator.hasNext()) { HistogramIterationValue i...
java
public void reestablishTotalCount() { // On overflow, the totalCount accumulated counter will (always) not match the total of counts long totalCounted = 0; for (int i = 0; i < countsArrayLength; i++) { totalCounted += getCountAtIndex(i); } setTotalCount(totalCounted);...
java
static void setTableColumnsForSubquery(Table table, QueryExpression queryExpression, boolean fullIndex) { table.columnList = queryExpression.getColumns(); table.columnCount = queryExpression.getColumnCount(); ...
java
public void considerCandidatePlan(CompiledPlan plan, AbstractParsedStmt parsedStmt) { //System.out.println(String.format("[Raw plan]:%n%s", rawplan.rootPlanGraph.toExplainPlanString())); // run the set of microptimizations, which may return many plans (or not) ScanDeterminizer.apply(plan, m_det...
java
public static PartitionDRGateway getInstance(int partitionId, ProducerDRGateway producerGateway, StartAction startAction) { // if this is a primary cluster in a DR-enabled scenario // try to load the re...
java
public String[] getUserPermissionList(String userName) { if (!m_enabled) { return m_perm_list; } if (userName == null) { return new String[] {}; } AuthUser user = getUser(userName); if (user == null) { return new String[] {}; } ...
java
public void callProcedure(AuthUser user, boolean isAdmin, int timeout, ProcedureCallback cb, String procName, Object[] args) { // since we know the caller, th...
java
public static void printSystemOut(String message1, long message2) { if (TRACESYSTEMOUT) { System.out.print(message1); System.out.println(message2); } }
java
public static boolean acceptsPrecision(int type) { switch (type) { case Types.SQL_BINARY : case Types.SQL_BIT : case Types.SQL_BIT_VARYING : case Types.SQL_BLOB : case Types.SQL_CHAR : case Types.SQL_NCHAR : case Types.SQL_CLO...
java
public static <T> Iterable<T> cycle(T... elements) { return cycle(Lists.newArrayList(elements)); }
java
@Override protected void coreLoadCatalog(long timestamp, final byte[] catalogBytes) throws EEException { LOG.trace("Loading Application Catalog..."); int errorCode = 0; errorCode = nativeLoadCatalog(pointer, timestamp, catalogBytes); checkErrorCode(errorCode); //LOG.info("Loa...
java
@Override public void coreUpdateCatalog(long timestamp, boolean isStreamUpdate, final String catalogDiffs) throws EEException { LOG.trace("Loading Application Catalog..."); int errorCode = 0; errorCode = nativeUpdateCatalog(pointer, timestamp, isStreamUpdate, getStringBytes(catalogDiffs)); ...
java
@Override public int extractPerFragmentStats(int batchSize, long[] executionTimesOut) { m_perFragmentStatsBuffer.clear(); // Discard the first byte since it is the timing on/off switch. m_perFragmentStatsBuffer.get(); int succeededFragmentsCount = m_perFragmentStatsBuffer.getInt(); ...
java
@Override public VoltTable[] getStats( final StatsSelector selector, final int locators[], final boolean interval, final Long now) { //Clear is destructive, do it before the native call m_nextDeserializer.clear(); final int numResults = nat...
java
public boolean storeLargeTempTableBlock(long siteId, long blockCounter, ByteBuffer block) { LargeBlockTask task = LargeBlockTask.getStoreTask(new BlockId(siteId, blockCounter), block); return executeLargeBlockTaskSynchronously(task); }
java
public boolean loadLargeTempTableBlock(long siteId, long blockCounter, ByteBuffer block) { LargeBlockTask task = LargeBlockTask.getLoadTask(new BlockId(siteId, blockCounter), block); return executeLargeBlockTaskSynchronously(task); }
java
public boolean releaseLargeTempTableBlock(long siteId, long blockCounter) { LargeBlockTask task = LargeBlockTask.getReleaseTask(new BlockId(siteId, blockCounter)); return executeLargeBlockTaskSynchronously(task); }
java
public List<String> getSQLStatements() { List<String> sqlStatements = new ArrayList<>(plannedStatements.size()); for (AdHocPlannedStatement plannedStatement : plannedStatements) { sqlStatements.add(new String(plannedStatement.sql, Constants.UTF8ENCODING)); } return sqlStateme...
java
public boolean isSinglePartitionCompatible() { for (AdHocPlannedStatement plannedStmt : plannedStatements) { if (plannedStmt.core.collectorFragment != null) { return false; } } return true; }
java
public ByteBuffer flattenPlanArrayToBuffer() throws IOException { int size = 0; // sizeof batch ParameterSet userParamCache = null; if (userParamSet == null) { userParamCache = ParameterSet.emptyParameterSet(); } else { Object[] typedUserParams = new Object[userP...
java
public String explainStatement(int i, Database db, boolean getJSONString) { AdHocPlannedStatement plannedStatement = plannedStatements.get(i); String aggplan = new String(plannedStatement.core.aggregatorFragment, Constants.UTF8ENCODING); PlanNodeTree pnt = new PlanNodeTree(); try { ...
java
public synchronized static AdHocCompilerCache getCacheForCatalogHash(byte[] catalogHash) { String hashString = Encoder.hexEncode(catalogHash); AdHocCompilerCache cache = m_catalogHashMatch.getIfPresent(hashString); if (cache == null) { cache = new AdHocCompilerCache(); m_...
java
synchronized void printStats() { String line1 = String.format("CACHE STATS - Literals: Hits %d/%d (%.1f%%), Inserts %d Evictions %d\n", m_literalHits, m_literalQueries, (m_literalHits * 100.0) / m_literalQueries, m_literalInsertions, m_literalEvictions); String line2 = St...
java
public synchronized void put(String sql, String parsedToken, AdHocPlannedStatement planIn, String[] extractedLiterals, boolean hasUserQuestionMarkParameters, ...
java
public void startPeriodicStatsPrinting() { if (m_statsTimer == null) { m_statsTimer = new Timer(); m_statsTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { printStats(); } }, 5000, 500...
java
@Override public Date getDate(int parameterIndex, Calendar cal) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public Date getDate(String parameterName, Calendar cal) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public Object getObject(String parameterName, Map<String,Class<?>> map) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public Time getTime(int parameterIndex, Calendar cal) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public Time getTime(String parameterName, Calendar cal) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public void setNString(String parameterName, String value) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public void setURL(String parameterName, URL val) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
public static String suffixHSIdsWithMigratePartitionLeaderRequest(Long HSId) { return Long.toString(Long.MAX_VALUE) + "/" + Long.toString(HSId) + migrate_partition_leader_suffix; }
java
public void startPartitionWatch() throws InterruptedException, ExecutionException { Future<?> task = m_es.submit(new PartitionWatchEvent()); task.get(); }
java
private void processPartitionWatchEvent() throws KeeperException, InterruptedException { try { m_zk.create(m_rootNode, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); m_zk.getData(m_rootNode, m_childWatch, null); } catch (KeeperException.NodeExistsException e) { m_...
java
public Object convertToDefaultType(SessionInterface session, Object a) { if (a == null) { return a; } Type otherType; if (a instanceof Number) { if (a instanceof BigInteger) { a = new BigDecimal((BigInteger) a); } else if (a instance...
java
private static Double convertToDouble(Object a) { double value; if (a instanceof java.lang.Double) { return (Double) a; } else if (a instanceof BigDecimal) { BigDecimal bd = (BigDecimal) a; value = bd.doubleValue(); int signum = bd.signu...
java
public Object mod(Object a, Object b) { if (a == null || b == null) { return null; } switch (typeCode) { case Types.SQL_REAL : case Types.SQL_FLOAT : case Types.SQL_DOUBLE : { double ad = ((Number) a).doubleValue(); ...
java
public synchronized void write(int c) throws IOException { checkClosed(); int newcount = count + 1; if (newcount > buf.length) { buf = copyOf(buf, Math.max(buf.length << 1, newcount)); } buf[count] = (char) c; count = newcount; }
java
private void initiateSPIMigrationIfRequested(Iv2InitiateTaskMessage msg) { if (!"@MigratePartitionLeader".equals(msg.getStoredProcedureName())) { return; } final Object[] params = msg.getParameters(); int pid = Integer.parseInt(params[1].toString()); if (pid != m_par...
java
private boolean checkMisroutedIv2IntiateTaskMessage(Iv2InitiateTaskMessage message) { if (message.isForReplica()) { return false; } if (m_scheduler.isLeader() && m_migratePartitionLeaderStatus != MigratePartitionLeaderStatus.TXN_RESTART) { //At this point, the message is...
java
private boolean checkMisroutedFragmentTaskMessage(FragmentTaskMessage message) { if (m_scheduler.isLeader() || message.isForReplica()) { return false; } TransactionState txnState = (((SpScheduler)m_scheduler).getTransactionState(message.getTxnId())); // If a fragment is par...
java
private void handleLogRequest(VoltMessage message) { Iv2RepairLogRequestMessage req = (Iv2RepairLogRequestMessage)message; // It is possible for a dead host to queue messages after a repair request is processed // so make sure this can't happen by re-queuing this message after we know the de...
java
private void setMigratePartitionLeaderStatus(MigratePartitionLeaderMessage message) { //The host with old partition leader is down. if (message.isStatusReset()) { m_migratePartitionLeaderStatus = MigratePartitionLeaderStatus.NONE; return; } if (m_migratePartitio...
java
public void setMigratePartitionLeaderStatus(boolean migratePartitionLeader) { if (!migratePartitionLeader) { m_migratePartitionLeaderStatus = MigratePartitionLeaderStatus.NONE; m_newLeaderHSID = Long.MIN_VALUE; return; } //The previous leader has already drai...
java
public void notifyNewLeaderOfTxnDoneIfNeeded() { //return quickly to avoid performance hit if (m_newLeaderHSID == Long.MIN_VALUE ) { return; } SpScheduler scheduler = (SpScheduler)m_scheduler; if (!scheduler.txnDoneBeforeCheckPoint()) { return; } ...
java
public void resetMigratePartitionLeaderStatus() { m_scheduler.m_isLeader = true; m_migratePartitionLeaderStatus = MigratePartitionLeaderStatus.NONE; m_repairLog.setLeaderState(true); m_newLeaderHSID = Long.MIN_VALUE; }
java
private Option resolveOption(String opt) { opt = Util.stripLeadingHyphens(opt); for (Option option : options) { if (opt.equals(option.getOpt())) { return option; } if (opt.equals(option.getLongOpt())) { ...
java
public String[] getArgs() { String[] answer = new String[args.size()]; args.toArray(answer); return answer; }
java
public boolean processScanNodeWithReAggNode(AbstractPlanNode node, AbstractPlanNode reAggNode) { // MV table scan node can not be in in-lined nodes. for (int i = 0; i < node.getChildCount(); i++) { AbstractPlanNode child = node.getChild(i); if (child instanceof AbstractScanPlanN...
java
private void resolveColumnReferences() { if (isDistinctSelect || isGrouped) { acceptsSequences = false; } for (int i = 0; i < rangeVariables.length; i++) { Expression e = rangeVariables[i].nonIndexJoinCondition; if (e == null) { continue; ...
java
private int getMaxRowCount(Session session, int rowCount) { int limitStart = getLimitStart(session); int limitCount = getLimitCount(session, rowCount); if (simpleLimit) { if (rowCount == 0) { rowCount = limitCount; } // A VoltDB extension to...
java
protected void dumpExprColumns(String header){ System.out.println("\n\n*********************************************"); System.out.println(header); try { System.out.println(getSQL()); } catch (Exception e) { } for (int i = 0; i < exprColumns.length; ++i) { ...
java
public void updateEECacheStats(long eeCacheSize, long hits, long misses, int partitionId) { m_cache1Level = eeCacheSize; m_cache1Hits += hits; m_cacheMisses += misses; m_invocations += hits + misses; m_partitionId = partitionId; }
java
public void endStatsCollection(long cache1Size, long cache2Size, CacheUse cacheUse, long partitionId) { if (m_currentStartTime != null) { long delta = System.nanoTime() - m_currentStartTime; if (delta < 0) { if (Math.abs(delta) > 1000000000) { log.info...
java
@Override protected void updateStatsRow(Object rowKey, Object rowValues[]) { super.updateStatsRow(rowKey, rowValues); rowValues[columnNameToIndex.get("PARTITION_ID")] = m_partitionId; long totalTimedExecutionTime = m_totalPlanningTime; long minExecutionTime = m_minPlanningTime; ...
java
static void tag(StringBuilder sb, String color, String text) { sb.append("<span class='label label"); if (color != null) { sb.append("-").append(color); } String classText = text.replace(' ', '_'); sb.append(" l-").append(classText).append("'>").append(text).append("<...
java
public static String report(Catalog catalog, long minHeap, boolean isPro, int hostCount, int sitesPerHost, int kfactor, ArrayList<Feedback> warnings, String autoGenDDL) throws IOException { // asynchronously get platform properties new Thread() { @Override public void...
java
public static String liveReport() { byte[] reportbytes = VoltDB.instance().getCatalogContext().getFileInJar(VoltCompiler.CATLOG_REPORT); String report = new String(reportbytes, Charsets.UTF_8); // remove commented out code report = report.replace("<!--##RESOURCES", ""); report =...
java
private static boolean turnOffClientInterface() { // we don't expect this to ever fail, but if it does, skip to dying immediately VoltDBInterface vdbInstance = instance(); if (vdbInstance != null) { ClientInterface ci = vdbInstance.getClientInterface(); if (ci != null) { ...
java
private static void sendCrashSNMPTrap(String msg) { if (msg == null || msg.trim().isEmpty()) { return; } VoltDBInterface vdbInstance = instance(); if (vdbInstance == null) { return; } SnmpTrapSender snmp = vdbInstance.getSnmpTrapSender(); i...
java
public static void crashGlobalVoltDB(String errMsg, boolean stackTrace, Throwable t) { // for test code wasCrashCalled = true; crashMessage = errMsg; if (ignoreCrash) { throw new AssertionError("Faux crash of VoltDB successful."); } // end test code /...
java
public static void main(String[] args) { //Thread.setDefaultUncaughtExceptionHandler(new VoltUncaughtExceptionHandler()); Configuration config = new Configuration(args); try { if (!config.validate()) { System.exit(-1); } else { if (config.m...
java
public static String getDefaultReplicationInterface() { if (m_config.m_drInterface == null || m_config.m_drInterface.isEmpty()) { if (m_config.m_externalInterface == null) { return ""; } else { return m_config.m_externalInterface; }...
java
public void removeAllZeros() { Iterator<Map.Entry<K, AtomicLong>> entryIterator = map.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry<K, AtomicLong> entry = entryIterator.next(); AtomicLong atomic = entry.getValue(); if (atomic != null && atomic.get() == 0L) { entryI...
java
public CompletableFuture<ClientResponseWithPartitionKey[]> callAllPartitionProcedure(String procedureName, Object... params) { return m_runner.callAllPartitionProcedure(procedureName, params); }
java
public static ByteBuffer getTableDataReference(VoltTable vt) { ByteBuffer buf = vt.m_buffer.duplicate(); buf.rewind(); return buf; }
java
private long reserveNextTicket(double requiredPermits, long nowMicros) { resync(nowMicros); long microsToNextFreeTicket = Math.max(0, nextFreeTicketMicros - nowMicros); double storedPermitsToSpend = Math.min(requiredPermits, this.storedPermits); double freshPermits = requiredPermits - storedPermitsToSpe...
java
public Options addOptionGroup(OptionGroup group) { if (group.isRequired()) { requiredOpts.add(group); } for (Option option : group.getOptions()) { // an Option cannot be required if it is in an // OptionGroup, either the group is required ...
java
public Options addOption(String opt, String description) { addOption(opt, null, false, description); return this; }
java
public Options addOption(String opt, boolean hasArg, String description) { addOption(opt, null, hasArg, description); return this; }
java
public Options addOption(String opt, String longOpt, boolean hasArg, String description) { addOption(new Option(opt, longOpt, hasArg, description)); return this; }
java
public CommandLine makeCopy() { CommandLine cl = new CommandLine(m_startAction); // first copy the base class fields cl.m_ipcPort = m_ipcPort; cl.m_backend = m_backend; cl.m_leader = m_leader; cl.m_pathToCatalog = m_pathToCatalog; cl.m_pathToDeployment = m_pathToD...
java
public static VoltXMLElement mergeTwoElementsUsingOperator(String opName, String opElementId, VoltXMLElement first, VoltXMLElement ...
java
public static List<VoltXMLElement> buildLimitElements(int limit, String limitValueElementId) { if (limitValueElementId == null) { return null; } List<VoltXMLElement> retval = new ArrayList<VoltXMLElement>(); retval.add( new VoltXMLElement("offset") ); VoltXMLElement limitElement = new ...
java
public static VoltXMLElement buildColumnParamJoincondElement(String opName, VoltXMLElement leftElement, String valueParamElementId, String opElementId) { VoltXMLElement valueParamElement = buildValueElement(valueParamElementId); return mergeTwoElementsUsingOperator(opName, opElementId, leftElement, valu...
java
public static VoltXMLElement buildParamElement(String elementId, String index, String valueType) { VoltXMLElement retval = new VoltXMLElement("parameter"); retval.attributes.put("id", elementId); retval.attributes.put("index", index); retval.attributes.put("valuetype", valueType); ...
java
@Override public void loadFromJSONObject( JSONObject jobj, Database db ) throws JSONException { super.loadFromJSONObject(jobj, db); m_lookupType = IndexLookupType.get( jobj.getString( Members.LOOKUP_TYPE.name() ) ); m_sortDirection = SortDirectionType.get( jobj.getString( Members.SORT_DIRECT...
java
public boolean isPredicatesOptimizableForAggregate() { // for reverse scan, need to examine "added" predicates List<AbstractExpression> predicates = ExpressionUtil.uncombinePredicate(m_predicate); // if the size of predicates doesn't equal 1, can't be our added artifact predicates if (pr...
java