code
stringlengths
73
34.1k
label
stringclasses
1 value
public static ThreadFactory getThreadFactory( final String groupName, final String name, final int stackSize, final boolean incrementThreadNames, final Queue<String> coreList) { ThreadGroup group = null; if (groupName != null) { gro...
java
public static String getHostnameOrAddress() { final InetAddress addr = m_localAddressSupplier.get(); if (addr == null) return ""; return ReverseDNSCache.hostnameOrAddress(addr); }
java
public static final<T> ListenableFuture<T> retryHelper( final ScheduledExecutorService ses, final ExecutorService es, final Callable<T> callable, final long maxAttempts, final long startInterval, final TimeUnit startUnit, final long ma...
java
public static <K extends Comparable< ? super K>,V extends Comparable< ? super V>> List<Entry<K,V>> sortKeyValuePairByValue(Map<K,V> map) { List<Map.Entry<K,V>> entries = new ArrayList<Map.Entry<K,V>>(map.entrySet()); Collections.sort(entries, new Comparator<Map.Entry<K,V>>() { @O...
java
private static NodeAVL set(PersistentStore store, NodeAVL x, boolean isleft, NodeAVL n) { if (isleft) { x = x.setLeft(store, n); } else { x = x.setRight(store, n); } if (n != null) { n.setParent(store, x); } ...
java
private static NodeAVL child(PersistentStore store, NodeAVL x, boolean isleft) { return isleft ? x.getLeft(store) : x.getRight(store); }
java
public static int compareRows(Object[] a, Object[] b, int[] cols, Type[] coltypes) { int fieldcount = cols.length; for (int j = 0; j < fieldcount; j++) { int i = coltypes[cols[j]].compare(a[cols[j]], b[cols[j]]); if (i != 0) { ...
java
@Override public int size(PersistentStore store) { int count = 0; readLock.lock(); try { RowIterator it = firstRow(null, store); while (it.hasNext()) { it.getNextRow(); count++; } return count; } fi...
java
@Override public void insert(Session session, PersistentStore store, Row row) { NodeAVL n; NodeAVL x; boolean isleft = true; int compare = -1; writeLock.lock(); try { n = getAccessor(store); x = n; if (n == null) { ...
java
@Override public RowIterator findFirstRow(Session session, PersistentStore store, Object[] rowdata, int match) { NodeAVL node = findNode(session, store, rowdata, defaultColMap, match); return getIterator(session, store, node); }
java
@Override public RowIterator findFirstRow(Session session, PersistentStore store, Object[] rowdata) { NodeAVL node = findNode(session, store, rowdata, colIndex, colIndex.length); return getIterator(session, store, node); }
java
@Override public RowIterator findFirstRow(Session session, PersistentStore store, Object value, int compare) { readLock.lock(); try { if (compare == OpTypes.SMALLER || compare == OpTypes.SMALLER_EQUAL) { return fin...
java
@Override public RowIterator findFirstRowNotNull(Session session, PersistentStore store) { readLock.lock(); try { NodeAVL x = getAccessor(store); while (x != null) { boolean t = colTypes[0].compare( ...
java
@Override public RowIterator firstRow(Session session, PersistentStore store) { int tempDepth = 0; readLock.lock(); try { NodeAVL x = getAccessor(store); NodeAVL l = x; while (l != null) { x = l; l = x.getLeft(store); ...
java
@Override public Row lastRow(Session session, PersistentStore store) { readLock.lock(); try { NodeAVL x = getAccessor(store); NodeAVL l = x; while (l != null) { x = l; l = x.getRight(store); } while (sess...
java
private NodeAVL next(Session session, PersistentStore store, NodeAVL x) { if (x == null) { return null; } readLock.lock(); try { while (true) { x = next(store, x); if (x == null) { return x; }...
java
private void replace(PersistentStore store, NodeAVL x, NodeAVL n) { if (x.isRoot()) { if (n != null) { n = n.setParent(store, null); } store.setAccessor(this, n); } else { set(store, x.getParent(store), x.isFromLeft(store), n); } ...
java
@Override public int compareRowNonUnique(Object[] a, Object[] b, int fieldcount) { for (int j = 0; j < fieldcount; j++) { int i = colTypes[j].compare(a[j], b[colIndex[j]]); if (i != 0) { return i; } } return 0; }
java
private int compareRowForInsertOrDelete(Session session, Row newRow, Row existingRow) { Object[] a = newRow.getData(); Object[] b = existingRow.getData(); int j = 0; boolean hasNull = false; for (; j < colIndex.length; j++) { Obje...
java
private NodeAVL findNode(Session session, PersistentStore store, Object[] rowdata, int[] rowColMap, int fieldCount) { readLock.lock(); try { NodeAVL x = getAccessor(store); NodeAVL n; NodeAVL result = null; ...
java
private void balance(PersistentStore store, NodeAVL x, boolean isleft) { while (true) { int sign = isleft ? 1 : -1; switch (x.getBalance() * sign) { case 1 : x = x.setBalance(store, 0); return; ...
java
public AbstractExpression resolveTVE(TupleValueExpression tve) { AbstractExpression resolvedExpr = processTVE(tve, tve.getColumnName()); List<TupleValueExpression> tves = ExpressionUtil.getTupleValueExpressions(resolvedExpr); for (TupleValueExpression subqTve : tves) { resolveLeafTv...
java
void resolveColumnIndexesUsingSchema(NodeSchema inputSchema) { // get all the TVEs in the output columns int difftor = 0; for (SchemaColumn col : m_outputSchema) { col.setDifferentiator(difftor); ++difftor; Collection<TupleValueExpression> allTves = ...
java
public boolean isIdentity(AbstractPlanNode childNode) throws PlanningErrorException { assert(childNode != null); // Find the output schema. // If the child node has an inline projection node, // then the output schema is the inline projection // node's output schema. Otherwise i...
java
public void replaceChildOutputSchemaNames(AbstractPlanNode child) { NodeSchema childSchema = child.getTrueOutputSchema(false); NodeSchema mySchema = getOutputSchema(); assert(childSchema.size() == mySchema.size()); for (int idx = 0; idx < childSchema.size(); idx += 1) { Schem...
java
void deliverToRepairLog(VoltMessage msg) { assert(Thread.currentThread().getId() == m_taskThreadId); m_repairLog.deliver(msg); }
java
private void sendInternal(long destHSId, VoltMessage message) { message.m_sourceHSId = getHSId(); m_messenger.send(destHSId, message); }
java
public static ClientAffinityStats diff(ClientAffinityStats newer, ClientAffinityStats older) { if (newer.m_partitionId != older.m_partitionId) { throw new IllegalArgumentException("Can't diff these ClientAffinityStats instances."); } ClientAffinityStats retval = new ClientAffinitySt...
java
private int addFramesForCompleteMessage() { boolean added = false; EncryptFrame frame = null; int delta = 0; while (!added && (frame = m_encryptedFrames.poll()) != null) { if (!frame.isLast()) { //TODO: Review - I don't think this synchronized(m_partialMessag...
java
void shutdown() { m_isShutdown = true; try { int waitFor = 1 - Math.min(m_inFlight.availablePermits(), -4); for (int i = 0; i < waitFor; ++i) { try { if (m_inFlight.tryAcquire(1, TimeUnit.SECONDS)) { m_inFlight.release()...
java
private Runnable createCompletionTask(final Mailbox mb) { return new Runnable() { @Override public void run() { VoltDB.instance().getHostMessenger().removeMailbox(mb.getHSId()); } }; }
java
private Callable<Boolean> coalesceTruncationSnapshotPlan(String file_path, String pathType, String file_nonce, long txnId, Map<Integer, Long> partitionTransactionIds, SystemProcedureExecutionContext...
java
void killSocket() { try { m_closing = true; m_socket.setKeepAlive(false); m_socket.setSoLinger(false, 0); Thread.sleep(25); m_socket.close(); Thread.sleep(25); System.gc(); Thread.sleep(25); } catch (...
java
void send(final long destinations[], final VoltMessage message) { if (!m_isUp) { hostLog.warn("Failed to send VoltMessage because connection to host " + CoreUtils.getHostIdFromHSId(destinations[0])+ " is closed"); return; } if (destinations.length == 0...
java
private void deliverMessage(long destinationHSId, VoltMessage message) { if (!m_hostMessenger.validateForeignHostId(m_hostId)) { hostLog.warn(String.format("Message (%s) sent to site id: %s @ (%s) at %d from %s " + "which is a known failed host. The message will be dropped\n", ...
java
private void handleRead(ByteBuffer in, Connection c) throws IOException { // port is locked by VoltNetwork when in valid use. // assert(m_port.m_lock.tryLock() == true); long recvDests[] = null; final long sourceHSId = in.getLong(); final int destCount = in.getInt(); if ...
java
@Nullable private AvlNode<E> firstNode() { AvlNode<E> root = rootReference.get(); if (root == null) { return null; } AvlNode<E> node; if (range.hasLowerBound()) { E endpoint = range.getLowerEndpoint(); node = rootReference.get().ceiling(comparator(), endpoint); if (node == ...
java
public static MediaType create(String type, String subtype) { return create(type, subtype, ImmutableListMultimap.<String, String>of()); }
java
private static int getSerializedParamSizeForApplyBinaryLog(int streamCount, int remotePartitionCount, int concatLogSize) { int serializedParamSize = 2 + 1 + 4 // placeholder byte[0] + 1 + 4 ...
java
void restart() { // The poisoning path will, unfortunately, set this to true. Need to undo that. setNeedsRollback(false); // Also need to make sure that we get the original invocation in the first fragment // since some masters may not have seen it. m_haveDistributedInitTask...
java
@Override public void setupProcedureResume(int[] dependencies) { // Reset state so we can run this batch cleanly m_localWork = null; m_remoteWork = null; m_remoteDeps = null; m_remoteDepTables.clear(); }
java
public void setupProcedureResume(List<Integer> deps) { setupProcedureResume(com.google_voltpatches.common.primitives.Ints.toArray(deps)); }
java
public void restartFragment(FragmentResponseMessage message, List<Long> masters, Map<Integer, Long> partitionMastersMap) { final int partionId = message.getPartitionId(); Long restartHsid = partitionMastersMap.get(partionId); Long hsid = message.getExecutorSiteId(); if (!hsid.equals(rest...
java
private boolean checkNewUniqueIndex(Index newIndex) { Table table = (Table) newIndex.getParent(); CatalogMap<Index> existingIndexes = m_originalIndexesByTable.get(table.getTypeName()); for (Index existingIndex : existingIndexes) { if (indexCovers(newIndex, existingIndex)) { ...
java
private String createViewDisallowedMessage(String viewName, String singleTableName) { boolean singleTable = (singleTableName != null); return String.format( "Unable to create %sview %s %sbecause the view definition uses operations that cannot always be applied if %s.", (s...
java
private TablePopulationRequirements getMVHandlerInfoMessage(MaterializedViewHandlerInfo mvh) { if ( ! mvh.getIssafewithnonemptysources()) { TablePopulationRequirements retval; String viewName = mvh.getDesttable().getTypeName(); String errorMessage = createViewDisallowedMessag...
java
private void writeModification(CatalogType newType, CatalogType prevType, String field) { // Don't write modifications if the field can be ignored if (checkModifyIgnoreList(newType, prevType, field)) { return; } // verify this is possible, write an error and mark return ...
java
protected static boolean checkCatalogDiffShouldApplyToEE(final CatalogType suspect) { // Warning: // This check list should be consistent with catalog items defined in EE // Once a new catalog type is added in EE, we should add it here. if (suspect instanceof Cluster || suspect inst...
java
private void processModifyResponses(String errorMessage, List<TablePopulationRequirements> responseList) { assert(errorMessage != null); // if no requirements, then it's just not possible if (responseList == null) { m_supported = false; m_errors.append(errorMessage + "\n...
java
private void writeDeletion(CatalogType prevType, CatalogType newlyChildlessParent, String mapName) { // Don't write deletions if the field can be ignored if (checkDeleteIgnoreList(prevType, newlyChildlessParent, mapName, prevType.getTypeName())) { return; } // verify thi...
java
private void writeAddition(CatalogType newType) { // Don't write additions if the field can be ignored if (checkAddIgnoreList(newType)) { return; } // verify this is possible, write an error and mark return code false if so String errorMessage = checkAddDropWhitelist(...
java
private void getCommandsToDiff(String mapName, CatalogMap<? extends CatalogType> prevMap, CatalogMap<? extends CatalogType> newMap) { assert(prevMap != null); assert(newMap != null); // in previous, not in new for...
java
public String getSQL() { StringBuffer sb = new StringBuffer(64); switch (opType) { case OpTypes.VALUE : if (valueData == null) { return Tokens.T_NULL; } return dataType.convertToSQLString(valueData); case Op...
java
void setDataType(Session session, Type type) { if (opType == OpTypes.VALUE) { valueData = type.convertToType(session, valueData, dataType); } dataType = type; }
java
Expression replaceAliasInOrderBy(Expression[] columns, int length) { for (int i = 0; i < nodes.length; i++) { if (nodes[i] == null) { continue; } nodes[i] = nodes[i].replaceAliasInOrderBy(columns, length); } return this; }
java
public HsqlList resolveColumnReferences(RangeVariable[] rangeVarArray, HsqlList unresolvedSet) { return resolveColumnReferences(rangeVarArray, rangeVarArray.length, unresolvedSet, true); }
java
void insertValuesIntoSubqueryTable(Session session, PersistentStore store) { for (int i = 0; i < nodes.length; i++) { Object[] data = nodes[i].getRowValue(session); for (int j = 0; j < nodeDataTypes.length; j++) { data[j] = nodeData...
java
static QuerySpecification getCheckSelect(Session session, Table t, Expression e) { CompileContext compileContext = new CompileContext(session); QuerySpecification s = new QuerySpecification(compileContext); s.exprColumns = new Expression[1]; s.exprColumns[0] = EXPR_T...
java
static void collectAllExpressions(HsqlList set, Expression e, OrderedIntHashSet typeSet, OrderedIntHashSet stopAtTypeSet) { if (e == null) { return; } if (stopAtTypeSet.contains(e.opType)) { ret...
java
protected String getUniqueId(final Session session) { if (cached_id != null) { return cached_id; } // // Calculated an new Id // // this line ripped from the "describe" method // seems to help with some types like "equal" cached_id = new Stri...
java
private VoltXMLElement convertUsingColumnrefToCoaleseExpression(Session session, VoltXMLElement exp, Type dataType) throws org.hsqldb_voltpatches.HSQLInterface.HSQLParseException { // Hsql has check dataType can not be null. assert(dataType != null); exp.attributes.put("valuetype", d...
java
private void appendOptionGroup(StringBuffer buff, OptionGroup group) { if (!group.isRequired()) { buff.append("["); } List<Option> optList = new ArrayList<Option>(group.getOptions()); if (getOptionComparator() != null) { Collections.sort(optLi...
java
private void appendOption(StringBuffer buff, Option option, boolean required) { if (!required) { buff.append("["); } if (option.getOpt() != null) { buff.append("-").append(option.getOpt()); } else { buff.append("--"...
java
public void printUsage(PrintWriter pw, int width, String cmdLineSyntax) { int argPos = cmdLineSyntax.indexOf(' ') + 1; printWrapped(pw, width, getSyntaxPrefix().length() + argPos, getSyntaxPrefix() + cmdLineSyntax); }
java
protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad) { final String lpad = createPadding(leftPad); final String dpad = createPadding(descPad); // first create list containing only <lpad>-a,--aaa where // -a is opt and --aaa is ...
java
protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text) { int pos = findWrapPos(text, width, 0); if (pos == -1) { sb.append(rtrim(text)); return sb; } sb.app...
java
private static boolean functionMatches(FunctionDescriptor existingFd, Type returnType, Type[] parameterTypes) { if (returnType != existingFd.m_type) { return false; } if (parameterTypes.length != ex...
java
private static FunctionDescriptor findFunction(String functionName, Type returnType, Type[] parameterType) { m_logger.debug("Looking for UDF " + functionName); FunctionDescriptor fd = FunctionDescriptor...
java
public static synchronized int registerTokenForUDF(String functionName, int functionId, VoltType voltReturnType, VoltType[] voltParameterTypes) { i...
java
public static Type hsqlTypeFromVoltType(VoltType voltReturnType) { Class<?> typeClass = VoltType.classFromByteValue(voltReturnType.getValue()); int typeNo = Types.getParameterSQLTypeNumber(typeClass); return Type.getDefaultTypeWithSize(typeNo); }
java
public static Type[] hsqlTypeFromVoltType(VoltType[] voltParameterTypes) { Type[] answer = new Type[voltParameterTypes.length]; for (int idx = 0; idx < voltParameterTypes.length; idx++) { answer[idx] = hsqlTypeFromVoltType(voltParameterTypes[idx]); } return answer; }
java
void setNewNodes() { int index = tTable.getIndexCount(); nPrimaryNode = new NodeAVLMemoryPointer(this); NodeAVL n = nPrimaryNode; for (int i = 1; i < index; i++) { n.nNext = new NodeAVLMemoryPointer(this); n = n.nNext; } }
java
private void bufferCatchup(int messageSize) throws IOException { // If the current buffer has too many tasks logged, queue it and // create a new one. if (m_tail != null && m_tail.size() > 0 && messageSize > m_bufferHeadroom) { // compile the invocation buffer m_tail.comp...
java
@Override public TransactionInfoBaseMessage getNextMessage() throws IOException { if (m_closed) { throw new IOException("Closed"); } if (m_head == null) { // Get another buffer asynchronously final Runnable r = new Runnable() { @Override ...
java
void sendBufferSync(ByteBuffer bb) { try { /* configure socket to be blocking * so that we dont have to do write in * a tight while loop */ sock.configureBlocking(true); if (bb != closeConn) { if (sock != null) { ...
java
private void cleanupWriterSocket(PrintWriter pwriter) { try { if (pwriter != null) { pwriter.flush(); pwriter.close(); } } catch (Exception e) { LOG.info("Error closing PrintWriter ", e); } finally { try { ...
java
private boolean readLength(SelectionKey k) throws IOException { // Read the length, now get the buffer int len = lenBuffer.getInt(); if (!initialized && checkFourLetterWord(k, len)) { return false; } if (len < 0 || len > BinaryInputArchive.maxBuffer) { thr...
java
private void closeSock() { if (sock == null) { return; } LOG.debug("Closed socket connection for client " + sock.socket().getRemoteSocketAddress() + (sessionId != 0 ? " which had sessionid 0x" + Long.toHexString(sessionId) : ...
java
void increment() { long id = rand.nextInt(config.tuples); long toIncrement = rand.nextInt(5); // 0 - 4 try { client.callProcedure(new CMCallback(), "Increment", toIncrement, id); } catch (IOException e) { // This is not ideal error handling for production...
java
public synchronized void writeToLog(Session session, String statement) { if (logStatements && log != null) { log.writeStatement(session, statement); } }
java
public DataFileCache openTextCache(Table table, String source, boolean readOnlyData, boolean reversed) { return log.openTextCache(table, source, readOnlyData, reversed); }
java
protected void initParams(Database database, String baseFileName) { HsqlDatabaseProperties props = database.getProperties(); fileName = baseFileName + ".data"; backupFileName = baseFileName + ".backup"; this.database = database; fa = database.getFileAccess();...
java
public void close(boolean write) { SimpleLog appLog = database.logger.appLog; try { if (cacheReadonly) { if (dataFile != null) { dataFile.close(); dataFile = null; } return; } ...
java
public void defrag() { if (cacheReadonly) { return; } if (fileFreePosition == INITIAL_FREE_POS) { return; } database.logger.appLog.logContext(SimpleLog.LOG_NORMAL, "start"); try { boolean wasNio = dataFile.wasNio(); cac...
java
public void remove(int i, PersistentStore store) { writeLock.lock(); try { CachedObject r = release(i); if (r != null) { int size = r.getStorageSize(); freeBlocks.add(i, size); } } finally { writeLock.unlock(); ...
java
public void restore(CachedObject object) { writeLock.lock(); try { int i = object.getPos(); cache.put(i, object); // was previously used for text tables if (storeOnInsert) { saveRow(object); } } finally { ...
java
static void deleteOrResetFreePos(Database database, String filename) { ScaledRAFile raFile = null; database.getFileAccess().removeElement(filename); // OOo related code if (database.isStoredFileAccess()) { return; } // OOo end if (!database.getFile...
java
public static boolean isDurableFragment(byte[] planHash) { long fragId = VoltSystemProcedure.hashToFragId(planHash); return (fragId == PF_prepBalancePartitions || fragId == PF_balancePartitions || fragId == PF_balancePartitionsData || fragId == PF_balance...
java
protected void set(ClientResponse response) { if (!this.status.compareAndSet(STATUS_RUNNING, STATUS_SUCCESS)) return; this.response = response; this.latch.countDown(); }
java
private static List<JoinNode> generateInnerJoinOrdersForTree(JoinNode subTree) { // Get a list of the leaf nodes(tables) to permute them List<JoinNode> tableNodes = subTree.generateLeafNodesJoinOrder(); List<List<JoinNode>> joinOrders = PermutationGenerator.generatePurmutations(tableNodes); ...
java
private static List<JoinNode> generateOuterJoinOrdersForTree(JoinNode subTree) { List<JoinNode> treePermutations = new ArrayList<>(); treePermutations.add(subTree); return treePermutations; }
java
private static List<JoinNode> generateFullJoinOrdersForTree(JoinNode subTree) { assert(subTree != null); List<JoinNode> joinOrders = new ArrayList<>(); if (!(subTree instanceof BranchNode)) { // End of recursion joinOrders.add(subTree); return joinOrders; ...
java
private void generateMorePlansForJoinTree(JoinNode joinTree) { assert(joinTree != null); // generate the access paths for all nodes generateAccessPaths(joinTree); List<JoinNode> nodes = joinTree.generateAllNodesJoinOrder(); generateSubPlanForJoinNodeRecursively(joinTree, 0, node...
java
private void generateInnerAccessPaths(BranchNode parentNode) { JoinNode innerChildNode = parentNode.getRightNode(); assert(innerChildNode != null); // In case of inner join WHERE and JOIN expressions can be merged if (parentNode.getJoinType() == JoinType.INNER) { parentNode.m...
java
private AbstractPlanNode getSelectSubPlanForJoinNode(JoinNode joinNode) { assert(joinNode != null); if (joinNode instanceof BranchNode) { BranchNode branchJoinNode = (BranchNode)joinNode; // Outer node AbstractPlanNode outerScanPlan = getSelectSubP...
java
private static List<AbstractExpression> filterSingleTVEExpressions(List<AbstractExpression> exprs, List<AbstractExpression> otherExprs) { List<AbstractExpression> singleTVEExprs = new ArrayList<>(); for (AbstractExpression expr : exprs) { List<TupleValueExpression> tves = Express...
java
public void notifyShutdown() { if (m_shutdown.compareAndSet(false, true)) { for (KafkaExternalConsumerRunner consumer : m_consumers) { consumer.shutdown(); } close(); } }
java
protected void runDDL(String ddl, boolean transformDdl) { String modifiedDdl = (transformDdl ? transformDDL(ddl) : ddl); printTransformedSql(ddl, modifiedDdl); super.runDDL(modifiedDdl); }
java
@Override protected String getVoltColumnTypeName(String columnTypeName) { String equivalentTypeName = m_PostgreSQLTypeNames.get(columnTypeName); return (equivalentTypeName == null) ? columnTypeName.toUpperCase() : equivalentTypeName; }
java
static private int numOccurencesOfCharIn(String str, char ch) { boolean inMiddleOfQuote = false; int num = 0, previousIndex = 0; for (int index = str.indexOf(ch); index >= 0 ; index = str.indexOf(ch, index+1)) { if (hasOddNumberOfSingleQuotes(str.substring(previousIndex, index))) { ...
java