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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
andkulikov/Transitions-Everywhere | library(1.x)/src/main/java/com/transitionseverywhere/Transition.java | Transition.cancel | protected void cancel() {
int numAnimators = mCurrentAnimators.size();
for (int i = numAnimators - 1; i >= 0; i--) {
Animator animator = mCurrentAnimators.get(i);
animator.cancel();
}
if (mListeners != null && mListeners.size() > 0) {
ArrayList<TransitionListener> tmpListeners =
(ArrayList<TransitionListener>) mListeners.clone();
int numListeners = tmpListeners.size();
for (int i = 0; i < numListeners; ++i) {
tmpListeners.get(i).onTransitionCancel(this);
}
}
} | java | protected void cancel() {
int numAnimators = mCurrentAnimators.size();
for (int i = numAnimators - 1; i >= 0; i--) {
Animator animator = mCurrentAnimators.get(i);
animator.cancel();
}
if (mListeners != null && mListeners.size() > 0) {
ArrayList<TransitionListener> tmpListeners =
(ArrayList<TransitionListener>) mListeners.clone();
int numListeners = tmpListeners.size();
for (int i = 0; i < numListeners; ++i) {
tmpListeners.get(i).onTransitionCancel(this);
}
}
} | [
"protected",
"void",
"cancel",
"(",
")",
"{",
"int",
"numAnimators",
"=",
"mCurrentAnimators",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"numAnimators",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"Animator",
"animator",
... | This method cancels a transition that is currently running.
@hide | [
"This",
"method",
"cancels",
"a",
"transition",
"that",
"is",
"currently",
"running",
"."
] | 828efe5f152a2f05e2bfeee6254b74ad2269d4f1 | https://github.com/andkulikov/Transitions-Everywhere/blob/828efe5f152a2f05e2bfeee6254b74ad2269d4f1/library(1.x)/src/main/java/com/transitionseverywhere/Transition.java#L1990-L2004 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/dto/BatchPoints.java | BatchPoints.point | public BatchPoints point(final Point point) {
point.getTags().putAll(this.tags);
this.points.add(point);
return this;
} | java | public BatchPoints point(final Point point) {
point.getTags().putAll(this.tags);
this.points.add(point);
return this;
} | [
"public",
"BatchPoints",
"point",
"(",
"final",
"Point",
"point",
")",
"{",
"point",
".",
"getTags",
"(",
")",
".",
"putAll",
"(",
"this",
".",
"tags",
")",
";",
"this",
".",
"points",
".",
"add",
"(",
"point",
")",
";",
"return",
"this",
";",
"}"
... | Add a single Point to these batches.
@param point the Point to add
@return this Instance to be able to daisy chain calls. | [
"Add",
"a",
"single",
"Point",
"to",
"these",
"batches",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/dto/BatchPoints.java#L242-L246 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/dto/BatchPoints.java | BatchPoints.lineProtocol | public String lineProtocol() {
StringBuilder sb = new StringBuilder();
for (Point point : this.points) {
sb.append(point.lineProtocol(this.precision)).append("\n");
}
return sb.toString();
} | java | public String lineProtocol() {
StringBuilder sb = new StringBuilder();
for (Point point : this.points) {
sb.append(point.lineProtocol(this.precision)).append("\n");
}
return sb.toString();
} | [
"public",
"String",
"lineProtocol",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Point",
"point",
":",
"this",
".",
"points",
")",
"{",
"sb",
".",
"append",
"(",
"point",
".",
"lineProtocol",
"(",
"this... | calculate the lineprotocol for all Points.
@return the String with newLines. | [
"calculate",
"the",
"lineprotocol",
"for",
"all",
"Points",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/dto/BatchPoints.java#L328-L335 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/dto/BatchPoints.java | BatchPoints.isMergeAbleWith | public boolean isMergeAbleWith(final BatchPoints that) {
return Objects.equals(database, that.database)
&& Objects.equals(retentionPolicy, that.retentionPolicy)
&& Objects.equals(tags, that.tags)
&& consistency == that.consistency;
} | java | public boolean isMergeAbleWith(final BatchPoints that) {
return Objects.equals(database, that.database)
&& Objects.equals(retentionPolicy, that.retentionPolicy)
&& Objects.equals(tags, that.tags)
&& consistency == that.consistency;
} | [
"public",
"boolean",
"isMergeAbleWith",
"(",
"final",
"BatchPoints",
"that",
")",
"{",
"return",
"Objects",
".",
"equals",
"(",
"database",
",",
"that",
".",
"database",
")",
"&&",
"Objects",
".",
"equals",
"(",
"retentionPolicy",
",",
"that",
".",
"retentio... | Test whether is possible to merge two BatchPoints objects.
@param that batch point to merge in
@return true if the batch points can be sent in a single HTTP request write | [
"Test",
"whether",
"is",
"possible",
"to",
"merge",
"two",
"BatchPoints",
"objects",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/dto/BatchPoints.java#L343-L348 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/dto/BatchPoints.java | BatchPoints.mergeIn | public boolean mergeIn(final BatchPoints that) {
boolean mergeAble = isMergeAbleWith(that);
if (mergeAble) {
this.points.addAll(that.points);
}
return mergeAble;
} | java | public boolean mergeIn(final BatchPoints that) {
boolean mergeAble = isMergeAbleWith(that);
if (mergeAble) {
this.points.addAll(that.points);
}
return mergeAble;
} | [
"public",
"boolean",
"mergeIn",
"(",
"final",
"BatchPoints",
"that",
")",
"{",
"boolean",
"mergeAble",
"=",
"isMergeAbleWith",
"(",
"that",
")",
";",
"if",
"(",
"mergeAble",
")",
"{",
"this",
".",
"points",
".",
"addAll",
"(",
"that",
".",
"points",
")",... | Merge two BatchPoints objects.
@param that batch point to merge in
@return true if the batch points have been merged into this BatchPoints instance. Return false otherwise. | [
"Merge",
"two",
"BatchPoints",
"objects",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/dto/BatchPoints.java#L356-L362 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/msgpack/MessagePackTraverser.java | MessagePackTraverser.traverse | public Iterable<QueryResult> traverse(final InputStream is) {
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(is);
return () -> {
return new Iterator<QueryResult>() {
@Override
public boolean hasNext() {
try {
return unpacker.hasNext();
} catch (IOException e) {
throw new InfluxDBException(e);
}
}
@Override
public QueryResult next() {
return parse(unpacker);
}
};
};
} | java | public Iterable<QueryResult> traverse(final InputStream is) {
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(is);
return () -> {
return new Iterator<QueryResult>() {
@Override
public boolean hasNext() {
try {
return unpacker.hasNext();
} catch (IOException e) {
throw new InfluxDBException(e);
}
}
@Override
public QueryResult next() {
return parse(unpacker);
}
};
};
} | [
"public",
"Iterable",
"<",
"QueryResult",
">",
"traverse",
"(",
"final",
"InputStream",
"is",
")",
"{",
"MessageUnpacker",
"unpacker",
"=",
"MessagePack",
".",
"newDefaultUnpacker",
"(",
"is",
")",
";",
"return",
"(",
")",
"->",
"{",
"return",
"new",
"Iterat... | Traverse over the whole message pack stream.
This method can be used for converting query results in chunk.
@param is
The MessagePack format input stream
@return an Iterable over the QueryResult objects | [
"Traverse",
"over",
"the",
"whole",
"message",
"pack",
"stream",
".",
"This",
"method",
"can",
"be",
"used",
"for",
"converting",
"query",
"results",
"in",
"chunk",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/msgpack/MessagePackTraverser.java#L43-L64 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/msgpack/MessagePackTraverser.java | MessagePackTraverser.parse | public QueryResult parse(final InputStream is) {
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(is);
return parse(unpacker);
} | java | public QueryResult parse(final InputStream is) {
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(is);
return parse(unpacker);
} | [
"public",
"QueryResult",
"parse",
"(",
"final",
"InputStream",
"is",
")",
"{",
"MessageUnpacker",
"unpacker",
"=",
"MessagePack",
".",
"newDefaultUnpacker",
"(",
"is",
")",
";",
"return",
"parse",
"(",
"unpacker",
")",
";",
"}"
] | Parse the message pack stream.
This method can be used for converting query
result from normal query response where exactly one QueryResult returned
@param is
The MessagePack format input stream
@return QueryResult | [
"Parse",
"the",
"message",
"pack",
"stream",
".",
"This",
"method",
"can",
"be",
"used",
"for",
"converting",
"query",
"result",
"from",
"normal",
"query",
"response",
"where",
"exactly",
"one",
"QueryResult",
"returned"
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/msgpack/MessagePackTraverser.java#L76-L79 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/impl/Preconditions.java | Preconditions.checkPositiveNumber | public static void checkPositiveNumber(final Number number, final String name) throws IllegalArgumentException {
if (number == null || number.doubleValue() <= 0) {
throw new IllegalArgumentException("Expecting a positive number for " + name);
}
} | java | public static void checkPositiveNumber(final Number number, final String name) throws IllegalArgumentException {
if (number == null || number.doubleValue() <= 0) {
throw new IllegalArgumentException("Expecting a positive number for " + name);
}
} | [
"public",
"static",
"void",
"checkPositiveNumber",
"(",
"final",
"Number",
"number",
",",
"final",
"String",
"name",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"number",
"==",
"null",
"||",
"number",
".",
"doubleValue",
"(",
")",
"<=",
"0",
"... | Enforces that the number is larger than 0.
@param number the number to test
@param name variable name for reporting
@throws IllegalArgumentException if the number is less or equal to 0 | [
"Enforces",
"that",
"the",
"number",
"is",
"larger",
"than",
"0",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/impl/Preconditions.java#L33-L37 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/impl/Preconditions.java | Preconditions.checkNotNegativeNumber | public static void checkNotNegativeNumber(final Number number, final String name) throws IllegalArgumentException {
if (number == null || number.doubleValue() < 0) {
throw new IllegalArgumentException("Expecting a positive or zero number for " + name);
}
} | java | public static void checkNotNegativeNumber(final Number number, final String name) throws IllegalArgumentException {
if (number == null || number.doubleValue() < 0) {
throw new IllegalArgumentException("Expecting a positive or zero number for " + name);
}
} | [
"public",
"static",
"void",
"checkNotNegativeNumber",
"(",
"final",
"Number",
"number",
",",
"final",
"String",
"name",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"number",
"==",
"null",
"||",
"number",
".",
"doubleValue",
"(",
")",
"<",
"0",
... | Enforces that the number is not negative.
@param number the number to test
@param name variable name for reporting
@throws IllegalArgumentException if the number is less or equal to 0 | [
"Enforces",
"that",
"the",
"number",
"is",
"not",
"negative",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/impl/Preconditions.java#L45-L49 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/impl/Preconditions.java | Preconditions.checkDuration | public static void checkDuration(final String duration, final String name) throws IllegalArgumentException {
if (!duration.matches("(\\d+[wdmhs])+|inf")) {
throw new IllegalArgumentException("Invalid InfluxDB duration: " + duration
+ " for " + name);
}
} | java | public static void checkDuration(final String duration, final String name) throws IllegalArgumentException {
if (!duration.matches("(\\d+[wdmhs])+|inf")) {
throw new IllegalArgumentException("Invalid InfluxDB duration: " + duration
+ " for " + name);
}
} | [
"public",
"static",
"void",
"checkDuration",
"(",
"final",
"String",
"duration",
",",
"final",
"String",
"name",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"!",
"duration",
".",
"matches",
"(",
"\"(\\\\d+[wdmhs])+|inf\"",
")",
")",
"{",
"throw",
... | Enforces that the duration is a valid influxDB duration.
@param duration the duration to test
@param name variable name for reporting
@throws IllegalArgumentException if the given duration is not valid. | [
"Enforces",
"that",
"the",
"duration",
"is",
"a",
"valid",
"influxDB",
"duration",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/impl/Preconditions.java#L56-L61 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/BatchOptions.java | BatchOptions.jitterDuration | public BatchOptions jitterDuration(final int jitterDuration) {
BatchOptions clone = getClone();
clone.jitterDuration = jitterDuration;
return clone;
} | java | public BatchOptions jitterDuration(final int jitterDuration) {
BatchOptions clone = getClone();
clone.jitterDuration = jitterDuration;
return clone;
} | [
"public",
"BatchOptions",
"jitterDuration",
"(",
"final",
"int",
"jitterDuration",
")",
"{",
"BatchOptions",
"clone",
"=",
"getClone",
"(",
")",
";",
"clone",
".",
"jitterDuration",
"=",
"jitterDuration",
";",
"return",
"clone",
";",
"}"
] | Jitters the batch flush interval by a random amount. This is primarily to avoid
large write spikes for users running a large number of client instances.
ie, a jitter of 5s and flush duration 10s means flushes will happen every 10-15s.
@param jitterDuration (milliseconds)
@return the BatchOptions instance to be able to use it in a fluent manner. | [
"Jitters",
"the",
"batch",
"flush",
"interval",
"by",
"a",
"random",
"amount",
".",
"This",
"is",
"primarily",
"to",
"avoid",
"large",
"write",
"spikes",
"for",
"users",
"running",
"a",
"large",
"number",
"of",
"client",
"instances",
".",
"ie",
"a",
"jitte... | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/BatchOptions.java#L72-L76 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/BatchOptions.java | BatchOptions.bufferLimit | public BatchOptions bufferLimit(final int bufferLimit) {
BatchOptions clone = getClone();
clone.bufferLimit = bufferLimit;
return clone;
} | java | public BatchOptions bufferLimit(final int bufferLimit) {
BatchOptions clone = getClone();
clone.bufferLimit = bufferLimit;
return clone;
} | [
"public",
"BatchOptions",
"bufferLimit",
"(",
"final",
"int",
"bufferLimit",
")",
"{",
"BatchOptions",
"clone",
"=",
"getClone",
"(",
")",
";",
"clone",
".",
"bufferLimit",
"=",
"bufferLimit",
";",
"return",
"clone",
";",
"}"
] | The client maintains a buffer for failed writes so that the writes will be retried later on. This may
help to overcome temporary network problems or InfluxDB load spikes.
When the buffer is full and new points are written, oldest entries in the buffer are lost.
To disable this feature set buffer limit to a value smaller than {@link BatchOptions#getActions}
@param bufferLimit maximum number of points stored in the retry buffer
@return the BatchOptions instance to be able to use it in a fluent manner. | [
"The",
"client",
"maintains",
"a",
"buffer",
"for",
"failed",
"writes",
"so",
"that",
"the",
"writes",
"will",
"be",
"retried",
"later",
"on",
".",
"This",
"may",
"help",
"to",
"overcome",
"temporary",
"network",
"problems",
"or",
"InfluxDB",
"load",
"spikes... | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/BatchOptions.java#L88-L92 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/impl/InfluxDBImpl.java | InfluxDBImpl.callQuery | private Call<QueryResult> callQuery(final Query query) {
Call<QueryResult> call;
String db = query.getDatabase();
if (db == null) {
db = this.database;
}
if (query instanceof BoundParameterQuery) {
BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query;
call = this.influxDBService.postQuery(db, query.getCommandWithUrlEncoded(),
boundParameterQuery.getParameterJsonWithUrlEncoded());
} else {
if (query.requiresPost()) {
call = this.influxDBService.postQuery(db, query.getCommandWithUrlEncoded());
} else {
call = this.influxDBService.query(db, query.getCommandWithUrlEncoded());
}
}
return call;
} | java | private Call<QueryResult> callQuery(final Query query) {
Call<QueryResult> call;
String db = query.getDatabase();
if (db == null) {
db = this.database;
}
if (query instanceof BoundParameterQuery) {
BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query;
call = this.influxDBService.postQuery(db, query.getCommandWithUrlEncoded(),
boundParameterQuery.getParameterJsonWithUrlEncoded());
} else {
if (query.requiresPost()) {
call = this.influxDBService.postQuery(db, query.getCommandWithUrlEncoded());
} else {
call = this.influxDBService.query(db, query.getCommandWithUrlEncoded());
}
}
return call;
} | [
"private",
"Call",
"<",
"QueryResult",
">",
"callQuery",
"(",
"final",
"Query",
"query",
")",
"{",
"Call",
"<",
"QueryResult",
">",
"call",
";",
"String",
"db",
"=",
"query",
".",
"getDatabase",
"(",
")",
";",
"if",
"(",
"db",
"==",
"null",
")",
"{",... | Calls the influxDBService for the query. | [
"Calls",
"the",
"influxDBService",
"for",
"the",
"query",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/impl/InfluxDBImpl.java#L747-L765 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/InfluxDBException.java | InfluxDBException.buildExceptionForErrorState | public static InfluxDBException buildExceptionForErrorState(final InputStream messagePackErrorBody) {
try {
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(messagePackErrorBody);
ImmutableMapValue mapVal = (ImmutableMapValue) unpacker.unpackValue();
return InfluxDBException.buildExceptionFromErrorMessage(
mapVal.map().get(new ImmutableStringValueImpl("error")).toString());
} catch (Exception e) {
return new InfluxDBException(e);
}
} | java | public static InfluxDBException buildExceptionForErrorState(final InputStream messagePackErrorBody) {
try {
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(messagePackErrorBody);
ImmutableMapValue mapVal = (ImmutableMapValue) unpacker.unpackValue();
return InfluxDBException.buildExceptionFromErrorMessage(
mapVal.map().get(new ImmutableStringValueImpl("error")).toString());
} catch (Exception e) {
return new InfluxDBException(e);
}
} | [
"public",
"static",
"InfluxDBException",
"buildExceptionForErrorState",
"(",
"final",
"InputStream",
"messagePackErrorBody",
")",
"{",
"try",
"{",
"MessageUnpacker",
"unpacker",
"=",
"MessagePack",
".",
"newDefaultUnpacker",
"(",
"messagePackErrorBody",
")",
";",
"Immutab... | Create corresponding InfluxDBException from the message pack error body.
@param messagePackErrorBody
the error body if any
@return the Exception | [
"Create",
"corresponding",
"InfluxDBException",
"from",
"the",
"message",
"pack",
"error",
"body",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/InfluxDBException.java#L185-L194 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/impl/BatchProcessor.java | BatchProcessor.put | void put(final AbstractBatchEntry batchEntry) {
try {
this.queue.put(batchEntry);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (this.queue.size() >= this.actions) {
this.scheduler.submit(new Runnable() {
@Override
public void run() {
write();
}
});
}
} | java | void put(final AbstractBatchEntry batchEntry) {
try {
this.queue.put(batchEntry);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (this.queue.size() >= this.actions) {
this.scheduler.submit(new Runnable() {
@Override
public void run() {
write();
}
});
}
} | [
"void",
"put",
"(",
"final",
"AbstractBatchEntry",
"batchEntry",
")",
"{",
"try",
"{",
"this",
".",
"queue",
".",
"put",
"(",
"batchEntry",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
... | Put a single BatchEntry to the cache for later processing.
@param batchEntry
the batchEntry to write to the cache. | [
"Put",
"a",
"single",
"BatchEntry",
"to",
"the",
"cache",
"for",
"later",
"processing",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/impl/BatchProcessor.java#L360-L374 | train |
influxdata/influxdb-java | src/main/java/org/influxdb/dto/Point.java | Point.measurementByPOJO | public static Builder measurementByPOJO(final Class<?> clazz) {
Objects.requireNonNull(clazz, "clazz");
throwExceptionIfMissingAnnotation(clazz, Measurement.class);
String measurementName = findMeasurementName(clazz);
return new Builder(measurementName);
} | java | public static Builder measurementByPOJO(final Class<?> clazz) {
Objects.requireNonNull(clazz, "clazz");
throwExceptionIfMissingAnnotation(clazz, Measurement.class);
String measurementName = findMeasurementName(clazz);
return new Builder(measurementName);
} | [
"public",
"static",
"Builder",
"measurementByPOJO",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"clazz",
",",
"\"clazz\"",
")",
";",
"throwExceptionIfMissingAnnotation",
"(",
"clazz",
",",
"Measurement",
".",
... | Create a new Point Build build to create a new Point in a fluent manner from a POJO.
@param clazz Class of the POJO
@return the Builder instance | [
"Create",
"a",
"new",
"Point",
"Build",
"build",
"to",
"create",
"a",
"new",
"Point",
"in",
"a",
"fluent",
"manner",
"from",
"a",
"POJO",
"."
] | 8ae777f34aa2e598f609208cf4fa12d4642f83f5 | https://github.com/influxdata/influxdb-java/blob/8ae777f34aa2e598f609208cf4fa12d4642f83f5/src/main/java/org/influxdb/dto/Point.java#L67-L72 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java | MvpViewState.restoreState | protected void restoreState(View view, Set<ViewCommand<View>> currentState) {
if (mViewCommands.isEmpty()) {
return;
}
mViewCommands.reapply(view, currentState);
} | java | protected void restoreState(View view, Set<ViewCommand<View>> currentState) {
if (mViewCommands.isEmpty()) {
return;
}
mViewCommands.reapply(view, currentState);
} | [
"protected",
"void",
"restoreState",
"(",
"View",
"view",
",",
"Set",
"<",
"ViewCommand",
"<",
"View",
">",
">",
"currentState",
")",
"{",
"if",
"(",
"mViewCommands",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"mViewCommands",
".",
"reapply"... | Apply saved state to attached view
@param view mvp view to restore state
@param currentState commands that was applied already | [
"Apply",
"saved",
"state",
"to",
"attached",
"view"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java#L36-L42 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java | MvpViewState.attachView | public void attachView(View view) {
if (view == null) {
throw new IllegalArgumentException("Mvp view must be not null");
}
boolean isViewAdded = mViews.add(view);
if (!isViewAdded) {
return;
}
mInRestoreState.add(view);
Set<ViewCommand<View>> currentState = mViewStates.get(view);
currentState = currentState == null ? Collections.<ViewCommand<View>>emptySet() : currentState;
restoreState(view, currentState);
mViewStates.remove(view);
mInRestoreState.remove(view);
} | java | public void attachView(View view) {
if (view == null) {
throw new IllegalArgumentException("Mvp view must be not null");
}
boolean isViewAdded = mViews.add(view);
if (!isViewAdded) {
return;
}
mInRestoreState.add(view);
Set<ViewCommand<View>> currentState = mViewStates.get(view);
currentState = currentState == null ? Collections.<ViewCommand<View>>emptySet() : currentState;
restoreState(view, currentState);
mViewStates.remove(view);
mInRestoreState.remove(view);
} | [
"public",
"void",
"attachView",
"(",
"View",
"view",
")",
"{",
"if",
"(",
"view",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Mvp view must be not null\"",
")",
";",
"}",
"boolean",
"isViewAdded",
"=",
"mViews",
".",
"add",
"(... | Attach view to view state and apply saves state
@param view attachment | [
"Attach",
"view",
"to",
"view",
"state",
"and",
"apply",
"saves",
"state"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java#L49-L70 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/PresenterStore.java | PresenterStore.add | public <T extends MvpPresenter> void add(String tag, T instance) {
mPresenters.put(tag, instance);
} | java | public <T extends MvpPresenter> void add(String tag, T instance) {
mPresenters.put(tag, instance);
} | [
"public",
"<",
"T",
"extends",
"MvpPresenter",
">",
"void",
"add",
"(",
"String",
"tag",
",",
"T",
"instance",
")",
"{",
"mPresenters",
".",
"put",
"(",
"tag",
",",
"instance",
")",
";",
"}"
] | Add presenter to storage
@param tag Tag of presenter. Local presenters contains also delegate's tag as prefix
@param instance Instance of MvpPresenter implementation to store
@param <T> Type of presenter | [
"Add",
"presenter",
"to",
"storage"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/PresenterStore.java#L26-L28 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/MvpPresenter.java | MvpPresenter.isInRestoreState | @SuppressWarnings("unused")
public boolean isInRestoreState(View view) {
//noinspection SimplifiableIfStatement
if (mViewState != null) {
return mViewState.isInRestoreState(view);
}
return false;
} | java | @SuppressWarnings("unused")
public boolean isInRestoreState(View view) {
//noinspection SimplifiableIfStatement
if (mViewState != null) {
return mViewState.isInRestoreState(view);
}
return false;
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"boolean",
"isInRestoreState",
"(",
"View",
"view",
")",
"{",
"//noinspection SimplifiableIfStatement",
"if",
"(",
"mViewState",
"!=",
"null",
")",
"{",
"return",
"mViewState",
".",
"isInRestoreState",
"(",
... | Check if view is in restore state or not
@param view view for check
@return true if view state restore state to incoming view. false otherwise. | [
"Check",
"if",
"view",
"is",
"in",
"restore",
"state",
"or",
"not"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/MvpPresenter.java#L110-L117 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/MvpPresenter.java | MvpPresenter.setViewState | @SuppressWarnings({"unchecked", "unused"})
public void setViewState(MvpViewState<View> viewState) {
mViewStateAsView = (View) viewState;
mViewState = (MvpViewState) viewState;
} | java | @SuppressWarnings({"unchecked", "unused"})
public void setViewState(MvpViewState<View> viewState) {
mViewStateAsView = (View) viewState;
mViewState = (MvpViewState) viewState;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"unused\"",
"}",
")",
"public",
"void",
"setViewState",
"(",
"MvpViewState",
"<",
"View",
">",
"viewState",
")",
"{",
"mViewStateAsView",
"=",
"(",
"View",
")",
"viewState",
";",
"mViewState",
"=",
"... | Set view state to presenter
@param viewState that implements type, setted as View generic param | [
"Set",
"view",
"state",
"to",
"presenter"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/MvpPresenter.java#L124-L128 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/MvpProcessor.java | MvpProcessor.hasMoxyReflector | private static boolean hasMoxyReflector() {
if (hasMoxyReflector != null) {
return hasMoxyReflector;
}
try {
new MoxyReflector();
hasMoxyReflector = true;
} catch (NoClassDefFoundError error) {
hasMoxyReflector = false;
}
return hasMoxyReflector;
} | java | private static boolean hasMoxyReflector() {
if (hasMoxyReflector != null) {
return hasMoxyReflector;
}
try {
new MoxyReflector();
hasMoxyReflector = true;
} catch (NoClassDefFoundError error) {
hasMoxyReflector = false;
}
return hasMoxyReflector;
} | [
"private",
"static",
"boolean",
"hasMoxyReflector",
"(",
")",
"{",
"if",
"(",
"hasMoxyReflector",
"!=",
"null",
")",
"{",
"return",
"hasMoxyReflector",
";",
"}",
"try",
"{",
"new",
"MoxyReflector",
"(",
")",
";",
"hasMoxyReflector",
"=",
"true",
";",
"}",
... | Check is it have generated MoxyReflector without usage of reflection API | [
"Check",
"is",
"it",
"have",
"generated",
"MoxyReflector",
"without",
"usage",
"of",
"reflection",
"API"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/MvpProcessor.java#L118-L132 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java | MvpDelegate.onSaveInstanceState | public void onSaveInstanceState(Bundle outState) {
if (mParentDelegate == null) {
Bundle moxyDelegateBundle = new Bundle();
outState.putBundle(MOXY_DELEGATE_TAGS_KEY, moxyDelegateBundle);
outState = moxyDelegateBundle;
}
outState.putAll(mBundle);
outState.putString(mKeyTag, mDelegateTag);
for (MvpDelegate childDelegate : mChildDelegates) {
childDelegate.onSaveInstanceState(outState);
}
} | java | public void onSaveInstanceState(Bundle outState) {
if (mParentDelegate == null) {
Bundle moxyDelegateBundle = new Bundle();
outState.putBundle(MOXY_DELEGATE_TAGS_KEY, moxyDelegateBundle);
outState = moxyDelegateBundle;
}
outState.putAll(mBundle);
outState.putString(mKeyTag, mDelegateTag);
for (MvpDelegate childDelegate : mChildDelegates) {
childDelegate.onSaveInstanceState(outState);
}
} | [
"public",
"void",
"onSaveInstanceState",
"(",
"Bundle",
"outState",
")",
"{",
"if",
"(",
"mParentDelegate",
"==",
"null",
")",
"{",
"Bundle",
"moxyDelegateBundle",
"=",
"new",
"Bundle",
"(",
")",
";",
"outState",
".",
"putBundle",
"(",
"MOXY_DELEGATE_TAGS_KEY",
... | Save presenters tag prefix to save state for restore presenters at future after delegate recreate
@param outState out state from Android component | [
"Save",
"presenters",
"tag",
"prefix",
"to",
"save",
"state",
"for",
"restore",
"presenters",
"at",
"future",
"after",
"delegate",
"recreate"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java#L240-L253 | train |
Arello-Mobile/Moxy | moxy-compiler/src/main/java/com/arellomobile/mvp/compiler/reflector/MoxyReflectorGenerator.java | MoxyReflectorGenerator.getPresenterBinders | private static SortedMap<TypeElement, List<TypeElement>> getPresenterBinders(List<TypeElement> presentersContainers) {
Map<TypeElement, TypeElement> extendingMap = new HashMap<>();
for (TypeElement presentersContainer : presentersContainers) {
TypeMirror superclass = presentersContainer.getSuperclass();
TypeElement parent = null;
while (superclass.getKind() == TypeKind.DECLARED) {
TypeElement superclassElement = (TypeElement) ((DeclaredType) superclass).asElement();
if (presentersContainers.contains(superclassElement)) {
parent = superclassElement;
break;
}
superclass = superclassElement.getSuperclass();
}
extendingMap.put(presentersContainer, parent);
}
// TreeMap for sorting
SortedMap<TypeElement, List<TypeElement>> elementListMap = new TreeMap<>(TYPE_ELEMENT_COMPARATOR);
for (TypeElement presentersContainer : presentersContainers) {
ArrayList<TypeElement> typeElements = new ArrayList<>();
typeElements.add(presentersContainer);
TypeElement key = presentersContainer;
while ((key = extendingMap.get(key)) != null) {
typeElements.add(key);
}
elementListMap.put(presentersContainer, typeElements);
}
return elementListMap;
} | java | private static SortedMap<TypeElement, List<TypeElement>> getPresenterBinders(List<TypeElement> presentersContainers) {
Map<TypeElement, TypeElement> extendingMap = new HashMap<>();
for (TypeElement presentersContainer : presentersContainers) {
TypeMirror superclass = presentersContainer.getSuperclass();
TypeElement parent = null;
while (superclass.getKind() == TypeKind.DECLARED) {
TypeElement superclassElement = (TypeElement) ((DeclaredType) superclass).asElement();
if (presentersContainers.contains(superclassElement)) {
parent = superclassElement;
break;
}
superclass = superclassElement.getSuperclass();
}
extendingMap.put(presentersContainer, parent);
}
// TreeMap for sorting
SortedMap<TypeElement, List<TypeElement>> elementListMap = new TreeMap<>(TYPE_ELEMENT_COMPARATOR);
for (TypeElement presentersContainer : presentersContainers) {
ArrayList<TypeElement> typeElements = new ArrayList<>();
typeElements.add(presentersContainer);
TypeElement key = presentersContainer;
while ((key = extendingMap.get(key)) != null) {
typeElements.add(key);
}
elementListMap.put(presentersContainer, typeElements);
}
return elementListMap;
} | [
"private",
"static",
"SortedMap",
"<",
"TypeElement",
",",
"List",
"<",
"TypeElement",
">",
">",
"getPresenterBinders",
"(",
"List",
"<",
"TypeElement",
">",
"presentersContainers",
")",
"{",
"Map",
"<",
"TypeElement",
",",
"TypeElement",
">",
"extendingMap",
"=... | Collects presenter binders from superclasses that are also presenter containers.
@return sorted map between presenter container and list of corresponding binders | [
"Collects",
"presenter",
"binders",
"from",
"superclasses",
"that",
"are",
"also",
"presenter",
"containers",
"."
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy-compiler/src/main/java/com/arellomobile/mvp/compiler/reflector/MoxyReflectorGenerator.java#L181-L218 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/PresentersCounter.java | PresentersCounter.injectPresenter | public void injectPresenter(MvpPresenter<?> presenter, String delegateTag) {
Set<String> delegateTags = mConnections.get(presenter);
if (delegateTags == null) {
delegateTags = new HashSet<>();
mConnections.put(presenter, delegateTags);
}
delegateTags.add(delegateTag);
Set<MvpPresenter> presenters = mTags.get(delegateTag);
if (presenters == null) {
presenters = new HashSet<>();
mTags.put(delegateTag, presenters);
}
presenters.add(presenter);
} | java | public void injectPresenter(MvpPresenter<?> presenter, String delegateTag) {
Set<String> delegateTags = mConnections.get(presenter);
if (delegateTags == null) {
delegateTags = new HashSet<>();
mConnections.put(presenter, delegateTags);
}
delegateTags.add(delegateTag);
Set<MvpPresenter> presenters = mTags.get(delegateTag);
if (presenters == null) {
presenters = new HashSet<>();
mTags.put(delegateTag, presenters);
}
presenters.add(presenter);
} | [
"public",
"void",
"injectPresenter",
"(",
"MvpPresenter",
"<",
"?",
">",
"presenter",
",",
"String",
"delegateTag",
")",
"{",
"Set",
"<",
"String",
">",
"delegateTags",
"=",
"mConnections",
".",
"get",
"(",
"presenter",
")",
";",
"if",
"(",
"delegateTags",
... | Save delegate tag when it inject presenter to delegate's object
@param presenter Injected presenter
@param delegateTag Delegate tag | [
"Save",
"delegate",
"tag",
"when",
"it",
"inject",
"presenter",
"to",
"delegate",
"s",
"object"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/PresentersCounter.java#L27-L42 | train |
Arello-Mobile/Moxy | moxy/src/main/java/com/arellomobile/mvp/PresentersCounter.java | PresentersCounter.rejectPresenter | public boolean rejectPresenter(MvpPresenter<?> presenter, String delegateTag) {
Set<MvpPresenter> presenters = mTags.get(delegateTag);
if (presenters != null) {
presenters.remove(presenter);
}
if (presenters == null || presenters.isEmpty()) {
mTags.remove(delegateTag);
}
Set<String> delegateTags = mConnections.get(presenter);
if (delegateTags == null) {
mConnections.remove(presenter);
return true;
}
Iterator<String> tagsIterator = delegateTags.iterator();
while (tagsIterator.hasNext()) {
String tag = tagsIterator.next();
if (tag.startsWith(delegateTag)) {
tagsIterator.remove();
}
}
boolean noTags = delegateTags.isEmpty();
if (noTags) {
mConnections.remove(presenter);
}
return noTags;
} | java | public boolean rejectPresenter(MvpPresenter<?> presenter, String delegateTag) {
Set<MvpPresenter> presenters = mTags.get(delegateTag);
if (presenters != null) {
presenters.remove(presenter);
}
if (presenters == null || presenters.isEmpty()) {
mTags.remove(delegateTag);
}
Set<String> delegateTags = mConnections.get(presenter);
if (delegateTags == null) {
mConnections.remove(presenter);
return true;
}
Iterator<String> tagsIterator = delegateTags.iterator();
while (tagsIterator.hasNext()) {
String tag = tagsIterator.next();
if (tag.startsWith(delegateTag)) {
tagsIterator.remove();
}
}
boolean noTags = delegateTags.isEmpty();
if (noTags) {
mConnections.remove(presenter);
}
return noTags;
} | [
"public",
"boolean",
"rejectPresenter",
"(",
"MvpPresenter",
"<",
"?",
">",
"presenter",
",",
"String",
"delegateTag",
")",
"{",
"Set",
"<",
"MvpPresenter",
">",
"presenters",
"=",
"mTags",
".",
"get",
"(",
"delegateTag",
")",
";",
"if",
"(",
"presenters",
... | Remove tag when delegate's object was fully destroyed
@param presenter Rejected presenter
@param delegateTag Delegate tag
@return True if there are no links to this presenter and presenter be able to destroy. False otherwise | [
"Remove",
"tag",
"when",
"delegate",
"s",
"object",
"was",
"fully",
"destroyed"
] | 83c608de22a55864f0cdd8c1eee878e72afa3e71 | https://github.com/Arello-Mobile/Moxy/blob/83c608de22a55864f0cdd8c1eee878e72afa3e71/moxy/src/main/java/com/arellomobile/mvp/PresentersCounter.java#L51-L82 | train |
OpenHFT/Java-Thread-Affinity | affinity/src/main/java/net/openhft/affinity/AffinityLock.java | AffinityLock.bind | public void bind(boolean wholeCore) {
if (bound && assignedThread != null && assignedThread.isAlive())
throw new IllegalStateException("cpu " + cpuId + " already bound to " + assignedThread);
if (areAssertionsEnabled())
boundHere = new Throwable("Bound here");
if (wholeCore) {
lockInventory.bindWholeCore(cpuId);
} else if (cpuId >= 0) {
bound = true;
assignedThread = Thread.currentThread();
LOGGER.info("Assigning cpu {} to {}", cpuId, assignedThread);
}
if (cpuId >= 0) {
BitSet affinity = new BitSet();
affinity.set(cpuId, true);
Affinity.setAffinity(affinity);
}
} | java | public void bind(boolean wholeCore) {
if (bound && assignedThread != null && assignedThread.isAlive())
throw new IllegalStateException("cpu " + cpuId + " already bound to " + assignedThread);
if (areAssertionsEnabled())
boundHere = new Throwable("Bound here");
if (wholeCore) {
lockInventory.bindWholeCore(cpuId);
} else if (cpuId >= 0) {
bound = true;
assignedThread = Thread.currentThread();
LOGGER.info("Assigning cpu {} to {}", cpuId, assignedThread);
}
if (cpuId >= 0) {
BitSet affinity = new BitSet();
affinity.set(cpuId, true);
Affinity.setAffinity(affinity);
}
} | [
"public",
"void",
"bind",
"(",
"boolean",
"wholeCore",
")",
"{",
"if",
"(",
"bound",
"&&",
"assignedThread",
"!=",
"null",
"&&",
"assignedThread",
".",
"isAlive",
"(",
")",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"cpu \"",
"+",
"cpuId",
"+",
"... | Bind the current thread to this reservable lock.
@param wholeCore if true, also reserve the whole core. | [
"Bind",
"the",
"current",
"thread",
"to",
"this",
"reservable",
"lock",
"."
] | e0987f6f21aeea89830d8010483bb4abca54fc1b | https://github.com/OpenHFT/Java-Thread-Affinity/blob/e0987f6f21aeea89830d8010483bb4abca54fc1b/affinity/src/main/java/net/openhft/affinity/AffinityLock.java#L238-L257 | train |
OpenHFT/Java-Thread-Affinity | affinity/src/main/java/net/openhft/affinity/impl/Utilities.java | Utilities.toHexString | public static String toHexString(final BitSet set) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(out);
final long[] longs = set.toLongArray();
for (long aLong : longs) {
writer.write(Long.toHexString(aLong));
}
writer.flush();
return new String(out.toByteArray(), java.nio.charset.StandardCharsets.UTF_8);
} | java | public static String toHexString(final BitSet set) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(out);
final long[] longs = set.toLongArray();
for (long aLong : longs) {
writer.write(Long.toHexString(aLong));
}
writer.flush();
return new String(out.toByteArray(), java.nio.charset.StandardCharsets.UTF_8);
} | [
"public",
"static",
"String",
"toHexString",
"(",
"final",
"BitSet",
"set",
")",
"{",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"PrintWriter",
"writer",
"=",
"new",
"PrintWriter",
"(",
"out",
")",
";",
"final",
"long",... | Creates a hexademical representation of the bit set
@param set the bit set to convert
@return the hexademical string representation | [
"Creates",
"a",
"hexademical",
"representation",
"of",
"the",
"bit",
"set"
] | e0987f6f21aeea89830d8010483bb4abca54fc1b | https://github.com/OpenHFT/Java-Thread-Affinity/blob/e0987f6f21aeea89830d8010483bb4abca54fc1b/affinity/src/main/java/net/openhft/affinity/impl/Utilities.java#L38-L48 | train |
sannies/mp4parser | muxer/src/main/java/org/mp4parser/muxer/builder/DefaultMp4Builder.java | DefaultMp4Builder.getChunkSizes | int[] getChunkSizes(Track track) {
long[] referenceChunkStarts = fragmenter.sampleNumbers(track);
int[] chunkSizes = new int[referenceChunkStarts.length];
for (int i = 0; i < referenceChunkStarts.length; i++) {
long start = referenceChunkStarts[i] - 1;
long end;
if (referenceChunkStarts.length == i + 1) {
end = track.getSamples().size();
} else {
end = referenceChunkStarts[i + 1] - 1;
}
chunkSizes[i] = l2i(end - start);
}
assert DefaultMp4Builder.this.track2Sample.get(track).size() == sum(chunkSizes) : "The number of samples and the sum of all chunk lengths must be equal";
return chunkSizes;
} | java | int[] getChunkSizes(Track track) {
long[] referenceChunkStarts = fragmenter.sampleNumbers(track);
int[] chunkSizes = new int[referenceChunkStarts.length];
for (int i = 0; i < referenceChunkStarts.length; i++) {
long start = referenceChunkStarts[i] - 1;
long end;
if (referenceChunkStarts.length == i + 1) {
end = track.getSamples().size();
} else {
end = referenceChunkStarts[i + 1] - 1;
}
chunkSizes[i] = l2i(end - start);
}
assert DefaultMp4Builder.this.track2Sample.get(track).size() == sum(chunkSizes) : "The number of samples and the sum of all chunk lengths must be equal";
return chunkSizes;
} | [
"int",
"[",
"]",
"getChunkSizes",
"(",
"Track",
"track",
")",
"{",
"long",
"[",
"]",
"referenceChunkStarts",
"=",
"fragmenter",
".",
"sampleNumbers",
"(",
"track",
")",
";",
"int",
"[",
"]",
"chunkSizes",
"=",
"new",
"int",
"[",
"referenceChunkStarts",
"."... | Gets the chunk sizes for the given track.
@param track the track we are talking about
@return the size of each chunk in number of samples | [
"Gets",
"the",
"chunk",
"sizes",
"for",
"the",
"given",
"track",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/muxer/src/main/java/org/mp4parser/muxer/builder/DefaultMp4Builder.java#L603-L624 | train |
sannies/mp4parser | examples/src/main/java/com/google/code/mp4parser/example/PrintStructure.java | PrintStructure.print | private void print(FileChannel fc, int level, long start, long end) throws IOException {
fc.position(start);
if(end <= 0) {
end = start + fc.size();
System.out.println("Setting END to " + end);
}
while (end - fc.position() > 8) {
long begin = fc.position();
ByteBuffer bb = ByteBuffer.allocate(8);
fc.read(bb);
bb.rewind();
long size = IsoTypeReader.readUInt32(bb);
String type = IsoTypeReader.read4cc(bb);
long fin = begin + size;
// indent by the required number of spaces
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println(type + "@" + (begin) + " size: " + size);
if (containers.contains(type)) {
print(fc, level + 1, begin + 8, fin);
if(fc.position() != fin) {
System.out.println("End of container contents at " + fc.position());
System.out.println(" FIN = " + fin);
}
}
fc.position(fin);
}
} | java | private void print(FileChannel fc, int level, long start, long end) throws IOException {
fc.position(start);
if(end <= 0) {
end = start + fc.size();
System.out.println("Setting END to " + end);
}
while (end - fc.position() > 8) {
long begin = fc.position();
ByteBuffer bb = ByteBuffer.allocate(8);
fc.read(bb);
bb.rewind();
long size = IsoTypeReader.readUInt32(bb);
String type = IsoTypeReader.read4cc(bb);
long fin = begin + size;
// indent by the required number of spaces
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println(type + "@" + (begin) + " size: " + size);
if (containers.contains(type)) {
print(fc, level + 1, begin + 8, fin);
if(fc.position() != fin) {
System.out.println("End of container contents at " + fc.position());
System.out.println(" FIN = " + fin);
}
}
fc.position(fin);
}
} | [
"private",
"void",
"print",
"(",
"FileChannel",
"fc",
",",
"int",
"level",
",",
"long",
"start",
",",
"long",
"end",
")",
"throws",
"IOException",
"{",
"fc",
".",
"position",
"(",
"start",
")",
";",
"if",
"(",
"end",
"<=",
"0",
")",
"{",
"end",
"="... | Parses the FileChannel, in the range [start, end) and prints the elements found
Elements are printed, indented by "level" number of spaces. If an element is
a container, then its contents will be, recursively, printed, with a greater
indentation.
@param fc
@param level
@param start
@param end
@throws IOException | [
"Parses",
"the",
"FileChannel",
"in",
"the",
"range",
"[",
"start",
"end",
")",
"and",
"prints",
"the",
"elements",
"found"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/examples/src/main/java/com/google/code/mp4parser/example/PrintStructure.java#L52-L83 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/AbstractBoxParser.java | AbstractBoxParser.parseBox | public ParsableBox parseBox(ReadableByteChannel byteChannel, String parentType) throws IOException {
header.get().rewind().limit(8);
int bytesRead = 0;
int b;
while ((b = byteChannel.read(header.get())) + bytesRead < 8) {
if (b < 0) {
throw new EOFException();
} else {
bytesRead += b;
}
}
header.get().rewind();
long size = IsoTypeReader.readUInt32(header.get());
// do plausibility check
if (size < 8 && size > 1) {
LOG.error("Plausibility check failed: size < 8 (size = {}). Stop parsing!", size);
return null;
}
String type = IsoTypeReader.read4cc(header.get());
//System.err.println(type);
byte[] usertype = null;
long contentSize;
if (size == 1) {
header.get().limit(16);
byteChannel.read(header.get());
header.get().position(8);
size = IsoTypeReader.readUInt64(header.get());
contentSize = size - 16;
} else if (size == 0) {
throw new RuntimeException("box size of zero means 'till end of file. That is not yet supported");
} else {
contentSize = size - 8;
}
if (UserBox.TYPE.equals(type)) {
header.get().limit(header.get().limit() + 16);
byteChannel.read(header.get());
usertype = new byte[16];
for (int i = header.get().position() - 16; i < header.get().position(); i++) {
usertype[i - (header.get().position() - 16)] = header.get().get(i);
}
contentSize -= 16;
}
ParsableBox parsableBox = null;
if( skippedTypes != null && skippedTypes.contains(type) ) {
LOG.trace("Skipping box {} {} {}", type, usertype, parentType);
parsableBox = new SkipBox(type, usertype, parentType);
}
else {
LOG.trace("Creating box {} {} {}", type, usertype, parentType);
parsableBox = createBox(type, usertype, parentType);
}
//LOG.finest("Parsing " + box.getType());
// System.out.println("parsing " + Mp4Arrays.toString(box.getType()) + " " + box.getClass().getName() + " size=" + size);
header.get().rewind();
parsableBox.parse(byteChannel, header.get(), contentSize, this);
return parsableBox;
} | java | public ParsableBox parseBox(ReadableByteChannel byteChannel, String parentType) throws IOException {
header.get().rewind().limit(8);
int bytesRead = 0;
int b;
while ((b = byteChannel.read(header.get())) + bytesRead < 8) {
if (b < 0) {
throw new EOFException();
} else {
bytesRead += b;
}
}
header.get().rewind();
long size = IsoTypeReader.readUInt32(header.get());
// do plausibility check
if (size < 8 && size > 1) {
LOG.error("Plausibility check failed: size < 8 (size = {}). Stop parsing!", size);
return null;
}
String type = IsoTypeReader.read4cc(header.get());
//System.err.println(type);
byte[] usertype = null;
long contentSize;
if (size == 1) {
header.get().limit(16);
byteChannel.read(header.get());
header.get().position(8);
size = IsoTypeReader.readUInt64(header.get());
contentSize = size - 16;
} else if (size == 0) {
throw new RuntimeException("box size of zero means 'till end of file. That is not yet supported");
} else {
contentSize = size - 8;
}
if (UserBox.TYPE.equals(type)) {
header.get().limit(header.get().limit() + 16);
byteChannel.read(header.get());
usertype = new byte[16];
for (int i = header.get().position() - 16; i < header.get().position(); i++) {
usertype[i - (header.get().position() - 16)] = header.get().get(i);
}
contentSize -= 16;
}
ParsableBox parsableBox = null;
if( skippedTypes != null && skippedTypes.contains(type) ) {
LOG.trace("Skipping box {} {} {}", type, usertype, parentType);
parsableBox = new SkipBox(type, usertype, parentType);
}
else {
LOG.trace("Creating box {} {} {}", type, usertype, parentType);
parsableBox = createBox(type, usertype, parentType);
}
//LOG.finest("Parsing " + box.getType());
// System.out.println("parsing " + Mp4Arrays.toString(box.getType()) + " " + box.getClass().getName() + " size=" + size);
header.get().rewind();
parsableBox.parse(byteChannel, header.get(), contentSize, this);
return parsableBox;
} | [
"public",
"ParsableBox",
"parseBox",
"(",
"ReadableByteChannel",
"byteChannel",
",",
"String",
"parentType",
")",
"throws",
"IOException",
"{",
"header",
".",
"get",
"(",
")",
".",
"rewind",
"(",
")",
".",
"limit",
"(",
"8",
")",
";",
"int",
"bytesRead",
"... | Parses the next size and type, creates a box instance and parses the box's content.
@param byteChannel the DataSource pointing to the ISO file
@param parentType the current box's parent's type (null if no parent)
@return the box just parsed
@throws java.io.IOException if reading from <code>in</code> fails | [
"Parses",
"the",
"next",
"size",
"and",
"type",
"creates",
"a",
"box",
"instance",
"and",
"parses",
"the",
"box",
"s",
"content",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/AbstractBoxParser.java#L55-L117 | train |
sannies/mp4parser | muxer/src/main/java/org/mp4parser/muxer/builder/SyncSampleIntersectFinderImpl.java | SyncSampleIntersectFinderImpl.getSyncSamplesTimestamps | public static List<long[]> getSyncSamplesTimestamps(Movie movie, Track track) {
List<long[]> times = new LinkedList<long[]>();
for (Track currentTrack : movie.getTracks()) {
if (currentTrack.getHandler().equals(track.getHandler())) {
long[] currentTrackSyncSamples = currentTrack.getSyncSamples();
if (currentTrackSyncSamples != null && currentTrackSyncSamples.length > 0) {
final long[] currentTrackTimes = getTimes(currentTrack, movie);
times.add(currentTrackTimes);
}
}
}
return times;
} | java | public static List<long[]> getSyncSamplesTimestamps(Movie movie, Track track) {
List<long[]> times = new LinkedList<long[]>();
for (Track currentTrack : movie.getTracks()) {
if (currentTrack.getHandler().equals(track.getHandler())) {
long[] currentTrackSyncSamples = currentTrack.getSyncSamples();
if (currentTrackSyncSamples != null && currentTrackSyncSamples.length > 0) {
final long[] currentTrackTimes = getTimes(currentTrack, movie);
times.add(currentTrackTimes);
}
}
}
return times;
} | [
"public",
"static",
"List",
"<",
"long",
"[",
"]",
">",
"getSyncSamplesTimestamps",
"(",
"Movie",
"movie",
",",
"Track",
"track",
")",
"{",
"List",
"<",
"long",
"[",
"]",
">",
"times",
"=",
"new",
"LinkedList",
"<",
"long",
"[",
"]",
">",
"(",
")",
... | Calculates the timestamp of all tracks' sync samples.
@param movie <code>track</code> is located in this movie
@param track get this track's samples timestamps
@return a list of timestamps | [
"Calculates",
"the",
"timestamp",
"of",
"all",
"tracks",
"sync",
"samples",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/muxer/src/main/java/org/mp4parser/muxer/builder/SyncSampleIntersectFinderImpl.java#L94-L106 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/iso14496/part12/CompositionTimeToSample.java | CompositionTimeToSample.blowupCompositionTimes | public static int[] blowupCompositionTimes(List<CompositionTimeToSample.Entry> entries) {
long numOfSamples = 0;
for (CompositionTimeToSample.Entry entry : entries) {
numOfSamples += entry.getCount();
}
assert numOfSamples <= Integer.MAX_VALUE;
int[] decodingTime = new int[(int) numOfSamples];
int current = 0;
for (CompositionTimeToSample.Entry entry : entries) {
for (int i = 0; i < entry.getCount(); i++) {
decodingTime[current++] = entry.getOffset();
}
}
return decodingTime;
} | java | public static int[] blowupCompositionTimes(List<CompositionTimeToSample.Entry> entries) {
long numOfSamples = 0;
for (CompositionTimeToSample.Entry entry : entries) {
numOfSamples += entry.getCount();
}
assert numOfSamples <= Integer.MAX_VALUE;
int[] decodingTime = new int[(int) numOfSamples];
int current = 0;
for (CompositionTimeToSample.Entry entry : entries) {
for (int i = 0; i < entry.getCount(); i++) {
decodingTime[current++] = entry.getOffset();
}
}
return decodingTime;
} | [
"public",
"static",
"int",
"[",
"]",
"blowupCompositionTimes",
"(",
"List",
"<",
"CompositionTimeToSample",
".",
"Entry",
">",
"entries",
")",
"{",
"long",
"numOfSamples",
"=",
"0",
";",
"for",
"(",
"CompositionTimeToSample",
".",
"Entry",
"entry",
":",
"entri... | Decompresses the list of entries and returns the list of composition times.
@param entries composition time to sample entries in compressed form
@return decoding time per sample | [
"Decompresses",
"the",
"list",
"of",
"entries",
"and",
"returns",
"the",
"list",
"of",
"composition",
"times",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/iso14496/part12/CompositionTimeToSample.java#L58-L76 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/tools/IsoTypeReader.java | IsoTypeReader.readString | public static String readString(ByteBuffer byteBuffer) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
int read;
while ((read = byteBuffer.get()) != 0) {
out.write(read);
}
return Utf8.convert(out.toByteArray());
} | java | public static String readString(ByteBuffer byteBuffer) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
int read;
while ((read = byteBuffer.get()) != 0) {
out.write(read);
}
return Utf8.convert(out.toByteArray());
} | [
"public",
"static",
"String",
"readString",
"(",
"ByteBuffer",
"byteBuffer",
")",
"{",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"int",
"read",
";",
"while",
"(",
"(",
"read",
"=",
"byteBuffer",
".",
"get",
"(",
")",... | Reads a zero terminated UTF-8 string.
@param byteBuffer the data source
@return the string readByte
@throws Error in case of an error in the underlying stream | [
"Reads",
"a",
"zero",
"terminated",
"UTF",
"-",
"8",
"string",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/tools/IsoTypeReader.java#L81-L89 | train |
sannies/mp4parser | streaming/src/main/java/org/mp4parser/streaming/output/mp4/StandardMp4Writer.java | StandardMp4Writer.isChunkReady | protected boolean isChunkReady(StreamingTrack streamingTrack, StreamingSample next) {
long ts = nextSampleStartTime.get(streamingTrack);
long cfst = nextChunkCreateStartTime.get(streamingTrack);
return (ts >= cfst + 2 * streamingTrack.getTimescale());
// chunk interleave of 2 seconds
} | java | protected boolean isChunkReady(StreamingTrack streamingTrack, StreamingSample next) {
long ts = nextSampleStartTime.get(streamingTrack);
long cfst = nextChunkCreateStartTime.get(streamingTrack);
return (ts >= cfst + 2 * streamingTrack.getTimescale());
// chunk interleave of 2 seconds
} | [
"protected",
"boolean",
"isChunkReady",
"(",
"StreamingTrack",
"streamingTrack",
",",
"StreamingSample",
"next",
")",
"{",
"long",
"ts",
"=",
"nextSampleStartTime",
".",
"get",
"(",
"streamingTrack",
")",
";",
"long",
"cfst",
"=",
"nextChunkCreateStartTime",
".",
... | Tests if the currently received samples for a given track
are already a 'chunk' as we want to have it. The next
sample will not be part of the chunk
will be added to the fragment buffer later.
@param streamingTrack track to test
@param next the lastest samples
@return true if a chunk is to b e created. | [
"Tests",
"if",
"the",
"currently",
"received",
"samples",
"for",
"a",
"given",
"track",
"are",
"already",
"a",
"chunk",
"as",
"we",
"want",
"to",
"have",
"it",
".",
"The",
"next",
"sample",
"will",
"not",
"be",
"part",
"of",
"the",
"chunk",
"will",
"be... | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/streaming/src/main/java/org/mp4parser/streaming/output/mp4/StandardMp4Writer.java#L181-L187 | train |
sannies/mp4parser | streaming/src/main/java/org/mp4parser/streaming/output/mp4/FragmentedMp4Writer.java | FragmentedMp4Writer.isFragmentReady | protected boolean isFragmentReady(StreamingTrack streamingTrack, StreamingSample next) {
long ts = nextSampleStartTime.get(streamingTrack);
long cfst = nextFragmentCreateStartTime.get(streamingTrack);
if ((ts > cfst + 3 * streamingTrack.getTimescale())) {
// mininum fragment length == 3 seconds
SampleFlagsSampleExtension sfExt = next.getSampleExtension(SampleFlagsSampleExtension.class);
if (sfExt == null || sfExt.isSyncSample()) {
//System.err.println(streamingTrack + " ready at " + ts);
// the next sample needs to be a sync sample
// when there is no SampleFlagsSampleExtension we assume syncSample == true
return true;
}
}
return false;
} | java | protected boolean isFragmentReady(StreamingTrack streamingTrack, StreamingSample next) {
long ts = nextSampleStartTime.get(streamingTrack);
long cfst = nextFragmentCreateStartTime.get(streamingTrack);
if ((ts > cfst + 3 * streamingTrack.getTimescale())) {
// mininum fragment length == 3 seconds
SampleFlagsSampleExtension sfExt = next.getSampleExtension(SampleFlagsSampleExtension.class);
if (sfExt == null || sfExt.isSyncSample()) {
//System.err.println(streamingTrack + " ready at " + ts);
// the next sample needs to be a sync sample
// when there is no SampleFlagsSampleExtension we assume syncSample == true
return true;
}
}
return false;
} | [
"protected",
"boolean",
"isFragmentReady",
"(",
"StreamingTrack",
"streamingTrack",
",",
"StreamingSample",
"next",
")",
"{",
"long",
"ts",
"=",
"nextSampleStartTime",
".",
"get",
"(",
"streamingTrack",
")",
";",
"long",
"cfst",
"=",
"nextFragmentCreateStartTime",
"... | Tests if the currently received samples for a given track
form a valid fragment taking the latest received sample into
account. The next sample is not part of the segment and
will be added to the fragment buffer later.
@param streamingTrack track to test
@param next the lastest samples
@return true if a fragment has been created. | [
"Tests",
"if",
"the",
"currently",
"received",
"samples",
"for",
"a",
"given",
"track",
"form",
"a",
"valid",
"fragment",
"taking",
"the",
"latest",
"received",
"sample",
"into",
"account",
".",
"The",
"next",
"sample",
"is",
"not",
"part",
"of",
"the",
"s... | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/streaming/src/main/java/org/mp4parser/streaming/output/mp4/FragmentedMp4Writer.java#L299-L314 | train |
sannies/mp4parser | muxer/src/main/java/org/mp4parser/muxer/builder/FragmentedMp4Builder.java | FragmentedMp4Builder.getSampleSizes | protected long[] getSampleSizes(long startSample, long endSample, Track track, int sequenceNumber) {
List<Sample> samples = getSamples(startSample, endSample, track);
long[] sampleSizes = new long[samples.size()];
for (int i = 0; i < sampleSizes.length; i++) {
sampleSizes[i] = samples.get(i).getSize();
}
return sampleSizes;
} | java | protected long[] getSampleSizes(long startSample, long endSample, Track track, int sequenceNumber) {
List<Sample> samples = getSamples(startSample, endSample, track);
long[] sampleSizes = new long[samples.size()];
for (int i = 0; i < sampleSizes.length; i++) {
sampleSizes[i] = samples.get(i).getSize();
}
return sampleSizes;
} | [
"protected",
"long",
"[",
"]",
"getSampleSizes",
"(",
"long",
"startSample",
",",
"long",
"endSample",
",",
"Track",
"track",
",",
"int",
"sequenceNumber",
")",
"{",
"List",
"<",
"Sample",
">",
"samples",
"=",
"getSamples",
"(",
"startSample",
",",
"endSampl... | Gets the sizes of a sequence of samples.
@param startSample low endpoint (inclusive) of the sample sequence
@param endSample high endpoint (exclusive) of the sample sequence
@param track source of the samples
@param sequenceNumber the fragment index of the requested list of samples
@return the sample sizes in the given interval | [
"Gets",
"the",
"sizes",
"of",
"a",
"sequence",
"of",
"samples",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/muxer/src/main/java/org/mp4parser/muxer/builder/FragmentedMp4Builder.java#L377-L385 | train |
sannies/mp4parser | muxer/src/main/java/org/mp4parser/muxer/builder/FragmentedMp4Builder.java | FragmentedMp4Builder.createMoof | protected ParsableBox createMoof(long startSample, long endSample, Track track, int sequenceNumber) {
MovieFragmentBox moof = new MovieFragmentBox();
createMfhd(startSample, endSample, track, sequenceNumber, moof);
createTraf(startSample, endSample, track, sequenceNumber, moof);
TrackRunBox firstTrun = moof.getTrackRunBoxes().get(0);
firstTrun.setDataOffset(1); // dummy to make size correct
firstTrun.setDataOffset((int) (8 + moof.getSize())); // mdat header + moof size
return moof;
} | java | protected ParsableBox createMoof(long startSample, long endSample, Track track, int sequenceNumber) {
MovieFragmentBox moof = new MovieFragmentBox();
createMfhd(startSample, endSample, track, sequenceNumber, moof);
createTraf(startSample, endSample, track, sequenceNumber, moof);
TrackRunBox firstTrun = moof.getTrackRunBoxes().get(0);
firstTrun.setDataOffset(1); // dummy to make size correct
firstTrun.setDataOffset((int) (8 + moof.getSize())); // mdat header + moof size
return moof;
} | [
"protected",
"ParsableBox",
"createMoof",
"(",
"long",
"startSample",
",",
"long",
"endSample",
",",
"Track",
"track",
",",
"int",
"sequenceNumber",
")",
"{",
"MovieFragmentBox",
"moof",
"=",
"new",
"MovieFragmentBox",
"(",
")",
";",
"createMfhd",
"(",
"startSam... | Creates a 'moof' box for a given sequence of samples.
@param startSample low endpoint (inclusive) of the sample sequence
@param endSample high endpoint (exclusive) of the sample sequence
@param track source of the samples
@param sequenceNumber the fragment index of the requested list of samples
@return the list of TrackRun boxes. | [
"Creates",
"a",
"moof",
"box",
"for",
"a",
"given",
"sequence",
"of",
"samples",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/muxer/src/main/java/org/mp4parser/muxer/builder/FragmentedMp4Builder.java#L498-L508 | train |
sannies/mp4parser | muxer/src/main/java/org/mp4parser/muxer/builder/FragmentedMp4Builder.java | FragmentedMp4Builder.createMvhd | protected ParsableBox createMvhd(Movie movie) {
MovieHeaderBox mvhd = new MovieHeaderBox();
mvhd.setVersion(1);
mvhd.setCreationTime(getDate());
mvhd.setModificationTime(getDate());
mvhd.setDuration(0);//no duration in moov for fragmented movies
long movieTimeScale = movie.getTimescale();
mvhd.setTimescale(movieTimeScale);
// find the next available trackId
long nextTrackId = 0;
for (Track track : movie.getTracks()) {
nextTrackId = nextTrackId < track.getTrackMetaData().getTrackId() ? track.getTrackMetaData().getTrackId() : nextTrackId;
}
mvhd.setNextTrackId(++nextTrackId);
return mvhd;
} | java | protected ParsableBox createMvhd(Movie movie) {
MovieHeaderBox mvhd = new MovieHeaderBox();
mvhd.setVersion(1);
mvhd.setCreationTime(getDate());
mvhd.setModificationTime(getDate());
mvhd.setDuration(0);//no duration in moov for fragmented movies
long movieTimeScale = movie.getTimescale();
mvhd.setTimescale(movieTimeScale);
// find the next available trackId
long nextTrackId = 0;
for (Track track : movie.getTracks()) {
nextTrackId = nextTrackId < track.getTrackMetaData().getTrackId() ? track.getTrackMetaData().getTrackId() : nextTrackId;
}
mvhd.setNextTrackId(++nextTrackId);
return mvhd;
} | [
"protected",
"ParsableBox",
"createMvhd",
"(",
"Movie",
"movie",
")",
"{",
"MovieHeaderBox",
"mvhd",
"=",
"new",
"MovieHeaderBox",
"(",
")",
";",
"mvhd",
".",
"setVersion",
"(",
"1",
")",
";",
"mvhd",
".",
"setCreationTime",
"(",
"getDate",
"(",
")",
")",
... | Creates a single 'mvhd' movie header box for a given movie.
@param movie the concerned movie
@return an 'mvhd' box | [
"Creates",
"a",
"single",
"mvhd",
"movie",
"header",
"box",
"for",
"a",
"given",
"movie",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/muxer/src/main/java/org/mp4parser/muxer/builder/FragmentedMp4Builder.java#L516-L531 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/support/AbstractBox.java | AbstractBox.parseDetails | public synchronized final void parseDetails() {
LOG.debug("parsing details of {}", this.getType());
if (content != null) {
ByteBuffer content = this.content;
isParsed = true;
content.rewind();
_parseDetails(content);
if (content.remaining() > 0) {
deadBytes = content.slice();
}
this.content = null;
assert verify(content);
}
} | java | public synchronized final void parseDetails() {
LOG.debug("parsing details of {}", this.getType());
if (content != null) {
ByteBuffer content = this.content;
isParsed = true;
content.rewind();
_parseDetails(content);
if (content.remaining() > 0) {
deadBytes = content.slice();
}
this.content = null;
assert verify(content);
}
} | [
"public",
"synchronized",
"final",
"void",
"parseDetails",
"(",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"parsing details of {}\"",
",",
"this",
".",
"getType",
"(",
")",
")",
";",
"if",
"(",
"content",
"!=",
"null",
")",
"{",
"ByteBuffer",
"content",
"=",
... | Parses the raw content of the box. It surrounds the actual parsing
which is done | [
"Parses",
"the",
"raw",
"content",
"of",
"the",
"box",
".",
"It",
"surrounds",
"the",
"actual",
"parsing",
"which",
"is",
"done"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/support/AbstractBox.java#L134-L147 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/support/AbstractBox.java | AbstractBox.getSize | public long getSize() {
long size = isParsed ? getContentSize() : content.limit();
size += (8 + // size|type
(size >= ((1L << 32) - 8) ? 8 : 0) + // 32bit - 8 byte size and type
(UserBox.TYPE.equals(getType()) ? 16 : 0));
size += (deadBytes == null ? 0 : deadBytes.limit());
return size;
} | java | public long getSize() {
long size = isParsed ? getContentSize() : content.limit();
size += (8 + // size|type
(size >= ((1L << 32) - 8) ? 8 : 0) + // 32bit - 8 byte size and type
(UserBox.TYPE.equals(getType()) ? 16 : 0));
size += (deadBytes == null ? 0 : deadBytes.limit());
return size;
} | [
"public",
"long",
"getSize",
"(",
")",
"{",
"long",
"size",
"=",
"isParsed",
"?",
"getContentSize",
"(",
")",
":",
"content",
".",
"limit",
"(",
")",
";",
"size",
"+=",
"(",
"8",
"+",
"// size|type",
"(",
"size",
">=",
"(",
"(",
"1L",
"<<",
"32",
... | Gets the full size of the box including header and content.
@return the box's size | [
"Gets",
"the",
"full",
"size",
"of",
"the",
"box",
"including",
"header",
"and",
"content",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/support/AbstractBox.java#L155-L162 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/support/AbstractBox.java | AbstractBox.verify | private boolean verify(ByteBuffer content) {
ByteBuffer bb = ByteBuffer.allocate(l2i(getContentSize() + (deadBytes != null ? deadBytes.limit() : 0)));
getContent(bb);
if (deadBytes != null) {
deadBytes.rewind();
while (deadBytes.remaining() > 0) {
bb.put(deadBytes);
}
}
content.rewind();
bb.rewind();
if (content.remaining() != bb.remaining()) {
LOG.error("{}: remaining differs {} vs. {}", this.getType(), content.remaining(), bb.remaining());
return false;
}
int p = content.position();
for (int i = content.limit() - 1, j = bb.limit() - 1; i >= p; i--, j--) {
byte v1 = content.get(i);
byte v2 = bb.get(j);
if (v1 != v2) {
LOG.error("{}: buffers differ at {}: {}/{}", this.getType(), i, v1, v2);
byte[] b1 = new byte[content.remaining()];
byte[] b2 = new byte[bb.remaining()];
content.get(b1);
bb.get(b2);
LOG.error("original : {}", Hex.encodeHex(b1, 4));
LOG.error("reconstructed : {}", Hex.encodeHex(b2, 4));
return false;
}
}
return true;
} | java | private boolean verify(ByteBuffer content) {
ByteBuffer bb = ByteBuffer.allocate(l2i(getContentSize() + (deadBytes != null ? deadBytes.limit() : 0)));
getContent(bb);
if (deadBytes != null) {
deadBytes.rewind();
while (deadBytes.remaining() > 0) {
bb.put(deadBytes);
}
}
content.rewind();
bb.rewind();
if (content.remaining() != bb.remaining()) {
LOG.error("{}: remaining differs {} vs. {}", this.getType(), content.remaining(), bb.remaining());
return false;
}
int p = content.position();
for (int i = content.limit() - 1, j = bb.limit() - 1; i >= p; i--, j--) {
byte v1 = content.get(i);
byte v2 = bb.get(j);
if (v1 != v2) {
LOG.error("{}: buffers differ at {}: {}/{}", this.getType(), i, v1, v2);
byte[] b1 = new byte[content.remaining()];
byte[] b2 = new byte[bb.remaining()];
content.get(b1);
bb.get(b2);
LOG.error("original : {}", Hex.encodeHex(b1, 4));
LOG.error("reconstructed : {}", Hex.encodeHex(b2, 4));
return false;
}
}
return true;
} | [
"private",
"boolean",
"verify",
"(",
"ByteBuffer",
"content",
")",
"{",
"ByteBuffer",
"bb",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"l2i",
"(",
"getContentSize",
"(",
")",
"+",
"(",
"deadBytes",
"!=",
"null",
"?",
"deadBytes",
".",
"limit",
"(",
")",
":... | Verifies that a box can be reconstructed byte-exact after parsing.
@param content the raw content of the box
@return <code>true</code> if raw content exactly matches the reconstructed content | [
"Verifies",
"that",
"a",
"box",
"can",
"be",
"reconstructed",
"byte",
"-",
"exact",
"after",
"parsing",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/support/AbstractBox.java#L190-L224 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/iso14496/part1/objectdescriptors/ExtensionDescriptor.java | ExtensionDescriptor.allTags | static int[] allTags() {
int[] ints = new int[0xFE - 0x6A];
for (int i = 0x6A; i < 0xFE; i++) {
final int pos = i - 0x6A;
LOG.trace("pos: {}", pos);
ints[pos] = i;
}
return ints;
} | java | static int[] allTags() {
int[] ints = new int[0xFE - 0x6A];
for (int i = 0x6A; i < 0xFE; i++) {
final int pos = i - 0x6A;
LOG.trace("pos: {}", pos);
ints[pos] = i;
}
return ints;
} | [
"static",
"int",
"[",
"]",
"allTags",
"(",
")",
"{",
"int",
"[",
"]",
"ints",
"=",
"new",
"int",
"[",
"0xFE",
"-",
"0x6A",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0x6A",
";",
"i",
"<",
"0xFE",
";",
"i",
"++",
")",
"{",
"final",
"int",
"pos"... | ExtDescrTagEndRange = 0xFE | [
"ExtDescrTagEndRange",
"=",
"0xFE"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/iso14496/part1/objectdescriptors/ExtensionDescriptor.java#L50-L59 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.getAllTagNames | public String[] getAllTagNames() {
String names[] = new String[tags.size()];
for (int i = 0; i < tags.size(); i++) {
XtraTag tag = tags.elementAt(i);
names[i] = tag.tagName;
}
return names;
} | java | public String[] getAllTagNames() {
String names[] = new String[tags.size()];
for (int i = 0; i < tags.size(); i++) {
XtraTag tag = tags.elementAt(i);
names[i] = tag.tagName;
}
return names;
} | [
"public",
"String",
"[",
"]",
"getAllTagNames",
"(",
")",
"{",
"String",
"names",
"[",
"]",
"=",
"new",
"String",
"[",
"tags",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tags",
".",
"size",
"(",
")",
";... | Returns a list of the tag names present in this Xtra Box
@return Possibly empty (zero length) array of tag names present | [
"Returns",
"a",
"list",
"of",
"the",
"tag",
"names",
"present",
"in",
"this",
"Xtra",
"Box"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L196-L203 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.getFirstStringValue | public String getFirstStringValue(String name) {
Object objs[] = getValues(name);
for (Object obj : objs) {
if (obj instanceof String) {
return (String) obj;
}
}
return null;
} | java | public String getFirstStringValue(String name) {
Object objs[] = getValues(name);
for (Object obj : objs) {
if (obj instanceof String) {
return (String) obj;
}
}
return null;
} | [
"public",
"String",
"getFirstStringValue",
"(",
"String",
"name",
")",
"{",
"Object",
"objs",
"[",
"]",
"=",
"getValues",
"(",
"name",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"objs",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"String",
")",
"{",
"... | Returns the first String value found for this tag
@param name Tag name
@return First String value found | [
"Returns",
"the",
"first",
"String",
"value",
"found",
"for",
"this",
"tag"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L211-L219 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.getFirstDateValue | public Date getFirstDateValue(String name) {
Object objs[] = getValues(name);
for (Object obj : objs) {
if (obj instanceof Date) {
return (Date) obj;
}
}
return null;
} | java | public Date getFirstDateValue(String name) {
Object objs[] = getValues(name);
for (Object obj : objs) {
if (obj instanceof Date) {
return (Date) obj;
}
}
return null;
} | [
"public",
"Date",
"getFirstDateValue",
"(",
"String",
"name",
")",
"{",
"Object",
"objs",
"[",
"]",
"=",
"getValues",
"(",
"name",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"objs",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"Date",
")",
"{",
"return... | Returns the first Date value found for this tag
@param name Tag name
@return First Date value found | [
"Returns",
"the",
"first",
"Date",
"value",
"found",
"for",
"this",
"tag"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L227-L235 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.getFirstLongValue | public Long getFirstLongValue(String name) {
Object objs[] = getValues(name);
for (Object obj : objs) {
if (obj instanceof Long) {
return (Long) obj;
}
}
return null;
} | java | public Long getFirstLongValue(String name) {
Object objs[] = getValues(name);
for (Object obj : objs) {
if (obj instanceof Long) {
return (Long) obj;
}
}
return null;
} | [
"public",
"Long",
"getFirstLongValue",
"(",
"String",
"name",
")",
"{",
"Object",
"objs",
"[",
"]",
"=",
"getValues",
"(",
"name",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"objs",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"Long",
")",
"{",
"return... | Returns the first Long value found for this tag
@param name Tag name
@return First long value found | [
"Returns",
"the",
"first",
"Long",
"value",
"found",
"for",
"this",
"tag"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L243-L251 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.getValues | public Object[] getValues(String name) {
XtraTag tag = getTagByName(name);
Object values[];
if (tag != null) {
values = new Object[tag.values.size()];
for (int i = 0; i < tag.values.size(); i++) {
values[i] = tag.values.elementAt(i).getValueAsObject();
}
} else {
values = new Object[0];
}
return values;
} | java | public Object[] getValues(String name) {
XtraTag tag = getTagByName(name);
Object values[];
if (tag != null) {
values = new Object[tag.values.size()];
for (int i = 0; i < tag.values.size(); i++) {
values[i] = tag.values.elementAt(i).getValueAsObject();
}
} else {
values = new Object[0];
}
return values;
} | [
"public",
"Object",
"[",
"]",
"getValues",
"(",
"String",
"name",
")",
"{",
"XtraTag",
"tag",
"=",
"getTagByName",
"(",
"name",
")",
";",
"Object",
"values",
"[",
"]",
";",
"if",
"(",
"tag",
"!=",
"null",
")",
"{",
"values",
"=",
"new",
"Object",
"... | Returns an array of values for this tag. Empty array when tag is not present
@param name Tag name to retrieve
@return Possibly empty array of values (possible types are String, Long, Date and byte[] ) | [
"Returns",
"an",
"array",
"of",
"values",
"for",
"this",
"tag",
".",
"Empty",
"array",
"when",
"tag",
"is",
"not",
"present"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L259-L271 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.setTagValues | public void setTagValues(String name, String values[]) {
removeTag(name);
XtraTag tag = new XtraTag(name);
for (int i = 0; i < values.length; i++) {
tag.values.addElement(new XtraValue(values[i]));
}
tags.addElement(tag);
} | java | public void setTagValues(String name, String values[]) {
removeTag(name);
XtraTag tag = new XtraTag(name);
for (int i = 0; i < values.length; i++) {
tag.values.addElement(new XtraValue(values[i]));
}
tags.addElement(tag);
} | [
"public",
"void",
"setTagValues",
"(",
"String",
"name",
",",
"String",
"values",
"[",
"]",
")",
"{",
"removeTag",
"(",
"name",
")",
";",
"XtraTag",
"tag",
"=",
"new",
"XtraTag",
"(",
"name",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
... | Removes and recreates tag using specified String values
@param name Tag name to replace
@param values New String values | [
"Removes",
"and",
"recreates",
"tag",
"using",
"specified",
"String",
"values"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L291-L298 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.setTagValue | public void setTagValue(String name, Date date) {
removeTag(name);
XtraTag tag = new XtraTag(name);
tag.values.addElement(new XtraValue(date));
tags.addElement(tag);
} | java | public void setTagValue(String name, Date date) {
removeTag(name);
XtraTag tag = new XtraTag(name);
tag.values.addElement(new XtraValue(date));
tags.addElement(tag);
} | [
"public",
"void",
"setTagValue",
"(",
"String",
"name",
",",
"Date",
"date",
")",
"{",
"removeTag",
"(",
"name",
")",
";",
"XtraTag",
"tag",
"=",
"new",
"XtraTag",
"(",
"name",
")",
";",
"tag",
".",
"values",
".",
"addElement",
"(",
"new",
"XtraValue",... | Removes and recreates tag using specified Date value
@param name Tag name to replace
@param date New Date value | [
"Removes",
"and",
"recreates",
"tag",
"using",
"specified",
"Date",
"value"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L316-L321 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java | XtraBox.setTagValue | public void setTagValue(String name, long value) {
removeTag(name);
XtraTag tag = new XtraTag(name);
tag.values.addElement(new XtraValue(value));
tags.addElement(tag);
} | java | public void setTagValue(String name, long value) {
removeTag(name);
XtraTag tag = new XtraTag(name);
tag.values.addElement(new XtraValue(value));
tags.addElement(tag);
} | [
"public",
"void",
"setTagValue",
"(",
"String",
"name",
",",
"long",
"value",
")",
"{",
"removeTag",
"(",
"name",
")",
";",
"XtraTag",
"tag",
"=",
"new",
"XtraTag",
"(",
"name",
")",
";",
"tag",
".",
"values",
".",
"addElement",
"(",
"new",
"XtraValue"... | Removes and recreates tag using specified Long value
@param name Tag name to replace
@param value New Long value | [
"Removes",
"and",
"recreates",
"tag",
"using",
"specified",
"Long",
"value"
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/microsoft/XtraBox.java#L329-L334 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/iso14496/part12/SampleToChunkBox.java | SampleToChunkBox.blowup | public long[] blowup(int chunkCount) {
long[] numberOfSamples = new long[chunkCount];
int j = 0;
List<SampleToChunkBox.Entry> sampleToChunkEntries = new LinkedList<Entry>(entries);
Collections.reverse(sampleToChunkEntries);
Iterator<Entry> iterator = sampleToChunkEntries.iterator();
SampleToChunkBox.Entry currentEntry = iterator.next();
for (int i = numberOfSamples.length; i > 1; i--) {
numberOfSamples[i - 1] = currentEntry.getSamplesPerChunk();
if (i == currentEntry.getFirstChunk()) {
currentEntry = iterator.next();
}
}
numberOfSamples[0] = currentEntry.getSamplesPerChunk();
return numberOfSamples;
} | java | public long[] blowup(int chunkCount) {
long[] numberOfSamples = new long[chunkCount];
int j = 0;
List<SampleToChunkBox.Entry> sampleToChunkEntries = new LinkedList<Entry>(entries);
Collections.reverse(sampleToChunkEntries);
Iterator<Entry> iterator = sampleToChunkEntries.iterator();
SampleToChunkBox.Entry currentEntry = iterator.next();
for (int i = numberOfSamples.length; i > 1; i--) {
numberOfSamples[i - 1] = currentEntry.getSamplesPerChunk();
if (i == currentEntry.getFirstChunk()) {
currentEntry = iterator.next();
}
}
numberOfSamples[0] = currentEntry.getSamplesPerChunk();
return numberOfSamples;
} | [
"public",
"long",
"[",
"]",
"blowup",
"(",
"int",
"chunkCount",
")",
"{",
"long",
"[",
"]",
"numberOfSamples",
"=",
"new",
"long",
"[",
"chunkCount",
"]",
";",
"int",
"j",
"=",
"0",
";",
"List",
"<",
"SampleToChunkBox",
".",
"Entry",
">",
"sampleToChun... | Decompresses the list of entries and returns the number of samples per chunk for
every single chunk.
@param chunkCount overall number of chunks
@return number of samples per chunk | [
"Decompresses",
"the",
"list",
"of",
"entries",
"and",
"returns",
"the",
"number",
"of",
"samples",
"per",
"chunk",
"for",
"every",
"single",
"chunk",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/iso14496/part12/SampleToChunkBox.java#L89-L105 | train |
sannies/mp4parser | isoparser/src/main/java/org/mp4parser/boxes/iso14496/part12/TimeToSampleBox.java | TimeToSampleBox.blowupTimeToSamples | public static synchronized long[] blowupTimeToSamples(List<TimeToSampleBox.Entry> entries) {
SoftReference<long[]> cacheEntry;
if ((cacheEntry = cache.get(entries)) != null) {
long[] cacheVal;
if ((cacheVal = cacheEntry.get()) != null) {
return cacheVal;
}
}
long numOfSamples = 0;
for (TimeToSampleBox.Entry entry : entries) {
numOfSamples += entry.getCount();
}
assert numOfSamples <= Integer.MAX_VALUE;
long[] decodingTime = new long[(int) numOfSamples];
int current = 0;
for (TimeToSampleBox.Entry entry : entries) {
for (int i = 0; i < entry.getCount(); i++) {
decodingTime[current++] = entry.getDelta();
}
}
cache.put(entries, new SoftReference<long[]>(decodingTime));
return decodingTime;
} | java | public static synchronized long[] blowupTimeToSamples(List<TimeToSampleBox.Entry> entries) {
SoftReference<long[]> cacheEntry;
if ((cacheEntry = cache.get(entries)) != null) {
long[] cacheVal;
if ((cacheVal = cacheEntry.get()) != null) {
return cacheVal;
}
}
long numOfSamples = 0;
for (TimeToSampleBox.Entry entry : entries) {
numOfSamples += entry.getCount();
}
assert numOfSamples <= Integer.MAX_VALUE;
long[] decodingTime = new long[(int) numOfSamples];
int current = 0;
for (TimeToSampleBox.Entry entry : entries) {
for (int i = 0; i < entry.getCount(); i++) {
decodingTime[current++] = entry.getDelta();
}
}
cache.put(entries, new SoftReference<long[]>(decodingTime));
return decodingTime;
} | [
"public",
"static",
"synchronized",
"long",
"[",
"]",
"blowupTimeToSamples",
"(",
"List",
"<",
"TimeToSampleBox",
".",
"Entry",
">",
"entries",
")",
"{",
"SoftReference",
"<",
"long",
"[",
"]",
">",
"cacheEntry",
";",
"if",
"(",
"(",
"cacheEntry",
"=",
"ca... | Decompresses the list of entries and returns the list of decoding times.
@param entries compressed entries
@return decoding time per sample | [
"Decompresses",
"the",
"list",
"of",
"entries",
"and",
"returns",
"the",
"list",
"of",
"decoding",
"times",
"."
] | 3382ff5d489363900f352a8da0f794a20ad3b063 | https://github.com/sannies/mp4parser/blob/3382ff5d489363900f352a8da0f794a20ad3b063/isoparser/src/main/java/org/mp4parser/boxes/iso14496/part12/TimeToSampleBox.java#L58-L83 | train |
VoltDB/voltdb | third_party/java/src/com/google_voltpatches/common/eventbus/SubscriberRegistry.java | SubscriberRegistry.register | void register(Object listener) {
Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener);
for (Map.Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
Class<?> eventType = entry.getKey();
Collection<Subscriber> eventMethodsInListener = entry.getValue();
CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
if (eventSubscribers == null) {
CopyOnWriteArraySet<Subscriber> newSet = new CopyOnWriteArraySet<Subscriber>();
eventSubscribers =
MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType, newSet), newSet);
}
eventSubscribers.addAll(eventMethodsInListener);
}
} | java | void register(Object listener) {
Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener);
for (Map.Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
Class<?> eventType = entry.getKey();
Collection<Subscriber> eventMethodsInListener = entry.getValue();
CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
if (eventSubscribers == null) {
CopyOnWriteArraySet<Subscriber> newSet = new CopyOnWriteArraySet<Subscriber>();
eventSubscribers =
MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType, newSet), newSet);
}
eventSubscribers.addAll(eventMethodsInListener);
}
} | [
"void",
"register",
"(",
"Object",
"listener",
")",
"{",
"Multimap",
"<",
"Class",
"<",
"?",
">",
",",
"Subscriber",
">",
"listenerMethods",
"=",
"findAllSubscribers",
"(",
"listener",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Class",
"<",
"?",
... | Registers all subscriber methods on the given listener object. | [
"Registers",
"all",
"subscriber",
"methods",
"on",
"the",
"given",
"listener",
"object",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/eventbus/SubscriberRegistry.java#L76-L93 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.deleteRow | public int deleteRow() {
// build the delete string
String deleteString = "DELETE FROM " + tableName
+ this.generatePKWhere();
PreparedStatement ps = null;
// System.out.println("delete string "+deleteString);
try {
// fill the question marks
ps = cConn.prepareStatement(deleteString);
ps.clearParameters();
int i;
for (int j = 0; j < primaryKeys.length; j++) {
ps.setObject(j + 1, resultRowPKs[aktRowNr][j]);
} // end of for (int i=0; i<primaryKeys.length; i++)
ps.executeUpdate();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return 0;
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {}
}
// delete the corresponding primary key values from resultRowPKs
numberOfResult--;
for (int i = aktRowNr; i < numberOfResult; i++) {
for (int j = 0; j < primaryKeys.length; j++) {
resultRowPKs[i][j] = resultRowPKs[i + 1][j];
}
}
// there are the following outcomes after deleting aktRowNr:
/*
A B C D E F
no rows left J N N N N N
one row left - J N J N N
deleted row was the last row - J J N N N
deleted row was the pre-last - - - - J N
first D X + D + *
. D X X D D
. D X +
last X
new numberOfResult 0 1 2 1 2 2
old aktRowNr 0 1 2 0 1 0
D - deleted row
X - any one row
+ - one or more rows
* - zero or more rows
*/
// A. return to the search panel and tell 'last row deleted' on the status line
// B. show the previous row and disable previous button
// C. show the previous row as akt row
// D. show akt row and disable next button
// E. show akt row and disable next button
// F. show akt row
// these actions reduce to the following actions for ZaurusEditor:
// 1. show search panel
// 2. disable previous button
// 3. disable next button
// 4. do nothing
// and 1,2,3,4 are the possible return codes
int actionCode;
if (numberOfResult == 0) {
// case A
actionCode = 1;
ZaurusEditor.printStatus("Last row was deleted.");
return actionCode;
} else if (numberOfResult == aktRowNr) {
// B or C
// new aktRow is previous row
aktRowNr--;
if (aktRowNr == 0) {
// B
actionCode = 2;
} else {
// C
actionCode = 4;
} // end of if (aktRowNr == 0)
} else {
// D, E, F
if (numberOfResult >= 2 && aktRowNr < numberOfResult - 1) {
// F
actionCode = 4;
} else {
actionCode = 3;
} // end of else
}
this.showAktRow();
ZaurusEditor.printStatus("Row was deleted.");
return actionCode;
} | java | public int deleteRow() {
// build the delete string
String deleteString = "DELETE FROM " + tableName
+ this.generatePKWhere();
PreparedStatement ps = null;
// System.out.println("delete string "+deleteString);
try {
// fill the question marks
ps = cConn.prepareStatement(deleteString);
ps.clearParameters();
int i;
for (int j = 0; j < primaryKeys.length; j++) {
ps.setObject(j + 1, resultRowPKs[aktRowNr][j]);
} // end of for (int i=0; i<primaryKeys.length; i++)
ps.executeUpdate();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return 0;
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {}
}
// delete the corresponding primary key values from resultRowPKs
numberOfResult--;
for (int i = aktRowNr; i < numberOfResult; i++) {
for (int j = 0; j < primaryKeys.length; j++) {
resultRowPKs[i][j] = resultRowPKs[i + 1][j];
}
}
// there are the following outcomes after deleting aktRowNr:
/*
A B C D E F
no rows left J N N N N N
one row left - J N J N N
deleted row was the last row - J J N N N
deleted row was the pre-last - - - - J N
first D X + D + *
. D X X D D
. D X +
last X
new numberOfResult 0 1 2 1 2 2
old aktRowNr 0 1 2 0 1 0
D - deleted row
X - any one row
+ - one or more rows
* - zero or more rows
*/
// A. return to the search panel and tell 'last row deleted' on the status line
// B. show the previous row and disable previous button
// C. show the previous row as akt row
// D. show akt row and disable next button
// E. show akt row and disable next button
// F. show akt row
// these actions reduce to the following actions for ZaurusEditor:
// 1. show search panel
// 2. disable previous button
// 3. disable next button
// 4. do nothing
// and 1,2,3,4 are the possible return codes
int actionCode;
if (numberOfResult == 0) {
// case A
actionCode = 1;
ZaurusEditor.printStatus("Last row was deleted.");
return actionCode;
} else if (numberOfResult == aktRowNr) {
// B or C
// new aktRow is previous row
aktRowNr--;
if (aktRowNr == 0) {
// B
actionCode = 2;
} else {
// C
actionCode = 4;
} // end of if (aktRowNr == 0)
} else {
// D, E, F
if (numberOfResult >= 2 && aktRowNr < numberOfResult - 1) {
// F
actionCode = 4;
} else {
actionCode = 3;
} // end of else
}
this.showAktRow();
ZaurusEditor.printStatus("Row was deleted.");
return actionCode;
} | [
"public",
"int",
"deleteRow",
"(",
")",
"{",
"// build the delete string",
"String",
"deleteString",
"=",
"\"DELETE FROM \"",
"+",
"tableName",
"+",
"this",
".",
"generatePKWhere",
"(",
")",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"// System.out.println(\"... | delete current row, answer special action codes, see comment below | [
"delete",
"current",
"row",
"answer",
"special",
"action",
"codes",
"see",
"comment",
"below"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L142-L261 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.getPrimaryKeysString | public String getPrimaryKeysString() {
String result = "";
for (int i = 0; i < primaryKeys.length; i++) {
if (result != "") {
result += ", ";
}
result += primaryKeys[i];
} // end of for (int i=0; i<primaryKeys.length; i++)
return result;
} | java | public String getPrimaryKeysString() {
String result = "";
for (int i = 0; i < primaryKeys.length; i++) {
if (result != "") {
result += ", ";
}
result += primaryKeys[i];
} // end of for (int i=0; i<primaryKeys.length; i++)
return result;
} | [
"public",
"String",
"getPrimaryKeysString",
"(",
")",
"{",
"String",
"result",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"primaryKeys",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"result",
"!=",
"\"\"",
")",
"{",
... | answer a String containing a String list of primary keys i. e. "pk1, pk2, pk3" | [
"answer",
"a",
"String",
"containing",
"a",
"String",
"list",
"of",
"primary",
"keys",
"i",
".",
"e",
".",
"pk1",
"pk2",
"pk3"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L264-L277 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.insertNewRow | public void insertNewRow() {
// reset all fields
for (int i = 0; i < komponente.length; i++) {
komponente[i].clearContent();
} // end of for (int i=0; i<komponente.length; i++)
// reset the field for the primary keys
for (int i = 0; i < primaryKeys.length; i++) {
komponente[pkColIndex[i]].setEditable(true);
}
ZaurusEditor.printStatus("enter a new row for table " + tableName);
} | java | public void insertNewRow() {
// reset all fields
for (int i = 0; i < komponente.length; i++) {
komponente[i].clearContent();
} // end of for (int i=0; i<komponente.length; i++)
// reset the field for the primary keys
for (int i = 0; i < primaryKeys.length; i++) {
komponente[pkColIndex[i]].setEditable(true);
}
ZaurusEditor.printStatus("enter a new row for table " + tableName);
} | [
"public",
"void",
"insertNewRow",
"(",
")",
"{",
"// reset all fields",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"komponente",
".",
"length",
";",
"i",
"++",
")",
"{",
"komponente",
"[",
"i",
"]",
".",
"clearContent",
"(",
")",
";",
"}",
"/... | open the panel to insert a new row into the table | [
"open",
"the",
"panel",
"to",
"insert",
"a",
"new",
"row",
"into",
"the",
"table"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L280-L293 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.saveChanges | public boolean saveChanges() {
// the initial settings of the textfields counts with one
// so a real change by the user needs as many changes as there are columns
// System.out.print("Anderungen in den Feldern: ");
// there are changes to the database
// memorize all columns which have been changed
int[] changedColumns = new int[columns.length];
int countChanged = 0;
// build the update string
String updateString = "";
for (int i = 0; i < columns.length; i++) {
if (komponente[i].hasChanged()) {
if (updateString != "") {
updateString += ", ";
}
updateString += columns[i] + "=?";
changedColumns[countChanged++] = i;
}
} // end of for (int i=0; i<columns.length; i++)
if (countChanged > 0) {
updateString = "UPDATE " + tableName + " SET " + updateString
+ this.generatePKWhere();
PreparedStatement ps = null;
// System.out.println("update "+updateString);
try {
// fill the question marks
ps = cConn.prepareStatement(updateString);
ps.clearParameters();
int i;
for (i = 0; i < countChanged; i++) {
ps.setObject(i + 1,
komponente[changedColumns[i]].getContent());
// System.out.print(" changed feld "+komponente[changedColumns[i]].getContent());
} // end of for (int i=0; i<countChanged; i++)
// System.out.println();
for (int j = 0; j < primaryKeys.length; j++) {
ps.setObject(i + j + 1, resultRowPKs[aktRowNr][j]);
} // end of for (int i=0; i<primaryKeys.length; i++)
ps.executeUpdate();
ZaurusEditor.printStatus("changed row was saved to table "
+ tableName);
return true;
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {}
}
} else {
// System.out.println("no changes");
return true;
} // end of if (changed)
} | java | public boolean saveChanges() {
// the initial settings of the textfields counts with one
// so a real change by the user needs as many changes as there are columns
// System.out.print("Anderungen in den Feldern: ");
// there are changes to the database
// memorize all columns which have been changed
int[] changedColumns = new int[columns.length];
int countChanged = 0;
// build the update string
String updateString = "";
for (int i = 0; i < columns.length; i++) {
if (komponente[i].hasChanged()) {
if (updateString != "") {
updateString += ", ";
}
updateString += columns[i] + "=?";
changedColumns[countChanged++] = i;
}
} // end of for (int i=0; i<columns.length; i++)
if (countChanged > 0) {
updateString = "UPDATE " + tableName + " SET " + updateString
+ this.generatePKWhere();
PreparedStatement ps = null;
// System.out.println("update "+updateString);
try {
// fill the question marks
ps = cConn.prepareStatement(updateString);
ps.clearParameters();
int i;
for (i = 0; i < countChanged; i++) {
ps.setObject(i + 1,
komponente[changedColumns[i]].getContent());
// System.out.print(" changed feld "+komponente[changedColumns[i]].getContent());
} // end of for (int i=0; i<countChanged; i++)
// System.out.println();
for (int j = 0; j < primaryKeys.length; j++) {
ps.setObject(i + j + 1, resultRowPKs[aktRowNr][j]);
} // end of for (int i=0; i<primaryKeys.length; i++)
ps.executeUpdate();
ZaurusEditor.printStatus("changed row was saved to table "
+ tableName);
return true;
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {}
}
} else {
// System.out.println("no changes");
return true;
} // end of if (changed)
} | [
"public",
"boolean",
"saveChanges",
"(",
")",
"{",
"// the initial settings of the textfields counts with one",
"// so a real change by the user needs as many changes as there are columns",
"// System.out.print(\"Anderungen in den Feldern: \");",
"// there are changes to the database",
"// memor... | answer true, if the update succeeds | [
"answer",
"true",
"if",
"the",
"update",
"succeeds"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L327-L400 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.saveNewRow | public boolean saveNewRow() {
// check the fields of the primary keys whether one is empty
boolean onePKempty = false;
int tmp;
PreparedStatement ps = null;
for (tmp = 0; tmp < primaryKeys.length; tmp++) {
if (komponente[pkColIndex[tmp]].getContent().equals("")) {
onePKempty = true;
break;
}
}
if (onePKempty) {
komponente[pkColIndex[tmp]].requestFocus();
ZaurusEditor.printStatus("no value for primary key "
+ primaryKeys[tmp]);
return false;
} // end of if (onePKempty)
// build the insert string
String insertString = "INSERT INTO " + tableName + " VALUES(";
for (int j = 0; j < columns.length; j++) {
if (j > 0) {
insertString += ", ";
}
insertString += "?";
} // end of for (int i=0; i<columns.length; i++)
insertString += ")";
// System.out.println("insert string "+insertString);
try {
// fill the question marks
ps = cConn.prepareStatement(insertString);
ps.clearParameters();
int i;
for (i = 0; i < columns.length; i++) {
ps.setObject(i + 1, komponente[i].getContent());
}
ps.executeUpdate();
ZaurusEditor.printStatus("new row was saved to table "
+ tableName);
return true;
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {}
}
} | java | public boolean saveNewRow() {
// check the fields of the primary keys whether one is empty
boolean onePKempty = false;
int tmp;
PreparedStatement ps = null;
for (tmp = 0; tmp < primaryKeys.length; tmp++) {
if (komponente[pkColIndex[tmp]].getContent().equals("")) {
onePKempty = true;
break;
}
}
if (onePKempty) {
komponente[pkColIndex[tmp]].requestFocus();
ZaurusEditor.printStatus("no value for primary key "
+ primaryKeys[tmp]);
return false;
} // end of if (onePKempty)
// build the insert string
String insertString = "INSERT INTO " + tableName + " VALUES(";
for (int j = 0; j < columns.length; j++) {
if (j > 0) {
insertString += ", ";
}
insertString += "?";
} // end of for (int i=0; i<columns.length; i++)
insertString += ")";
// System.out.println("insert string "+insertString);
try {
// fill the question marks
ps = cConn.prepareStatement(insertString);
ps.clearParameters();
int i;
for (i = 0; i < columns.length; i++) {
ps.setObject(i + 1, komponente[i].getContent());
}
ps.executeUpdate();
ZaurusEditor.printStatus("new row was saved to table "
+ tableName);
return true;
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {}
}
} | [
"public",
"boolean",
"saveNewRow",
"(",
")",
"{",
"// check the fields of the primary keys whether one is empty",
"boolean",
"onePKempty",
"=",
"false",
";",
"int",
"tmp",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"for",
"(",
"tmp",
"=",
"0",
";",
"tmp",
... | answer true, if saving succeeds | [
"answer",
"true",
"if",
"saving",
"succeeds"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L404-L470 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.searchRows | public int searchRows(String[] words, boolean allWords,
boolean ignoreCase, boolean noMatchWhole) {
// System.out.print("search in " + tableName + " for: ");
// for (int i=0; i < words.length; i++) {
// System.out.print(words[i]+", ");
// }
// System.out.println("allWords = "+allWords+", ignoreCase = "+ignoreCase+", noMatchWhole= "+noMatchWhole);
String where = this.generateWhere(words, allWords, ignoreCase,
noMatchWhole);
Vector temp = new Vector(20);
Statement stmt = null;
try {
stmt = cConn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT "
+ this.getPrimaryKeysString()
+ " FROM " + tableName + where);
while (rs.next()) {
Object[] pkValues = new Object[primaryKeys.length];
for (int i = 0; i < primaryKeys.length; i++) {
pkValues[i] = rs.getObject(pkColIndex[i] + 1);
} // end of for (int i=0; i<primaryKeys.length; i++)
temp.addElement(pkValues);
}
rs.close();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return -1;
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (SQLException e) {}
}
resultRowPKs = new Object[temp.size()][primaryKeys.length];
numberOfResult = temp.size();
for (int i = 0; i < primaryKeys.length; i++) {
for (int j = 0; j < temp.size(); j++) {
resultRowPKs[j][i] = ((Object[]) temp.elementAt(j))[i];
} // end of for (int j=0; j<temp.size(); j++)
} // end of for (int i=0; i<primaryKeys.length; i++)
// prepare statement for fetching the result rows for later use
String stmtString = "SELECT * FROM " + tableName;
try {
pStmt = cConn.prepareStatement(stmtString
+ this.generatePKWhere());
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
} // end of try-catch
// System.out.println("prepared statement: "+stmtString);
if (numberOfResult > 0) {
this.disablePKFields();
aktRowNr = 0;
this.showAktRow();
} // end of if (numberOfResult > 0)
// System.out.println("number of rows: "+numberOfResult);
return numberOfResult;
} | java | public int searchRows(String[] words, boolean allWords,
boolean ignoreCase, boolean noMatchWhole) {
// System.out.print("search in " + tableName + " for: ");
// for (int i=0; i < words.length; i++) {
// System.out.print(words[i]+", ");
// }
// System.out.println("allWords = "+allWords+", ignoreCase = "+ignoreCase+", noMatchWhole= "+noMatchWhole);
String where = this.generateWhere(words, allWords, ignoreCase,
noMatchWhole);
Vector temp = new Vector(20);
Statement stmt = null;
try {
stmt = cConn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT "
+ this.getPrimaryKeysString()
+ " FROM " + tableName + where);
while (rs.next()) {
Object[] pkValues = new Object[primaryKeys.length];
for (int i = 0; i < primaryKeys.length; i++) {
pkValues[i] = rs.getObject(pkColIndex[i] + 1);
} // end of for (int i=0; i<primaryKeys.length; i++)
temp.addElement(pkValues);
}
rs.close();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
return -1;
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (SQLException e) {}
}
resultRowPKs = new Object[temp.size()][primaryKeys.length];
numberOfResult = temp.size();
for (int i = 0; i < primaryKeys.length; i++) {
for (int j = 0; j < temp.size(); j++) {
resultRowPKs[j][i] = ((Object[]) temp.elementAt(j))[i];
} // end of for (int j=0; j<temp.size(); j++)
} // end of for (int i=0; i<primaryKeys.length; i++)
// prepare statement for fetching the result rows for later use
String stmtString = "SELECT * FROM " + tableName;
try {
pStmt = cConn.prepareStatement(stmtString
+ this.generatePKWhere());
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
} // end of try-catch
// System.out.println("prepared statement: "+stmtString);
if (numberOfResult > 0) {
this.disablePKFields();
aktRowNr = 0;
this.showAktRow();
} // end of if (numberOfResult > 0)
// System.out.println("number of rows: "+numberOfResult);
return numberOfResult;
} | [
"public",
"int",
"searchRows",
"(",
"String",
"[",
"]",
"words",
",",
"boolean",
"allWords",
",",
"boolean",
"ignoreCase",
",",
"boolean",
"noMatchWhole",
")",
"{",
"// System.out.print(\"search in \" + tableName + \" for: \");",
"// for (int i=0; i < words.length; i++) {",
... | answer the number of found rows, -1 if there is an SQL exception | [
"answer",
"the",
"number",
"of",
"found",
"rows",
"-",
"1",
"if",
"there",
"is",
"an",
"SQL",
"exception"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L475-L548 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.disablePKFields | private void disablePKFields() {
for (int i = 0; i < primaryKeys.length; i++) {
komponente[pkColIndex[i]].setEditable(false);
} // end of for (int i=0; i<columns.length; i++)
} | java | private void disablePKFields() {
for (int i = 0; i < primaryKeys.length; i++) {
komponente[pkColIndex[i]].setEditable(false);
} // end of for (int i=0; i<columns.length; i++)
} | [
"private",
"void",
"disablePKFields",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"primaryKeys",
".",
"length",
";",
"i",
"++",
")",
"{",
"komponente",
"[",
"pkColIndex",
"[",
"i",
"]",
"]",
".",
"setEditable",
"(",
"false",
")"... | set all fields for primary keys to not editable | [
"set",
"all",
"fields",
"for",
"primary",
"keys",
"to",
"not",
"editable"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L578-L583 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.fillZChoice | private void fillZChoice(ZaurusChoice zc, String tab, String col) {
Statement stmt = null;
try {
if (cConn == null) {
return;
}
stmt = cConn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM " + tab
+ " ORDER BY " + col);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int colIndex = rs.findColumn(col);
while (rs.next()) {
String tmp = "";
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) {
tmp += "; ";
}
tmp += rs.getString(i);
} // end of for (int i=1; i<=numberOfColumns; i++)
zc.add(tmp, rs.getString(colIndex));
}
rs.close();
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (SQLException e) {}
}
} | java | private void fillZChoice(ZaurusChoice zc, String tab, String col) {
Statement stmt = null;
try {
if (cConn == null) {
return;
}
stmt = cConn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM " + tab
+ " ORDER BY " + col);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int colIndex = rs.findColumn(col);
while (rs.next()) {
String tmp = "";
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) {
tmp += "; ";
}
tmp += rs.getString(i);
} // end of for (int i=1; i<=numberOfColumns; i++)
zc.add(tmp, rs.getString(colIndex));
}
rs.close();
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (SQLException e) {}
}
} | [
"private",
"void",
"fillZChoice",
"(",
"ZaurusChoice",
"zc",
",",
"String",
"tab",
",",
"String",
"col",
")",
"{",
"Statement",
"stmt",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"cConn",
"==",
"null",
")",
"{",
"return",
";",
"}",
"stmt",
"=",
"cConn"... | and the column values as values | [
"and",
"the",
"column",
"values",
"as",
"values"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L588-L629 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.fetchColumns | private void fetchColumns() {
Vector temp = new Vector(20);
Vector tempType = new Vector(20);
try {
if (cConn == null) {
return;
}
if (dbmeta == null) {
dbmeta = cConn.getMetaData();
}
ResultSet colList = dbmeta.getColumns(null, null, tableName, "%");
while (colList.next()) {
temp.addElement(colList.getString("COLUMN_NAME"));
tempType.addElement(new Short(colList.getShort("DATA_TYPE")));
}
colList.close();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
}
columns = new String[temp.size()];
temp.copyInto(columns);
columnTypes = new short[temp.size()];
for (int i = 0; i < columnTypes.length; i++) {
columnTypes[i] = ((Short) tempType.elementAt(i)).shortValue();
}
} | java | private void fetchColumns() {
Vector temp = new Vector(20);
Vector tempType = new Vector(20);
try {
if (cConn == null) {
return;
}
if (dbmeta == null) {
dbmeta = cConn.getMetaData();
}
ResultSet colList = dbmeta.getColumns(null, null, tableName, "%");
while (colList.next()) {
temp.addElement(colList.getString("COLUMN_NAME"));
tempType.addElement(new Short(colList.getShort("DATA_TYPE")));
}
colList.close();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
}
columns = new String[temp.size()];
temp.copyInto(columns);
columnTypes = new short[temp.size()];
for (int i = 0; i < columnTypes.length; i++) {
columnTypes[i] = ((Short) tempType.elementAt(i)).shortValue();
}
} | [
"private",
"void",
"fetchColumns",
"(",
")",
"{",
"Vector",
"temp",
"=",
"new",
"Vector",
"(",
"20",
")",
";",
"Vector",
"tempType",
"=",
"new",
"Vector",
"(",
"20",
")",
";",
"try",
"{",
"if",
"(",
"cConn",
"==",
"null",
")",
"{",
"return",
";",
... | fetch all column names | [
"fetch",
"all",
"column",
"names"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L632-L667 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.generateWhere | private String generateWhere(String[] words, boolean allWords,
boolean ignoreCase, boolean noMatchWhole) {
String result = "";
// if all words must match use AND between the different conditions
String join;
if (allWords) {
join = " AND ";
} else {
join = " OR ";
} // end of else
for (int wordInd = 0; wordInd < words.length; wordInd++) {
String oneCondition = "";
for (int col = 0; col < columns.length; col++) {
if (oneCondition != "") {
oneCondition += " OR ";
}
if (ignoreCase) {
if (noMatchWhole) {
oneCondition += "LOWER(" + columns[col] + ") LIKE '%"
+ words[wordInd].toLowerCase() + "%'";
} else {
oneCondition += "LOWER(" + columns[col] + ") LIKE '"
+ words[wordInd].toLowerCase() + "'";
}
} else {
if (noMatchWhole) {
oneCondition += columns[col] + " LIKE '%"
+ words[wordInd] + "%'";
} else {
oneCondition += columns[col] + " LIKE '"
+ words[wordInd] + "'";
}
}
}
if (result != "") {
result += join;
}
result += "(" + oneCondition + ")";
}
if (result != "") {
result = " WHERE " + result;
} // end of if (result != "")
// System.out.println("result: "+result);
return result;
} | java | private String generateWhere(String[] words, boolean allWords,
boolean ignoreCase, boolean noMatchWhole) {
String result = "";
// if all words must match use AND between the different conditions
String join;
if (allWords) {
join = " AND ";
} else {
join = " OR ";
} // end of else
for (int wordInd = 0; wordInd < words.length; wordInd++) {
String oneCondition = "";
for (int col = 0; col < columns.length; col++) {
if (oneCondition != "") {
oneCondition += " OR ";
}
if (ignoreCase) {
if (noMatchWhole) {
oneCondition += "LOWER(" + columns[col] + ") LIKE '%"
+ words[wordInd].toLowerCase() + "%'";
} else {
oneCondition += "LOWER(" + columns[col] + ") LIKE '"
+ words[wordInd].toLowerCase() + "'";
}
} else {
if (noMatchWhole) {
oneCondition += columns[col] + " LIKE '%"
+ words[wordInd] + "%'";
} else {
oneCondition += columns[col] + " LIKE '"
+ words[wordInd] + "'";
}
}
}
if (result != "") {
result += join;
}
result += "(" + oneCondition + ")";
}
if (result != "") {
result = " WHERE " + result;
} // end of if (result != "")
// System.out.println("result: "+result);
return result;
} | [
"private",
"String",
"generateWhere",
"(",
"String",
"[",
"]",
"words",
",",
"boolean",
"allWords",
",",
"boolean",
"ignoreCase",
",",
"boolean",
"noMatchWhole",
")",
"{",
"String",
"result",
"=",
"\"\"",
";",
"// if all words must match use AND between the different ... | generate the Where-condition for the words | [
"generate",
"the",
"Where",
"-",
"condition",
"for",
"the",
"words"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L807-L861 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.getColIndex | private int getColIndex(String name) {
for (int i = 0; i < columns.length; i++) {
if (name.equals(columns[i])) {
return i;
} // end of if (name.equals(columns[i]))
} // end of for (int i=0; i<columns.length; i++)
return -1;
} | java | private int getColIndex(String name) {
for (int i = 0; i < columns.length; i++) {
if (name.equals(columns[i])) {
return i;
} // end of if (name.equals(columns[i]))
} // end of for (int i=0; i<columns.length; i++)
return -1;
} | [
"private",
"int",
"getColIndex",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columns",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"name",
".",
"equals",
"(",
"columns",
"[",
"i",
"]",
")",
")",
... | answer the index of the column named name in the actual table | [
"answer",
"the",
"index",
"of",
"the",
"column",
"named",
"name",
"in",
"the",
"actual",
"table"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L864-L873 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.getColIndex | private int getColIndex(String colName, String tabName) {
int ordPos = 0;
try {
if (cConn == null) {
return -1;
}
if (dbmeta == null) {
dbmeta = cConn.getMetaData();
}
ResultSet colList = dbmeta.getColumns(null, null, tabName,
colName);
colList.next();
ordPos = colList.getInt("ORDINAL_POSITION");
colList.close();
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
}
return ordPos - 1;
} | java | private int getColIndex(String colName, String tabName) {
int ordPos = 0;
try {
if (cConn == null) {
return -1;
}
if (dbmeta == null) {
dbmeta = cConn.getMetaData();
}
ResultSet colList = dbmeta.getColumns(null, null, tabName,
colName);
colList.next();
ordPos = colList.getInt("ORDINAL_POSITION");
colList.close();
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
}
return ordPos - 1;
} | [
"private",
"int",
"getColIndex",
"(",
"String",
"colName",
",",
"String",
"tabName",
")",
"{",
"int",
"ordPos",
"=",
"0",
";",
"try",
"{",
"if",
"(",
"cConn",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"dbmeta",
"==",
"null",
... | answer the index of the column named colName in the table tabName | [
"answer",
"the",
"index",
"of",
"the",
"column",
"named",
"colName",
"in",
"the",
"table",
"tabName"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L876-L902 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.getConstraintIndex | private int getConstraintIndex(int colIndex) {
for (int i = 0; i < imColIndex.length; i++) {
for (int j = 0; j < imColIndex[i].length; j++) {
if (colIndex == imColIndex[i][j]) {
return i;
} // end of if (col == imColIndex[i][j])
} // end of for (int j=0; j<imColIndex[i].length; j++)
} // end of for (int i=0; i<imColIndex.length; i++)
return -1;
} | java | private int getConstraintIndex(int colIndex) {
for (int i = 0; i < imColIndex.length; i++) {
for (int j = 0; j < imColIndex[i].length; j++) {
if (colIndex == imColIndex[i][j]) {
return i;
} // end of if (col == imColIndex[i][j])
} // end of for (int j=0; j<imColIndex[i].length; j++)
} // end of for (int i=0; i<imColIndex.length; i++)
return -1;
} | [
"private",
"int",
"getConstraintIndex",
"(",
"int",
"colIndex",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"imColIndex",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"imColIndex",
"[",
... | answer -1, if the column is not part of any constraint | [
"answer",
"-",
"1",
"if",
"the",
"column",
"is",
"not",
"part",
"of",
"any",
"constraint"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L906-L917 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java | ZaurusTableForm.showAktRow | private void showAktRow() {
try {
pStmt.clearParameters();
for (int i = 0; i < primaryKeys.length; i++) {
pStmt.setObject(i + 1, resultRowPKs[aktRowNr][i]);
} // end of for (int i=0; i<primaryKeys.length; i++)
ResultSet rs = pStmt.executeQuery();
rs.next();
for (int i = 0; i < columns.length; i++) {
komponente[i].setContent(rs.getString(i + 1));
} // end of for (int i=0; i<primaryKeys.length; i++)
rs.close();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
} // end of try-catch
for (int i = 0; i < columns.length; i++) {
komponente[i].clearChanges();
}
} | java | private void showAktRow() {
try {
pStmt.clearParameters();
for (int i = 0; i < primaryKeys.length; i++) {
pStmt.setObject(i + 1, resultRowPKs[aktRowNr][i]);
} // end of for (int i=0; i<primaryKeys.length; i++)
ResultSet rs = pStmt.executeQuery();
rs.next();
for (int i = 0; i < columns.length; i++) {
komponente[i].setContent(rs.getString(i + 1));
} // end of for (int i=0; i<primaryKeys.length; i++)
rs.close();
} catch (SQLException e) {
ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
} // end of try-catch
for (int i = 0; i < columns.length; i++) {
komponente[i].clearChanges();
}
} | [
"private",
"void",
"showAktRow",
"(",
")",
"{",
"try",
"{",
"pStmt",
".",
"clearParameters",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"primaryKeys",
".",
"length",
";",
"i",
"++",
")",
"{",
"pStmt",
".",
"setObject",
"(",
"... | get and show the values of the actual row in the GUI | [
"get",
"and",
"show",
"the",
"values",
"of",
"the",
"actual",
"row",
"in",
"the",
"GUI"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/util/ZaurusTableForm.java#L982-L1007 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/ExpressionArithmetic.java | ExpressionArithmetic.voltConvertBinaryLiteralOperandsToBigint | private void voltConvertBinaryLiteralOperandsToBigint() {
// Strange that CONCAT is an arithmetic operator.
// You could imagine using it for VARBINARY, so
// definitely don't convert its operands to BIGINT!
assert(opType != OpTypes.CONCAT);
for (int i = 0; i < nodes.length; ++i) {
Expression e = nodes[i];
ExpressionValue.voltMutateToBigintType(e, this, i);
}
} | java | private void voltConvertBinaryLiteralOperandsToBigint() {
// Strange that CONCAT is an arithmetic operator.
// You could imagine using it for VARBINARY, so
// definitely don't convert its operands to BIGINT!
assert(opType != OpTypes.CONCAT);
for (int i = 0; i < nodes.length; ++i) {
Expression e = nodes[i];
ExpressionValue.voltMutateToBigintType(e, this, i);
}
} | [
"private",
"void",
"voltConvertBinaryLiteralOperandsToBigint",
"(",
")",
"{",
"// Strange that CONCAT is an arithmetic operator.",
"// You could imagine using it for VARBINARY, so",
"// definitely don't convert its operands to BIGINT!",
"assert",
"(",
"opType",
"!=",
"OpTypes",
".",
"C... | A VoltDB extension to use X'..' as a numeric value | [
"A",
"VoltDB",
"extension",
"to",
"use",
"X",
"..",
"as",
"a",
"numeric",
"value"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/ExpressionArithmetic.java#L446-L456 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/RangeVariable.java | RangeVariable.findColumn | public int findColumn(String tableName, String columnName) {
// The namedJoinColumnExpressions are ExpressionColumn objects
// for columns named in USING conditions. Each range variable
// has a possibly empty list of these. If two range variables are
// operands of a join with a USING condition, both get the same list
// of USING columns. In our semantics the query
// select T2.C from T1 join T2 using(C);
// selects T2.C. This is not standard behavior, but it seems to
// be common to mysql and postgresql. The query
// select C from T1 join T2 using(C);
// selects the C from T1 or T2, since the using clause says
// they will have the same value. In the query
// select C from T1 join T2 using(C), T3;
// where T3 has a column named C, there is an ambiguity, since
// the first join tree (T1 join T2 using(C)) has a column named C and
// T3 has another C column. In this case we need the T1.C notation.
// The query
// select T1.C from T1 join T2 using(C), T3;
// will select the C from the first join tree, and
// select T3.C from T1 join T2 using(C), T3;
// will select the C from the second join tree, which is just T3.
// If we don't have a table name and there are some USING columns,
// then look into them. If the name is in the USING columns, it
// is not in this range variable. The function getColumnExpression
// will fetch this using variable in another search.
if (namedJoinColumnExpressions != null
&& tableName == null
&& namedJoinColumnExpressions.containsKey(columnName)) {
return -1;
}
if (variables != null) {
return variables.getIndex(columnName);
} else if (columnAliases != null) {
return columnAliases.getIndex(columnName);
} else {
return rangeTable.findColumn(columnName);
}
} | java | public int findColumn(String tableName, String columnName) {
// The namedJoinColumnExpressions are ExpressionColumn objects
// for columns named in USING conditions. Each range variable
// has a possibly empty list of these. If two range variables are
// operands of a join with a USING condition, both get the same list
// of USING columns. In our semantics the query
// select T2.C from T1 join T2 using(C);
// selects T2.C. This is not standard behavior, but it seems to
// be common to mysql and postgresql. The query
// select C from T1 join T2 using(C);
// selects the C from T1 or T2, since the using clause says
// they will have the same value. In the query
// select C from T1 join T2 using(C), T3;
// where T3 has a column named C, there is an ambiguity, since
// the first join tree (T1 join T2 using(C)) has a column named C and
// T3 has another C column. In this case we need the T1.C notation.
// The query
// select T1.C from T1 join T2 using(C), T3;
// will select the C from the first join tree, and
// select T3.C from T1 join T2 using(C), T3;
// will select the C from the second join tree, which is just T3.
// If we don't have a table name and there are some USING columns,
// then look into them. If the name is in the USING columns, it
// is not in this range variable. The function getColumnExpression
// will fetch this using variable in another search.
if (namedJoinColumnExpressions != null
&& tableName == null
&& namedJoinColumnExpressions.containsKey(columnName)) {
return -1;
}
if (variables != null) {
return variables.getIndex(columnName);
} else if (columnAliases != null) {
return columnAliases.getIndex(columnName);
} else {
return rangeTable.findColumn(columnName);
}
} | [
"public",
"int",
"findColumn",
"(",
"String",
"tableName",
",",
"String",
"columnName",
")",
"{",
"// The namedJoinColumnExpressions are ExpressionColumn objects",
"// for columns named in USING conditions. Each range variable",
"// has a possibly empty list of these. If two range variab... | Returns the index for the column given the column's table name
and column name. If the table name is null, there is no table
name specified. For example, in a query "select C from T" there
is no table name, so tableName would be null. In the query
"select T.C from T" tableName would be the string "T". Don't
return any column found in a USING join condition.
@param tableName
@param columnName
@return the column index or -1 if the column name is in a using list. | [
"Returns",
"the",
"index",
"for",
"the",
"column",
"given",
"the",
"column",
"s",
"table",
"name",
"and",
"column",
"name",
".",
"If",
"the",
"table",
"name",
"is",
"null",
"there",
"is",
"no",
"table",
"name",
"specified",
".",
"For",
"example",
"in",
... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/RangeVariable.java#L244-L283 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/RangeVariable.java | RangeVariable.addIndexCondition | void addIndexCondition(Expression[] exprList, Index index, int colCount,
boolean isJoin) {
// VoltDB extension
if (rangeIndex == index && isJoinIndex && (!isJoin) &&
(multiColumnCount > 0) && (colCount == 0)) {
// This is one particular set of conditions which broke the classification of
// ON and WHERE clauses.
return;
}
// End of VoltDB extension
rangeIndex = index;
isJoinIndex = isJoin;
for (int i = 0; i < colCount; i++) {
Expression e = exprList[i];
indexEndCondition =
ExpressionLogical.andExpressions(indexEndCondition, e);
}
if (colCount == 1) {
indexCondition = exprList[0];
} else {
findFirstExpressions = exprList;
isMultiFindFirst = true;
multiColumnCount = colCount;
}
} | java | void addIndexCondition(Expression[] exprList, Index index, int colCount,
boolean isJoin) {
// VoltDB extension
if (rangeIndex == index && isJoinIndex && (!isJoin) &&
(multiColumnCount > 0) && (colCount == 0)) {
// This is one particular set of conditions which broke the classification of
// ON and WHERE clauses.
return;
}
// End of VoltDB extension
rangeIndex = index;
isJoinIndex = isJoin;
for (int i = 0; i < colCount; i++) {
Expression e = exprList[i];
indexEndCondition =
ExpressionLogical.andExpressions(indexEndCondition, e);
}
if (colCount == 1) {
indexCondition = exprList[0];
} else {
findFirstExpressions = exprList;
isMultiFindFirst = true;
multiColumnCount = colCount;
}
} | [
"void",
"addIndexCondition",
"(",
"Expression",
"[",
"]",
"exprList",
",",
"Index",
"index",
",",
"int",
"colCount",
",",
"boolean",
"isJoin",
")",
"{",
"// VoltDB extension",
"if",
"(",
"rangeIndex",
"==",
"index",
"&&",
"isJoinIndex",
"&&",
"(",
"!",
"isJo... | Only multiple EQUAL conditions are used
@param exprList list of expressions
@param index Index to use
@param isJoin whether a join or not | [
"Only",
"multiple",
"EQUAL",
"conditions",
"are",
"used"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/RangeVariable.java#L548-L575 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/HsqlNameManager.java | HsqlNameManager.getSubqueryTableName | public HsqlName getSubqueryTableName() {
HsqlName hsqlName = new HsqlName(this, SqlInvariants.SYSTEM_SUBQUERY,
false, SchemaObject.TABLE);
hsqlName.schema = SqlInvariants.SYSTEM_SCHEMA_HSQLNAME;
return hsqlName;
} | java | public HsqlName getSubqueryTableName() {
HsqlName hsqlName = new HsqlName(this, SqlInvariants.SYSTEM_SUBQUERY,
false, SchemaObject.TABLE);
hsqlName.schema = SqlInvariants.SYSTEM_SCHEMA_HSQLNAME;
return hsqlName;
} | [
"public",
"HsqlName",
"getSubqueryTableName",
"(",
")",
"{",
"HsqlName",
"hsqlName",
"=",
"new",
"HsqlName",
"(",
"this",
",",
"SqlInvariants",
".",
"SYSTEM_SUBQUERY",
",",
"false",
",",
"SchemaObject",
".",
"TABLE",
")",
";",
"hsqlName",
".",
"schema",
"=",
... | Same name string but different objects and serial number | [
"Same",
"name",
"string",
"but",
"different",
"objects",
"and",
"serial",
"number"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/HsqlNameManager.java#L187-L195 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/HsqlNameManager.java | HsqlNameManager.getAutoColumnName | static public HsqlName getAutoColumnName(int i) {
if (i < autoColumnNames.length) {
return autoColumnNames[i];
}
return new HsqlName(staticManager, makeAutoColumnName("C_", i), 0, false);
} | java | static public HsqlName getAutoColumnName(int i) {
if (i < autoColumnNames.length) {
return autoColumnNames[i];
}
return new HsqlName(staticManager, makeAutoColumnName("C_", i), 0, false);
} | [
"static",
"public",
"HsqlName",
"getAutoColumnName",
"(",
"int",
"i",
")",
"{",
"if",
"(",
"i",
"<",
"autoColumnNames",
".",
"length",
")",
"{",
"return",
"autoColumnNames",
"[",
"i",
"]",
";",
"}",
"return",
"new",
"HsqlName",
"(",
"staticManager",
",",
... | Column index i is 0 based, returns 1 based numbered column. | [
"Column",
"index",
"i",
"is",
"0",
"based",
"returns",
"1",
"based",
"numbered",
"column",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/HsqlNameManager.java#L212-L219 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/RefCapablePropertyResourceBundle.java | RefCapablePropertyResourceBundle.getString | public String getString(String key) {
String value = wrappedBundle.getString(key);
if (value.length() < 1) {
value = getStringFromFile(key);
// For conciseness and sanity, get rid of all \r's so that \n
// will definitively be our line breaks.
if (value.indexOf('\r') > -1)
value = value.replaceAll("\\Q\r\n", "\n")
.replaceAll("\\Q\r", "\n");
if (value.length() > 0 && value.charAt(value.length() - 1) == '\n')
value = value.substring(0, value.length() - 1);
}
return RefCapablePropertyResourceBundle.toNativeLs(value);
} | java | public String getString(String key) {
String value = wrappedBundle.getString(key);
if (value.length() < 1) {
value = getStringFromFile(key);
// For conciseness and sanity, get rid of all \r's so that \n
// will definitively be our line breaks.
if (value.indexOf('\r') > -1)
value = value.replaceAll("\\Q\r\n", "\n")
.replaceAll("\\Q\r", "\n");
if (value.length() > 0 && value.charAt(value.length() - 1) == '\n')
value = value.substring(0, value.length() - 1);
}
return RefCapablePropertyResourceBundle.toNativeLs(value);
} | [
"public",
"String",
"getString",
"(",
"String",
"key",
")",
"{",
"String",
"value",
"=",
"wrappedBundle",
".",
"getString",
"(",
"key",
")",
";",
"if",
"(",
"value",
".",
"length",
"(",
")",
"<",
"1",
")",
"{",
"value",
"=",
"getStringFromFile",
"(",
... | Returns value defined in this RefCapablePropertyResourceBundle's
.properties file, unless that value is empty.
If the value in the .properties file is empty, then this returns
the entire contents of the referenced text file.
@see ResourceBundle#getString(String) | [
"Returns",
"value",
"defined",
"in",
"this",
"RefCapablePropertyResourceBundle",
"s",
".",
"properties",
"file",
"unless",
"that",
"value",
"is",
"empty",
".",
"If",
"the",
"value",
"in",
"the",
".",
"properties",
"file",
"is",
"empty",
"then",
"this",
"return... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/RefCapablePropertyResourceBundle.java#L309-L322 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/RefCapablePropertyResourceBundle.java | RefCapablePropertyResourceBundle.getRef | static private RefCapablePropertyResourceBundle getRef(String baseName,
ResourceBundle rb, ClassLoader loader) {
if (!(rb instanceof PropertyResourceBundle))
throw new MissingResourceException(
"Found a Resource Bundle, but it is a "
+ rb.getClass().getName(),
PropertyResourceBundle.class.getName(), null);
if (allBundles.containsKey(rb))
return (RefCapablePropertyResourceBundle) allBundles.get(rb);
RefCapablePropertyResourceBundle newPRAFP =
new RefCapablePropertyResourceBundle(baseName,
(PropertyResourceBundle) rb, loader);
allBundles.put(rb, newPRAFP);
return newPRAFP;
} | java | static private RefCapablePropertyResourceBundle getRef(String baseName,
ResourceBundle rb, ClassLoader loader) {
if (!(rb instanceof PropertyResourceBundle))
throw new MissingResourceException(
"Found a Resource Bundle, but it is a "
+ rb.getClass().getName(),
PropertyResourceBundle.class.getName(), null);
if (allBundles.containsKey(rb))
return (RefCapablePropertyResourceBundle) allBundles.get(rb);
RefCapablePropertyResourceBundle newPRAFP =
new RefCapablePropertyResourceBundle(baseName,
(PropertyResourceBundle) rb, loader);
allBundles.put(rb, newPRAFP);
return newPRAFP;
} | [
"static",
"private",
"RefCapablePropertyResourceBundle",
"getRef",
"(",
"String",
"baseName",
",",
"ResourceBundle",
"rb",
",",
"ClassLoader",
"loader",
")",
"{",
"if",
"(",
"!",
"(",
"rb",
"instanceof",
"PropertyResourceBundle",
")",
")",
"throw",
"new",
"Missing... | Return a ref to a new or existing RefCapablePropertyResourceBundle,
or throw a MissingResourceException. | [
"Return",
"a",
"ref",
"to",
"a",
"new",
"or",
"existing",
"RefCapablePropertyResourceBundle",
"or",
"throw",
"a",
"MissingResourceException",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/RefCapablePropertyResourceBundle.java#L364-L378 | train |
VoltDB/voltdb | src/frontend/org/voltdb/planner/microoptimizations/ReplaceWithIndexLimit.java | ReplaceWithIndexLimit.checkPureColumnIndex | private static boolean checkPureColumnIndex(Index index, int aggCol, List<AbstractExpression> filterExprs) {
boolean found = false;
// all left child of filterExprs must be of type TupleValueExpression in equality comparison
for (AbstractExpression expr : filterExprs) {
if (expr.getExpressionType() != ExpressionType.COMPARE_EQUAL) {
return false;
}
if (!(expr.getLeft() instanceof TupleValueExpression)) {
return false;
}
if (((TupleValueExpression)expr.getLeft()).getColumnIndex() == aggCol) {
found = true;
}
}
if (found) {
return true;
}
if (index.getColumns().size() > filterExprs.size()) {
List<ColumnRef> indexedColRefs = CatalogUtil.getSortedCatalogItems(index.getColumns(), "index");
if (indexedColRefs.get(filterExprs.size()).getColumn().getIndex() == aggCol) {
return true;
}
}
return false;
} | java | private static boolean checkPureColumnIndex(Index index, int aggCol, List<AbstractExpression> filterExprs) {
boolean found = false;
// all left child of filterExprs must be of type TupleValueExpression in equality comparison
for (AbstractExpression expr : filterExprs) {
if (expr.getExpressionType() != ExpressionType.COMPARE_EQUAL) {
return false;
}
if (!(expr.getLeft() instanceof TupleValueExpression)) {
return false;
}
if (((TupleValueExpression)expr.getLeft()).getColumnIndex() == aggCol) {
found = true;
}
}
if (found) {
return true;
}
if (index.getColumns().size() > filterExprs.size()) {
List<ColumnRef> indexedColRefs = CatalogUtil.getSortedCatalogItems(index.getColumns(), "index");
if (indexedColRefs.get(filterExprs.size()).getColumn().getIndex() == aggCol) {
return true;
}
}
return false;
} | [
"private",
"static",
"boolean",
"checkPureColumnIndex",
"(",
"Index",
"index",
",",
"int",
"aggCol",
",",
"List",
"<",
"AbstractExpression",
">",
"filterExprs",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"// all left child of filterExprs must be of type TupleValue... | or all filters compose the complete set of prefix key components | [
"or",
"all",
"filters",
"compose",
"the",
"complete",
"set",
"of",
"prefix",
"key",
"components"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/microoptimizations/ReplaceWithIndexLimit.java#L416-L445 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.writeHashinatorConfig | public static Runnable writeHashinatorConfig(
InstanceId instId,
String path,
String nonce,
int hostId,
HashinatorSnapshotData hashData,
boolean isTruncationSnapshot)
throws IOException
{
final File file = new VoltFile(path, constructHashinatorConfigFilenameForNonce(nonce, hostId));
if (file.exists()) {
if (!file.delete()) {
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to delete old hash file for truncation snapshot");
}
throw new IOException("Unable to replace existing hashinator config " + file);
}
}
boolean success = false;
try {
final FileOutputStream fos = new FileOutputStream(file);
ByteBuffer fileBuffer = hashData.saveToBuffer(instId);
fos.getChannel().write(fileBuffer);
success = true;
return new Runnable()
{
@Override
public void run()
{
try {
fos.getChannel().force(true);
}
catch (IOException e) {
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to create hash file for truncation snapshot",
true, e);
}
throw new RuntimeException(e);
}
finally {
try {
fos.close();
}
catch (IOException e) {
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to create hash file for truncation snapshot",
true, e);
}
throw new RuntimeException(e);
}
}
}
};
}
finally {
if (!success) {
file.delete();
}
}
} | java | public static Runnable writeHashinatorConfig(
InstanceId instId,
String path,
String nonce,
int hostId,
HashinatorSnapshotData hashData,
boolean isTruncationSnapshot)
throws IOException
{
final File file = new VoltFile(path, constructHashinatorConfigFilenameForNonce(nonce, hostId));
if (file.exists()) {
if (!file.delete()) {
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to delete old hash file for truncation snapshot");
}
throw new IOException("Unable to replace existing hashinator config " + file);
}
}
boolean success = false;
try {
final FileOutputStream fos = new FileOutputStream(file);
ByteBuffer fileBuffer = hashData.saveToBuffer(instId);
fos.getChannel().write(fileBuffer);
success = true;
return new Runnable()
{
@Override
public void run()
{
try {
fos.getChannel().force(true);
}
catch (IOException e) {
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to create hash file for truncation snapshot",
true, e);
}
throw new RuntimeException(e);
}
finally {
try {
fos.close();
}
catch (IOException e) {
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to create hash file for truncation snapshot",
true, e);
}
throw new RuntimeException(e);
}
}
}
};
}
finally {
if (!success) {
file.delete();
}
}
} | [
"public",
"static",
"Runnable",
"writeHashinatorConfig",
"(",
"InstanceId",
"instId",
",",
"String",
"path",
",",
"String",
"nonce",
",",
"int",
"hostId",
",",
"HashinatorSnapshotData",
"hashData",
",",
"boolean",
"isTruncationSnapshot",
")",
"throws",
"IOException",
... | Write the hashinator config file for a snapshot
@param instId instance ID
@param path path to which snapshot files will be written
@param nonce nonce used to distinguish this snapshot
@param hostId host ID where this is happening
@param hashData serialized hash configuration data
@return Runnable object for asynchronous write flushing
@throws IOException | [
"Write",
"the",
"hashinator",
"config",
"file",
"for",
"a",
"snapshot"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L272-L332 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.parseNonceFromDigestFilename | public static String parseNonceFromDigestFilename(String filename) {
if (filename == null || !filename.endsWith(".digest")) {
throw new IllegalArgumentException("Bad digest filename: " + filename);
}
return parseNonceFromSnapshotFilename(filename);
} | java | public static String parseNonceFromDigestFilename(String filename) {
if (filename == null || !filename.endsWith(".digest")) {
throw new IllegalArgumentException("Bad digest filename: " + filename);
}
return parseNonceFromSnapshotFilename(filename);
} | [
"public",
"static",
"String",
"parseNonceFromDigestFilename",
"(",
"String",
"filename",
")",
"{",
"if",
"(",
"filename",
"==",
"null",
"||",
"!",
"filename",
".",
"endsWith",
"(",
"\".digest\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
... | Get the nonce from the filename of the digest file.
@param filename The filename of the digest file
@return The nonce | [
"Get",
"the",
"nonce",
"from",
"the",
"filename",
"of",
"the",
"digest",
"file",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L339-L345 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.parseNonceFromHashinatorConfigFilename | public static String parseNonceFromHashinatorConfigFilename(String filename) {
if (filename == null || !filename.endsWith(HASH_EXTENSION)) {
throw new IllegalArgumentException("Bad hashinator config filename: " + filename);
}
return parseNonceFromSnapshotFilename(filename);
} | java | public static String parseNonceFromHashinatorConfigFilename(String filename) {
if (filename == null || !filename.endsWith(HASH_EXTENSION)) {
throw new IllegalArgumentException("Bad hashinator config filename: " + filename);
}
return parseNonceFromSnapshotFilename(filename);
} | [
"public",
"static",
"String",
"parseNonceFromHashinatorConfigFilename",
"(",
"String",
"filename",
")",
"{",
"if",
"(",
"filename",
"==",
"null",
"||",
"!",
"filename",
".",
"endsWith",
"(",
"HASH_EXTENSION",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentExceptio... | Get the nonce from the filename of the hashinator config file.
@param filename The filename of the hashinator config file
@return The nonce | [
"Get",
"the",
"nonce",
"from",
"the",
"filename",
"of",
"the",
"hashinator",
"config",
"file",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L352-L358 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.parseNonceFromSnapshotFilename | public static String parseNonceFromSnapshotFilename(String filename)
{
if (filename == null) {
throw new IllegalArgumentException("Bad snapshot filename: " + filename);
}
// For the snapshot catalog
if (filename.endsWith(".jar")) {
return filename.substring(0, filename.indexOf(".jar"));
}
// for everything else valid in new format or volt1.2 or earlier table files
else if (filename.indexOf("-") > 0) {
return filename.substring(0, filename.indexOf("-"));
}
// volt 1.2 and earlier digest filename
else if (filename.endsWith(".digest")) {
return filename.substring(0, filename.indexOf(".digest"));
}
// Hashinator config filename.
else if (filename.endsWith(HASH_EXTENSION)) {
return filename.substring(0, filename.indexOf(HASH_EXTENSION));
}
throw new IllegalArgumentException("Bad snapshot filename: " + filename);
} | java | public static String parseNonceFromSnapshotFilename(String filename)
{
if (filename == null) {
throw new IllegalArgumentException("Bad snapshot filename: " + filename);
}
// For the snapshot catalog
if (filename.endsWith(".jar")) {
return filename.substring(0, filename.indexOf(".jar"));
}
// for everything else valid in new format or volt1.2 or earlier table files
else if (filename.indexOf("-") > 0) {
return filename.substring(0, filename.indexOf("-"));
}
// volt 1.2 and earlier digest filename
else if (filename.endsWith(".digest")) {
return filename.substring(0, filename.indexOf(".digest"));
}
// Hashinator config filename.
else if (filename.endsWith(HASH_EXTENSION)) {
return filename.substring(0, filename.indexOf(HASH_EXTENSION));
}
throw new IllegalArgumentException("Bad snapshot filename: " + filename);
} | [
"public",
"static",
"String",
"parseNonceFromSnapshotFilename",
"(",
"String",
"filename",
")",
"{",
"if",
"(",
"filename",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Bad snapshot filename: \"",
"+",
"filename",
")",
";",
"}",
"// ... | Get the nonce from any snapshot-related file. | [
"Get",
"the",
"nonce",
"from",
"any",
"snapshot",
"-",
"related",
"file",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L363-L387 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.retrieveHashinatorConfigs | public static List<ByteBuffer> retrieveHashinatorConfigs(
String path,
String nonce,
int maxConfigs,
VoltLogger logger) throws IOException
{
VoltFile directory = new VoltFile(path);
ArrayList<ByteBuffer> configs = new ArrayList<ByteBuffer>();
if (directory.listFiles() == null) {
return configs;
}
for (File file : directory.listFiles()) {
if (file.getName().startsWith(nonce + "-host_") && file.getName().endsWith(HASH_EXTENSION)) {
byte[] rawData = new byte[(int) file.length()];
FileInputStream fis = null;
DataInputStream dis = null;
try {
fis = new FileInputStream(file);
dis = new DataInputStream(fis);
dis.readFully(rawData);
configs.add(ByteBuffer.wrap(rawData));
}
finally {
if (dis != null) {
dis.close();
}
if (fis != null) {
fis.close();
}
}
}
}
return configs;
} | java | public static List<ByteBuffer> retrieveHashinatorConfigs(
String path,
String nonce,
int maxConfigs,
VoltLogger logger) throws IOException
{
VoltFile directory = new VoltFile(path);
ArrayList<ByteBuffer> configs = new ArrayList<ByteBuffer>();
if (directory.listFiles() == null) {
return configs;
}
for (File file : directory.listFiles()) {
if (file.getName().startsWith(nonce + "-host_") && file.getName().endsWith(HASH_EXTENSION)) {
byte[] rawData = new byte[(int) file.length()];
FileInputStream fis = null;
DataInputStream dis = null;
try {
fis = new FileInputStream(file);
dis = new DataInputStream(fis);
dis.readFully(rawData);
configs.add(ByteBuffer.wrap(rawData));
}
finally {
if (dis != null) {
dis.close();
}
if (fis != null) {
fis.close();
}
}
}
}
return configs;
} | [
"public",
"static",
"List",
"<",
"ByteBuffer",
">",
"retrieveHashinatorConfigs",
"(",
"String",
"path",
",",
"String",
"nonce",
",",
"int",
"maxConfigs",
",",
"VoltLogger",
"logger",
")",
"throws",
"IOException",
"{",
"VoltFile",
"directory",
"=",
"new",
"VoltFi... | Read hashinator snapshots into byte buffers.
@param path base snapshot path
@param nonce unique snapshot name
@param maxConfigs max number of good configs to return (0 for all)
@param logger log writer
@return byte buffers for each host
@throws IOException | [
"Read",
"hashinator",
"snapshots",
"into",
"byte",
"buffers",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L417-L450 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.writeSnapshotCatalog | public static Runnable writeSnapshotCatalog(String path, String nonce, boolean isTruncationSnapshot)
throws IOException
{
String filename = SnapshotUtil.constructCatalogFilenameForNonce(nonce);
try
{
return VoltDB.instance().getCatalogContext().writeCatalogJarToFile(path, filename,
CatalogJarWriteMode.RECOVER);
}
catch (IOException ioe)
{
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to create Catalog file for truncation snapshot",
true, ioe);
}
throw new IOException("Unable to write snapshot catalog to file: " +
path + File.separator + filename, ioe);
}
} | java | public static Runnable writeSnapshotCatalog(String path, String nonce, boolean isTruncationSnapshot)
throws IOException
{
String filename = SnapshotUtil.constructCatalogFilenameForNonce(nonce);
try
{
return VoltDB.instance().getCatalogContext().writeCatalogJarToFile(path, filename,
CatalogJarWriteMode.RECOVER);
}
catch (IOException ioe)
{
if (isTruncationSnapshot) {
VoltDB.crashLocalVoltDB("Unexpected exception while attempting to create Catalog file for truncation snapshot",
true, ioe);
}
throw new IOException("Unable to write snapshot catalog to file: " +
path + File.separator + filename, ioe);
}
} | [
"public",
"static",
"Runnable",
"writeSnapshotCatalog",
"(",
"String",
"path",
",",
"String",
"nonce",
",",
"boolean",
"isTruncationSnapshot",
")",
"throws",
"IOException",
"{",
"String",
"filename",
"=",
"SnapshotUtil",
".",
"constructCatalogFilenameForNonce",
"(",
"... | Write the current catalog associated with the database snapshot
to the snapshot location | [
"Write",
"the",
"current",
"catalog",
"associated",
"with",
"the",
"database",
"snapshot",
"to",
"the",
"snapshot",
"location"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L456-L474 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.writeTerminusMarker | public static Runnable writeTerminusMarker(final String nonce, final NodeSettings paths, final VoltLogger logger) {
final File f = new File(paths.getVoltDBRoot(), VoltDB.TERMINUS_MARKER);
return new Runnable() {
@Override
public void run() {
try(PrintWriter pw = new PrintWriter(new FileWriter(f), true)) {
pw.println(nonce);
} catch (IOException e) {
throw new RuntimeException("Failed to create .complete file for " + f.getName(), e);
}
}
};
} | java | public static Runnable writeTerminusMarker(final String nonce, final NodeSettings paths, final VoltLogger logger) {
final File f = new File(paths.getVoltDBRoot(), VoltDB.TERMINUS_MARKER);
return new Runnable() {
@Override
public void run() {
try(PrintWriter pw = new PrintWriter(new FileWriter(f), true)) {
pw.println(nonce);
} catch (IOException e) {
throw new RuntimeException("Failed to create .complete file for " + f.getName(), e);
}
}
};
} | [
"public",
"static",
"Runnable",
"writeTerminusMarker",
"(",
"final",
"String",
"nonce",
",",
"final",
"NodeSettings",
"paths",
",",
"final",
"VoltLogger",
"logger",
")",
"{",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"paths",
".",
"getVoltDBRoot",
"(",
... | Write the shutdown save snapshot terminus marker | [
"Write",
"the",
"shutdown",
"save",
"snapshot",
"terminus",
"marker"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L509-L521 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.retrieveSnapshotFiles | public static void retrieveSnapshotFiles(
File directory,
Map<String, Snapshot> namedSnapshotMap,
FileFilter filter,
boolean validate,
SnapshotPathType stype,
VoltLogger logger) {
NamedSnapshots namedSnapshots = new NamedSnapshots(namedSnapshotMap, stype);
retrieveSnapshotFilesInternal(directory, namedSnapshots, filter, validate, stype, logger, 0);
} | java | public static void retrieveSnapshotFiles(
File directory,
Map<String, Snapshot> namedSnapshotMap,
FileFilter filter,
boolean validate,
SnapshotPathType stype,
VoltLogger logger) {
NamedSnapshots namedSnapshots = new NamedSnapshots(namedSnapshotMap, stype);
retrieveSnapshotFilesInternal(directory, namedSnapshots, filter, validate, stype, logger, 0);
} | [
"public",
"static",
"void",
"retrieveSnapshotFiles",
"(",
"File",
"directory",
",",
"Map",
"<",
"String",
",",
"Snapshot",
">",
"namedSnapshotMap",
",",
"FileFilter",
"filter",
",",
"boolean",
"validate",
",",
"SnapshotPathType",
"stype",
",",
"VoltLogger",
"logge... | Spider the provided directory applying the provided FileFilter. Optionally validate snapshot
files. Return a summary of partition counts, partition information, files, digests etc.
that can be used to determine if a valid restore plan exists.
@param directory
@param snapshots
@param filter
@param validate | [
"Spider",
"the",
"provided",
"directory",
"applying",
"the",
"provided",
"FileFilter",
".",
"Optionally",
"validate",
"snapshot",
"files",
".",
"Return",
"a",
"summary",
"of",
"partition",
"counts",
"partition",
"information",
"files",
"digests",
"etc",
".",
"that... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L799-L809 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.constructFilenameForTable | public static final String constructFilenameForTable(Table table,
String fileNonce,
SnapshotFormat format,
int hostId)
{
String extension = ".vpt";
if (format == SnapshotFormat.CSV) {
extension = ".csv";
}
StringBuilder filename_builder = new StringBuilder(fileNonce);
filename_builder.append("-");
filename_builder.append(table.getTypeName());
if (!table.getIsreplicated())
{
filename_builder.append("-host_");
filename_builder.append(hostId);
}
filename_builder.append(extension);//Volt partitioned table
return filename_builder.toString();
} | java | public static final String constructFilenameForTable(Table table,
String fileNonce,
SnapshotFormat format,
int hostId)
{
String extension = ".vpt";
if (format == SnapshotFormat.CSV) {
extension = ".csv";
}
StringBuilder filename_builder = new StringBuilder(fileNonce);
filename_builder.append("-");
filename_builder.append(table.getTypeName());
if (!table.getIsreplicated())
{
filename_builder.append("-host_");
filename_builder.append(hostId);
}
filename_builder.append(extension);//Volt partitioned table
return filename_builder.toString();
} | [
"public",
"static",
"final",
"String",
"constructFilenameForTable",
"(",
"Table",
"table",
",",
"String",
"fileNonce",
",",
"SnapshotFormat",
"format",
",",
"int",
"hostId",
")",
"{",
"String",
"extension",
"=",
"\".vpt\"",
";",
"if",
"(",
"format",
"==",
"Sna... | Generates a Filename to the snapshot file for the given table.
@param table
@param fileNonce
@param hostId | [
"Generates",
"a",
"Filename",
"to",
"the",
"snapshot",
"file",
"for",
"the",
"given",
"table",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L1207-L1227 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.requestSnapshot | public static void requestSnapshot(final long clientHandle,
final String path,
final String nonce,
final boolean blocking,
final SnapshotFormat format,
final SnapshotPathType stype,
final String data,
final SnapshotResponseHandler handler,
final boolean notifyChanges)
{
final SnapshotInitiationInfo snapInfo = new SnapshotInitiationInfo(path, nonce, blocking, format, stype, data);
final SimpleClientResponseAdapter adapter =
new SimpleClientResponseAdapter(ClientInterface.SNAPSHOT_UTIL_CID, "SnapshotUtilAdapter", true);
final LinkedBlockingQueue<ClientResponse> responses = new LinkedBlockingQueue<ClientResponse>();
adapter.registerCallback(clientHandle, new SimpleClientResponseAdapter.Callback() {
@Override
public void handleResponse(ClientResponse response)
{
responses.offer(response);
}
});
final SnapshotDaemon sd = VoltDB.instance().getClientInterface().getSnapshotDaemon();
Runnable work = new Runnable() {
@Override
public void run() {
ClientResponse response = null;
// abort if unable to succeed in 2 hours
final long startTime = System.currentTimeMillis();
boolean hasRequested = false;
while (System.currentTimeMillis() - startTime <= TimeUnit.HOURS.toMillis(2)) {
try {
if (!hasRequested) {
sd.createAndWatchRequestNode(clientHandle, adapter, snapInfo, notifyChanges);
hasRequested = true;
}
try {
response = responses.poll(
TimeUnit.HOURS.toMillis(2) - (System.currentTimeMillis() - startTime),
TimeUnit.MILLISECONDS);
if (response == null) {
break;
}
} catch (InterruptedException e) {
VoltDB.crashLocalVoltDB("Should never happen", true, e);
}
VoltTable[] results = response.getResults();
if (response.getStatus() != ClientResponse.SUCCESS) {
break;
} else if (isSnapshotInProgress(results)) {
// retry after a second
Thread.sleep(1000);
// Request again
hasRequested = false;
continue;
} else if (isSnapshotQueued(results) && notifyChanges) {
//Wait for an update on the queued state via ZK
continue;
} else {
// other errors are not recoverable
break;
}
} catch (ForwardClientException e) {
//This happens when something goes wrong in the snapshot daemon
//I think it will always be that there was an existing snapshot request
//It should eventually terminate and then we can submit one.
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {}
new VoltLogger("SNAPSHOT").warn("Partition detection is unable to submit a snapshot request " +
"because one already exists. Retrying.");
continue;
} catch (InterruptedException ignore) {}
}
handler.handleResponse(response);
}
};
// Use an executor service here to avoid explosion of threads???
ThreadFactory factory = CoreUtils.getThreadFactory("Snapshot Request - " + nonce);
Thread workThread = factory.newThread(work);
workThread.start();
} | java | public static void requestSnapshot(final long clientHandle,
final String path,
final String nonce,
final boolean blocking,
final SnapshotFormat format,
final SnapshotPathType stype,
final String data,
final SnapshotResponseHandler handler,
final boolean notifyChanges)
{
final SnapshotInitiationInfo snapInfo = new SnapshotInitiationInfo(path, nonce, blocking, format, stype, data);
final SimpleClientResponseAdapter adapter =
new SimpleClientResponseAdapter(ClientInterface.SNAPSHOT_UTIL_CID, "SnapshotUtilAdapter", true);
final LinkedBlockingQueue<ClientResponse> responses = new LinkedBlockingQueue<ClientResponse>();
adapter.registerCallback(clientHandle, new SimpleClientResponseAdapter.Callback() {
@Override
public void handleResponse(ClientResponse response)
{
responses.offer(response);
}
});
final SnapshotDaemon sd = VoltDB.instance().getClientInterface().getSnapshotDaemon();
Runnable work = new Runnable() {
@Override
public void run() {
ClientResponse response = null;
// abort if unable to succeed in 2 hours
final long startTime = System.currentTimeMillis();
boolean hasRequested = false;
while (System.currentTimeMillis() - startTime <= TimeUnit.HOURS.toMillis(2)) {
try {
if (!hasRequested) {
sd.createAndWatchRequestNode(clientHandle, adapter, snapInfo, notifyChanges);
hasRequested = true;
}
try {
response = responses.poll(
TimeUnit.HOURS.toMillis(2) - (System.currentTimeMillis() - startTime),
TimeUnit.MILLISECONDS);
if (response == null) {
break;
}
} catch (InterruptedException e) {
VoltDB.crashLocalVoltDB("Should never happen", true, e);
}
VoltTable[] results = response.getResults();
if (response.getStatus() != ClientResponse.SUCCESS) {
break;
} else if (isSnapshotInProgress(results)) {
// retry after a second
Thread.sleep(1000);
// Request again
hasRequested = false;
continue;
} else if (isSnapshotQueued(results) && notifyChanges) {
//Wait for an update on the queued state via ZK
continue;
} else {
// other errors are not recoverable
break;
}
} catch (ForwardClientException e) {
//This happens when something goes wrong in the snapshot daemon
//I think it will always be that there was an existing snapshot request
//It should eventually terminate and then we can submit one.
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {}
new VoltLogger("SNAPSHOT").warn("Partition detection is unable to submit a snapshot request " +
"because one already exists. Retrying.");
continue;
} catch (InterruptedException ignore) {}
}
handler.handleResponse(response);
}
};
// Use an executor service here to avoid explosion of threads???
ThreadFactory factory = CoreUtils.getThreadFactory("Snapshot Request - " + nonce);
Thread workThread = factory.newThread(work);
workThread.start();
} | [
"public",
"static",
"void",
"requestSnapshot",
"(",
"final",
"long",
"clientHandle",
",",
"final",
"String",
"path",
",",
"final",
"String",
"nonce",
",",
"final",
"boolean",
"blocking",
",",
"final",
"SnapshotFormat",
"format",
",",
"final",
"SnapshotPathType",
... | Request a new snapshot. It will retry for a couple of times. If it
doesn't succeed in the specified time, an error response will be sent to
the response handler, otherwise a success response will be passed to the
handler.
The request process runs in a separate thread, this method call will
return immediately.
@param clientHandle
@param path
@param nonce
@param blocking
@param format
@param stype type of snapshot path SNAP_AUTO, SNAP_CL or SNAP_PATH
@param data Any data that needs to be passed to the snapshot target
@param handler | [
"Request",
"a",
"new",
"snapshot",
".",
"It",
"will",
"retry",
"for",
"a",
"couple",
"of",
"times",
".",
"If",
"it",
"doesn",
"t",
"succeed",
"in",
"the",
"specified",
"time",
"an",
"error",
"response",
"will",
"be",
"sent",
"to",
"the",
"response",
"h... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L1433-L1518 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.watchSnapshot | public static ListenableFuture<SnapshotCompletionInterest.SnapshotCompletionEvent>
watchSnapshot(final String nonce)
{
final SettableFuture<SnapshotCompletionInterest.SnapshotCompletionEvent> result =
SettableFuture.create();
SnapshotCompletionInterest interest = new SnapshotCompletionInterest() {
@Override
public CountDownLatch snapshotCompleted(SnapshotCompletionEvent event)
{
if (event.nonce.equals(nonce) && event.didSucceed) {
VoltDB.instance().getSnapshotCompletionMonitor().removeInterest(this);
result.set(event);
}
return null;
}
};
VoltDB.instance().getSnapshotCompletionMonitor().addInterest(interest);
return result;
} | java | public static ListenableFuture<SnapshotCompletionInterest.SnapshotCompletionEvent>
watchSnapshot(final String nonce)
{
final SettableFuture<SnapshotCompletionInterest.SnapshotCompletionEvent> result =
SettableFuture.create();
SnapshotCompletionInterest interest = new SnapshotCompletionInterest() {
@Override
public CountDownLatch snapshotCompleted(SnapshotCompletionEvent event)
{
if (event.nonce.equals(nonce) && event.didSucceed) {
VoltDB.instance().getSnapshotCompletionMonitor().removeInterest(this);
result.set(event);
}
return null;
}
};
VoltDB.instance().getSnapshotCompletionMonitor().addInterest(interest);
return result;
} | [
"public",
"static",
"ListenableFuture",
"<",
"SnapshotCompletionInterest",
".",
"SnapshotCompletionEvent",
">",
"watchSnapshot",
"(",
"final",
"String",
"nonce",
")",
"{",
"final",
"SettableFuture",
"<",
"SnapshotCompletionInterest",
".",
"SnapshotCompletionEvent",
">",
"... | Watch for the completion of a snapshot
@param nonce The snapshot nonce to watch for
@return A future that will return the SnapshotCompletionEvent | [
"Watch",
"for",
"the",
"completion",
"of",
"a",
"snapshot"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L1546-L1566 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.retrieveHashinatorConfig | public static HashinatorSnapshotData retrieveHashinatorConfig(
String path, String nonce, int hostId, VoltLogger logger) throws IOException {
HashinatorSnapshotData hashData = null;
String expectedFileName = constructHashinatorConfigFilenameForNonce(nonce, hostId);
File[] files = new VoltFile(path).listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().equals(expectedFileName)) {
hashData = new HashinatorSnapshotData();
hashData.restoreFromFile(file);
break;
}
}
}
if (hashData == null) {
throw new IOException("Missing hashinator data in snapshot");
}
return hashData;
} | java | public static HashinatorSnapshotData retrieveHashinatorConfig(
String path, String nonce, int hostId, VoltLogger logger) throws IOException {
HashinatorSnapshotData hashData = null;
String expectedFileName = constructHashinatorConfigFilenameForNonce(nonce, hostId);
File[] files = new VoltFile(path).listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().equals(expectedFileName)) {
hashData = new HashinatorSnapshotData();
hashData.restoreFromFile(file);
break;
}
}
}
if (hashData == null) {
throw new IOException("Missing hashinator data in snapshot");
}
return hashData;
} | [
"public",
"static",
"HashinatorSnapshotData",
"retrieveHashinatorConfig",
"(",
"String",
"path",
",",
"String",
"nonce",
",",
"int",
"hostId",
",",
"VoltLogger",
"logger",
")",
"throws",
"IOException",
"{",
"HashinatorSnapshotData",
"hashData",
"=",
"null",
";",
"St... | Retrieve hashinator config for restore.
@param path snapshot base directory
@param nonce unique snapshot ID
@param hostId host ID
@return hashinator shapshot data
@throws Exception | [
"Retrieve",
"hashinator",
"config",
"for",
"restore",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L1576-L1594 | train |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.getRealPath | public static String getRealPath(SnapshotPathType stype, String path) {
if (stype == SnapshotPathType.SNAP_CL) {
return VoltDB.instance().getCommandLogSnapshotPath();
} else if (stype == SnapshotPathType.SNAP_AUTO) {
return VoltDB.instance().getSnapshotPath();
}
return path;
} | java | public static String getRealPath(SnapshotPathType stype, String path) {
if (stype == SnapshotPathType.SNAP_CL) {
return VoltDB.instance().getCommandLogSnapshotPath();
} else if (stype == SnapshotPathType.SNAP_AUTO) {
return VoltDB.instance().getSnapshotPath();
}
return path;
} | [
"public",
"static",
"String",
"getRealPath",
"(",
"SnapshotPathType",
"stype",
",",
"String",
"path",
")",
"{",
"if",
"(",
"stype",
"==",
"SnapshotPathType",
".",
"SNAP_CL",
")",
"{",
"return",
"VoltDB",
".",
"instance",
"(",
")",
".",
"getCommandLogSnapshotPa... | Return path based on type if type is not CL or AUTO return provided path. | [
"Return",
"path",
"based",
"on",
"type",
"if",
"type",
"is",
"not",
"CL",
"or",
"AUTO",
"return",
"provided",
"path",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L1664-L1671 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/LifeTimeConnectionWrapper.java | LifeTimeConnectionWrapper.close | public void close() throws SQLException {
validate();
try {
this.connection.rollback();
this.connection.clearWarnings();
this.connectionDefaults.setDefaults(this.connection);
this.connection.reset();
fireCloseEvent();
} catch (SQLException e) {
fireSqlExceptionEvent(e);
throw e;
}
} | java | public void close() throws SQLException {
validate();
try {
this.connection.rollback();
this.connection.clearWarnings();
this.connectionDefaults.setDefaults(this.connection);
this.connection.reset();
fireCloseEvent();
} catch (SQLException e) {
fireSqlExceptionEvent(e);
throw e;
}
} | [
"public",
"void",
"close",
"(",
")",
"throws",
"SQLException",
"{",
"validate",
"(",
")",
";",
"try",
"{",
"this",
".",
"connection",
".",
"rollback",
"(",
")",
";",
"this",
".",
"connection",
".",
"clearWarnings",
"(",
")",
";",
"this",
".",
"connecti... | Rolls the connection back, resets the connection back to defaults, clears warnings,
resets the connection on the server side, and returns the connection to the pool.
@throws SQLException | [
"Rolls",
"the",
"connection",
"back",
"resets",
"the",
"connection",
"back",
"to",
"defaults",
"clears",
"warnings",
"resets",
"the",
"connection",
"on",
"the",
"server",
"side",
"and",
"returns",
"the",
"connection",
"to",
"the",
"pool",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/LifeTimeConnectionWrapper.java#L116-L131 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/LifeTimeConnectionWrapper.java | LifeTimeConnectionWrapper.closePhysically | public void closePhysically() throws SQLException {
SQLException exception = null;
if (!isClosed && this.connection != null
&& !this.connection.isClosed()) {
try {
this.connection.close();
} catch (SQLException e) {
//catch and hold so that the rest of the finalizer is run too. Throw at the end if present.
exception = e;
}
}
this.isClosed = true;
this.pooledConnection = null;
this.connection = null;
this.connectionDefaults = null;
this.connectionListeners.clear();
this.connectionListeners = null;
if (exception != null) {
throw exception;
}
} | java | public void closePhysically() throws SQLException {
SQLException exception = null;
if (!isClosed && this.connection != null
&& !this.connection.isClosed()) {
try {
this.connection.close();
} catch (SQLException e) {
//catch and hold so that the rest of the finalizer is run too. Throw at the end if present.
exception = e;
}
}
this.isClosed = true;
this.pooledConnection = null;
this.connection = null;
this.connectionDefaults = null;
this.connectionListeners.clear();
this.connectionListeners = null;
if (exception != null) {
throw exception;
}
} | [
"public",
"void",
"closePhysically",
"(",
")",
"throws",
"SQLException",
"{",
"SQLException",
"exception",
"=",
"null",
";",
"if",
"(",
"!",
"isClosed",
"&&",
"this",
".",
"connection",
"!=",
"null",
"&&",
"!",
"this",
".",
"connection",
".",
"isClosed",
"... | Closes the connection physically. The pool is not notified of this.
@throws SQLException If something goes wrong during the closing of the wrapped JDBCConnection. | [
"Closes",
"the",
"connection",
"physically",
".",
"The",
"pool",
"is",
"not",
"notified",
"of",
"this",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/pool/LifeTimeConnectionWrapper.java#L137-L163 | train |
VoltDB/voltdb | src/frontend/org/voltdb/SnapshotSiteProcessor.java | SnapshotSiteProcessor.startSnapshotWithTargets | public void startSnapshotWithTargets(Collection<SnapshotDataTarget> targets, long now)
{
// TRAIL [SnapSave:9] 5 [all SP] Start snapshot by putting task into the site queue.
//Basically asserts that there are no tasks with null targets at this point
//getTarget checks and crashes
for (SnapshotTableTask t : m_snapshotTableTasks.values()) {
t.getTarget();
}
ArrayList<SnapshotDataTarget> targetsToClose = Lists.newArrayList();
for (final SnapshotDataTarget target : targets) {
if (target.needsFinalClose()) {
targetsToClose.add(target);
}
}
m_snapshotTargets = targetsToClose;
// Queue the first snapshot task
VoltDB.instance().schedulePriorityWork(
new Runnable() {
@Override
public void run()
{
m_siteTaskerQueue.offer(new SnapshotTask());
}
},
(m_quietUntil + (5 * m_snapshotPriority) - now),
0,
TimeUnit.MILLISECONDS);
m_quietUntil += 5 * m_snapshotPriority;
} | java | public void startSnapshotWithTargets(Collection<SnapshotDataTarget> targets, long now)
{
// TRAIL [SnapSave:9] 5 [all SP] Start snapshot by putting task into the site queue.
//Basically asserts that there are no tasks with null targets at this point
//getTarget checks and crashes
for (SnapshotTableTask t : m_snapshotTableTasks.values()) {
t.getTarget();
}
ArrayList<SnapshotDataTarget> targetsToClose = Lists.newArrayList();
for (final SnapshotDataTarget target : targets) {
if (target.needsFinalClose()) {
targetsToClose.add(target);
}
}
m_snapshotTargets = targetsToClose;
// Queue the first snapshot task
VoltDB.instance().schedulePriorityWork(
new Runnable() {
@Override
public void run()
{
m_siteTaskerQueue.offer(new SnapshotTask());
}
},
(m_quietUntil + (5 * m_snapshotPriority) - now),
0,
TimeUnit.MILLISECONDS);
m_quietUntil += 5 * m_snapshotPriority;
} | [
"public",
"void",
"startSnapshotWithTargets",
"(",
"Collection",
"<",
"SnapshotDataTarget",
">",
"targets",
",",
"long",
"now",
")",
"{",
"// TRAIL [SnapSave:9] 5 [all SP] Start snapshot by putting task into the site queue.",
"//Basically asserts that there are no tasks with null targe... | This is called from the snapshot IO thread when the deferred setup is finished. It sets
the data targets and queues a snapshot task onto the site thread. | [
"This",
"is",
"called",
"from",
"the",
"snapshot",
"IO",
"thread",
"when",
"the",
"deferred",
"setup",
"is",
"finished",
".",
"It",
"sets",
"the",
"data",
"targets",
"and",
"queues",
"a",
"snapshot",
"task",
"onto",
"the",
"site",
"thread",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/SnapshotSiteProcessor.java#L452-L482 | train |
VoltDB/voltdb | src/frontend/org/voltdb/SnapshotSiteProcessor.java | SnapshotSiteProcessor.getOutputBuffers | private List<BBContainer> getOutputBuffers(Collection<SnapshotTableTask> tableTasks, boolean noSchedule)
{
final int desired = tableTasks.size();
while (true) {
int available = m_availableSnapshotBuffers.get();
//Limit the number of buffers used concurrently
if (desired > available) {
return null;
}
if (m_availableSnapshotBuffers.compareAndSet(available, available - desired)) break;
}
List<BBContainer> outputBuffers = new ArrayList<BBContainer>(tableTasks.size());
for (int ii = 0; ii < tableTasks.size(); ii++) {
final BBContainer origin = DBBPool.allocateDirectAndPool(m_snapshotBufferLength);
outputBuffers.add(createNewBuffer(origin, noSchedule));
}
return outputBuffers;
} | java | private List<BBContainer> getOutputBuffers(Collection<SnapshotTableTask> tableTasks, boolean noSchedule)
{
final int desired = tableTasks.size();
while (true) {
int available = m_availableSnapshotBuffers.get();
//Limit the number of buffers used concurrently
if (desired > available) {
return null;
}
if (m_availableSnapshotBuffers.compareAndSet(available, available - desired)) break;
}
List<BBContainer> outputBuffers = new ArrayList<BBContainer>(tableTasks.size());
for (int ii = 0; ii < tableTasks.size(); ii++) {
final BBContainer origin = DBBPool.allocateDirectAndPool(m_snapshotBufferLength);
outputBuffers.add(createNewBuffer(origin, noSchedule));
}
return outputBuffers;
} | [
"private",
"List",
"<",
"BBContainer",
">",
"getOutputBuffers",
"(",
"Collection",
"<",
"SnapshotTableTask",
">",
"tableTasks",
",",
"boolean",
"noSchedule",
")",
"{",
"final",
"int",
"desired",
"=",
"tableTasks",
".",
"size",
"(",
")",
";",
"while",
"(",
"t... | Create an output buffer for each task.
@return null if there aren't enough buffers left in the pool. | [
"Create",
"an",
"output",
"buffer",
"for",
"each",
"task",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/SnapshotSiteProcessor.java#L517-L538 | train |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/navigator/RowSetNavigatorLinkedList.java | RowSetNavigatorLinkedList.write | public void write(RowOutputInterface out,
ResultMetaData meta) throws IOException {
beforeFirst();
out.writeLong(id);
out.writeInt(size);
out.writeInt(0); // offset
out.writeInt(size);
while (hasNext()) {
Object[] data = getNext();
out.writeData(meta.getColumnCount(), meta.columnTypes, data, null,
null);
}
beforeFirst();
} | java | public void write(RowOutputInterface out,
ResultMetaData meta) throws IOException {
beforeFirst();
out.writeLong(id);
out.writeInt(size);
out.writeInt(0); // offset
out.writeInt(size);
while (hasNext()) {
Object[] data = getNext();
out.writeData(meta.getColumnCount(), meta.columnTypes, data, null,
null);
}
beforeFirst();
} | [
"public",
"void",
"write",
"(",
"RowOutputInterface",
"out",
",",
"ResultMetaData",
"meta",
")",
"throws",
"IOException",
"{",
"beforeFirst",
"(",
")",
";",
"out",
".",
"writeLong",
"(",
"id",
")",
";",
"out",
".",
"writeInt",
"(",
"size",
")",
";",
"out... | reading and writing | [
"reading",
"and",
"writing"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/navigator/RowSetNavigatorLinkedList.java#L120-L137 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ClientInterface.java | ClientInterface.create | public static ClientInterface create(
HostMessenger messenger,
CatalogContext context,
ReplicationRole replicationRole,
Cartographer cartographer,
InetAddress clientIntf,
int clientPort,
InetAddress adminIntf,
int adminPort,
SslContext SslContext) throws Exception {
/*
* Construct the runnables so they have access to the list of connections
*/
final ClientInterface ci = new ClientInterface(
clientIntf, clientPort, adminIntf, adminPort, context, messenger, replicationRole, cartographer,
SslContext);
return ci;
} | java | public static ClientInterface create(
HostMessenger messenger,
CatalogContext context,
ReplicationRole replicationRole,
Cartographer cartographer,
InetAddress clientIntf,
int clientPort,
InetAddress adminIntf,
int adminPort,
SslContext SslContext) throws Exception {
/*
* Construct the runnables so they have access to the list of connections
*/
final ClientInterface ci = new ClientInterface(
clientIntf, clientPort, adminIntf, adminPort, context, messenger, replicationRole, cartographer,
SslContext);
return ci;
} | [
"public",
"static",
"ClientInterface",
"create",
"(",
"HostMessenger",
"messenger",
",",
"CatalogContext",
"context",
",",
"ReplicationRole",
"replicationRole",
",",
"Cartographer",
"cartographer",
",",
"InetAddress",
"clientIntf",
",",
"int",
"clientPort",
",",
"InetAd... | Static factory method to easily create a ClientInterface with the default
settings.
@throws Exception | [
"Static",
"factory",
"method",
"to",
"easily",
"create",
"a",
"ClientInterface",
"with",
"the",
"default",
"settings",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ClientInterface.java#L1138-L1157 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ClientInterface.java | ClientInterface.initializeSnapshotDaemon | public void initializeSnapshotDaemon(HostMessenger messenger, GlobalServiceElector gse) {
m_snapshotDaemon.init(this, messenger, new Runnable() {
@Override
public void run() {
bindAdapter(m_snapshotDaemonAdapter, null);
}
},
gse);
} | java | public void initializeSnapshotDaemon(HostMessenger messenger, GlobalServiceElector gse) {
m_snapshotDaemon.init(this, messenger, new Runnable() {
@Override
public void run() {
bindAdapter(m_snapshotDaemonAdapter, null);
}
},
gse);
} | [
"public",
"void",
"initializeSnapshotDaemon",
"(",
"HostMessenger",
"messenger",
",",
"GlobalServiceElector",
"gse",
")",
"{",
"m_snapshotDaemon",
".",
"init",
"(",
"this",
",",
"messenger",
",",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void... | Initializes the snapshot daemon so that it's ready to take snapshots | [
"Initializes",
"the",
"snapshot",
"daemon",
"so",
"that",
"it",
"s",
"ready",
"to",
"take",
"snapshots"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ClientInterface.java#L1386-L1394 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ClientInterface.java | ClientInterface.bindAdapter | public ClientInterfaceHandleManager bindAdapter(final Connection adapter, final ClientInterfaceRepairCallback repairCallback) {
return bindAdapter(adapter, repairCallback, false);
} | java | public ClientInterfaceHandleManager bindAdapter(final Connection adapter, final ClientInterfaceRepairCallback repairCallback) {
return bindAdapter(adapter, repairCallback, false);
} | [
"public",
"ClientInterfaceHandleManager",
"bindAdapter",
"(",
"final",
"Connection",
"adapter",
",",
"final",
"ClientInterfaceRepairCallback",
"repairCallback",
")",
"{",
"return",
"bindAdapter",
"(",
"adapter",
",",
"repairCallback",
",",
"false",
")",
";",
"}"
] | Tell the clientInterface about a connection adapter. | [
"Tell",
"the",
"clientInterface",
"about",
"a",
"connection",
"adapter",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ClientInterface.java#L1399-L1401 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ClientInterface.java | ClientInterface.mayActivateSnapshotDaemon | public void mayActivateSnapshotDaemon() {
SnapshotSchedule schedule = m_catalogContext.get().database.getSnapshotschedule().get("default");
if (schedule != null)
{
final ListenableFuture<Void> future = m_snapshotDaemon.mayGoActiveOrInactive(schedule);
future.addListener(new Runnable() {
@Override
public void run() {
try {
future.get();
} catch (InterruptedException e) {
VoltDB.crashLocalVoltDB("Failed to make SnapshotDaemon active", false, e);
} catch (ExecutionException e) {
VoltDB.crashLocalVoltDB("Failed to make SnapshotDaemon active", false, e);
}
}
}, CoreUtils.SAMETHREADEXECUTOR);
}
} | java | public void mayActivateSnapshotDaemon() {
SnapshotSchedule schedule = m_catalogContext.get().database.getSnapshotschedule().get("default");
if (schedule != null)
{
final ListenableFuture<Void> future = m_snapshotDaemon.mayGoActiveOrInactive(schedule);
future.addListener(new Runnable() {
@Override
public void run() {
try {
future.get();
} catch (InterruptedException e) {
VoltDB.crashLocalVoltDB("Failed to make SnapshotDaemon active", false, e);
} catch (ExecutionException e) {
VoltDB.crashLocalVoltDB("Failed to make SnapshotDaemon active", false, e);
}
}
}, CoreUtils.SAMETHREADEXECUTOR);
}
} | [
"public",
"void",
"mayActivateSnapshotDaemon",
"(",
")",
"{",
"SnapshotSchedule",
"schedule",
"=",
"m_catalogContext",
".",
"get",
"(",
")",
".",
"database",
".",
"getSnapshotschedule",
"(",
")",
".",
"get",
"(",
"\"default\"",
")",
";",
"if",
"(",
"schedule",... | in the cluster, make our SnapshotDaemon responsible for snapshots | [
"in",
"the",
"cluster",
"make",
"our",
"SnapshotDaemon",
"responsible",
"for",
"snapshots"
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ClientInterface.java#L1431-L1449 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ClientInterface.java | ClientInterface.notifyOfCatalogUpdate | public void notifyOfCatalogUpdate() {
m_catalogContext.set(VoltDB.instance().getCatalogContext());
/*
* Update snapshot daemon settings.
*
* Don't do it if the system is still initializing (CL replay),
* because snapshot daemon may call @SnapshotScan on activation and
* it will mess replaying txns up.
*/
if (VoltDB.instance().getMode() != OperationMode.INITIALIZING) {
mayActivateSnapshotDaemon();
//add a notification to client right away
StoredProcedureInvocation spi = new StoredProcedureInvocation();
spi.setProcName("@SystemCatalog");
spi.setParams("PROCEDURES");
spi.setClientHandle(ASYNC_PROC_HANDLE);
notifyClients(m_currentProcValues,m_currentProcSupplier,
spi, OpsSelector.SYSTEMCATALOG);
}
} | java | public void notifyOfCatalogUpdate() {
m_catalogContext.set(VoltDB.instance().getCatalogContext());
/*
* Update snapshot daemon settings.
*
* Don't do it if the system is still initializing (CL replay),
* because snapshot daemon may call @SnapshotScan on activation and
* it will mess replaying txns up.
*/
if (VoltDB.instance().getMode() != OperationMode.INITIALIZING) {
mayActivateSnapshotDaemon();
//add a notification to client right away
StoredProcedureInvocation spi = new StoredProcedureInvocation();
spi.setProcName("@SystemCatalog");
spi.setParams("PROCEDURES");
spi.setClientHandle(ASYNC_PROC_HANDLE);
notifyClients(m_currentProcValues,m_currentProcSupplier,
spi, OpsSelector.SYSTEMCATALOG);
}
} | [
"public",
"void",
"notifyOfCatalogUpdate",
"(",
")",
"{",
"m_catalogContext",
".",
"set",
"(",
"VoltDB",
".",
"instance",
"(",
")",
".",
"getCatalogContext",
"(",
")",
")",
";",
"/*\n * Update snapshot daemon settings.\n *\n * Don't do it if the syst... | Set the flag that tells this client interface to update its
catalog when it's threadsafe. | [
"Set",
"the",
"flag",
"that",
"tells",
"this",
"client",
"interface",
"to",
"update",
"its",
"catalog",
"when",
"it",
"s",
"threadsafe",
"."
] | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ClientInterface.java#L1463-L1483 | train |
VoltDB/voltdb | src/frontend/org/voltdb/ClientInterface.java | ClientInterface.checkForDeadConnections | private final void checkForDeadConnections(final long now) {
final ArrayList<Pair<Connection, Integer>> connectionsToRemove = new ArrayList<Pair<Connection, Integer>>();
for (final ClientInterfaceHandleManager cihm : m_cihm.values()) {
// Internal connections don't implement calculatePendingWriteDelta(), so check for real connection first
if (VoltPort.class == cihm.connection.getClass()) {
final int delta = cihm.connection.writeStream().calculatePendingWriteDelta(now);
if (delta > CLIENT_HANGUP_TIMEOUT) {
connectionsToRemove.add(Pair.of(cihm.connection, delta));
}
}
}
for (final Pair<Connection, Integer> p : connectionsToRemove) {
Connection c = p.getFirst();
networkLog.warn("Closing connection to " + c +
" because it hasn't read a response that was pending for " + p.getSecond() + " milliseconds");
c.unregister();
}
} | java | private final void checkForDeadConnections(final long now) {
final ArrayList<Pair<Connection, Integer>> connectionsToRemove = new ArrayList<Pair<Connection, Integer>>();
for (final ClientInterfaceHandleManager cihm : m_cihm.values()) {
// Internal connections don't implement calculatePendingWriteDelta(), so check for real connection first
if (VoltPort.class == cihm.connection.getClass()) {
final int delta = cihm.connection.writeStream().calculatePendingWriteDelta(now);
if (delta > CLIENT_HANGUP_TIMEOUT) {
connectionsToRemove.add(Pair.of(cihm.connection, delta));
}
}
}
for (final Pair<Connection, Integer> p : connectionsToRemove) {
Connection c = p.getFirst();
networkLog.warn("Closing connection to " + c +
" because it hasn't read a response that was pending for " + p.getSecond() + " milliseconds");
c.unregister();
}
} | [
"private",
"final",
"void",
"checkForDeadConnections",
"(",
"final",
"long",
"now",
")",
"{",
"final",
"ArrayList",
"<",
"Pair",
"<",
"Connection",
",",
"Integer",
">",
">",
"connectionsToRemove",
"=",
"new",
"ArrayList",
"<",
"Pair",
"<",
"Connection",
",",
... | Check for dead connections by providing each connection with the current
time so it can calculate the delta between now and the time the oldest message was
queued for sending.
@param now Current time in milliseconds | [
"Check",
"for",
"dead",
"connections",
"by",
"providing",
"each",
"connection",
"with",
"the",
"current",
"time",
"so",
"it",
"can",
"calculate",
"the",
"delta",
"between",
"now",
"and",
"the",
"time",
"the",
"oldest",
"message",
"was",
"queued",
"for",
"sen... | 8afc1031e475835344b5497ea9e7203bc95475ac | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ClientInterface.java#L1693-L1711 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.