repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/persist/ScaledRAFile.java | ScaledRAFile.seek | public void seek(long position) throws IOException {
if (!readOnly && file.length() < position) {
long tempSize = position - file.length();
if (tempSize > 1 << 18) {
tempSize = 1 << 18;
}
byte[] temp = new byte[(int) tempSize];
try {
long pos = file.length();
for (; pos < position - tempSize; pos += tempSize) {
file.seek(pos);
file.write(temp, 0, (int) tempSize);
}
file.seek(pos);
file.write(temp, 0, (int) (position - pos));
realPosition = position;
} catch (IOException e) {
appLog.logContext(e, null);
throw e;
}
}
seekPosition = position;
} | java | public void seek(long position) throws IOException {
if (!readOnly && file.length() < position) {
long tempSize = position - file.length();
if (tempSize > 1 << 18) {
tempSize = 1 << 18;
}
byte[] temp = new byte[(int) tempSize];
try {
long pos = file.length();
for (; pos < position - tempSize; pos += tempSize) {
file.seek(pos);
file.write(temp, 0, (int) tempSize);
}
file.seek(pos);
file.write(temp, 0, (int) (position - pos));
realPosition = position;
} catch (IOException e) {
appLog.logContext(e, null);
throw e;
}
}
seekPosition = position;
} | [
"public",
"void",
"seek",
"(",
"long",
"position",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"readOnly",
"&&",
"file",
".",
"length",
"(",
")",
"<",
"position",
")",
"{",
"long",
"tempSize",
"=",
"position",
"-",
"file",
".",
"length",
"(",
... | Some JVM's do not allow seek beyond end of file, so zeros are written
first in that case. Reported by bohgammer@users in Open Disucssion
Forum. | [
"Some",
"JVM",
"s",
"do",
"not",
"allow",
"seek",
"beyond",
"end",
"of",
"file",
"so",
"zeros",
"are",
"written",
"first",
"in",
"that",
"case",
".",
"Reported",
"by",
"bohgammer"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/persist/ScaledRAFile.java#L188-L219 | train |
VoltDB/voltdb | src/frontend/org/voltcore/network/NIOReadStream.java | NIOReadStream.getBytes | void getBytes(byte[] output) {
if (m_totalAvailable < output.length) {
throw new IllegalStateException("Requested " + output.length + " bytes; only have "
+ m_totalAvailable + " bytes; call tryRead() first");
}
int bytesCopied = 0;
while (bytesCopied < output.length) {
BBContainer firstC = m_readBBContainers.peekFirst();
if (firstC == null) {
// Steal the write buffer
m_poolBBContainer.b().flip();
m_readBBContainers.add(m_poolBBContainer);
firstC = m_poolBBContainer;
m_poolBBContainer = null;
}
ByteBuffer first = firstC.b();
assert first.remaining() > 0;
// Copy bytes from first into output
int bytesRemaining = first.remaining();
int bytesToCopy = output.length - bytesCopied;
if (bytesToCopy > bytesRemaining) bytesToCopy = bytesRemaining;
first.get(output, bytesCopied, bytesToCopy);
bytesCopied += bytesToCopy;
m_totalAvailable -= bytesToCopy;
if (first.remaining() == 0) {
// read an entire block: move it to the empty buffers list
m_readBBContainers.poll();
firstC.discard();
}
}
} | java | void getBytes(byte[] output) {
if (m_totalAvailable < output.length) {
throw new IllegalStateException("Requested " + output.length + " bytes; only have "
+ m_totalAvailable + " bytes; call tryRead() first");
}
int bytesCopied = 0;
while (bytesCopied < output.length) {
BBContainer firstC = m_readBBContainers.peekFirst();
if (firstC == null) {
// Steal the write buffer
m_poolBBContainer.b().flip();
m_readBBContainers.add(m_poolBBContainer);
firstC = m_poolBBContainer;
m_poolBBContainer = null;
}
ByteBuffer first = firstC.b();
assert first.remaining() > 0;
// Copy bytes from first into output
int bytesRemaining = first.remaining();
int bytesToCopy = output.length - bytesCopied;
if (bytesToCopy > bytesRemaining) bytesToCopy = bytesRemaining;
first.get(output, bytesCopied, bytesToCopy);
bytesCopied += bytesToCopy;
m_totalAvailable -= bytesToCopy;
if (first.remaining() == 0) {
// read an entire block: move it to the empty buffers list
m_readBBContainers.poll();
firstC.discard();
}
}
} | [
"void",
"getBytes",
"(",
"byte",
"[",
"]",
"output",
")",
"{",
"if",
"(",
"m_totalAvailable",
"<",
"output",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Requested \"",
"+",
"output",
".",
"length",
"+",
"\" bytes; only have \"",
... | Move all bytes in current read buffers to output array, free read buffers
back to thread local memory pool.
@param output | [
"Move",
"all",
"bytes",
"in",
"current",
"read",
"buffers",
"to",
"output",
"array",
"free",
"read",
"buffers",
"back",
"to",
"thread",
"local",
"memory",
"pool",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/network/NIOReadStream.java#L87-L120 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/persist/RowStoreAVLMemory.java | RowStoreAVLMemory.reindex | void reindex(Session session, Index index) {
setAccessor(index, null);
RowIterator it = table.rowIterator(session);
while (it.hasNext()) {
Row row = it.getNextRow();
// may need to clear the node before insert
index.insert(session, this, row);
}
} | java | void reindex(Session session, Index index) {
setAccessor(index, null);
RowIterator it = table.rowIterator(session);
while (it.hasNext()) {
Row row = it.getNextRow();
// may need to clear the node before insert
index.insert(session, this, row);
}
} | [
"void",
"reindex",
"(",
"Session",
"session",
",",
"Index",
"index",
")",
"{",
"setAccessor",
"(",
"index",
",",
"null",
")",
";",
"RowIterator",
"it",
"=",
"table",
".",
"rowIterator",
"(",
"session",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",... | for result tables | [
"for",
"result",
"tables"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/persist/RowStoreAVLMemory.java#L279-L291 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/JDBCXADataSource.java | JDBCXADataSource.getXAConnection | public XAConnection getXAConnection() throws SQLException {
// Comment out before public release:
System.err.print("Executing " + getClass().getName()
+ ".getXAConnection()...");
try {
Class.forName(driver).newInstance();
} catch (ClassNotFoundException e) {
throw new SQLException("Error opening connection: "
+ e.getMessage());
} catch (IllegalAccessException e) {
throw new SQLException("Error opening connection: "
+ e.getMessage());
} catch (InstantiationException e) {
throw new SQLException("Error opening connection: "
+ e.getMessage());
}
JDBCConnection connection =
(JDBCConnection) DriverManager.getConnection(url, connProperties);
// Comment out before public release:
System.err.print("New phys: " + connection);
JDBCXAResource xaResource = new JDBCXAResource(connection, this);
JDBCXAConnectionWrapper xaWrapper =
new JDBCXAConnectionWrapper(connection, xaResource,
connectionDefaults);
JDBCXAConnection xaConnection = new JDBCXAConnection(xaWrapper,
xaResource);
xaWrapper.setPooledConnection(xaConnection);
return xaConnection;
} | java | public XAConnection getXAConnection() throws SQLException {
// Comment out before public release:
System.err.print("Executing " + getClass().getName()
+ ".getXAConnection()...");
try {
Class.forName(driver).newInstance();
} catch (ClassNotFoundException e) {
throw new SQLException("Error opening connection: "
+ e.getMessage());
} catch (IllegalAccessException e) {
throw new SQLException("Error opening connection: "
+ e.getMessage());
} catch (InstantiationException e) {
throw new SQLException("Error opening connection: "
+ e.getMessage());
}
JDBCConnection connection =
(JDBCConnection) DriverManager.getConnection(url, connProperties);
// Comment out before public release:
System.err.print("New phys: " + connection);
JDBCXAResource xaResource = new JDBCXAResource(connection, this);
JDBCXAConnectionWrapper xaWrapper =
new JDBCXAConnectionWrapper(connection, xaResource,
connectionDefaults);
JDBCXAConnection xaConnection = new JDBCXAConnection(xaWrapper,
xaResource);
xaWrapper.setPooledConnection(xaConnection);
return xaConnection;
} | [
"public",
"XAConnection",
"getXAConnection",
"(",
")",
"throws",
"SQLException",
"{",
"// Comment out before public release:",
"System",
".",
"err",
".",
"print",
"(",
"\"Executing \"",
"+",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".getXAConnection().... | Get new PHYSICAL connection, to be managed by a connection manager. | [
"Get",
"new",
"PHYSICAL",
"connection",
"to",
"be",
"managed",
"by",
"a",
"connection",
"manager",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/JDBCXADataSource.java#L122-L157 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/JDBCXADataSource.java | JDBCXADataSource.getXAConnection | public XAConnection getXAConnection(String user,
String password) throws SQLException {
validateSpecifiedUserAndPassword(user, password);
return getXAConnection();
} | java | public XAConnection getXAConnection(String user,
String password) throws SQLException {
validateSpecifiedUserAndPassword(user, password);
return getXAConnection();
} | [
"public",
"XAConnection",
"getXAConnection",
"(",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"SQLException",
"{",
"validateSpecifiedUserAndPassword",
"(",
"user",
",",
"password",
")",
";",
"return",
"getXAConnection",
"(",
")",
";",
"}"
] | Gets a new physical connection after validating the given username
and password.
@param user String which must match the 'user' configured for this
JDBCXADataSource.
@param password String which must match the 'password' configured
for this JDBCXADataSource.
@see #getXAConnection() | [
"Gets",
"a",
"new",
"physical",
"connection",
"after",
"validating",
"the",
"given",
"username",
"and",
"password",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/JDBCXADataSource.java#L170-L176 | train |
VoltDB/voltdb | src/frontend/org/voltdb/importer/ChannelDistributer.java | ChannelDistributer.id | static String id(Object o) {
if (o == null) return "(null)";
Thread t = Thread.currentThread();
StringBuilder sb = new StringBuilder(128);
sb.append("(T[").append(t.getName()).append("]@");
sb.append(Long.toString(t.getId(), Character.MAX_RADIX));
sb.append(":O[").append(o.getClass().getSimpleName());
sb.append("]@");
sb.append(Long.toString(System.identityHashCode(o),Character.MAX_RADIX));
sb.append(")");
return sb.toString();
} | java | static String id(Object o) {
if (o == null) return "(null)";
Thread t = Thread.currentThread();
StringBuilder sb = new StringBuilder(128);
sb.append("(T[").append(t.getName()).append("]@");
sb.append(Long.toString(t.getId(), Character.MAX_RADIX));
sb.append(":O[").append(o.getClass().getSimpleName());
sb.append("]@");
sb.append(Long.toString(System.identityHashCode(o),Character.MAX_RADIX));
sb.append(")");
return sb.toString();
} | [
"static",
"String",
"id",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"return",
"\"(null)\"",
";",
"Thread",
"t",
"=",
"Thread",
".",
"currentThread",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"128",
... | Tracing utility method useful for debugging
@param o and object
@return string with information on the given object | [
"Tracing",
"utility",
"method",
"useful",
"for",
"debugging"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/ChannelDistributer.java#L220-L231 | train |
VoltDB/voltdb | src/frontend/org/voltdb/importer/ChannelDistributer.java | ChannelDistributer.registerCallback | public void registerCallback(String importer, ChannelChangeCallback callback) {
Preconditions.checkArgument(
importer != null && !importer.trim().isEmpty(),
"importer is null or empty"
);
callback = checkNotNull(callback, "callback is null");
if (m_done.get()) return;
int [] stamp = new int[]{0};
NavigableMap<String,ChannelChangeCallback> prev = null;
NavigableMap<String,ChannelChangeCallback> next = null;
ImmutableSortedMap.Builder<String,ChannelChangeCallback> mbldr = null;
synchronized (m_undispatched) {
do {
prev = m_callbacks.get(stamp);
mbldr = ImmutableSortedMap.naturalOrder();
mbldr.putAll(Maps.filterKeys(prev, not(equalTo(importer))));
mbldr.put(importer, callback);
next = mbldr.build();
} while (!m_callbacks.compareAndSet(prev, next, stamp[0], stamp[0]+1));
NavigableSet<String> registered = next.navigableKeySet();
NavigableSet<String> unregistered = m_unregistered.getReference();
Iterator<ImporterChannelAssignment> itr = m_undispatched.iterator();
while (itr.hasNext()) {
final ImporterChannelAssignment assignment = itr.next();
if (registered.contains(assignment.getImporter())) {
final ChannelChangeCallback dispatch = next.get(assignment.getImporter());
m_buses.submit(new DistributerRunnable() {
@Override
public void susceptibleRun() throws Exception {
dispatch.onChange(assignment);
}
});
itr.remove();
} else if (unregistered.contains(assignment.getImporter())) {
itr.remove();
if (!assignment.getAdded().isEmpty()) {
LOG.warn("(" + m_hostId
+ ") discarding assignment to unregistered importer "
+ assignment);
}
}
}
}
} | java | public void registerCallback(String importer, ChannelChangeCallback callback) {
Preconditions.checkArgument(
importer != null && !importer.trim().isEmpty(),
"importer is null or empty"
);
callback = checkNotNull(callback, "callback is null");
if (m_done.get()) return;
int [] stamp = new int[]{0};
NavigableMap<String,ChannelChangeCallback> prev = null;
NavigableMap<String,ChannelChangeCallback> next = null;
ImmutableSortedMap.Builder<String,ChannelChangeCallback> mbldr = null;
synchronized (m_undispatched) {
do {
prev = m_callbacks.get(stamp);
mbldr = ImmutableSortedMap.naturalOrder();
mbldr.putAll(Maps.filterKeys(prev, not(equalTo(importer))));
mbldr.put(importer, callback);
next = mbldr.build();
} while (!m_callbacks.compareAndSet(prev, next, stamp[0], stamp[0]+1));
NavigableSet<String> registered = next.navigableKeySet();
NavigableSet<String> unregistered = m_unregistered.getReference();
Iterator<ImporterChannelAssignment> itr = m_undispatched.iterator();
while (itr.hasNext()) {
final ImporterChannelAssignment assignment = itr.next();
if (registered.contains(assignment.getImporter())) {
final ChannelChangeCallback dispatch = next.get(assignment.getImporter());
m_buses.submit(new DistributerRunnable() {
@Override
public void susceptibleRun() throws Exception {
dispatch.onChange(assignment);
}
});
itr.remove();
} else if (unregistered.contains(assignment.getImporter())) {
itr.remove();
if (!assignment.getAdded().isEmpty()) {
LOG.warn("(" + m_hostId
+ ") discarding assignment to unregistered importer "
+ assignment);
}
}
}
}
} | [
"public",
"void",
"registerCallback",
"(",
"String",
"importer",
",",
"ChannelChangeCallback",
"callback",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"importer",
"!=",
"null",
"&&",
"!",
"importer",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
... | Registers a (@link ChannelChangeCallback} for the given importer.
@param importer
@param callback a (@link ChannelChangeCallback} | [
"Registers",
"a",
"("
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/ChannelDistributer.java#L412-L460 | train |
VoltDB/voltdb | src/frontend/org/voltdb/importer/ChannelDistributer.java | ChannelDistributer.unregisterCallback | public void unregisterCallback(String importer) {
if ( importer == null
|| !m_callbacks.getReference().containsKey(importer)
|| m_unregistered.getReference().contains(importer))
{
return;
}
if (m_done.get()) return;
int [] rstamp = new int[]{0};
NavigableMap<String,ChannelChangeCallback> rprev = null;
NavigableMap<String,ChannelChangeCallback> rnext = null;
int [] ustamp = new int[]{0};
NavigableSet<String> uprev = null;
NavigableSet<String> unext = null;
synchronized(m_undispatched) {
do {
rprev = m_callbacks.get(rstamp);
rnext = ImmutableSortedMap.<String,ChannelChangeCallback>naturalOrder()
.putAll(Maps.filterKeys(rprev, not(equalTo(importer))))
.build();
} while (rprev.containsKey(importer) && !m_callbacks.compareAndSet(rprev, rnext, rstamp[0], rstamp[0]+1));
do {
uprev = m_unregistered.get(ustamp);
unext = ImmutableSortedSet.<String>naturalOrder()
.addAll(Sets.filter(uprev, not(equalTo(importer))))
.add(importer)
.build();
} while (!uprev.contains(importer) && m_unregistered.compareAndSet(uprev, unext, ustamp[0], ustamp[0]+1));
Iterator<ImporterChannelAssignment> itr = m_undispatched.iterator();
while (itr.hasNext()) {
final ImporterChannelAssignment assignment = itr.next();
if (unext.contains(assignment.getImporter())) {
itr.remove();
}
}
}
} | java | public void unregisterCallback(String importer) {
if ( importer == null
|| !m_callbacks.getReference().containsKey(importer)
|| m_unregistered.getReference().contains(importer))
{
return;
}
if (m_done.get()) return;
int [] rstamp = new int[]{0};
NavigableMap<String,ChannelChangeCallback> rprev = null;
NavigableMap<String,ChannelChangeCallback> rnext = null;
int [] ustamp = new int[]{0};
NavigableSet<String> uprev = null;
NavigableSet<String> unext = null;
synchronized(m_undispatched) {
do {
rprev = m_callbacks.get(rstamp);
rnext = ImmutableSortedMap.<String,ChannelChangeCallback>naturalOrder()
.putAll(Maps.filterKeys(rprev, not(equalTo(importer))))
.build();
} while (rprev.containsKey(importer) && !m_callbacks.compareAndSet(rprev, rnext, rstamp[0], rstamp[0]+1));
do {
uprev = m_unregistered.get(ustamp);
unext = ImmutableSortedSet.<String>naturalOrder()
.addAll(Sets.filter(uprev, not(equalTo(importer))))
.add(importer)
.build();
} while (!uprev.contains(importer) && m_unregistered.compareAndSet(uprev, unext, ustamp[0], ustamp[0]+1));
Iterator<ImporterChannelAssignment> itr = m_undispatched.iterator();
while (itr.hasNext()) {
final ImporterChannelAssignment assignment = itr.next();
if (unext.contains(assignment.getImporter())) {
itr.remove();
}
}
}
} | [
"public",
"void",
"unregisterCallback",
"(",
"String",
"importer",
")",
"{",
"if",
"(",
"importer",
"==",
"null",
"||",
"!",
"m_callbacks",
".",
"getReference",
"(",
")",
".",
"containsKey",
"(",
"importer",
")",
"||",
"m_unregistered",
".",
"getReference",
... | Unregisters the callback assigned to given importer. Once it is
unregistered it can no longer be re-registered
@param importer | [
"Unregisters",
"the",
"callback",
"assigned",
"to",
"given",
"importer",
".",
"Once",
"it",
"is",
"unregistered",
"it",
"can",
"no",
"longer",
"be",
"re",
"-",
"registered"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/ChannelDistributer.java#L468-L509 | train |
VoltDB/voltdb | src/frontend/org/voltdb/importer/ChannelDistributer.java | ChannelDistributer.shutdown | public void shutdown() {
if (m_done.compareAndSet(false, true)) {
m_es.shutdown();
m_buses.shutdown();
DeleteNode deleteHost = new DeleteNode(joinZKPath(HOST_DN, m_hostId));
DeleteNode deleteCandidate = new DeleteNode(m_candidate);
try {
m_es.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
try {
m_buses.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
deleteHost.onComplete();
deleteCandidate.onComplete();
}
} | java | public void shutdown() {
if (m_done.compareAndSet(false, true)) {
m_es.shutdown();
m_buses.shutdown();
DeleteNode deleteHost = new DeleteNode(joinZKPath(HOST_DN, m_hostId));
DeleteNode deleteCandidate = new DeleteNode(m_candidate);
try {
m_es.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
try {
m_buses.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
deleteHost.onComplete();
deleteCandidate.onComplete();
}
} | [
"public",
"void",
"shutdown",
"(",
")",
"{",
"if",
"(",
"m_done",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"m_es",
".",
"shutdown",
"(",
")",
";",
"m_buses",
".",
"shutdown",
"(",
")",
";",
"DeleteNode",
"deleteHost",
"=",
"new... | Sets the done flag, shuts down its executor thread, and deletes its own host
and candidate nodes | [
"Sets",
"the",
"done",
"flag",
"shuts",
"down",
"its",
"executor",
"thread",
"and",
"deletes",
"its",
"own",
"host",
"and",
"candidate",
"nodes"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/ChannelDistributer.java#L515-L534 | train |
VoltDB/voltdb | src/frontend/org/voltdb/importer/ChannelDistributer.java | ChannelDistributer.undispatched | @Subscribe
public void undispatched(DeadEvent e) {
if (!m_done.get() && e.getEvent() instanceof ImporterChannelAssignment) {
ImporterChannelAssignment assignment = (ImporterChannelAssignment)e.getEvent();
synchronized (m_undispatched) {
NavigableSet<String> registered = m_callbacks.getReference().navigableKeySet();
NavigableSet<String> unregistered = m_unregistered.getReference();
if (registered.contains(assignment.getImporter())) {
m_eb.post(assignment);
} else if (!assignment.getAdded().isEmpty()
&& unregistered.contains(assignment.getImporter())) {
LOG.warn("(" + m_hostId
+ ") disgarding assignment to unregistered importer "
+ assignment);
} else {
m_undispatched.add(assignment);
}
}
}
} | java | @Subscribe
public void undispatched(DeadEvent e) {
if (!m_done.get() && e.getEvent() instanceof ImporterChannelAssignment) {
ImporterChannelAssignment assignment = (ImporterChannelAssignment)e.getEvent();
synchronized (m_undispatched) {
NavigableSet<String> registered = m_callbacks.getReference().navigableKeySet();
NavigableSet<String> unregistered = m_unregistered.getReference();
if (registered.contains(assignment.getImporter())) {
m_eb.post(assignment);
} else if (!assignment.getAdded().isEmpty()
&& unregistered.contains(assignment.getImporter())) {
LOG.warn("(" + m_hostId
+ ") disgarding assignment to unregistered importer "
+ assignment);
} else {
m_undispatched.add(assignment);
}
}
}
} | [
"@",
"Subscribe",
"public",
"void",
"undispatched",
"(",
"DeadEvent",
"e",
")",
"{",
"if",
"(",
"!",
"m_done",
".",
"get",
"(",
")",
"&&",
"e",
".",
"getEvent",
"(",
")",
"instanceof",
"ImporterChannelAssignment",
")",
"{",
"ImporterChannelAssignment",
"assi... | Keeps assignments for unregistered importers
@param e | [
"Keeps",
"assignments",
"for",
"unregistered",
"importers"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/ChannelDistributer.java#L540-L560 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/WrapperIterator.java | WrapperIterator.next | public Object next() {
// for chained iterators
if (chained) {
if (it1 == null) {
if (it2 == null) {
throw new NoSuchElementException();
}
if (it2.hasNext()) {
return it2.next();
}
it2 = null;
next();
} else {
if (it1.hasNext()) {
return it1.next();
}
it1 = null;
next();
}
}
// for other itertors
if (hasNext()) {
return elements[i++];
}
throw new NoSuchElementException();
} | java | public Object next() {
// for chained iterators
if (chained) {
if (it1 == null) {
if (it2 == null) {
throw new NoSuchElementException();
}
if (it2.hasNext()) {
return it2.next();
}
it2 = null;
next();
} else {
if (it1.hasNext()) {
return it1.next();
}
it1 = null;
next();
}
}
// for other itertors
if (hasNext()) {
return elements[i++];
}
throw new NoSuchElementException();
} | [
"public",
"Object",
"next",
"(",
")",
"{",
"// for chained iterators",
"if",
"(",
"chained",
")",
"{",
"if",
"(",
"it1",
"==",
"null",
")",
"{",
"if",
"(",
"it2",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"}",
"... | Returns the next element.
@return the next element
@throws NoSuchElementException if there is no next element | [
"Returns",
"the",
"next",
"element",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/WrapperIterator.java#L164-L197 | train |
VoltDB/voltdb | src/frontend/org/voltdb/dtxn/SiteTracker.java | SiteTracker.getSitesForPartitions | public List<Long> getSitesForPartitions(int[] partitions) {
ArrayList<Long> all_sites = new ArrayList<Long>();
for (int p : partitions) {
List<Long> sites = getSitesForPartition(p);
for (long site : sites)
{
all_sites.add(site);
}
}
return all_sites;
} | java | public List<Long> getSitesForPartitions(int[] partitions) {
ArrayList<Long> all_sites = new ArrayList<Long>();
for (int p : partitions) {
List<Long> sites = getSitesForPartition(p);
for (long site : sites)
{
all_sites.add(site);
}
}
return all_sites;
} | [
"public",
"List",
"<",
"Long",
">",
"getSitesForPartitions",
"(",
"int",
"[",
"]",
"partitions",
")",
"{",
"ArrayList",
"<",
"Long",
">",
"all_sites",
"=",
"new",
"ArrayList",
"<",
"Long",
">",
"(",
")",
";",
"for",
"(",
"int",
"p",
":",
"partitions",
... | Get the ids of all sites that contain a copy of ANY of
the given partitions.
@param partitions as ArrayList | [
"Get",
"the",
"ids",
"of",
"all",
"sites",
"that",
"contain",
"a",
"copy",
"of",
"ANY",
"of",
"the",
"given",
"partitions",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/dtxn/SiteTracker.java#L346-L356 | train |
VoltDB/voltdb | src/frontend/org/voltdb/dtxn/SiteTracker.java | SiteTracker.getSitesForPartitionsAsArray | public long[] getSitesForPartitionsAsArray(int[] partitions) {
ArrayList<Long> all_sites = new ArrayList<Long>();
for (int p : partitions) {
List<Long> sites = getSitesForPartition(p);
for (long site : sites)
{
all_sites.add(site);
}
}
return longListToArray(all_sites);
} | java | public long[] getSitesForPartitionsAsArray(int[] partitions) {
ArrayList<Long> all_sites = new ArrayList<Long>();
for (int p : partitions) {
List<Long> sites = getSitesForPartition(p);
for (long site : sites)
{
all_sites.add(site);
}
}
return longListToArray(all_sites);
} | [
"public",
"long",
"[",
"]",
"getSitesForPartitionsAsArray",
"(",
"int",
"[",
"]",
"partitions",
")",
"{",
"ArrayList",
"<",
"Long",
">",
"all_sites",
"=",
"new",
"ArrayList",
"<",
"Long",
">",
"(",
")",
";",
"for",
"(",
"int",
"p",
":",
"partitions",
"... | Get the ids of all live sites that contain a copy of ANY of
the given partitions.
@param partitions A set of unique, non-null VoltDB
partition ids.
@return An array of VoltDB site ids. | [
"Get",
"the",
"ids",
"of",
"all",
"live",
"sites",
"that",
"contain",
"a",
"copy",
"of",
"ANY",
"of",
"the",
"given",
"partitions",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/dtxn/SiteTracker.java#L377-L387 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/tar/TarFileInputStream.java | TarFileInputStream.readCompressedBlocks | protected void readCompressedBlocks(int blocks) throws IOException {
int bytesSoFar = 0;
int requiredBytes = 512 * blocks;
// This method works with individual bytes!
int i;
while (bytesSoFar < requiredBytes) {
i = readStream.read(readBuffer, bytesSoFar,
requiredBytes - bytesSoFar);
if (i < 0) {
// A VoltDB extension to disable tagging eof as an error.
return;
/* disable 3 lines ...
throw new EOFException(
RB.singleton.getString(
RB.DECOMPRESS_RANOUT, bytesSoFar, requiredBytes));
... disabled 3 lines */
// End of VoltDB extension
}
bytesRead += i;
bytesSoFar += i;
}
} | java | protected void readCompressedBlocks(int blocks) throws IOException {
int bytesSoFar = 0;
int requiredBytes = 512 * blocks;
// This method works with individual bytes!
int i;
while (bytesSoFar < requiredBytes) {
i = readStream.read(readBuffer, bytesSoFar,
requiredBytes - bytesSoFar);
if (i < 0) {
// A VoltDB extension to disable tagging eof as an error.
return;
/* disable 3 lines ...
throw new EOFException(
RB.singleton.getString(
RB.DECOMPRESS_RANOUT, bytesSoFar, requiredBytes));
... disabled 3 lines */
// End of VoltDB extension
}
bytesRead += i;
bytesSoFar += i;
}
} | [
"protected",
"void",
"readCompressedBlocks",
"(",
"int",
"blocks",
")",
"throws",
"IOException",
"{",
"int",
"bytesSoFar",
"=",
"0",
";",
"int",
"requiredBytes",
"=",
"512",
"*",
"blocks",
";",
"// This method works with individual bytes!",
"int",
"i",
";",
"while... | Work-around for the problem that compressed InputReaders don't fill
the read buffer before returning.
Has visibility 'protected' so that subclasses may override with
different algorithms, or use different algorithms for different
compression stream. | [
"Work",
"-",
"around",
"for",
"the",
"problem",
"that",
"compressed",
"InputReaders",
"don",
"t",
"fill",
"the",
"read",
"buffer",
"before",
"returning",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/tar/TarFileInputStream.java#L210-L236 | train |
VoltDB/voltdb | third_party/java/src/com/google_voltpatches/common/collect/ObjectArrays.java | ObjectArrays.arraysCopyOf | static <T> T[] arraysCopyOf(T[] original, int newLength) {
T[] copy = newArray(original, newLength);
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
} | java | static <T> T[] arraysCopyOf(T[] original, int newLength) {
T[] copy = newArray(original, newLength);
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
} | [
"static",
"<",
"T",
">",
"T",
"[",
"]",
"arraysCopyOf",
"(",
"T",
"[",
"]",
"original",
",",
"int",
"newLength",
")",
"{",
"T",
"[",
"]",
"copy",
"=",
"newArray",
"(",
"original",
",",
"newLength",
")",
";",
"System",
".",
"arraycopy",
"(",
"origin... | GWT safe version of Arrays.copyOf. | [
"GWT",
"safe",
"version",
"of",
"Arrays",
".",
"copyOf",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/collect/ObjectArrays.java#L110-L114 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.initialize | public static void initialize(Class<? extends TheHashinator> hashinatorImplementation, byte config[]) {
TheHashinator hashinator = constructHashinator( hashinatorImplementation, config, false);
m_pristineHashinator = hashinator;
m_cachedHashinators.put(0L, hashinator);
instance.set(Pair.of(0L, hashinator));
} | java | public static void initialize(Class<? extends TheHashinator> hashinatorImplementation, byte config[]) {
TheHashinator hashinator = constructHashinator( hashinatorImplementation, config, false);
m_pristineHashinator = hashinator;
m_cachedHashinators.put(0L, hashinator);
instance.set(Pair.of(0L, hashinator));
} | [
"public",
"static",
"void",
"initialize",
"(",
"Class",
"<",
"?",
"extends",
"TheHashinator",
">",
"hashinatorImplementation",
",",
"byte",
"config",
"[",
"]",
")",
"{",
"TheHashinator",
"hashinator",
"=",
"constructHashinator",
"(",
"hashinatorImplementation",
",",... | Initialize TheHashinator with the specified implementation class and configuration.
The starting version number will be 0. | [
"Initialize",
"TheHashinator",
"with",
"the",
"specified",
"implementation",
"class",
"and",
"configuration",
".",
"The",
"starting",
"version",
"number",
"will",
"be",
"0",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L114-L119 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.getHashinator | public static TheHashinator getHashinator(Class<? extends TheHashinator> hashinatorImplementation,
byte config[], boolean cooked) {
return constructHashinator(hashinatorImplementation, config, cooked);
} | java | public static TheHashinator getHashinator(Class<? extends TheHashinator> hashinatorImplementation,
byte config[], boolean cooked) {
return constructHashinator(hashinatorImplementation, config, cooked);
} | [
"public",
"static",
"TheHashinator",
"getHashinator",
"(",
"Class",
"<",
"?",
"extends",
"TheHashinator",
">",
"hashinatorImplementation",
",",
"byte",
"config",
"[",
"]",
",",
"boolean",
"cooked",
")",
"{",
"return",
"constructHashinator",
"(",
"hashinatorImplement... | Get TheHashinator instanced based on known implementation and configuration.
Used by client after asking server what it is running.
@param hashinatorImplementation
@param config
@return | [
"Get",
"TheHashinator",
"instanced",
"based",
"on",
"known",
"implementation",
"and",
"configuration",
".",
"Used",
"by",
"client",
"after",
"asking",
"server",
"what",
"it",
"is",
"running",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L129-L132 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.constructHashinator | public static TheHashinator
constructHashinator(
Class<? extends TheHashinator> hashinatorImplementation,
byte configBytes[], boolean cooked) {
try {
Constructor<? extends TheHashinator> constructor =
hashinatorImplementation.getConstructor(byte[].class, boolean.class);
return constructor.newInstance(configBytes, cooked);
} catch (Exception e) {
Throwables.propagate(e);
}
return null;
} | java | public static TheHashinator
constructHashinator(
Class<? extends TheHashinator> hashinatorImplementation,
byte configBytes[], boolean cooked) {
try {
Constructor<? extends TheHashinator> constructor =
hashinatorImplementation.getConstructor(byte[].class, boolean.class);
return constructor.newInstance(configBytes, cooked);
} catch (Exception e) {
Throwables.propagate(e);
}
return null;
} | [
"public",
"static",
"TheHashinator",
"constructHashinator",
"(",
"Class",
"<",
"?",
"extends",
"TheHashinator",
">",
"hashinatorImplementation",
",",
"byte",
"configBytes",
"[",
"]",
",",
"boolean",
"cooked",
")",
"{",
"try",
"{",
"Constructor",
"<",
"?",
"exten... | Helper method to do the reflection boilerplate to call the constructor
of the selected hashinator and convert the exceptions to runtime exceptions.
@param hashinatorImplementation hashinator class
@param configBytes config data (raw or cooked)
@param cooked true if configBytes is cooked, i.e. in wire serialization format
@return the constructed hashinator | [
"Helper",
"method",
"to",
"do",
"the",
"reflection",
"boilerplate",
"to",
"call",
"the",
"constructor",
"of",
"the",
"selected",
"hashinator",
"and",
"convert",
"the",
"exceptions",
"to",
"runtime",
"exceptions",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L142-L154 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.computeConfigurationSignature | static public long computeConfigurationSignature(byte [] config) {
PureJavaCrc32C crc = new PureJavaCrc32C();
crc.update(config);
return crc.getValue();
} | java | static public long computeConfigurationSignature(byte [] config) {
PureJavaCrc32C crc = new PureJavaCrc32C();
crc.update(config);
return crc.getValue();
} | [
"static",
"public",
"long",
"computeConfigurationSignature",
"(",
"byte",
"[",
"]",
"config",
")",
"{",
"PureJavaCrc32C",
"crc",
"=",
"new",
"PureJavaCrc32C",
"(",
")",
";",
"crc",
".",
"update",
"(",
"config",
")",
";",
"return",
"crc",
".",
"getValue",
"... | It computes a signature from the given configuration bytes
@param config configuration byte array
@return signature from the given configuration bytes | [
"It",
"computes",
"a",
"signature",
"from",
"the",
"given",
"configuration",
"bytes"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L207-L211 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.getPartitionForParameter | public static int getPartitionForParameter(VoltType partitionType, Object invocationParameter) {
return instance.get().getSecond().getHashedPartitionForParameter(partitionType, invocationParameter);
} | java | public static int getPartitionForParameter(VoltType partitionType, Object invocationParameter) {
return instance.get().getSecond().getHashedPartitionForParameter(partitionType, invocationParameter);
} | [
"public",
"static",
"int",
"getPartitionForParameter",
"(",
"VoltType",
"partitionType",
",",
"Object",
"invocationParameter",
")",
"{",
"return",
"instance",
".",
"get",
"(",
")",
".",
"getSecond",
"(",
")",
".",
"getHashedPartitionForParameter",
"(",
"partitionTyp... | Given the type of the targeting partition parameter and an object,
coerce the object to the correct type and hash it.
NOTE NOTE NOTE NOTE! THIS SHOULD BE THE ONLY WAY THAT
YOU FIGURE OUT THE PARTITIONING FOR A PARAMETER! ON SERVER
@return The partition best set up to execute the procedure.
@throws VoltTypeException | [
"Given",
"the",
"type",
"of",
"the",
"targeting",
"partition",
"parameter",
"and",
"an",
"object",
"coerce",
"the",
"object",
"to",
"the",
"correct",
"type",
"and",
"hash",
"it",
".",
"NOTE",
"NOTE",
"NOTE",
"NOTE!",
"THIS",
"SHOULD",
"BE",
"THE",
"ONLY",
... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L238-L240 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.updateHashinator | public static Pair<? extends UndoAction, TheHashinator> updateHashinator(
Class<? extends TheHashinator> hashinatorImplementation,
long version,
byte configBytes[],
boolean cooked) {
//Use a cached/canonical hashinator if possible
TheHashinator existingHashinator = m_cachedHashinators.get(version);
if (existingHashinator == null) {
existingHashinator = constructHashinator(hashinatorImplementation, configBytes, cooked);
TheHashinator tempVal = m_cachedHashinators.putIfAbsent( version, existingHashinator);
if (tempVal != null) {
existingHashinator = tempVal;
}
}
//Do a CAS loop to maintain a global instance
while (true) {
final Pair<Long, ? extends TheHashinator> snapshot = instance.get();
if (version > snapshot.getFirst()) {
final Pair<Long, ? extends TheHashinator> update =
Pair.of(version, existingHashinator);
if (instance.compareAndSet(snapshot, update)) {
if (!m_elasticallyModified) {
if (!update.getSecond().pIsPristine()) {
// This is not a lock protected (atomic) but it should be fine because
// release() should only be called by the one thread that successfully
// updated the hashinator
hostLogger.debug("The Hashinator has been elastically modified.");
m_elasticallyModified = true;
}
}
// Note: Only undo is ever called and only from a failure in @BalancePartitions
return Pair.of(new UndoAction() {
@Override
public void release() {}
@Override
public void undo() {
boolean rolledBack = instance.compareAndSet(update, snapshot);
if (!rolledBack) {
hostLogger.info(
"Didn't roll back hashinator because it wasn't set to expected hashinator");
}
}
}, existingHashinator);
}
} else {
return Pair.of(new UndoAction() {
@Override
public void release() {}
@Override
public void undo() {}
}, existingHashinator);
}
}
} | java | public static Pair<? extends UndoAction, TheHashinator> updateHashinator(
Class<? extends TheHashinator> hashinatorImplementation,
long version,
byte configBytes[],
boolean cooked) {
//Use a cached/canonical hashinator if possible
TheHashinator existingHashinator = m_cachedHashinators.get(version);
if (existingHashinator == null) {
existingHashinator = constructHashinator(hashinatorImplementation, configBytes, cooked);
TheHashinator tempVal = m_cachedHashinators.putIfAbsent( version, existingHashinator);
if (tempVal != null) {
existingHashinator = tempVal;
}
}
//Do a CAS loop to maintain a global instance
while (true) {
final Pair<Long, ? extends TheHashinator> snapshot = instance.get();
if (version > snapshot.getFirst()) {
final Pair<Long, ? extends TheHashinator> update =
Pair.of(version, existingHashinator);
if (instance.compareAndSet(snapshot, update)) {
if (!m_elasticallyModified) {
if (!update.getSecond().pIsPristine()) {
// This is not a lock protected (atomic) but it should be fine because
// release() should only be called by the one thread that successfully
// updated the hashinator
hostLogger.debug("The Hashinator has been elastically modified.");
m_elasticallyModified = true;
}
}
// Note: Only undo is ever called and only from a failure in @BalancePartitions
return Pair.of(new UndoAction() {
@Override
public void release() {}
@Override
public void undo() {
boolean rolledBack = instance.compareAndSet(update, snapshot);
if (!rolledBack) {
hostLogger.info(
"Didn't roll back hashinator because it wasn't set to expected hashinator");
}
}
}, existingHashinator);
}
} else {
return Pair.of(new UndoAction() {
@Override
public void release() {}
@Override
public void undo() {}
}, existingHashinator);
}
}
} | [
"public",
"static",
"Pair",
"<",
"?",
"extends",
"UndoAction",
",",
"TheHashinator",
">",
"updateHashinator",
"(",
"Class",
"<",
"?",
"extends",
"TheHashinator",
">",
"hashinatorImplementation",
",",
"long",
"version",
",",
"byte",
"configBytes",
"[",
"]",
",",
... | Update the hashinator in a thread safe manner with a newer version of the hash function.
A version number must be provided and the new config will only be used if it is greater than
the current version of the hash function.
Returns an action for undoing the hashinator update
@param hashinatorImplementation hashinator class
@param version hashinator version/txn id
@param configBytes config data (format determined by cooked flag)
@param cooked compressible wire serialization format if true | [
"Update",
"the",
"hashinator",
"in",
"a",
"thread",
"safe",
"manner",
"with",
"a",
"newer",
"version",
"of",
"the",
"hash",
"function",
".",
"A",
"version",
"number",
"must",
"be",
"provided",
"and",
"the",
"new",
"config",
"will",
"only",
"be",
"used",
... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L325-L382 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.getRanges | public static Map<Integer, Integer> getRanges(int partition) {
return instance.get().getSecond().pGetRanges(partition);
} | java | public static Map<Integer, Integer> getRanges(int partition) {
return instance.get().getSecond().pGetRanges(partition);
} | [
"public",
"static",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"getRanges",
"(",
"int",
"partition",
")",
"{",
"return",
"instance",
".",
"get",
"(",
")",
".",
"getSecond",
"(",
")",
".",
"pGetRanges",
"(",
"partition",
")",
";",
"}"
] | Get the ranges the given partition is assigned to.
@param partition
@return A map of ranges, the key is the start of a range, the value is
the corresponding end. Ranges returned in the map are [start, end).
The ranges may or may not be contiguous. | [
"Get",
"the",
"ranges",
"the",
"given",
"partition",
"is",
"assigned",
"to",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L418-L420 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.serializeConfiguredHashinator | public static HashinatorSnapshotData serializeConfiguredHashinator()
throws IOException
{
Pair<Long, ? extends TheHashinator> currentInstance = instance.get();
byte[] cookedData = currentInstance.getSecond().getCookedBytes();
return new HashinatorSnapshotData(cookedData, currentInstance.getFirst());
} | java | public static HashinatorSnapshotData serializeConfiguredHashinator()
throws IOException
{
Pair<Long, ? extends TheHashinator> currentInstance = instance.get();
byte[] cookedData = currentInstance.getSecond().getCookedBytes();
return new HashinatorSnapshotData(cookedData, currentInstance.getFirst());
} | [
"public",
"static",
"HashinatorSnapshotData",
"serializeConfiguredHashinator",
"(",
")",
"throws",
"IOException",
"{",
"Pair",
"<",
"Long",
",",
"?",
"extends",
"TheHashinator",
">",
"currentInstance",
"=",
"instance",
".",
"get",
"(",
")",
";",
"byte",
"[",
"]"... | Get optimized configuration data for wire serialization.
@return optimized configuration data
@throws IOException | [
"Get",
"optimized",
"configuration",
"data",
"for",
"wire",
"serialization",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L427-L433 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.updateConfiguredHashinator | public static Pair< ? extends UndoAction, TheHashinator> updateConfiguredHashinator(long version, byte config[]) {
return updateHashinator(getConfiguredHashinatorClass(), version, config, true);
} | java | public static Pair< ? extends UndoAction, TheHashinator> updateConfiguredHashinator(long version, byte config[]) {
return updateHashinator(getConfiguredHashinatorClass(), version, config, true);
} | [
"public",
"static",
"Pair",
"<",
"?",
"extends",
"UndoAction",
",",
"TheHashinator",
">",
"updateConfiguredHashinator",
"(",
"long",
"version",
",",
"byte",
"config",
"[",
"]",
")",
"{",
"return",
"updateHashinator",
"(",
"getConfiguredHashinatorClass",
"(",
")",
... | Update the current configured hashinator class. Used by snapshot restore.
@param version
@param config
@return Pair<UndoAction, TheHashinator> Undo action to revert hashinator update and the hashinator that was
requested which may actually be an older one (although the one requested) during live rejoin | [
"Update",
"the",
"current",
"configured",
"hashinator",
"class",
".",
"Used",
"by",
"snapshot",
"restore",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L442-L444 | train |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.getPartitionKeys | public static VoltTable getPartitionKeys(TheHashinator hashinator, VoltType type) {
// get partitionKeys response table so we can copy it
final VoltTable partitionKeys;
switch (type) {
case INTEGER:
partitionKeys = hashinator.m_integerPartitionKeys.get();
break;
case STRING:
partitionKeys = hashinator.m_stringPartitionKeys.get();
break;
case VARBINARY:
partitionKeys = hashinator.m_varbinaryPartitionKeys.get();
break;
default:
return null;
}
// return a clone because if the table is used at all in the voltdb process,
// (like by an NT procedure),
// you can corrupt the various offsets and positions in the underlying buffer
return partitionKeys.semiDeepCopy();
} | java | public static VoltTable getPartitionKeys(TheHashinator hashinator, VoltType type) {
// get partitionKeys response table so we can copy it
final VoltTable partitionKeys;
switch (type) {
case INTEGER:
partitionKeys = hashinator.m_integerPartitionKeys.get();
break;
case STRING:
partitionKeys = hashinator.m_stringPartitionKeys.get();
break;
case VARBINARY:
partitionKeys = hashinator.m_varbinaryPartitionKeys.get();
break;
default:
return null;
}
// return a clone because if the table is used at all in the voltdb process,
// (like by an NT procedure),
// you can corrupt the various offsets and positions in the underlying buffer
return partitionKeys.semiDeepCopy();
} | [
"public",
"static",
"VoltTable",
"getPartitionKeys",
"(",
"TheHashinator",
"hashinator",
",",
"VoltType",
"type",
")",
"{",
"// get partitionKeys response table so we can copy it",
"final",
"VoltTable",
"partitionKeys",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"INT... | Get a VoltTable containing the partition keys for each partition that can be found for the given hashinator.
May be missing some partitions during elastic rebalance when the partitions don't own
enough of the ring to be probed
If the type is not supported returns null
@param hashinator a particular hashinator to get partition keys
@param type key type
@return a VoltTable containing the partition keys | [
"Get",
"a",
"VoltTable",
"containing",
"the",
"partition",
"keys",
"for",
"each",
"partition",
"that",
"can",
"be",
"found",
"for",
"the",
"given",
"hashinator",
".",
"May",
"be",
"missing",
"some",
"partitions",
"during",
"elastic",
"rebalance",
"when",
"the"... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L529-L551 | train |
VoltDB/voltdb | src/frontend/org/voltdb/DRConsumerDrIdTracker.java | DRConsumerDrIdTracker.append | public void append(long startDrId, long endDrId, long spUniqueId, long mpUniqueId) {
assert(startDrId <= endDrId && (m_map.isEmpty() || startDrId > end(m_map.span())));
addRange(startDrId, endDrId, spUniqueId, mpUniqueId);
} | java | public void append(long startDrId, long endDrId, long spUniqueId, long mpUniqueId) {
assert(startDrId <= endDrId && (m_map.isEmpty() || startDrId > end(m_map.span())));
addRange(startDrId, endDrId, spUniqueId, mpUniqueId);
} | [
"public",
"void",
"append",
"(",
"long",
"startDrId",
",",
"long",
"endDrId",
",",
"long",
"spUniqueId",
",",
"long",
"mpUniqueId",
")",
"{",
"assert",
"(",
"startDrId",
"<=",
"endDrId",
"&&",
"(",
"m_map",
".",
"isEmpty",
"(",
")",
"||",
"startDrId",
">... | Appends a range to the tracker. The range has to be after the last DrId
of the tracker.
@param startDrId
@param endDrId
@param spUniqueId
@param mpUniqueId | [
"Appends",
"a",
"range",
"to",
"the",
"tracker",
".",
"The",
"range",
"has",
"to",
"be",
"after",
"the",
"last",
"DrId",
"of",
"the",
"tracker",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/DRConsumerDrIdTracker.java#L328-L332 | train |
VoltDB/voltdb | src/frontend/org/voltdb/DRConsumerDrIdTracker.java | DRConsumerDrIdTracker.truncate | public void truncate(long newTruncationPoint) {
if (newTruncationPoint < getFirstDrId()) {
return;
}
final Iterator<Range<Long>> iter = m_map.asRanges().iterator();
while (iter.hasNext()) {
final Range<Long> next = iter.next();
if (end(next) < newTruncationPoint) {
iter.remove();
} else if (next.contains(newTruncationPoint)) {
iter.remove();
m_map.add(range(newTruncationPoint, end(next)));
return;
} else {
break;
}
}
m_map.add(range(newTruncationPoint, newTruncationPoint));
} | java | public void truncate(long newTruncationPoint) {
if (newTruncationPoint < getFirstDrId()) {
return;
}
final Iterator<Range<Long>> iter = m_map.asRanges().iterator();
while (iter.hasNext()) {
final Range<Long> next = iter.next();
if (end(next) < newTruncationPoint) {
iter.remove();
} else if (next.contains(newTruncationPoint)) {
iter.remove();
m_map.add(range(newTruncationPoint, end(next)));
return;
} else {
break;
}
}
m_map.add(range(newTruncationPoint, newTruncationPoint));
} | [
"public",
"void",
"truncate",
"(",
"long",
"newTruncationPoint",
")",
"{",
"if",
"(",
"newTruncationPoint",
"<",
"getFirstDrId",
"(",
")",
")",
"{",
"return",
";",
"}",
"final",
"Iterator",
"<",
"Range",
"<",
"Long",
">",
">",
"iter",
"=",
"m_map",
".",
... | Truncate the tracker to the given safe point. After truncation, the new
safe point will be the first DrId of the tracker. If the new safe point
is before the first DrId of the tracker, it's a no-op.
@param newTruncationPoint New safe point | [
"Truncate",
"the",
"tracker",
"to",
"the",
"given",
"safe",
"point",
".",
"After",
"truncation",
"the",
"new",
"safe",
"point",
"will",
"be",
"the",
"first",
"DrId",
"of",
"the",
"tracker",
".",
"If",
"the",
"new",
"safe",
"point",
"is",
"before",
"the",... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/DRConsumerDrIdTracker.java#L340-L358 | train |
VoltDB/voltdb | src/frontend/org/voltdb/DRConsumerDrIdTracker.java | DRConsumerDrIdTracker.mergeTracker | public void mergeTracker(DRConsumerDrIdTracker tracker) {
final long newSafePoint = Math.max(tracker.getSafePointDrId(), getSafePointDrId());
m_map.addAll(tracker.m_map);
truncate(newSafePoint);
m_lastSpUniqueId = Math.max(m_lastSpUniqueId, tracker.m_lastSpUniqueId);
m_lastMpUniqueId = Math.max(m_lastMpUniqueId, tracker.m_lastMpUniqueId);
} | java | public void mergeTracker(DRConsumerDrIdTracker tracker) {
final long newSafePoint = Math.max(tracker.getSafePointDrId(), getSafePointDrId());
m_map.addAll(tracker.m_map);
truncate(newSafePoint);
m_lastSpUniqueId = Math.max(m_lastSpUniqueId, tracker.m_lastSpUniqueId);
m_lastMpUniqueId = Math.max(m_lastMpUniqueId, tracker.m_lastMpUniqueId);
} | [
"public",
"void",
"mergeTracker",
"(",
"DRConsumerDrIdTracker",
"tracker",
")",
"{",
"final",
"long",
"newSafePoint",
"=",
"Math",
".",
"max",
"(",
"tracker",
".",
"getSafePointDrId",
"(",
")",
",",
"getSafePointDrId",
"(",
")",
")",
";",
"m_map",
".",
"addA... | Merge the given tracker with the current tracker. Ranges can
overlap. After the merge, the current tracker will be truncated to the
larger safe point.
@param tracker | [
"Merge",
"the",
"given",
"tracker",
"with",
"the",
"current",
"tracker",
".",
"Ranges",
"can",
"overlap",
".",
"After",
"the",
"merge",
"the",
"current",
"tracker",
"will",
"be",
"truncated",
"to",
"the",
"larger",
"safe",
"point",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/DRConsumerDrIdTracker.java#L366-L372 | train |
VoltDB/voltdb | src/frontend/org/voltcore/messaging/SocketJoiner.java | SocketJoiner.readJSONObjFromWire | private JSONObject readJSONObjFromWire(MessagingChannel messagingChannel) throws IOException, JSONException {
ByteBuffer messageBytes = messagingChannel.readMessage();
JSONObject jsObj = new JSONObject(new String(messageBytes.array(), StandardCharsets.UTF_8));
return jsObj;
} | java | private JSONObject readJSONObjFromWire(MessagingChannel messagingChannel) throws IOException, JSONException {
ByteBuffer messageBytes = messagingChannel.readMessage();
JSONObject jsObj = new JSONObject(new String(messageBytes.array(), StandardCharsets.UTF_8));
return jsObj;
} | [
"private",
"JSONObject",
"readJSONObjFromWire",
"(",
"MessagingChannel",
"messagingChannel",
")",
"throws",
"IOException",
",",
"JSONException",
"{",
"ByteBuffer",
"messageBytes",
"=",
"messagingChannel",
".",
"readMessage",
"(",
")",
";",
"JSONObject",
"jsObj",
"=",
... | Read a length prefixed JSON message | [
"Read",
"a",
"length",
"prefixed",
"JSON",
"message"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/messaging/SocketJoiner.java#L428-L433 | train |
VoltDB/voltdb | src/frontend/org/voltcore/messaging/SocketJoiner.java | SocketJoiner.processJSONResponse | private JSONObject processJSONResponse(MessagingChannel messagingChannel,
Set<String> activeVersions,
boolean checkVersion) throws IOException, JSONException
{
// read the json response from socketjoiner with version info
JSONObject jsonResponse = readJSONObjFromWire(messagingChannel);
if (!checkVersion) {
return jsonResponse;
}
VersionChecker versionChecker = m_acceptor.getVersionChecker();
String remoteVersionString = jsonResponse.getString(VERSION_STRING);
String remoteBuildString = jsonResponse.getString(BUILD_STRING);
boolean remoteAcceptsLocalVersion = jsonResponse.getBoolean(VERSION_COMPATIBLE);
if (remoteVersionString.equals(versionChecker.getVersionString())) {
if (!versionChecker.getBuildString().equals(remoteBuildString)) {
// ignore test/eclipse build string so tests still work
if (!versionChecker.getBuildString().equals("VoltDB") && !remoteBuildString.equals("VoltDB")) {
org.voltdb.VoltDB.crashLocalVoltDB("For VoltDB version " + versionChecker.getVersionString() +
" git tag/hash is not identical across the cluster. Node join failed.\n" +
" joining build string: " + versionChecker.getBuildString() + "\n" +
" existing build string: " + remoteBuildString, false, null);
return null;
}
}
}
else if (!remoteAcceptsLocalVersion) {
if (!versionChecker.isCompatibleVersionString(remoteVersionString)) {
org.voltdb.VoltDB.crashLocalVoltDB("Cluster contains nodes running VoltDB version " + remoteVersionString +
" which is incompatibile with local version " + versionChecker.getVersionString() +
".\n", false, null);
return null;
}
}
//Do this only after we think we are compatible.
activeVersions.add(remoteVersionString);
return jsonResponse;
} | java | private JSONObject processJSONResponse(MessagingChannel messagingChannel,
Set<String> activeVersions,
boolean checkVersion) throws IOException, JSONException
{
// read the json response from socketjoiner with version info
JSONObject jsonResponse = readJSONObjFromWire(messagingChannel);
if (!checkVersion) {
return jsonResponse;
}
VersionChecker versionChecker = m_acceptor.getVersionChecker();
String remoteVersionString = jsonResponse.getString(VERSION_STRING);
String remoteBuildString = jsonResponse.getString(BUILD_STRING);
boolean remoteAcceptsLocalVersion = jsonResponse.getBoolean(VERSION_COMPATIBLE);
if (remoteVersionString.equals(versionChecker.getVersionString())) {
if (!versionChecker.getBuildString().equals(remoteBuildString)) {
// ignore test/eclipse build string so tests still work
if (!versionChecker.getBuildString().equals("VoltDB") && !remoteBuildString.equals("VoltDB")) {
org.voltdb.VoltDB.crashLocalVoltDB("For VoltDB version " + versionChecker.getVersionString() +
" git tag/hash is not identical across the cluster. Node join failed.\n" +
" joining build string: " + versionChecker.getBuildString() + "\n" +
" existing build string: " + remoteBuildString, false, null);
return null;
}
}
}
else if (!remoteAcceptsLocalVersion) {
if (!versionChecker.isCompatibleVersionString(remoteVersionString)) {
org.voltdb.VoltDB.crashLocalVoltDB("Cluster contains nodes running VoltDB version " + remoteVersionString +
" which is incompatibile with local version " + versionChecker.getVersionString() +
".\n", false, null);
return null;
}
}
//Do this only after we think we are compatible.
activeVersions.add(remoteVersionString);
return jsonResponse;
} | [
"private",
"JSONObject",
"processJSONResponse",
"(",
"MessagingChannel",
"messagingChannel",
",",
"Set",
"<",
"String",
">",
"activeVersions",
",",
"boolean",
"checkVersion",
")",
"throws",
"IOException",
",",
"JSONException",
"{",
"// read the json response from socketjoin... | Read version info from a socket and check compatibility.
After verifying versions return if "paused" start is indicated. True if paused start otherwise normal start. | [
"Read",
"version",
"info",
"from",
"a",
"socket",
"and",
"check",
"compatibility",
".",
"After",
"verifying",
"versions",
"return",
"if",
"paused",
"start",
"is",
"indicated",
".",
"True",
"if",
"paused",
"start",
"otherwise",
"normal",
"start",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/messaging/SocketJoiner.java#L657-L694 | train |
VoltDB/voltdb | src/frontend/org/voltcore/messaging/SocketJoiner.java | SocketJoiner.createLeaderSocket | private SocketChannel createLeaderSocket(
SocketAddress hostAddr,
ConnectStrategy mode) throws IOException
{
SocketChannel socket;
int connectAttempts = 0;
do {
try {
socket = SocketChannel.open();
socket.socket().connect(hostAddr, 5000);
}
catch (java.net.ConnectException
|java.nio.channels.UnresolvedAddressException
|java.net.NoRouteToHostException
|java.net.PortUnreachableException e)
{
// reset the socket to null for loop purposes
socket = null;
if (mode == ConnectStrategy.PROBE) {
return null;
}
if ((++connectAttempts % 8) == 0) {
LOG.warn("Joining primary failed: " + e + " retrying..");
}
try {
Thread.sleep(250); // milliseconds
}
catch (InterruptedException dontcare) {}
}
} while (socket == null);
return socket;
} | java | private SocketChannel createLeaderSocket(
SocketAddress hostAddr,
ConnectStrategy mode) throws IOException
{
SocketChannel socket;
int connectAttempts = 0;
do {
try {
socket = SocketChannel.open();
socket.socket().connect(hostAddr, 5000);
}
catch (java.net.ConnectException
|java.nio.channels.UnresolvedAddressException
|java.net.NoRouteToHostException
|java.net.PortUnreachableException e)
{
// reset the socket to null for loop purposes
socket = null;
if (mode == ConnectStrategy.PROBE) {
return null;
}
if ((++connectAttempts % 8) == 0) {
LOG.warn("Joining primary failed: " + e + " retrying..");
}
try {
Thread.sleep(250); // milliseconds
}
catch (InterruptedException dontcare) {}
}
} while (socket == null);
return socket;
} | [
"private",
"SocketChannel",
"createLeaderSocket",
"(",
"SocketAddress",
"hostAddr",
",",
"ConnectStrategy",
"mode",
")",
"throws",
"IOException",
"{",
"SocketChannel",
"socket",
";",
"int",
"connectAttempts",
"=",
"0",
";",
"do",
"{",
"try",
"{",
"socket",
"=",
... | Create socket to the leader node | [
"Create",
"socket",
"to",
"the",
"leader",
"node"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/messaging/SocketJoiner.java#L699-L731 | train |
VoltDB/voltdb | src/frontend/org/voltcore/messaging/SocketJoiner.java | SocketJoiner.connectToHost | private SocketChannel connectToHost(SocketAddress hostAddr)
throws IOException
{
SocketChannel socket = null;
while (socket == null) {
try {
socket = SocketChannel.open(hostAddr);
}
catch (java.net.ConnectException e) {
LOG.warn("Joining host failed: " + e.getMessage() + " retrying..");
try {
Thread.sleep(250); // milliseconds
}
catch (InterruptedException dontcare) {}
}
}
return socket;
} | java | private SocketChannel connectToHost(SocketAddress hostAddr)
throws IOException
{
SocketChannel socket = null;
while (socket == null) {
try {
socket = SocketChannel.open(hostAddr);
}
catch (java.net.ConnectException e) {
LOG.warn("Joining host failed: " + e.getMessage() + " retrying..");
try {
Thread.sleep(250); // milliseconds
}
catch (InterruptedException dontcare) {}
}
}
return socket;
} | [
"private",
"SocketChannel",
"connectToHost",
"(",
"SocketAddress",
"hostAddr",
")",
"throws",
"IOException",
"{",
"SocketChannel",
"socket",
"=",
"null",
";",
"while",
"(",
"socket",
"==",
"null",
")",
"{",
"try",
"{",
"socket",
"=",
"SocketChannel",
".",
"ope... | Create socket to the given host | [
"Create",
"socket",
"to",
"the",
"given",
"host"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/messaging/SocketJoiner.java#L736-L753 | train |
VoltDB/voltdb | src/frontend/org/voltcore/messaging/SocketJoiner.java | SocketJoiner.requestHostId | private RequestHostIdResponse requestHostId (
MessagingChannel messagingChannel,
Set<String> activeVersions) throws Exception
{
VersionChecker versionChecker = m_acceptor.getVersionChecker();
activeVersions.add(versionChecker.getVersionString());
JSONObject jsObj = new JSONObject();
jsObj.put(TYPE, ConnectionType.REQUEST_HOSTID.name());
// put the version compatibility status in the json
jsObj.put(VERSION_STRING, versionChecker.getVersionString());
// Advertise the port we are going to listen on based on config
jsObj.put(PORT, m_internalPort);
// If config specified an internal interface use that.
// Otherwise the leader will echo back what we connected on
if (!m_internalInterface.isEmpty()) {
jsObj.put(ADDRESS, m_internalInterface);
}
// communicate configuration and node state
jsObj = m_acceptor.decorate(jsObj, Optional.empty());
jsObj.put(MAY_EXCHANGE_TS, true);
byte jsBytes[] = jsObj.toString(4).getBytes(StandardCharsets.UTF_8);
ByteBuffer requestHostIdBuffer = ByteBuffer.allocate(4 + jsBytes.length);
requestHostIdBuffer.putInt(jsBytes.length);
requestHostIdBuffer.put(jsBytes).flip();
messagingChannel.writeMessage(requestHostIdBuffer);
// read the json response from socketjoiner with version info and validate it
JSONObject leaderInfo = processJSONResponse(messagingChannel, activeVersions, true);
// read the json response sent by HostMessenger with HostID
JSONObject jsonObj = readJSONObjFromWire(messagingChannel);
return new RequestHostIdResponse(leaderInfo, jsonObj);
} | java | private RequestHostIdResponse requestHostId (
MessagingChannel messagingChannel,
Set<String> activeVersions) throws Exception
{
VersionChecker versionChecker = m_acceptor.getVersionChecker();
activeVersions.add(versionChecker.getVersionString());
JSONObject jsObj = new JSONObject();
jsObj.put(TYPE, ConnectionType.REQUEST_HOSTID.name());
// put the version compatibility status in the json
jsObj.put(VERSION_STRING, versionChecker.getVersionString());
// Advertise the port we are going to listen on based on config
jsObj.put(PORT, m_internalPort);
// If config specified an internal interface use that.
// Otherwise the leader will echo back what we connected on
if (!m_internalInterface.isEmpty()) {
jsObj.put(ADDRESS, m_internalInterface);
}
// communicate configuration and node state
jsObj = m_acceptor.decorate(jsObj, Optional.empty());
jsObj.put(MAY_EXCHANGE_TS, true);
byte jsBytes[] = jsObj.toString(4).getBytes(StandardCharsets.UTF_8);
ByteBuffer requestHostIdBuffer = ByteBuffer.allocate(4 + jsBytes.length);
requestHostIdBuffer.putInt(jsBytes.length);
requestHostIdBuffer.put(jsBytes).flip();
messagingChannel.writeMessage(requestHostIdBuffer);
// read the json response from socketjoiner with version info and validate it
JSONObject leaderInfo = processJSONResponse(messagingChannel, activeVersions, true);
// read the json response sent by HostMessenger with HostID
JSONObject jsonObj = readJSONObjFromWire(messagingChannel);
return new RequestHostIdResponse(leaderInfo, jsonObj);
} | [
"private",
"RequestHostIdResponse",
"requestHostId",
"(",
"MessagingChannel",
"messagingChannel",
",",
"Set",
"<",
"String",
">",
"activeVersions",
")",
"throws",
"Exception",
"{",
"VersionChecker",
"versionChecker",
"=",
"m_acceptor",
".",
"getVersionChecker",
"(",
")"... | Connection handshake to the leader, ask the leader to assign a host Id
for current node.
@param
@return array of two JSON objects, first is leader info, second is
the response to our request
@throws Exception | [
"Connection",
"handshake",
"to",
"the",
"leader",
"ask",
"the",
"leader",
"to",
"assign",
"a",
"host",
"Id",
"for",
"current",
"node",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/messaging/SocketJoiner.java#L763-L801 | train |
VoltDB/voltdb | src/frontend/org/voltdb/messaging/FragmentTaskMessage.java | FragmentTaskMessage.addFragment | public void addFragment(byte[] planHash, int outputDepId, ByteBuffer parameterSet) {
addFragment(planHash, null, outputDepId, parameterSet);
} | java | public void addFragment(byte[] planHash, int outputDepId, ByteBuffer parameterSet) {
addFragment(planHash, null, outputDepId, parameterSet);
} | [
"public",
"void",
"addFragment",
"(",
"byte",
"[",
"]",
"planHash",
",",
"int",
"outputDepId",
",",
"ByteBuffer",
"parameterSet",
")",
"{",
"addFragment",
"(",
"planHash",
",",
"null",
",",
"outputDepId",
",",
"parameterSet",
")",
";",
"}"
] | Add a pre-planned fragment.
@param fragmentId
@param outputDepId
@param parameterSet | [
"Add",
"a",
"pre",
"-",
"planned",
"fragment",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/messaging/FragmentTaskMessage.java#L289-L291 | train |
VoltDB/voltdb | src/frontend/org/voltdb/messaging/FragmentTaskMessage.java | FragmentTaskMessage.addCustomFragment | public void addCustomFragment(byte[] planHash, int outputDepId, ByteBuffer parameterSet, byte[] fragmentPlan, String stmtText) {
FragmentData item = new FragmentData();
item.m_planHash = planHash;
item.m_outputDepId = outputDepId;
item.m_parameterSet = parameterSet;
item.m_fragmentPlan = fragmentPlan;
item.m_stmtText = stmtText.getBytes();
m_items.add(item);
} | java | public void addCustomFragment(byte[] planHash, int outputDepId, ByteBuffer parameterSet, byte[] fragmentPlan, String stmtText) {
FragmentData item = new FragmentData();
item.m_planHash = planHash;
item.m_outputDepId = outputDepId;
item.m_parameterSet = parameterSet;
item.m_fragmentPlan = fragmentPlan;
item.m_stmtText = stmtText.getBytes();
m_items.add(item);
} | [
"public",
"void",
"addCustomFragment",
"(",
"byte",
"[",
"]",
"planHash",
",",
"int",
"outputDepId",
",",
"ByteBuffer",
"parameterSet",
",",
"byte",
"[",
"]",
"fragmentPlan",
",",
"String",
"stmtText",
")",
"{",
"FragmentData",
"item",
"=",
"new",
"FragmentDat... | Add an unplanned fragment.
@param fragmentId
@param outputDepId
@param parameterSet
@param fragmentPlan | [
"Add",
"an",
"unplanned",
"fragment",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/messaging/FragmentTaskMessage.java#L312-L320 | train |
VoltDB/voltdb | src/frontend/org/voltdb/messaging/FragmentTaskMessage.java | FragmentTaskMessage.createWithOneFragment | public static FragmentTaskMessage createWithOneFragment(long initiatorHSId,
long coordinatorHSId,
long txnId,
long uniqueId,
boolean isReadOnly,
byte[] planHash,
int outputDepId,
ParameterSet params,
boolean isFinal,
boolean isForReplay,
boolean isNPartTxn,
long timestamp) {
ByteBuffer parambytes = null;
if (params != null) {
parambytes = ByteBuffer.allocate(params.getSerializedSize());
try {
params.flattenToBuffer(parambytes);
parambytes.flip();
}
catch (IOException e) {
VoltDB.crashLocalVoltDB("Failed to serialize parameter for fragment: " + params.toString(), true, e);
}
}
FragmentTaskMessage ret = new FragmentTaskMessage(initiatorHSId, coordinatorHSId,
txnId, uniqueId, isReadOnly, isFinal,
isForReplay, isNPartTxn, timestamp);
ret.addFragment(planHash, outputDepId, parambytes);
return ret;
} | java | public static FragmentTaskMessage createWithOneFragment(long initiatorHSId,
long coordinatorHSId,
long txnId,
long uniqueId,
boolean isReadOnly,
byte[] planHash,
int outputDepId,
ParameterSet params,
boolean isFinal,
boolean isForReplay,
boolean isNPartTxn,
long timestamp) {
ByteBuffer parambytes = null;
if (params != null) {
parambytes = ByteBuffer.allocate(params.getSerializedSize());
try {
params.flattenToBuffer(parambytes);
parambytes.flip();
}
catch (IOException e) {
VoltDB.crashLocalVoltDB("Failed to serialize parameter for fragment: " + params.toString(), true, e);
}
}
FragmentTaskMessage ret = new FragmentTaskMessage(initiatorHSId, coordinatorHSId,
txnId, uniqueId, isReadOnly, isFinal,
isForReplay, isNPartTxn, timestamp);
ret.addFragment(planHash, outputDepId, parambytes);
return ret;
} | [
"public",
"static",
"FragmentTaskMessage",
"createWithOneFragment",
"(",
"long",
"initiatorHSId",
",",
"long",
"coordinatorHSId",
",",
"long",
"txnId",
",",
"long",
"uniqueId",
",",
"boolean",
"isReadOnly",
",",
"byte",
"[",
"]",
"planHash",
",",
"int",
"outputDep... | Convenience factory method to replace constructor that includes arrays of stuff.
@param initiatorHSId
@param coordinatorHSId
@param txnId
@param isReadOnly
@param fragmentId
@param outputDepId
@param parameterSet
@param isFinal
@return new FragmentTaskMessage | [
"Convenience",
"factory",
"method",
"to",
"replace",
"constructor",
"that",
"includes",
"arrays",
"of",
"stuff",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/messaging/FragmentTaskMessage.java#L337-L366 | train |
VoltDB/voltdb | src/frontend/org/voltdb/messaging/FragmentTaskMessage.java | FragmentTaskMessage.setEmptyForRestart | public void setEmptyForRestart(int outputDepId) {
m_emptyForRestart = true;
ParameterSet blank = ParameterSet.emptyParameterSet();
ByteBuffer mt = ByteBuffer.allocate(blank.getSerializedSize());
try {
blank.flattenToBuffer(mt);
}
catch (IOException ioe) {
// Shouldn't ever happen, just bail out to not-obviously equivalent behavior
mt = ByteBuffer.allocate(2);
mt.putShort((short)0);
}
addFragment(EMPTY_HASH, outputDepId, mt);
} | java | public void setEmptyForRestart(int outputDepId) {
m_emptyForRestart = true;
ParameterSet blank = ParameterSet.emptyParameterSet();
ByteBuffer mt = ByteBuffer.allocate(blank.getSerializedSize());
try {
blank.flattenToBuffer(mt);
}
catch (IOException ioe) {
// Shouldn't ever happen, just bail out to not-obviously equivalent behavior
mt = ByteBuffer.allocate(2);
mt.putShort((short)0);
}
addFragment(EMPTY_HASH, outputDepId, mt);
} | [
"public",
"void",
"setEmptyForRestart",
"(",
"int",
"outputDepId",
")",
"{",
"m_emptyForRestart",
"=",
"true",
";",
"ParameterSet",
"blank",
"=",
"ParameterSet",
".",
"emptyParameterSet",
"(",
")",
";",
"ByteBuffer",
"mt",
"=",
"ByteBuffer",
".",
"allocate",
"("... | fragment with the provided outputDepId | [
"fragment",
"with",
"the",
"provided",
"outputDepId"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/messaging/FragmentTaskMessage.java#L457-L470 | train |
VoltDB/voltdb | third_party/java/src/com/google_voltpatches/common/collect/ImmutableTable.java | ImmutableTable.copyOf | public static <R, C, V> ImmutableTable<R, C, V> copyOf(
Table<? extends R, ? extends C, ? extends V> table) {
if (table instanceof ImmutableTable) {
@SuppressWarnings("unchecked")
ImmutableTable<R, C, V> parameterizedTable = (ImmutableTable<R, C, V>) table;
return parameterizedTable;
} else {
int size = table.size();
switch (size) {
case 0:
return of();
case 1:
Cell<? extends R, ? extends C, ? extends V> onlyCell =
Iterables.getOnlyElement(table.cellSet());
return ImmutableTable.<R, C, V>of(
onlyCell.getRowKey(), onlyCell.getColumnKey(), onlyCell.getValue());
default:
ImmutableSet.Builder<Cell<R, C, V>> cellSetBuilder =
new ImmutableSet.Builder<Cell<R, C, V>>(size);
for (Cell<? extends R, ? extends C, ? extends V> cell : table.cellSet()) {
/*
* Must cast to be able to create a Cell<R, C, V> rather than a
* Cell<? extends R, ? extends C, ? extends V>
*/
cellSetBuilder.add(
cellOf((R) cell.getRowKey(), (C) cell.getColumnKey(), (V) cell.getValue()));
}
return RegularImmutableTable.forCells(cellSetBuilder.build());
}
}
} | java | public static <R, C, V> ImmutableTable<R, C, V> copyOf(
Table<? extends R, ? extends C, ? extends V> table) {
if (table instanceof ImmutableTable) {
@SuppressWarnings("unchecked")
ImmutableTable<R, C, V> parameterizedTable = (ImmutableTable<R, C, V>) table;
return parameterizedTable;
} else {
int size = table.size();
switch (size) {
case 0:
return of();
case 1:
Cell<? extends R, ? extends C, ? extends V> onlyCell =
Iterables.getOnlyElement(table.cellSet());
return ImmutableTable.<R, C, V>of(
onlyCell.getRowKey(), onlyCell.getColumnKey(), onlyCell.getValue());
default:
ImmutableSet.Builder<Cell<R, C, V>> cellSetBuilder =
new ImmutableSet.Builder<Cell<R, C, V>>(size);
for (Cell<? extends R, ? extends C, ? extends V> cell : table.cellSet()) {
/*
* Must cast to be able to create a Cell<R, C, V> rather than a
* Cell<? extends R, ? extends C, ? extends V>
*/
cellSetBuilder.add(
cellOf((R) cell.getRowKey(), (C) cell.getColumnKey(), (V) cell.getValue()));
}
return RegularImmutableTable.forCells(cellSetBuilder.build());
}
}
} | [
"public",
"static",
"<",
"R",
",",
"C",
",",
"V",
">",
"ImmutableTable",
"<",
"R",
",",
"C",
",",
"V",
">",
"copyOf",
"(",
"Table",
"<",
"?",
"extends",
"R",
",",
"?",
"extends",
"C",
",",
"?",
"extends",
"V",
">",
"table",
")",
"{",
"if",
"(... | Returns an immutable copy of the provided table.
<p>The {@link Table#cellSet()} iteration order of the provided table
determines the iteration ordering of all views in the returned table. Note
that some views of the original table and the copied table may have
different iteration orders. For more control over the ordering, create a
{@link Builder} and call {@link Builder#orderRowsBy},
{@link Builder#orderColumnsBy}, and {@link Builder#putAll}
<p>Despite the method name, this method attempts to avoid actually copying
the data when it is safe to do so. The exact circumstances under which a
copy will or will not be performed are undocumented and subject to change. | [
"Returns",
"an",
"immutable",
"copy",
"of",
"the",
"provided",
"table",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/collect/ImmutableTable.java#L70-L100 | train |
VoltDB/voltdb | src/frontend/org/voltdb/importclient/socket/PullSocketImporter.java | PullSocketImporter.replaceSocket | private void replaceSocket(Socket newSocket) {
synchronized (m_socketLock) {
closeSocket(m_socket);
if (m_eos.get()) {
closeSocket(newSocket);
m_socket = null;
} else {
m_socket = newSocket;
}
}
} | java | private void replaceSocket(Socket newSocket) {
synchronized (m_socketLock) {
closeSocket(m_socket);
if (m_eos.get()) {
closeSocket(newSocket);
m_socket = null;
} else {
m_socket = newSocket;
}
}
} | [
"private",
"void",
"replaceSocket",
"(",
"Socket",
"newSocket",
")",
"{",
"synchronized",
"(",
"m_socketLock",
")",
"{",
"closeSocket",
"(",
"m_socket",
")",
";",
"if",
"(",
"m_eos",
".",
"get",
"(",
")",
")",
"{",
"closeSocket",
"(",
"newSocket",
")",
"... | Set the socket to newSocket, unless we're shutting down.
The most reliable way to ensure the importer thread exits is to close its socket.
@param newSocket socket to replace any previous socket. May be null. | [
"Set",
"the",
"socket",
"to",
"newSocket",
"unless",
"we",
"re",
"shutting",
"down",
".",
"The",
"most",
"reliable",
"way",
"to",
"ensure",
"the",
"importer",
"thread",
"exits",
"is",
"to",
"close",
"its",
"socket",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importclient/socket/PullSocketImporter.java#L92-L102 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/server/WatchManager.java | WatchManager.dumpWatches | public synchronized void dumpWatches(PrintWriter pwriter, boolean byPath) {
if (byPath) {
for (Entry<String, HashSet<Watcher>> e : watchTable.entrySet()) {
pwriter.println(e.getKey());
for (Watcher w : e.getValue()) {
pwriter.print("\t0x");
pwriter.print(Long.toHexString(((ServerCnxn)w).getSessionId()));
pwriter.print("\n");
}
}
} else {
for (Entry<Watcher, HashSet<String>> e : watch2Paths.entrySet()) {
pwriter.print("0x");
pwriter.println(Long.toHexString(((ServerCnxn)e.getKey()).getSessionId()));
for (String path : e.getValue()) {
pwriter.print("\t");
pwriter.println(path);
}
}
}
} | java | public synchronized void dumpWatches(PrintWriter pwriter, boolean byPath) {
if (byPath) {
for (Entry<String, HashSet<Watcher>> e : watchTable.entrySet()) {
pwriter.println(e.getKey());
for (Watcher w : e.getValue()) {
pwriter.print("\t0x");
pwriter.print(Long.toHexString(((ServerCnxn)w).getSessionId()));
pwriter.print("\n");
}
}
} else {
for (Entry<Watcher, HashSet<String>> e : watch2Paths.entrySet()) {
pwriter.print("0x");
pwriter.println(Long.toHexString(((ServerCnxn)e.getKey()).getSessionId()));
for (String path : e.getValue()) {
pwriter.print("\t");
pwriter.println(path);
}
}
}
} | [
"public",
"synchronized",
"void",
"dumpWatches",
"(",
"PrintWriter",
"pwriter",
",",
"boolean",
"byPath",
")",
"{",
"if",
"(",
"byPath",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"HashSet",
"<",
"Watcher",
">",
">",
"e",
":",
"watchTable",
".",
... | String representation of watches. Warning, may be large!
@param byPath iff true output watches by paths, otw output
watches by connection
@return string representation of watches | [
"String",
"representation",
"of",
"watches",
".",
"Warning",
"may",
"be",
"large!"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/WatchManager.java#L148-L168 | train |
VoltDB/voltdb | src/catgen/in/javasrc/CatalogType.java | CatalogType.setBaseValues | void setBaseValues(CatalogMap<? extends CatalogType> parentMap, String name) {
if (name == null) {
throw new CatalogException("Null value where it shouldn't be.");
}
m_parentMap = parentMap;
m_typename = name;
} | java | void setBaseValues(CatalogMap<? extends CatalogType> parentMap, String name) {
if (name == null) {
throw new CatalogException("Null value where it shouldn't be.");
}
m_parentMap = parentMap;
m_typename = name;
} | [
"void",
"setBaseValues",
"(",
"CatalogMap",
"<",
"?",
"extends",
"CatalogType",
">",
"parentMap",
",",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"new",
"CatalogException",
"(",
"\"Null value where it shouldn't be.\"",
")",
... | This is my lazy hack to avoid using reflection to instantiate records. | [
"This",
"is",
"my",
"lazy",
"hack",
"to",
"avoid",
"using",
"reflection",
"to",
"instantiate",
"records",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/catgen/in/javasrc/CatalogType.java#L215-L221 | train |
VoltDB/voltdb | src/catgen/in/javasrc/CatalogType.java | CatalogType.validate | public void validate() throws IllegalArgumentException, IllegalAccessException {
for (Field field : getClass().getDeclaredFields()) {
if (CatalogType.class.isAssignableFrom(field.getType())) {
CatalogType ct = (CatalogType) field.get(this);
assert(ct.getCatalog() == getCatalog()) : ct.getCatalogPath() + " has wrong catalog";
}
if (CatalogReference.class.isAssignableFrom(field.getType())) {
@SuppressWarnings("unchecked")
CatalogReference<? extends CatalogType> cr = (CatalogReference<? extends CatalogType>) field.get(this);
if (cr.m_value != null) {
assert(cr.m_value.getCatalog() == getCatalog()) : cr.m_value.getCatalogPath() + " has wrong catalog";
}
}
if (CatalogMap.class.isAssignableFrom(field.getClass())) {
@SuppressWarnings("unchecked")
CatalogMap<? extends CatalogType> cm = (CatalogMap<? extends CatalogType>) field.get(this);
for (CatalogType ct : cm) {
assert(ct.getCatalog() == getCatalog()) : ct.getCatalogPath() + " has wrong catalog";
ct.validate();
}
}
}
} | java | public void validate() throws IllegalArgumentException, IllegalAccessException {
for (Field field : getClass().getDeclaredFields()) {
if (CatalogType.class.isAssignableFrom(field.getType())) {
CatalogType ct = (CatalogType) field.get(this);
assert(ct.getCatalog() == getCatalog()) : ct.getCatalogPath() + " has wrong catalog";
}
if (CatalogReference.class.isAssignableFrom(field.getType())) {
@SuppressWarnings("unchecked")
CatalogReference<? extends CatalogType> cr = (CatalogReference<? extends CatalogType>) field.get(this);
if (cr.m_value != null) {
assert(cr.m_value.getCatalog() == getCatalog()) : cr.m_value.getCatalogPath() + " has wrong catalog";
}
}
if (CatalogMap.class.isAssignableFrom(field.getClass())) {
@SuppressWarnings("unchecked")
CatalogMap<? extends CatalogType> cm = (CatalogMap<? extends CatalogType>) field.get(this);
for (CatalogType ct : cm) {
assert(ct.getCatalog() == getCatalog()) : ct.getCatalogPath() + " has wrong catalog";
ct.validate();
}
}
}
} | [
"public",
"void",
"validate",
"(",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalAccessException",
"{",
"for",
"(",
"Field",
"field",
":",
"getClass",
"(",
")",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"if",
"(",
"CatalogType",
".",
"class",
"... | Fails an assertion if any child of this object doesn't think
it's part of the same catalog.
@throws IllegalAccessException
@throws IllegalArgumentException | [
"Fails",
"an",
"assertion",
"if",
"any",
"child",
"of",
"this",
"object",
"doesn",
"t",
"think",
"it",
"s",
"part",
"of",
"the",
"same",
"catalog",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/catgen/in/javasrc/CatalogType.java#L294-L316 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ExtensibleSnapshotDigestData.java | ExtensibleSnapshotDigestData.writeExternalStreamStates | private void writeExternalStreamStates(JSONStringer stringer) throws JSONException {
stringer.key(DISABLED_EXTERNAL_STREAMS).array();
for (int partition : m_disabledExternalStreams) {
stringer.value(partition);
}
stringer.endArray();
} | java | private void writeExternalStreamStates(JSONStringer stringer) throws JSONException {
stringer.key(DISABLED_EXTERNAL_STREAMS).array();
for (int partition : m_disabledExternalStreams) {
stringer.value(partition);
}
stringer.endArray();
} | [
"private",
"void",
"writeExternalStreamStates",
"(",
"JSONStringer",
"stringer",
")",
"throws",
"JSONException",
"{",
"stringer",
".",
"key",
"(",
"DISABLED_EXTERNAL_STREAMS",
")",
".",
"array",
"(",
")",
";",
"for",
"(",
"int",
"partition",
":",
"m_disabledExtern... | Writes external streams state for partitions into snapshot digest. | [
"Writes",
"external",
"streams",
"state",
"for",
"partitions",
"into",
"snapshot",
"digest",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ExtensibleSnapshotDigestData.java#L365-L371 | train |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTableUtil.java | VoltTableUtil.unionTables | public static VoltTable unionTables(Collection<VoltTable> operands) {
VoltTable result = null;
// Locate the first non-null table to get the schema
for (VoltTable vt : operands) {
if (vt != null) {
result = new VoltTable(vt.getTableSchema());
result.setStatusCode(vt.getStatusCode());
break;
}
}
if (result != null) {
result.addTables(operands);
result.resetRowPosition();
}
return result;
} | java | public static VoltTable unionTables(Collection<VoltTable> operands) {
VoltTable result = null;
// Locate the first non-null table to get the schema
for (VoltTable vt : operands) {
if (vt != null) {
result = new VoltTable(vt.getTableSchema());
result.setStatusCode(vt.getStatusCode());
break;
}
}
if (result != null) {
result.addTables(operands);
result.resetRowPosition();
}
return result;
} | [
"public",
"static",
"VoltTable",
"unionTables",
"(",
"Collection",
"<",
"VoltTable",
">",
"operands",
")",
"{",
"VoltTable",
"result",
"=",
"null",
";",
"// Locate the first non-null table to get the schema",
"for",
"(",
"VoltTable",
"vt",
":",
"operands",
")",
"{",... | Utility to aggregate a list of tables sharing a schema. Common for
sysprocs to do this, to aggregate results. | [
"Utility",
"to",
"aggregate",
"a",
"list",
"of",
"tables",
"sharing",
"a",
"schema",
".",
"Common",
"for",
"sysprocs",
"to",
"do",
"this",
"to",
"aggregate",
"results",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTableUtil.java#L194-L212 | train |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTableUtil.java | VoltTableUtil.tableContainsString | public static boolean tableContainsString(VoltTable t, String s, boolean caseSenstive) {
if (t.getRowCount() == 0) {
return false;
}
if (!caseSenstive) {
s = s.toLowerCase();
}
VoltTableRow row = t.fetchRow(0);
do {
for (int i = 0; i < t.getColumnCount(); i++) {
if (t.getColumnType(i) == VoltType.STRING) {
String value = row.getString(i);
if (value == null) {
continue;
}
if (!caseSenstive) {
value = value.toLowerCase();
}
if (value.contains(s)) {
return true;
}
}
}
} while (row.advanceRow());
return false;
} | java | public static boolean tableContainsString(VoltTable t, String s, boolean caseSenstive) {
if (t.getRowCount() == 0) {
return false;
}
if (!caseSenstive) {
s = s.toLowerCase();
}
VoltTableRow row = t.fetchRow(0);
do {
for (int i = 0; i < t.getColumnCount(); i++) {
if (t.getColumnType(i) == VoltType.STRING) {
String value = row.getString(i);
if (value == null) {
continue;
}
if (!caseSenstive) {
value = value.toLowerCase();
}
if (value.contains(s)) {
return true;
}
}
}
} while (row.advanceRow());
return false;
} | [
"public",
"static",
"boolean",
"tableContainsString",
"(",
"VoltTable",
"t",
",",
"String",
"s",
",",
"boolean",
"caseSenstive",
")",
"{",
"if",
"(",
"t",
".",
"getRowCount",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
... | Return true if any string field in the table contains param s. | [
"Return",
"true",
"if",
"any",
"string",
"field",
"in",
"the",
"table",
"contains",
"param",
"s",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTableUtil.java#L217-L245 | train |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTableUtil.java | VoltTableUtil.tableRowAsObjects | public static Object[] tableRowAsObjects(VoltTableRow row) {
Object[] result = new Object[row.getColumnCount()];
for (int i = 0; i < row.getColumnCount(); i++) {
result[i] = row.get(i, row.getColumnType(i));
}
return result;
} | java | public static Object[] tableRowAsObjects(VoltTableRow row) {
Object[] result = new Object[row.getColumnCount()];
for (int i = 0; i < row.getColumnCount(); i++) {
result[i] = row.get(i, row.getColumnType(i));
}
return result;
} | [
"public",
"static",
"Object",
"[",
"]",
"tableRowAsObjects",
"(",
"VoltTableRow",
"row",
")",
"{",
"Object",
"[",
"]",
"result",
"=",
"new",
"Object",
"[",
"row",
".",
"getColumnCount",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
... | Get a VoltTableRow as an array of Objects of the right type | [
"Get",
"a",
"VoltTableRow",
"as",
"an",
"array",
"of",
"Objects",
"of",
"the",
"right",
"type"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTableUtil.java#L250-L256 | train |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTableUtil.java | VoltTableUtil.stream | public static Stream<VoltTableRow> stream(VoltTable table) {
return StreamSupport.stream(new VoltTableSpliterator(table, 0, table.getRowCount()), false);
} | java | public static Stream<VoltTableRow> stream(VoltTable table) {
return StreamSupport.stream(new VoltTableSpliterator(table, 0, table.getRowCount()), false);
} | [
"public",
"static",
"Stream",
"<",
"VoltTableRow",
">",
"stream",
"(",
"VoltTable",
"table",
")",
"{",
"return",
"StreamSupport",
".",
"stream",
"(",
"new",
"VoltTableSpliterator",
"(",
"table",
",",
"0",
",",
"table",
".",
"getRowCount",
"(",
")",
")",
",... | Not yet public API for VoltTable and Java 8 streams | [
"Not",
"yet",
"public",
"API",
"for",
"VoltTable",
"and",
"Java",
"8",
"streams"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTableUtil.java#L315-L317 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java | MBeanRegistry.register | public void register(ZKMBeanInfo bean, ZKMBeanInfo parent)
throws JMException
{
assert bean != null;
String path = null;
if (parent != null) {
path = mapBean2Path.get(parent);
assert path != null;
}
path = makeFullPath(path, parent);
mapBean2Path.put(bean, path);
mapName2Bean.put(bean.getName(), bean);
if(bean.isHidden())
return;
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName oname = makeObjectName(path, bean);
try {
mbs.registerMBean(bean, oname);
} catch (JMException e) {
LOG.warn("Failed to register MBean " + bean.getName());
throw e;
}
} | java | public void register(ZKMBeanInfo bean, ZKMBeanInfo parent)
throws JMException
{
assert bean != null;
String path = null;
if (parent != null) {
path = mapBean2Path.get(parent);
assert path != null;
}
path = makeFullPath(path, parent);
mapBean2Path.put(bean, path);
mapName2Bean.put(bean.getName(), bean);
if(bean.isHidden())
return;
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName oname = makeObjectName(path, bean);
try {
mbs.registerMBean(bean, oname);
} catch (JMException e) {
LOG.warn("Failed to register MBean " + bean.getName());
throw e;
}
} | [
"public",
"void",
"register",
"(",
"ZKMBeanInfo",
"bean",
",",
"ZKMBeanInfo",
"parent",
")",
"throws",
"JMException",
"{",
"assert",
"bean",
"!=",
"null",
";",
"String",
"path",
"=",
"null",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"path",
"=",
... | Registers a new MBean with the platform MBean server.
@param bean the bean being registered
@param parent if not null, the new bean will be registered as a child
node of this parent. | [
"Registers",
"a",
"new",
"MBean",
"with",
"the",
"platform",
"MBean",
"server",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java#L61-L83 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java | MBeanRegistry.unregister | private void unregister(String path,ZKMBeanInfo bean) throws JMException {
if(path==null)
return;
if (!bean.isHidden()) {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
mbs.unregisterMBean(makeObjectName(path, bean));
} catch (JMException e) {
LOG.warn("Failed to unregister MBean " + bean.getName());
throw e;
}
}
} | java | private void unregister(String path,ZKMBeanInfo bean) throws JMException {
if(path==null)
return;
if (!bean.isHidden()) {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
mbs.unregisterMBean(makeObjectName(path, bean));
} catch (JMException e) {
LOG.warn("Failed to unregister MBean " + bean.getName());
throw e;
}
}
} | [
"private",
"void",
"unregister",
"(",
"String",
"path",
",",
"ZKMBeanInfo",
"bean",
")",
"throws",
"JMException",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"return",
";",
"if",
"(",
"!",
"bean",
".",
"isHidden",
"(",
")",
")",
"{",
"MBeanServer",
"mbs... | Unregister the MBean identified by the path.
@param path
@param bean | [
"Unregister",
"the",
"MBean",
"identified",
"by",
"the",
"path",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java#L90-L102 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java | MBeanRegistry.unregister | public void unregister(ZKMBeanInfo bean) {
if(bean==null)
return;
String path=mapBean2Path.get(bean);
try {
unregister(path,bean);
}
catch (InstanceNotFoundException e) {
LOG.warn("InstanceNotFoundException during unregister usually means more than one Zookeeper server has been running in a single JVM");
LOG.warn("InstanceNotFoundException during unregister can be safely ignored during automated tests.");
}
catch (JMException e) {
LOG.warn("Error during unregister", e);
}
mapBean2Path.remove(bean);
mapName2Bean.remove(bean.getName());
} | java | public void unregister(ZKMBeanInfo bean) {
if(bean==null)
return;
String path=mapBean2Path.get(bean);
try {
unregister(path,bean);
}
catch (InstanceNotFoundException e) {
LOG.warn("InstanceNotFoundException during unregister usually means more than one Zookeeper server has been running in a single JVM");
LOG.warn("InstanceNotFoundException during unregister can be safely ignored during automated tests.");
}
catch (JMException e) {
LOG.warn("Error during unregister", e);
}
mapBean2Path.remove(bean);
mapName2Bean.remove(bean.getName());
} | [
"public",
"void",
"unregister",
"(",
"ZKMBeanInfo",
"bean",
")",
"{",
"if",
"(",
"bean",
"==",
"null",
")",
"return",
";",
"String",
"path",
"=",
"mapBean2Path",
".",
"get",
"(",
"bean",
")",
";",
"try",
"{",
"unregister",
"(",
"path",
",",
"bean",
"... | Unregister MBean.
@param bean | [
"Unregister",
"MBean",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java#L108-L124 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java | MBeanRegistry.unregisterAll | public void unregisterAll() {
for(Map.Entry<ZKMBeanInfo,String> e: mapBean2Path.entrySet()) {
try {
unregister(e.getValue(), e.getKey());
} catch (JMException e1) {
LOG.warn("Error during unregister", e1);
}
}
mapBean2Path.clear();
mapName2Bean.clear();
} | java | public void unregisterAll() {
for(Map.Entry<ZKMBeanInfo,String> e: mapBean2Path.entrySet()) {
try {
unregister(e.getValue(), e.getKey());
} catch (JMException e1) {
LOG.warn("Error during unregister", e1);
}
}
mapBean2Path.clear();
mapName2Bean.clear();
} | [
"public",
"void",
"unregisterAll",
"(",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"ZKMBeanInfo",
",",
"String",
">",
"e",
":",
"mapBean2Path",
".",
"entrySet",
"(",
")",
")",
"{",
"try",
"{",
"unregister",
"(",
"e",
".",
"getValue",
"(",
")",
... | Unregister all currently registered MBeans | [
"Unregister",
"all",
"currently",
"registered",
"MBeans"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java#L128-L138 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java | MBeanRegistry.makeFullPath | public String makeFullPath(String prefix, String... name) {
StringBuilder sb=new StringBuilder(prefix == null ? "/" : (prefix.equals("/")?prefix:prefix+"/"));
boolean first=true;
for (String s : name) {
if(s==null) continue;
if(!first){
sb.append("/");
}else
first=false;
sb.append(s);
}
return sb.toString();
} | java | public String makeFullPath(String prefix, String... name) {
StringBuilder sb=new StringBuilder(prefix == null ? "/" : (prefix.equals("/")?prefix:prefix+"/"));
boolean first=true;
for (String s : name) {
if(s==null) continue;
if(!first){
sb.append("/");
}else
first=false;
sb.append(s);
}
return sb.toString();
} | [
"public",
"String",
"makeFullPath",
"(",
"String",
"prefix",
",",
"String",
"...",
"name",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"prefix",
"==",
"null",
"?",
"\"/\"",
":",
"(",
"prefix",
".",
"equals",
"(",
"\"/\"",
")",
"?",... | Generate a filesystem-like path.
@param prefix path prefix
@param name path elements
@return absolute path | [
"Generate",
"a",
"filesystem",
"-",
"like",
"path",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java#L145-L157 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java | MBeanRegistry.makeObjectName | protected ObjectName makeObjectName(String path, ZKMBeanInfo bean)
throws MalformedObjectNameException
{
if(path==null)
return null;
StringBuilder beanName = new StringBuilder(CommonNames.DOMAIN + ":");
int counter=0;
counter=tokenize(beanName,path,counter);
tokenize(beanName,bean.getName(),counter);
beanName.deleteCharAt(beanName.length()-1);
try {
return new ObjectName(beanName.toString());
} catch (MalformedObjectNameException e) {
LOG.warn("Invalid name \"" + beanName.toString() + "\" for class "
+ bean.getClass().toString());
throw e;
}
} | java | protected ObjectName makeObjectName(String path, ZKMBeanInfo bean)
throws MalformedObjectNameException
{
if(path==null)
return null;
StringBuilder beanName = new StringBuilder(CommonNames.DOMAIN + ":");
int counter=0;
counter=tokenize(beanName,path,counter);
tokenize(beanName,bean.getName(),counter);
beanName.deleteCharAt(beanName.length()-1);
try {
return new ObjectName(beanName.toString());
} catch (MalformedObjectNameException e) {
LOG.warn("Invalid name \"" + beanName.toString() + "\" for class "
+ bean.getClass().toString());
throw e;
}
} | [
"protected",
"ObjectName",
"makeObjectName",
"(",
"String",
"path",
",",
"ZKMBeanInfo",
"bean",
")",
"throws",
"MalformedObjectNameException",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"return",
"null",
";",
"StringBuilder",
"beanName",
"=",
"new",
"StringBuilder... | Builds an MBean path and creates an ObjectName instance using the path.
@param path MBean path
@param bean the MBean instance
@return ObjectName to be registered with the platform MBean server | [
"Builds",
"an",
"MBean",
"path",
"and",
"creates",
"an",
"ObjectName",
"instance",
"using",
"the",
"path",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/jmx/MBeanRegistry.java#L183-L200 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java | Type.getType | @Override
public final int getType() {
if (userTypeModifier == null) {
throw Error.runtimeError(ErrorCode.U_S0500, "Type");
}
return userTypeModifier.getType();
} | java | @Override
public final int getType() {
if (userTypeModifier == null) {
throw Error.runtimeError(ErrorCode.U_S0500, "Type");
}
return userTypeModifier.getType();
} | [
"@",
"Override",
"public",
"final",
"int",
"getType",
"(",
")",
"{",
"if",
"(",
"userTypeModifier",
"==",
"null",
")",
"{",
"throw",
"Error",
".",
"runtimeError",
"(",
"ErrorCode",
".",
"U_S0500",
",",
"\"Type\"",
")",
";",
"}",
"return",
"userTypeModifier... | interface specific methods | [
"interface",
"specific",
"methods"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java#L75-L83 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java | Type.castToType | public Object castToType(SessionInterface session, Object a, Type type) {
return convertToType(session, a, type);
} | java | public Object castToType(SessionInterface session, Object a, Type type) {
return convertToType(session, a, type);
} | [
"public",
"Object",
"castToType",
"(",
"SessionInterface",
"session",
",",
"Object",
"a",
",",
"Type",
"type",
")",
"{",
"return",
"convertToType",
"(",
"session",
",",
"a",
",",
"type",
")",
";",
"}"
] | Explicit casts are handled by this method.
SQL standard 6.12 rules for enforcement of size, precision and scale
are implemented. For CHARACTER values, it performs truncation in all
cases of long strings. | [
"Explicit",
"casts",
"are",
"handled",
"by",
"this",
"method",
".",
"SQL",
"standard",
"6",
".",
"12",
"rules",
"for",
"enforcement",
"of",
"size",
"precision",
"and",
"scale",
"are",
"implemented",
".",
"For",
"CHARACTER",
"values",
"it",
"performs",
"trunc... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java#L253-L255 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java | Type.convertToTypeJDBC | public Object convertToTypeJDBC(SessionInterface session, Object a,
Type type) {
return convertToType(session, a, type);
} | java | public Object convertToTypeJDBC(SessionInterface session, Object a,
Type type) {
return convertToType(session, a, type);
} | [
"public",
"Object",
"convertToTypeJDBC",
"(",
"SessionInterface",
"session",
",",
"Object",
"a",
",",
"Type",
"type",
")",
"{",
"return",
"convertToType",
"(",
"session",
",",
"a",
",",
"type",
")",
";",
"}"
] | Convert type for JDBC. Same as convertToType, but supports non-standard
SQL conversions supported by JDBC | [
"Convert",
"type",
"for",
"JDBC",
".",
"Same",
"as",
"convertToType",
"but",
"supports",
"non",
"-",
"standard",
"SQL",
"conversions",
"supported",
"by",
"JDBC"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java#L269-L272 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java | Type.getJDBCTypeCode | public static int getJDBCTypeCode(int type) {
switch (type) {
case Types.SQL_BLOB :
return Types.BLOB;
case Types.SQL_CLOB :
return Types.CLOB;
case Types.SQL_BIGINT :
return Types.BIGINT;
case Types.SQL_BINARY :
return Types.BINARY;
case Types.SQL_VARBINARY :
return Types.VARBINARY;
case Types.SQL_BIT :
case Types.SQL_BIT_VARYING :
return Types.BIT;
default :
return type;
}
} | java | public static int getJDBCTypeCode(int type) {
switch (type) {
case Types.SQL_BLOB :
return Types.BLOB;
case Types.SQL_CLOB :
return Types.CLOB;
case Types.SQL_BIGINT :
return Types.BIGINT;
case Types.SQL_BINARY :
return Types.BINARY;
case Types.SQL_VARBINARY :
return Types.VARBINARY;
case Types.SQL_BIT :
case Types.SQL_BIT_VARYING :
return Types.BIT;
default :
return type;
}
} | [
"public",
"static",
"int",
"getJDBCTypeCode",
"(",
"int",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"Types",
".",
"SQL_BLOB",
":",
"return",
"Types",
".",
"BLOB",
";",
"case",
"Types",
".",
"SQL_CLOB",
":",
"return",
"Types",
".",
"CLO... | translate an internal type number to JDBC type number if a type is not
supported internally, it is returned without translation
@param type int
@return int | [
"translate",
"an",
"internal",
"type",
"number",
"to",
"JDBC",
"type",
"number",
"if",
"a",
"type",
"is",
"not",
"supported",
"internally",
"it",
"is",
"returned",
"without",
"translation"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java#L837-L863 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java | Type.getType | public static Type getType(int type, int collation, long precision,
int scale) {
switch (type) {
case Types.SQL_ALL_TYPES :
return SQL_ALL_TYPES;
// return SQL_ALL_TYPES; // needs changes to Expression type resolution
case Types.SQL_CHAR :
case Types.SQL_VARCHAR :
case Types.VARCHAR_IGNORECASE :
case Types.SQL_CLOB :
return CharacterType.getCharacterType(type, precision);
case Types.SQL_INTEGER :
return SQL_INTEGER;
case Types.SQL_SMALLINT :
return SQL_SMALLINT;
case Types.SQL_BIGINT :
return SQL_BIGINT;
case Types.TINYINT :
return TINYINT;
case Types.SQL_FLOAT :
if (precision > 53) {
throw Error.error(ErrorCode.X_42592, "" + precision);
}
// $FALL-THROUGH$
case Types.SQL_REAL :
case Types.SQL_DOUBLE :
return SQL_DOUBLE;
case Types.SQL_NUMERIC :
case Types.SQL_DECIMAL :
if (precision == 0) {
precision = NumberType.defaultNumericPrecision;
}
// A VoltDB extension to disable variable scale decimals
scale = 12;
// End of VoltDB extension
return NumberType.getNumberType(type, precision, scale);
case Types.SQL_BOOLEAN :
return SQL_BOOLEAN;
case Types.SQL_BINARY :
case Types.SQL_VARBINARY :
case Types.SQL_BLOB :
return BinaryType.getBinaryType(type, precision);
case Types.SQL_BIT :
case Types.SQL_BIT_VARYING :
return BitType.getBitType(type, precision);
case Types.SQL_DATE :
case Types.SQL_TIME :
case Types.SQL_TIME_WITH_TIME_ZONE :
case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
return DateTimeType.getDateTimeType(type, scale);
case Types.SQL_INTERVAL_YEAR :
case Types.SQL_INTERVAL_YEAR_TO_MONTH :
case Types.SQL_INTERVAL_MONTH :
case Types.SQL_INTERVAL_DAY :
case Types.SQL_INTERVAL_DAY_TO_HOUR :
case Types.SQL_INTERVAL_DAY_TO_MINUTE :
case Types.SQL_INTERVAL_DAY_TO_SECOND :
case Types.SQL_INTERVAL_HOUR :
case Types.SQL_INTERVAL_HOUR_TO_MINUTE :
case Types.SQL_INTERVAL_HOUR_TO_SECOND :
case Types.SQL_INTERVAL_MINUTE :
case Types.SQL_INTERVAL_MINUTE_TO_SECOND :
case Types.SQL_INTERVAL_SECOND :
return IntervalType.getIntervalType(type, precision, scale);
case Types.VOLT_GEOGRAPHY_POINT :
return VOLT_GEOGRAPHY_POINT;
case Types.VOLT_GEOGRAPHY :
return new VoltGeographyType(precision);
case Types.OTHER :
return OTHER;
default :
throw Error.runtimeError(ErrorCode.U_S0500, "Type");
}
} | java | public static Type getType(int type, int collation, long precision,
int scale) {
switch (type) {
case Types.SQL_ALL_TYPES :
return SQL_ALL_TYPES;
// return SQL_ALL_TYPES; // needs changes to Expression type resolution
case Types.SQL_CHAR :
case Types.SQL_VARCHAR :
case Types.VARCHAR_IGNORECASE :
case Types.SQL_CLOB :
return CharacterType.getCharacterType(type, precision);
case Types.SQL_INTEGER :
return SQL_INTEGER;
case Types.SQL_SMALLINT :
return SQL_SMALLINT;
case Types.SQL_BIGINT :
return SQL_BIGINT;
case Types.TINYINT :
return TINYINT;
case Types.SQL_FLOAT :
if (precision > 53) {
throw Error.error(ErrorCode.X_42592, "" + precision);
}
// $FALL-THROUGH$
case Types.SQL_REAL :
case Types.SQL_DOUBLE :
return SQL_DOUBLE;
case Types.SQL_NUMERIC :
case Types.SQL_DECIMAL :
if (precision == 0) {
precision = NumberType.defaultNumericPrecision;
}
// A VoltDB extension to disable variable scale decimals
scale = 12;
// End of VoltDB extension
return NumberType.getNumberType(type, precision, scale);
case Types.SQL_BOOLEAN :
return SQL_BOOLEAN;
case Types.SQL_BINARY :
case Types.SQL_VARBINARY :
case Types.SQL_BLOB :
return BinaryType.getBinaryType(type, precision);
case Types.SQL_BIT :
case Types.SQL_BIT_VARYING :
return BitType.getBitType(type, precision);
case Types.SQL_DATE :
case Types.SQL_TIME :
case Types.SQL_TIME_WITH_TIME_ZONE :
case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
return DateTimeType.getDateTimeType(type, scale);
case Types.SQL_INTERVAL_YEAR :
case Types.SQL_INTERVAL_YEAR_TO_MONTH :
case Types.SQL_INTERVAL_MONTH :
case Types.SQL_INTERVAL_DAY :
case Types.SQL_INTERVAL_DAY_TO_HOUR :
case Types.SQL_INTERVAL_DAY_TO_MINUTE :
case Types.SQL_INTERVAL_DAY_TO_SECOND :
case Types.SQL_INTERVAL_HOUR :
case Types.SQL_INTERVAL_HOUR_TO_MINUTE :
case Types.SQL_INTERVAL_HOUR_TO_SECOND :
case Types.SQL_INTERVAL_MINUTE :
case Types.SQL_INTERVAL_MINUTE_TO_SECOND :
case Types.SQL_INTERVAL_SECOND :
return IntervalType.getIntervalType(type, precision, scale);
case Types.VOLT_GEOGRAPHY_POINT :
return VOLT_GEOGRAPHY_POINT;
case Types.VOLT_GEOGRAPHY :
return new VoltGeographyType(precision);
case Types.OTHER :
return OTHER;
default :
throw Error.runtimeError(ErrorCode.U_S0500, "Type");
}
} | [
"public",
"static",
"Type",
"getType",
"(",
"int",
"type",
",",
"int",
"collation",
",",
"long",
"precision",
",",
"int",
"scale",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"Types",
".",
"SQL_ALL_TYPES",
":",
"return",
"SQL_ALL_TYPES",
";",
"// ... | Enforces precision and scale limits on type | [
"Enforces",
"precision",
"and",
"scale",
"limits",
"on",
"type"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java#L868-L962 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/Grid.java | Grid.handleEvent | public boolean handleEvent(Event e) {
switch (e.id) {
case Event.SCROLL_LINE_UP :
case Event.SCROLL_LINE_DOWN :
case Event.SCROLL_PAGE_UP :
case Event.SCROLL_PAGE_DOWN :
case Event.SCROLL_ABSOLUTE :
iX = sbHoriz.getValue();
iY = iRowHeight * sbVert.getValue();
repaint();
return true;
}
return super.handleEvent(e);
} | java | public boolean handleEvent(Event e) {
switch (e.id) {
case Event.SCROLL_LINE_UP :
case Event.SCROLL_LINE_DOWN :
case Event.SCROLL_PAGE_UP :
case Event.SCROLL_PAGE_DOWN :
case Event.SCROLL_ABSOLUTE :
iX = sbHoriz.getValue();
iY = iRowHeight * sbVert.getValue();
repaint();
return true;
}
return super.handleEvent(e);
} | [
"public",
"boolean",
"handleEvent",
"(",
"Event",
"e",
")",
"{",
"switch",
"(",
"e",
".",
"id",
")",
"{",
"case",
"Event",
".",
"SCROLL_LINE_UP",
":",
"case",
"Event",
".",
"SCROLL_LINE_DOWN",
":",
"case",
"Event",
".",
"SCROLL_PAGE_UP",
":",
"case",
"Ev... | would require browsers to use the Java plugin. | [
"would",
"require",
"browsers",
"to",
"use",
"the",
"Java",
"plugin",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/Grid.java#L302-L320 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.getConfigureBytes | public static byte[] getConfigureBytes(int partitionCount, int tokenCount) {
Preconditions.checkArgument(partitionCount > 0);
Preconditions.checkArgument(tokenCount > partitionCount);
Buckets buckets = new Buckets(partitionCount, tokenCount);
ElasticHashinator hashinator = new ElasticHashinator(buckets.getTokens());
return hashinator.getConfigBytes();
} | java | public static byte[] getConfigureBytes(int partitionCount, int tokenCount) {
Preconditions.checkArgument(partitionCount > 0);
Preconditions.checkArgument(tokenCount > partitionCount);
Buckets buckets = new Buckets(partitionCount, tokenCount);
ElasticHashinator hashinator = new ElasticHashinator(buckets.getTokens());
return hashinator.getConfigBytes();
} | [
"public",
"static",
"byte",
"[",
"]",
"getConfigureBytes",
"(",
"int",
"partitionCount",
",",
"int",
"tokenCount",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"partitionCount",
">",
"0",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"tokenCount... | Convenience method for generating a deterministic token distribution for the ring based
on a given partition count and tokens per partition. Each partition will have N tokens
placed randomly on the ring. | [
"Convenience",
"method",
"for",
"generating",
"a",
"deterministic",
"token",
"distribution",
"for",
"the",
"ring",
"based",
"on",
"a",
"given",
"partition",
"count",
"and",
"tokens",
"per",
"partition",
".",
"Each",
"partition",
"will",
"have",
"N",
"tokens",
... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L200-L206 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.toBytes | private byte[] toBytes() {
ByteBuffer buf = ByteBuffer.allocate(4 + (m_tokenCount * 8));
buf.putInt(m_tokenCount);
int lastToken = Integer.MIN_VALUE;
for (int ii = 0; ii < m_tokenCount; ii++) {
final long ptr = m_tokens + (ii * 8);
final int token = Bits.unsafe.getInt(ptr);
Preconditions.checkArgument(token >= lastToken);
lastToken = token;
final int pid = Bits.unsafe.getInt(ptr + 4);
buf.putInt(token);
buf.putInt(pid);
}
return buf.array();
} | java | private byte[] toBytes() {
ByteBuffer buf = ByteBuffer.allocate(4 + (m_tokenCount * 8));
buf.putInt(m_tokenCount);
int lastToken = Integer.MIN_VALUE;
for (int ii = 0; ii < m_tokenCount; ii++) {
final long ptr = m_tokens + (ii * 8);
final int token = Bits.unsafe.getInt(ptr);
Preconditions.checkArgument(token >= lastToken);
lastToken = token;
final int pid = Bits.unsafe.getInt(ptr + 4);
buf.putInt(token);
buf.putInt(pid);
}
return buf.array();
} | [
"private",
"byte",
"[",
"]",
"toBytes",
"(",
")",
"{",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"4",
"+",
"(",
"m_tokenCount",
"*",
"8",
")",
")",
";",
"buf",
".",
"putInt",
"(",
"m_tokenCount",
")",
";",
"int",
"lastToken",
"=",... | Serializes the configuration into bytes, also updates the currently cached m_configBytes.
@return The byte[] of the current configuration. | [
"Serializes",
"the",
"configuration",
"into",
"bytes",
"also",
"updates",
"the",
"currently",
"cached",
"m_configBytes",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L212-L226 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.addTokens | public ElasticHashinator addTokens(NavigableMap<Integer, Integer> tokensToAdd)
{
// figure out the interval
long interval = deriveTokenInterval(m_tokensMap.get().keySet());
Map<Integer, Integer> tokens = Maps.newTreeMap();
for (Map.Entry<Integer, Integer> e : m_tokensMap.get().entrySet()) {
if (tokensToAdd.containsKey(e.getKey())) {
continue;
}
// see if we are moving an intermediate token forward
if (isIntermediateToken(e.getKey(), interval)) {
Map.Entry<Integer, Integer> floorEntry = tokensToAdd.floorEntry(e.getKey());
// If the two tokens belong to the same partition and bucket, we are moving the one on the ring
// forward, so remove it from the ring
if (floorEntry != null &&
floorEntry.getValue().equals(e.getValue()) &&
containingBucket(floorEntry.getKey(), interval) == containingBucket(e.getKey(), interval)) {
continue;
}
}
tokens.put(e.getKey(), e.getValue());
}
tokens.putAll(tokensToAdd);
return new ElasticHashinator(ImmutableSortedMap.copyOf(tokens));
} | java | public ElasticHashinator addTokens(NavigableMap<Integer, Integer> tokensToAdd)
{
// figure out the interval
long interval = deriveTokenInterval(m_tokensMap.get().keySet());
Map<Integer, Integer> tokens = Maps.newTreeMap();
for (Map.Entry<Integer, Integer> e : m_tokensMap.get().entrySet()) {
if (tokensToAdd.containsKey(e.getKey())) {
continue;
}
// see if we are moving an intermediate token forward
if (isIntermediateToken(e.getKey(), interval)) {
Map.Entry<Integer, Integer> floorEntry = tokensToAdd.floorEntry(e.getKey());
// If the two tokens belong to the same partition and bucket, we are moving the one on the ring
// forward, so remove it from the ring
if (floorEntry != null &&
floorEntry.getValue().equals(e.getValue()) &&
containingBucket(floorEntry.getKey(), interval) == containingBucket(e.getKey(), interval)) {
continue;
}
}
tokens.put(e.getKey(), e.getValue());
}
tokens.putAll(tokensToAdd);
return new ElasticHashinator(ImmutableSortedMap.copyOf(tokens));
} | [
"public",
"ElasticHashinator",
"addTokens",
"(",
"NavigableMap",
"<",
"Integer",
",",
"Integer",
">",
"tokensToAdd",
")",
"{",
"// figure out the interval",
"long",
"interval",
"=",
"deriveTokenInterval",
"(",
"m_tokensMap",
".",
"get",
"(",
")",
".",
"keySet",
"(... | Add the given tokens to the ring and generate the new hashinator. The current hashinator is not changed.
@param tokensToAdd Tokens to add as a map of tokens to partitions
@return The new hashinator | [
"Add",
"the",
"given",
"tokens",
"to",
"the",
"ring",
"and",
"generate",
"the",
"new",
"hashinator",
".",
"The",
"current",
"hashinator",
"is",
"not",
"changed",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L314-L342 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.pPredecessors | @Override
public Map<Integer, Integer> pPredecessors(int partition) {
Map<Integer, Integer> predecessors = new TreeMap<Integer, Integer>();
UnmodifiableIterator<Map.Entry<Integer,Integer>> iter = m_tokensMap.get().entrySet().iterator();
Set<Integer> pTokens = new HashSet<Integer>();
while (iter.hasNext()) {
Map.Entry<Integer, Integer> next = iter.next();
if (next.getValue() == partition) {
pTokens.add(next.getKey());
}
}
for (Integer token : pTokens) {
Map.Entry<Integer, Integer> predecessor = null;
if (token != null) {
predecessor = m_tokensMap.get().headMap(token).lastEntry();
// If null, it means partition is the first one on the ring, so predecessor
// should be the last entry on the ring because it wraps around.
if (predecessor == null) {
predecessor = m_tokensMap.get().lastEntry();
}
}
if (predecessor != null && predecessor.getValue() != partition) {
predecessors.put(predecessor.getKey(), predecessor.getValue());
}
}
return predecessors;
} | java | @Override
public Map<Integer, Integer> pPredecessors(int partition) {
Map<Integer, Integer> predecessors = new TreeMap<Integer, Integer>();
UnmodifiableIterator<Map.Entry<Integer,Integer>> iter = m_tokensMap.get().entrySet().iterator();
Set<Integer> pTokens = new HashSet<Integer>();
while (iter.hasNext()) {
Map.Entry<Integer, Integer> next = iter.next();
if (next.getValue() == partition) {
pTokens.add(next.getKey());
}
}
for (Integer token : pTokens) {
Map.Entry<Integer, Integer> predecessor = null;
if (token != null) {
predecessor = m_tokensMap.get().headMap(token).lastEntry();
// If null, it means partition is the first one on the ring, so predecessor
// should be the last entry on the ring because it wraps around.
if (predecessor == null) {
predecessor = m_tokensMap.get().lastEntry();
}
}
if (predecessor != null && predecessor.getValue() != partition) {
predecessors.put(predecessor.getKey(), predecessor.getValue());
}
}
return predecessors;
} | [
"@",
"Override",
"public",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"pPredecessors",
"(",
"int",
"partition",
")",
"{",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"predecessors",
"=",
"new",
"TreeMap",
"<",
"Integer",
",",
"Integer",
">",
"(",
")",
... | Find the predecessors of the given partition on the ring. This method runs in linear time,
use with caution when the set of partitions is large.
@param partition
@return The map of tokens to partitions that are the predecessors of the given partition.
If the given partition doesn't exist or it's the only partition on the ring, the
map will be empty. | [
"Find",
"the",
"predecessors",
"of",
"the",
"given",
"partition",
"on",
"the",
"ring",
".",
"This",
"method",
"runs",
"in",
"linear",
"time",
"use",
"with",
"caution",
"when",
"the",
"set",
"of",
"partitions",
"is",
"large",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L375-L404 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.pPredecessor | @Override
public Pair<Integer, Integer> pPredecessor(int partition, int token) {
Integer partForToken = m_tokensMap.get().get(token);
if (partForToken != null && partForToken == partition) {
Map.Entry<Integer, Integer> predecessor = m_tokensMap.get().headMap(token).lastEntry();
if (predecessor == null) {
predecessor = m_tokensMap.get().lastEntry();
}
if (predecessor.getKey() != token) {
return Pair.of(predecessor.getKey(), predecessor.getValue());
} else {
// given token is the only one on the ring, umpossible
throw new RuntimeException("There is only one token on the hash ring");
}
} else {
// given token doesn't map to partition
throw new IllegalArgumentException("The given token " + token +
" does not map to partition " + partition);
}
} | java | @Override
public Pair<Integer, Integer> pPredecessor(int partition, int token) {
Integer partForToken = m_tokensMap.get().get(token);
if (partForToken != null && partForToken == partition) {
Map.Entry<Integer, Integer> predecessor = m_tokensMap.get().headMap(token).lastEntry();
if (predecessor == null) {
predecessor = m_tokensMap.get().lastEntry();
}
if (predecessor.getKey() != token) {
return Pair.of(predecessor.getKey(), predecessor.getValue());
} else {
// given token is the only one on the ring, umpossible
throw new RuntimeException("There is only one token on the hash ring");
}
} else {
// given token doesn't map to partition
throw new IllegalArgumentException("The given token " + token +
" does not map to partition " + partition);
}
} | [
"@",
"Override",
"public",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
"pPredecessor",
"(",
"int",
"partition",
",",
"int",
"token",
")",
"{",
"Integer",
"partForToken",
"=",
"m_tokensMap",
".",
"get",
"(",
")",
".",
"get",
"(",
"token",
")",
";",
"if... | Find the predecessor of the given token on the ring.
@param partition The partition that maps to the given token
@param token The token on the ring
@return The predecessor of the given token. | [
"Find",
"the",
"predecessor",
"of",
"the",
"given",
"token",
"on",
"the",
"ring",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L412-L433 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.pGetRanges | @Override
public Map<Integer, Integer> pGetRanges(int partition) {
Map<Integer, Integer> ranges = new TreeMap<Integer, Integer>();
Integer first = null; // start of the very first token on the ring
Integer start = null; // start of a range
UnmodifiableIterator<Map.Entry<Integer,Integer>> iter = m_tokensMap.get().entrySet().iterator();
// Iterate through the token map to find the ranges assigned to
// the given partition
while (iter.hasNext()) {
Map.Entry<Integer, Integer> next = iter.next();
int token = next.getKey();
int pid = next.getValue();
if (first == null) {
first = token;
}
// if start is not null, there's an open range, now is
// the time to close it.
// else there is no open range, keep on going.
if (start != null) {
//Range end is inclusive so do token - 1
ranges.put(start, token - 1);
start = null;
}
if (pid == partition) {
// if start is null, there's no open range, start one.
start = token;
}
}
// if there is an open range when we get here
// It is the last token which implicity ends at the next max value
if (start != null) {
assert first != null;
ranges.put(start, Integer.MAX_VALUE);
}
return ranges;
} | java | @Override
public Map<Integer, Integer> pGetRanges(int partition) {
Map<Integer, Integer> ranges = new TreeMap<Integer, Integer>();
Integer first = null; // start of the very first token on the ring
Integer start = null; // start of a range
UnmodifiableIterator<Map.Entry<Integer,Integer>> iter = m_tokensMap.get().entrySet().iterator();
// Iterate through the token map to find the ranges assigned to
// the given partition
while (iter.hasNext()) {
Map.Entry<Integer, Integer> next = iter.next();
int token = next.getKey();
int pid = next.getValue();
if (first == null) {
first = token;
}
// if start is not null, there's an open range, now is
// the time to close it.
// else there is no open range, keep on going.
if (start != null) {
//Range end is inclusive so do token - 1
ranges.put(start, token - 1);
start = null;
}
if (pid == partition) {
// if start is null, there's no open range, start one.
start = token;
}
}
// if there is an open range when we get here
// It is the last token which implicity ends at the next max value
if (start != null) {
assert first != null;
ranges.put(start, Integer.MAX_VALUE);
}
return ranges;
} | [
"@",
"Override",
"public",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"pGetRanges",
"(",
"int",
"partition",
")",
"{",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"ranges",
"=",
"new",
"TreeMap",
"<",
"Integer",
",",
"Integer",
">",
"(",
")",
";",
"... | This runs in linear time with respect to the number of tokens on the ring. | [
"This",
"runs",
"in",
"linear",
"time",
"with",
"respect",
"to",
"the",
"number",
"of",
"tokens",
"on",
"the",
"ring",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L438-L479 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.toCookedBytes | private byte[] toCookedBytes()
{
// Allocate for a int pair per token/partition ID entry, plus a size.
ByteBuffer buf = ByteBuffer.allocate(4 + (m_tokenCount * 8));
buf.putInt(m_tokenCount);
// Keep tokens and partition ids separate to aid compression.
for (int zz = 3; zz >= 0; zz--) {
int lastToken = Integer.MIN_VALUE;
for (int ii = 0; ii < m_tokenCount; ii++) {
int token = Bits.unsafe.getInt(m_tokens + (ii * 8));
Preconditions.checkArgument(token >= lastToken);
lastToken = token;
token = token >>> (zz * 8);
token = token & 0xFF;
buf.put((byte)token);
}
}
for (int ii = 0; ii < m_tokenCount; ii++) {
buf.putInt(Bits.unsafe.getInt(m_tokens + (ii * 8) + 4));
}
try {
return CompressionService.gzipBytes(buf.array());
} catch (IOException e) {
throw new RuntimeException("Failed to compress bytes", e);
}
} | java | private byte[] toCookedBytes()
{
// Allocate for a int pair per token/partition ID entry, plus a size.
ByteBuffer buf = ByteBuffer.allocate(4 + (m_tokenCount * 8));
buf.putInt(m_tokenCount);
// Keep tokens and partition ids separate to aid compression.
for (int zz = 3; zz >= 0; zz--) {
int lastToken = Integer.MIN_VALUE;
for (int ii = 0; ii < m_tokenCount; ii++) {
int token = Bits.unsafe.getInt(m_tokens + (ii * 8));
Preconditions.checkArgument(token >= lastToken);
lastToken = token;
token = token >>> (zz * 8);
token = token & 0xFF;
buf.put((byte)token);
}
}
for (int ii = 0; ii < m_tokenCount; ii++) {
buf.putInt(Bits.unsafe.getInt(m_tokens + (ii * 8) + 4));
}
try {
return CompressionService.gzipBytes(buf.array());
} catch (IOException e) {
throw new RuntimeException("Failed to compress bytes", e);
}
} | [
"private",
"byte",
"[",
"]",
"toCookedBytes",
"(",
")",
"{",
"// Allocate for a int pair per token/partition ID entry, plus a size.",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"4",
"+",
"(",
"m_tokenCount",
"*",
"8",
")",
")",
";",
"buf",
".",
... | Returns compressed config bytes.
@return config bytes
@throws IOException | [
"Returns",
"compressed",
"config",
"bytes",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L540-L567 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.trackAllocatedHashinatorBytes | private static synchronized void trackAllocatedHashinatorBytes(long bytes) {
final long allocated = m_allocatedHashinatorBytes.addAndGet(bytes);
if (allocated > HASHINATOR_GC_THRESHHOLD) {
hostLogger.warn(allocated + " bytes of hashinator data has been allocated");
if (m_emergencyGCThread == null || m_emergencyGCThread.getState() == State.TERMINATED) {
m_emergencyGCThread = new Thread(new Runnable() {
@Override
public void run() {
hostLogger.warn("Invoking System.gc() to recoup hashinator bytes");
System.gc();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {}
hostLogger.info(m_allocatedHashinatorBytes.get() + " bytes of hashinator allocated after GC");
}
}, "Hashinator GC thread");
m_emergencyGCThread.start();
}
}
} | java | private static synchronized void trackAllocatedHashinatorBytes(long bytes) {
final long allocated = m_allocatedHashinatorBytes.addAndGet(bytes);
if (allocated > HASHINATOR_GC_THRESHHOLD) {
hostLogger.warn(allocated + " bytes of hashinator data has been allocated");
if (m_emergencyGCThread == null || m_emergencyGCThread.getState() == State.TERMINATED) {
m_emergencyGCThread = new Thread(new Runnable() {
@Override
public void run() {
hostLogger.warn("Invoking System.gc() to recoup hashinator bytes");
System.gc();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {}
hostLogger.info(m_allocatedHashinatorBytes.get() + " bytes of hashinator allocated after GC");
}
}, "Hashinator GC thread");
m_emergencyGCThread.start();
}
}
} | [
"private",
"static",
"synchronized",
"void",
"trackAllocatedHashinatorBytes",
"(",
"long",
"bytes",
")",
"{",
"final",
"long",
"allocated",
"=",
"m_allocatedHashinatorBytes",
".",
"addAndGet",
"(",
"bytes",
")",
";",
"if",
"(",
"allocated",
">",
"HASHINATOR_GC_THRES... | Track allocated bytes and invoke System.gc to encourage reclamation if it is growing large | [
"Track",
"allocated",
"bytes",
"and",
"invoke",
"System",
".",
"gc",
"to",
"encourage",
"reclamation",
"if",
"it",
"is",
"growing",
"large"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L675-L694 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.deriveTokenInterval | private static long deriveTokenInterval(ImmutableSortedSet<Integer> tokens)
{
long interval = 0;
int count = 4;
int prevToken = Integer.MIN_VALUE;
UnmodifiableIterator<Integer> tokenIter = tokens.iterator();
while (tokenIter.hasNext() && count-- > 0) {
int nextToken = tokenIter.next();
interval = Math.max(interval, nextToken - prevToken);
prevToken = nextToken;
}
return interval;
} | java | private static long deriveTokenInterval(ImmutableSortedSet<Integer> tokens)
{
long interval = 0;
int count = 4;
int prevToken = Integer.MIN_VALUE;
UnmodifiableIterator<Integer> tokenIter = tokens.iterator();
while (tokenIter.hasNext() && count-- > 0) {
int nextToken = tokenIter.next();
interval = Math.max(interval, nextToken - prevToken);
prevToken = nextToken;
}
return interval;
} | [
"private",
"static",
"long",
"deriveTokenInterval",
"(",
"ImmutableSortedSet",
"<",
"Integer",
">",
"tokens",
")",
"{",
"long",
"interval",
"=",
"0",
";",
"int",
"count",
"=",
"4",
";",
"int",
"prevToken",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"Unmodifiable... | Figure out the token interval from the first 3 ranges, assuming that there is at most one token that doesn't
fall onto the bucket boundary at any given time. The largest range will be the hashinator's bucket size.
@return The bucket size, or token interval if you prefer. | [
"Figure",
"out",
"the",
"token",
"interval",
"from",
"the",
"first",
"3",
"ranges",
"assuming",
"that",
"there",
"is",
"at",
"most",
"one",
"token",
"that",
"doesn",
"t",
"fall",
"onto",
"the",
"bucket",
"boundary",
"at",
"any",
"given",
"time",
".",
"Th... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L740-L752 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ElasticHashinator.java | ElasticHashinator.containingBucket | private static int containingBucket(int token, long interval)
{
return (int) ((((long) token - Integer.MIN_VALUE) / interval) * interval + Integer.MIN_VALUE);
} | java | private static int containingBucket(int token, long interval)
{
return (int) ((((long) token - Integer.MIN_VALUE) / interval) * interval + Integer.MIN_VALUE);
} | [
"private",
"static",
"int",
"containingBucket",
"(",
"int",
"token",
",",
"long",
"interval",
")",
"{",
"return",
"(",
"int",
")",
"(",
"(",
"(",
"(",
"long",
")",
"token",
"-",
"Integer",
".",
"MIN_VALUE",
")",
"/",
"interval",
")",
"*",
"interval",
... | Calculate the boundary of the bucket that countain the given token given the token interval.
@return The token of the bucket boundary. | [
"Calculate",
"the",
"boundary",
"of",
"the",
"bucket",
"that",
"countain",
"the",
"given",
"token",
"given",
"the",
"token",
"interval",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ElasticHashinator.java#L767-L770 | train |
VoltDB/voltdb | src/frontend/org/voltdb/plannodes/InsertPlanNode.java | InsertPlanNode.isOrderDeterministic | @Override
public boolean isOrderDeterministic() {
assert(m_children != null);
assert(m_children.size() == 1);
// This implementation is very close to AbstractPlanNode's implementation of this
// method, except that we assert just one child.
// Java doesn't allow calls to super-super-class methods via super.super.
AbstractPlanNode child = m_children.get(0);
if (! child.isOrderDeterministic()) {
m_nondeterminismDetail = child.m_nondeterminismDetail;
return false;
}
return true;
} | java | @Override
public boolean isOrderDeterministic() {
assert(m_children != null);
assert(m_children.size() == 1);
// This implementation is very close to AbstractPlanNode's implementation of this
// method, except that we assert just one child.
// Java doesn't allow calls to super-super-class methods via super.super.
AbstractPlanNode child = m_children.get(0);
if (! child.isOrderDeterministic()) {
m_nondeterminismDetail = child.m_nondeterminismDetail;
return false;
}
return true;
} | [
"@",
"Override",
"public",
"boolean",
"isOrderDeterministic",
"(",
")",
"{",
"assert",
"(",
"m_children",
"!=",
"null",
")",
";",
"assert",
"(",
"m_children",
".",
"size",
"(",
")",
"==",
"1",
")",
";",
"// This implementation is very close to AbstractPlanNode's i... | Order determinism for insert nodes depends on the determinism of child nodes. For subqueries producing
unordered rows, the insert will be considered order-nondeterministic. | [
"Order",
"determinism",
"for",
"insert",
"nodes",
"depends",
"on",
"the",
"determinism",
"of",
"child",
"nodes",
".",
"For",
"subqueries",
"producing",
"unordered",
"rows",
"the",
"insert",
"will",
"be",
"considered",
"order",
"-",
"nondeterministic",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/plannodes/InsertPlanNode.java#L120-L135 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocNTBase.java | AdHocNTBase.logBatch | private void logBatch(final CatalogContext context,
final AdHocPlannedStmtBatch batch,
final Object[] userParams)
{
final int numStmts = batch.getPlannedStatementCount();
final int numParams = userParams == null ? 0 : userParams.length;
final String readOnly = batch.readOnly ? "yes" : "no";
final String singlePartition = batch.isSinglePartitionCompatible() ? "yes" : "no";
final String user = getUsername();
final String[] groupNames = context.authSystem.getGroupNamesForUser(user);
final String groupList = StringUtils.join(groupNames, ',');
//String[] stmtArray = batch.stmts.stream().map(s -> new String(s.sql, Charsets.UTF_8)).toArray(String[]::new);
adhocLog.debug(String.format(
"=== statements=%d parameters=%d read-only=%s single-partition=%s user=%s groups=[%s]",
numStmts, numParams, readOnly, singlePartition, user, groupList));
for (int i = 0; i < batch.getPlannedStatementCount(); i++) {
AdHocPlannedStatement stmt = batch.getPlannedStatement(i);
String sql = stmt.sql == null ? "SQL_UNKNOWN" : new String(stmt.sql, Charsets.UTF_8);
adhocLog.debug(String.format("Statement #%d: %s", i + 1, sql));
}
if (userParams != null) {
for (int i = 0; i < userParams.length; ++i) {
Object value = userParams[i];
final String valueString = (value != null ? value.toString() : "NULL");
adhocLog.debug(String.format("Parameter #%d: %s", i + 1, valueString));
}
}
} | java | private void logBatch(final CatalogContext context,
final AdHocPlannedStmtBatch batch,
final Object[] userParams)
{
final int numStmts = batch.getPlannedStatementCount();
final int numParams = userParams == null ? 0 : userParams.length;
final String readOnly = batch.readOnly ? "yes" : "no";
final String singlePartition = batch.isSinglePartitionCompatible() ? "yes" : "no";
final String user = getUsername();
final String[] groupNames = context.authSystem.getGroupNamesForUser(user);
final String groupList = StringUtils.join(groupNames, ',');
//String[] stmtArray = batch.stmts.stream().map(s -> new String(s.sql, Charsets.UTF_8)).toArray(String[]::new);
adhocLog.debug(String.format(
"=== statements=%d parameters=%d read-only=%s single-partition=%s user=%s groups=[%s]",
numStmts, numParams, readOnly, singlePartition, user, groupList));
for (int i = 0; i < batch.getPlannedStatementCount(); i++) {
AdHocPlannedStatement stmt = batch.getPlannedStatement(i);
String sql = stmt.sql == null ? "SQL_UNKNOWN" : new String(stmt.sql, Charsets.UTF_8);
adhocLog.debug(String.format("Statement #%d: %s", i + 1, sql));
}
if (userParams != null) {
for (int i = 0; i < userParams.length; ++i) {
Object value = userParams[i];
final String valueString = (value != null ? value.toString() : "NULL");
adhocLog.debug(String.format("Parameter #%d: %s", i + 1, valueString));
}
}
} | [
"private",
"void",
"logBatch",
"(",
"final",
"CatalogContext",
"context",
",",
"final",
"AdHocPlannedStmtBatch",
"batch",
",",
"final",
"Object",
"[",
"]",
"userParams",
")",
"{",
"final",
"int",
"numStmts",
"=",
"batch",
".",
"getPlannedStatementCount",
"(",
")... | Log ad hoc batch info
@param batch planned statement batch | [
"Log",
"ad",
"hoc",
"batch",
"info"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocNTBase.java#L83-L112 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocNTBase.java | AdHocNTBase.processExplainDefaultProc | static CompletableFuture<ClientResponse> processExplainDefaultProc(AdHocPlannedStmtBatch planBatch) {
Database db = VoltDB.instance().getCatalogContext().database;
// there better be one statement if this is really SQL
// from a default procedure
assert(planBatch.getPlannedStatementCount() == 1);
AdHocPlannedStatement ahps = planBatch.getPlannedStatement(0);
String sql = new String(ahps.sql, StandardCharsets.UTF_8);
String explain = planBatch.explainStatement(0, db, false);
VoltTable vt = new VoltTable(new VoltTable.ColumnInfo("STATEMENT_NAME", VoltType.STRING),
new VoltTable.ColumnInfo( "SQL_STATEMENT", VoltType.STRING),
new VoltTable.ColumnInfo( "EXECUTION_PLAN", VoltType.STRING));
vt.addRow("sql0", sql, explain);
ClientResponseImpl response =
new ClientResponseImpl(
ClientResponseImpl.SUCCESS,
ClientResponse.UNINITIALIZED_APP_STATUS_CODE,
null,
new VoltTable[] { vt },
null);
CompletableFuture<ClientResponse> fut = new CompletableFuture<>();
fut.complete(response);
return fut;
} | java | static CompletableFuture<ClientResponse> processExplainDefaultProc(AdHocPlannedStmtBatch planBatch) {
Database db = VoltDB.instance().getCatalogContext().database;
// there better be one statement if this is really SQL
// from a default procedure
assert(planBatch.getPlannedStatementCount() == 1);
AdHocPlannedStatement ahps = planBatch.getPlannedStatement(0);
String sql = new String(ahps.sql, StandardCharsets.UTF_8);
String explain = planBatch.explainStatement(0, db, false);
VoltTable vt = new VoltTable(new VoltTable.ColumnInfo("STATEMENT_NAME", VoltType.STRING),
new VoltTable.ColumnInfo( "SQL_STATEMENT", VoltType.STRING),
new VoltTable.ColumnInfo( "EXECUTION_PLAN", VoltType.STRING));
vt.addRow("sql0", sql, explain);
ClientResponseImpl response =
new ClientResponseImpl(
ClientResponseImpl.SUCCESS,
ClientResponse.UNINITIALIZED_APP_STATUS_CODE,
null,
new VoltTable[] { vt },
null);
CompletableFuture<ClientResponse> fut = new CompletableFuture<>();
fut.complete(response);
return fut;
} | [
"static",
"CompletableFuture",
"<",
"ClientResponse",
">",
"processExplainDefaultProc",
"(",
"AdHocPlannedStmtBatch",
"planBatch",
")",
"{",
"Database",
"db",
"=",
"VoltDB",
".",
"instance",
"(",
")",
".",
"getCatalogContext",
"(",
")",
".",
"database",
";",
"// t... | Explain Proc for a default proc is routed through the regular Explain
path using ad hoc planning and all. Take the result from that async
process and format it like other explains for procedures. | [
"Explain",
"Proc",
"for",
"a",
"default",
"proc",
"is",
"routed",
"through",
"the",
"regular",
"Explain",
"path",
"using",
"ad",
"hoc",
"planning",
"and",
"all",
".",
"Take",
"the",
"result",
"from",
"that",
"async",
"process",
"and",
"format",
"it",
"like... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocNTBase.java#L414-L440 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocNTBase.java | AdHocNTBase.createAdHocTransaction | private final CompletableFuture<ClientResponse> createAdHocTransaction(
final AdHocPlannedStmtBatch plannedStmtBatch,
final boolean isSwapTables)
throws VoltTypeException
{
ByteBuffer buf = null;
try {
buf = plannedStmtBatch.flattenPlanArrayToBuffer();
}
catch (IOException e) {
VoltDB.crashLocalVoltDB(e.getMessage(), true, e);
}
assert(buf.hasArray());
// create the execution site task
String procedureName = null;
Object[] params = null;
// pick the sysproc based on the presence of partition info
// HSQL (or PostgreSQL) does not specifically implement AdHoc SP
// -- instead, use its always-SP implementation of AdHoc
boolean isSinglePartition = plannedStmtBatch.isSinglePartitionCompatible() || m_isConfiguredForNonVoltDBBackend;
if (isSwapTables) {
procedureName = "@SwapTablesCore";
params = new Object[] { buf.array() };
}
else if (isSinglePartition) {
if (plannedStmtBatch.isReadOnly()) {
procedureName = "@AdHoc_RO_SP";
}
else {
procedureName = "@AdHoc_RW_SP";
}
int type = VoltType.NULL.getValue();
// replicated table read is single-part without a partitioning param
// I copied this from below, but I'm not convinced that the above statement is correct
// or that the null behavior here either (a) ever actually happens or (b) has the
// desired intent.
Object partitionParam = plannedStmtBatch.partitionParam();
byte[] param = null;
if (partitionParam != null) {
type = VoltType.typeFromClass(partitionParam.getClass()).getValue();
param = VoltType.valueToBytes(partitionParam);
}
// Send the partitioning parameter and its type along so that the site can check if
// it's mis-partitioned. Type is needed to re-hashinate for command log re-init.
params = new Object[] { param, (byte)type, buf.array() };
}
else {
if (plannedStmtBatch.isReadOnly()) {
procedureName = "@AdHoc_RO_MP";
}
else {
procedureName = "@AdHoc_RW_MP";
}
params = new Object[] { buf.array() };
}
return callProcedure(procedureName, params);
} | java | private final CompletableFuture<ClientResponse> createAdHocTransaction(
final AdHocPlannedStmtBatch plannedStmtBatch,
final boolean isSwapTables)
throws VoltTypeException
{
ByteBuffer buf = null;
try {
buf = plannedStmtBatch.flattenPlanArrayToBuffer();
}
catch (IOException e) {
VoltDB.crashLocalVoltDB(e.getMessage(), true, e);
}
assert(buf.hasArray());
// create the execution site task
String procedureName = null;
Object[] params = null;
// pick the sysproc based on the presence of partition info
// HSQL (or PostgreSQL) does not specifically implement AdHoc SP
// -- instead, use its always-SP implementation of AdHoc
boolean isSinglePartition = plannedStmtBatch.isSinglePartitionCompatible() || m_isConfiguredForNonVoltDBBackend;
if (isSwapTables) {
procedureName = "@SwapTablesCore";
params = new Object[] { buf.array() };
}
else if (isSinglePartition) {
if (plannedStmtBatch.isReadOnly()) {
procedureName = "@AdHoc_RO_SP";
}
else {
procedureName = "@AdHoc_RW_SP";
}
int type = VoltType.NULL.getValue();
// replicated table read is single-part without a partitioning param
// I copied this from below, but I'm not convinced that the above statement is correct
// or that the null behavior here either (a) ever actually happens or (b) has the
// desired intent.
Object partitionParam = plannedStmtBatch.partitionParam();
byte[] param = null;
if (partitionParam != null) {
type = VoltType.typeFromClass(partitionParam.getClass()).getValue();
param = VoltType.valueToBytes(partitionParam);
}
// Send the partitioning parameter and its type along so that the site can check if
// it's mis-partitioned. Type is needed to re-hashinate for command log re-init.
params = new Object[] { param, (byte)type, buf.array() };
}
else {
if (plannedStmtBatch.isReadOnly()) {
procedureName = "@AdHoc_RO_MP";
}
else {
procedureName = "@AdHoc_RW_MP";
}
params = new Object[] { buf.array() };
}
return callProcedure(procedureName, params);
} | [
"private",
"final",
"CompletableFuture",
"<",
"ClientResponse",
">",
"createAdHocTransaction",
"(",
"final",
"AdHocPlannedStmtBatch",
"plannedStmtBatch",
",",
"final",
"boolean",
"isSwapTables",
")",
"throws",
"VoltTypeException",
"{",
"ByteBuffer",
"buf",
"=",
"null",
... | Take a set of adhoc plans and pass them off to the right transactional
adhoc variant. | [
"Take",
"a",
"set",
"of",
"adhoc",
"plans",
"and",
"pass",
"them",
"off",
"to",
"the",
"right",
"transactional",
"adhoc",
"variant",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocNTBase.java#L446-L507 | train |
VoltDB/voltdb | src/frontend/org/voltdb/expressions/RowSubqueryExpression.java | RowSubqueryExpression.collectParameterValueExpressions | private void collectParameterValueExpressions(AbstractExpression expr, List<AbstractExpression> pves) {
if (expr == null) {
return;
}
if (expr instanceof TupleValueExpression || expr instanceof AggregateExpression) {
// Create a matching PVE for this expression to be used on the EE side
// to get the original expression value
addCorrelationParameterValueExpression(expr, pves);
return;
}
collectParameterValueExpressions(expr.getLeft(), pves);
collectParameterValueExpressions(expr.getRight(), pves);
if (expr.getArgs() != null) {
for (AbstractExpression arg : expr.getArgs()) {
collectParameterValueExpressions(arg, pves);
}
}
} | java | private void collectParameterValueExpressions(AbstractExpression expr, List<AbstractExpression> pves) {
if (expr == null) {
return;
}
if (expr instanceof TupleValueExpression || expr instanceof AggregateExpression) {
// Create a matching PVE for this expression to be used on the EE side
// to get the original expression value
addCorrelationParameterValueExpression(expr, pves);
return;
}
collectParameterValueExpressions(expr.getLeft(), pves);
collectParameterValueExpressions(expr.getRight(), pves);
if (expr.getArgs() != null) {
for (AbstractExpression arg : expr.getArgs()) {
collectParameterValueExpressions(arg, pves);
}
}
} | [
"private",
"void",
"collectParameterValueExpressions",
"(",
"AbstractExpression",
"expr",
",",
"List",
"<",
"AbstractExpression",
">",
"pves",
")",
"{",
"if",
"(",
"expr",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"expr",
"instanceof",
"TupleValue... | PVE inside the Row subquery | [
"PVE",
"inside",
"the",
"Row",
"subquery"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/RowSubqueryExpression.java#L70-L88 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.newPSMResult | public static Result newPSMResult(int type, String label, Object value) {
Result result = newResult(ResultConstants.VALUE);
result.errorCode = type;
result.mainString = label;
result.valueData = value;
return result;
} | java | public static Result newPSMResult(int type, String label, Object value) {
Result result = newResult(ResultConstants.VALUE);
result.errorCode = type;
result.mainString = label;
result.valueData = value;
return result;
} | [
"public",
"static",
"Result",
"newPSMResult",
"(",
"int",
"type",
",",
"String",
"label",
",",
"Object",
"value",
")",
"{",
"Result",
"result",
"=",
"newResult",
"(",
"ResultConstants",
".",
"VALUE",
")",
";",
"result",
".",
"errorCode",
"=",
"type",
";",
... | For interval PSM return values | [
"For",
"interval",
"PSM",
"return",
"values"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L592-L601 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.newPreparedExecuteRequest | public static Result newPreparedExecuteRequest(Type[] types,
long statementId) {
Result result = newResult(ResultConstants.EXECUTE);
result.metaData = ResultMetaData.newSimpleResultMetaData(types);
result.statementID = statementId;
result.navigator.add(ValuePool.emptyObjectArray);
return result;
} | java | public static Result newPreparedExecuteRequest(Type[] types,
long statementId) {
Result result = newResult(ResultConstants.EXECUTE);
result.metaData = ResultMetaData.newSimpleResultMetaData(types);
result.statementID = statementId;
result.navigator.add(ValuePool.emptyObjectArray);
return result;
} | [
"public",
"static",
"Result",
"newPreparedExecuteRequest",
"(",
"Type",
"[",
"]",
"types",
",",
"long",
"statementId",
")",
"{",
"Result",
"result",
"=",
"newResult",
"(",
"ResultConstants",
".",
"EXECUTE",
")",
";",
"result",
".",
"metaData",
"=",
"ResultMeta... | For SQLEXECUTE
For execution of SQL prepared statements.
The parameters are set afterwards as the Result is reused | [
"For",
"SQLEXECUTE",
"For",
"execution",
"of",
"SQL",
"prepared",
"statements",
".",
"The",
"parameters",
"are",
"set",
"afterwards",
"as",
"the",
"Result",
"is",
"reused"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L616-L627 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.newCallResponse | public static Result newCallResponse(Type[] types, long statementId,
Object[] values) {
Result result = newResult(ResultConstants.CALL_RESPONSE);
result.metaData = ResultMetaData.newSimpleResultMetaData(types);
result.statementID = statementId;
result.navigator.add(values);
return result;
} | java | public static Result newCallResponse(Type[] types, long statementId,
Object[] values) {
Result result = newResult(ResultConstants.CALL_RESPONSE);
result.metaData = ResultMetaData.newSimpleResultMetaData(types);
result.statementID = statementId;
result.navigator.add(values);
return result;
} | [
"public",
"static",
"Result",
"newCallResponse",
"(",
"Type",
"[",
"]",
"types",
",",
"long",
"statementId",
",",
"Object",
"[",
"]",
"values",
")",
"{",
"Result",
"result",
"=",
"newResult",
"(",
"ResultConstants",
".",
"CALL_RESPONSE",
")",
";",
"result",
... | For CALL_RESPONSE
For execution of SQL callable statements. | [
"For",
"CALL_RESPONSE",
"For",
"execution",
"of",
"SQL",
"callable",
"statements",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L633-L644 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.newUpdateResultRequest | public static Result newUpdateResultRequest(Type[] types, long id) {
Result result = newResult(ResultConstants.UPDATE_RESULT);
result.metaData = ResultMetaData.newUpdateResultMetaData(types);
result.id = id;
result.navigator.add(new Object[]{});
return result;
} | java | public static Result newUpdateResultRequest(Type[] types, long id) {
Result result = newResult(ResultConstants.UPDATE_RESULT);
result.metaData = ResultMetaData.newUpdateResultMetaData(types);
result.id = id;
result.navigator.add(new Object[]{});
return result;
} | [
"public",
"static",
"Result",
"newUpdateResultRequest",
"(",
"Type",
"[",
"]",
"types",
",",
"long",
"id",
")",
"{",
"Result",
"result",
"=",
"newResult",
"(",
"ResultConstants",
".",
"UPDATE_RESULT",
")",
";",
"result",
".",
"metaData",
"=",
"ResultMetaData",... | For UPDATE_RESULT
The parameters are set afterwards as the Result is reused | [
"For",
"UPDATE_RESULT",
"The",
"parameters",
"are",
"set",
"afterwards",
"as",
"the",
"Result",
"is",
"reused"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L650-L660 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.setPreparedResultUpdateProperties | public void setPreparedResultUpdateProperties(Object[] parameterValues) {
if (navigator.getSize() == 1) {
((RowSetNavigatorClient) navigator).setData(0, parameterValues);
} else {
navigator.clear();
navigator.add(parameterValues);
}
} | java | public void setPreparedResultUpdateProperties(Object[] parameterValues) {
if (navigator.getSize() == 1) {
((RowSetNavigatorClient) navigator).setData(0, parameterValues);
} else {
navigator.clear();
navigator.add(parameterValues);
}
} | [
"public",
"void",
"setPreparedResultUpdateProperties",
"(",
"Object",
"[",
"]",
"parameterValues",
")",
"{",
"if",
"(",
"navigator",
".",
"getSize",
"(",
")",
"==",
"1",
")",
"{",
"(",
"(",
"RowSetNavigatorClient",
")",
"navigator",
")",
".",
"setData",
"(",... | For UPDATE_RESULT results
The parameters are set by this method as the Result is reused | [
"For",
"UPDATE_RESULT",
"results",
"The",
"parameters",
"are",
"set",
"by",
"this",
"method",
"as",
"the",
"Result",
"is",
"reused"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L666-L674 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.setPreparedExecuteProperties | public void setPreparedExecuteProperties(Object[] parameterValues,
int maxRows, int fetchSize) {
mode = ResultConstants.EXECUTE;
if (navigator.getSize() == 1) {
((RowSetNavigatorClient) navigator).setData(0, parameterValues);
} else {
navigator.clear();
navigator.add(parameterValues);
}
updateCount = maxRows;
this.fetchSize = fetchSize;
} | java | public void setPreparedExecuteProperties(Object[] parameterValues,
int maxRows, int fetchSize) {
mode = ResultConstants.EXECUTE;
if (navigator.getSize() == 1) {
((RowSetNavigatorClient) navigator).setData(0, parameterValues);
} else {
navigator.clear();
navigator.add(parameterValues);
}
updateCount = maxRows;
this.fetchSize = fetchSize;
} | [
"public",
"void",
"setPreparedExecuteProperties",
"(",
"Object",
"[",
"]",
"parameterValues",
",",
"int",
"maxRows",
",",
"int",
"fetchSize",
")",
"{",
"mode",
"=",
"ResultConstants",
".",
"EXECUTE",
";",
"if",
"(",
"navigator",
".",
"getSize",
"(",
")",
"==... | For SQLEXECUTE results
The parameters are set by this method as the Result is reused | [
"For",
"SQLEXECUTE",
"results",
"The",
"parameters",
"are",
"set",
"by",
"this",
"method",
"as",
"the",
"Result",
"is",
"reused"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L680-L694 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.newBatchedExecuteResponse | public static Result newBatchedExecuteResponse(int[] updateCounts,
Result generatedResult, Result e) {
Result result = newResult(ResultConstants.BATCHEXECRESPONSE);
result.addChainedResult(generatedResult);
result.addChainedResult(e);
Type[] types = new Type[]{ Type.SQL_INTEGER };
result.metaData = ResultMetaData.newSimpleResultMetaData(types);
Object[][] table = new Object[updateCounts.length][];
for (int i = 0; i < updateCounts.length; i++) {
table[i] = new Object[]{ ValuePool.getInt(updateCounts[i]) };
}
((RowSetNavigatorClient) result.navigator).setData(table);
return result;
} | java | public static Result newBatchedExecuteResponse(int[] updateCounts,
Result generatedResult, Result e) {
Result result = newResult(ResultConstants.BATCHEXECRESPONSE);
result.addChainedResult(generatedResult);
result.addChainedResult(e);
Type[] types = new Type[]{ Type.SQL_INTEGER };
result.metaData = ResultMetaData.newSimpleResultMetaData(types);
Object[][] table = new Object[updateCounts.length][];
for (int i = 0; i < updateCounts.length; i++) {
table[i] = new Object[]{ ValuePool.getInt(updateCounts[i]) };
}
((RowSetNavigatorClient) result.navigator).setData(table);
return result;
} | [
"public",
"static",
"Result",
"newBatchedExecuteResponse",
"(",
"int",
"[",
"]",
"updateCounts",
",",
"Result",
"generatedResult",
",",
"Result",
"e",
")",
"{",
"Result",
"result",
"=",
"newResult",
"(",
"ResultConstants",
".",
"BATCHEXECRESPONSE",
")",
";",
"re... | For BATCHEXERESPONSE for a BATCHEXECUTE or BATCHEXECDIRECT | [
"For",
"BATCHEXERESPONSE",
"for",
"a",
"BATCHEXECUTE",
"or",
"BATCHEXECDIRECT"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L729-L750 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java | Result.setPrepareOrExecuteProperties | public void setPrepareOrExecuteProperties(String sql, int maxRows,
int fetchSize, int statementReturnType, int resultSetType,
int resultSetConcurrency, int resultSetHoldability, int keyMode,
int[] generatedIndexes, String[] generatedNames) {
mainString = sql;
updateCount = maxRows;
this.fetchSize = fetchSize;
this.statementReturnType = statementReturnType;
rsScrollability = resultSetType;
rsConcurrency = resultSetConcurrency;
rsHoldability = resultSetHoldability;
generateKeys = keyMode;
generatedMetaData =
ResultMetaData.newGeneratedColumnsMetaData(generatedIndexes,
generatedNames);
} | java | public void setPrepareOrExecuteProperties(String sql, int maxRows,
int fetchSize, int statementReturnType, int resultSetType,
int resultSetConcurrency, int resultSetHoldability, int keyMode,
int[] generatedIndexes, String[] generatedNames) {
mainString = sql;
updateCount = maxRows;
this.fetchSize = fetchSize;
this.statementReturnType = statementReturnType;
rsScrollability = resultSetType;
rsConcurrency = resultSetConcurrency;
rsHoldability = resultSetHoldability;
generateKeys = keyMode;
generatedMetaData =
ResultMetaData.newGeneratedColumnsMetaData(generatedIndexes,
generatedNames);
} | [
"public",
"void",
"setPrepareOrExecuteProperties",
"(",
"String",
"sql",
",",
"int",
"maxRows",
",",
"int",
"fetchSize",
",",
"int",
"statementReturnType",
",",
"int",
"resultSetType",
",",
"int",
"resultSetConcurrency",
",",
"int",
"resultSetHoldability",
",",
"int... | For both EXECDIRECT and PREPARE | [
"For",
"both",
"EXECDIRECT",
"and",
"PREPARE"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/result/Result.java#L908-L924 | train |
VoltDB/voltdb | third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java | OptionBuilder.reset | private static void reset()
{
description = null;
argName = null;
longopt = null;
type = String.class;
required = false;
numberOfArgs = Option.UNINITIALIZED;
optionalArg = false;
valuesep = (char) 0;
} | java | private static void reset()
{
description = null;
argName = null;
longopt = null;
type = String.class;
required = false;
numberOfArgs = Option.UNINITIALIZED;
optionalArg = false;
valuesep = (char) 0;
} | [
"private",
"static",
"void",
"reset",
"(",
")",
"{",
"description",
"=",
"null",
";",
"argName",
"=",
"null",
";",
"longopt",
"=",
"null",
";",
"type",
"=",
"String",
".",
"class",
";",
"required",
"=",
"false",
";",
"numberOfArgs",
"=",
"Option",
".",... | Resets the member variables to their default values. | [
"Resets",
"the",
"member",
"variables",
"to",
"their",
"default",
"values",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java#L79-L89 | train |
VoltDB/voltdb | third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java | OptionBuilder.hasOptionalArgs | public static OptionBuilder hasOptionalArgs()
{
OptionBuilder.numberOfArgs = Option.UNLIMITED_VALUES;
OptionBuilder.optionalArg = true;
return INSTANCE;
} | java | public static OptionBuilder hasOptionalArgs()
{
OptionBuilder.numberOfArgs = Option.UNLIMITED_VALUES;
OptionBuilder.optionalArg = true;
return INSTANCE;
} | [
"public",
"static",
"OptionBuilder",
"hasOptionalArgs",
"(",
")",
"{",
"OptionBuilder",
".",
"numberOfArgs",
"=",
"Option",
".",
"UNLIMITED_VALUES",
";",
"OptionBuilder",
".",
"optionalArg",
"=",
"true",
";",
"return",
"INSTANCE",
";",
"}"
] | The next Option can have an unlimited number of optional arguments.
@return the OptionBuilder instance | [
"The",
"next",
"Option",
"can",
"have",
"an",
"unlimited",
"number",
"of",
"optional",
"arguments",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java#L261-L267 | train |
VoltDB/voltdb | third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java | OptionBuilder.hasOptionalArgs | public static OptionBuilder hasOptionalArgs(int numArgs)
{
OptionBuilder.numberOfArgs = numArgs;
OptionBuilder.optionalArg = true;
return INSTANCE;
} | java | public static OptionBuilder hasOptionalArgs(int numArgs)
{
OptionBuilder.numberOfArgs = numArgs;
OptionBuilder.optionalArg = true;
return INSTANCE;
} | [
"public",
"static",
"OptionBuilder",
"hasOptionalArgs",
"(",
"int",
"numArgs",
")",
"{",
"OptionBuilder",
".",
"numberOfArgs",
"=",
"numArgs",
";",
"OptionBuilder",
".",
"optionalArg",
"=",
"true",
";",
"return",
"INSTANCE",
";",
"}"
] | The next Option can have the specified number of optional arguments.
@param numArgs - the maximum number of optional arguments
the next Option created can have.
@return the OptionBuilder instance | [
"The",
"next",
"Option",
"can",
"have",
"the",
"specified",
"number",
"of",
"optional",
"arguments",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java#L276-L282 | train |
VoltDB/voltdb | third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java | OptionBuilder.create | public static Option create() throws IllegalArgumentException
{
if (longopt == null)
{
OptionBuilder.reset();
throw new IllegalArgumentException("must specify longopt");
}
return create(null);
} | java | public static Option create() throws IllegalArgumentException
{
if (longopt == null)
{
OptionBuilder.reset();
throw new IllegalArgumentException("must specify longopt");
}
return create(null);
} | [
"public",
"static",
"Option",
"create",
"(",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"longopt",
"==",
"null",
")",
"{",
"OptionBuilder",
".",
"reset",
"(",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"must specify longopt\"",
... | Create an Option using the current settings
@return the Option instance
@throws IllegalArgumentException if <code>longOpt</code> has not been set. | [
"Create",
"an",
"Option",
"using",
"the",
"current",
"settings"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/OptionBuilder.java#L349-L358 | train |
VoltDB/voltdb | src/frontend/org/voltdb/compiler/statements/CreateProcedureAsSQL.java | CreateProcedureAsSQL.checkProcedureIdentifier | private String checkProcedureIdentifier(
final String identifier, final String statement
) throws VoltCompilerException {
String retIdent = checkIdentifierStart(identifier, statement);
if (retIdent.contains(".")) {
String msg = String.format(
"Invalid procedure name containing dots \"%s\" in DDL: \"%s\"",
identifier, statement.substring(0,statement.length()-1));
throw m_compiler.new VoltCompilerException(msg);
}
return retIdent;
} | java | private String checkProcedureIdentifier(
final String identifier, final String statement
) throws VoltCompilerException {
String retIdent = checkIdentifierStart(identifier, statement);
if (retIdent.contains(".")) {
String msg = String.format(
"Invalid procedure name containing dots \"%s\" in DDL: \"%s\"",
identifier, statement.substring(0,statement.length()-1));
throw m_compiler.new VoltCompilerException(msg);
}
return retIdent;
} | [
"private",
"String",
"checkProcedureIdentifier",
"(",
"final",
"String",
"identifier",
",",
"final",
"String",
"statement",
")",
"throws",
"VoltCompilerException",
"{",
"String",
"retIdent",
"=",
"checkIdentifierStart",
"(",
"identifier",
",",
"statement",
")",
";",
... | Check whether or not a procedure name is acceptible.
@param identifier the identifier to check
@param statement the statement where the identifier is
@return the given identifier unmodified
@throws VoltCompilerException | [
"Check",
"whether",
"or",
"not",
"a",
"procedure",
"name",
"is",
"acceptible",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/statements/CreateProcedureAsSQL.java#L81-L92 | train |
VoltDB/voltdb | src/frontend/org/voltcore/network/VoltPort.java | VoltPort.resolveHostname | void resolveHostname(boolean synchronous) {
Runnable r = new Runnable() {
@Override
public void run() {
String remoteHost = ReverseDNSCache.hostnameOrAddress(m_remoteSocketAddress.getAddress());
if (!remoteHost.equals(m_remoteSocketAddress.getAddress().getHostAddress())) {
m_remoteHostname = remoteHost;
m_remoteHostAndAddressAndPort = remoteHost + m_remoteHostAndAddressAndPort;
m_toString = VoltPort.this.toString() + ":" + m_remoteHostAndAddressAndPort;
}
}
};
if (synchronous) {
r.run();
} else {
/*
* Start the reverse DNS lookup in background because it might be
* very slow if the hostname is not specified in local /etc/hosts.
*/
try {
ReverseDNSCache.submit(r);
} catch (RejectedExecutionException e) {
networkLog.debug(
"Reverse DNS lookup for " + m_remoteSocketAddress + " rejected because the queue was full");
}
}
} | java | void resolveHostname(boolean synchronous) {
Runnable r = new Runnable() {
@Override
public void run() {
String remoteHost = ReverseDNSCache.hostnameOrAddress(m_remoteSocketAddress.getAddress());
if (!remoteHost.equals(m_remoteSocketAddress.getAddress().getHostAddress())) {
m_remoteHostname = remoteHost;
m_remoteHostAndAddressAndPort = remoteHost + m_remoteHostAndAddressAndPort;
m_toString = VoltPort.this.toString() + ":" + m_remoteHostAndAddressAndPort;
}
}
};
if (synchronous) {
r.run();
} else {
/*
* Start the reverse DNS lookup in background because it might be
* very slow if the hostname is not specified in local /etc/hosts.
*/
try {
ReverseDNSCache.submit(r);
} catch (RejectedExecutionException e) {
networkLog.debug(
"Reverse DNS lookup for " + m_remoteSocketAddress + " rejected because the queue was full");
}
}
} | [
"void",
"resolveHostname",
"(",
"boolean",
"synchronous",
")",
"{",
"Runnable",
"r",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"String",
"remoteHost",
"=",
"ReverseDNSCache",
".",
"hostnameOrAddress",
"("... | Do a reverse DNS lookup of the remote end. Done in a separate thread unless synchronous is specified.
If asynchronous lookup is requested the task may be dropped and resolution may never occur | [
"Do",
"a",
"reverse",
"DNS",
"lookup",
"of",
"the",
"remote",
"end",
".",
"Done",
"in",
"a",
"separate",
"thread",
"unless",
"synchronous",
"is",
"specified",
".",
"If",
"asynchronous",
"lookup",
"is",
"requested",
"the",
"task",
"may",
"be",
"dropped",
"a... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/network/VoltPort.java#L110-L136 | train |
VoltDB/voltdb | src/frontend/org/voltcore/network/VoltPort.java | VoltPort.setInterests | public void setInterests(int opsToAdd, int opsToRemove) {
// must be done atomically with changes to m_running
synchronized(m_lock) {
int oldInterestOps = m_interestOps;
m_interestOps = (m_interestOps | opsToAdd) & (~opsToRemove);
if (oldInterestOps != m_interestOps && !m_running) {
/*
* If this is a write, optimistically assume the write
* will succeed and try it without using the selector
*/
m_network.addToChangeList(this, (opsToAdd & SelectionKey.OP_WRITE) != 0);
}
}
} | java | public void setInterests(int opsToAdd, int opsToRemove) {
// must be done atomically with changes to m_running
synchronized(m_lock) {
int oldInterestOps = m_interestOps;
m_interestOps = (m_interestOps | opsToAdd) & (~opsToRemove);
if (oldInterestOps != m_interestOps && !m_running) {
/*
* If this is a write, optimistically assume the write
* will succeed and try it without using the selector
*/
m_network.addToChangeList(this, (opsToAdd & SelectionKey.OP_WRITE) != 0);
}
}
} | [
"public",
"void",
"setInterests",
"(",
"int",
"opsToAdd",
",",
"int",
"opsToRemove",
")",
"{",
"// must be done atomically with changes to m_running",
"synchronized",
"(",
"m_lock",
")",
"{",
"int",
"oldInterestOps",
"=",
"m_interestOps",
";",
"m_interestOps",
"=",
"(... | Change the desired interest key set | [
"Change",
"the",
"desired",
"interest",
"key",
"set"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/network/VoltPort.java#L291-L305 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocBase.java | AdHocBase.adHocSQLFromInvocationForDebug | public static String adHocSQLFromInvocationForDebug(StoredProcedureInvocation invocation) {
assert(invocation.getProcName().startsWith("@AdHoc"));
ParameterSet params = invocation.getParams();
// the final param is the byte array we need
byte[] serializedBatchData = (byte[]) params.getParam(params.size() - 1);
Pair<Object[], AdHocPlannedStatement[]> data = decodeSerializedBatchData(serializedBatchData);
Object[] userparams = data.getFirst();
AdHocPlannedStatement[] statements = data.getSecond();
StringBuilder sb = new StringBuilder();
if (statements.length == 0) {
sb.append("ADHOC INVOCATION HAS NO SQL");
}
else if (statements.length == 1) {
sb.append(adHocSQLStringFromPlannedStatement(statements[0], userparams));
}
else { // > 1
sb.append("BEGIN ADHOC_SQL_BATCH {\n");
for (AdHocPlannedStatement stmt : statements) {
sb.append(adHocSQLStringFromPlannedStatement(stmt, userparams)).append("\n");
}
sb.append("} END ADHOC_SQL_BATCH");
}
return sb.toString();
} | java | public static String adHocSQLFromInvocationForDebug(StoredProcedureInvocation invocation) {
assert(invocation.getProcName().startsWith("@AdHoc"));
ParameterSet params = invocation.getParams();
// the final param is the byte array we need
byte[] serializedBatchData = (byte[]) params.getParam(params.size() - 1);
Pair<Object[], AdHocPlannedStatement[]> data = decodeSerializedBatchData(serializedBatchData);
Object[] userparams = data.getFirst();
AdHocPlannedStatement[] statements = data.getSecond();
StringBuilder sb = new StringBuilder();
if (statements.length == 0) {
sb.append("ADHOC INVOCATION HAS NO SQL");
}
else if (statements.length == 1) {
sb.append(adHocSQLStringFromPlannedStatement(statements[0], userparams));
}
else { // > 1
sb.append("BEGIN ADHOC_SQL_BATCH {\n");
for (AdHocPlannedStatement stmt : statements) {
sb.append(adHocSQLStringFromPlannedStatement(stmt, userparams)).append("\n");
}
sb.append("} END ADHOC_SQL_BATCH");
}
return sb.toString();
} | [
"public",
"static",
"String",
"adHocSQLFromInvocationForDebug",
"(",
"StoredProcedureInvocation",
"invocation",
")",
"{",
"assert",
"(",
"invocation",
".",
"getProcName",
"(",
")",
".",
"startsWith",
"(",
"\"@AdHoc\"",
")",
")",
";",
"ParameterSet",
"params",
"=",
... | Get a string containing the SQL statements and any parameters for a given
batch passed to an ad-hoc query. Used for debugging and logging. | [
"Get",
"a",
"string",
"containing",
"the",
"SQL",
"statements",
"and",
"any",
"parameters",
"for",
"a",
"given",
"batch",
"passed",
"to",
"an",
"ad",
"-",
"hoc",
"query",
".",
"Used",
"for",
"debugging",
"and",
"logging",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocBase.java#L72-L98 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocBase.java | AdHocBase.adHocSQLStringFromPlannedStatement | public static String adHocSQLStringFromPlannedStatement(AdHocPlannedStatement statement, Object[] userparams) {
final int MAX_PARAM_LINE_CHARS = 120;
StringBuilder sb = new StringBuilder();
String sql = new String(statement.sql, Charsets.UTF_8);
sb.append(sql);
Object[] params = paramsForStatement(statement, userparams);
// convert params to strings of a certain max length
for (int i = 0; i < params.length; i++) {
Object param = params[i];
String paramLineStr = String.format(" Param %d: %s", i, param.toString());
// trim param line if it's silly long
if (paramLineStr.length() > MAX_PARAM_LINE_CHARS) {
paramLineStr = paramLineStr.substring(0, MAX_PARAM_LINE_CHARS - 3);
paramLineStr += "...";
}
sb.append('\n').append(paramLineStr);
}
return sb.toString();
} | java | public static String adHocSQLStringFromPlannedStatement(AdHocPlannedStatement statement, Object[] userparams) {
final int MAX_PARAM_LINE_CHARS = 120;
StringBuilder sb = new StringBuilder();
String sql = new String(statement.sql, Charsets.UTF_8);
sb.append(sql);
Object[] params = paramsForStatement(statement, userparams);
// convert params to strings of a certain max length
for (int i = 0; i < params.length; i++) {
Object param = params[i];
String paramLineStr = String.format(" Param %d: %s", i, param.toString());
// trim param line if it's silly long
if (paramLineStr.length() > MAX_PARAM_LINE_CHARS) {
paramLineStr = paramLineStr.substring(0, MAX_PARAM_LINE_CHARS - 3);
paramLineStr += "...";
}
sb.append('\n').append(paramLineStr);
}
return sb.toString();
} | [
"public",
"static",
"String",
"adHocSQLStringFromPlannedStatement",
"(",
"AdHocPlannedStatement",
"statement",
",",
"Object",
"[",
"]",
"userparams",
")",
"{",
"final",
"int",
"MAX_PARAM_LINE_CHARS",
"=",
"120",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",... | Get a string containing a SQL statement and any parameters for a given
AdHocPlannedStatement. Used for debugging and logging. | [
"Get",
"a",
"string",
"containing",
"a",
"SQL",
"statement",
"and",
"any",
"parameters",
"for",
"a",
"given",
"AdHocPlannedStatement",
".",
"Used",
"for",
"debugging",
"and",
"logging",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocBase.java#L104-L127 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocBase.java | AdHocBase.decodeSerializedBatchData | public static Pair<Object[], AdHocPlannedStatement[]> decodeSerializedBatchData(byte[] serializedBatchData) {
// Collections must be the same size since they all contain slices of the same data.
assert(serializedBatchData != null);
ByteBuffer buf = ByteBuffer.wrap(serializedBatchData);
AdHocPlannedStatement[] statements = null;
Object[] userparams = null;
try {
userparams = AdHocPlannedStmtBatch.userParamsFromBuffer(buf);
statements = AdHocPlannedStmtBatch.planArrayFromBuffer(buf);
}
catch (IOException e) {
throw new VoltAbortException(e);
}
return new Pair<Object[], AdHocPlannedStatement[]>(userparams, statements);
} | java | public static Pair<Object[], AdHocPlannedStatement[]> decodeSerializedBatchData(byte[] serializedBatchData) {
// Collections must be the same size since they all contain slices of the same data.
assert(serializedBatchData != null);
ByteBuffer buf = ByteBuffer.wrap(serializedBatchData);
AdHocPlannedStatement[] statements = null;
Object[] userparams = null;
try {
userparams = AdHocPlannedStmtBatch.userParamsFromBuffer(buf);
statements = AdHocPlannedStmtBatch.planArrayFromBuffer(buf);
}
catch (IOException e) {
throw new VoltAbortException(e);
}
return new Pair<Object[], AdHocPlannedStatement[]>(userparams, statements);
} | [
"public",
"static",
"Pair",
"<",
"Object",
"[",
"]",
",",
"AdHocPlannedStatement",
"[",
"]",
">",
"decodeSerializedBatchData",
"(",
"byte",
"[",
"]",
"serializedBatchData",
")",
"{",
"// Collections must be the same size since they all contain slices of the same data.",
"as... | Decode binary data into structures needed to process adhoc queries.
This code was pulled out of runAdHoc so it could be shared there and with
adHocSQLStringFromPlannedStatement. | [
"Decode",
"binary",
"data",
"into",
"structures",
"needed",
"to",
"process",
"adhoc",
"queries",
".",
"This",
"code",
"was",
"pulled",
"out",
"of",
"runAdHoc",
"so",
"it",
"could",
"be",
"shared",
"there",
"and",
"with",
"adHocSQLStringFromPlannedStatement",
"."... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocBase.java#L134-L149 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocBase.java | AdHocBase.paramsForStatement | static Object[] paramsForStatement(AdHocPlannedStatement statement, Object[] userparams) {
// When there are no user-provided parameters, statements may have parameterized constants.
if (userparams.length > 0) {
return userparams;
} else {
return statement.extractedParamArray();
}
} | java | static Object[] paramsForStatement(AdHocPlannedStatement statement, Object[] userparams) {
// When there are no user-provided parameters, statements may have parameterized constants.
if (userparams.length > 0) {
return userparams;
} else {
return statement.extractedParamArray();
}
} | [
"static",
"Object",
"[",
"]",
"paramsForStatement",
"(",
"AdHocPlannedStatement",
"statement",
",",
"Object",
"[",
"]",
"userparams",
")",
"{",
"// When there are no user-provided parameters, statements may have parameterized constants.",
"if",
"(",
"userparams",
".",
"length... | Get the params for a specific SQL statement within a batch.
Note that there is usually a batch size of one. | [
"Get",
"the",
"params",
"for",
"a",
"specific",
"SQL",
"statement",
"within",
"a",
"batch",
".",
"Note",
"that",
"there",
"is",
"usually",
"a",
"batch",
"size",
"of",
"one",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocBase.java#L155-L162 | train |
VoltDB/voltdb | src/frontend/org/voltdb/utils/InMemoryJarfile.java | InMemoryJarfile.writeToFile | public static void writeToFile(byte[] catalogBytes, File file) throws IOException {
JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file));
JarInputStream jarIn = new JarInputStream(new ByteArrayInputStream(catalogBytes));
JarEntry catEntry = null;
JarInputStreamReader reader = new JarInputStreamReader();
while ((catEntry = jarIn.getNextJarEntry()) != null) {
byte[] value = reader.readEntryFromStream(jarIn);
String key = catEntry.getName();
assert (value != null);
JarEntry entry = new JarEntry(key);
entry.setSize(value.length);
entry.setTime(System.currentTimeMillis());
jarOut.putNextEntry(entry);
jarOut.write(value);
jarOut.flush();
jarOut.closeEntry();
}
jarOut.finish();
jarIn.close();
} | java | public static void writeToFile(byte[] catalogBytes, File file) throws IOException {
JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file));
JarInputStream jarIn = new JarInputStream(new ByteArrayInputStream(catalogBytes));
JarEntry catEntry = null;
JarInputStreamReader reader = new JarInputStreamReader();
while ((catEntry = jarIn.getNextJarEntry()) != null) {
byte[] value = reader.readEntryFromStream(jarIn);
String key = catEntry.getName();
assert (value != null);
JarEntry entry = new JarEntry(key);
entry.setSize(value.length);
entry.setTime(System.currentTimeMillis());
jarOut.putNextEntry(entry);
jarOut.write(value);
jarOut.flush();
jarOut.closeEntry();
}
jarOut.finish();
jarIn.close();
} | [
"public",
"static",
"void",
"writeToFile",
"(",
"byte",
"[",
"]",
"catalogBytes",
",",
"File",
"file",
")",
"throws",
"IOException",
"{",
"JarOutputStream",
"jarOut",
"=",
"new",
"JarOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
";",
... | directly transformed and written to the specified file | [
"directly",
"transformed",
"and",
"written",
"to",
"the",
"specified",
"file"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/InMemoryJarfile.java#L163-L185 | train |
VoltDB/voltdb | src/frontend/org/voltdb/utils/InMemoryJarfile.java | InMemoryJarfile.getCRC | public long getCRC() {
PureJavaCrc32 crc = new PureJavaCrc32();
for (Entry<String, byte[]> e : super.entrySet()) {
if (e.getKey().equals("buildinfo.txt") || e.getKey().equals("catalog-report.html")) {
continue;
}
// Hacky way to skip the first line of the autogenerated ddl, which
// has a date which changes and causes test failures
if (e.getKey().equals(VoltCompiler.AUTOGEN_DDL_FILE_NAME)) {
byte[] ddlbytes = e.getValue();
int index = 0;
while (ddlbytes[index] != '\n') {
index++;
}
byte[] newddlbytes = Arrays.copyOfRange(ddlbytes, index, ddlbytes.length);
crc.update(e.getKey().getBytes(Constants.UTF8ENCODING));
crc.update(newddlbytes);
}
else {
crc.update(e.getKey().getBytes(Constants.UTF8ENCODING));
crc.update(e.getValue());
}
}
return crc.getValue();
} | java | public long getCRC() {
PureJavaCrc32 crc = new PureJavaCrc32();
for (Entry<String, byte[]> e : super.entrySet()) {
if (e.getKey().equals("buildinfo.txt") || e.getKey().equals("catalog-report.html")) {
continue;
}
// Hacky way to skip the first line of the autogenerated ddl, which
// has a date which changes and causes test failures
if (e.getKey().equals(VoltCompiler.AUTOGEN_DDL_FILE_NAME)) {
byte[] ddlbytes = e.getValue();
int index = 0;
while (ddlbytes[index] != '\n') {
index++;
}
byte[] newddlbytes = Arrays.copyOfRange(ddlbytes, index, ddlbytes.length);
crc.update(e.getKey().getBytes(Constants.UTF8ENCODING));
crc.update(newddlbytes);
}
else {
crc.update(e.getKey().getBytes(Constants.UTF8ENCODING));
crc.update(e.getValue());
}
}
return crc.getValue();
} | [
"public",
"long",
"getCRC",
"(",
")",
"{",
"PureJavaCrc32",
"crc",
"=",
"new",
"PureJavaCrc32",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"e",
":",
"super",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"e",... | just replacing one method call with another, though. | [
"just",
"replacing",
"one",
"method",
"call",
"with",
"another",
"though",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/InMemoryJarfile.java#L241-L268 | train |
VoltDB/voltdb | src/frontend/org/voltdb/utils/InMemoryJarfile.java | InMemoryJarfile.removeClassFromJar | public void removeClassFromJar(String classname)
{
for (String innerclass : getLoader().getInnerClassesForClass(classname)) {
remove(classToFileName(innerclass));
}
remove(classToFileName(classname));
} | java | public void removeClassFromJar(String classname)
{
for (String innerclass : getLoader().getInnerClassesForClass(classname)) {
remove(classToFileName(innerclass));
}
remove(classToFileName(classname));
} | [
"public",
"void",
"removeClassFromJar",
"(",
"String",
"classname",
")",
"{",
"for",
"(",
"String",
"innerclass",
":",
"getLoader",
"(",
")",
".",
"getInnerClassesForClass",
"(",
"classname",
")",
")",
"{",
"remove",
"(",
"classToFileName",
"(",
"innerclass",
... | Remove the provided classname and all inner classes from the jarfile and the classloader | [
"Remove",
"the",
"provided",
"classname",
"and",
"all",
"inner",
"classes",
"from",
"the",
"jarfile",
"and",
"the",
"classloader"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/InMemoryJarfile.java#L334-L340 | train |
VoltDB/voltdb | src/frontend/org/voltdb/parser/JDBCParser.java | JDBCParser.parseJDBCCall | public static ParsedCall parseJDBCCall(String jdbcCall) throws SQLParser.Exception
{
Matcher m = PAT_CALL_WITH_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
String sql = m.group(1);
int parameterCount = PAT_CLEAN_CALL_PARAMETERS.matcher(m.group(2)).replaceAll("").length();
return new ParsedCall(sql, parameterCount);
}
m = PAT_CALL_WITHOUT_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
return new ParsedCall(m.group(1), 0);
}
return null;
} | java | public static ParsedCall parseJDBCCall(String jdbcCall) throws SQLParser.Exception
{
Matcher m = PAT_CALL_WITH_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
String sql = m.group(1);
int parameterCount = PAT_CLEAN_CALL_PARAMETERS.matcher(m.group(2)).replaceAll("").length();
return new ParsedCall(sql, parameterCount);
}
m = PAT_CALL_WITHOUT_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
return new ParsedCall(m.group(1), 0);
}
return null;
} | [
"public",
"static",
"ParsedCall",
"parseJDBCCall",
"(",
"String",
"jdbcCall",
")",
"throws",
"SQLParser",
".",
"Exception",
"{",
"Matcher",
"m",
"=",
"PAT_CALL_WITH_PARAMETERS",
".",
"matcher",
"(",
"jdbcCall",
")",
";",
"if",
"(",
"m",
".",
"matches",
"(",
... | Parse call statements for JDBC.
@param jdbcCall statement to parse
@return object with parsed data or null if it didn't parse
@throws SQLParser.Exception | [
"Parse",
"call",
"statements",
"for",
"JDBC",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/JDBCParser.java#L67-L80 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/SetFunction.java | SetFunction.getType | static Type getType(int setType, Type type) {
if (setType == OpTypes.COUNT) {
return Type.SQL_BIGINT;
}
// A VoltDB extension to handle aggfnc(*) syntax errors.
// If the argument node does not have
// a data type, it may be '*'. If the
// operation is COUNT (optype == 71) this is
// just fine. But if it's anything else this
// is a syntax error.
if (type == null) {
throw Error.error(ErrorCode.U_S0500);
}
// End of VoltDB extension
int dataType = type.isIntervalType() ? Types.SQL_INTERVAL
: type.typeCode;
switch (setType) {
case OpTypes.AVG : {
switch (dataType) {
case Types.TINYINT :
case Types.SQL_SMALLINT :
case Types.SQL_INTEGER :
case Types.SQL_BIGINT :
case Types.SQL_REAL :
case Types.SQL_FLOAT :
case Types.SQL_DOUBLE :
case Types.SQL_NUMERIC :
case Types.SQL_DECIMAL :
case Types.SQL_INTERVAL :
return type;
default :
throw Error.error(ErrorCode.X_42565);
}
}
case OpTypes.SUM : {
switch (dataType) {
case Types.TINYINT :
case Types.SQL_SMALLINT :
case Types.SQL_INTEGER :
return Type.SQL_BIGINT;
case Types.SQL_BIGINT :
return Type.SQL_DECIMAL_BIGINT_SQR;
case Types.SQL_REAL :
case Types.SQL_FLOAT :
case Types.SQL_DOUBLE :
return Type.SQL_DOUBLE;
case Types.SQL_NUMERIC :
case Types.SQL_DECIMAL :
return Type.getType(type.typeCode, 0,
type.precision * 2, type.scale);
case Types.SQL_INTERVAL :
return IntervalType.newIntervalType(
type.typeCode, DTIType.maxIntervalPrecision,
type.scale);
default :
throw Error.error(ErrorCode.X_42565);
}
}
case OpTypes.MIN :
case OpTypes.MAX :
return type;
case OpTypes.EVERY :
case OpTypes.SOME :
if (type.isBooleanType()) {
return Type.SQL_BOOLEAN;
}
break;
case OpTypes.STDDEV_POP :
case OpTypes.STDDEV_SAMP :
case OpTypes.VAR_POP :
case OpTypes.VAR_SAMP :
if (type.isNumberType()) {
return Type.SQL_DOUBLE;
}
break;
// A VoltDB extension for APPROX_COUNT_DISTINCT
case OpTypes.APPROX_COUNT_DISTINCT :
switch (dataType) {
case Types.TINYINT :
case Types.SQL_SMALLINT :
case Types.SQL_INTEGER :
case Types.SQL_BIGINT :
case Types.SQL_DECIMAL :
case Types.SQL_TIMESTAMP :
return Type.SQL_BIGINT;
default:
// We only support fixed-width types for this
// aggregate function.
//
// FLOAT is not supported since this function
// relies on different values having different bit
// patterns, and the same values being the
// same. Floating point numbers don't hold to
// this---e.g., positive and negative zero.
//
// Incompatible data types in operation
throw Error.error(ErrorCode.X_42565);
}
// End of VoltDB extension for APPROX_COUNT_DISTINCT
default :
throw Error.runtimeError(ErrorCode.U_S0500, "SetFunction");
}
throw Error.error(ErrorCode.X_42565);
} | java | static Type getType(int setType, Type type) {
if (setType == OpTypes.COUNT) {
return Type.SQL_BIGINT;
}
// A VoltDB extension to handle aggfnc(*) syntax errors.
// If the argument node does not have
// a data type, it may be '*'. If the
// operation is COUNT (optype == 71) this is
// just fine. But if it's anything else this
// is a syntax error.
if (type == null) {
throw Error.error(ErrorCode.U_S0500);
}
// End of VoltDB extension
int dataType = type.isIntervalType() ? Types.SQL_INTERVAL
: type.typeCode;
switch (setType) {
case OpTypes.AVG : {
switch (dataType) {
case Types.TINYINT :
case Types.SQL_SMALLINT :
case Types.SQL_INTEGER :
case Types.SQL_BIGINT :
case Types.SQL_REAL :
case Types.SQL_FLOAT :
case Types.SQL_DOUBLE :
case Types.SQL_NUMERIC :
case Types.SQL_DECIMAL :
case Types.SQL_INTERVAL :
return type;
default :
throw Error.error(ErrorCode.X_42565);
}
}
case OpTypes.SUM : {
switch (dataType) {
case Types.TINYINT :
case Types.SQL_SMALLINT :
case Types.SQL_INTEGER :
return Type.SQL_BIGINT;
case Types.SQL_BIGINT :
return Type.SQL_DECIMAL_BIGINT_SQR;
case Types.SQL_REAL :
case Types.SQL_FLOAT :
case Types.SQL_DOUBLE :
return Type.SQL_DOUBLE;
case Types.SQL_NUMERIC :
case Types.SQL_DECIMAL :
return Type.getType(type.typeCode, 0,
type.precision * 2, type.scale);
case Types.SQL_INTERVAL :
return IntervalType.newIntervalType(
type.typeCode, DTIType.maxIntervalPrecision,
type.scale);
default :
throw Error.error(ErrorCode.X_42565);
}
}
case OpTypes.MIN :
case OpTypes.MAX :
return type;
case OpTypes.EVERY :
case OpTypes.SOME :
if (type.isBooleanType()) {
return Type.SQL_BOOLEAN;
}
break;
case OpTypes.STDDEV_POP :
case OpTypes.STDDEV_SAMP :
case OpTypes.VAR_POP :
case OpTypes.VAR_SAMP :
if (type.isNumberType()) {
return Type.SQL_DOUBLE;
}
break;
// A VoltDB extension for APPROX_COUNT_DISTINCT
case OpTypes.APPROX_COUNT_DISTINCT :
switch (dataType) {
case Types.TINYINT :
case Types.SQL_SMALLINT :
case Types.SQL_INTEGER :
case Types.SQL_BIGINT :
case Types.SQL_DECIMAL :
case Types.SQL_TIMESTAMP :
return Type.SQL_BIGINT;
default:
// We only support fixed-width types for this
// aggregate function.
//
// FLOAT is not supported since this function
// relies on different values having different bit
// patterns, and the same values being the
// same. Floating point numbers don't hold to
// this---e.g., positive and negative zero.
//
// Incompatible data types in operation
throw Error.error(ErrorCode.X_42565);
}
// End of VoltDB extension for APPROX_COUNT_DISTINCT
default :
throw Error.runtimeError(ErrorCode.U_S0500, "SetFunction");
}
throw Error.error(ErrorCode.X_42565);
} | [
"static",
"Type",
"getType",
"(",
"int",
"setType",
",",
"Type",
"type",
")",
"{",
"if",
"(",
"setType",
"==",
"OpTypes",
".",
"COUNT",
")",
"{",
"return",
"Type",
".",
"SQL_BIGINT",
";",
"}",
"// A VoltDB extension to handle aggfnc(*) syntax errors.",
"// If th... | During parsing and before an instance of SetFunction is created,
getType is called with type parameter set to correct type when main
SELECT statements contain aggregates. | [
"During",
"parsing",
"and",
"before",
"an",
"instance",
"of",
"SetFunction",
"is",
"created",
"getType",
"is",
"called",
"with",
"type",
"parameter",
"set",
"to",
"correct",
"type",
"when",
"main",
"SELECT",
"statements",
"contain",
"aggregates",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/SetFunction.java#L379-L498 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/server/persistence/Util.java | Util.makeFileLoggerURL | public static URI makeFileLoggerURL(File dataDir, File dataLogDir){
return URI.create(makeURIString(dataDir.getPath(),dataLogDir.getPath(),null));
} | java | public static URI makeFileLoggerURL(File dataDir, File dataLogDir){
return URI.create(makeURIString(dataDir.getPath(),dataLogDir.getPath(),null));
} | [
"public",
"static",
"URI",
"makeFileLoggerURL",
"(",
"File",
"dataDir",
",",
"File",
"dataLogDir",
")",
"{",
"return",
"URI",
".",
"create",
"(",
"makeURIString",
"(",
"dataDir",
".",
"getPath",
"(",
")",
",",
"dataLogDir",
".",
"getPath",
"(",
")",
",",
... | Given two directory files the method returns a well-formed
logfile provider URI. This method is for backward compatibility with the
existing code that only supports logfile persistence and expects these two
parameters passed either on the command-line or in the configuration file.
@param dataDir snapshot directory
@param dataLogDir transaction log directory
@return logfile provider URI | [
"Given",
"two",
"directory",
"files",
"the",
"method",
"returns",
"a",
"well",
"-",
"formed",
"logfile",
"provider",
"URI",
".",
"This",
"method",
"is",
"for",
"backward",
"compatibility",
"with",
"the",
"existing",
"code",
"that",
"only",
"supports",
"logfile... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/persistence/Util.java#L73-L75 | train |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/server/persistence/Util.java | Util.isValidSnapshot | public static boolean isValidSnapshot(File f) throws IOException {
if (f==null || Util.getZxidFromName(f.getName(), "snapshot") == -1)
return false;
// Check for a valid snapshot
RandomAccessFile raf = new RandomAccessFile(f, "r");
// including the header and the last / bytes
// the snapshot should be atleast 10 bytes
if (raf.length() < 10) {
return false;
}
try {
raf.seek(raf.length() - 5);
byte bytes[] = new byte[5];
int readlen = 0;
int l;
while(readlen < 5 &&
(l = raf.read(bytes, readlen, bytes.length - readlen)) >= 0) {
readlen += l;
}
if (readlen != bytes.length) {
LOG.info("Invalid snapshot " + f
+ " too short, len = " + readlen);
return false;
}
ByteBuffer bb = ByteBuffer.wrap(bytes);
int len = bb.getInt();
byte b = bb.get();
if (len != 1 || b != '/') {
LOG.info("Invalid snapshot " + f + " len = " + len
+ " byte = " + (b & 0xff));
return false;
}
} finally {
raf.close();
}
return true;
} | java | public static boolean isValidSnapshot(File f) throws IOException {
if (f==null || Util.getZxidFromName(f.getName(), "snapshot") == -1)
return false;
// Check for a valid snapshot
RandomAccessFile raf = new RandomAccessFile(f, "r");
// including the header and the last / bytes
// the snapshot should be atleast 10 bytes
if (raf.length() < 10) {
return false;
}
try {
raf.seek(raf.length() - 5);
byte bytes[] = new byte[5];
int readlen = 0;
int l;
while(readlen < 5 &&
(l = raf.read(bytes, readlen, bytes.length - readlen)) >= 0) {
readlen += l;
}
if (readlen != bytes.length) {
LOG.info("Invalid snapshot " + f
+ " too short, len = " + readlen);
return false;
}
ByteBuffer bb = ByteBuffer.wrap(bytes);
int len = bb.getInt();
byte b = bb.get();
if (len != 1 || b != '/') {
LOG.info("Invalid snapshot " + f + " len = " + len
+ " byte = " + (b & 0xff));
return false;
}
} finally {
raf.close();
}
return true;
} | [
"public",
"static",
"boolean",
"isValidSnapshot",
"(",
"File",
"f",
")",
"throws",
"IOException",
"{",
"if",
"(",
"f",
"==",
"null",
"||",
"Util",
".",
"getZxidFromName",
"(",
"f",
".",
"getName",
"(",
")",
",",
"\"snapshot\"",
")",
"==",
"-",
"1",
")"... | Verifies that the file is a valid snapshot. Snapshot may be invalid if
it's incomplete as in a situation when the server dies while in the process
of storing a snapshot. Any file that is not a snapshot is also
an invalid snapshot.
@param f file to verify
@return true if the snapshot is valid
@throws IOException | [
"Verifies",
"that",
"the",
"file",
"is",
"a",
"valid",
"snapshot",
".",
"Snapshot",
"may",
"be",
"invalid",
"if",
"it",
"s",
"incomplete",
"as",
"in",
"a",
"situation",
"when",
"the",
"server",
"dies",
"while",
"in",
"the",
"process",
"of",
"storing",
"a... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/persistence/Util.java#L161-L199 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.