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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java | QuantilesCallback.createBuckets | protected final Buckets createBuckets(Stopwatch stopwatch, long min, long max, int bucketNb) {
Buckets buckets = bucketsType.createBuckets(stopwatch, min, max, bucketNb);
buckets.setLogTemplate(createLogTemplate(stopwatch));
return buckets;
} | java | protected final Buckets createBuckets(Stopwatch stopwatch, long min, long max, int bucketNb) {
Buckets buckets = bucketsType.createBuckets(stopwatch, min, max, bucketNb);
buckets.setLogTemplate(createLogTemplate(stopwatch));
return buckets;
} | [
"protected",
"final",
"Buckets",
"createBuckets",
"(",
"Stopwatch",
"stopwatch",
",",
"long",
"min",
",",
"long",
"max",
",",
"int",
"bucketNb",
")",
"{",
"Buckets",
"buckets",
"=",
"bucketsType",
".",
"createBuckets",
"(",
"stopwatch",
",",
"min",
",",
"max... | Factory method to create a Buckets object using given configuration.
@param stopwatch Target Stopwatch
@param min Min bound
@param max Max bound
@param bucketNb Number of buckets between min and max
@return Buckets | [
"Factory",
"method",
"to",
"create",
"a",
"Buckets",
"object",
"using",
"given",
"configuration",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java#L106-L110 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java | QuantilesCallback.getOrCreateBuckets | @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
protected final Buckets getOrCreateBuckets(Stopwatch stopwatch) {
synchronized (stopwatch) {
Buckets buckets = getBuckets(stopwatch);
if (buckets == null) {
buckets = createBuckets(stopwatch);
stopwatch.setAttribute(ATTR_NAME_BUCKETS, buckets);
}
return buckets;
}
} | java | @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
protected final Buckets getOrCreateBuckets(Stopwatch stopwatch) {
synchronized (stopwatch) {
Buckets buckets = getBuckets(stopwatch);
if (buckets == null) {
buckets = createBuckets(stopwatch);
stopwatch.setAttribute(ATTR_NAME_BUCKETS, buckets);
}
return buckets;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"SynchronizationOnLocalVariableOrMethodParameter\"",
")",
"protected",
"final",
"Buckets",
"getOrCreateBuckets",
"(",
"Stopwatch",
"stopwatch",
")",
"{",
"synchronized",
"(",
"stopwatch",
")",
"{",
"Buckets",
"buckets",
"=",
"getBuckets",
... | Returns the buckets attribute or create it if it does not exist. | [
"Returns",
"the",
"buckets",
"attribute",
"or",
"create",
"it",
"if",
"it",
"does",
"not",
"exist",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java#L122-L132 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java | QuantilesCallback.sampleBuckets | public static BucketsSample sampleBuckets(Stopwatch stopwatch) {
final Buckets buckets = getBuckets(stopwatch);
return buckets == null ? null : buckets.sample();
} | java | public static BucketsSample sampleBuckets(Stopwatch stopwatch) {
final Buckets buckets = getBuckets(stopwatch);
return buckets == null ? null : buckets.sample();
} | [
"public",
"static",
"BucketsSample",
"sampleBuckets",
"(",
"Stopwatch",
"stopwatch",
")",
"{",
"final",
"Buckets",
"buckets",
"=",
"getBuckets",
"(",
"stopwatch",
")",
";",
"return",
"buckets",
"==",
"null",
"?",
"null",
":",
"buckets",
".",
"sample",
"(",
"... | Returns the buckets attribute and sample them. | [
"Returns",
"the",
"buckets",
"attribute",
"and",
"sample",
"them",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java#L135-L138 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java | QuantilesCallback.onStopwatchStop | @Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
onStopwatchSplit(split.getStopwatch(), split);
} | java | @Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
onStopwatchSplit(split.getStopwatch(), split);
} | [
"@",
"Override",
"public",
"void",
"onStopwatchStop",
"(",
"Split",
"split",
",",
"StopwatchSample",
"sample",
")",
"{",
"onStopwatchSplit",
"(",
"split",
".",
"getStopwatch",
"(",
")",
",",
"split",
")",
";",
"}"
] | When a split is stopped, if buckets have been initialized, the value
is added to appropriate bucket. | [
"When",
"a",
"split",
"is",
"stopped",
"if",
"buckets",
"have",
"been",
"initialized",
"the",
"value",
"is",
"added",
"to",
"appropriate",
"bucket",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java#L157-L160 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java | QuantilesCallback.onStopwatchAdd | @Override
public void onStopwatchAdd(Stopwatch stopwatch, Split split, StopwatchSample sample) {
onStopwatchSplit(split.getStopwatch(), split);
} | java | @Override
public void onStopwatchAdd(Stopwatch stopwatch, Split split, StopwatchSample sample) {
onStopwatchSplit(split.getStopwatch(), split);
} | [
"@",
"Override",
"public",
"void",
"onStopwatchAdd",
"(",
"Stopwatch",
"stopwatch",
",",
"Split",
"split",
",",
"StopwatchSample",
"sample",
")",
"{",
"onStopwatchSplit",
"(",
"split",
".",
"getStopwatch",
"(",
")",
",",
"split",
")",
";",
"}"
] | When a split is added, if buckets have been initialized, the value is added to appropriate bucket. | [
"When",
"a",
"split",
"is",
"added",
"if",
"buckets",
"have",
"been",
"initialized",
"the",
"value",
"is",
"added",
"to",
"appropriate",
"bucket",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/QuantilesCallback.java#L163-L166 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/source/CachedMonitorSource.java | CachedMonitorSource.getMonitorInformation | private MonitorInformation getMonitorInformation(L location) {
final K monitorKey = getLocationKey(location);
MonitorInformation monitorInformation = monitorInformations.get(monitorKey);
if (monitorInformation == null) {
// Not found, let's call delegate
if (delegate.isMonitored(location)) {
monitorInformation = new MonitorInformation(true, delegate.getMonitor(location));
} else {
monitorInformation = NULL_MONITOR_INFORMATION;
}
monitorInformations.put(monitorKey, monitorInformation);
}
return monitorInformation;
} | java | private MonitorInformation getMonitorInformation(L location) {
final K monitorKey = getLocationKey(location);
MonitorInformation monitorInformation = monitorInformations.get(monitorKey);
if (monitorInformation == null) {
// Not found, let's call delegate
if (delegate.isMonitored(location)) {
monitorInformation = new MonitorInformation(true, delegate.getMonitor(location));
} else {
monitorInformation = NULL_MONITOR_INFORMATION;
}
monitorInformations.put(monitorKey, monitorInformation);
}
return monitorInformation;
} | [
"private",
"MonitorInformation",
"getMonitorInformation",
"(",
"L",
"location",
")",
"{",
"final",
"K",
"monitorKey",
"=",
"getLocationKey",
"(",
"location",
")",
";",
"MonitorInformation",
"monitorInformation",
"=",
"monitorInformations",
".",
"get",
"(",
"monitorKey... | Get monitor information for given location.
First monitor information is looked up in cache.
Then, when not found, delegate is called.
@param location Location
@return Monitor information | [
"Get",
"monitor",
"information",
"for",
"given",
"location",
".",
"First",
"monitor",
"information",
"is",
"looked",
"up",
"in",
"cache",
".",
"Then",
"when",
"not",
"found",
"delegate",
"is",
"called",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/source/CachedMonitorSource.java#L79-L92 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/source/CachedMonitorSource.java | CachedMonitorSource.getMonitor | @Override
public M getMonitor(L location) {
M monitor = getMonitorOnce(location);
// In case monitor was removed from manager, we retry
if (monitor == null) {
removeMonitorInformation(location);
monitor = getMonitorOnce(location);
}
return monitor;
} | java | @Override
public M getMonitor(L location) {
M monitor = getMonitorOnce(location);
// In case monitor was removed from manager, we retry
if (monitor == null) {
removeMonitorInformation(location);
monitor = getMonitorOnce(location);
}
return monitor;
} | [
"@",
"Override",
"public",
"M",
"getMonitor",
"(",
"L",
"location",
")",
"{",
"M",
"monitor",
"=",
"getMonitorOnce",
"(",
"location",
")",
";",
"// In case monitor was removed from manager, we retry",
"if",
"(",
"monitor",
"==",
"null",
")",
"{",
"removeMonitorInf... | Get Simon for the specified location.
Simon is retrieved from name in cache.
@param location Location
@return Simon for the specified location | [
"Get",
"Simon",
"for",
"the",
"specified",
"location",
".",
"Simon",
"is",
"retrieved",
"from",
"name",
"in",
"cache",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/source/CachedMonitorSource.java#L120-L129 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SLF4JLoggingCallback.java | SLF4JLoggingCallback.onStopwatchStop | @Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
logger.debug(marker, "SIMON STOP: {} ({})", sample.toString(), split.runningFor());
} | java | @Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
logger.debug(marker, "SIMON STOP: {} ({})", sample.toString(), split.runningFor());
} | [
"@",
"Override",
"public",
"void",
"onStopwatchStop",
"(",
"Split",
"split",
",",
"StopwatchSample",
"sample",
")",
"{",
"logger",
".",
"debug",
"(",
"marker",
",",
"\"SIMON STOP: {} ({})\"",
",",
"sample",
".",
"toString",
"(",
")",
",",
"split",
".",
"runn... | Logs Simon stop on a specified log marker.
@param split stopped split
@param sample stopwatch sample | [
"Logs",
"Simon",
"stop",
"on",
"a",
"specified",
"log",
"marker",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SLF4JLoggingCallback.java#L40-L43 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SLF4JLoggingCallback.java | SLF4JLoggingCallback.onManagerWarning | @Override
public void onManagerWarning(String warning, Exception cause) {
logger.debug(marker, "SIMON WARNING: {}", warning, cause);
} | java | @Override
public void onManagerWarning(String warning, Exception cause) {
logger.debug(marker, "SIMON WARNING: {}", warning, cause);
} | [
"@",
"Override",
"public",
"void",
"onManagerWarning",
"(",
"String",
"warning",
",",
"Exception",
"cause",
")",
"{",
"logger",
".",
"debug",
"(",
"marker",
",",
"\"SIMON WARNING: {}\"",
",",
"warning",
",",
"cause",
")",
";",
"}"
] | Logs the warning on a specified log marker.
@param warning warning message
@param cause throwable cause | [
"Logs",
"the",
"warning",
"on",
"a",
"specified",
"log",
"marker",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SLF4JLoggingCallback.java#L51-L54 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/proxy/DelegatingProxyFactory.java | DelegatingProxyFactory.newProxy | public Object newProxy(ClassLoader classLoader, Class<?>... interfaces) {
return Proxy.newProxyInstance(classLoader, interfaces, this);
} | java | public Object newProxy(ClassLoader classLoader, Class<?>... interfaces) {
return Proxy.newProxyInstance(classLoader, interfaces, this);
} | [
"public",
"Object",
"newProxy",
"(",
"ClassLoader",
"classLoader",
",",
"Class",
"<",
"?",
">",
"...",
"interfaces",
")",
"{",
"return",
"Proxy",
".",
"newProxyInstance",
"(",
"classLoader",
",",
"interfaces",
",",
"this",
")",
";",
"}"
] | Create a proxy using given classloader and interfaces
@param classLoader Class loader
@param interfaces Interfaces to implement
@return Proxy | [
"Create",
"a",
"proxy",
"using",
"given",
"classloader",
"and",
"interfaces"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/proxy/DelegatingProxyFactory.java#L56-L58 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/proxy/DelegatingProxyFactory.java | DelegatingProxyFactory.newProxy | public <X> X newProxy(Class<X> interfaces) {
return (X) newProxy(new Class[] {interfaces});
} | java | public <X> X newProxy(Class<X> interfaces) {
return (X) newProxy(new Class[] {interfaces});
} | [
"public",
"<",
"X",
">",
"X",
"newProxy",
"(",
"Class",
"<",
"X",
">",
"interfaces",
")",
"{",
"return",
"(",
"X",
")",
"newProxy",
"(",
"new",
"Class",
"[",
"]",
"{",
"interfaces",
"}",
")",
";",
"}"
] | Create a proxy using given classloader and interfaces.
@param interfaces Interface to implement
@return proxy | [
"Create",
"a",
"proxy",
"using",
"given",
"classloader",
"and",
"interfaces",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/proxy/DelegatingProxyFactory.java#L77-L79 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/logging/LogTemplates.java | LogTemplates.everyNSplits | public static <C> LogTemplate<C> everyNSplits(LogTemplate<C> delegateLogger, int period) {
return new CounterLogTemplate<>(delegateLogger, period);
} | java | public static <C> LogTemplate<C> everyNSplits(LogTemplate<C> delegateLogger, int period) {
return new CounterLogTemplate<>(delegateLogger, period);
} | [
"public",
"static",
"<",
"C",
">",
"LogTemplate",
"<",
"C",
">",
"everyNSplits",
"(",
"LogTemplate",
"<",
"C",
">",
"delegateLogger",
",",
"int",
"period",
")",
"{",
"return",
"new",
"CounterLogTemplate",
"<>",
"(",
"delegateLogger",
",",
"period",
")",
";... | Produces a log template which logs something every N split.
@param delegateLogger Concrete log template
@param period N value, period
@return Logger | [
"Produces",
"a",
"log",
"template",
"which",
"logs",
"something",
"every",
"N",
"split",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/logging/LogTemplates.java#L27-L29 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/logging/LogTemplates.java | LogTemplates.everyNSeconds | public static <C> LogTemplate<C> everyNSeconds(LogTemplate<C> delegateLogger, long period) {
return everyNMilliseconds(delegateLogger, period * SimonClock.MILLIS_IN_SECOND);
} | java | public static <C> LogTemplate<C> everyNSeconds(LogTemplate<C> delegateLogger, long period) {
return everyNMilliseconds(delegateLogger, period * SimonClock.MILLIS_IN_SECOND);
} | [
"public",
"static",
"<",
"C",
">",
"LogTemplate",
"<",
"C",
">",
"everyNSeconds",
"(",
"LogTemplate",
"<",
"C",
">",
"delegateLogger",
",",
"long",
"period",
")",
"{",
"return",
"everyNMilliseconds",
"(",
"delegateLogger",
",",
"period",
"*",
"SimonClock",
"... | Produces a log template which logs something at most every N secoonds.
@param delegateLogger Concrete log template
@param period N value in seconds, maximum period
@return Logger | [
"Produces",
"a",
"log",
"template",
"which",
"logs",
"something",
"at",
"most",
"every",
"N",
"secoonds",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/logging/LogTemplates.java#L61-L63 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/logging/LogTemplates.java | LogTemplates.toJUL | public static <C> JULLogTemplate<C> toJUL(String loggerName, Level level) {
return new JULLogTemplate<>(loggerName, level);
} | java | public static <C> JULLogTemplate<C> toJUL(String loggerName, Level level) {
return new JULLogTemplate<>(loggerName, level);
} | [
"public",
"static",
"<",
"C",
">",
"JULLogTemplate",
"<",
"C",
">",
"toJUL",
"(",
"String",
"loggerName",
",",
"Level",
"level",
")",
"{",
"return",
"new",
"JULLogTemplate",
"<>",
"(",
"loggerName",
",",
"level",
")",
";",
"}"
] | Produces a concrete log template which logs messages into a Java Util Logging Logger.
@param loggerName Logger name
@param level Level (warn, fine, finer, etc.)
@return Logger | [
"Produces",
"a",
"concrete",
"log",
"template",
"which",
"logs",
"messages",
"into",
"a",
"Java",
"Util",
"Logging",
"Logger",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/logging/LogTemplates.java#L103-L105 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/logging/LogTemplates.java | LogTemplates.whenSplitLongerThanMilliseconds | public static SplitThresholdLogTemplate whenSplitLongerThanMilliseconds(LogTemplate<Split> delegateLogger, long threshold) {
return whenSplitLongerThanNanoseconds(delegateLogger, threshold * SimonClock.NANOS_IN_MILLIS);
} | java | public static SplitThresholdLogTemplate whenSplitLongerThanMilliseconds(LogTemplate<Split> delegateLogger, long threshold) {
return whenSplitLongerThanNanoseconds(delegateLogger, threshold * SimonClock.NANOS_IN_MILLIS);
} | [
"public",
"static",
"SplitThresholdLogTemplate",
"whenSplitLongerThanMilliseconds",
"(",
"LogTemplate",
"<",
"Split",
">",
"delegateLogger",
",",
"long",
"threshold",
")",
"{",
"return",
"whenSplitLongerThanNanoseconds",
"(",
"delegateLogger",
",",
"threshold",
"*",
"Simo... | Produces a log template which logs something when stopwatch split is longer than threshold.
@param delegateLogger Concrete log template
@param threshold Threshold (in milliseconds), above which logging is enabled
@return Logger | [
"Produces",
"a",
"log",
"template",
"which",
"logs",
"something",
"when",
"stopwatch",
"split",
"is",
"longer",
"than",
"threshold",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/logging/LogTemplates.java#L125-L127 | train |
virgo47/javasimon | examples/src/main/java/org/javasimon/examples/ExampleUtils.java | ExampleUtils.waitRandomlySquared | public static void waitRandomlySquared(long maxMsRoot) {
long random = (long) (Math.random() * maxMsRoot);
try {
Thread.sleep(random * random);
} catch (InterruptedException e) {
e.printStackTrace();
}
} | java | public static void waitRandomlySquared(long maxMsRoot) {
long random = (long) (Math.random() * maxMsRoot);
try {
Thread.sleep(random * random);
} catch (InterruptedException e) {
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"waitRandomlySquared",
"(",
"long",
"maxMsRoot",
")",
"{",
"long",
"random",
"=",
"(",
"long",
")",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"maxMsRoot",
")",
";",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"random",
"*",
... | Method that lasts randomly from ~0 to the square of the specified amount of maxMsRoot.
This is just to avoid linear randomness.
@param maxMsRoot square root of the maximal waiting time | [
"Method",
"that",
"lasts",
"randomly",
"from",
"~0",
"to",
"the",
"square",
"of",
"the",
"specified",
"amount",
"of",
"maxMsRoot",
".",
"This",
"is",
"just",
"to",
"avoid",
"linear",
"randomness",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/examples/src/main/java/org/javasimon/examples/ExampleUtils.java#L24-L31 | train |
virgo47/javasimon | console-embed/src/main/java/org/javasimon/console/text/NoneStringifier.java | NoneStringifier.checkInstance | public static <T> Stringifier<T> checkInstance(Stringifier<T> stringifier) {
return INSTANCE==stringifier?null:stringifier;
} | java | public static <T> Stringifier<T> checkInstance(Stringifier<T> stringifier) {
return INSTANCE==stringifier?null:stringifier;
} | [
"public",
"static",
"<",
"T",
">",
"Stringifier",
"<",
"T",
">",
"checkInstance",
"(",
"Stringifier",
"<",
"T",
">",
"stringifier",
")",
"{",
"return",
"INSTANCE",
"==",
"stringifier",
"?",
"null",
":",
"stringifier",
";",
"}"
] | Check whether stringifier is the NoneStringifier
@param stringifier Stringifier to compare with NoneStringifier
@return null when stringifier==NoneStringifier, else given stringifier | [
"Check",
"whether",
"stringifier",
"is",
"the",
"NoneStringifier"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/console-embed/src/main/java/org/javasimon/console/text/NoneStringifier.java#L25-L27 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/source/DisabledMonitorSource.java | DisabledMonitorSource.get | @SuppressWarnings("unchecked")
public static <L, M extends Simon> DisabledMonitorSource<L, M> get() {
return (DisabledMonitorSource<L, M>) INSTANCE;
} | java | @SuppressWarnings("unchecked")
public static <L, M extends Simon> DisabledMonitorSource<L, M> get() {
return (DisabledMonitorSource<L, M>) INSTANCE;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"L",
",",
"M",
"extends",
"Simon",
">",
"DisabledMonitorSource",
"<",
"L",
",",
"M",
">",
"get",
"(",
")",
"{",
"return",
"(",
"DisabledMonitorSource",
"<",
"L",
",",
"M",
">",
... | Returns a singleton instance. | [
"Returns",
"a",
"singleton",
"instance",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/source/DisabledMonitorSource.java#L20-L23 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java | CompositeCallbackImpl.initialize | @Override
public synchronized void initialize(Manager manager) {
if (this.manager != null) {
throw new IllegalStateException("Callback was already initialized");
}
this.manager = manager;
for (Callback callback : callbacks) {
try {
callback.initialize(manager);
} catch (Exception e) {
onManagerWarning("Callback initialization error", e);
}
}
} | java | @Override
public synchronized void initialize(Manager manager) {
if (this.manager != null) {
throw new IllegalStateException("Callback was already initialized");
}
this.manager = manager;
for (Callback callback : callbacks) {
try {
callback.initialize(manager);
} catch (Exception e) {
onManagerWarning("Callback initialization error", e);
}
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"initialize",
"(",
"Manager",
"manager",
")",
"{",
"if",
"(",
"this",
".",
"manager",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Callback was already initialized\"",
")",
";",
"}",
... | Calls initialize on all children. | [
"Calls",
"initialize",
"on",
"all",
"children",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java#L27-L40 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java | CompositeCallbackImpl.addCallback | @Override
public void addCallback(Callback callback) {
if (manager != null) {
callback.initialize(manager);
}
callbacks.add(callback);
} | java | @Override
public void addCallback(Callback callback) {
if (manager != null) {
callback.initialize(manager);
}
callbacks.add(callback);
} | [
"@",
"Override",
"public",
"void",
"addCallback",
"(",
"Callback",
"callback",
")",
"{",
"if",
"(",
"manager",
"!=",
"null",
")",
"{",
"callback",
".",
"initialize",
"(",
"manager",
")",
";",
"}",
"callbacks",
".",
"add",
"(",
"callback",
")",
";",
"}"... | Adds another callback as a child to this callback.
@param callback added callback | [
"Adds",
"another",
"callback",
"as",
"a",
"child",
"to",
"this",
"callback",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java#L57-L63 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java | CompositeCallbackImpl.removeCallback | @Override
public void removeCallback(Callback callback) {
callbacks.remove(callback);
if (manager != null) {
callback.cleanup();
}
} | java | @Override
public void removeCallback(Callback callback) {
callbacks.remove(callback);
if (manager != null) {
callback.cleanup();
}
} | [
"@",
"Override",
"public",
"void",
"removeCallback",
"(",
"Callback",
"callback",
")",
"{",
"callbacks",
".",
"remove",
"(",
"callback",
")",
";",
"if",
"(",
"manager",
"!=",
"null",
")",
"{",
"callback",
".",
"cleanup",
"(",
")",
";",
"}",
"}"
] | Removes specified callback from this callback, properly cleans up the removed callback.
@param callback removed child-callback | [
"Removes",
"specified",
"callback",
"from",
"this",
"callback",
"properly",
"cleans",
"up",
"the",
"removed",
"callback",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java#L70-L76 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java | CompositeCallbackImpl.cleanup | @Override
public void cleanup() {
manager = null;
for (Callback callback : callbacks) {
try {
callback.cleanup();
} catch (Exception e) {
onManagerWarning("Callback cleanup error", e);
}
}
} | java | @Override
public void cleanup() {
manager = null;
for (Callback callback : callbacks) {
try {
callback.cleanup();
} catch (Exception e) {
onManagerWarning("Callback cleanup error", e);
}
}
} | [
"@",
"Override",
"public",
"void",
"cleanup",
"(",
")",
"{",
"manager",
"=",
"null",
";",
"for",
"(",
"Callback",
"callback",
":",
"callbacks",
")",
"{",
"try",
"{",
"callback",
".",
"cleanup",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",... | Calls deactivate on all children. | [
"Calls",
"deactivate",
"on",
"all",
"children",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/CompositeCallbackImpl.java#L87-L97 | train |
virgo47/javasimon | javaee/src/main/java/org/javasimon/javaee/MethodStopwatchSource.java | MethodStopwatchSource.getMonitorName | protected String getMonitorName(InvocationContext context) {
String className = context.getMethod().getDeclaringClass().getSimpleName();
String methodName = context.getMethod().getName();
return prefix + Manager.HIERARCHY_DELIMITER + className + Manager.HIERARCHY_DELIMITER + methodName;
} | java | protected String getMonitorName(InvocationContext context) {
String className = context.getMethod().getDeclaringClass().getSimpleName();
String methodName = context.getMethod().getName();
return prefix + Manager.HIERARCHY_DELIMITER + className + Manager.HIERARCHY_DELIMITER + methodName;
} | [
"protected",
"String",
"getMonitorName",
"(",
"InvocationContext",
"context",
")",
"{",
"String",
"className",
"=",
"context",
".",
"getMethod",
"(",
")",
".",
"getDeclaringClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
";",
"String",
"methodName",
"=",
"co... | Returns Simon name for the specified Invocation context.
By default it contains the prefix + method name.
This method can be overridden.
@param context Invocation context
@return fully qualified name of the Simon
@since 3.1 | [
"Returns",
"Simon",
"name",
"for",
"the",
"specified",
"Invocation",
"context",
".",
"By",
"default",
"it",
"contains",
"the",
"prefix",
"+",
"method",
"name",
".",
"This",
"method",
"can",
"be",
"overridden",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/javaee/src/main/java/org/javasimon/javaee/MethodStopwatchSource.java#L57-L61 | train |
virgo47/javasimon | console-embed/src/main/java/org/javasimon/console/reflect/Getter.java | Getter.get | public T get(Object source) {
try {
if (!method.isAccessible()) {
method.setAccessible(true);
}
@SuppressWarnings("unchecked")
T value=(T) method.invoke(source);
return value;
} catch (IllegalAccessException illegalAccessException) {
return null;
} catch (IllegalArgumentException illegalArgumentException) {
return null;
} catch (InvocationTargetException invocationTargetException) {
return null;
}
} | java | public T get(Object source) {
try {
if (!method.isAccessible()) {
method.setAccessible(true);
}
@SuppressWarnings("unchecked")
T value=(T) method.invoke(source);
return value;
} catch (IllegalAccessException illegalAccessException) {
return null;
} catch (IllegalArgumentException illegalArgumentException) {
return null;
} catch (InvocationTargetException invocationTargetException) {
return null;
}
} | [
"public",
"T",
"get",
"(",
"Object",
"source",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"method",
".",
"isAccessible",
"(",
")",
")",
"{",
"method",
".",
"setAccessible",
"(",
"true",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T... | Get value from source object using getter method
@param source Source object
@return Value | [
"Get",
"value",
"from",
"source",
"object",
"using",
"getter",
"method"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/console-embed/src/main/java/org/javasimon/console/reflect/Getter.java#L70-L85 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SimonUtils.java | SimonUtils.localName | public static String localName(String name) {
int ix = name.lastIndexOf(Manager.HIERARCHY_DELIMITER);
if (ix == -1) {
return name;
}
return name.substring(ix + 1);
} | java | public static String localName(String name) {
int ix = name.lastIndexOf(Manager.HIERARCHY_DELIMITER);
if (ix == -1) {
return name;
}
return name.substring(ix + 1);
} | [
"public",
"static",
"String",
"localName",
"(",
"String",
"name",
")",
"{",
"int",
"ix",
"=",
"name",
".",
"lastIndexOf",
"(",
"Manager",
".",
"HIERARCHY_DELIMITER",
")",
";",
"if",
"(",
"ix",
"==",
"-",
"1",
")",
"{",
"return",
"name",
";",
"}",
"re... | Returns last part of Simon name - local name.
@param name full Simon name
@return string containing local name | [
"Returns",
"last",
"part",
"of",
"Simon",
"name",
"-",
"local",
"name",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SimonUtils.java#L254-L260 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SimonUtils.java | SimonUtils.generatePrivate | private static String generatePrivate(String suffix, boolean includeMethodName) {
StackTraceElement stackElement = Thread.currentThread().getStackTrace()[CLIENT_CODE_STACK_INDEX];
StringBuilder nameBuilder = new StringBuilder(stackElement.getClassName());
if (includeMethodName) {
nameBuilder.append('.').append(stackElement.getMethodName());
}
if (suffix != null) {
nameBuilder.append(suffix);
}
return nameBuilder.toString();
} | java | private static String generatePrivate(String suffix, boolean includeMethodName) {
StackTraceElement stackElement = Thread.currentThread().getStackTrace()[CLIENT_CODE_STACK_INDEX];
StringBuilder nameBuilder = new StringBuilder(stackElement.getClassName());
if (includeMethodName) {
nameBuilder.append('.').append(stackElement.getMethodName());
}
if (suffix != null) {
nameBuilder.append(suffix);
}
return nameBuilder.toString();
} | [
"private",
"static",
"String",
"generatePrivate",
"(",
"String",
"suffix",
",",
"boolean",
"includeMethodName",
")",
"{",
"StackTraceElement",
"stackElement",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getStackTrace",
"(",
")",
"[",
"CLIENT_CODE_STACK_INDE... | method is extracted, so the stack trace index is always right | [
"method",
"is",
"extracted",
"so",
"the",
"stack",
"trace",
"index",
"is",
"always",
"right"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SimonUtils.java#L312-L322 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SimonUtils.java | SimonUtils.doWithStopwatch | public static <T> T doWithStopwatch(String name, Callable<T> callable) throws Exception {
try (Split split = SimonManager.getStopwatch(name).start()) {
return callable.call();
}
} | java | public static <T> T doWithStopwatch(String name, Callable<T> callable) throws Exception {
try (Split split = SimonManager.getStopwatch(name).start()) {
return callable.call();
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"doWithStopwatch",
"(",
"String",
"name",
",",
"Callable",
"<",
"T",
">",
"callable",
")",
"throws",
"Exception",
"{",
"try",
"(",
"Split",
"split",
"=",
"SimonManager",
".",
"getStopwatch",
"(",
"name",
")",
".",
... | Calls a block of code with stopwatch around and returns result.
@param name name of the Stopwatch
@param callable callable block of code
@param <T> return type
@return whatever block of code returns
@throws Exception whatever block of code throws
@since 3.0 | [
"Calls",
"a",
"block",
"of",
"code",
"with",
"stopwatch",
"around",
"and",
"returns",
"result",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SimonUtils.java#L344-L348 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SimonUtils.java | SimonUtils.compact | public static String compact(String input, int limitTo) {
if (input == null || input.length() <= limitTo) {
return input;
}
int headLength = limitTo / 2;
int tailLength = limitTo - SHRINKED_STRING.length() - headLength;
if (tailLength < 0) {
tailLength = 1;
}
return input.substring(0, headLength) + SHRINKED_STRING + input.substring(input.length() - tailLength);
} | java | public static String compact(String input, int limitTo) {
if (input == null || input.length() <= limitTo) {
return input;
}
int headLength = limitTo / 2;
int tailLength = limitTo - SHRINKED_STRING.length() - headLength;
if (tailLength < 0) {
tailLength = 1;
}
return input.substring(0, headLength) + SHRINKED_STRING + input.substring(input.length() - tailLength);
} | [
"public",
"static",
"String",
"compact",
"(",
"String",
"input",
",",
"int",
"limitTo",
")",
"{",
"if",
"(",
"input",
"==",
"null",
"||",
"input",
".",
"length",
"(",
")",
"<=",
"limitTo",
")",
"{",
"return",
"input",
";",
"}",
"int",
"headLength",
"... | Shrinks the middle of the input string if it is too long, so it does not exceed limitTo.
@since 3.2 | [
"Shrinks",
"the",
"middle",
"of",
"the",
"input",
"string",
"if",
"it",
"is",
"too",
"long",
"so",
"it",
"does",
"not",
"exceed",
"limitTo",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SimonUtils.java#L371-L383 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SimonUtils.java | SimonUtils.calculateStopwatchAggregate | public static StopwatchAggregate calculateStopwatchAggregate(Simon simon, SimonFilter filter) {
StopwatchAggregate stopwatchAggregate = new StopwatchAggregate();
aggregateStopwatches(stopwatchAggregate, simon,
filter != null ? filter : SimonFilter.ACCEPT_ALL_FILTER);
return stopwatchAggregate;
} | java | public static StopwatchAggregate calculateStopwatchAggregate(Simon simon, SimonFilter filter) {
StopwatchAggregate stopwatchAggregate = new StopwatchAggregate();
aggregateStopwatches(stopwatchAggregate, simon,
filter != null ? filter : SimonFilter.ACCEPT_ALL_FILTER);
return stopwatchAggregate;
} | [
"public",
"static",
"StopwatchAggregate",
"calculateStopwatchAggregate",
"(",
"Simon",
"simon",
",",
"SimonFilter",
"filter",
")",
"{",
"StopwatchAggregate",
"stopwatchAggregate",
"=",
"new",
"StopwatchAggregate",
"(",
")",
";",
"aggregateStopwatches",
"(",
"stopwatchAggr... | Aggregate statistics from all stopwatches in hierarchy that pass specified filter. Filter is applied
to all simons in the hierarchy of all types. If a simon is rejected by filter its children are not considered.
Simons are aggregated in the top-bottom fashion, i.e. parent simons are aggregated before children.
@param simon root of the hierarchy of simons for which statistics will be aggregated
@param filter filter to select subsets of simons to aggregate
@return aggregates statistics
@since 3.5 | [
"Aggregate",
"statistics",
"from",
"all",
"stopwatches",
"in",
"hierarchy",
"that",
"pass",
"specified",
"filter",
".",
"Filter",
"is",
"applied",
"to",
"all",
"simons",
"in",
"the",
"hierarchy",
"of",
"all",
"types",
".",
"If",
"a",
"simon",
"is",
"rejected... | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SimonUtils.java#L406-L412 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SimonUtils.java | SimonUtils.calculateCounterAggregate | public static CounterAggregate calculateCounterAggregate(Simon simon, SimonFilter filter) {
CounterAggregate aggregate = new CounterAggregate();
aggregateCounters(aggregate, simon,
filter != null ? filter : SimonFilter.ACCEPT_ALL_FILTER);
return aggregate;
} | java | public static CounterAggregate calculateCounterAggregate(Simon simon, SimonFilter filter) {
CounterAggregate aggregate = new CounterAggregate();
aggregateCounters(aggregate, simon,
filter != null ? filter : SimonFilter.ACCEPT_ALL_FILTER);
return aggregate;
} | [
"public",
"static",
"CounterAggregate",
"calculateCounterAggregate",
"(",
"Simon",
"simon",
",",
"SimonFilter",
"filter",
")",
"{",
"CounterAggregate",
"aggregate",
"=",
"new",
"CounterAggregate",
"(",
")",
";",
"aggregateCounters",
"(",
"aggregate",
",",
"simon",
"... | Aggregate statistics from all counters in hierarchy that pass specified filter. Filter is applied
to all simons in the hierarchy of all types. If a simon is rejected by filter its children are not considered.
Simons are aggregated in the top-bottom fashion, i.e. parent simons are aggregated before children.
@param simon root of the hierarchy of simons for which statistics will be aggregated
@param filter filter to select subsets of simons to aggregate
@return aggregates statistics
@since 3.5 | [
"Aggregate",
"statistics",
"from",
"all",
"counters",
"in",
"hierarchy",
"that",
"pass",
"specified",
"filter",
".",
"Filter",
"is",
"applied",
"to",
"all",
"simons",
"in",
"the",
"hierarchy",
"of",
"all",
"types",
".",
"If",
"a",
"simon",
"is",
"rejected",
... | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SimonUtils.java#L448-L454 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/AbstractSimon.java | AbstractSimon.addChild | final void addChild(AbstractSimon simon) {
children.add(simon);
simon.setParent(this);
simon.enabled = enabled;
} | java | final void addChild(AbstractSimon simon) {
children.add(simon);
simon.setParent(this);
simon.enabled = enabled;
} | [
"final",
"void",
"addChild",
"(",
"AbstractSimon",
"simon",
")",
"{",
"children",
".",
"add",
"(",
"simon",
")",
";",
"simon",
".",
"setParent",
"(",
"this",
")",
";",
"simon",
".",
"enabled",
"=",
"enabled",
";",
"}"
] | Adds child to this Simon with setting the parent of the child.
@param simon future child of this Simon | [
"Adds",
"child",
"to",
"this",
"Simon",
"with",
"setting",
"the",
"parent",
"of",
"the",
"child",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/AbstractSimon.java#L82-L86 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/AbstractSimon.java | AbstractSimon.setAttribute | @Override
public void setAttribute(String name, Object value) {
attributesSupport.setAttribute(name, value);
} | java | @Override
public void setAttribute(String name, Object value) {
attributesSupport.setAttribute(name, value);
} | [
"@",
"Override",
"public",
"void",
"setAttribute",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"attributesSupport",
".",
"setAttribute",
"(",
"name",
",",
"value",
")",
";",
"}"
] | Stores an attribute in this Simon. Attributes can be used to store any custom objects.
@param name a String specifying the name of the attribute
@param value the Object to be stored
@since 2.3 | [
"Stores",
"an",
"attribute",
"in",
"this",
"Simon",
".",
"Attributes",
"can",
"be",
"used",
"to",
"store",
"any",
"custom",
"objects",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/AbstractSimon.java#L194-L197 | train |
virgo47/javasimon | console-embed/src/main/java/org/javasimon/console/action/ResourceAction.java | ResourceAction.copyStream | private void copyStream(InputStream inputStream) throws IOException {
OutputStream outputStream = null;
try {
outputStream = getContext().getOutputStream();
byte[] buffer = new byte[65535];
int bufferLen;
int totalLen = 0;
while ((bufferLen = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, bufferLen);
totalLen += bufferLen;
}
getContext().getResponse().setContentLength(totalLen);
} finally {
if (outputStream != null) {
outputStream.flush();
}
}
} | java | private void copyStream(InputStream inputStream) throws IOException {
OutputStream outputStream = null;
try {
outputStream = getContext().getOutputStream();
byte[] buffer = new byte[65535];
int bufferLen;
int totalLen = 0;
while ((bufferLen = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, bufferLen);
totalLen += bufferLen;
}
getContext().getResponse().setContentLength(totalLen);
} finally {
if (outputStream != null) {
outputStream.flush();
}
}
} | [
"private",
"void",
"copyStream",
"(",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"OutputStream",
"outputStream",
"=",
"null",
";",
"try",
"{",
"outputStream",
"=",
"getContext",
"(",
")",
".",
"getOutputStream",
"(",
")",
";",
"byte",
"["... | Copy resource input stream to HTTP response output stream using
a 64kib buffer | [
"Copy",
"resource",
"input",
"stream",
"to",
"HTTP",
"response",
"output",
"stream",
"using",
"a",
"64kib",
"buffer"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/console-embed/src/main/java/org/javasimon/console/action/ResourceAction.java#L86-L103 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/bean/SimonBeanUtils.java | SimonBeanUtils.setProperty | public void setProperty(Object target, String property, Object value) {
NestedResolver resolver = new NestedResolver(target, property);
if (value instanceof String) {
convertStringValue(resolver.getNestedTarget(), resolver.getProperty(), (String) value);
} else {
setObjectValue(resolver.getNestedTarget(), resolver.getProperty(), value);
}
} | java | public void setProperty(Object target, String property, Object value) {
NestedResolver resolver = new NestedResolver(target, property);
if (value instanceof String) {
convertStringValue(resolver.getNestedTarget(), resolver.getProperty(), (String) value);
} else {
setObjectValue(resolver.getNestedTarget(), resolver.getProperty(), value);
}
} | [
"public",
"void",
"setProperty",
"(",
"Object",
"target",
",",
"String",
"property",
",",
"Object",
"value",
")",
"{",
"NestedResolver",
"resolver",
"=",
"new",
"NestedResolver",
"(",
"target",
",",
"property",
")",
";",
"if",
"(",
"value",
"instanceof",
"St... | Set property in object target. If values has type other than String setter method or field
with specified type will be used to set value. If value has String type value will be converted
using available converters. If conversion to all of the types accepted by setters fails, field
with corresponding name will be used
@param target Java bean where a property will be set
@param property property to be set
@param value value to be set | [
"Set",
"property",
"in",
"object",
"target",
".",
"If",
"values",
"has",
"type",
"other",
"than",
"String",
"setter",
"method",
"or",
"field",
"with",
"specified",
"type",
"will",
"be",
"used",
"to",
"set",
"value",
".",
"If",
"value",
"has",
"String",
"... | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/bean/SimonBeanUtils.java#L69-L77 | train |
virgo47/javasimon | javaee/src/main/java/org/javasimon/javaee/HttpStopwatchSource.java | HttpStopwatchSource.getMonitor | @Override
public Stopwatch getMonitor(HttpServletRequest request) {
final Stopwatch stopwatch = super.getMonitor(request);
if (stopwatch.getNote() == null) {
stopwatch.setNote(request.getRequestURI());
}
return stopwatch;
} | java | @Override
public Stopwatch getMonitor(HttpServletRequest request) {
final Stopwatch stopwatch = super.getMonitor(request);
if (stopwatch.getNote() == null) {
stopwatch.setNote(request.getRequestURI());
}
return stopwatch;
} | [
"@",
"Override",
"public",
"Stopwatch",
"getMonitor",
"(",
"HttpServletRequest",
"request",
")",
"{",
"final",
"Stopwatch",
"stopwatch",
"=",
"super",
".",
"getMonitor",
"(",
"request",
")",
";",
"if",
"(",
"stopwatch",
".",
"getNote",
"(",
")",
"==",
"null"... | Get a stopwatch for given HTTP request.
@param request Method HTTP request
@return Stopwatch for the HTTP request | [
"Get",
"a",
"stopwatch",
"for",
"given",
"HTTP",
"request",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/javaee/src/main/java/org/javasimon/javaee/HttpStopwatchSource.java#L206-L213 | train |
virgo47/javasimon | javaee/src/main/java/org/javasimon/javaee/HttpStopwatchSource.java | HttpStopwatchSource.newCacheStopwatchSource | public static StopwatchSource<HttpServletRequest> newCacheStopwatchSource(StopwatchSource<HttpServletRequest> stopwatchSource) {
return new CachedStopwatchSource<HttpServletRequest, String>(stopwatchSource) {
@Override
protected String getLocationKey(HttpServletRequest location) {
return location.getRequestURI();
}
};
} | java | public static StopwatchSource<HttpServletRequest> newCacheStopwatchSource(StopwatchSource<HttpServletRequest> stopwatchSource) {
return new CachedStopwatchSource<HttpServletRequest, String>(stopwatchSource) {
@Override
protected String getLocationKey(HttpServletRequest location) {
return location.getRequestURI();
}
};
} | [
"public",
"static",
"StopwatchSource",
"<",
"HttpServletRequest",
">",
"newCacheStopwatchSource",
"(",
"StopwatchSource",
"<",
"HttpServletRequest",
">",
"stopwatchSource",
")",
"{",
"return",
"new",
"CachedStopwatchSource",
"<",
"HttpServletRequest",
",",
"String",
">",
... | Wraps given stop watch source in a cache.
@param stopwatchSource Stopwatch source
@return Cached stopwatch source | [
"Wraps",
"given",
"stop",
"watch",
"source",
"in",
"a",
"cache",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/javaee/src/main/java/org/javasimon/javaee/HttpStopwatchSource.java#L221-L228 | train |
virgo47/javasimon | examples/src/main/java/org/javasimon/examples/CallbackFilteringExample.java | CallbackFilteringExample.main | public static void main(String[] args) {
// manager with two stopwatches is created
Manager manager = new EnabledManager();
Stopwatch sw1 = manager.getStopwatch("org.javasimon.examples.stopwatch1");
Stopwatch sw2 = manager.getStopwatch("other.stopwatch2");
// simple callback printing actions to the stdout is created and installed
Callback stdoutCallback = new CallbackSkeleton() {
@Override
public void onStopwatchStart(Split split) {
System.out.println("Starting " + split.getStopwatch().getName());
}
@Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
System.out.println("Stopped " + split.getStopwatch().getName() + " (" + SimonUtils.presentNanoTime(split.runningFor()) + ")");
}
};
manager.callback().addCallback(stdoutCallback);
// prints start/stop for both stopwatches
sw1.start().stop();
sw2.start().stop();
System.out.println();
// we need to remove old callback
manager.callback().removeCallback(stdoutCallback);
// alternatively you can call this if you want to remove all callbacks
SimonManager.callback().removeAllCallbacks();
// filter callback is created
CompositeFilterCallback filter = new CompositeFilterCallback();
// rule to filter out all Simons matching pattern "other.*" is added
filter.addRule(FilterRule.Type.MUST_NOT, null, "other.*");
// original callback is added after this callback
filter.addCallback(stdoutCallback);
// filter callback is installed to the manager (with printing callback behind)
manager.callback().addCallback(filter);
// start/stop is printed only for sw1 because sw2 matches other.* pattern that is excluded (MUST_NOT)
sw1.start().stop();
sw2.start().stop();
} | java | public static void main(String[] args) {
// manager with two stopwatches is created
Manager manager = new EnabledManager();
Stopwatch sw1 = manager.getStopwatch("org.javasimon.examples.stopwatch1");
Stopwatch sw2 = manager.getStopwatch("other.stopwatch2");
// simple callback printing actions to the stdout is created and installed
Callback stdoutCallback = new CallbackSkeleton() {
@Override
public void onStopwatchStart(Split split) {
System.out.println("Starting " + split.getStopwatch().getName());
}
@Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
System.out.println("Stopped " + split.getStopwatch().getName() + " (" + SimonUtils.presentNanoTime(split.runningFor()) + ")");
}
};
manager.callback().addCallback(stdoutCallback);
// prints start/stop for both stopwatches
sw1.start().stop();
sw2.start().stop();
System.out.println();
// we need to remove old callback
manager.callback().removeCallback(stdoutCallback);
// alternatively you can call this if you want to remove all callbacks
SimonManager.callback().removeAllCallbacks();
// filter callback is created
CompositeFilterCallback filter = new CompositeFilterCallback();
// rule to filter out all Simons matching pattern "other.*" is added
filter.addRule(FilterRule.Type.MUST_NOT, null, "other.*");
// original callback is added after this callback
filter.addCallback(stdoutCallback);
// filter callback is installed to the manager (with printing callback behind)
manager.callback().addCallback(filter);
// start/stop is printed only for sw1 because sw2 matches other.* pattern that is excluded (MUST_NOT)
sw1.start().stop();
sw2.start().stop();
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"// manager with two stopwatches is created",
"Manager",
"manager",
"=",
"new",
"EnabledManager",
"(",
")",
";",
"Stopwatch",
"sw1",
"=",
"manager",
".",
"getStopwatch",
"(",
"\"org.j... | Entry point to the Callback Filtering Example.
@param args unused | [
"Entry",
"point",
"to",
"the",
"Callback",
"Filtering",
"Example",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/examples/src/main/java/org/javasimon/examples/CallbackFilteringExample.java#L26-L69 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/bean/ClassUtils.java | ClassUtils.getField | static Field getField(Class<?> targetClass, String fieldName) {
while (targetClass != null) {
try {
Field field = targetClass.getDeclaredField(fieldName);
logger.debug("Found field {} in class {}", fieldName, targetClass.getName());
return field;
} catch (NoSuchFieldException e) {
logger.debug("Failed to find field {} in class {}", fieldName, targetClass.getName());
}
targetClass = targetClass.getSuperclass();
}
return null;
} | java | static Field getField(Class<?> targetClass, String fieldName) {
while (targetClass != null) {
try {
Field field = targetClass.getDeclaredField(fieldName);
logger.debug("Found field {} in class {}", fieldName, targetClass.getName());
return field;
} catch (NoSuchFieldException e) {
logger.debug("Failed to find field {} in class {}", fieldName, targetClass.getName());
}
targetClass = targetClass.getSuperclass();
}
return null;
} | [
"static",
"Field",
"getField",
"(",
"Class",
"<",
"?",
">",
"targetClass",
",",
"String",
"fieldName",
")",
"{",
"while",
"(",
"targetClass",
"!=",
"null",
")",
"{",
"try",
"{",
"Field",
"field",
"=",
"targetClass",
".",
"getDeclaredField",
"(",
"fieldName... | Get field with the specified name.
@param targetClass class for which a field will be returned
@param fieldName name of the field that should be returned
@return field with the specified name if one exists, null otherwise | [
"Get",
"field",
"with",
"the",
"specified",
"name",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/bean/ClassUtils.java#L31-L44 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/bean/ClassUtils.java | ClassUtils.getSetters | static Set<Method> getSetters(Class<?> targetClass, String propertyName) {
String setterName = setterName(propertyName);
Set<Method> setters = new HashSet<>();
while (targetClass != null) {
for (Method method : targetClass.getDeclaredMethods()) {
if (method.getName().equals(setterName) && method.getParameterTypes().length == 1) {
logger.debug("Found setter {} in class {}", method, targetClass);
setters.add(method);
}
}
targetClass = targetClass.getSuperclass();
}
return setters;
} | java | static Set<Method> getSetters(Class<?> targetClass, String propertyName) {
String setterName = setterName(propertyName);
Set<Method> setters = new HashSet<>();
while (targetClass != null) {
for (Method method : targetClass.getDeclaredMethods()) {
if (method.getName().equals(setterName) && method.getParameterTypes().length == 1) {
logger.debug("Found setter {} in class {}", method, targetClass);
setters.add(method);
}
}
targetClass = targetClass.getSuperclass();
}
return setters;
} | [
"static",
"Set",
"<",
"Method",
">",
"getSetters",
"(",
"Class",
"<",
"?",
">",
"targetClass",
",",
"String",
"propertyName",
")",
"{",
"String",
"setterName",
"=",
"setterName",
"(",
"propertyName",
")",
";",
"Set",
"<",
"Method",
">",
"setters",
"=",
"... | Get all setters for the specified property
@param targetClass class for which setters will be returned
@param propertyName name of the property for which setters will be returned
@return possible setters for the specified property * | [
"Get",
"all",
"setters",
"for",
"the",
"specified",
"property"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/bean/ClassUtils.java#L89-L104 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/bean/ClassUtils.java | ClassUtils.getSetterType | static Class<?> getSetterType(Method setter) {
Class<?>[] parameterTypes = setter.getParameterTypes();
if (parameterTypes.length != 1) {
throw new BeanUtilsException(
String.format("Method %s has %d parameters and cannot be a setter", setter.getName(), parameterTypes.length));
}
return parameterTypes[0];
} | java | static Class<?> getSetterType(Method setter) {
Class<?>[] parameterTypes = setter.getParameterTypes();
if (parameterTypes.length != 1) {
throw new BeanUtilsException(
String.format("Method %s has %d parameters and cannot be a setter", setter.getName(), parameterTypes.length));
}
return parameterTypes[0];
} | [
"static",
"Class",
"<",
"?",
">",
"getSetterType",
"(",
"Method",
"setter",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
"=",
"setter",
".",
"getParameterTypes",
"(",
")",
";",
"if",
"(",
"parameterTypes",
".",
"length",
"!=",
"1",
")"... | Get property type by a setter method.
@param setter setter of Java bean class
@return type of the specified setter method
@throws org.javasimon.utils.bean.BeanUtilsException if specified method does not has setter signature | [
"Get",
"property",
"type",
"by",
"a",
"setter",
"method",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/bean/ClassUtils.java#L112-L120 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/bean/ClassUtils.java | ClassUtils.getGetter | static Method getGetter(Class<?> targetClass, String propertyName) {
if (targetClass == null) {
return null;
}
final String getterName = getterName(propertyName, false);
Method result = findPublicGetter(targetClass, getterName, propertyName, false);
if (result == null) {
final String booleanGetterName = getterName(propertyName, true);
result = findPublicGetter(targetClass, booleanGetterName, propertyName, true);
if (result == null) {
do {
result = findNonPublicGetter(targetClass, getterName, propertyName, false);
if (result == null) {
result = findNonPublicGetter(targetClass, booleanGetterName, propertyName, true);
}
} while (result == null && (targetClass = targetClass.getSuperclass()) != null);
}
}
return result;
} | java | static Method getGetter(Class<?> targetClass, String propertyName) {
if (targetClass == null) {
return null;
}
final String getterName = getterName(propertyName, false);
Method result = findPublicGetter(targetClass, getterName, propertyName, false);
if (result == null) {
final String booleanGetterName = getterName(propertyName, true);
result = findPublicGetter(targetClass, booleanGetterName, propertyName, true);
if (result == null) {
do {
result = findNonPublicGetter(targetClass, getterName, propertyName, false);
if (result == null) {
result = findNonPublicGetter(targetClass, booleanGetterName, propertyName, true);
}
} while (result == null && (targetClass = targetClass.getSuperclass()) != null);
}
}
return result;
} | [
"static",
"Method",
"getGetter",
"(",
"Class",
"<",
"?",
">",
"targetClass",
",",
"String",
"propertyName",
")",
"{",
"if",
"(",
"targetClass",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"String",
"getterName",
"=",
"getterName",
"(",
"... | Get getter method for a specified property.
@param targetClass class for which a getter will be returned
@param propertyName name of the property for which a getter will be returned
@return getter of a specified property if one exists, null otherwise | [
"Get",
"getter",
"method",
"for",
"a",
"specified",
"property",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/bean/ClassUtils.java#L128-L148 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/proxy/StopwatchProxyFactory.java | StopwatchProxyFactory.invoke | @Override
protected Object invoke(DelegatingMethodInvocation<T> methodInvocation) throws Throwable {
final Split split = stopwatchSource.start(methodInvocation);
try {
return methodInvocation.proceed();
} finally {
split.stop();
}
} | java | @Override
protected Object invoke(DelegatingMethodInvocation<T> methodInvocation) throws Throwable {
final Split split = stopwatchSource.start(methodInvocation);
try {
return methodInvocation.proceed();
} finally {
split.stop();
}
} | [
"@",
"Override",
"protected",
"Object",
"invoke",
"(",
"DelegatingMethodInvocation",
"<",
"T",
">",
"methodInvocation",
")",
"throws",
"Throwable",
"{",
"final",
"Split",
"split",
"=",
"stopwatchSource",
".",
"start",
"(",
"methodInvocation",
")",
";",
"try",
"{... | Invocation handler main method. | [
"Invocation",
"handler",
"main",
"method",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/proxy/StopwatchProxyFactory.java#L44-L52 | train |
virgo47/javasimon | spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java | MonitoringHandlerInterceptor.startStopwatch | protected final Split startStopwatch(HandlerLocation location) {
Split split = stopwatchSource.start(location);
location.setSplit(split);
return split;
} | java | protected final Split startStopwatch(HandlerLocation location) {
Split split = stopwatchSource.start(location);
location.setSplit(split);
return split;
} | [
"protected",
"final",
"Split",
"startStopwatch",
"(",
"HandlerLocation",
"location",
")",
"{",
"Split",
"split",
"=",
"stopwatchSource",
".",
"start",
"(",
"location",
")",
";",
"location",
".",
"setSplit",
"(",
"split",
")",
";",
"return",
"split",
";",
"}"... | Start stopwatch for given name and thread.
@return Running split | [
"Start",
"stopwatch",
"for",
"given",
"name",
"and",
"thread",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java#L67-L71 | train |
virgo47/javasimon | spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java | MonitoringHandlerInterceptor.preHandle | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
final HandlerLocation location = new HandlerLocation(request, handler, HandlerStep.CONTROLLER);
threadLocation.set(location);
// Start controller stopwatch
startStopwatch(location);
return true;
} | java | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
final HandlerLocation location = new HandlerLocation(request, handler, HandlerStep.CONTROLLER);
threadLocation.set(location);
// Start controller stopwatch
startStopwatch(location);
return true;
} | [
"public",
"boolean",
"preHandle",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"Object",
"handler",
")",
"{",
"final",
"HandlerLocation",
"location",
"=",
"new",
"HandlerLocation",
"(",
"request",
",",
"handler",
",",
"HandlerSt... | Invoked before controller. | [
"Invoked",
"before",
"controller",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java#L92-L99 | train |
virgo47/javasimon | spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java | MonitoringHandlerInterceptor.postHandle | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
// Stop controller stopwatch
stopStopwatch();
HandlerLocation location = threadLocation.get();
location.setStep(HandlerStep.VIEW);
// Start view stopwatch
startStopwatch(location);
} | java | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
// Stop controller stopwatch
stopStopwatch();
HandlerLocation location = threadLocation.get();
location.setStep(HandlerStep.VIEW);
// Start view stopwatch
startStopwatch(location);
} | [
"public",
"void",
"postHandle",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"Object",
"handler",
",",
"ModelAndView",
"modelAndView",
")",
"{",
"// Stop controller stopwatch\r",
"stopStopwatch",
"(",
")",
";",
"HandlerLocation",
"l... | Invoked between controller and view. | [
"Invoked",
"between",
"controller",
"and",
"view",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java#L104-L113 | train |
virgo47/javasimon | spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java | MonitoringHandlerInterceptor.afterCompletion | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
// Stop view stopwatch
stopStopwatch();
// Remove location
threadLocation.remove();
} | java | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
// Stop view stopwatch
stopStopwatch();
// Remove location
threadLocation.remove();
} | [
"public",
"void",
"afterCompletion",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"Object",
"handler",
",",
"Exception",
"ex",
")",
"{",
"// Stop view stopwatch\r",
"stopStopwatch",
"(",
")",
";",
"// Remove location\r",
"threadLoca... | Invoked after view. | [
"Invoked",
"after",
"view",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/spring/src/main/java/org/javasimon/spring/webmvc/MonitoringHandlerInterceptor.java#L118-L124 | train |
virgo47/javasimon | jdbc41/src/main/java/org/javasimon/jdbcx4/AbstractSimonDataSource.java | AbstractSimonDataSource.getRealDataSourceClassName | public final String getRealDataSourceClassName() {
if ((realDataSourceClassName == null || realDataSourceClassName.isEmpty()) && (configuration != null)) {
realDataSourceClassName = doGetRealDataSourceClassName();
}
return realDataSourceClassName;
} | java | public final String getRealDataSourceClassName() {
if ((realDataSourceClassName == null || realDataSourceClassName.isEmpty()) && (configuration != null)) {
realDataSourceClassName = doGetRealDataSourceClassName();
}
return realDataSourceClassName;
} | [
"public",
"final",
"String",
"getRealDataSourceClassName",
"(",
")",
"{",
"if",
"(",
"(",
"realDataSourceClassName",
"==",
"null",
"||",
"realDataSourceClassName",
".",
"isEmpty",
"(",
")",
")",
"&&",
"(",
"configuration",
"!=",
"null",
")",
")",
"{",
"realDat... | Returns real datasource class name.
@return real datasource class name | [
"Returns",
"real",
"datasource",
"class",
"name",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbcx4/AbstractSimonDataSource.java#L158-L163 | train |
virgo47/javasimon | jdbc41/src/main/java/org/javasimon/jdbcx4/AbstractSimonDataSource.java | AbstractSimonDataSource.createDataSource | protected final <T> T createDataSource(Class<T> dataSourceClass) throws SQLException {
if (getRealDataSourceClassName() == null) {
throw new SQLException("Property realDataSourceClassName is not set");
}
try {
T ds = dataSourceClass.cast(Class.forName(realDataSourceClassName).newInstance());
for (Method m : ds.getClass().getMethods()) {
String methodName = m.getName();
if (methodName.startsWith("set") && m.getParameterTypes().length == 1) {
final Object propertyValue;
if (methodName.equals("setUser")) {
propertyValue = getUser();
} else if (methodName.equals("setPassword")) {
propertyValue = getPassword();
} else if (methodName.equalsIgnoreCase("setUrl")) {
propertyValue = getRealUrl();
} else if (methodName.equals("setLogWriter")) {
propertyValue = getLogWriter();
} else if (methodName.equals("setLoginTimeout")) {
propertyValue = getLoginTimeout();
} else {
String propertyName = methodName.substring(3, 4).toLowerCase();
if (methodName.length() > 4) {
propertyName += methodName.substring(4);
}
final Class<?> propertyType = m.getParameterTypes()[0];
propertyValue = getPropertyAs(propertyName, propertyType);
}
if (propertyValue != null) {
m.invoke(ds, propertyValue);
}
}
}
return ds;
} catch (Exception e) {
throw new SQLException(e);
}
} | java | protected final <T> T createDataSource(Class<T> dataSourceClass) throws SQLException {
if (getRealDataSourceClassName() == null) {
throw new SQLException("Property realDataSourceClassName is not set");
}
try {
T ds = dataSourceClass.cast(Class.forName(realDataSourceClassName).newInstance());
for (Method m : ds.getClass().getMethods()) {
String methodName = m.getName();
if (methodName.startsWith("set") && m.getParameterTypes().length == 1) {
final Object propertyValue;
if (methodName.equals("setUser")) {
propertyValue = getUser();
} else if (methodName.equals("setPassword")) {
propertyValue = getPassword();
} else if (methodName.equalsIgnoreCase("setUrl")) {
propertyValue = getRealUrl();
} else if (methodName.equals("setLogWriter")) {
propertyValue = getLogWriter();
} else if (methodName.equals("setLoginTimeout")) {
propertyValue = getLoginTimeout();
} else {
String propertyName = methodName.substring(3, 4).toLowerCase();
if (methodName.length() > 4) {
propertyName += methodName.substring(4);
}
final Class<?> propertyType = m.getParameterTypes()[0];
propertyValue = getPropertyAs(propertyName, propertyType);
}
if (propertyValue != null) {
m.invoke(ds, propertyValue);
}
}
}
return ds;
} catch (Exception e) {
throw new SQLException(e);
}
} | [
"protected",
"final",
"<",
"T",
">",
"T",
"createDataSource",
"(",
"Class",
"<",
"T",
">",
"dataSourceClass",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"getRealDataSourceClassName",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"SQLException",
"(",
... | Instantiates the DataSource.
@param dataSourceClass Expected DataSource class
@param <T> DataSource type
@return Create DataSource
@throws SQLException | [
"Instantiates",
"the",
"DataSource",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbcx4/AbstractSimonDataSource.java#L182-L220 | train |
virgo47/javasimon | jdbc41/src/main/java/org/javasimon/jdbcx4/AbstractSimonDataSource.java | AbstractSimonDataSource.getPrefix | public final String getPrefix() {
if ((prefix == null || prefix.isEmpty()) && (configuration != null)) {
prefix = configuration.getPrefix();
}
return prefix;
} | java | public final String getPrefix() {
if ((prefix == null || prefix.isEmpty()) && (configuration != null)) {
prefix = configuration.getPrefix();
}
return prefix;
} | [
"public",
"final",
"String",
"getPrefix",
"(",
")",
"{",
"if",
"(",
"(",
"prefix",
"==",
"null",
"||",
"prefix",
".",
"isEmpty",
"(",
")",
")",
"&&",
"(",
"configuration",
"!=",
"null",
")",
")",
"{",
"prefix",
"=",
"configuration",
".",
"getPrefix",
... | Returns Simon prefix for constructing names of Simons.
@return Simon prefix | [
"Returns",
"Simon",
"prefix",
"for",
"constructing",
"names",
"of",
"Simons",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbcx4/AbstractSimonDataSource.java#L232-L237 | train |
virgo47/javasimon | jdbc41/src/main/java/org/javasimon/jdbc4/SimonResultSet.java | SimonResultSet.next | @Override
public boolean next() throws SQLException {
try (Split ignored = SimonManager.getStopwatch(stmtPrefix + ".next").start()) {
return rset.next();
}
} | java | @Override
public boolean next() throws SQLException {
try (Split ignored = SimonManager.getStopwatch(stmtPrefix + ".next").start()) {
return rset.next();
}
} | [
"@",
"Override",
"public",
"boolean",
"next",
"(",
")",
"throws",
"SQLException",
"{",
"try",
"(",
"Split",
"ignored",
"=",
"SimonManager",
".",
"getStopwatch",
"(",
"stmtPrefix",
"+",
"\".next\"",
")",
".",
"start",
"(",
")",
")",
"{",
"return",
"rset",
... | Measure next operation.
@return {@code true} if the new current row is valid; {@code false} if there are no more rows
@throws java.sql.SQLException if real next operation fails | [
"Measure",
"next",
"operation",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbc4/SimonResultSet.java#L70-L75 | train |
virgo47/javasimon | spring/src/main/java/org/javasimon/spring/BasicMonitoringInterceptor.java | BasicMonitoringInterceptor.invoke | public final Object invoke(MethodInvocation invocation) throws Throwable {
final Split split = stopwatchSource.start(invocation);
try {
return processInvoke(invocation, split);
} finally {
split.stop();
}
} | java | public final Object invoke(MethodInvocation invocation) throws Throwable {
final Split split = stopwatchSource.start(invocation);
try {
return processInvoke(invocation, split);
} finally {
split.stop();
}
} | [
"public",
"final",
"Object",
"invoke",
"(",
"MethodInvocation",
"invocation",
")",
"throws",
"Throwable",
"{",
"final",
"Split",
"split",
"=",
"stopwatchSource",
".",
"start",
"(",
"invocation",
")",
";",
"try",
"{",
"return",
"processInvoke",
"(",
"invocation",... | Performs method invocation and wraps it with Stopwatch.
@param invocation method invocation
@return return object from the method
@throws Throwable anything thrown by the method | [
"Performs",
"method",
"invocation",
"and",
"wraps",
"it",
"with",
"Stopwatch",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/spring/src/main/java/org/javasimon/spring/BasicMonitoringInterceptor.java#L48-L55 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/PropertiesQuantilesCallback.java | PropertiesQuantilesCallback.createBuckets | @Override
protected Buckets createBuckets(Stopwatch stopwatch) {
// Get configuration
BucketsType type = bucketsTypeEnumPropertyType.get(stopwatch, "type");
Long min = longPropertyType.get(stopwatch, "min");
Long max = longPropertyType.get(stopwatch, "max");
Integer nb = integerPropertyType.get(stopwatch, "nb");
// Build buckets
Buckets buckets = type.createBuckets(stopwatch, min, max, nb);
buckets.setLogTemplate(createLogTemplate(stopwatch));
return buckets;
} | java | @Override
protected Buckets createBuckets(Stopwatch stopwatch) {
// Get configuration
BucketsType type = bucketsTypeEnumPropertyType.get(stopwatch, "type");
Long min = longPropertyType.get(stopwatch, "min");
Long max = longPropertyType.get(stopwatch, "max");
Integer nb = integerPropertyType.get(stopwatch, "nb");
// Build buckets
Buckets buckets = type.createBuckets(stopwatch, min, max, nb);
buckets.setLogTemplate(createLogTemplate(stopwatch));
return buckets;
} | [
"@",
"Override",
"protected",
"Buckets",
"createBuckets",
"(",
"Stopwatch",
"stopwatch",
")",
"{",
"// Get configuration",
"BucketsType",
"type",
"=",
"bucketsTypeEnumPropertyType",
".",
"get",
"(",
"stopwatch",
",",
"\"type\"",
")",
";",
"Long",
"min",
"=",
"long... | Create buckets using callback attributes.
@param stopwatch Target stopwatch
@return Created buckets for given stopwatch | [
"Create",
"buckets",
"using",
"callback",
"attributes",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/PropertiesQuantilesCallback.java#L51-L62 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/PropertiesQuantilesCallback.java | PropertiesQuantilesCallback.getProperty | private String getProperty(Simon simon, String name) {
return properties.getProperty(simon.getName() + "." + name);
} | java | private String getProperty(Simon simon, String name) {
return properties.getProperty(simon.getName() + "." + name);
} | [
"private",
"String",
"getProperty",
"(",
"Simon",
"simon",
",",
"String",
"name",
")",
"{",
"return",
"properties",
".",
"getProperty",
"(",
"simon",
".",
"getName",
"(",
")",
"+",
"\".\"",
"+",
"name",
")",
";",
"}"
] | Returns value of Simon property.
@param simon Simon
@param name Property name
@return Raw property value | [
"Returns",
"value",
"of",
"Simon",
"property",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/PropertiesQuantilesCallback.java#L71-L73 | train |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/quantiles/PropertiesQuantilesCallback.java | PropertiesQuantilesCallback.cleanString | private static String cleanString(String s) {
if (s != null) {
s = s.trim();
if (s.equals("")) {
s = null;
}
}
return s;
} | java | private static String cleanString(String s) {
if (s != null) {
s = s.trim();
if (s.equals("")) {
s = null;
}
}
return s;
} | [
"private",
"static",
"String",
"cleanString",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"s",
"=",
"s",
".",
"trim",
"(",
")",
";",
"if",
"(",
"s",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"s",
"=",
"null",
";",
... | Remove space at both ends and convert empty strings to null. | [
"Remove",
"space",
"at",
"both",
"ends",
"and",
"convert",
"empty",
"strings",
"to",
"null",
"."
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/quantiles/PropertiesQuantilesCallback.java#L76-L84 | train |
virgo47/javasimon | console-embed/src/main/java/org/javasimon/console/SimonCallbacks.java | SimonCallbacks.getCallbackByType | public static <T extends Callback> T getCallbackByType(Manager manager, Class<T> callbackType) {
return getCallbackByType(manager.callback().callbacks(), callbackType);
} | java | public static <T extends Callback> T getCallbackByType(Manager manager, Class<T> callbackType) {
return getCallbackByType(manager.callback().callbacks(), callbackType);
} | [
"public",
"static",
"<",
"T",
"extends",
"Callback",
">",
"T",
"getCallbackByType",
"(",
"Manager",
"manager",
",",
"Class",
"<",
"T",
">",
"callbackType",
")",
"{",
"return",
"getCallbackByType",
"(",
"manager",
".",
"callback",
"(",
")",
".",
"callbacks",
... | Get the first callback of given type in manager
@param manager Simon manager containing callbacks
@param callbackType Expected callback type
@return Callback or null if not any | [
"Get",
"the",
"first",
"callback",
"of",
"given",
"type",
"in",
"manager"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/console-embed/src/main/java/org/javasimon/console/SimonCallbacks.java#L24-L26 | train |
virgo47/javasimon | console-embed/src/main/java/org/javasimon/console/SimonCallbacks.java | SimonCallbacks.getCallbackByType | private static <T extends Callback> T getCallbackByType(Iterable<Callback> callbacks, Class<T> callbackType) {
T foundCallback = null;
Iterator<Callback> callbackIterator = callbacks.iterator();
while (foundCallback == null && callbackIterator.hasNext()) {
Callback callback = callbackIterator.next();
// Remove callback wrappers
while ((callback instanceof Delegating) && (!callbackType.isInstance(callback))) {
callback = ((Delegating<Callback>) callback).getDelegate();
}
if (callbackType.isInstance(callback)) {
// Callback found
foundCallback = callbackType.cast(callback);
} else if (callback instanceof CompositeCallback) {
// Visit the composite callback
foundCallback = getCallbackByType(((CompositeCallback) callback).callbacks(), callbackType);
}
}
return foundCallback;
} | java | private static <T extends Callback> T getCallbackByType(Iterable<Callback> callbacks, Class<T> callbackType) {
T foundCallback = null;
Iterator<Callback> callbackIterator = callbacks.iterator();
while (foundCallback == null && callbackIterator.hasNext()) {
Callback callback = callbackIterator.next();
// Remove callback wrappers
while ((callback instanceof Delegating) && (!callbackType.isInstance(callback))) {
callback = ((Delegating<Callback>) callback).getDelegate();
}
if (callbackType.isInstance(callback)) {
// Callback found
foundCallback = callbackType.cast(callback);
} else if (callback instanceof CompositeCallback) {
// Visit the composite callback
foundCallback = getCallbackByType(((CompositeCallback) callback).callbacks(), callbackType);
}
}
return foundCallback;
} | [
"private",
"static",
"<",
"T",
"extends",
"Callback",
">",
"T",
"getCallbackByType",
"(",
"Iterable",
"<",
"Callback",
">",
"callbacks",
",",
"Class",
"<",
"T",
">",
"callbackType",
")",
"{",
"T",
"foundCallback",
"=",
"null",
";",
"Iterator",
"<",
"Callba... | Search callback by type in list of callbacks
@param callbacks List of callback
@param callbackType Callback type
@return Callback matching type | [
"Search",
"callback",
"by",
"type",
"in",
"list",
"of",
"callbacks"
] | 17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/console-embed/src/main/java/org/javasimon/console/SimonCallbacks.java#L35-L53 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/io/FileBlockStore.java | FileBlockStore.set | public WriteBuffer set(final int index) {
if (useMmap) {
final ByteBuffer buf = getMmapForIndex(index);
if (buf != null) {
return new WriteBuffer(this, index, useMmap, buf);
}
}
return new WriteBuffer(this, index, false, bufstack.pop());
} | java | public WriteBuffer set(final int index) {
if (useMmap) {
final ByteBuffer buf = getMmapForIndex(index);
if (buf != null) {
return new WriteBuffer(this, index, useMmap, buf);
}
}
return new WriteBuffer(this, index, false, bufstack.pop());
} | [
"public",
"WriteBuffer",
"set",
"(",
"final",
"int",
"index",
")",
"{",
"if",
"(",
"useMmap",
")",
"{",
"final",
"ByteBuffer",
"buf",
"=",
"getMmapForIndex",
"(",
"index",
")",
";",
"if",
"(",
"buf",
"!=",
"null",
")",
"{",
"return",
"new",
"WriteBuffe... | Alloc a WriteBuffer
@param index of block
@return WriteBuffer | [
"Alloc",
"a",
"WriteBuffer"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileBlockStore.java#L359-L367 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/hash/IntHashMap.java | IntHashMap.clear | @SuppressWarnings("unchecked")
public void clear(final boolean shrink) {
clearCache();
if (elementCount > 0) {
elementCount = 0;
}
if (shrink && (elementData.length > 1024) && (elementData.length > defaultSize)) {
elementData = new IntEntry[defaultSize];
} else {
Arrays.fill(elementData, null);
}
computeMaxSize();
} | java | @SuppressWarnings("unchecked")
public void clear(final boolean shrink) {
clearCache();
if (elementCount > 0) {
elementCount = 0;
}
if (shrink && (elementData.length > 1024) && (elementData.length > defaultSize)) {
elementData = new IntEntry[defaultSize];
} else {
Arrays.fill(elementData, null);
}
computeMaxSize();
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"clear",
"(",
"final",
"boolean",
"shrink",
")",
"{",
"clearCache",
"(",
")",
";",
"if",
"(",
"elementCount",
">",
"0",
")",
"{",
"elementCount",
"=",
"0",
";",
"}",
"if",
"(",
"shri... | Clear the map
@param shrink if true shrink the map to initial size | [
"Clear",
"the",
"map"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/IntHashMap.java#L96-L108 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/hash/IntHashMap.java | IntHashMap.get | public V get(final int key) {
final int index = (key & 0x7FFFFFFF) % elementData.length;
IntEntry<V> m = elementData[index];
while (m != null) {
if (key == m.key) {
return m.value;
}
m = m.nextInSlot;
}
return null;
} | java | public V get(final int key) {
final int index = (key & 0x7FFFFFFF) % elementData.length;
IntEntry<V> m = elementData[index];
while (m != null) {
if (key == m.key) {
return m.value;
}
m = m.nextInSlot;
}
return null;
} | [
"public",
"V",
"get",
"(",
"final",
"int",
"key",
")",
"{",
"final",
"int",
"index",
"=",
"(",
"key",
"&",
"0x7FFFFFFF",
")",
"%",
"elementData",
".",
"length",
";",
"IntEntry",
"<",
"V",
">",
"m",
"=",
"elementData",
"[",
"index",
"]",
";",
"while... | Returns the value of specified key.
@param key the key.
@return the value of the mapping with the specified key, or {@code null} if no mapping for the
specified key is found. | [
"Returns",
"the",
"value",
"of",
"specified",
"key",
"."
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/IntHashMap.java#L121-L132 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/hash/IntHashMap.java | IntHashMap.getValues | public V[] getValues() {
final V[] array = factory.newArray(elementCount);
int i = 0;
for (final V v : this) {
array[i++] = v;
}
return array;
} | java | public V[] getValues() {
final V[] array = factory.newArray(elementCount);
int i = 0;
for (final V v : this) {
array[i++] = v;
}
return array;
} | [
"public",
"V",
"[",
"]",
"getValues",
"(",
")",
"{",
"final",
"V",
"[",
"]",
"array",
"=",
"factory",
".",
"newArray",
"(",
"elementCount",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"V",
"v",
":",
"this",
")",
"{",
"array",
"[",... | Return an array with values in this map
@return array with values | [
"Return",
"an",
"array",
"with",
"values",
"in",
"this",
"map"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/IntHashMap.java#L410-L417 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.registerDefaults | protected void registerDefaults() {
register(Long.class, new LongConverter());
register(Integer.class, new IntegerConverter());
register(Short.class, new ShortConverter());
register(Byte.class, new ByteConverter());
register(Double.class, new DoubleConverter());
register(Float.class, new FloatConverter());
register(Character.class, new CharacterConverter());
register(Boolean.class, new BooleanConverter());
register(String.class, new StringConverter());
register(URL.class, new UrlConverter());
register(URI.class, new UriConverter());
register(Charset.class, new CharsetConverter());
register(File.class, new FileConverter());
register(Path.class, new PathConverter());
register(Locale.class, new LocaleConverter());
register(Pattern.class, new PatternConverter());
register(Long.TYPE, new LongConverter());
register(Integer.TYPE, new IntegerConverter());
register(Short.TYPE, new ShortConverter());
register(Byte.TYPE, new ByteConverter());
register(Character.TYPE, new CharacterConverter());
register(Double.TYPE, new DoubleConverter());
register(Float.TYPE, new FloatConverter());
register(Boolean.TYPE, new BooleanConverter());
} | java | protected void registerDefaults() {
register(Long.class, new LongConverter());
register(Integer.class, new IntegerConverter());
register(Short.class, new ShortConverter());
register(Byte.class, new ByteConverter());
register(Double.class, new DoubleConverter());
register(Float.class, new FloatConverter());
register(Character.class, new CharacterConverter());
register(Boolean.class, new BooleanConverter());
register(String.class, new StringConverter());
register(URL.class, new UrlConverter());
register(URI.class, new UriConverter());
register(Charset.class, new CharsetConverter());
register(File.class, new FileConverter());
register(Path.class, new PathConverter());
register(Locale.class, new LocaleConverter());
register(Pattern.class, new PatternConverter());
register(Long.TYPE, new LongConverter());
register(Integer.TYPE, new IntegerConverter());
register(Short.TYPE, new ShortConverter());
register(Byte.TYPE, new ByteConverter());
register(Character.TYPE, new CharacterConverter());
register(Double.TYPE, new DoubleConverter());
register(Float.TYPE, new FloatConverter());
register(Boolean.TYPE, new BooleanConverter());
} | [
"protected",
"void",
"registerDefaults",
"(",
")",
"{",
"register",
"(",
"Long",
".",
"class",
",",
"new",
"LongConverter",
"(",
")",
")",
";",
"register",
"(",
"Integer",
".",
"class",
",",
"new",
"IntegerConverter",
"(",
")",
")",
";",
"register",
"(",... | Register converters supported by default. | [
"Register",
"converters",
"supported",
"by",
"default",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L50-L77 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.register | public <T> void register(Class<T> type, Converter<T> converter) {
addConverter(type, converter);
} | java | public <T> void register(Class<T> type, Converter<T> converter) {
addConverter(type, converter);
} | [
"public",
"<",
"T",
">",
"void",
"register",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"Converter",
"<",
"T",
">",
"converter",
")",
"{",
"addConverter",
"(",
"type",
",",
"converter",
")",
";",
"}"
] | Register converter. | [
"Register",
"converter",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L82-L84 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.addConverter | protected <T> void addConverter(Class<T> type, Converter<T> converter) {
storage.put(type, converter);
} | java | protected <T> void addConverter(Class<T> type, Converter<T> converter) {
storage.put(type, converter);
} | [
"protected",
"<",
"T",
">",
"void",
"addConverter",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"Converter",
"<",
"T",
">",
"converter",
")",
"{",
"storage",
".",
"put",
"(",
"type",
",",
"converter",
")",
";",
"}"
] | Add converter to the storage. | [
"Add",
"converter",
"to",
"the",
"storage",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L89-L91 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.find | protected <T> Converter<T> find(Class<T> type) throws ConversionException {
//noinspection unchecked
Converter<T> converter = (Converter<T>) storage.get(type);
if (converter == null) {
if (type.isEnum()) {
//noinspection unchecked
return new EnumConverter((Class<? extends Enum>) type);
}
if (type.isArray()) {
Class<?> componentType = type.getComponentType();
Converter childConverter = find(componentType);
//noinspection unchecked
return new ArrayConverter(childConverter, componentType, stringSplitter);
}
throw new ConversionException(String.format("Could not find converter for type <%s>", type));
}
return converter;
} | java | protected <T> Converter<T> find(Class<T> type) throws ConversionException {
//noinspection unchecked
Converter<T> converter = (Converter<T>) storage.get(type);
if (converter == null) {
if (type.isEnum()) {
//noinspection unchecked
return new EnumConverter((Class<? extends Enum>) type);
}
if (type.isArray()) {
Class<?> componentType = type.getComponentType();
Converter childConverter = find(componentType);
//noinspection unchecked
return new ArrayConverter(childConverter, componentType, stringSplitter);
}
throw new ConversionException(String.format("Could not find converter for type <%s>", type));
}
return converter;
} | [
"protected",
"<",
"T",
">",
"Converter",
"<",
"T",
">",
"find",
"(",
"Class",
"<",
"T",
">",
"type",
")",
"throws",
"ConversionException",
"{",
"//noinspection unchecked",
"Converter",
"<",
"T",
">",
"converter",
"=",
"(",
"Converter",
"<",
"T",
">",
")"... | Find converter for given type. Returns null if converter doesn't exists. | [
"Find",
"converter",
"for",
"given",
"type",
".",
"Returns",
"null",
"if",
"converter",
"doesn",
"t",
"exists",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L96-L113 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.convert | public Object convert(Class<?> type, String origin) throws ConversionException {
if (origin == null) {
return convertNullValue(type);
}
Converter converter = find(type);
try {
return converter.convert(origin);
} catch (Exception e) {
throw new ConversionException(String.format("Could not convert string <%s> to type <%s>", origin, type), e);
}
} | java | public Object convert(Class<?> type, String origin) throws ConversionException {
if (origin == null) {
return convertNullValue(type);
}
Converter converter = find(type);
try {
return converter.convert(origin);
} catch (Exception e) {
throw new ConversionException(String.format("Could not convert string <%s> to type <%s>", origin, type), e);
}
} | [
"public",
"Object",
"convert",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"origin",
")",
"throws",
"ConversionException",
"{",
"if",
"(",
"origin",
"==",
"null",
")",
"{",
"return",
"convertNullValue",
"(",
"type",
")",
";",
"}",
"Converter",
"c... | Convert given string to type.
@throws ConversionException If can't find converter for given type.
@see #find(Class) | [
"Convert",
"given",
"string",
"to",
"type",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L121-L132 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.convertNullValue | protected Object convertNullValue(Class type) throws ConversionException {
try {
return type.isPrimitive() ? Array.get(Array.newInstance(type, 1), 0) : null;
} catch (Exception e) {
throw new ConversionException(String.format("Could not convert null to primitive type <%s>", type), e);
}
} | java | protected Object convertNullValue(Class type) throws ConversionException {
try {
return type.isPrimitive() ? Array.get(Array.newInstance(type, 1), 0) : null;
} catch (Exception e) {
throw new ConversionException(String.format("Could not convert null to primitive type <%s>", type), e);
}
} | [
"protected",
"Object",
"convertNullValue",
"(",
"Class",
"type",
")",
"throws",
"ConversionException",
"{",
"try",
"{",
"return",
"type",
".",
"isPrimitive",
"(",
")",
"?",
"Array",
".",
"get",
"(",
"Array",
".",
"newInstance",
"(",
"type",
",",
"1",
")",
... | Convert null to given type.
@throws ConversionException if any occurs. | [
"Convert",
"null",
"to",
"given",
"type",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L139-L145 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.convert | public <T> Object convert(Class collectionType, Class<T> elementType, String origin) throws ConversionException {
Converter<T> elementConverter = find(elementType);
CollectionConverter<T> converter = new CollectionConverter<>(elementConverter, stringSplitter);
try {
Collection<T> converted = converter.convert(origin);
return castCollectionToType(collectionType, converted);
} catch (Exception e) {
throw new ConversionException(String.format("Could not convert string <%s> to collection <%s> " +
"with element type <%s>", origin, collectionType, elementType), e);
}
} | java | public <T> Object convert(Class collectionType, Class<T> elementType, String origin) throws ConversionException {
Converter<T> elementConverter = find(elementType);
CollectionConverter<T> converter = new CollectionConverter<>(elementConverter, stringSplitter);
try {
Collection<T> converted = converter.convert(origin);
return castCollectionToType(collectionType, converted);
} catch (Exception e) {
throw new ConversionException(String.format("Could not convert string <%s> to collection <%s> " +
"with element type <%s>", origin, collectionType, elementType), e);
}
} | [
"public",
"<",
"T",
">",
"Object",
"convert",
"(",
"Class",
"collectionType",
",",
"Class",
"<",
"T",
">",
"elementType",
",",
"String",
"origin",
")",
"throws",
"ConversionException",
"{",
"Converter",
"<",
"T",
">",
"elementConverter",
"=",
"find",
"(",
... | Convert given string to specified collection with given element type.
@throws ConversionException If any occurs.
@see #find(Class) | [
"Convert",
"given",
"string",
"to",
"specified",
"collection",
"with",
"given",
"element",
"type",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L154-L165 | train |
qatools/properties | src/main/java/ru/qatools/properties/converters/ConverterManager.java | ConverterManager.castCollectionToType | @SuppressWarnings("unchecked")
protected <T> Collection<T> castCollectionToType(Class collectionType, Collection<T> converted) throws ConversionException {
if (!Collection.class.isAssignableFrom(collectionType)) {
throw new ConversionException("Collection type should extends collection" + collectionType);
}
if (collectionType.isInterface()) {
if (collectionType.isAssignableFrom(Set.class)) {
return Collections.unmodifiableSet(new HashSet<>(converted));
}
if (collectionType.isAssignableFrom(List.class)) {
return Collections.unmodifiableList(new LinkedList<>(converted));
}
if (collectionType.isAssignableFrom(Collection.class)) {
return Collections.unmodifiableCollection(converted);
}
throw new ConversionException("Unsupported collection type " + collectionType);
}
try {
Constructor constructor = collectionType.getConstructor(Collection.class);
return (Collection<T>) constructor.newInstance(converted);
} catch (Exception e) {
throw new ConversionException("Could not create an instance of " + collectionType, e);
}
} | java | @SuppressWarnings("unchecked")
protected <T> Collection<T> castCollectionToType(Class collectionType, Collection<T> converted) throws ConversionException {
if (!Collection.class.isAssignableFrom(collectionType)) {
throw new ConversionException("Collection type should extends collection" + collectionType);
}
if (collectionType.isInterface()) {
if (collectionType.isAssignableFrom(Set.class)) {
return Collections.unmodifiableSet(new HashSet<>(converted));
}
if (collectionType.isAssignableFrom(List.class)) {
return Collections.unmodifiableList(new LinkedList<>(converted));
}
if (collectionType.isAssignableFrom(Collection.class)) {
return Collections.unmodifiableCollection(converted);
}
throw new ConversionException("Unsupported collection type " + collectionType);
}
try {
Constructor constructor = collectionType.getConstructor(Collection.class);
return (Collection<T>) constructor.newInstance(converted);
} catch (Exception e) {
throw new ConversionException("Could not create an instance of " + collectionType, e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"T",
">",
"Collection",
"<",
"T",
">",
"castCollectionToType",
"(",
"Class",
"collectionType",
",",
"Collection",
"<",
"T",
">",
"converted",
")",
"throws",
"ConversionException",
"{",
"if",
... | Create an instance of specified collection with given element type. | [
"Create",
"an",
"instance",
"of",
"specified",
"collection",
"with",
"given",
"element",
"type",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/converters/ConverterManager.java#L170-L194 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/stack/IntStack.java | IntStack.pop | public final int pop() {
if (stackPointer == 0) {
return null_value;
}
final int element = stack[--stackPointer];
stack[stackPointer] = null_value;
return element;
} | java | public final int pop() {
if (stackPointer == 0) {
return null_value;
}
final int element = stack[--stackPointer];
stack[stackPointer] = null_value;
return element;
} | [
"public",
"final",
"int",
"pop",
"(",
")",
"{",
"if",
"(",
"stackPointer",
"==",
"0",
")",
"{",
"return",
"null_value",
";",
"}",
"final",
"int",
"element",
"=",
"stack",
"[",
"--",
"stackPointer",
"]",
";",
"stack",
"[",
"stackPointer",
"]",
"=",
"n... | Pop value from top of stack
@return int of value | [
"Pop",
"value",
"from",
"top",
"of",
"stack"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/stack/IntStack.java#L95-L102 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/io/FileLongStore.java | FileLongStore.read | public synchronized void read() throws IOException {
if (!validState) {
throw new InvalidStateException();
}
final long offset = ((fc.size() & ~7) - 8);
if (offset < 0) {
throw new IOException("Empty file");
}
buf.clear();
int readed = fc.position(offset).read(buf);
if (readed < 8) { // long 8 bytes
throw new IOException("cant read long from file");
}
buf.flip();
value = buf.getLong();
} | java | public synchronized void read() throws IOException {
if (!validState) {
throw new InvalidStateException();
}
final long offset = ((fc.size() & ~7) - 8);
if (offset < 0) {
throw new IOException("Empty file");
}
buf.clear();
int readed = fc.position(offset).read(buf);
if (readed < 8) { // long 8 bytes
throw new IOException("cant read long from file");
}
buf.flip();
value = buf.getLong();
} | [
"public",
"synchronized",
"void",
"read",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"validState",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
")",
";",
"}",
"final",
"long",
"offset",
"=",
"(",
"(",
"fc",
".",
"size",
"(",
")"... | Read value from file
@throws IOException | [
"Read",
"value",
"from",
"file"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileLongStore.java#L225-L240 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/io/FileLongStore.java | FileLongStore.write | public synchronized void write(final boolean forceSync) throws IOException {
if (!validState) {
throw new InvalidStateException();
}
buf.clear();
buf.putLong(value);
buf.flip();
fc.position(fc.size()).write(buf); // go end and write
if (forceSync) {
fc.force(false);
}
} | java | public synchronized void write(final boolean forceSync) throws IOException {
if (!validState) {
throw new InvalidStateException();
}
buf.clear();
buf.putLong(value);
buf.flip();
fc.position(fc.size()).write(buf); // go end and write
if (forceSync) {
fc.force(false);
}
} | [
"public",
"synchronized",
"void",
"write",
"(",
"final",
"boolean",
"forceSync",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"validState",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
")",
";",
"}",
"buf",
".",
"clear",
"(",
")",
";",
"... | Write value to file
@param forceSync if true data must be synced to disk
@throws IOException | [
"Write",
"value",
"to",
"file"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileLongStore.java#L257-L268 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/io/FileLongStore.java | FileLongStore.pack | public synchronized void pack() throws IOException {
if (!validState) {
throw new InvalidStateException();
}
buf.clear();
buf.putLong(value);
buf.flip();
fc.position(0).write(buf); // go begin and write
fc.truncate(8).force(true);
} | java | public synchronized void pack() throws IOException {
if (!validState) {
throw new InvalidStateException();
}
buf.clear();
buf.putLong(value);
buf.flip();
fc.position(0).write(buf); // go begin and write
fc.truncate(8).force(true);
} | [
"public",
"synchronized",
"void",
"pack",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"validState",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
")",
";",
"}",
"buf",
".",
"clear",
"(",
")",
";",
"buf",
".",
"putLong",
"(",
"valu... | Write value to file and reduce size to minimal
@throws IOException | [
"Write",
"value",
"to",
"file",
"and",
"reduce",
"size",
"to",
"minimal"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileLongStore.java#L275-L284 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/bitset/SimpleBitSet.java | SimpleBitSet.ensureCapacity | private void ensureCapacity(int wordsRequired) {
if (words.length < wordsRequired) {
// Allocate larger of doubled size or required size
int request = Math.max(2 * words.length, wordsRequired);
words = Arrays.copyOf(words, request);
sizeIsSticky = false;
}
} | java | private void ensureCapacity(int wordsRequired) {
if (words.length < wordsRequired) {
// Allocate larger of doubled size or required size
int request = Math.max(2 * words.length, wordsRequired);
words = Arrays.copyOf(words, request);
sizeIsSticky = false;
}
} | [
"private",
"void",
"ensureCapacity",
"(",
"int",
"wordsRequired",
")",
"{",
"if",
"(",
"words",
".",
"length",
"<",
"wordsRequired",
")",
"{",
"// Allocate larger of doubled size or required size",
"int",
"request",
"=",
"Math",
".",
"max",
"(",
"2",
"*",
"words... | Ensures that the BitSet can hold enough words.
@param wordsRequired the minimum acceptable number of words. | [
"Ensures",
"that",
"the",
"BitSet",
"can",
"hold",
"enough",
"words",
"."
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/bitset/SimpleBitSet.java#L122-L129 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/bitset/SimpleBitSet.java | SimpleBitSet.checkRange | private static void checkRange(int fromIndex, int toIndex) {
if (fromIndex < 0)
throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);
if (toIndex < 0)
throw new IndexOutOfBoundsException("toIndex < 0: " + toIndex);
if (fromIndex > toIndex)
throw new IndexOutOfBoundsException("fromIndex: " + fromIndex +
" > toIndex: " + toIndex);
} | java | private static void checkRange(int fromIndex, int toIndex) {
if (fromIndex < 0)
throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);
if (toIndex < 0)
throw new IndexOutOfBoundsException("toIndex < 0: " + toIndex);
if (fromIndex > toIndex)
throw new IndexOutOfBoundsException("fromIndex: " + fromIndex +
" > toIndex: " + toIndex);
} | [
"private",
"static",
"void",
"checkRange",
"(",
"int",
"fromIndex",
",",
"int",
"toIndex",
")",
"{",
"if",
"(",
"fromIndex",
"<",
"0",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"fromIndex < 0: \"",
"+",
"fromIndex",
")",
";",
"if",
"(",
"toInd... | Checks that fromIndex ... toIndex is a valid range of bit indices. | [
"Checks",
"that",
"fromIndex",
"...",
"toIndex",
"is",
"a",
"valid",
"range",
"of",
"bit",
"indices",
"."
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/bitset/SimpleBitSet.java#L149-L157 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.getNodeFromStore | private Node<K, V> getNodeFromStore(final int nodeid) {
final int index = nodeid < 0 ? -nodeid : nodeid;
final ByteBuffer buf = storage.get(index);
final Node<K, V> node = Node.deserialize(buf, this);
if (rootIdx == node.id) {
log.warn(this.getClass().getName() + "::getNodeFromStore(" + nodeid + ") WARN LOADED ROOT NODE");
}
storage.release(buf);
if (enableIOStats) {
getIOStat(nodeid).incPhysRead();
}
return node;
} | java | private Node<K, V> getNodeFromStore(final int nodeid) {
final int index = nodeid < 0 ? -nodeid : nodeid;
final ByteBuffer buf = storage.get(index);
final Node<K, V> node = Node.deserialize(buf, this);
if (rootIdx == node.id) {
log.warn(this.getClass().getName() + "::getNodeFromStore(" + nodeid + ") WARN LOADED ROOT NODE");
}
storage.release(buf);
if (enableIOStats) {
getIOStat(nodeid).incPhysRead();
}
return node;
} | [
"private",
"Node",
"<",
"K",
",",
"V",
">",
"getNodeFromStore",
"(",
"final",
"int",
"nodeid",
")",
"{",
"final",
"int",
"index",
"=",
"nodeid",
"<",
"0",
"?",
"-",
"nodeid",
":",
"nodeid",
";",
"final",
"ByteBuffer",
"buf",
"=",
"storage",
".",
"get... | Get node from file
@param nodeid int with nodeid
@return Node<K,V> | [
"Get",
"node",
"from",
"file"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L270-L282 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.putNodeToStore | private void putNodeToStore(final Node<K, V> node) {
final int nodeid = node.id;
final int index = (nodeid < 0 ? -nodeid : nodeid);
final WriteBuffer wbuf = storage.set(index);
final ByteBuffer buf = wbuf.buf();
if (node.isDeleted()) { // This block is for delete
if (cleanBlocksOnFree) {
buf.clear();
int cx = (blockSize >> 3); // division by 8
while (cx-- > 0) {
buf.putLong(0); // Fill with zeroes
}
buf.flip();
} else {
node.clean(buf); // Generate zeroed minimal buffer
}
freeBlocks.set(index); // Mark block as free
} else {
node.serialize(buf);
}
wbuf.save();
if (enableDirtyCheck) {
dirtyCheck.clear(index);
}
if (enableIOStats) {
getIOStat(nodeid).incPhysWrite();
}
} | java | private void putNodeToStore(final Node<K, V> node) {
final int nodeid = node.id;
final int index = (nodeid < 0 ? -nodeid : nodeid);
final WriteBuffer wbuf = storage.set(index);
final ByteBuffer buf = wbuf.buf();
if (node.isDeleted()) { // This block is for delete
if (cleanBlocksOnFree) {
buf.clear();
int cx = (blockSize >> 3); // division by 8
while (cx-- > 0) {
buf.putLong(0); // Fill with zeroes
}
buf.flip();
} else {
node.clean(buf); // Generate zeroed minimal buffer
}
freeBlocks.set(index); // Mark block as free
} else {
node.serialize(buf);
}
wbuf.save();
if (enableDirtyCheck) {
dirtyCheck.clear(index);
}
if (enableIOStats) {
getIOStat(nodeid).incPhysWrite();
}
} | [
"private",
"void",
"putNodeToStore",
"(",
"final",
"Node",
"<",
"K",
",",
"V",
">",
"node",
")",
"{",
"final",
"int",
"nodeid",
"=",
"node",
".",
"id",
";",
"final",
"int",
"index",
"=",
"(",
"nodeid",
"<",
"0",
"?",
"-",
"nodeid",
":",
"nodeid",
... | Put a node in file
@param node | [
"Put",
"a",
"node",
"in",
"file"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L302-L329 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.removeEldestElementsFromCache | @SuppressWarnings("rawtypes")
private final int removeEldestElementsFromCache(final IntLinkedHashMap<Node> hash, final int maxSize) {
final int evict = hash.size() - maxSize;
if (evict <= 0) {
return 0;
}
for (int count = 0; count < evict; count++) {
hash.removeEldest();
}
return evict;
} | java | @SuppressWarnings("rawtypes")
private final int removeEldestElementsFromCache(final IntLinkedHashMap<Node> hash, final int maxSize) {
final int evict = hash.size() - maxSize;
if (evict <= 0) {
return 0;
}
for (int count = 0; count < evict; count++) {
hash.removeEldest();
}
return evict;
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"private",
"final",
"int",
"removeEldestElementsFromCache",
"(",
"final",
"IntLinkedHashMap",
"<",
"Node",
">",
"hash",
",",
"final",
"int",
"maxSize",
")",
"{",
"final",
"int",
"evict",
"=",
"hash",
".",
"siz... | Evict from Read Cache excess nodes
@param hash cache to purge
@param maxSize max elements to hold in cache
@return int number of elements evicted | [
"Evict",
"from",
"Read",
"Cache",
"excess",
"nodes"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L397-L408 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.writeMetaData | private boolean writeMetaData(final boolean isClean) {
if (readOnly) {
return true;
}
final WriteBuffer wbuf = storage.set(0);
final ByteBuffer buf = wbuf.buf();
boolean isOK = false;
// @formatter:off
buf
.putInt(MAGIC_1)
.putInt(blockSize)
.putInt(b_order_leaf)
.putInt(b_order_internal)
.putInt(storageBlock)
.putInt(rootIdx)
.putInt(lowIdx)
.putInt(highIdx)
.putInt(elements)
.putInt(height)
.putInt(maxInternalNodes)
.putInt(maxLeafNodes)
.put((byte) (isClean ? 0xEA : 0x00))
.putInt(MAGIC_2)
.flip();
// @formatter:on
isOK = wbuf.save();
if (isClean) {
storage.sync();
}
try {
if (isClean) {
SimpleBitSet.serializeToFile(fileFreeBlocks, freeBlocks);
} else {
fileFreeBlocks.delete();
}
} catch (IOException e) {
log.error("IOException in writeMetaData(" + isClean + ")", e);
}
if (log.isDebugEnabled()) {
log.debug(this.getClass().getName() + "::writeMetaData() elements=" + elements + " rootIdx="
+ rootIdx + " lastNodeId=" + storageBlock + " freeBlocks=" + freeBlocks.cardinality());
}
return isOK;
} | java | private boolean writeMetaData(final boolean isClean) {
if (readOnly) {
return true;
}
final WriteBuffer wbuf = storage.set(0);
final ByteBuffer buf = wbuf.buf();
boolean isOK = false;
// @formatter:off
buf
.putInt(MAGIC_1)
.putInt(blockSize)
.putInt(b_order_leaf)
.putInt(b_order_internal)
.putInt(storageBlock)
.putInt(rootIdx)
.putInt(lowIdx)
.putInt(highIdx)
.putInt(elements)
.putInt(height)
.putInt(maxInternalNodes)
.putInt(maxLeafNodes)
.put((byte) (isClean ? 0xEA : 0x00))
.putInt(MAGIC_2)
.flip();
// @formatter:on
isOK = wbuf.save();
if (isClean) {
storage.sync();
}
try {
if (isClean) {
SimpleBitSet.serializeToFile(fileFreeBlocks, freeBlocks);
} else {
fileFreeBlocks.delete();
}
} catch (IOException e) {
log.error("IOException in writeMetaData(" + isClean + ")", e);
}
if (log.isDebugEnabled()) {
log.debug(this.getClass().getName() + "::writeMetaData() elements=" + elements + " rootIdx="
+ rootIdx + " lastNodeId=" + storageBlock + " freeBlocks=" + freeBlocks.cardinality());
}
return isOK;
} | [
"private",
"boolean",
"writeMetaData",
"(",
"final",
"boolean",
"isClean",
")",
"{",
"if",
"(",
"readOnly",
")",
"{",
"return",
"true",
";",
"}",
"final",
"WriteBuffer",
"wbuf",
"=",
"storage",
".",
"set",
"(",
"0",
")",
";",
"final",
"ByteBuffer",
"buf"... | Write metadata to file
@param isClean mark file with clean/true or unclean/false
@return boolean if operation is ok | [
"Write",
"metadata",
"to",
"file"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L418-L461 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.readMetaData | private boolean readMetaData() throws InvalidDataException {
final ByteBuffer buf = storage.get(0);
int magic1, magic2, t_b_order_leaf, t_b_order_internal, t_blockSize; // sanity
boolean isClean = false;
magic1 = buf.getInt();
if (magic1 != MAGIC_1) {
throw new InvalidDataException("Invalid metadata (MAGIC1)");
}
t_blockSize = buf.getInt();
if (t_blockSize != blockSize) {
throw new InvalidDataException("Invalid metadata (blockSize) " + t_blockSize + " != " + blockSize);
}
t_b_order_leaf = buf.getInt();
t_b_order_internal = buf.getInt();
if (t_b_order_leaf != b_order_leaf) {
throw new InvalidDataException("Invalid metadata (b-order leaf) " + t_b_order_leaf + " != "
+ b_order_leaf);
}
if (t_b_order_internal != b_order_internal) {
throw new InvalidDataException("Invalid metadata (b-order internal) " + t_b_order_internal
+ " != " + b_order_internal);
}
storageBlock = buf.getInt();
rootIdx = buf.getInt();
lowIdx = buf.getInt();
highIdx = buf.getInt();
elements = buf.getInt();
height = buf.getInt();
maxInternalNodes = buf.getInt();
maxLeafNodes = buf.getInt();
isClean = ((buf.get() == ((byte) 0xEA)) ? true : false);
magic2 = buf.getInt();
if (magic2 != MAGIC_2) {
throw new InvalidDataException("Invalid metadata (MAGIC2)");
}
if (log.isDebugEnabled()) {
log.debug(this.getClass().getName() + "::readMetaData() elements=" + elements + " rootIdx="
+ rootIdx);
}
storage.release(buf);
// Clear Caches
clearReadCaches();
clearWriteCaches();
if (isClean && fileFreeBlocks.exists()) {
try {
final SimpleBitSet newFreeBlocks = SimpleBitSet.deserializeFromFile(fileFreeBlocks);
freeBlocks = newFreeBlocks;
} catch (IOException e) {
log.error("IOException in readMetaData()", e);
}
}
return isClean;
} | java | private boolean readMetaData() throws InvalidDataException {
final ByteBuffer buf = storage.get(0);
int magic1, magic2, t_b_order_leaf, t_b_order_internal, t_blockSize; // sanity
boolean isClean = false;
magic1 = buf.getInt();
if (magic1 != MAGIC_1) {
throw new InvalidDataException("Invalid metadata (MAGIC1)");
}
t_blockSize = buf.getInt();
if (t_blockSize != blockSize) {
throw new InvalidDataException("Invalid metadata (blockSize) " + t_blockSize + " != " + blockSize);
}
t_b_order_leaf = buf.getInt();
t_b_order_internal = buf.getInt();
if (t_b_order_leaf != b_order_leaf) {
throw new InvalidDataException("Invalid metadata (b-order leaf) " + t_b_order_leaf + " != "
+ b_order_leaf);
}
if (t_b_order_internal != b_order_internal) {
throw new InvalidDataException("Invalid metadata (b-order internal) " + t_b_order_internal
+ " != " + b_order_internal);
}
storageBlock = buf.getInt();
rootIdx = buf.getInt();
lowIdx = buf.getInt();
highIdx = buf.getInt();
elements = buf.getInt();
height = buf.getInt();
maxInternalNodes = buf.getInt();
maxLeafNodes = buf.getInt();
isClean = ((buf.get() == ((byte) 0xEA)) ? true : false);
magic2 = buf.getInt();
if (magic2 != MAGIC_2) {
throw new InvalidDataException("Invalid metadata (MAGIC2)");
}
if (log.isDebugEnabled()) {
log.debug(this.getClass().getName() + "::readMetaData() elements=" + elements + " rootIdx="
+ rootIdx);
}
storage.release(buf);
// Clear Caches
clearReadCaches();
clearWriteCaches();
if (isClean && fileFreeBlocks.exists()) {
try {
final SimpleBitSet newFreeBlocks = SimpleBitSet.deserializeFromFile(fileFreeBlocks);
freeBlocks = newFreeBlocks;
} catch (IOException e) {
log.error("IOException in readMetaData()", e);
}
}
return isClean;
} | [
"private",
"boolean",
"readMetaData",
"(",
")",
"throws",
"InvalidDataException",
"{",
"final",
"ByteBuffer",
"buf",
"=",
"storage",
".",
"get",
"(",
"0",
")",
";",
"int",
"magic1",
",",
"magic2",
",",
"t_b_order_leaf",
",",
"t_b_order_internal",
",",
"t_block... | Read metadata from file
@return true if file is clean or not
@throws InvalidDataException if metadata is invalid | [
"Read",
"metadata",
"from",
"file"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L469-L521 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.delete | public synchronized void delete() {
try {
clear();
} catch (Exception ign) {
}
try {
close();
} catch (Exception ign) {
}
try {
fileRedo.delete();
} catch (Exception ign) {
}
try {
fileStorage.delete();
} catch (Exception ign) {
}
try {
fileFreeBlocks.delete();
} catch (Exception ign) {
}
} | java | public synchronized void delete() {
try {
clear();
} catch (Exception ign) {
}
try {
close();
} catch (Exception ign) {
}
try {
fileRedo.delete();
} catch (Exception ign) {
}
try {
fileStorage.delete();
} catch (Exception ign) {
}
try {
fileFreeBlocks.delete();
} catch (Exception ign) {
}
} | [
"public",
"synchronized",
"void",
"delete",
"(",
")",
"{",
"try",
"{",
"clear",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ign",
")",
"{",
"}",
"try",
"{",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ign",
")",
"{",
"}",
"try",
... | Clear tree and Delete associated files | [
"Clear",
"tree",
"and",
"Delete",
"associated",
"files"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L757-L778 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.setUseRedo | public synchronized void setUseRedo(final boolean useRedo) {
if (validState && this.useRedo && !useRedo) { // Remove Redo
redoQueue.clear();
redoStore.clear();
}
this.useRedo = useRedo;
} | java | public synchronized void setUseRedo(final boolean useRedo) {
if (validState && this.useRedo && !useRedo) { // Remove Redo
redoQueue.clear();
redoStore.clear();
}
this.useRedo = useRedo;
} | [
"public",
"synchronized",
"void",
"setUseRedo",
"(",
"final",
"boolean",
"useRedo",
")",
"{",
"if",
"(",
"validState",
"&&",
"this",
".",
"useRedo",
"&&",
"!",
"useRedo",
")",
"{",
"// Remove Redo",
"redoQueue",
".",
"clear",
"(",
")",
";",
"redoStore",
".... | Use Redo system?
@param useRedo (default true) | [
"Use",
"Redo",
"system?"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L785-L791 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.setUseRedoThread | public synchronized void setUseRedoThread(final boolean useRedoThread) {
if (this.useRedoThread && !useRedoThread) { // Stop Redo Thread
if (redoThread != null) {
stopRedoThread(redoThread);
}
}
this.useRedoThread = useRedoThread;
} | java | public synchronized void setUseRedoThread(final boolean useRedoThread) {
if (this.useRedoThread && !useRedoThread) { // Stop Redo Thread
if (redoThread != null) {
stopRedoThread(redoThread);
}
}
this.useRedoThread = useRedoThread;
} | [
"public",
"synchronized",
"void",
"setUseRedoThread",
"(",
"final",
"boolean",
"useRedoThread",
")",
"{",
"if",
"(",
"this",
".",
"useRedoThread",
"&&",
"!",
"useRedoThread",
")",
"{",
"// Stop Redo Thread",
"if",
"(",
"redoThread",
"!=",
"null",
")",
"{",
"st... | Use Dedicated Thread for Redo?
@param useRedoThread (default false) | [
"Use",
"Dedicated",
"Thread",
"for",
"Redo?"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L798-L805 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.submitRedoPut | @Override
protected void submitRedoPut(final K key, final V value) {
if (!useRedo) {
return;
}
createRedoThread();
final ByteBuffer buf = bufstack.pop();
buf.put((byte) 0x0A); // PUT HEADER
key.serialize(buf);
value.serialize(buf);
buf.put((byte) 0x0A); // PUT FOOTER
buf.flip();
if (useRedoThread) {
try {
redoQueue.put(buf);
} catch (InterruptedException e) {
log.error("InterruptedException in submitRedoPut(key, value)", e);
}
} else {
redoStore.write(buf);
bufstack.push(buf);
}
} | java | @Override
protected void submitRedoPut(final K key, final V value) {
if (!useRedo) {
return;
}
createRedoThread();
final ByteBuffer buf = bufstack.pop();
buf.put((byte) 0x0A); // PUT HEADER
key.serialize(buf);
value.serialize(buf);
buf.put((byte) 0x0A); // PUT FOOTER
buf.flip();
if (useRedoThread) {
try {
redoQueue.put(buf);
} catch (InterruptedException e) {
log.error("InterruptedException in submitRedoPut(key, value)", e);
}
} else {
redoStore.write(buf);
bufstack.push(buf);
}
} | [
"@",
"Override",
"protected",
"void",
"submitRedoPut",
"(",
"final",
"K",
"key",
",",
"final",
"V",
"value",
")",
"{",
"if",
"(",
"!",
"useRedo",
")",
"{",
"return",
";",
"}",
"createRedoThread",
"(",
")",
";",
"final",
"ByteBuffer",
"buf",
"=",
"bufst... | submit put to redo
@param key
@param value | [
"submit",
"put",
"to",
"redo"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L920-L942 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.submitRedoMeta | @Override
protected void submitRedoMeta(final int futureUse) {
if (!useRedo) {
return;
}
createRedoThread();
final ByteBuffer buf = bufstack.pop();
buf.putInt(0x0C0C0C0C); // META HEADER/FOOTER
buf.flip();
if (useRedoThread) {
try {
redoQueue.put(buf);
} catch (InterruptedException e) {
log.error("InterruptedException in submitRedoMeta(" + futureUse + ")", e);
}
} else {
redoStore.write(buf);
bufstack.push(buf);
}
} | java | @Override
protected void submitRedoMeta(final int futureUse) {
if (!useRedo) {
return;
}
createRedoThread();
final ByteBuffer buf = bufstack.pop();
buf.putInt(0x0C0C0C0C); // META HEADER/FOOTER
buf.flip();
if (useRedoThread) {
try {
redoQueue.put(buf);
} catch (InterruptedException e) {
log.error("InterruptedException in submitRedoMeta(" + futureUse + ")", e);
}
} else {
redoStore.write(buf);
bufstack.push(buf);
}
} | [
"@",
"Override",
"protected",
"void",
"submitRedoMeta",
"(",
"final",
"int",
"futureUse",
")",
"{",
"if",
"(",
"!",
"useRedo",
")",
"{",
"return",
";",
"}",
"createRedoThread",
"(",
")",
";",
"final",
"ByteBuffer",
"buf",
"=",
"bufstack",
".",
"pop",
"("... | submit metadata to redo
@param futureUse ignored (byte in the range of 0-0x7F) | [
"submit",
"metadata",
"to",
"redo"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L977-L996 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.setMaxCacheSizeInBytes | public synchronized void setMaxCacheSizeInBytes(final int newsize) {
if (validState) {
log.info(this.getClass().getName() + "::setMaxCacheSizeInBytes newsize=" + newsize
+ " flushing write-cache");
privateSync(true, false);
clearReadCaches();
}
if (newsize >= 1024) { // 1KB minimal
maxCacheSizeInBytes = newsize;
createReadCaches();
}
} | java | public synchronized void setMaxCacheSizeInBytes(final int newsize) {
if (validState) {
log.info(this.getClass().getName() + "::setMaxCacheSizeInBytes newsize=" + newsize
+ " flushing write-cache");
privateSync(true, false);
clearReadCaches();
}
if (newsize >= 1024) { // 1KB minimal
maxCacheSizeInBytes = newsize;
createReadCaches();
}
} | [
"public",
"synchronized",
"void",
"setMaxCacheSizeInBytes",
"(",
"final",
"int",
"newsize",
")",
"{",
"if",
"(",
"validState",
")",
"{",
"log",
".",
"info",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"::setMaxCacheSizeInBytes ne... | Clear caches and Set new value of maximal bytes used for nodes in cache.
<p>
<ul>
<li>Calculo aproximado del numero de elementos que se pueden mantener en memoria: <br/>
elementos=nodos*(b-leaf-order*2/3)
<li>Calculo aproximado del numero de nodos necesarios para mantener en memoria N elementos: <br/>
nodos=elementos/(b-leaf-order*2/3)
<li>El cache necesario para almacenar N nodos: <br/>
cache-size=nodos*blocksize
</ul>
<p>
Ejemplos, para almacenar 5millones de registros (bloque de 1k):
<ul>
<li>LongHolder (8 bytes) b-leaf-order=63 <br/>
5000000/(63*2/3) = 119047nodos * 1024bytes = 121.904.128 bytes
<li>IntHolder (4 bytes) b-leaf-order=127 <br/>
5000000/(127*2/3) = 59055nodos * 1024bytes = 60.472.320 bytes
</ul>
@param newsize size of cache in bytes (0 only clear caches) | [
"Clear",
"caches",
"and",
"Set",
"new",
"value",
"of",
"maximal",
"bytes",
"used",
"for",
"nodes",
"in",
"cache",
"."
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1095-L1106 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.recalculateSizeReadCaches | private void recalculateSizeReadCaches() {
final int maxCacheNodes = (maxCacheSizeInBytes / blockSize);
readCacheInternal = Math.max((int) (maxCacheNodes * .05f), 37);
readCacheLeaf = Math.max((int) (maxCacheNodes * .95f), 37);
} | java | private void recalculateSizeReadCaches() {
final int maxCacheNodes = (maxCacheSizeInBytes / blockSize);
readCacheInternal = Math.max((int) (maxCacheNodes * .05f), 37);
readCacheLeaf = Math.max((int) (maxCacheNodes * .95f), 37);
} | [
"private",
"void",
"recalculateSizeReadCaches",
"(",
")",
"{",
"final",
"int",
"maxCacheNodes",
"=",
"(",
"maxCacheSizeInBytes",
"/",
"blockSize",
")",
";",
"readCacheInternal",
"=",
"Math",
".",
"max",
"(",
"(",
"int",
")",
"(",
"maxCacheNodes",
"*",
".05f",
... | Recalculate size of read caches | [
"Recalculate",
"size",
"of",
"read",
"caches"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1118-L1122 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.createReadCaches | private void createReadCaches() {
recalculateSizeReadCaches();
if (log.isDebugEnabled()) {
log.debug(this.getClass().getName() + "::createReadCaches readCacheInternal=" + readCacheInternal
+ " readCacheLeaf=" + readCacheLeaf);
}
cacheInternalNodes = createCacheLRUlinked(readCacheInternal);
cacheLeafNodes = createCacheLRUlinked(readCacheLeaf);
} | java | private void createReadCaches() {
recalculateSizeReadCaches();
if (log.isDebugEnabled()) {
log.debug(this.getClass().getName() + "::createReadCaches readCacheInternal=" + readCacheInternal
+ " readCacheLeaf=" + readCacheLeaf);
}
cacheInternalNodes = createCacheLRUlinked(readCacheInternal);
cacheLeafNodes = createCacheLRUlinked(readCacheLeaf);
} | [
"private",
"void",
"createReadCaches",
"(",
")",
"{",
"recalculateSizeReadCaches",
"(",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
... | Create read caches | [
"Create",
"read",
"caches"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1127-L1135 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.createCacheLRUlinked | @SuppressWarnings("rawtypes")
private IntLinkedHashMap<Node> createCacheLRUlinked(final int maxSize) {
return new IntLinkedHashMap<Node>((int) (maxSize * 1.5f), Node.class, true);
} | java | @SuppressWarnings("rawtypes")
private IntLinkedHashMap<Node> createCacheLRUlinked(final int maxSize) {
return new IntLinkedHashMap<Node>((int) (maxSize * 1.5f), Node.class, true);
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"private",
"IntLinkedHashMap",
"<",
"Node",
">",
"createCacheLRUlinked",
"(",
"final",
"int",
"maxSize",
")",
"{",
"return",
"new",
"IntLinkedHashMap",
"<",
"Node",
">",
"(",
"(",
"int",
")",
"(",
"maxSize",
... | Create a LRU hashmap of size maxSize
@param maxSize
@return IntLinkedHashMap | [
"Create",
"a",
"LRU",
"hashmap",
"of",
"size",
"maxSize"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1152-L1155 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.populateCache | private void populateCache() {
if (disableAllCaches || disablePopulateCache) {
return;
}
// Populate Cache
final long ts = System.currentTimeMillis();
for (int index = 1; ((index < storageBlock) && (cacheInternalNodes.size() < readCacheInternal) && (cacheLeafNodes
.size() < readCacheLeaf)); index++) {
if (freeBlocks.get(index)) {
continue; // skip free
}
try {
final Node<K, V> node = getNodeFromStore(index); // read
(node.isLeaf() ? cacheLeafNodes : cacheInternalNodes).put(node.id, node);
} catch (Node.InvalidNodeID e) {
freeBlocks.set(index); // mark index as free
}
}
log.info("Populated read cache ts=" + (System.currentTimeMillis() - ts) + " blocks=" + storageBlock
+ " elements=" + elements);
} | java | private void populateCache() {
if (disableAllCaches || disablePopulateCache) {
return;
}
// Populate Cache
final long ts = System.currentTimeMillis();
for (int index = 1; ((index < storageBlock) && (cacheInternalNodes.size() < readCacheInternal) && (cacheLeafNodes
.size() < readCacheLeaf)); index++) {
if (freeBlocks.get(index)) {
continue; // skip free
}
try {
final Node<K, V> node = getNodeFromStore(index); // read
(node.isLeaf() ? cacheLeafNodes : cacheInternalNodes).put(node.id, node);
} catch (Node.InvalidNodeID e) {
freeBlocks.set(index); // mark index as free
}
}
log.info("Populated read cache ts=" + (System.currentTimeMillis() - ts) + " blocks=" + storageBlock
+ " elements=" + elements);
} | [
"private",
"void",
"populateCache",
"(",
")",
"{",
"if",
"(",
"disableAllCaches",
"||",
"disablePopulateCache",
")",
"{",
"return",
";",
"}",
"// Populate Cache",
"final",
"long",
"ts",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"for",
"(",
"int... | Populate read cache if cache is enabled | [
"Populate",
"read",
"cache",
"if",
"cache",
"is",
"enabled"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1160-L1180 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.getNodeCache | @SuppressWarnings("unchecked")
private Node<K, V> getNodeCache(final int nodeid) {
final boolean isLeaf = Node.isLeaf(nodeid);
boolean responseFromCache = true;
Node<K, V> node = (isLeaf ? dirtyLeafNodes : dirtyInternalNodes).get(nodeid);
if (node == null) {
node = (isLeaf ? cacheLeafNodes : cacheInternalNodes).get(nodeid);
if (node == null) {
if (log.isDebugEnabled())
log.debug("diskread node id=" + nodeid);
node = getNodeFromStore(nodeid);
responseFromCache = false;
(node.isLeaf() ? cacheLeafNodes : cacheInternalNodes).put(nodeid, node);
}
}
if (enableIOStats) {
if (responseFromCache) {
getIOStat(nodeid).incCacheRead();
}
}
return node;
} | java | @SuppressWarnings("unchecked")
private Node<K, V> getNodeCache(final int nodeid) {
final boolean isLeaf = Node.isLeaf(nodeid);
boolean responseFromCache = true;
Node<K, V> node = (isLeaf ? dirtyLeafNodes : dirtyInternalNodes).get(nodeid);
if (node == null) {
node = (isLeaf ? cacheLeafNodes : cacheInternalNodes).get(nodeid);
if (node == null) {
if (log.isDebugEnabled())
log.debug("diskread node id=" + nodeid);
node = getNodeFromStore(nodeid);
responseFromCache = false;
(node.isLeaf() ? cacheLeafNodes : cacheInternalNodes).put(nodeid, node);
}
}
if (enableIOStats) {
if (responseFromCache) {
getIOStat(nodeid).incCacheRead();
}
}
return node;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"Node",
"<",
"K",
",",
"V",
">",
"getNodeCache",
"(",
"final",
"int",
"nodeid",
")",
"{",
"final",
"boolean",
"isLeaf",
"=",
"Node",
".",
"isLeaf",
"(",
"nodeid",
")",
";",
"boolean",
"respon... | Get node from cache
@param nodeid int with nodeid
@return Node<K,V> | [
"Get",
"node",
"from",
"cache"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1188-L1209 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.setNodeDirty | private void setNodeDirty(final Node<K, V> node) {
final int nodeid = node.id;
final int index = nodeid < 0 ? -nodeid : nodeid;
(node.isLeaf() ? dirtyLeafNodes : dirtyInternalNodes).put(nodeid, node);
(node.isLeaf() ? cacheLeafNodes : cacheInternalNodes).remove(nodeid);
if (enableIOStats) {
getIOStat(nodeid).incCacheWrite();
}
if (enableDirtyCheck) {
dirtyCheck.set(index);
}
} | java | private void setNodeDirty(final Node<K, V> node) {
final int nodeid = node.id;
final int index = nodeid < 0 ? -nodeid : nodeid;
(node.isLeaf() ? dirtyLeafNodes : dirtyInternalNodes).put(nodeid, node);
(node.isLeaf() ? cacheLeafNodes : cacheInternalNodes).remove(nodeid);
if (enableIOStats) {
getIOStat(nodeid).incCacheWrite();
}
if (enableDirtyCheck) {
dirtyCheck.set(index);
}
} | [
"private",
"void",
"setNodeDirty",
"(",
"final",
"Node",
"<",
"K",
",",
"V",
">",
"node",
")",
"{",
"final",
"int",
"nodeid",
"=",
"node",
".",
"id",
";",
"final",
"int",
"index",
"=",
"nodeid",
"<",
"0",
"?",
"-",
"nodeid",
":",
"nodeid",
";",
"... | Put a node in dirty cache
@param node | [
"Put",
"a",
"node",
"in",
"dirty",
"cache"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1251-L1262 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.getIOStat | private IOStat getIOStat(final int nodeid) {
IOStat io = iostats.get(nodeid);
if (io == null) {
io = new IOStat(nodeid);
iostats.put(nodeid, io);
}
return io;
} | java | private IOStat getIOStat(final int nodeid) {
IOStat io = iostats.get(nodeid);
if (io == null) {
io = new IOStat(nodeid);
iostats.put(nodeid, io);
}
return io;
} | [
"private",
"IOStat",
"getIOStat",
"(",
"final",
"int",
"nodeid",
")",
"{",
"IOStat",
"io",
"=",
"iostats",
".",
"get",
"(",
"nodeid",
")",
";",
"if",
"(",
"io",
"==",
"null",
")",
"{",
"io",
"=",
"new",
"IOStat",
"(",
"nodeid",
")",
";",
"iostats",... | Return or Create if not exist an IOStat object for a nodeid
@param nodeid
@param isLeaf
@return IOStat object | [
"Return",
"or",
"Create",
"if",
"not",
"exist",
"an",
"IOStat",
"object",
"for",
"a",
"nodeid"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1421-L1428 | train |
ggrandes/kvstore | src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java | BplusTreeFile.dumpStats | public void dumpStats(final String file) throws FileNotFoundException {
PrintStream out = null;
try {
out = new PrintStream(new FileOutputStream(file));
dumpStats(out);
} finally {
try {
out.close();
} catch (Exception ign) {
}
}
} | java | public void dumpStats(final String file) throws FileNotFoundException {
PrintStream out = null;
try {
out = new PrintStream(new FileOutputStream(file));
dumpStats(out);
} finally {
try {
out.close();
} catch (Exception ign) {
}
}
} | [
"public",
"void",
"dumpStats",
"(",
"final",
"String",
"file",
")",
"throws",
"FileNotFoundException",
"{",
"PrintStream",
"out",
"=",
"null",
";",
"try",
"{",
"out",
"=",
"new",
"PrintStream",
"(",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
";",
"d... | Dump IOStats of tree to a file
@param file
@throws FileNotFoundException | [
"Dump",
"IOStats",
"of",
"tree",
"to",
"a",
"file"
] | c79277f79f4604e0fec8349a98519838e3de38f0 | https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L1436-L1447 | train |
qatools/properties | src/main/java/ru/qatools/properties/utils/PropsReplacer.java | PropsReplacer.replaceProps | public PropsReplacer replaceProps(String pattern, Properties properties) {
List<String> replaced = new ArrayList<>();
for (String path : paths) {
replaced.add(replaceProps(pattern, path, properties));
}
setPaths(replaced);
return this;
} | java | public PropsReplacer replaceProps(String pattern, Properties properties) {
List<String> replaced = new ArrayList<>();
for (String path : paths) {
replaced.add(replaceProps(pattern, path, properties));
}
setPaths(replaced);
return this;
} | [
"public",
"PropsReplacer",
"replaceProps",
"(",
"String",
"pattern",
",",
"Properties",
"properties",
")",
"{",
"List",
"<",
"String",
">",
"replaced",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"path",
":",
"paths",
")",
"{",
"r... | Fluent-api method. Replace properties in each path from paths field using pattern. Change paths filed value
@param pattern - pattern to replace. First group should contains property name
@param properties - list of properties using to replace
@return PropsReplacer | [
"Fluent",
"-",
"api",
"method",
".",
"Replace",
"properties",
"in",
"each",
"path",
"from",
"paths",
"field",
"using",
"pattern",
".",
"Change",
"paths",
"filed",
"value"
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/utils/PropsReplacer.java#L29-L36 | train |
qatools/properties | src/main/java/ru/qatools/properties/utils/PropsReplacer.java | PropsReplacer.replaceProps | private String replaceProps(String pattern, String path, Properties properties) {
Matcher matcher = Pattern.compile(pattern).matcher(path);
String replaced = path;
while (matcher.find()) {
replaced = replaced.replace(matcher.group(0), properties.getProperty(matcher.group(1), ""));
}
return replaced;
} | java | private String replaceProps(String pattern, String path, Properties properties) {
Matcher matcher = Pattern.compile(pattern).matcher(path);
String replaced = path;
while (matcher.find()) {
replaced = replaced.replace(matcher.group(0), properties.getProperty(matcher.group(1), ""));
}
return replaced;
} | [
"private",
"String",
"replaceProps",
"(",
"String",
"pattern",
",",
"String",
"path",
",",
"Properties",
"properties",
")",
"{",
"Matcher",
"matcher",
"=",
"Pattern",
".",
"compile",
"(",
"pattern",
")",
".",
"matcher",
"(",
"path",
")",
";",
"String",
"re... | Replace properties in given path using pattern
@param pattern - pattern to replace. First group should contains property name
@param path - given path to replace in
@param properties - list of properties using to replace
@return path with replaced properties | [
"Replace",
"properties",
"in",
"given",
"path",
"using",
"pattern"
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/utils/PropsReplacer.java#L45-L52 | train |
qatools/properties | src/main/java/ru/qatools/properties/PropertyLoader.java | PropertyLoader.populate | public <T> T populate(String prefix, Class<T> clazz, Set<Class> resolvedConfigs) {
checkConfigurationClass(clazz);
Map<Method, PropertyInfo> properties = resolve(prefix, clazz.getMethods(), resolvedConfigs);
//noinspection unchecked
return (T) Proxy.newProxyInstance(classLoader, new Class[]{clazz},
new PropertiesProxy(properties));
} | java | public <T> T populate(String prefix, Class<T> clazz, Set<Class> resolvedConfigs) {
checkConfigurationClass(clazz);
Map<Method, PropertyInfo> properties = resolve(prefix, clazz.getMethods(), resolvedConfigs);
//noinspection unchecked
return (T) Proxy.newProxyInstance(classLoader, new Class[]{clazz},
new PropertiesProxy(properties));
} | [
"public",
"<",
"T",
">",
"T",
"populate",
"(",
"String",
"prefix",
",",
"Class",
"<",
"T",
">",
"clazz",
",",
"Set",
"<",
"Class",
">",
"resolvedConfigs",
")",
"{",
"checkConfigurationClass",
"(",
"clazz",
")",
";",
"Map",
"<",
"Method",
",",
"Property... | Creates a proxy instance of given configuration. | [
"Creates",
"a",
"proxy",
"instance",
"of",
"given",
"configuration",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L89-L95 | train |
qatools/properties | src/main/java/ru/qatools/properties/PropertyLoader.java | PropertyLoader.setValueToField | protected void setValueToField(Field field, Object bean, Object value) {
try {
field.setAccessible(true);
field.set(bean, value);
} catch (Exception e) {
throw new PropertyLoaderException(
String.format("Can not set bean <%s> field <%s> value", bean, field), e
);
}
} | java | protected void setValueToField(Field field, Object bean, Object value) {
try {
field.setAccessible(true);
field.set(bean, value);
} catch (Exception e) {
throw new PropertyLoaderException(
String.format("Can not set bean <%s> field <%s> value", bean, field), e
);
}
} | [
"protected",
"void",
"setValueToField",
"(",
"Field",
"field",
",",
"Object",
"bean",
",",
"Object",
"value",
")",
"{",
"try",
"{",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"bean",
",",
"value",
")",
";",
"}",
"... | Set given value to specified field of given object.
@throws PropertyLoaderException if some exceptions occurs during reflection calls.
@see Field#setAccessible(boolean)
@see Field#set(Object, Object) | [
"Set",
"given",
"value",
"to",
"specified",
"field",
"of",
"given",
"object",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L104-L113 | train |
qatools/properties | src/main/java/ru/qatools/properties/PropertyLoader.java | PropertyLoader.resolveProperty | private <T extends AnnotatedElement> Map<T, PropertyInfo> resolveProperty(String keyPrefix, T element) {
Map<T, PropertyInfo> result = new HashMap<>();
if (!shouldDecorate(element)) {
return result;
}
String key = getKey(keyPrefix, element);
String defaultValue = getPropertyDefaultValue(element);
String stringValue = compiled.getProperty(key, defaultValue);
if (stringValue == null) {
checkRequired(key, element);
return result;
}
Object value = convertValue(element, stringValue);
result.put(element, new PropertyInfo(key, stringValue, value));
return result;
} | java | private <T extends AnnotatedElement> Map<T, PropertyInfo> resolveProperty(String keyPrefix, T element) {
Map<T, PropertyInfo> result = new HashMap<>();
if (!shouldDecorate(element)) {
return result;
}
String key = getKey(keyPrefix, element);
String defaultValue = getPropertyDefaultValue(element);
String stringValue = compiled.getProperty(key, defaultValue);
if (stringValue == null) {
checkRequired(key, element);
return result;
}
Object value = convertValue(element, stringValue);
result.put(element, new PropertyInfo(key, stringValue, value));
return result;
} | [
"private",
"<",
"T",
"extends",
"AnnotatedElement",
">",
"Map",
"<",
"T",
",",
"PropertyInfo",
">",
"resolveProperty",
"(",
"String",
"keyPrefix",
",",
"T",
"element",
")",
"{",
"Map",
"<",
"T",
",",
"PropertyInfo",
">",
"result",
"=",
"new",
"HashMap",
... | Resolve the property for given element. | [
"Resolve",
"the",
"property",
"for",
"given",
"element",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L158-L176 | train |
qatools/properties | src/main/java/ru/qatools/properties/PropertyLoader.java | PropertyLoader.resolveConfig | private <T extends AnnotatedElement> Map<T, PropertyInfo> resolveConfig(String keyPrefix, T element,
Set<Class> resolvedConfigs) {
Map<T, PropertyInfo> result = new HashMap<>();
if (!element.isAnnotationPresent(Config.class)) {
return result;
}
String prefix = concat(keyPrefix, element.getAnnotation(Config.class).prefix());
Class<?> returnType = getValueType(element);
checkRecursiveConfigs(resolvedConfigs, returnType);
resolvedConfigs.add(returnType);
Object proxy = populate(prefix, returnType, resolvedConfigs);
result.put(element, new PropertyInfo(proxy));
return result;
} | java | private <T extends AnnotatedElement> Map<T, PropertyInfo> resolveConfig(String keyPrefix, T element,
Set<Class> resolvedConfigs) {
Map<T, PropertyInfo> result = new HashMap<>();
if (!element.isAnnotationPresent(Config.class)) {
return result;
}
String prefix = concat(keyPrefix, element.getAnnotation(Config.class).prefix());
Class<?> returnType = getValueType(element);
checkRecursiveConfigs(resolvedConfigs, returnType);
resolvedConfigs.add(returnType);
Object proxy = populate(prefix, returnType, resolvedConfigs);
result.put(element, new PropertyInfo(proxy));
return result;
} | [
"private",
"<",
"T",
"extends",
"AnnotatedElement",
">",
"Map",
"<",
"T",
",",
"PropertyInfo",
">",
"resolveConfig",
"(",
"String",
"keyPrefix",
",",
"T",
"element",
",",
"Set",
"<",
"Class",
">",
"resolvedConfigs",
")",
"{",
"Map",
"<",
"T",
",",
"Prope... | Resolve the config for given element. | [
"Resolve",
"the",
"config",
"for",
"given",
"element",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L181-L196 | train |
qatools/properties | src/main/java/ru/qatools/properties/PropertyLoader.java | PropertyLoader.checkRecursiveConfigs | private void checkRecursiveConfigs(Set<Class> resolvedConfigs, Class<?> configClass) {
if (resolvedConfigs.contains(configClass)) {
throw new PropertyLoaderException(String.format("Recursive configuration <%s>", configClass));
}
} | java | private void checkRecursiveConfigs(Set<Class> resolvedConfigs, Class<?> configClass) {
if (resolvedConfigs.contains(configClass)) {
throw new PropertyLoaderException(String.format("Recursive configuration <%s>", configClass));
}
} | [
"private",
"void",
"checkRecursiveConfigs",
"(",
"Set",
"<",
"Class",
">",
"resolvedConfigs",
",",
"Class",
"<",
"?",
">",
"configClass",
")",
"{",
"if",
"(",
"resolvedConfigs",
".",
"contains",
"(",
"configClass",
")",
")",
"{",
"throw",
"new",
"PropertyLoa... | Throws an exception if already meet the config. | [
"Throws",
"an",
"exception",
"if",
"already",
"meet",
"the",
"config",
"."
] | ae50b460a6bb4fcb21afe888b2e86a7613cd2115 | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L209-L213 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.