code
stringlengths
73
34.1k
label
stringclasses
1 value
@Override public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
java
@Override public boolean supportsConvert(int fromType, int toType) throws SQLException { checkClosed(); switch (fromType) { /* * ALL types can be converted to VARCHAR /VoltType.String */ case java.sql.Types.VARCHAR: case java.sql.Types.VARBINARY: cas...
java
@Override public boolean supportsResultSetType(int type) throws SQLException { checkClosed(); if (type == ResultSet.TYPE_SCROLL_INSENSITIVE) return true; return false; }
java
public static boolean isInProcessDatabaseType(String url) { if (url == S_FILE || url == S_RES || url == S_MEM) { return true; } return false; }
java
public T nextReady(long systemCurrentTimeMillis) { if (delayed.size() == 0) { return null; } // no ready objects if (delayed.firstKey() > systemCurrentTimeMillis) { return null; } Entry<Long, Object[]> entry = delayed.pollFirstEntry(); Ob...
java
private static byte[] readCatalog(String catalogUrl) throws IOException { assert (catalogUrl != null); final int MAX_CATALOG_SIZE = 40 * 1024 * 1024; // 40mb InputStream fin = null; try { URL url = new URL(catalogUrl); fin = url.openStream(); } catch...
java
synchronized public void close() { closed = true; if (sqw != null) { try { if (layoutHeaderChecked && layout != null && layout.getFooter() != null) { sendLayoutMessage(layout.getFooter()); } sqw.close(); sqw = null; } catch(java...
java
public static int getFacility(String facilityName) { if(facilityName != null) { facilityName = facilityName.trim(); } if("KERN".equalsIgnoreCase(facilityName)) { return LOG_KERN; } else if("USER".equalsIgnoreCase(facilityName)) { return LOG_USER; } else if("MAIL".equalsIgnoreCa...
java
public void activateOptions() { if (header) { getLocalHostname(); } if (layout != null && layout.getHeader() != null) { sendLayoutMessage(layout.getHeader()); } layoutHeaderChecked = true; }
java
private String getPacketHeader(final long timeStamp) { if (header) { StringBuffer buf = new StringBuffer(dateFormat.format(new Date(timeStamp))); // RFC 3164 says leading space, not leading zero on days 1-9 if (buf.charAt(4) == '0') { buf.setCharAt(4, ' '); } buf...
java
private void sendLayoutMessage(final String msg) { if (sqw != null) { String packet = msg; String hdr = getPacketHeader(new Date().getTime()); if(facilityPrinting || hdr.length() > 0) { StringBuffer buf = new StringBuffer(hdr); if(facilityPrinting) { ...
java
protected byte[] getGZipData() throws SQLException { byte[] bytes = gZipData(); if (bytes != null) { return bytes; } if ((this.outputStream == null) || !this.outputStream.isClosed() || this.outputStream.isFreed()) { throw Exceptions.notReadable(...
java
protected synchronized void close() { this.closed = true; setReadable(false); setWritable(false); freeOutputStream(); freeInputStream(); this.gzdata = null; }
java
protected <T extends Result>T createResult( Class<T> resultClass) throws SQLException { checkWritable(); setWritable(false); setReadable(true); if (JAXBResult.class.isAssignableFrom(resultClass)) { // Must go first presently, since JAXBResult extends SAXResult ...
java
@SuppressWarnings("unchecked") protected <T extends Result>T createSAXResult( Class<T> resultClass) throws SQLException { SAXResult result = null; try { result = (resultClass == null) ? new SAXResult() : (SAXResult) resultClass.newInstance(); } c...
java
@Override public List<AbstractExpression> bindingToIndexedExpression(AbstractExpression expr) { if (equals(expr)) { return s_reusableImmutableEmptyBinding; } return null; }
java
public static Client getClient(ClientConfig config, String[] servers, int port) throws Exception { config.setTopologyChangeAware(true); // Set client to be topology-aware final Client client = ClientFactory.createClient(config); for (String server : servers) { // Try conn...
java
public synchronized void addAdapter(int pid, InternalClientResponseAdapter adapter) { final ImmutableMap.Builder<Integer, InternalClientResponseAdapter> builder = ImmutableMap.builder(); builder.putAll(m_adapters); builder.put(pid, adapter); m_adapters = builder.build(); }
java
public boolean hasTable(String name) { Table table = getCatalogContext().tables.get(name); return (table!=null); }
java
public boolean callProcedure(InternalConnectionContext caller, Function<Integer, Boolean> backPressurePredicate, InternalConnectionStatsCollector statsCollector, ProcedureCallback procCallback, String proc, Object... fiel...
java
synchronized void registerService(Promotable service) { m_services.add(service); if (m_isLeader) { try { service.acceptPromotion(); } catch (Exception e) { VoltDB.crashLocalVoltDB("Unable to promote global service.", true, e); ...
java
void resolveTypesForCaseWhen(Session session) { if (dataType != null) { return; } Expression expr = this; while (expr.opType == OpTypes.CASEWHEN) { expr.nodes[LEFT].resolveTypes(session, expr); if (expr.nodes[LEFT].isParam) { expr.n...
java
public static GeographyPointValue fromWKT(String param) { if (param == null) { throw new IllegalArgumentException("Null well known text argument to GeographyPointValue constructor."); } Matcher m = wktPattern.matcher(param); if (m.find()) { // Add 0.0 to avoid -0....
java
String formatLngLat() { DecimalFormat df = new DecimalFormat("##0.0###########"); // Explicitly test for differences less than 1.0e-12 and // force them to be zero. Otherwise you may find a case // where two points differ in the less significant bits, but // they format as the ...
java
public static GeographyPointValue unflattenFromBuffer(ByteBuffer inBuffer, int offset) { double lng = inBuffer.getDouble(offset); double lat = inBuffer.getDouble(offset + BYTES_IN_A_COORD); if (lat == 360.0 && lng == 360.0) { // This is a null point. return null; ...
java
private static double normalize(double v, double range) { double a = v-Math.floor((v + (range/2))/range)*range; // Make sure that a and v have the same sign // when abs(v) = 180. if (Math.abs(a) == 180.0 && (a * v) < 0) { a *= -1; } // The addition of 0.0 is t...
java
@Deprecated public GeographyPointValue mul(double alpha) { return GeographyPointValue.normalizeLngLat(getLongitude() * alpha + 0.0, getLatitude() * alpha + 0.0); }
java
@Deprecated public GeographyPointValue rotate(double phi, GeographyPointValue center) { double sinphi = Math.sin(2*Math.PI*phi/360.0); double cosphi = Math.cos(2*Math.PI*phi/360.0); // Translate to the center. double longitude = getLongitude() - center.getLongitude(); double...
java
public static void createPersistentZKNodes(ZooKeeper zk) { LinkedList<ZKUtil.StringCallback> callbacks = new LinkedList<ZKUtil.StringCallback>(); for (int i=0; i < VoltZK.ZK_HIERARCHY.length; i++) { ZKUtil.StringCallback cb = new ZKUtil.StringCallback(); callbacks.add(cb); ...
java
public static List<MailboxNodeContent> parseMailboxContents(List<String> jsons) throws JSONException { ArrayList<MailboxNodeContent> objects = new ArrayList<MailboxNodeContent>(jsons.size()); for (String json : jsons) { MailboxNodeContent content = null; JSONObject jsObj = new JS...
java
public static boolean createMigratePartitionLeaderInfo(ZooKeeper zk, MigratePartitionLeaderInfo info) { try { zk.create(migrate_partition_leader_info, info.toBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } catch (KeeperException e) { if (e.code() == KeeperException.Code.N...
java
public static MigratePartitionLeaderInfo getMigratePartitionLeaderInfo(ZooKeeper zk) { try { byte[] data = zk.getData(migrate_partition_leader_info, null, null); if (data != null) { MigratePartitionLeaderInfo info = new MigratePartitionLeaderInfo(data); re...
java
private boolean convertDateTimeLiteral(Session session, Expression a, Expression b) { if (a.dataType.isDateTimeType()) {} else if (b.dataType.isDateTimeType()) { Expression c = a; a = b; b = c; } else { ...
java
void distributeOr() { if (opType != OpTypes.OR) { return; } if (nodes[LEFT].opType == OpTypes.AND) { opType = OpTypes.AND; Expression temp = new ExpressionLogical(OpTypes.OR, nodes[LEFT].nodes[RIGHT], nodes[RIGHT]); nodes[LEFT]....
java
boolean isSimpleBound() { if (opType == OpTypes.IS_NULL) { return true; } if (nodes[RIGHT] != null) { if (nodes[RIGHT].opType == OpTypes.VALUE) { // also true for all parameters return true; } if (nodes[RIGHT].op...
java
void swapCondition() { int i = OpTypes.EQUAL; switch (opType) { case OpTypes.GREATER_EQUAL : i = OpTypes.SMALLER_EQUAL; break; case OpTypes.SMALLER_EQUAL : i = OpTypes.GREATER_EQUAL; break; case OpTy...
java
private boolean voltConvertBinaryIntegerLiteral(Session session, Expression lhs, Expression rhs) { Expression nonIntegralExpr; int whichChild; if (lhs.dataType.isIntegralType()) { nonIntegralExpr = rhs; whichChild = RIGHT; } else if (rhs.dataType.isIntegra...
java
public final void delete(Row row) { for (int i = indexList.length - 1; i >= 0; i--) { indexList[i].delete(this, row); } remove(row.getPos()); }
java
public int compare(final Object a, final Object b) { final long awhen = ((Task) (a)).getNextScheduled(); final long bwhen = ((Task) (b)).getNextScheduled(); return (awhen < bwhen) ? -1 : (awhen == bwhen) ? 0 : 1; ...
java
public Object scheduleAfter(final long delay, final Runnable runnable) throws IllegalArgumentException { if (runnable == null) { throw new IllegalArgumentException("runnable == null"); } return this.addTask(now() + del...
java
public Object scheduleAt(final Date date, final Runnable runnable) throws IllegalArgumentException { if (date == null) { throw new IllegalArgumentException("date == null"); } else if (runnable == null) { throw new Illegal...
java
public Object schedulePeriodicallyAt(final Date date, final long period, final Runnable runnable, final boolean relative) throws IllegalArgumentException { if (date == null) { ...
java
public Object schedulePeriodicallyAfter(final long delay, final long period, final Runnable runnable, final boolean relative) throws IllegalArgumentException { if (period <= 0) { throw new IllegalArgumentException("period <= 0"); } else if (runnable == null) { ...
java
public synchronized void shutdownImmediately() { if (!this.isShutdown) { final Thread runner = this.taskRunnerThread; this.isShutdown = true; if (runner != null && runner.isAlive()) { runner.interrupt(); } this.taskQueue.cancelAllTa...
java
public static boolean isFixedRate(final Object task) { if (task instanceof Task) { final Task ltask = (Task) task; return (ltask.relative && ltask.period > 0); } else { return false; } }
java
public static boolean isFixedDelay(final Object task) { if (task instanceof Task) { final Task ltask = (Task) task; return (!ltask.relative && ltask.period > 0); } else { return false; } }
java
public static Date getLastScheduled(Object task) { if (task instanceof Task) { final Task ltask = (Task) task; final long last = ltask.getLastScheduled(); return (last == 0) ? null : new Date(last); } else { return null; ...
java
public static Date getNextScheduled(Object task) { if (task instanceof Task) { final Task ltask = (Task) task; final long next = ltask.isCancelled() ? 0 : ltask.getNextScheduled(); return next == 0 ? null ...
java
protected Task addTask(final long first, final Runnable runnable, final long period, boolean relative) { if (this.isShutdown) { throw new IllegalStateException("shutdown"); } final Task task = new Task(first, runnable, period, relative); // sychr...
java
protected Task nextTask() { try { while (!this.isShutdown || Thread.interrupted()) { long now; long next; long wait; Task task; // synchronized to ensure removeTask // applies only to the peeked task, ...
java
ExecutionEngine initializeEE() { String hostname = CoreUtils.getHostnameOrAddress(); HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig(); ExecutionEngine eeTemp = null; Deployment deploy = m_context.cluster.getDeployment().get("deployment"); final int default...
java
private static void handleUndoLog(List<UndoAction> undoLog, boolean undo) { if (undoLog == null) { return; } if (undo) { undoLog = Lists.reverse(undoLog); } for (UndoAction action : undoLog) { if (undo) { action.undo(); ...
java
public boolean updateCatalog(String diffCmds, CatalogContext context, boolean requiresSnapshotIsolationboolean, boolean isMPI, long txnId, long uniqueId, ...
java
public boolean updateSettings(CatalogContext context) { m_context = context; // here you could bring the timeout settings m_loadedProcedures.loadProcedures(m_context); m_ee.loadFunctions(m_context); return true; }
java
@Override public long[] validatePartitioning(long[] tableIds, byte[] hashinatorConfig) { ByteBuffer paramBuffer = m_ee.getParamBufferForExecuteTask(4 + (8 * tableIds.length) + 4 + hashinatorConfig.length); paramBuffer.putInt(tableIds.length); for (long tableId : tableIds) { param...
java
public void generateDREvent(EventType type, long txnId, long uniqueId, long lastCommittedSpHandle, long spHandle, byte[] payloads) { m_ee.quiesce(lastCommittedSpHandle); ByteBuffer paramBuffer = m_ee.getParamBufferForExecuteTask(32 + 16 + payloads.length); paramBuffer.putInt(type.ord...
java
public boolean areRepairLogsComplete() { for (Entry<Long, ReplicaRepairStruct> entry : m_replicaRepairStructs.entrySet()) { if (!entry.getValue().logsComplete()) { return false; } } return true; }
java
public void repairSurvivors() { // cancel() and repair() must be synchronized by the caller (the deliver lock, // currently). If cancelled and the last repair message arrives, don't send // out corrections! if (this.m_promotionResult.isCancelled()) { repairLogger.debug(m_...
java
void addToRepairLog(Iv2RepairLogResponseMessage msg) { // don't add the null payload from the first message ack to the repair log if (msg.getPayload() == null) { return; } // MP repair log has at most two messages, complete message for prior transaction // and fra...
java
static String getSchemaPath(String projectFilePath, String path) throws IOException { File file = null; if (path.contains(".jar!")) { String ddlText = null; ddlText = VoltCompilerUtils.readFileFromJarfile(path); file = VoltProjectBuilder.writeStringToTempFile(ddl...
java
public void loadFunctions(CatalogContext catalogContext) { final CatalogMap<Function> catalogFunctions = catalogContext.database.getFunctions(); // Remove obsolete tokens for (UserDefinedFunctionRunner runner : m_udfs.values()) { // The function that the current UserDefinedFunctionRu...
java
static String readFile(String file) { try { FileReader reader = new FileReader(file); BufferedReader read = new BufferedReader(reader); StringBuffer b = new StringBuffer(); String s = null; int count = 0; ...
java
static String[] getServersFromURL(String url) { // get everything between the prefix and the ? String prefix = URL_PREFIX + "//"; int end = url.length(); if (url.indexOf("?") > 0) { end = url.indexOf("?"); } String servstring = url.substring(prefix.length(), e...
java
private void initializeGenerationFromDisk(final CatalogMap<Connector> connectors, final ExportDataProcessor processor, File[] files, List<Pair<Integer, Integer>> localPartitionsToSites, long genId) { List<Integer> onDiskPartitions = new ArrayList<Integer>(); Navigabl...
java
void initializeGenerationFromCatalog(CatalogContext catalogContext, final CatalogMap<Connector> connectors, final ExportDataProcessor processor, int hostId, List<Pair<Integer, Integer>> localPartitionsToSites, boolean isCatalogUpdate) { // Update c...
java
private void updateStreamStatus( Set<String> exportedTables) { synchronized(m_dataSourcesByPartition) { for (Iterator<Map<String, ExportDataSource>> it = m_dataSourcesByPartition.values().iterator(); it.hasNext();) { Map<String, ExportDataSource> sources = it.next(); ...
java
private void sendDummyTakeMastershipResponse(long sourceHsid, long requestId, int partitionId, byte[] signatureBytes) { // msg type(1) + partition:int(4) + length:int(4) + signaturesBytes.length // requestId(8) int msgLen = 1 + 4 + 4 + signatureBytes.length + 8; ByteBuffer buf = ByteBuff...
java
public void updateAckMailboxes(int partition, Set<Long> newHSIds) { ImmutableList<Long> replicaHSIds = m_replicasHSIds.get(partition); synchronized (m_dataSourcesByPartition) { Map<String, ExportDataSource> partitionMap = m_dataSourcesByPartition.get(partition); if (partitionMap ...
java
private void addDataSources(Table table, int hostId, List<Pair<Integer, Integer>> localPartitionsToSites, Set<Integer> partitionsInUse, final ExportDataProcessor processor, final long genId, boolean isCatalogUpdate) { for (Pair<Integer, Integer> pa...
java
@Override public void onSourceDrained(int partitionId, String tableName) { ExportDataSource source; synchronized(m_dataSourcesByPartition) { Map<String, ExportDataSource> sources = m_dataSourcesByPartition.get(partitionId); if (sources == null) { if (!m_remov...
java
public void add(int index, Object element) { // reporter.updateCounter++; if (index > elementCount) { throw new IndexOutOfBoundsException("Index out of bounds: " + index + ">" + elementCount); } if (index < 0) { thr...
java
public boolean add(Object element) { // reporter.updateCounter++; if (elementCount >= elementData.length) { increaseCapacity(); } elementData[elementCount] = element; elementCount++; return true; }
java
public Object get(int index) { if (index >= elementCount) { throw new IndexOutOfBoundsException("Index out of bounds: " + index + " >= " + elementCount); } if (index < 0) { t...
java
public Object remove(int index) { if (index >= elementCount) { throw new IndexOutOfBoundsException("Index out of bounds: " + index + " >= " + elementCount); } if (index < 0) { ...
java
public Object set(int index, Object element) { if (index >= elementCount) { throw new IndexOutOfBoundsException("Index out of bounds: " + index + " >= " + elementCount); } if (index < 0)...
java
public static boolean bufEquals(byte onearray[], byte twoarray[]) { if (onearray == twoarray) return true; boolean ret = (onearray.length == twoarray.length); if (!ret) { return ret; } for (int idx = 0; idx < onearray.length; idx++) { if (onear...
java
public Connection getConnection(String curDriverIn, String curCharsetIn, String curTrustStoreIn) throws ClassNotFoundException, MalformedURLException, SQLExceptio...
java
static public String tiToString(int ti) { switch (ti) { case Connection.TRANSACTION_READ_UNCOMMITTED: return "TRANSACTION_READ_UNCOMMITTED"; case Connection.TRANSACTION_READ_COMMITTED: return "TRANSACTION_READ_COMMITTED"; case Connection.TRANSA...
java
protected void handleJSONMessageAsDummy(JSONObject obj) throws Exception { hostLog.info("Generating dummy response for ops request " + obj); sendOpsResponse(null, obj, OPS_DUMMY); }
java
public void performOpsAction(final Connection c, final long clientHandle, final OpsSelector selector, final ParameterSet params) throws Exception { m_es.submit(new Runnable() { @Override public void run() { try { collectStatsImpl(c, cli...
java
protected void distributeOpsWork(PendingOpsRequest newRequest, JSONObject obj) throws Exception { if (m_pendingRequests.size() > MAX_IN_FLIGHT_REQUESTS) { /* * Defensively check for an expired request not caught * by timeout check. Should never happen. ...
java
protected void sendClientResponse(PendingOpsRequest request) { byte statusCode = ClientResponse.SUCCESS; String statusString = null; /* * It is possible not to receive a table response if a feature is not enabled */ // All of the null/empty table handling/detecting/gene...
java
private void sendOpsResponse(VoltTable[] results, JSONObject obj, byte payloadType) throws Exception { long requestId = obj.getLong("requestId"); long returnAddress = obj.getLong("returnAddress"); // Send a response with no data since the stats is not supported or not yet available i...
java
private static void addUDFDependences(Function function, Statement catalogStmt) { Procedure procedure = (Procedure)catalogStmt.getParent(); addFunctionDependence(function, procedure, catalogStmt); addStatementDependence(function, catalogStmt); }
java
private static void addFunctionDependence(Function function, Procedure procedure, Statement catalogStmt) { String funcDeps = function.getStmtdependers(); Set<String> stmtSet = new TreeSet<>(); for (String stmtName : funcDeps.split(",")) { if (! stmtName.isEmpty()) { s...
java
private static void addStatementDependence(Function function, Statement catalogStmt) { String fnDeps = catalogStmt.getFunctiondependees(); Set<String> fnSet = new TreeSet<>(); for (String fnName : fnDeps.split(",")) { if (! fnName.isEmpty()) { fnSet.add(fnName); ...
java
static boolean fragmentReferencesPersistentTable(AbstractPlanNode node) { if (node == null) return false; // these nodes can read/modify persistent tables if (node instanceof AbstractScanPlanNode) return true; if (node instanceof InsertPlanNode) retur...
java
public static Procedure compileNibbleDeleteProcedure(Table catTable, String procName, Column col, ComparisonOperation comp) { Procedure newCatProc = addProcedure(catTable, procName); String countingQuery = genSelectSqlForNibbleDelete(catTable, col, comp); addStatement(catTable, newC...
java
public static Procedure compileMigrateProcedure(Table table, String procName, Column column, ComparisonOperation comparison) { Procedure proc = addProcedure(table, procName); // Select count(*) StringBuilder sb = new StringBuilder(); sb.append("SELECT COUNT(*) FROM " + table...
java
public static <E> Collection<E> constrainedCollection( Collection<E> collection, Constraint<? super E> constraint) { return new ConstrainedCollection<E>(collection, constraint); }
java
public static <E> Set<E> constrainedSet(Set<E> set, Constraint<? super E> constraint) { return new ConstrainedSet<E>(set, constraint); }
java
public static <E> SortedSet<E> constrainedSortedSet( SortedSet<E> sortedSet, Constraint<? super E> constraint) { return new ConstrainedSortedSet<E>(sortedSet, constraint); }
java
public static <E> List<E> constrainedList(List<E> list, Constraint<? super E> constraint) { return (list instanceof RandomAccess) ? new ConstrainedRandomAccessList<E>(list, constraint) : new ConstrainedList<E>(list, constraint); }
java
private static <E> ListIterator<E> constrainedListIterator( ListIterator<E> listIterator, Constraint<? super E> constraint) { return new ConstrainedListIterator<E>(listIterator, constraint); }
java
public final Index createIndex(PersistentStore store, HsqlName name, int[] columns, boolean[] descending, boolean[] nullsLast, boolean unique, boolean migrating, boolean constraint, boolean forward) { Index...
java
public Type getCombinedType(Type other, int operation) { if (operation != OpTypes.CONCAT) { return getAggregateType(other); } Type newType; long newPrecision = precision + other.precision; switch (other.typeCode) { case Types.SQL_ALL_TYPES : ...
java
public VoltTable[] run(SystemProcedureExecutionContext ctx) { // Choose the lowest site ID on this host to actually flip the bit if (ctx.isLowestSiteId()) { VoltDBInterface voltdb = VoltDB.instance(); OperationMode opMode = voltdb.getMode(); if (LOG.isDebugEnabled())...
java
@Override public void setGeneratedColumnInfo(int generate, ResultMetaData meta) { // can support INSERT_SELECT also if (type != StatementTypes.INSERT) { return; } int colIndex = baseTable.getIdentityColumnIndex(); if (colIndex == -1) { return; ...
java
void checkAccessRights(Session session) { if (targetTable != null && !targetTable.isTemp()) { targetTable.checkDataReadOnly(); session.checkReadWrite(); } if (session.isAdmin()) { return; } for (int i = 0; i < sequences.length; i++) { ...
java
@Override public ResultMetaData getResultMetaData() { switch (type) { case StatementTypes.DELETE_WHERE : case StatementTypes.INSERT : case StatementTypes.UPDATE_WHERE : case StatementTypes.MIGRATE_WHERE : return ResultMetaData.emptyResultMeta...
java