id
int32
0
165k
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
106,500
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
106,501
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.getReq...
java
public static StopwatchSource<HttpServletRequest> newCacheStopwatchSource(StopwatchSource<HttpServletRequest> stopwatchSource) { return new CachedStopwatchSource<HttpServletRequest, String>(stopwatchSource) { @Override protected String getLocationKey(HttpServletRequest location) { return location.getReq...
[ "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
106,502
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...
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...
[ "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
106,503
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("...
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("...
[ "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
106,504
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.getParame...
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.getParame...
[ "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
106,505
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
106,506
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 =...
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 =...
[ "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
106,507
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
106,508
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
106,509
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
106,510
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(lo...
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(lo...
[ "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
106,511
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
106,512
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
106,513
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 ...
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 ...
[ "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
106,514
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
106,515
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
106,516
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
106,517
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, "n...
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, "n...
[ "@", "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
106,518
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
106,519
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
106,520
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
106,521
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(); /...
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(); /...
[ "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
106,522
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
106,523
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); } ...
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); } ...
[ "@", "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
106,524
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
106,525
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
106,526
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(...
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(...
[ "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
106,527
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
106,528
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
106,529
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 EnumConver...
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 EnumConver...
[ "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
106,530
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...
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...
[ "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
106,531
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)...
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)...
[ "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
106,532
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> co...
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> co...
[ "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
106,533
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" + collec...
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" + collec...
[ "@", "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
106,534
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
106,535
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 byt...
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 byt...
[ "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
106,536
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
106,537
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
106,538
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
106,539
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: " +...
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: " +...
[ "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
106,540
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 LOAD...
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 LOAD...
[ "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
106,541
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(); ...
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(); ...
[ "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
106,542
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
106,543
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) .pu...
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) .pu...
[ "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
106,544
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 (MAGIC...
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 (MAGIC...
[ "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
106,545
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 (Except...
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 (Except...
[ "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
106,546
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
106,547
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
106,548
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 (useRedoThrea...
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 (useRedoThrea...
[ "@", "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
106,549
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) { ...
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) { ...
[ "@", "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
106,550
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 maxCacheSizeIn...
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 maxCacheSizeIn...
[ "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/...
[ "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
106,551
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
106,552
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); cacheLeafNo...
java
private void createReadCaches() { recalculateSizeReadCaches(); if (log.isDebugEnabled()) { log.debug(this.getClass().getName() + "::createReadCaches readCacheInternal=" + readCacheInternal + " readCacheLeaf=" + readCacheLeaf); } cacheInternalNodes = createCacheLRUlinked(readCacheInternal); cacheLeafNo...
[ "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
106,553
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
106,554
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++) { ...
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++) { ...
[ "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
106,555
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 : cacheInternalNo...
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 : cacheInternalNo...
[ "@", "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
106,556
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(nodei...
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(nodei...
[ "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
106,557
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
106,558
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
106,559
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
106,560
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), "")); ...
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), "")); ...
[ "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
106,561
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 Clas...
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 Clas...
[ "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
106,562
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", bea...
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", bea...
[ "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
106,563
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 = get...
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 = get...
[ "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
106,564
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)) { ...
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)) { ...
[ "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
106,565
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
106,566
qatools/properties
src/main/java/ru/qatools/properties/PropertyLoader.java
PropertyLoader.checkRequired
protected void checkRequired(String key, AnnotatedElement element) { if (isRequired(element)) { throw new PropertyLoaderException(String.format("Required property <%s> doesn't exists", key)); } }
java
protected void checkRequired(String key, AnnotatedElement element) { if (isRequired(element)) { throw new PropertyLoaderException(String.format("Required property <%s> doesn't exists", key)); } }
[ "protected", "void", "checkRequired", "(", "String", "key", ",", "AnnotatedElement", "element", ")", "{", "if", "(", "isRequired", "(", "element", ")", ")", "{", "throw", "new", "PropertyLoaderException", "(", "String", ".", "format", "(", "\"Required property <...
Throws an exception if given element is required. @see #isRequired(AnnotatedElement)
[ "Throws", "an", "exception", "if", "given", "element", "is", "required", "." ]
ae50b460a6bb4fcb21afe888b2e86a7613cd2115
https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L220-L224
106,567
qatools/properties
src/main/java/ru/qatools/properties/PropertyLoader.java
PropertyLoader.concat
protected String concat(String first, String second) { return first == null ? second : String.format("%s.%s", first, second); }
java
protected String concat(String first, String second) { return first == null ? second : String.format("%s.%s", first, second); }
[ "protected", "String", "concat", "(", "String", "first", ",", "String", "second", ")", "{", "return", "first", "==", "null", "?", "second", ":", "String", ".", "format", "(", "\"%s.%s\"", ",", "first", ",", "second", ")", ";", "}" ]
Concat the given prefixes into one.
[ "Concat", "the", "given", "prefixes", "into", "one", "." ]
ae50b460a6bb4fcb21afe888b2e86a7613cd2115
https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L256-L258
106,568
qatools/properties
src/main/java/ru/qatools/properties/PropertyLoader.java
PropertyLoader.register
public <T> PropertyLoader register(Converter<T> converter, Class<T> type) { manager.register(type, converter); return this; }
java
public <T> PropertyLoader register(Converter<T> converter, Class<T> type) { manager.register(type, converter); return this; }
[ "public", "<", "T", ">", "PropertyLoader", "register", "(", "Converter", "<", "T", ">", "converter", ",", "Class", "<", "T", ">", "type", ")", "{", "manager", ".", "register", "(", "type", ",", "converter", ")", ";", "return", "this", ";", "}" ]
Register custom converter for given type.
[ "Register", "custom", "converter", "for", "given", "type", "." ]
ae50b460a6bb4fcb21afe888b2e86a7613cd2115
https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L356-L359
106,569
ggrandes/kvstore
src/main/java/org/javastack/kvstore/utils/HexStrings.java
HexStrings.byteArrayAsHex
public final static String byteArrayAsHex(final byte[] buf, final int limit) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < limit; ++i) { if ((i % 16) == 0) { // print offset sb.append(nativeAsHex(i, 32)).append(" "); } else if (((i) % 8) == 0) { // split on qword sb.append(" ");...
java
public final static String byteArrayAsHex(final byte[] buf, final int limit) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < limit; ++i) { if ((i % 16) == 0) { // print offset sb.append(nativeAsHex(i, 32)).append(" "); } else if (((i) % 8) == 0) { // split on qword sb.append(" ");...
[ "public", "final", "static", "String", "byteArrayAsHex", "(", "final", "byte", "[", "]", "buf", ",", "final", "int", "limit", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", ...
Return hexdump of byte-array @param buf is byte array to dump @param limit size to dump from 0-offset to limit @return String representation of hexdump
[ "Return", "hexdump", "of", "byte", "-", "array" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/utils/HexStrings.java#L93-L120
106,570
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java
WeakSet.clear
public void clear(final boolean shrink) { while (queue.poll() != null) { ; } if (elementCount > 0) { elementCount = 0; } if (shrink && (elementData.length > 1024) && (elementData.length > defaultSize)) { elementData = newElementArray(defaultSize); } else { Arrays.fill(elementData, null); } c...
java
public void clear(final boolean shrink) { while (queue.poll() != null) { ; } if (elementCount > 0) { elementCount = 0; } if (shrink && (elementData.length > 1024) && (elementData.length > defaultSize)) { elementData = newElementArray(defaultSize); } else { Arrays.fill(elementData, null); } c...
[ "public", "void", "clear", "(", "final", "boolean", "shrink", ")", "{", "while", "(", "queue", ".", "poll", "(", ")", "!=", "null", ")", "{", ";", "}", "if", "(", "elementCount", ">", "0", ")", "{", "elementCount", "=", "0", ";", "}", "if", "(", ...
Clear the set @param shrink if true, shrink the set to initial size
[ "Clear", "the", "set" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java#L103-L119
106,571
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java
WeakSet.get
public T get(final T value) { expungeStaleEntries(); // final int index = (value.hashCode() & 0x7FFFFFFF) % elementData.length; Entry<T> m = elementData[index]; while (m != null) { if (eq(value, m.get())) { return m.get(); } m = m.nextInSlot; } return null; }
java
public T get(final T value) { expungeStaleEntries(); // final int index = (value.hashCode() & 0x7FFFFFFF) % elementData.length; Entry<T> m = elementData[index]; while (m != null) { if (eq(value, m.get())) { return m.get(); } m = m.nextInSlot; } return null; }
[ "public", "T", "get", "(", "final", "T", "value", ")", "{", "expungeStaleEntries", "(", ")", ";", "//", "final", "int", "index", "=", "(", "value", ".", "hashCode", "(", ")", "&", "0x7FFFFFFF", ")", "%", "elementData", ".", "length", ";", "Entry", "<...
Returns the specified value. @param value the value. @return the value, or {@code null} if not found the specified value
[ "Returns", "the", "specified", "value", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java#L127-L139
106,572
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java
WeakSet.put
public T put(final T value) { expungeStaleEntries(); // final int hash = value.hashCode(); int index = (hash & 0x7FFFFFFF) % elementData.length; Entry<T> entry = elementData[index]; while (entry != null && !eq(value, entry.get())) { entry = entry.nextInSlot; } if (entry == null) { if (++elementCo...
java
public T put(final T value) { expungeStaleEntries(); // final int hash = value.hashCode(); int index = (hash & 0x7FFFFFFF) % elementData.length; Entry<T> entry = elementData[index]; while (entry != null && !eq(value, entry.get())) { entry = entry.nextInSlot; } if (entry == null) { if (++elementCo...
[ "public", "T", "put", "(", "final", "T", "value", ")", "{", "expungeStaleEntries", "(", ")", ";", "//", "final", "int", "hash", "=", "value", ".", "hashCode", "(", ")", ";", "int", "index", "=", "(", "hash", "&", "0x7FFFFFFF", ")", "%", "elementData"...
Puts the specified value in the set. @param value the value. @return the value of any previous put or {@code null} if there was no such value.
[ "Puts", "the", "specified", "value", "in", "the", "set", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java#L158-L179
106,573
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java
WeakSet.remove
public T remove(final T value) { expungeStaleEntries(); // final Entry<T> entry = removeEntry(value); if (entry == null) { return null; } final T ret = entry.get(); return ret; }
java
public T remove(final T value) { expungeStaleEntries(); // final Entry<T> entry = removeEntry(value); if (entry == null) { return null; } final T ret = entry.get(); return ret; }
[ "public", "T", "remove", "(", "final", "T", "value", ")", "{", "expungeStaleEntries", "(", ")", ";", "//", "final", "Entry", "<", "T", ">", "entry", "=", "removeEntry", "(", "value", ")", ";", "if", "(", "entry", "==", "null", ")", "{", "return", "...
Removes the specified value from this set. @param value the value to remove. @return the value removed or {@code null} if not found
[ "Removes", "the", "specified", "value", "from", "this", "set", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/WeakSet.java#L253-L262
106,574
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/hash/FixedIntHashMap.java
FixedIntHashMap.clear
public void clear(boolean shrink) { if (elementCount > 0) { elementCount = 0; } if (shrink && ((elementKeys.length > 1024) && (elementKeys.length > defaultSize))) { elementKeys = newKeyArray(defaultSize); elementValues = newElementArray(defaultSize); } else { Arrays.fill(elementKeys, Integer.MIN_VAL...
java
public void clear(boolean shrink) { if (elementCount > 0) { elementCount = 0; } if (shrink && ((elementKeys.length > 1024) && (elementKeys.length > defaultSize))) { elementKeys = newKeyArray(defaultSize); elementValues = newElementArray(defaultSize); } else { Arrays.fill(elementKeys, Integer.MIN_VAL...
[ "public", "void", "clear", "(", "boolean", "shrink", ")", "{", "if", "(", "elementCount", ">", "0", ")", "{", "elementCount", "=", "0", ";", "}", "if", "(", "shrink", "&&", "(", "(", "elementKeys", ".", "length", ">", "1024", ")", "&&", "(", "eleme...
Removes all mappings from this hash map, leaving it empty. @see #isEmpty @see #size
[ "Removes", "all", "mappings", "from", "this", "hash", "map", "leaving", "it", "empty", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/FixedIntHashMap.java#L97-L109
106,575
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/hash/FixedIntHashMap.java
FixedIntHashMap.computeMaxSize
private void computeMaxSize() { threshold = (int) (elementKeys.length * loadFactor); if (log.isDebugEnabled()) { log.debug(this.getClass().getName() + "::computeMaxSize()=" + threshold + " collisions=" + collisions + " (" + (collisions * 100 / elementKeys.length) + ")"); } collisions = 0; }
java
private void computeMaxSize() { threshold = (int) (elementKeys.length * loadFactor); if (log.isDebugEnabled()) { log.debug(this.getClass().getName() + "::computeMaxSize()=" + threshold + " collisions=" + collisions + " (" + (collisions * 100 / elementKeys.length) + ")"); } collisions = 0; }
[ "private", "void", "computeMaxSize", "(", ")", "{", "threshold", "=", "(", "int", ")", "(", "elementKeys", ".", "length", "*", "loadFactor", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "this", ".",...
Returns a shallow copy of this map. @return a shallow copy of this map.
[ "Returns", "a", "shallow", "copy", "of", "this", "map", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/hash/FixedIntHashMap.java#L124-L131
106,576
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.createRootNode
protected void createRootNode() { final Node<K, V> node = createLeafNode(); node.allocId(); rootIdx = node.id; height = 1; elements = 0; putNode(node); }
java
protected void createRootNode() { final Node<K, V> node = createLeafNode(); node.allocId(); rootIdx = node.id; height = 1; elements = 0; putNode(node); }
[ "protected", "void", "createRootNode", "(", ")", "{", "final", "Node", "<", "K", ",", "V", ">", "node", "=", "createLeafNode", "(", ")", ";", "node", ".", "allocId", "(", ")", ";", "rootIdx", "=", "node", ".", "id", ";", "height", "=", "1", ";", ...
Create a Leaf root node and alloc nodeid for this
[ "Create", "a", "Leaf", "root", "node", "and", "alloc", "nodeid", "for", "this" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L295-L302
106,577
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.getMaxStructSize
private int getMaxStructSize() { final int leafSize = (createLeafNode().getStructMaxSize()); final int internalSize = (createInternalNode().getStructMaxSize()); return Math.max(leafSize, internalSize); }
java
private int getMaxStructSize() { final int leafSize = (createLeafNode().getStructMaxSize()); final int internalSize = (createInternalNode().getStructMaxSize()); return Math.max(leafSize, internalSize); }
[ "private", "int", "getMaxStructSize", "(", ")", "{", "final", "int", "leafSize", "=", "(", "createLeafNode", "(", ")", ".", "getStructMaxSize", "(", ")", ")", ";", "final", "int", "internalSize", "=", "(", "createInternalNode", "(", ")", ".", "getStructMaxSi...
Get the maximal size for a node @return integer with the max size of a leaf / internal node
[ "Get", "the", "maximal", "size", "for", "a", "node" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L309-L313
106,578
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.findOptimalNodeOrder
private void findOptimalNodeOrder(final int block_size) { final Node<K, V> leaf = createLeafNode(); final Node<K, V> internal = createInternalNode(); // Get Maximal Size final int nodeSize = Math.max(leaf.getStructEstimateSize(MIN_B_ORDER), internal.getStructEstimateSize(MIN_B_ORDER)); // Find minimal blo...
java
private void findOptimalNodeOrder(final int block_size) { final Node<K, V> leaf = createLeafNode(); final Node<K, V> internal = createInternalNode(); // Get Maximal Size final int nodeSize = Math.max(leaf.getStructEstimateSize(MIN_B_ORDER), internal.getStructEstimateSize(MIN_B_ORDER)); // Find minimal blo...
[ "private", "void", "findOptimalNodeOrder", "(", "final", "int", "block_size", ")", "{", "final", "Node", "<", "K", ",", "V", ">", "leaf", "=", "createLeafNode", "(", ")", ";", "final", "Node", "<", "K", ",", "V", ">", "internal", "=", "createInternalNode...
Calculate optimal values for b-order to fit in a block of block_size @param block_size integer with block size (bytes)
[ "Calculate", "optimal", "values", "for", "b", "-", "order", "to", "fit", "in", "a", "block", "of", "block_size" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L320-L332
106,579
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.findOptimalNodeOrder
private int findOptimalNodeOrder(final Node<K, V> node) { int low = MIN_B_ORDER; // minimal b-order int high = (blockSize / node.getStructEstimateSize(1)) << 2; // estimate high b-order while (low <= high) { int mid = ((low + high) >>> 1); mid += (1 - (mid % 2)); int nodeSize = node.getStructEstimateSiz...
java
private int findOptimalNodeOrder(final Node<K, V> node) { int low = MIN_B_ORDER; // minimal b-order int high = (blockSize / node.getStructEstimateSize(1)) << 2; // estimate high b-order while (low <= high) { int mid = ((low + high) >>> 1); mid += (1 - (mid % 2)); int nodeSize = node.getStructEstimateSiz...
[ "private", "int", "findOptimalNodeOrder", "(", "final", "Node", "<", "K", ",", "V", ">", "node", ")", "{", "int", "low", "=", "MIN_B_ORDER", ";", "// minimal b-order", "int", "high", "=", "(", "blockSize", "/", "node", ".", "getStructEstimateSize", "(", "1...
Find b-order for a blockSize of this tree @param node of type Leaf or Integernal @return integer with b-order
[ "Find", "b", "-", "order", "for", "a", "blockSize", "of", "this", "tree" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L340-L364
106,580
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.findLeafNode
private final LeafNode<K, V> findLeafNode(final K key, final boolean tracePath) { Node<K, V> node = getNode(rootIdx); if (tracePath) { stackNodes.clear(); stackSlots.clear(); } while (!node.isLeaf()) { final InternalNode<K, V> nodeInternal = (InternalNode<K, V>) node; int slot = node.findSlotByKey(k...
java
private final LeafNode<K, V> findLeafNode(final K key, final boolean tracePath) { Node<K, V> node = getNode(rootIdx); if (tracePath) { stackNodes.clear(); stackSlots.clear(); } while (!node.isLeaf()) { final InternalNode<K, V> nodeInternal = (InternalNode<K, V>) node; int slot = node.findSlotByKey(k...
[ "private", "final", "LeafNode", "<", "K", ",", "V", ">", "findLeafNode", "(", "final", "K", "key", ",", "final", "boolean", "tracePath", ")", "{", "Node", "<", "K", ",", "V", ">", "node", "=", "getNode", "(", "rootIdx", ")", ";", "if", "(", "traceP...
Find node that can hold the key @param key @return LeafNode<K, V> containing the key or null if not found
[ "Find", "node", "that", "can", "hold", "the", "key" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L425-L446
106,581
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.pollFirstEntry
public synchronized TreeEntry<K, V> pollFirstEntry() { final TreeEntry<K, V> entry = firstEntry(); if (entry != null) { remove(entry.getKey()); } return entry; }
java
public synchronized TreeEntry<K, V> pollFirstEntry() { final TreeEntry<K, V> entry = firstEntry(); if (entry != null) { remove(entry.getKey()); } return entry; }
[ "public", "synchronized", "TreeEntry", "<", "K", ",", "V", ">", "pollFirstEntry", "(", ")", "{", "final", "TreeEntry", "<", "K", ",", "V", ">", "entry", "=", "firstEntry", "(", ")", ";", "if", "(", "entry", "!=", "null", ")", "{", "remove", "(", "e...
Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty. @return entry
[ "Removes", "and", "returns", "a", "key", "-", "value", "mapping", "associated", "with", "the", "least", "key", "in", "this", "map", "or", "null", "if", "the", "map", "is", "empty", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L538-L544
106,582
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.pollLastEntry
public synchronized TreeEntry<K, V> pollLastEntry() { final TreeEntry<K, V> entry = lastEntry(); if (entry != null) { remove(entry.getKey()); } return entry; }
java
public synchronized TreeEntry<K, V> pollLastEntry() { final TreeEntry<K, V> entry = lastEntry(); if (entry != null) { remove(entry.getKey()); } return entry; }
[ "public", "synchronized", "TreeEntry", "<", "K", ",", "V", ">", "pollLastEntry", "(", ")", "{", "final", "TreeEntry", "<", "K", ",", "V", ">", "entry", "=", "lastEntry", "(", ")", ";", "if", "(", "entry", "!=", "null", ")", "{", "remove", "(", "ent...
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty. @return entry
[ "Removes", "and", "returns", "a", "key", "-", "value", "mapping", "associated", "with", "the", "greatest", "key", "in", "this", "map", "or", "null", "if", "the", "map", "is", "empty", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L552-L558
106,583
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.getRoundKey
private final K getRoundKey(final K key, final boolean upORdown, final boolean acceptEqual) { final TreeEntry<K, V> entry = getRoundEntry(key, upORdown, acceptEqual); if (entry == null) { return null; } return entry.getKey(); }
java
private final K getRoundKey(final K key, final boolean upORdown, final boolean acceptEqual) { final TreeEntry<K, V> entry = getRoundEntry(key, upORdown, acceptEqual); if (entry == null) { return null; } return entry.getKey(); }
[ "private", "final", "K", "getRoundKey", "(", "final", "K", "key", ",", "final", "boolean", "upORdown", ",", "final", "boolean", "acceptEqual", ")", "{", "final", "TreeEntry", "<", "K", ",", "V", ">", "entry", "=", "getRoundEntry", "(", "key", ",", "upORd...
Return ceilingKey, floorKey, higherKey or lowerKey @param key the key @param upORdown true returns ceilingKey, false floorKey @param acceptEqual true returns equal keys, otherwise, only higher or lower @return the key found or null if not found
[ "Return", "ceilingKey", "floorKey", "higherKey", "or", "lowerKey" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L635-L641
106,584
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.ceilingEntry
public synchronized TreeEntry<K, V> ceilingEntry(final K key) { // Retorna la clave mas cercana mayor o igual a la clave indicada return getRoundEntry(key, true, true); }
java
public synchronized TreeEntry<K, V> ceilingEntry(final K key) { // Retorna la clave mas cercana mayor o igual a la clave indicada return getRoundEntry(key, true, true); }
[ "public", "synchronized", "TreeEntry", "<", "K", ",", "V", ">", "ceilingEntry", "(", "final", "K", "key", ")", "{", "// Retorna la clave mas cercana mayor o igual a la clave indicada", "return", "getRoundEntry", "(", "key", ",", "true", ",", "true", ")", ";", "}" ...
Returns the least key greater than or equal to the given key, or null if there is no such key. @param key the key @return the Entry with least key greater than or equal to key, or null if there is no such key
[ "Returns", "the", "least", "key", "greater", "than", "or", "equal", "to", "the", "given", "key", "or", "null", "if", "there", "is", "no", "such", "key", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L649-L652
106,585
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.floorEntry
public synchronized TreeEntry<K, V> floorEntry(final K key) { // Retorna la clave mas cercana menor o igual a la clave indicada return getRoundEntry(key, false, true); }
java
public synchronized TreeEntry<K, V> floorEntry(final K key) { // Retorna la clave mas cercana menor o igual a la clave indicada return getRoundEntry(key, false, true); }
[ "public", "synchronized", "TreeEntry", "<", "K", ",", "V", ">", "floorEntry", "(", "final", "K", "key", ")", "{", "// Retorna la clave mas cercana menor o igual a la clave indicada", "return", "getRoundEntry", "(", "key", ",", "false", ",", "true", ")", ";", "}" ]
Returns the greatest key less than or equal to the given key, or null if there is no such key. @param key the key @return the Entry with greatest key less than or equal to key, or null if there is no such key
[ "Returns", "the", "greatest", "key", "less", "than", "or", "equal", "to", "the", "given", "key", "or", "null", "if", "there", "is", "no", "such", "key", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L660-L663
106,586
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.higherEntry
public synchronized TreeEntry<K, V> higherEntry(final K key) { // Retorna la clave mas cercana mayor a la clave indicada return getRoundEntry(key, true, false); }
java
public synchronized TreeEntry<K, V> higherEntry(final K key) { // Retorna la clave mas cercana mayor a la clave indicada return getRoundEntry(key, true, false); }
[ "public", "synchronized", "TreeEntry", "<", "K", ",", "V", ">", "higherEntry", "(", "final", "K", "key", ")", "{", "// Retorna la clave mas cercana mayor a la clave indicada", "return", "getRoundEntry", "(", "key", ",", "true", ",", "false", ")", ";", "}" ]
Returns the least key strictly greater than the given key, or null if there is no such key. @param key the key @return the Entry with least key strictly greater than the given key, or null if there is no such key.
[ "Returns", "the", "least", "key", "strictly", "greater", "than", "the", "given", "key", "or", "null", "if", "there", "is", "no", "such", "key", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L671-L674
106,587
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.lowerEntry
public synchronized TreeEntry<K, V> lowerEntry(final K key) { // Retorna la clave mas cercana menor a la clave indicada return getRoundEntry(key, false, false); }
java
public synchronized TreeEntry<K, V> lowerEntry(final K key) { // Retorna la clave mas cercana menor a la clave indicada return getRoundEntry(key, false, false); }
[ "public", "synchronized", "TreeEntry", "<", "K", ",", "V", ">", "lowerEntry", "(", "final", "K", "key", ")", "{", "// Retorna la clave mas cercana menor a la clave indicada", "return", "getRoundEntry", "(", "key", ",", "false", ",", "false", ")", ";", "}" ]
Returns the greatest key strictly less than the given key, or null if there is no such key. @param key the key @return the Entry with greatest key strictly less than the given key, or null if there is no such key.
[ "Returns", "the", "greatest", "key", "strictly", "less", "than", "the", "given", "key", "or", "null", "if", "there", "is", "no", "such", "key", "." ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L682-L685
106,588
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.getRoundEntry
private final TreeEntry<K, V> getRoundEntry(final K key, final boolean upORdown, final boolean acceptEqual) { if (!validState) { throw new InvalidStateException(); } if (_isEmpty()) { return null; } if (key == null) { return null; } try { LeafNode<K, V> node = findLeafNode(key, false); if (...
java
private final TreeEntry<K, V> getRoundEntry(final K key, final boolean upORdown, final boolean acceptEqual) { if (!validState) { throw new InvalidStateException(); } if (_isEmpty()) { return null; } if (key == null) { return null; } try { LeafNode<K, V> node = findLeafNode(key, false); if (...
[ "private", "final", "TreeEntry", "<", "K", ",", "V", ">", "getRoundEntry", "(", "final", "K", "key", ",", "final", "boolean", "upORdown", ",", "final", "boolean", "acceptEqual", ")", "{", "if", "(", "!", "validState", ")", "{", "throw", "new", "InvalidSt...
Return ceilingEntry, floorEntry, higherEntry or lowerEntry @param key the key @param upORdown true returns ceiling/higher, false floor/lower @param acceptEqual true returns equal keys, otherwise, only higher or lower @return the Entry found or null if not found
[ "Return", "ceilingEntry", "floorEntry", "higherEntry", "or", "lowerEntry" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L695-L737
106,589
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.get
public synchronized V get(final K key) { if (!validState) { throw new InvalidStateException(); } if (_isEmpty()) { return null; } if (key == null) { return null; } try { final LeafNode<K, V> node = findLeafNode(key, false); if (node == null) { return null; } int slot = node.findSl...
java
public synchronized V get(final K key) { if (!validState) { throw new InvalidStateException(); } if (_isEmpty()) { return null; } if (key == null) { return null; } try { final LeafNode<K, V> node = findLeafNode(key, false); if (node == null) { return null; } int slot = node.findSl...
[ "public", "synchronized", "V", "get", "(", "final", "K", "key", ")", "{", "if", "(", "!", "validState", ")", "{", "throw", "new", "InvalidStateException", "(", ")", ";", "}", "if", "(", "_isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "i...
Find a Key in the Tree @param key to find @return Value found or null if not
[ "Find", "a", "Key", "in", "the", "Tree" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L755-L778
106,590
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.remove
public synchronized boolean remove(final K key) { if (readOnly) { return false; } if (!validState) { throw new InvalidStateException(); } if (key == null) { return false; } try { if (log.isDebugEnabled()) { log.debug("trying remove key=" + key); } submitRedoRemove(key); if (remove...
java
public synchronized boolean remove(final K key) { if (readOnly) { return false; } if (!validState) { throw new InvalidStateException(); } if (key == null) { return false; } try { if (log.isDebugEnabled()) { log.debug("trying remove key=" + key); } submitRedoRemove(key); if (remove...
[ "public", "synchronized", "boolean", "remove", "(", "final", "K", "key", ")", "{", "if", "(", "readOnly", ")", "{", "return", "false", ";", "}", "if", "(", "!", "validState", ")", "{", "throw", "new", "InvalidStateException", "(", ")", ";", "}", "if", ...
Remove a key from key @param key to delete @return true if key was removed, false if not
[ "Remove", "a", "key", "from", "key" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L786-L836
106,591
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.toStringIterative
private String toStringIterative() { final String PADDING = " "; final StringBuilder sb = new StringBuilder(); int elements_debug_local_recounter = 0; Node<K, V> node = null; int nodeid = rootIdx; int depth = 0; stackSlots.clear(); stackSlots.push(rootIdx); // init seed, ...
java
private String toStringIterative() { final String PADDING = " "; final StringBuilder sb = new StringBuilder(); int elements_debug_local_recounter = 0; Node<K, V> node = null; int nodeid = rootIdx; int depth = 0; stackSlots.clear(); stackSlots.push(rootIdx); // init seed, ...
[ "private", "String", "toStringIterative", "(", ")", "{", "final", "String", "PADDING", "=", "\" \"", ";", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "elements_debug_local_recounter", "=", "0", "...
A iterative algorithm for converting this tree into a string @return String representing human readable tree
[ "A", "iterative", "algorithm", "for", "converting", "this", "tree", "into", "a", "string" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L1097-L1133
106,592
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.toStringRecursive
@SuppressWarnings("unused") private String toStringRecursive() { final StringBuilder sb = new StringBuilder(); int elements_debug_local_recounter = toString(rootIdx, sb, 0); sb.append("height=").append(getHeight()).append(" root=").append(rootIdx).append(" low=") .append(lowIdx).append(" high=").append(highI...
java
@SuppressWarnings("unused") private String toStringRecursive() { final StringBuilder sb = new StringBuilder(); int elements_debug_local_recounter = toString(rootIdx, sb, 0); sb.append("height=").append(getHeight()).append(" root=").append(rootIdx).append(" low=") .append(lowIdx).append(" high=").append(highI...
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "private", "String", "toStringRecursive", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "elements_debug_local_recounter", "=", "toString", "(", "rootIdx", ",", "...
A recursive algorithm for converting this tree into a string @return String representing human readable tree
[ "A", "recursive", "algorithm", "for", "converting", "this", "tree", "into", "a", "string" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L1140-L1148
106,593
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java
BplusTree.iterator
public Iterator<BplusTree.TreeEntry<K, V>> iterator() { return new TreeIterator<BplusTree.TreeEntry<K, V>>(this); }
java
public Iterator<BplusTree.TreeEntry<K, V>> iterator() { return new TreeIterator<BplusTree.TreeEntry<K, V>>(this); }
[ "public", "Iterator", "<", "BplusTree", ".", "TreeEntry", "<", "K", ",", "V", ">", ">", "iterator", "(", ")", "{", "return", "new", "TreeIterator", "<", "BplusTree", ".", "TreeEntry", "<", "K", ",", "V", ">", ">", "(", "this", ")", ";", "}" ]
Note that the iterator cannot be guaranteed to be thread-safe as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification. @returns iterator over values in map
[ "Note", "that", "the", "iterator", "cannot", "be", "guaranteed", "to", "be", "thread", "-", "safe", "as", "it", "is", "generally", "speaking", "impossible", "to", "make", "any", "hard", "guarantees", "in", "the", "presence", "of", "unsynchronized", "concurrent...
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTree.java#L1197-L1199
106,594
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/LeafNode.java
LeafNode.prevNode
public LeafNode<K, V> prevNode() { if (leftid == NULL_ID) { return null; } return (LeafNode<K, V>) tree.getNode(leftid); }
java
public LeafNode<K, V> prevNode() { if (leftid == NULL_ID) { return null; } return (LeafNode<K, V>) tree.getNode(leftid); }
[ "public", "LeafNode", "<", "K", ",", "V", ">", "prevNode", "(", ")", "{", "if", "(", "leftid", "==", "NULL_ID", ")", "{", "return", "null", ";", "}", "return", "(", "LeafNode", "<", "K", ",", "V", ">", ")", "tree", ".", "getNode", "(", "leftid", ...
Return the previous LeafNode in LinkedList @return LeafNode<K, V> previous node
[ "Return", "the", "previous", "LeafNode", "in", "LinkedList" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/LeafNode.java#L175-L180
106,595
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/LeafNode.java
LeafNode.nextNode
public LeafNode<K, V> nextNode() { if (rightid == NULL_ID) { return null; } return (LeafNode<K, V>) tree.getNode(rightid); }
java
public LeafNode<K, V> nextNode() { if (rightid == NULL_ID) { return null; } return (LeafNode<K, V>) tree.getNode(rightid); }
[ "public", "LeafNode", "<", "K", ",", "V", ">", "nextNode", "(", ")", "{", "if", "(", "rightid", "==", "NULL_ID", ")", "{", "return", "null", ";", "}", "return", "(", "LeafNode", "<", "K", ",", "V", ">", ")", "tree", ".", "getNode", "(", "rightid"...
Return the next LeafNode in LinkedList @return LeafNode<K, V> next node
[ "Return", "the", "next", "LeafNode", "in", "LinkedList" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/LeafNode.java#L187-L192
106,596
ggrandes/kvstore
src/main/java/org/javastack/kvstore/io/FileStreamStore.java
FileStreamStore.isValid
public synchronized boolean isValid() { if (!validState) { throw new InvalidStateException(); } final long size = size(); if (size == 0) { return true; } try { final long offset = (size - FOOTER_LEN); if (offset < 0) { return false; } if (offset >= offsetOutputCommited) { if (bufOu...
java
public synchronized boolean isValid() { if (!validState) { throw new InvalidStateException(); } final long size = size(); if (size == 0) { return true; } try { final long offset = (size - FOOTER_LEN); if (offset < 0) { return false; } if (offset >= offsetOutputCommited) { if (bufOu...
[ "public", "synchronized", "boolean", "isValid", "(", ")", "{", "if", "(", "!", "validState", ")", "{", "throw", "new", "InvalidStateException", "(", ")", ";", "}", "final", "long", "size", "=", "size", "(", ")", ";", "if", "(", "size", "==", "0", ")"...
Read end of valid and check last magic footer @return true if valid
[ "Read", "end", "of", "valid", "and", "check", "last", "magic", "footer" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileStreamStore.java#L249-L286
106,597
ggrandes/kvstore
src/main/java/org/javastack/kvstore/io/FileStreamStore.java
FileStreamStore.readFromEnd
public synchronized long readFromEnd(final long datalen, final ByteBuffer buf) { if (!validState) { throw new InvalidStateException(); } final long size = size(); final long offset = (size - HEADER_LEN - datalen - FOOTER_LEN); return read(offset, buf); }
java
public synchronized long readFromEnd(final long datalen, final ByteBuffer buf) { if (!validState) { throw new InvalidStateException(); } final long size = size(); final long offset = (size - HEADER_LEN - datalen - FOOTER_LEN); return read(offset, buf); }
[ "public", "synchronized", "long", "readFromEnd", "(", "final", "long", "datalen", ",", "final", "ByteBuffer", "buf", ")", "{", "if", "(", "!", "validState", ")", "{", "throw", "new", "InvalidStateException", "(", ")", ";", "}", "final", "long", "size", "="...
Read desired block of datalen from end of file @param datalen expected @param ByteBuffer @return new offset (offset+headerlen+datalen+footer)
[ "Read", "desired", "block", "of", "datalen", "from", "end", "of", "file" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileStreamStore.java#L368-L375
106,598
ggrandes/kvstore
src/main/java/org/javastack/kvstore/io/FileStreamStore.java
FileStreamStore.alignBuffer
private final void alignBuffer(final int diff) throws IOException { if (bufOutput.remaining() < diff) { flushBuffer(); } bufOutput.put(MAGIC_PADDING); // Magic for Padding int i = 1; for (; i + 8 <= diff; i += 8) { bufOutput.putLong(0L); } for (; i + 4 <= diff; i += 4) { bufOutput.putInt(0); } ...
java
private final void alignBuffer(final int diff) throws IOException { if (bufOutput.remaining() < diff) { flushBuffer(); } bufOutput.put(MAGIC_PADDING); // Magic for Padding int i = 1; for (; i + 8 <= diff; i += 8) { bufOutput.putLong(0L); } for (; i + 4 <= diff; i += 4) { bufOutput.putInt(0); } ...
[ "private", "final", "void", "alignBuffer", "(", "final", "int", "diff", ")", "throws", "IOException", "{", "if", "(", "bufOutput", ".", "remaining", "(", ")", "<", "diff", ")", "{", "flushBuffer", "(", ")", ";", "}", "bufOutput", ".", "put", "(", "MAGI...
Pad output buffer with NULL to complete alignment @param diff bytes @throws IOException
[ "Pad", "output", "buffer", "with", "NULL", "to", "complete", "alignment" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileStreamStore.java#L547-L568
106,599
ggrandes/kvstore
src/main/java/org/javastack/kvstore/io/FileStreamStore.java
FileStreamStore.flush
public synchronized boolean flush() { if (!validState) { throw new InvalidStateException(); } try { flushBuffer(); return true; } catch (Exception e) { log.error("Exception in flush()", e); } return false; }
java
public synchronized boolean flush() { if (!validState) { throw new InvalidStateException(); } try { flushBuffer(); return true; } catch (Exception e) { log.error("Exception in flush()", e); } return false; }
[ "public", "synchronized", "boolean", "flush", "(", ")", "{", "if", "(", "!", "validState", ")", "{", "throw", "new", "InvalidStateException", "(", ")", ";", "}", "try", "{", "flushBuffer", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "Excep...
Flush buffer to file @return false if exception occur
[ "Flush", "buffer", "to", "file" ]
c79277f79f4604e0fec8349a98519838e3de38f0
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/io/FileStreamStore.java#L575-L586