repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
softindex/datakernel
boot/src/main/java/io/datakernel/service/ServiceAdapters.java
ServiceAdapters.forBlockingService
public static ServiceAdapter<BlockingService> forBlockingService() { return new SimpleServiceAdapter<BlockingService>() { @Override protected void start(BlockingService instance) throws Exception { instance.start(); } @Override protected void stop(BlockingService instance) throws Exception { i...
java
public static ServiceAdapter<BlockingService> forBlockingService() { return new SimpleServiceAdapter<BlockingService>() { @Override protected void start(BlockingService instance) throws Exception { instance.start(); } @Override protected void stop(BlockingService instance) throws Exception { i...
[ "public", "static", "ServiceAdapter", "<", "BlockingService", ">", "forBlockingService", "(", ")", "{", "return", "new", "SimpleServiceAdapter", "<", "BlockingService", ">", "(", ")", "{", "@", "Override", "protected", "void", "start", "(", "BlockingService", "ins...
Returns factory which transforms blocking Service to asynchronous non-blocking ConcurrentService. It runs blocking operations from other thread from executor.
[ "Returns", "factory", "which", "transforms", "blocking", "Service", "to", "asynchronous", "non", "-", "blocking", "ConcurrentService", ".", "It", "runs", "blocking", "operations", "from", "other", "thread", "from", "executor", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/service/ServiceAdapters.java#L204-L216
train
softindex/datakernel
boot/src/main/java/io/datakernel/service/ServiceAdapters.java
ServiceAdapters.forTimer
public static ServiceAdapter<Timer> forTimer() { return new SimpleServiceAdapter<Timer>(false, false) { @Override protected void start(Timer instance) { } @Override protected void stop(Timer instance) { instance.cancel(); } }; }
java
public static ServiceAdapter<Timer> forTimer() { return new SimpleServiceAdapter<Timer>(false, false) { @Override protected void start(Timer instance) { } @Override protected void stop(Timer instance) { instance.cancel(); } }; }
[ "public", "static", "ServiceAdapter", "<", "Timer", ">", "forTimer", "(", ")", "{", "return", "new", "SimpleServiceAdapter", "<", "Timer", ">", "(", "false", ",", "false", ")", "{", "@", "Override", "protected", "void", "start", "(", "Timer", "instance", "...
Returns factory which transforms Timer to ConcurrentService. On starting it doing nothing, on stop it cancel timer.
[ "Returns", "factory", "which", "transforms", "Timer", "to", "ConcurrentService", ".", "On", "starting", "it", "doing", "nothing", "on", "stop", "it", "cancel", "timer", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/service/ServiceAdapters.java#L235-L246
train
softindex/datakernel
boot/src/main/java/io/datakernel/service/ServiceAdapters.java
ServiceAdapters.forExecutorService
public static ServiceAdapter<ExecutorService> forExecutorService() { return new SimpleServiceAdapter<ExecutorService>(false, true) { @Override protected void start(ExecutorService instance) { } @Override protected void stop(ExecutorService instance) throws Exception { List<Runnable> runnables = in...
java
public static ServiceAdapter<ExecutorService> forExecutorService() { return new SimpleServiceAdapter<ExecutorService>(false, true) { @Override protected void start(ExecutorService instance) { } @Override protected void stop(ExecutorService instance) throws Exception { List<Runnable> runnables = in...
[ "public", "static", "ServiceAdapter", "<", "ExecutorService", ">", "forExecutorService", "(", ")", "{", "return", "new", "SimpleServiceAdapter", "<", "ExecutorService", ">", "(", "false", ",", "true", ")", "{", "@", "Override", "protected", "void", "start", "(",...
Returns factory which transforms ExecutorService to ConcurrentService. On starting it doing nothing, on stopping it shuts down ExecutorService.
[ "Returns", "factory", "which", "transforms", "ExecutorService", "to", "ConcurrentService", ".", "On", "starting", "it", "doing", "nothing", "on", "stopping", "it", "shuts", "down", "ExecutorService", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/service/ServiceAdapters.java#L251-L269
train
softindex/datakernel
boot/src/main/java/io/datakernel/service/ServiceAdapters.java
ServiceAdapters.forCloseable
public static ServiceAdapter<Closeable> forCloseable() { return new SimpleServiceAdapter<Closeable>(false, true) { @Override protected void start(Closeable instance) { } @Override protected void stop(Closeable instance) throws Exception { instance.close(); } }; }
java
public static ServiceAdapter<Closeable> forCloseable() { return new SimpleServiceAdapter<Closeable>(false, true) { @Override protected void start(Closeable instance) { } @Override protected void stop(Closeable instance) throws Exception { instance.close(); } }; }
[ "public", "static", "ServiceAdapter", "<", "Closeable", ">", "forCloseable", "(", ")", "{", "return", "new", "SimpleServiceAdapter", "<", "Closeable", ">", "(", "false", ",", "true", ")", "{", "@", "Override", "protected", "void", "start", "(", "Closeable", ...
Returns factory which transforms Closeable object to ConcurrentService. On starting it doing nothing, on stopping it close Closeable.
[ "Returns", "factory", "which", "transforms", "Closeable", "object", "to", "ConcurrentService", ".", "On", "starting", "it", "doing", "nothing", "on", "stopping", "it", "close", "Closeable", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/service/ServiceAdapters.java#L274-L285
train
softindex/datakernel
boot/src/main/java/io/datakernel/service/ServiceAdapters.java
ServiceAdapters.forDataSource
public static ServiceAdapter<DataSource> forDataSource() { return new SimpleServiceAdapter<DataSource>(true, false) { @Override protected void start(DataSource instance) throws Exception { Connection connection = instance.getConnection(); connection.close(); } @Override protected void stop(Dat...
java
public static ServiceAdapter<DataSource> forDataSource() { return new SimpleServiceAdapter<DataSource>(true, false) { @Override protected void start(DataSource instance) throws Exception { Connection connection = instance.getConnection(); connection.close(); } @Override protected void stop(Dat...
[ "public", "static", "ServiceAdapter", "<", "DataSource", ">", "forDataSource", "(", ")", "{", "return", "new", "SimpleServiceAdapter", "<", "DataSource", ">", "(", "true", ",", "false", ")", "{", "@", "Override", "protected", "void", "start", "(", "DataSource"...
Returns factory which transforms DataSource object to ConcurrentService. On starting it checks connecting , on stopping it close DataSource.
[ "Returns", "factory", "which", "transforms", "DataSource", "object", "to", "ConcurrentService", ".", "On", "starting", "it", "checks", "connecting", "on", "stopping", "it", "close", "DataSource", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/service/ServiceAdapters.java#L290-L302
train
softindex/datakernel
core-http/src/main/java/io/datakernel/http/HttpUtils.java
HttpUtils.renderQueryString
public static String renderQueryString(Map<String, String> q, String enc) { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> e : q.entrySet()) { String name = urlEncode(e.getKey(), enc); sb.append(name); if (e.getValue() != null) { sb.append('='); sb.append(urlEncode(e.getValu...
java
public static String renderQueryString(Map<String, String> q, String enc) { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> e : q.entrySet()) { String name = urlEncode(e.getKey(), enc); sb.append(name); if (e.getValue() != null) { sb.append('='); sb.append(urlEncode(e.getValu...
[ "public", "static", "String", "renderQueryString", "(", "Map", "<", "String", ",", "String", ">", "q", ",", "String", "enc", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",...
Method which creates string with parameters and its value in format URL @param q map in which keys if name of parameters, value - value of parameters. @param enc encoding of this string @return string with parameters and its value in format URL
[ "Method", "which", "creates", "string", "with", "parameters", "and", "its", "value", "in", "format", "URL" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpUtils.java#L190-L204
train
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java
ByteBufQueue.peekBuf
@Nullable @Contract(pure = true) public ByteBuf peekBuf() { return hasRemaining() ? bufs[first] : null; }
java
@Nullable @Contract(pure = true) public ByteBuf peekBuf() { return hasRemaining() ? bufs[first] : null; }
[ "@", "Nullable", "@", "Contract", "(", "pure", "=", "true", ")", "public", "ByteBuf", "peekBuf", "(", ")", "{", "return", "hasRemaining", "(", ")", "?", "bufs", "[", "first", "]", ":", "null", ";", "}" ]
Returns the first ByteBuf of this queue if the queue is not empty. Otherwise returns null. @return the first ByteBuf of the queue or {@code null}
[ "Returns", "the", "first", "ByteBuf", "of", "this", "queue", "if", "the", "queue", "is", "not", "empty", ".", "Otherwise", "returns", "null", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java#L346-L350
train
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java
ByteBufQueue.remainingBufs
@Contract(pure = true) public int remainingBufs() { return last >= first ? last - first : bufs.length + (last - first); }
java
@Contract(pure = true) public int remainingBufs() { return last >= first ? last - first : bufs.length + (last - first); }
[ "@", "Contract", "(", "pure", "=", "true", ")", "public", "int", "remainingBufs", "(", ")", "{", "return", "last", ">=", "first", "?", "last", "-", "first", ":", "bufs", ".", "length", "+", "(", "last", "-", "first", ")", ";", "}" ]
Returns the number of ByteBufs in this queue.
[ "Returns", "the", "number", "of", "ByteBufs", "in", "this", "queue", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java#L372-L375
train
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java
ByteBufQueue.remainingBytes
@Contract(pure = true) public int remainingBytes() { int result = 0; for (int i = first; i != last; i = next(i)) { result += bufs[i].readRemaining(); } return result; }
java
@Contract(pure = true) public int remainingBytes() { int result = 0; for (int i = first; i != last; i = next(i)) { result += bufs[i].readRemaining(); } return result; }
[ "@", "Contract", "(", "pure", "=", "true", ")", "public", "int", "remainingBytes", "(", ")", "{", "int", "result", "=", "0", ";", "for", "(", "int", "i", "=", "first", ";", "i", "!=", "last", ";", "i", "=", "next", "(", "i", ")", ")", "{", "r...
Returns the number of bytes in this queue.
[ "Returns", "the", "number", "of", "bytes", "in", "this", "queue", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java#L380-L387
train
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java
ByteBufQueue.peekByte
@Contract(pure = true) public byte peekByte() { assert hasRemaining(); ByteBuf buf = bufs[first]; return buf.peek(); }
java
@Contract(pure = true) public byte peekByte() { assert hasRemaining(); ByteBuf buf = bufs[first]; return buf.peek(); }
[ "@", "Contract", "(", "pure", "=", "true", ")", "public", "byte", "peekByte", "(", ")", "{", "assert", "hasRemaining", "(", ")", ";", "ByteBuf", "buf", "=", "bufs", "[", "first", "]", ";", "return", "buf", ".", "peek", "(", ")", ";", "}" ]
Returns the first byte from this queue without any recycling. @see #getByte().
[ "Returns", "the", "first", "byte", "from", "this", "queue", "without", "any", "recycling", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufQueue.java#L444-L449
train
softindex/datakernel
core-http/src/main/java/io/datakernel/http/HttpServerConnection.java
HttpServerConnection.onStartLine
@SuppressWarnings("PointlessArithmeticExpression") @Override protected void onStartLine(byte[] line, int limit) throws ParseException { switchPool(server.poolReadWrite); HttpMethod method = getHttpMethod(line); if (method == null) { throw new UnknownFormatException(HttpServerConnection.class, "Unknown ...
java
@SuppressWarnings("PointlessArithmeticExpression") @Override protected void onStartLine(byte[] line, int limit) throws ParseException { switchPool(server.poolReadWrite); HttpMethod method = getHttpMethod(line); if (method == null) { throw new UnknownFormatException(HttpServerConnection.class, "Unknown ...
[ "@", "SuppressWarnings", "(", "\"PointlessArithmeticExpression\"", ")", "@", "Override", "protected", "void", "onStartLine", "(", "byte", "[", "]", "line", ",", "int", "limit", ")", "throws", "ParseException", "{", "switchPool", "(", "server", ".", "poolReadWrite"...
This method is called after received line of header. @param line received line of header.
[ "This", "method", "is", "called", "after", "received", "line", "of", "header", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpServerConnection.java#L114-L155
train
softindex/datakernel
core-http/src/main/java/io/datakernel/http/HttpServerConnection.java
HttpServerConnection.onHeader
@Override protected void onHeader(HttpHeader header, byte[] array, int off, int len) throws ParseException { if (header == HttpHeaders.EXPECT) { if (equalsLowerCaseAscii(EXPECT_100_CONTINUE, array, off, len)) { socket.write(ByteBuf.wrapForReading(EXPECT_RESPONSE_CONTINUE)); } } if (request.headers.size...
java
@Override protected void onHeader(HttpHeader header, byte[] array, int off, int len) throws ParseException { if (header == HttpHeaders.EXPECT) { if (equalsLowerCaseAscii(EXPECT_100_CONTINUE, array, off, len)) { socket.write(ByteBuf.wrapForReading(EXPECT_RESPONSE_CONTINUE)); } } if (request.headers.size...
[ "@", "Override", "protected", "void", "onHeader", "(", "HttpHeader", "header", ",", "byte", "[", "]", "array", ",", "int", "off", ",", "int", "len", ")", "throws", "ParseException", "{", "if", "(", "header", "==", "HttpHeaders", ".", "EXPECT", ")", "{", ...
This method is called after receiving header. It sets its value to request. @param header received header
[ "This", "method", "is", "called", "after", "receiving", "header", ".", "It", "sets", "its", "value", "to", "request", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpServerConnection.java#L201-L212
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/StreamMerger.java
StreamMerger.create
public static <K, T> StreamMerger<K, T> create(Function<T, K> keyFunction, Comparator<K> keyComparator, boolean distinct) { return new StreamMerger<>(keyFunction, keyComparator, distinct); }
java
public static <K, T> StreamMerger<K, T> create(Function<T, K> keyFunction, Comparator<K> keyComparator, boolean distinct) { return new StreamMerger<>(keyFunction, keyComparator, distinct); }
[ "public", "static", "<", "K", ",", "T", ">", "StreamMerger", "<", "K", ",", "T", ">", "create", "(", "Function", "<", "T", ",", "K", ">", "keyFunction", ",", "Comparator", "<", "K", ">", "keyComparator", ",", "boolean", "distinct", ")", "{", "return"...
Returns new instance of StreamMerger @param keyComparator comparator for compare keys @param keyFunction function for counting key @param distinct if it is true it means that in result will be not objects with same key @param <K> type of key for mapping @param <T> type of output data
[ "Returns", "new", "instance", "of", "StreamMerger" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/StreamMerger.java#L57-L61
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/StreamReducerSimple.java
StreamReducerSimple.create
public static <K, I, O, A> StreamReducerSimple<K, I, O, A> create(Function<I, K> keyFunction, Comparator<K> keyComparator, Reducer<K, I, O, A> reducer) { return new StreamReducerSimple<>(keyFunction, keyComparator, reducer); }
java
public static <K, I, O, A> StreamReducerSimple<K, I, O, A> create(Function<I, K> keyFunction, Comparator<K> keyComparator, Reducer<K, I, O, A> reducer) { return new StreamReducerSimple<>(keyFunction, keyComparator, reducer); }
[ "public", "static", "<", "K", ",", "I", ",", "O", ",", "A", ">", "StreamReducerSimple", "<", "K", ",", "I", ",", "O", ",", "A", ">", "create", "(", "Function", "<", "I", ",", "K", ">", "keyFunction", ",", "Comparator", "<", "K", ">", "keyComparat...
Creates a new instance of StreamReducerSimple @param keyComparator comparator for compare keys @param keyFunction function for counting key
[ "Creates", "a", "new", "instance", "of", "StreamReducerSimple" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/StreamReducerSimple.java#L54-L58
train
softindex/datakernel
cloud-lsmt-aggregation/src/main/java/io/datakernel/aggregation/Aggregation.java
Aggregation.create
public static Aggregation create(Eventloop eventloop, Executor executor, DefiningClassLoader classLoader, AggregationChunkStorage aggregationChunkStorage, AggregationStructure structure) { checkArgument(structure != null, "Cannot create Aggregation with AggregationStructure that is null"); return new Aggregation...
java
public static Aggregation create(Eventloop eventloop, Executor executor, DefiningClassLoader classLoader, AggregationChunkStorage aggregationChunkStorage, AggregationStructure structure) { checkArgument(structure != null, "Cannot create Aggregation with AggregationStructure that is null"); return new Aggregation...
[ "public", "static", "Aggregation", "create", "(", "Eventloop", "eventloop", ",", "Executor", "executor", ",", "DefiningClassLoader", "classLoader", ",", "AggregationChunkStorage", "aggregationChunkStorage", ",", "AggregationStructure", "structure", ")", "{", "checkArgument"...
Instantiates an aggregation with the specified structure, that runs in a given event loop, uses the specified class loader for creating dynamic classes, saves data and metadata to given storages. Maximum size of chunk is 1,000,000 bytes. No more than 1,000,000 records stay in memory while sorting. Maximum duration of c...
[ "Instantiates", "an", "aggregation", "with", "the", "specified", "structure", "that", "runs", "in", "a", "given", "event", "loop", "uses", "the", "specified", "class", "loader", "for", "creating", "dynamic", "classes", "saves", "data", "and", "metadata", "to", ...
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-lsmt-aggregation/src/main/java/io/datakernel/aggregation/Aggregation.java#L127-L131
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/StreamReducer.java
StreamReducer.create
public static <K, O, A> StreamReducer<K, O, A> create(Comparator<K> keyComparator) { return new StreamReducer<>(keyComparator); }
java
public static <K, O, A> StreamReducer<K, O, A> create(Comparator<K> keyComparator) { return new StreamReducer<>(keyComparator); }
[ "public", "static", "<", "K", ",", "O", ",", "A", ">", "StreamReducer", "<", "K", ",", "O", ",", "A", ">", "create", "(", "Comparator", "<", "K", ">", "keyComparator", ")", "{", "return", "new", "StreamReducer", "<>", "(", "keyComparator", ")", ";", ...
Creates a new instance of StreamReducer @param keyComparator comparator for compare keys
[ "Creates", "a", "new", "instance", "of", "StreamReducer" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/StreamReducer.java#L45-L47
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/StreamReducer.java
StreamReducer.newInput
@Override public <I> StreamConsumer<I> newInput(Function<I, K> keyFunction, Reducer<K, I, O, A> reducer) { return super.newInput(keyFunction, reducer); }
java
@Override public <I> StreamConsumer<I> newInput(Function<I, K> keyFunction, Reducer<K, I, O, A> reducer) { return super.newInput(keyFunction, reducer); }
[ "@", "Override", "public", "<", "I", ">", "StreamConsumer", "<", "I", ">", "newInput", "(", "Function", "<", "I", ",", "K", ">", "keyFunction", ",", "Reducer", "<", "K", ",", "I", ",", "O", ",", "A", ">", "reducer", ")", "{", "return", "super", "...
Creates a new input stream for this reducer @param keyFunction function for counting key @param reducer reducer witch will performs actions with its stream @param <I> type of input data @return new consumer
[ "Creates", "a", "new", "input", "stream", "for", "this", "reducer" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/StreamReducer.java#L63-L66
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/StreamJoin.java
StreamJoin.create
public static <K, L, R, V> StreamJoin<K, L, R, V> create(Comparator<K> keyComparator, Function<L, K> leftKeyFunction, Function<R, K> rightKeyFunction, Joiner<K, L, R, V> joiner) { return new StreamJoin<...
java
public static <K, L, R, V> StreamJoin<K, L, R, V> create(Comparator<K> keyComparator, Function<L, K> leftKeyFunction, Function<R, K> rightKeyFunction, Joiner<K, L, R, V> joiner) { return new StreamJoin<...
[ "public", "static", "<", "K", ",", "L", ",", "R", ",", "V", ">", "StreamJoin", "<", "K", ",", "L", ",", "R", ",", "V", ">", "create", "(", "Comparator", "<", "K", ">", "keyComparator", ",", "Function", "<", "L", ",", "K", ">", "leftKeyFunction", ...
Creates a new instance of StreamJoin @param keyComparator comparator for compare keys @param leftKeyFunction function for counting keys of left stream @param rightKeyFunction function for counting keys of right stream @param joiner joiner which will join streams
[ "Creates", "a", "new", "instance", "of", "StreamJoin" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/StreamJoin.java#L178-L182
train
softindex/datakernel
core-http/src/main/java/io/datakernel/dns/DnsProtocol.java
DnsProtocol.createDnsQueryPayload
public static ByteBuf createDnsQueryPayload(DnsTransaction transaction) { ByteBuf byteBuf = ByteBufPool.allocate(MAX_SIZE); byteBuf.writeShort(transaction.getId()); // standard query flags, 1 question and 0 of other stuff byteBuf.write(STANDARD_QUERY_HEADER); // query domain name byte componentSize = 0; ...
java
public static ByteBuf createDnsQueryPayload(DnsTransaction transaction) { ByteBuf byteBuf = ByteBufPool.allocate(MAX_SIZE); byteBuf.writeShort(transaction.getId()); // standard query flags, 1 question and 0 of other stuff byteBuf.write(STANDARD_QUERY_HEADER); // query domain name byte componentSize = 0; ...
[ "public", "static", "ByteBuf", "createDnsQueryPayload", "(", "DnsTransaction", "transaction", ")", "{", "ByteBuf", "byteBuf", "=", "ByteBufPool", ".", "allocate", "(", "MAX_SIZE", ")", ";", "byteBuf", ".", "writeShort", "(", "transaction", ".", "getId", "(", ")"...
Creates a bytebuf with a DNS query payload @param transaction DNS transaction to encode @return ByteBuf with DNS message payload data
[ "Creates", "a", "bytebuf", "with", "a", "DNS", "query", "payload" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/dns/DnsProtocol.java#L90-L121
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/BufferReader.java
BufferReader.read
@Override public int read() throws IOException { if (pos >= limit) return -1; try { int c = buf[pos] & 0xff; if (c < 0x80) { pos++; } else if (c < 0xE0) { c = (char) ((c & 0x1F) << 6 | buf[pos + 1] & 0x3F); pos += 2; } else { c = (char) ((c & 0x0F) << 12 | (buf[pos + 1] & 0x3F) << 6...
java
@Override public int read() throws IOException { if (pos >= limit) return -1; try { int c = buf[pos] & 0xff; if (c < 0x80) { pos++; } else if (c < 0xE0) { c = (char) ((c & 0x1F) << 6 | buf[pos + 1] & 0x3F); pos += 2; } else { c = (char) ((c & 0x0F) << 12 | (buf[pos + 1] & 0x3F) << 6...
[ "@", "Override", "public", "int", "read", "(", ")", "throws", "IOException", "{", "if", "(", "pos", ">=", "limit", ")", "return", "-", "1", ";", "try", "{", "int", "c", "=", "buf", "[", "pos", "]", "&", "0xff", ";", "if", "(", "c", "<", "0x80",...
Reads a single character @return the character read, as an integer @throws IOException if an I/O error occurs
[ "Reads", "a", "single", "character" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/BufferReader.java#L96-L118
train
softindex/datakernel
core-http/src/main/java/io/datakernel/http/stream/BufsConsumerGzipInflater.java
BufsConsumerGzipInflater.skipHeaders
private void skipHeaders(int flag) { // trying to skip optional gzip file members if any is present if ((flag & FEXTRA) != 0) { skipExtra(flag); } else if ((flag & FNAME) != 0) { skipTerminatorByte(flag, FNAME); } else if ((flag & FCOMMENT) != 0) { skipTerminatorByte(flag, FCOMMENT); } else if ((flag...
java
private void skipHeaders(int flag) { // trying to skip optional gzip file members if any is present if ((flag & FEXTRA) != 0) { skipExtra(flag); } else if ((flag & FNAME) != 0) { skipTerminatorByte(flag, FNAME); } else if ((flag & FCOMMENT) != 0) { skipTerminatorByte(flag, FCOMMENT); } else if ((flag...
[ "private", "void", "skipHeaders", "(", "int", "flag", ")", "{", "// trying to skip optional gzip file members if any is present", "if", "(", "(", "flag", "&", "FEXTRA", ")", "!=", "0", ")", "{", "skipExtra", "(", "flag", ")", ";", "}", "else", "if", "(", "("...
region skip header fields
[ "region", "skip", "header", "fields" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/stream/BufsConsumerGzipInflater.java#L223-L234
train
softindex/datakernel
cloud-fs/src/main/java/io/datakernel/remotefs/RemoteFsClusterClient.java
RemoteFsClusterClient.withPartition
public RemoteFsClusterClient withPartition(Object id, FsClient client) { clients.put(id, client); aliveClients.put(id, client); return this; }
java
public RemoteFsClusterClient withPartition(Object id, FsClient client) { clients.put(id, client); aliveClients.put(id, client); return this; }
[ "public", "RemoteFsClusterClient", "withPartition", "(", "Object", "id", ",", "FsClient", "client", ")", "{", "clients", ".", "put", "(", "id", ",", "client", ")", ";", "aliveClients", ".", "put", "(", "id", ",", "client", ")", ";", "return", "this", ";"...
Adds given client with given partition id to this cluster
[ "Adds", "given", "client", "with", "given", "partition", "id", "to", "this", "cluster" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-fs/src/main/java/io/datakernel/remotefs/RemoteFsClusterClient.java#L98-L102
train
softindex/datakernel
cloud-fs/src/main/java/io/datakernel/remotefs/RemoteFsClusterClient.java
RemoteFsClusterClient.withReplicationCount
public RemoteFsClusterClient withReplicationCount(int replicationCount) { checkArgument(1 <= replicationCount && replicationCount <= clients.size(), "Replication count cannot be less than one or more than number of clients"); this.replicationCount = replicationCount; return this; }
java
public RemoteFsClusterClient withReplicationCount(int replicationCount) { checkArgument(1 <= replicationCount && replicationCount <= clients.size(), "Replication count cannot be less than one or more than number of clients"); this.replicationCount = replicationCount; return this; }
[ "public", "RemoteFsClusterClient", "withReplicationCount", "(", "int", "replicationCount", ")", "{", "checkArgument", "(", "1", "<=", "replicationCount", "&&", "replicationCount", "<=", "clients", ".", "size", "(", ")", ",", "\"Replication count cannot be less than one or...
Sets the replication count that determines how many copies of the file should persist over the cluster.
[ "Sets", "the", "replication", "count", "that", "determines", "how", "many", "copies", "of", "the", "file", "should", "persist", "over", "the", "cluster", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-fs/src/main/java/io/datakernel/remotefs/RemoteFsClusterClient.java#L107-L111
train
softindex/datakernel
cloud-fs/src/main/java/io/datakernel/remotefs/RemoteFsClusterClient.java
RemoteFsClusterClient.ofFailure
private static <T, U> Promise<T> ofFailure(String message, List<Try<U>> failed) { StacklessException exception = new StacklessException(RemoteFsClusterClient.class, message); failed.stream() .map(Try::getExceptionOrNull) .filter(Objects::nonNull) .forEach(exception::addSuppressed); return Promise.ofEx...
java
private static <T, U> Promise<T> ofFailure(String message, List<Try<U>> failed) { StacklessException exception = new StacklessException(RemoteFsClusterClient.class, message); failed.stream() .map(Try::getExceptionOrNull) .filter(Objects::nonNull) .forEach(exception::addSuppressed); return Promise.ofEx...
[ "private", "static", "<", "T", ",", "U", ">", "Promise", "<", "T", ">", "ofFailure", "(", "String", "message", ",", "List", "<", "Try", "<", "U", ">", ">", "failed", ")", "{", "StacklessException", "exception", "=", "new", "StacklessException", "(", "R...
shortcut for creating single Exception from list of possibly failed tries
[ "shortcut", "for", "creating", "single", "Exception", "from", "list", "of", "possibly", "failed", "tries" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-fs/src/main/java/io/datakernel/remotefs/RemoteFsClusterClient.java#L239-L246
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.cast
public static Expression cast(Expression expression, Class<?> type) { return cast(expression, getType(type)); }
java
public static Expression cast(Expression expression, Class<?> type) { return cast(expression, getType(type)); }
[ "public", "static", "Expression", "cast", "(", "Expression", "expression", ",", "Class", "<", "?", ">", "type", ")", "{", "return", "cast", "(", "expression", ",", "getType", "(", "type", ")", ")", ";", "}" ]
Casts expression to the type @param expression expressions which will be casted @param type expression will be casted to the 'type' @return new instance of the Expression which is casted to the type
[ "Casts", "expression", "to", "the", "type" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L99-L101
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.cmpEq
public static PredicateDef cmpEq(Expression left, Expression right) { return cmp(CompareOperation.EQ, left, right); }
java
public static PredicateDef cmpEq(Expression left, Expression right) { return cmp(CompareOperation.EQ, left, right); }
[ "public", "static", "PredicateDef", "cmpEq", "(", "Expression", "left", ",", "Expression", "right", ")", "{", "return", "cmp", "(", "CompareOperation", ".", "EQ", ",", "left", ",", "right", ")", ";", "}" ]
Verifies that the arguments are equal @param left first argument which will be compared @param right second argument which will be compared @return new instance of the PredicateDefCmp
[ "Verifies", "that", "the", "arguments", "are", "equal" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L191-L193
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.asEquals
public static Expression asEquals(List<String> properties) { PredicateDefAnd predicate = PredicateDefAnd.create(); for (String property : properties) { predicate.add(cmpEq( property(self(), property), property(cast(arg(0), ExpressionCast.THIS_TYPE), property))); } return predicate; }
java
public static Expression asEquals(List<String> properties) { PredicateDefAnd predicate = PredicateDefAnd.create(); for (String property : properties) { predicate.add(cmpEq( property(self(), property), property(cast(arg(0), ExpressionCast.THIS_TYPE), property))); } return predicate; }
[ "public", "static", "Expression", "asEquals", "(", "List", "<", "String", ">", "properties", ")", "{", "PredicateDefAnd", "predicate", "=", "PredicateDefAnd", ".", "create", "(", ")", ";", "for", "(", "String", "property", ":", "properties", ")", "{", "predi...
Verifies that the properties are equal @param properties list of the properties @return new instance of the Expression
[ "Verifies", "that", "the", "properties", "are", "equal" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L261-L269
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.asString
public static Expression asString(List<String> properties) { ExpressionToString toString = new ExpressionToString(); for (String property : properties) { toString.withArgument(property + "=", property(self(), property)); } return toString; }
java
public static Expression asString(List<String> properties) { ExpressionToString toString = new ExpressionToString(); for (String property : properties) { toString.withArgument(property + "=", property(self(), property)); } return toString; }
[ "public", "static", "Expression", "asString", "(", "List", "<", "String", ">", "properties", ")", "{", "ExpressionToString", "toString", "=", "new", "ExpressionToString", "(", ")", ";", "for", "(", "String", "property", ":", "properties", ")", "{", "toString",...
Returns the string which was constructed from properties @param properties list of the properties @return new instance of the ExpressionToString
[ "Returns", "the", "string", "which", "was", "constructed", "from", "properties" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L277-L283
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.hashCodeOfThis
public static ExpressionHash hashCodeOfThis(List<String> properties) { List<Expression> arguments = new ArrayList<>(); for (String property : properties) { arguments.add(property(new VarThis(), property)); } return new ExpressionHash(arguments); }
java
public static ExpressionHash hashCodeOfThis(List<String> properties) { List<Expression> arguments = new ArrayList<>(); for (String property : properties) { arguments.add(property(new VarThis(), property)); } return new ExpressionHash(arguments); }
[ "public", "static", "ExpressionHash", "hashCodeOfThis", "(", "List", "<", "String", ">", "properties", ")", "{", "List", "<", "Expression", ">", "arguments", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "property", ":", "properties", ...
Returns hash of the properties @param properties list of the properties which will be hashed @return new instance of the ExpressionHash
[ "Returns", "hash", "of", "the", "properties" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L371-L377
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.add
public static ExpressionArithmeticOp add(Expression left, Expression right) { return new ExpressionArithmeticOp(ArithmeticOperation.ADD, left, right); }
java
public static ExpressionArithmeticOp add(Expression left, Expression right) { return new ExpressionArithmeticOp(ArithmeticOperation.ADD, left, right); }
[ "public", "static", "ExpressionArithmeticOp", "add", "(", "Expression", "left", ",", "Expression", "right", ")", "{", "return", "new", "ExpressionArithmeticOp", "(", "ArithmeticOperation", ".", "ADD", ",", "left", ",", "right", ")", ";", "}" ]
Returns sum of arguments @param left first argument which will be added @param right second argument which will be added @return new instance of the ExpressionArithmeticOp
[ "Returns", "sum", "of", "arguments" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L426-L428
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.constructor
public static ExpressionConstructor constructor(Class<?> type, Expression... fields) { return new ExpressionConstructor(type, asList(fields)); }
java
public static ExpressionConstructor constructor(Class<?> type, Expression... fields) { return new ExpressionConstructor(type, asList(fields)); }
[ "public", "static", "ExpressionConstructor", "constructor", "(", "Class", "<", "?", ">", "type", ",", "Expression", "...", "fields", ")", "{", "return", "new", "ExpressionConstructor", "(", "type", ",", "asList", "(", "fields", ")", ")", ";", "}" ]
Returns new instance of class @param type type of the constructor @param fields fields for constructor @return new instance of the ExpressionConstructor
[ "Returns", "new", "instance", "of", "class" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L461-L463
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/Expressions.java
Expressions.newLocal
public static VarLocal newLocal(Context ctx, Type type) { int local = ctx.getGeneratorAdapter().newLocal(type); return new VarLocal(local); }
java
public static VarLocal newLocal(Context ctx, Type type) { int local = ctx.getGeneratorAdapter().newLocal(type); return new VarLocal(local); }
[ "public", "static", "VarLocal", "newLocal", "(", "Context", "ctx", ",", "Type", "type", ")", "{", "int", "local", "=", "ctx", ".", "getGeneratorAdapter", "(", ")", ".", "newLocal", "(", "type", ")", ";", "return", "new", "VarLocal", "(", "local", ")", ...
Returns a new local variable from a given context @param ctx context of a dynamic class @param type the type of the local variable to be created @return new instance of {@link VarLocal}
[ "Returns", "a", "new", "local", "variable", "from", "a", "given", "context" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/Expressions.java#L507-L510
train
softindex/datakernel
core-http/src/main/java/io/datakernel/dns/DnsCache.java
DnsCache.tryToResolve
@Nullable public DnsQueryCacheResult tryToResolve(DnsQuery query) { CachedDnsQueryResult cachedResult = cache.get(query); if (cachedResult == null) { logger.trace("{} cache miss", query); return null; } DnsResponse result = cachedResult.response; assert result != null; // results with null responses ...
java
@Nullable public DnsQueryCacheResult tryToResolve(DnsQuery query) { CachedDnsQueryResult cachedResult = cache.get(query); if (cachedResult == null) { logger.trace("{} cache miss", query); return null; } DnsResponse result = cachedResult.response; assert result != null; // results with null responses ...
[ "@", "Nullable", "public", "DnsQueryCacheResult", "tryToResolve", "(", "DnsQuery", "query", ")", "{", "CachedDnsQueryResult", "cachedResult", "=", "cache", ".", "get", "(", "query", ")", ";", "if", "(", "cachedResult", "==", "null", ")", "{", "logger", ".", ...
Tries to get status of the entry for some query from the cache. @param query DNS query @return DnsQueryCacheResult for this query
[ "Tries", "to", "get", "status", "of", "the", "entry", "for", "some", "query", "from", "the", "cache", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/dns/DnsCache.java#L105-L130
train
softindex/datakernel
core-http/src/main/java/io/datakernel/dns/DnsCache.java
DnsCache.add
public void add(DnsQuery query, DnsResponse response) { assert eventloop.inEventloopThread() : "Concurrent cache adds are not allowed"; long expirationTime = now.currentTimeMillis(); if (response.isSuccessful()) { assert response.getRecord() != null; // where are my advanced contracts so that Intellj would kno...
java
public void add(DnsQuery query, DnsResponse response) { assert eventloop.inEventloopThread() : "Concurrent cache adds are not allowed"; long expirationTime = now.currentTimeMillis(); if (response.isSuccessful()) { assert response.getRecord() != null; // where are my advanced contracts so that Intellj would kno...
[ "public", "void", "add", "(", "DnsQuery", "query", ",", "DnsResponse", "response", ")", "{", "assert", "eventloop", ".", "inEventloopThread", "(", ")", ":", "\"Concurrent cache adds are not allowed\"", ";", "long", "expirationTime", "=", "now", ".", "currentTimeMill...
Adds DnsResponse to this cache @param response response to add
[ "Adds", "DnsResponse", "to", "this", "cache" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/dns/DnsCache.java#L145-L170
train
softindex/datakernel
cloud-dataflow/src/main/java/io/datakernel/dataflow/server/DatagraphEnvironment.java
DatagraphEnvironment.with
@SuppressWarnings("unchecked") public DatagraphEnvironment with(Object key, Object value) { ((Map<Object, Object>) instances).put(key, value); return this; }
java
@SuppressWarnings("unchecked") public DatagraphEnvironment with(Object key, Object value) { ((Map<Object, Object>) instances).put(key, value); return this; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "DatagraphEnvironment", "with", "(", "Object", "key", ",", "Object", "value", ")", "{", "(", "(", "Map", "<", "Object", ",", "Object", ">", ")", "instances", ")", ".", "put", "(", "key", ",", ...
Sets the given value for the specified key. @param key key @param value value @return this environment
[ "Sets", "the", "given", "value", "for", "the", "specified", "key", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-dataflow/src/main/java/io/datakernel/dataflow/server/DatagraphEnvironment.java#L66-L70
train
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufStrings.java
ByteBufStrings.encodeUtf8
public static int encodeUtf8(byte[] array, int pos, String string) { int p = pos; for (int i = 0; i < string.length(); i++) { p += encodeUtf8(array, p, string.charAt(i)); } return p - pos; }
java
public static int encodeUtf8(byte[] array, int pos, String string) { int p = pos; for (int i = 0; i < string.length(); i++) { p += encodeUtf8(array, p, string.charAt(i)); } return p - pos; }
[ "public", "static", "int", "encodeUtf8", "(", "byte", "[", "]", "array", ",", "int", "pos", ",", "String", "string", ")", "{", "int", "p", "=", "pos", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "string", ".", "length", "(", ")", ";",...
UTF-8
[ "UTF", "-", "8" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufStrings.java#L214-L220
train
softindex/datakernel
core-eventloop/src/main/java/io/datakernel/util/ReflectionUtils.java
ReflectionUtils.fetchAnnotationElementValue
public static Object fetchAnnotationElementValue(Annotation annotation, Method element) throws ReflectiveOperationException { Object value = element.invoke(annotation); if (value == null) { String errorMsg = "@" + annotation.annotationType().getName() + "." + element.getName() + "() returned null"; throw...
java
public static Object fetchAnnotationElementValue(Annotation annotation, Method element) throws ReflectiveOperationException { Object value = element.invoke(annotation); if (value == null) { String errorMsg = "@" + annotation.annotationType().getName() + "." + element.getName() + "() returned null"; throw...
[ "public", "static", "Object", "fetchAnnotationElementValue", "(", "Annotation", "annotation", ",", "Method", "element", ")", "throws", "ReflectiveOperationException", "{", "Object", "value", "=", "element", ".", "invoke", "(", "annotation", ")", ";", "if", "(", "v...
Returns values if it is not null, otherwise throws exception
[ "Returns", "values", "if", "it", "is", "not", "null", "otherwise", "throws", "exception" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-eventloop/src/main/java/io/datakernel/util/ReflectionUtils.java#L387-L395
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java
ClassBuilder.withField
public ClassBuilder<T> withField(String field, Class<?> fieldClass) { fields.put(field, fieldClass); return this; }
java
public ClassBuilder<T> withField(String field, Class<?> fieldClass) { fields.put(field, fieldClass); return this; }
[ "public", "ClassBuilder", "<", "T", ">", "withField", "(", "String", "field", ",", "Class", "<", "?", ">", "fieldClass", ")", "{", "fields", ".", "put", "(", "field", ",", "fieldClass", ")", ";", "return", "this", ";", "}" ]
Creates a new field for a dynamic class @param field name of field @param fieldClass type of field @return changed AsmFunctionFactory
[ "Creates", "a", "new", "field", "for", "a", "dynamic", "class" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java#L161-L164
train
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java
ClassBuilder.withMethod
public ClassBuilder<T> withMethod(String methodName, Expression expression) { if (methodName.contains("(")) { Method method = Method.getMethod(methodName); return withMethod(method, expression); } Method foundMethod = null; List<List<java.lang.reflect.Method>> listOfMethods = new ArrayList<>(); listOfM...
java
public ClassBuilder<T> withMethod(String methodName, Expression expression) { if (methodName.contains("(")) { Method method = Method.getMethod(methodName); return withMethod(method, expression); } Method foundMethod = null; List<List<java.lang.reflect.Method>> listOfMethods = new ArrayList<>(); listOfM...
[ "public", "ClassBuilder", "<", "T", ">", "withMethod", "(", "String", "methodName", ",", "Expression", "expression", ")", "{", "if", "(", "methodName", ".", "contains", "(", "\"(\"", ")", ")", "{", "Method", "method", "=", "Method", ".", "getMethod", "(", ...
CCreates a new method for a dynamic class @param methodName name of method @param expression function which will be processed @return changed AsmFunctionFactory
[ "CCreates", "a", "new", "method", "for", "a", "dynamic", "class" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java#L233-L260
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/AbstractStreamSupplier.java
AbstractStreamSupplier.setConsumer
@Override public final void setConsumer(StreamConsumer<T> consumer) { checkNotNull(consumer); checkState(this.consumer == null, "Consumer has already been set"); checkState(getCapabilities().contains(LATE_BINDING) || eventloop.tick() == createTick, LATE_BINDING_ERROR_MESSAGE, this); this.consumer = consum...
java
@Override public final void setConsumer(StreamConsumer<T> consumer) { checkNotNull(consumer); checkState(this.consumer == null, "Consumer has already been set"); checkState(getCapabilities().contains(LATE_BINDING) || eventloop.tick() == createTick, LATE_BINDING_ERROR_MESSAGE, this); this.consumer = consum...
[ "@", "Override", "public", "final", "void", "setConsumer", "(", "StreamConsumer", "<", "T", ">", "consumer", ")", "{", "checkNotNull", "(", "consumer", ")", ";", "checkState", "(", "this", ".", "consumer", "==", "null", ",", "\"Consumer has already been set\"", ...
Sets consumer for this supplier. At the moment of calling this method supplier shouldn't have consumer, as well as consumer shouldn't have supplier, otherwise there will be error @param consumer consumer for streaming
[ "Sets", "consumer", "for", "this", "supplier", ".", "At", "the", "moment", "of", "calling", "this", "method", "supplier", "shouldn", "t", "have", "consumer", "as", "well", "as", "consumer", "shouldn", "t", "have", "supplier", "otherwise", "there", "will", "b...
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/AbstractStreamSupplier.java#L79-L91
train
softindex/datakernel
cloud-dataflow/src/main/java/io/datakernel/dataflow/graph/DataGraph.java
DataGraph.execute
public void execute() { Map<Partition, List<Node>> map = getNodesByPartition(); for (Partition partition : map.keySet()) { List<Node> nodes = map.get(partition); partition.execute(nodes); } }
java
public void execute() { Map<Partition, List<Node>> map = getNodesByPartition(); for (Partition partition : map.keySet()) { List<Node> nodes = map.get(partition); partition.execute(nodes); } }
[ "public", "void", "execute", "(", ")", "{", "Map", "<", "Partition", ",", "List", "<", "Node", ">", ">", "map", "=", "getNodesByPartition", "(", ")", ";", "for", "(", "Partition", "partition", ":", "map", ".", "keySet", "(", ")", ")", "{", "List", ...
Executes the defined operations on all partitions.
[ "Executes", "the", "defined", "operations", "on", "all", "partitions", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-dataflow/src/main/java/io/datakernel/dataflow/graph/DataGraph.java#L69-L75
train
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.createFor
@Override public DynamicMBean createFor(List<?> monitorables, MBeanSettings setting, boolean enableRefresh) { checkNotNull(monitorables); checkArgument(monitorables.size() > 0, "Size of list of monitorables should be greater than 0"); checkArgument(monitorables.stream().noneMatch(Objects::isNull), "Monitorable c...
java
@Override public DynamicMBean createFor(List<?> monitorables, MBeanSettings setting, boolean enableRefresh) { checkNotNull(monitorables); checkArgument(monitorables.size() > 0, "Size of list of monitorables should be greater than 0"); checkArgument(monitorables.stream().noneMatch(Objects::isNull), "Monitorable c...
[ "@", "Override", "public", "DynamicMBean", "createFor", "(", "List", "<", "?", ">", "monitorables", ",", "MBeanSettings", "setting", ",", "boolean", "enableRefresh", ")", "{", "checkNotNull", "(", "monitorables", ")", ";", "checkArgument", "(", "monitorables", "...
Creates Jmx MBean for monitorables with operations and attributes.
[ "Creates", "Jmx", "MBean", "for", "monitorables", "with", "operations", "and", "attributes", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L113-L171
train
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.handleJmxRefreshables
private void handleJmxRefreshables(List<MBeanWrapper> mbeanWrappers, AttributeNodeForPojo rootNode) { for (MBeanWrapper mbeanWrapper : mbeanWrappers) { Eventloop eventloop = mbeanWrapper.getEventloop(); List<JmxRefreshable> currentRefreshables = rootNode.getAllRefreshables(mbeanWrapper.getMBean()); if (!even...
java
private void handleJmxRefreshables(List<MBeanWrapper> mbeanWrappers, AttributeNodeForPojo rootNode) { for (MBeanWrapper mbeanWrapper : mbeanWrappers) { Eventloop eventloop = mbeanWrapper.getEventloop(); List<JmxRefreshable> currentRefreshables = rootNode.getAllRefreshables(mbeanWrapper.getMBean()); if (!even...
[ "private", "void", "handleJmxRefreshables", "(", "List", "<", "MBeanWrapper", ">", "mbeanWrappers", ",", "AttributeNodeForPojo", "rootNode", ")", "{", "for", "(", "MBeanWrapper", "mbeanWrapper", ":", "mbeanWrappers", ")", "{", "Eventloop", "eventloop", "=", "mbeanWr...
region refreshing jmx
[ "region", "refreshing", "jmx" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L543-L559
train
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.createAttributesTree
private AttributeNodeForPojo createAttributesTree(Class<?> clazz, Map<Type, JmxCustomTypeAdapter<?>> customTypes) { List<AttributeNode> subNodes = createNodesFor(clazz, clazz, new String[0], null, customTypes); return new AttributeNodeForPojo("", null, true, new ValueFetcherDirect(), null, subNodes); }
java
private AttributeNodeForPojo createAttributesTree(Class<?> clazz, Map<Type, JmxCustomTypeAdapter<?>> customTypes) { List<AttributeNode> subNodes = createNodesFor(clazz, clazz, new String[0], null, customTypes); return new AttributeNodeForPojo("", null, true, new ValueFetcherDirect(), null, subNodes); }
[ "private", "AttributeNodeForPojo", "createAttributesTree", "(", "Class", "<", "?", ">", "clazz", ",", "Map", "<", "Type", ",", "JmxCustomTypeAdapter", "<", "?", ">", ">", "customTypes", ")", "{", "List", "<", "AttributeNode", ">", "subNodes", "=", "createNodes...
Creates attribute tree of Jmx attributes for clazz.
[ "Creates", "attribute", "tree", "of", "Jmx", "attributes", "for", "clazz", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L603-L606
train
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.createMBeanInfo
private static MBeanInfo createMBeanInfo(AttributeNodeForPojo rootNode, Class<?> monitorableClass) { String monitorableName = ""; String monitorableDescription = ""; MBeanAttributeInfo[] attributes = rootNode != null ? fetchAttributesInfo(rootNode) : new MBeanAttributeInfo[0]; MBeanOperationInfo[] opera...
java
private static MBeanInfo createMBeanInfo(AttributeNodeForPojo rootNode, Class<?> monitorableClass) { String monitorableName = ""; String monitorableDescription = ""; MBeanAttributeInfo[] attributes = rootNode != null ? fetchAttributesInfo(rootNode) : new MBeanAttributeInfo[0]; MBeanOperationInfo[] opera...
[ "private", "static", "MBeanInfo", "createMBeanInfo", "(", "AttributeNodeForPojo", "rootNode", ",", "Class", "<", "?", ">", "monitorableClass", ")", "{", "String", "monitorableName", "=", "\"\"", ";", "String", "monitorableDescription", "=", "\"\"", ";", "MBeanAttrib...
region creating jmx metadata - MBeanInfo
[ "region", "creating", "jmx", "metadata", "-", "MBeanInfo" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L610-L624
train
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.fetchOpkeyToMethod
private static Map<OperationKey, Method> fetchOpkeyToMethod(Class<?> mbeanClass) { Map<OperationKey, Method> opkeyToMethod = new HashMap<>(); Method[] methods = mbeanClass.getMethods(); for (Method method : methods) { if (method.isAnnotationPresent(JmxOperation.class)) { JmxOperation annotation = method.ge...
java
private static Map<OperationKey, Method> fetchOpkeyToMethod(Class<?> mbeanClass) { Map<OperationKey, Method> opkeyToMethod = new HashMap<>(); Method[] methods = mbeanClass.getMethods(); for (Method method : methods) { if (method.isAnnotationPresent(JmxOperation.class)) { JmxOperation annotation = method.ge...
[ "private", "static", "Map", "<", "OperationKey", ",", "Method", ">", "fetchOpkeyToMethod", "(", "Class", "<", "?", ">", "mbeanClass", ")", "{", "Map", "<", "OperationKey", ",", "Method", ">", "opkeyToMethod", "=", "new", "HashMap", "<>", "(", ")", ";", "...
region jmx operations fetching
[ "region", "jmx", "operations", "fetching" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L714-L737
train
softindex/datakernel
core-http/src/main/java/io/datakernel/http/HttpClientConnection.java
HttpClientConnection.send
public Promise<HttpResponse> send(HttpRequest request) { SettablePromise<HttpResponse> promise = new SettablePromise<>(); this.promise = promise; assert pool == null; (pool = client.poolReadWrite).addLastNode(this); poolTimestamp = eventloop.currentTimeMillis(); HttpHeaderValue connectionHeader = CONNECTION...
java
public Promise<HttpResponse> send(HttpRequest request) { SettablePromise<HttpResponse> promise = new SettablePromise<>(); this.promise = promise; assert pool == null; (pool = client.poolReadWrite).addLastNode(this); poolTimestamp = eventloop.currentTimeMillis(); HttpHeaderValue connectionHeader = CONNECTION...
[ "public", "Promise", "<", "HttpResponse", ">", "send", "(", "HttpRequest", "request", ")", "{", "SettablePromise", "<", "HttpResponse", ">", "promise", "=", "new", "SettablePromise", "<>", "(", ")", ";", "this", ".", "promise", "=", "promise", ";", "assert",...
Sends the request, recycles it and closes connection in case of timeout @param request request for sending
[ "Sends", "the", "request", "recycles", "it", "and", "closes", "connection", "in", "case", "of", "timeout" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpClientConnection.java#L232-L260
train
softindex/datakernel
core-http/src/main/java/io/datakernel/http/HttpClientConnection.java
HttpClientConnection.onClosed
@Override protected void onClosed() { assert promise == null; if (pool == client.poolKeepAlive) { AddressLinkedList addresses = client.addresses.get(remoteAddress); addresses.removeNode(this); if (addresses.isEmpty()) { client.addresses.remove(remoteAddress); } } // pool will be null if socket...
java
@Override protected void onClosed() { assert promise == null; if (pool == client.poolKeepAlive) { AddressLinkedList addresses = client.addresses.get(remoteAddress); addresses.removeNode(this); if (addresses.isEmpty()) { client.addresses.remove(remoteAddress); } } // pool will be null if socket...
[ "@", "Override", "protected", "void", "onClosed", "(", ")", "{", "assert", "promise", "==", "null", ";", "if", "(", "pool", "==", "client", ".", "poolKeepAlive", ")", "{", "AddressLinkedList", "addresses", "=", "client", ".", "addresses", ".", "get", "(", ...
After closing this connection it removes it from its connections cache and recycles Http response.
[ "After", "closing", "this", "connection", "it", "removes", "it", "from", "its", "connections", "cache", "and", "recycles", "Http", "response", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpClientConnection.java#L266-L287
train
softindex/datakernel
core-http/src/main/java/io/datakernel/http/AsyncHttpClient.java
AsyncHttpClient.request
@Override public Promise<HttpResponse> request(HttpRequest request) { assert eventloop.inEventloopThread(); if (inspector != null) inspector.onRequest(request); String host = request.getUrl().getHost(); assert host != null; return asyncDnsClient.resolve4(host) .thenEx((dnsResponse, e) -> { if (e =...
java
@Override public Promise<HttpResponse> request(HttpRequest request) { assert eventloop.inEventloopThread(); if (inspector != null) inspector.onRequest(request); String host = request.getUrl().getHost(); assert host != null; return asyncDnsClient.resolve4(host) .thenEx((dnsResponse, e) -> { if (e =...
[ "@", "Override", "public", "Promise", "<", "HttpResponse", ">", "request", "(", "HttpRequest", "request", ")", "{", "assert", "eventloop", ".", "inEventloopThread", "(", ")", ";", "if", "(", "inspector", "!=", "null", ")", "inspector", ".", "onRequest", "(",...
Sends the request to server, waits the result timeout and handles result with callback @param request request for server
[ "Sends", "the", "request", "to", "server", "waits", "the", "result", "timeout", "and", "handles", "result", "with", "callback" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/AsyncHttpClient.java#L333-L357
train
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufPool.java
ByteBufPool.clear
public static void clear() { for (int i = 0; i < ByteBufPool.NUMBER_OF_SLABS; i++) { slabs[i].clear(); created[i].set(0); reused[i].set(0); } synchronized (registry) { registry.clear(); } }
java
public static void clear() { for (int i = 0; i < ByteBufPool.NUMBER_OF_SLABS; i++) { slabs[i].clear(); created[i].set(0); reused[i].set(0); } synchronized (registry) { registry.clear(); } }
[ "public", "static", "void", "clear", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ByteBufPool", ".", "NUMBER_OF_SLABS", ";", "i", "++", ")", "{", "slabs", "[", "i", "]", ".", "clear", "(", ")", ";", "created", "[", "i", "]",...
Clears all of the slabs and stats.
[ "Clears", "all", "of", "the", "slabs", "and", "stats", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufPool.java#L330-L339
train
softindex/datakernel
core-eventloop/src/main/java/io/datakernel/eventloop/OptimizedSelectedKeysSet.java
OptimizedSelectedKeysSet.ensureCapacity
private void ensureCapacity() { if (size < selectionKeys.length) { return; } SelectionKey[] newArray = new SelectionKey[selectionKeys.length * 2]; System.arraycopy(selectionKeys, 0, newArray, 0, size); selectionKeys = newArray; }
java
private void ensureCapacity() { if (size < selectionKeys.length) { return; } SelectionKey[] newArray = new SelectionKey[selectionKeys.length * 2]; System.arraycopy(selectionKeys, 0, newArray, 0, size); selectionKeys = newArray; }
[ "private", "void", "ensureCapacity", "(", ")", "{", "if", "(", "size", "<", "selectionKeys", ".", "length", ")", "{", "return", ";", "}", "SelectionKey", "[", "]", "newArray", "=", "new", "SelectionKey", "[", "selectionKeys", ".", "length", "*", "2", "]"...
Multiply the size of array twice
[ "Multiply", "the", "size", "of", "array", "twice" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-eventloop/src/main/java/io/datakernel/eventloop/OptimizedSelectedKeysSet.java#L39-L46
train
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/StreamSorter.java
StreamSorter.create
public static <K, T> StreamSorter<K, T> create(StreamSorterStorage<T> storage, Function<T, K> keyFunction, Comparator<K> keyComparator, boolean distinct, int itemsInMemorySize) { return new StreamSorter<>(storage, keyFunction, keyComparator, distinct, itemsInMemorySize); }
java
public static <K, T> StreamSorter<K, T> create(StreamSorterStorage<T> storage, Function<T, K> keyFunction, Comparator<K> keyComparator, boolean distinct, int itemsInMemorySize) { return new StreamSorter<>(storage, keyFunction, keyComparator, distinct, itemsInMemorySize); }
[ "public", "static", "<", "K", ",", "T", ">", "StreamSorter", "<", "K", ",", "T", ">", "create", "(", "StreamSorterStorage", "<", "T", ">", "storage", ",", "Function", "<", "T", ",", "K", ">", "keyFunction", ",", "Comparator", "<", "K", ">", "keyCompa...
Creates a new instance of StreamSorter @param storage storage for storing elements which was no placed to RAM @param keyFunction function for searching key @param keyComparator comparator for comparing key @param distinct if it is true it means that in result will be not objects with same ...
[ "Creates", "a", "new", "instance", "of", "StreamSorter" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/StreamSorter.java#L139-L143
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java
EquationsBFGS.update
public static void update(DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double p = VectorVectorMult_DDRM.innerProd(y,s); if( p == 0 ) return; p = 1.0/p; double sBs = VectorVectorMult_DDRM.innerProdA(s,H,s); if( sBs == 0 ) return; ...
java
public static void update(DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double p = VectorVectorMult_DDRM.innerProd(y,s); if( p == 0 ) return; p = 1.0/p; double sBs = VectorVectorMult_DDRM.innerProdA(s,H,s); if( sBs == 0 ) return; ...
[ "public", "static", "void", "update", "(", "DMatrixRMaj", "H", ",", "DMatrixRMaj", "s", ",", "DMatrixRMaj", "y", ",", "DMatrixRMaj", "tempV0", ",", "DMatrixRMaj", "tempV1", ")", "{", "double", "p", "=", "VectorVectorMult_DDRM", ".", "innerProd", "(", "y", ",...
DFP Hessian update equation. See class description for equations @param H symmetric inverse matrix being updated @param s change in state (new - old) @param y change in gradient (new - old) @param tempV0 Storage vector
[ "DFP", "Hessian", "update", "equation", ".", "See", "class", "description", "for", "equations" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java#L62-L82
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java
EquationsBFGS.inverseUpdate
public static void inverseUpdate( DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double alpha = VectorVectorMult_DDRM.innerProdA(y,H,y); double p = 1.0/VectorVectorMult_DDRM.innerProd(s,y); CommonOps_DDRM.mult(H,y,tempV0); CommonOps_DDRM.multTransA(y, H, t...
java
public static void inverseUpdate( DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double alpha = VectorVectorMult_DDRM.innerProdA(y,H,y); double p = 1.0/VectorVectorMult_DDRM.innerProd(s,y); CommonOps_DDRM.mult(H,y,tempV0); CommonOps_DDRM.multTransA(y, H, t...
[ "public", "static", "void", "inverseUpdate", "(", "DMatrixRMaj", "H", ",", "DMatrixRMaj", "s", ",", "DMatrixRMaj", "y", ",", "DMatrixRMaj", "tempV0", ",", "DMatrixRMaj", "tempV1", ")", "{", "double", "alpha", "=", "VectorVectorMult_DDRM", ".", "innerProdA", "(",...
BFGS inverse hessian update equation that orders the multiplications to minimize the number of operations. @param H symmetric inverse matrix being updated @param s change in state @param y change in gradient @param tempV0 Storage vector of length N @param tempV1 Storage vector of length N
[ "BFGS", "inverse", "hessian", "update", "equation", "that", "orders", "the", "multiplications", "to", "minimize", "the", "number", "of", "operations", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java#L93-L105
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/UtilOptimize.java
UtilOptimize.process
public static boolean process( IterativeOptimization search , int maxSteps ) { for( int i = 0; i < maxSteps; i++ ) { boolean converged = step(search); if( converged ) { return search.isConverged(); } } return true; }
java
public static boolean process( IterativeOptimization search , int maxSteps ) { for( int i = 0; i < maxSteps; i++ ) { boolean converged = step(search); if( converged ) { return search.isConverged(); } } return true; }
[ "public", "static", "boolean", "process", "(", "IterativeOptimization", "search", ",", "int", "maxSteps", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maxSteps", ";", "i", "++", ")", "{", "boolean", "converged", "=", "step", "(", "search...
Iterate until the line search converges or the maximum number of iterations has been exceeded. The maximum number of steps is specified. A step is defined as the number of times the optimization parameters are changed. @param search Search algorithm @param maxSteps Maximum number of steps. @return Value returned by ...
[ "Iterate", "until", "the", "line", "search", "converges", "or", "the", "maximum", "number", "of", "iterations", "has", "been", "exceeded", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/UtilOptimize.java#L38-L47
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/UtilOptimize.java
UtilOptimize.step
public static boolean step( IterativeOptimization search ) { for( int i = 0; i < 10000; i++ ) { boolean converged = search.iterate(); if( converged || !search.isUpdated() ) { return converged; } } throw new RuntimeException("After 10,000 iterations it failed to take a step! Probably a bug."); }
java
public static boolean step( IterativeOptimization search ) { for( int i = 0; i < 10000; i++ ) { boolean converged = search.iterate(); if( converged || !search.isUpdated() ) { return converged; } } throw new RuntimeException("After 10,000 iterations it failed to take a step! Probably a bug."); }
[ "public", "static", "boolean", "step", "(", "IterativeOptimization", "search", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "10000", ";", "i", "++", ")", "{", "boolean", "converged", "=", "search", ".", "iterate", "(", ")", ";", "if", ...
Performs a single step by iterating until the parameters are updated. @param search Search algorithm @return Value returned by {@link IterativeOptimization#iterate}
[ "Performs", "a", "single", "step", "by", "iterating", "until", "the", "parameters", "are", "updated", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/UtilOptimize.java#L55-L63
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeMemory.java
KdTreeMemory.requestNode
public KdTree.Node requestNode() { if( unusedNodes.isEmpty() ) return new KdTree.Node(); return unusedNodes.remove( unusedNodes.size()-1); }
java
public KdTree.Node requestNode() { if( unusedNodes.isEmpty() ) return new KdTree.Node(); return unusedNodes.remove( unusedNodes.size()-1); }
[ "public", "KdTree", ".", "Node", "requestNode", "(", ")", "{", "if", "(", "unusedNodes", ".", "isEmpty", "(", ")", ")", "return", "new", "KdTree", ".", "Node", "(", ")", ";", "return", "unusedNodes", ".", "remove", "(", "unusedNodes", ".", "size", "(",...
Returns a new node. All object references can be assumed to be null. @return
[ "Returns", "a", "new", "node", ".", "All", "object", "references", "can", "be", "assumed", "to", "be", "null", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeMemory.java#L42-L46
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeMemory.java
KdTreeMemory.requestNode
public KdTree.Node requestNode(P point , int index ) { KdTree.Node n = requestNode(); n.point = point; n.index = index; n.split = -1; return n; }
java
public KdTree.Node requestNode(P point , int index ) { KdTree.Node n = requestNode(); n.point = point; n.index = index; n.split = -1; return n; }
[ "public", "KdTree", ".", "Node", "requestNode", "(", "P", "point", ",", "int", "index", ")", "{", "KdTree", ".", "Node", "n", "=", "requestNode", "(", ")", ";", "n", ".", "point", "=", "point", ";", "n", ".", "index", "=", "index", ";", "n", ".",...
Request a leaf node be returned. All data parameters will be automatically assigned appropriate values for a leaf.
[ "Request", "a", "leaf", "node", "be", "returned", ".", "All", "data", "parameters", "will", "be", "automatically", "assigned", "appropriate", "values", "for", "a", "leaf", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeMemory.java#L52-L58
train
lessthanoptimal/ddogleg
src/org/ddogleg/solver/PolynomialOps.java
PolynomialOps.multiply
public static Polynomial multiply( Polynomial a , Polynomial b , Polynomial result ) { int N = Math.max(0,a.size() + b.size() - 1); if( result == null ) { result = new Polynomial(N); } else { if( result.size < N ) throw new IllegalArgumentException("Unexpected length of 'result'"); result.zero(); ...
java
public static Polynomial multiply( Polynomial a , Polynomial b , Polynomial result ) { int N = Math.max(0,a.size() + b.size() - 1); if( result == null ) { result = new Polynomial(N); } else { if( result.size < N ) throw new IllegalArgumentException("Unexpected length of 'result'"); result.zero(); ...
[ "public", "static", "Polynomial", "multiply", "(", "Polynomial", "a", ",", "Polynomial", "b", ",", "Polynomial", "result", ")", "{", "int", "N", "=", "Math", ".", "max", "(", "0", ",", "a", ".", "size", "(", ")", "+", "b", ".", "size", "(", ")", ...
Multiplies the two polynomials together. @param a Polynomial @param b Polynomial @param result Optional storage parameter for the results. Must be have enough coefficients to store the results. If null a new instance is declared. @return Results of the multiplication
[ "Multiplies", "the", "two", "polynomials", "together", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialOps.java#L150-L172
train
lessthanoptimal/ddogleg
src/org/ddogleg/solver/PolynomialOps.java
PolynomialOps.add
public static Polynomial add( Polynomial a , Polynomial b , Polynomial results ) { int N = Math.max(a.size,b.size); if( results == null ) { results = new Polynomial(N); } else if( results.size < N ) { throw new IllegalArgumentException("storage for results must be at least as large as the the largest polyn...
java
public static Polynomial add( Polynomial a , Polynomial b , Polynomial results ) { int N = Math.max(a.size,b.size); if( results == null ) { results = new Polynomial(N); } else if( results.size < N ) { throw new IllegalArgumentException("storage for results must be at least as large as the the largest polyn...
[ "public", "static", "Polynomial", "add", "(", "Polynomial", "a", ",", "Polynomial", "b", ",", "Polynomial", "results", ")", "{", "int", "N", "=", "Math", ".", "max", "(", "a", ".", "size", ",", "b", ".", "size", ")", ";", "if", "(", "results", "=="...
Adds two polynomials together. The lengths of the polynomials do not need to be the zero, but the 'missing' coefficients are assumed to be zero. @param a Polynomial @param b Polynomial @param results Optional storage for resulting polynomial. If null a new instance is declared. If not null its length must be the same...
[ "Adds", "two", "polynomials", "together", ".", "The", "lengths", "of", "the", "polynomials", "do", "not", "need", "to", "be", "the", "zero", "but", "the", "missing", "coefficients", "are", "assumed", "to", "be", "zero", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialOps.java#L184-L212
train
lessthanoptimal/ddogleg
src/org/ddogleg/solver/PolynomialOps.java
PolynomialOps.createRootFinder
public static PolynomialRoots createRootFinder( int maxCoefficients , RootFinderType which ) { switch( which ) { case STURM: FindRealRootsSturm sturm = new FindRealRootsSturm(maxCoefficients,-1,1e-10,200,200); return new WrapRealRootsSturm(sturm); case EVD: return new RootFinderCompanion(); def...
java
public static PolynomialRoots createRootFinder( int maxCoefficients , RootFinderType which ) { switch( which ) { case STURM: FindRealRootsSturm sturm = new FindRealRootsSturm(maxCoefficients,-1,1e-10,200,200); return new WrapRealRootsSturm(sturm); case EVD: return new RootFinderCompanion(); def...
[ "public", "static", "PolynomialRoots", "createRootFinder", "(", "int", "maxCoefficients", ",", "RootFinderType", "which", ")", "{", "switch", "(", "which", ")", "{", "case", "STURM", ":", "FindRealRootsSturm", "sturm", "=", "new", "FindRealRootsSturm", "(", "maxCo...
Creates different polynomial root finders. @param maxCoefficients The maximum number of coefficients that will be processed. This is the order + 1 @param which 0 = Sturm and 1 = companion matrix. @return PolynomialRoots
[ "Creates", "different", "polynomial", "root", "finders", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialOps.java#L229-L241
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/DerivativeChecker.java
DerivativeChecker.gradient
public static boolean gradient( FunctionNtoS func , FunctionNtoN gradient , double param[] , double tol ) { return gradient(func, gradient, param, tol, Math.sqrt(UtilEjml.EPS)); }
java
public static boolean gradient( FunctionNtoS func , FunctionNtoN gradient , double param[] , double tol ) { return gradient(func, gradient, param, tol, Math.sqrt(UtilEjml.EPS)); }
[ "public", "static", "boolean", "gradient", "(", "FunctionNtoS", "func", ",", "FunctionNtoN", "gradient", ",", "double", "param", "[", "]", ",", "double", "tol", ")", "{", "return", "gradient", "(", "func", ",", "gradient", ",", "param", ",", "tol", ",", ...
Compares the passed in gradient function to a numerical calculation. Comparison is done using an absolute value. @return true for within tolerance and false otherwise
[ "Compares", "the", "passed", "in", "gradient", "function", "to", "a", "numerical", "calculation", ".", "Comparison", "is", "done", "using", "an", "absolute", "value", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/DerivativeChecker.java#L232-L236
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.bracket
protected boolean bracket() { // System.out.println("------------- bracket"); // the value of alpha was passed in function.setInput(stp); if( mode != 0 ) { fp = function.computeFunction(); gp = Double.NaN; } else { mode = 1; } // check for upper bounds if( fp > valueZero + ftol * stp *derivZero...
java
protected boolean bracket() { // System.out.println("------------- bracket"); // the value of alpha was passed in function.setInput(stp); if( mode != 0 ) { fp = function.computeFunction(); gp = Double.NaN; } else { mode = 1; } // check for upper bounds if( fp > valueZero + ftol * stp *derivZero...
[ "protected", "boolean", "bracket", "(", ")", "{", "//\t\tSystem.out.println(\"------------- bracket\");", "// the value of alpha was passed in", "function", ".", "setInput", "(", "stp", ")", ";", "if", "(", "mode", "!=", "0", ")", "{", "fp", "=", "function", ".", ...
Searches for an upper bound.
[ "Searches", "for", "an", "upper", "bound", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L210-L267
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.section
protected boolean section() { // System.out.println("------------- section"); // compute the value at the new sample point double temp = stp; stp = interpolate(pLow +t2*(pHi - pLow), pHi -t3*(pHi - pLow)); updated = true; // save the previous step if( !Double.isNaN(gp)) { // needs to keep a step with a...
java
protected boolean section() { // System.out.println("------------- section"); // compute the value at the new sample point double temp = stp; stp = interpolate(pLow +t2*(pHi - pLow), pHi -t3*(pHi - pLow)); updated = true; // save the previous step if( !Double.isNaN(gp)) { // needs to keep a step with a...
[ "protected", "boolean", "section", "(", ")", "{", "//\t\tSystem.out.println(\"------------- section\");", "// compute the value at the new sample point", "double", "temp", "=", "stp", ";", "stp", "=", "interpolate", "(", "pLow", "+", "t2", "*", "(", "pHi", "-", "pLow"...
Using the found bracket for alpha it searches for a better estimate.
[ "Using", "the", "found", "bracket", "for", "alpha", "it", "searches", "for", "a", "better", "estimate", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L280-L327
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.checkSmallStep
protected boolean checkSmallStep() { double max = Math.max(stp, stprev); return( Math.abs(stp - stprev)/max < tolStep ); }
java
protected boolean checkSmallStep() { double max = Math.max(stp, stprev); return( Math.abs(stp - stprev)/max < tolStep ); }
[ "protected", "boolean", "checkSmallStep", "(", ")", "{", "double", "max", "=", "Math", ".", "max", "(", "stp", ",", "stprev", ")", ";", "return", "(", "Math", ".", "abs", "(", "stp", "-", "stprev", ")", "/", "max", "<", "tolStep", ")", ";", "}" ]
Checks to see if alpha is changing by a significant amount. If it change is too small it can get stuck in a loop\
[ "Checks", "to", "see", "if", "alpha", "is", "changing", "by", "a", "significant", "amount", ".", "If", "it", "change", "is", "too", "small", "it", "can", "get", "stuck", "in", "a", "loop", "\\" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L343-L346
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.interpolate
protected double interpolate( double boundA , double boundB ) { double alphaNew; // interpolate minimum for rapid convergence if( Double.isNaN(gp) ) { alphaNew = SearchInterpolate.quadratic(fprev, gprev, stprev, fp, stp); } else { alphaNew = SearchInterpolate.cubic2(fprev, gprev, stprev, fp, gp, stp); ...
java
protected double interpolate( double boundA , double boundB ) { double alphaNew; // interpolate minimum for rapid convergence if( Double.isNaN(gp) ) { alphaNew = SearchInterpolate.quadratic(fprev, gprev, stprev, fp, stp); } else { alphaNew = SearchInterpolate.cubic2(fprev, gprev, stprev, fp, gp, stp); ...
[ "protected", "double", "interpolate", "(", "double", "boundA", ",", "double", "boundB", ")", "{", "double", "alphaNew", ";", "// interpolate minimum for rapid convergence", "if", "(", "Double", ".", "isNaN", "(", "gp", ")", ")", "{", "alphaNew", "=", "SearchInte...
Use either quadratic of cubic interpolation to guess the minimum.
[ "Use", "either", "quadratic", "of", "cubic", "interpolation", "to", "guess", "the", "minimum", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L351-L379
train
lessthanoptimal/ddogleg
benchmark/src/org/ddogleg/optimization/LineSearchEvaluator.java
LineSearchEvaluator.process
private List<Results> process( FunctionStoS f , FunctionStoS g , double ...initSteps ) { List<Results> results = new ArrayList<Results>(); for( double step : initSteps ) { results.add(performTest(f,g,step,0,Double.POSITIVE_INFINITY)); } return results; }
java
private List<Results> process( FunctionStoS f , FunctionStoS g , double ...initSteps ) { List<Results> results = new ArrayList<Results>(); for( double step : initSteps ) { results.add(performTest(f,g,step,0,Double.POSITIVE_INFINITY)); } return results; }
[ "private", "List", "<", "Results", ">", "process", "(", "FunctionStoS", "f", ",", "FunctionStoS", "g", ",", "double", "...", "initSteps", ")", "{", "List", "<", "Results", ">", "results", "=", "new", "ArrayList", "<", "Results", ">", "(", ")", ";", "fo...
Processes and compile results for the function at the specified initial steps
[ "Processes", "and", "compile", "results", "for", "the", "function", "at", "the", "specified", "initial", "steps" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/benchmark/src/org/ddogleg/optimization/LineSearchEvaluator.java#L93-L102
train
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/CountingSort.java
CountingSort.sort
public void sort( int data[] , int begin , int end ) { histogram.fill(0); for( int i = begin; i < end; i++ ) { histogram.data[data[i]-minValue]++; } // over wrist the input data with sorted elements int index = begin; for( int i = 0; i < histogram.size; i++ ) { int N = histogram.get(i); int value...
java
public void sort( int data[] , int begin , int end ) { histogram.fill(0); for( int i = begin; i < end; i++ ) { histogram.data[data[i]-minValue]++; } // over wrist the input data with sorted elements int index = begin; for( int i = 0; i < histogram.size; i++ ) { int N = histogram.get(i); int value...
[ "public", "void", "sort", "(", "int", "data", "[", "]", ",", "int", "begin", ",", "int", "end", ")", "{", "histogram", ".", "fill", "(", "0", ")", ";", "for", "(", "int", "i", "=", "begin", ";", "i", "<", "end", ";", "i", "++", ")", "{", "h...
Sorts the data in the array. @param data Data which is to be sorted. Sorted data is written back into this same array @param begin First element to be sorted (inclusive) @param end Last element to be sorted (exclusive)
[ "Sorts", "the", "data", "in", "the", "array", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/CountingSort.java#L64-L80
train
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/CountingSort.java
CountingSort.sort
public void sort( int input[] , int startIndex ,int output[] , int startOutput , int length ) { histogram.fill(0); for( int i = 0; i < length; i++ ) { histogram.data[input[i+startIndex]-minValue]++; } // over wrist the input data with sorted elements int index = startOutput; for( int i = 0; i < histogr...
java
public void sort( int input[] , int startIndex ,int output[] , int startOutput , int length ) { histogram.fill(0); for( int i = 0; i < length; i++ ) { histogram.data[input[i+startIndex]-minValue]++; } // over wrist the input data with sorted elements int index = startOutput; for( int i = 0; i < histogr...
[ "public", "void", "sort", "(", "int", "input", "[", "]", ",", "int", "startIndex", ",", "int", "output", "[", "]", ",", "int", "startOutput", ",", "int", "length", ")", "{", "histogram", ".", "fill", "(", "0", ")", ";", "for", "(", "int", "i", "=...
Sort routine which does not modify the input array. Input and output arrays can be the same instance. @param input (Input) Data which is to be sorted. Not modified. @param startIndex First element in input list @param output (Output) Sorted data. Modified. @param length Number of elements
[ "Sort", "routine", "which", "does", "not", "modify", "the", "input", "array", ".", "Input", "and", "output", "arrays", "can", "be", "the", "same", "instance", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/CountingSort.java#L90-L106
train
lessthanoptimal/ddogleg
examples/src/org/ddogleg/example/DistanceFromLine.java
DistanceFromLine.computeDistance
@Override public void computeDistance(List<Point2D> obs, double[] distance) { for( int i = 0; i < obs.size(); i++ ) { distance[i] = computeDistance(obs.get(i)); } }
java
@Override public void computeDistance(List<Point2D> obs, double[] distance) { for( int i = 0; i < obs.size(); i++ ) { distance[i] = computeDistance(obs.get(i)); } }
[ "@", "Override", "public", "void", "computeDistance", "(", "List", "<", "Point2D", ">", "obs", ",", "double", "[", "]", "distance", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "obs", ".", "size", "(", ")", ";", "i", "++", ")", "{...
There are some situations where processing everything as a list can speed things up a lot. This is not one of them.
[ "There", "are", "some", "situations", "where", "processing", "everything", "as", "a", "list", "can", "speed", "things", "up", "a", "lot", ".", "This", "is", "not", "one", "of", "them", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/examples/src/org/ddogleg/example/DistanceFromLine.java#L67-L72
train
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/StraightInsertionSort.java
StraightInsertionSort.sort
public static void sort( double[] data ) { int i=0,j; final int n = data.length; double a; // by doing the ugly exception catching it was 13% faster // on data set of 100000 try { for( j =1; ; j++ ) { a=data[j]; try { for( i=j; data[i-1] > a;i-- ) { data[i]=data[i-1]; } }cat...
java
public static void sort( double[] data ) { int i=0,j; final int n = data.length; double a; // by doing the ugly exception catching it was 13% faster // on data set of 100000 try { for( j =1; ; j++ ) { a=data[j]; try { for( i=j; data[i-1] > a;i-- ) { data[i]=data[i-1]; } }cat...
[ "public", "static", "void", "sort", "(", "double", "[", "]", "data", ")", "{", "int", "i", "=", "0", ",", "j", ";", "final", "int", "n", "=", "data", ".", "length", ";", "double", "a", ";", "// by doing the ugly exception catching it was 13% faster", "// o...
Sorts data into ascending order
[ "Sorts", "data", "into", "ascending", "order" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/StraightInsertionSort.java#L35-L54
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeConstructor.java
KdTreeConstructor.computeBranch
protected KdTree.Node computeBranch(List<P> points, GrowQueue_I32 indexes) { // declare storage for the split data List<P> left = new ArrayList<>(points.size()/2); List<P> right = new ArrayList<>(points.size()/2); GrowQueue_I32 leftIndexes,rightIndexes; if( indexes == null ) { leftIndexes = null; rightIn...
java
protected KdTree.Node computeBranch(List<P> points, GrowQueue_I32 indexes) { // declare storage for the split data List<P> left = new ArrayList<>(points.size()/2); List<P> right = new ArrayList<>(points.size()/2); GrowQueue_I32 leftIndexes,rightIndexes; if( indexes == null ) { leftIndexes = null; rightIn...
[ "protected", "KdTree", ".", "Node", "computeBranch", "(", "List", "<", "P", ">", "points", ",", "GrowQueue_I32", "indexes", ")", "{", "// declare storage for the split data", "List", "<", "P", ">", "left", "=", "new", "ArrayList", "<>", "(", "points", ".", "...
Given the data inside this particular node, select a point for the node and compute the node's children @return The node associated with this region
[ "Given", "the", "data", "inside", "this", "particular", "node", "select", "a", "point", "for", "the", "node", "and", "compute", "the", "node", "s", "children" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeConstructor.java#L99-L130
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeConstructor.java
KdTreeConstructor.computeChild
protected KdTree.Node computeChild(List<P> points , GrowQueue_I32 indexes ) { if( points.size() == 0 ) return null; if( points.size() == 1 ) { return createLeaf(points,indexes); } else { return computeBranch(points,indexes); } }
java
protected KdTree.Node computeChild(List<P> points , GrowQueue_I32 indexes ) { if( points.size() == 0 ) return null; if( points.size() == 1 ) { return createLeaf(points,indexes); } else { return computeBranch(points,indexes); } }
[ "protected", "KdTree", ".", "Node", "computeChild", "(", "List", "<", "P", ">", "points", ",", "GrowQueue_I32", "indexes", ")", "{", "if", "(", "points", ".", "size", "(", ")", "==", "0", ")", "return", "null", ";", "if", "(", "points", ".", "size", ...
Creates a child by checking to see if it is a leaf or branch.
[ "Creates", "a", "child", "by", "checking", "to", "see", "if", "it", "is", "a", "leaf", "or", "branch", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeConstructor.java#L135-L144
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeConstructor.java
KdTreeConstructor.createLeaf
private KdTree.Node createLeaf(List<P> points , GrowQueue_I32 indexes ) { int index = indexes == null ? -1 : indexes.get(0); return memory.requestNode(points.get(0),index); }
java
private KdTree.Node createLeaf(List<P> points , GrowQueue_I32 indexes ) { int index = indexes == null ? -1 : indexes.get(0); return memory.requestNode(points.get(0),index); }
[ "private", "KdTree", ".", "Node", "createLeaf", "(", "List", "<", "P", ">", "points", ",", "GrowQueue_I32", "indexes", ")", "{", "int", "index", "=", "indexes", "==", "null", "?", "-", "1", ":", "indexes", ".", "get", "(", "0", ")", ";", "return", ...
Convenient function for creating a leaf node
[ "Convenient", "function", "for", "creating", "a", "leaf", "node" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeConstructor.java#L149-L152
train
lessthanoptimal/ddogleg
src/org/ddogleg/struct/GrowQueue_I8.java
GrowQueue_I8.remove
public void remove( int first , int last ) { if( last < first ) throw new IllegalArgumentException("first <= last"); if( last >= size ) throw new IllegalArgumentException("last must be less than the max size"); int delta = last-first+1; for( int i = last+1; i < size; i++ ) { data[i-delta] = data[i]; ...
java
public void remove( int first , int last ) { if( last < first ) throw new IllegalArgumentException("first <= last"); if( last >= size ) throw new IllegalArgumentException("last must be less than the max size"); int delta = last-first+1; for( int i = last+1; i < size; i++ ) { data[i-delta] = data[i]; ...
[ "public", "void", "remove", "(", "int", "first", ",", "int", "last", ")", "{", "if", "(", "last", "<", "first", ")", "throw", "new", "IllegalArgumentException", "(", "\"first <= last\"", ")", ";", "if", "(", "last", ">=", "size", ")", "throw", "new", "...
Removes elements from the list starting at 'first' and ending at 'last' @param first First index you wish to remove. Inclusive. @param last Last index you wish to remove. Inclusive.
[ "Removes", "elements", "from", "the", "list", "starting", "at", "first", "and", "ending", "at", "last" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I8.java#L176-L187
train
lessthanoptimal/ddogleg
src/org/ddogleg/struct/GrowQueue_I8.java
GrowQueue_I8.printHex
public void printHex() { System.out.print("[ "); for (int i = 0; i < size; i++) { System.out.printf("0x%02X ",data[i]); } System.out.print("]"); }
java
public void printHex() { System.out.print("[ "); for (int i = 0; i < size; i++) { System.out.printf("0x%02X ",data[i]); } System.out.print("]"); }
[ "public", "void", "printHex", "(", ")", "{", "System", ".", "out", ".", "print", "(", "\"[ \"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "System", ".", "out", ".", "printf", "(", "\"0x%02X \""...
Prints the queue to stdout as a hex array
[ "Prints", "the", "queue", "to", "stdout", "as", "a", "hex", "array" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I8.java#L262-L268
train
lessthanoptimal/ddogleg
src/org/ddogleg/struct/GrowQueue_I8.java
GrowQueue_I8.indexOf
public int indexOf( byte value ) { for (int i = 0; i < size; i++) { if( data[i] == value ) return i; } return -1; }
java
public int indexOf( byte value ) { for (int i = 0; i < size; i++) { if( data[i] == value ) return i; } return -1; }
[ "public", "int", "indexOf", "(", "byte", "value", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "if", "(", "data", "[", "i", "]", "==", "value", ")", "return", "i", ";", "}", "return", "-", "1"...
Returns the index of the first element with the specified 'value'. return -1 if it wasn't found @param value Value to search for @return index or -1 if it's not in the list
[ "Returns", "the", "index", "of", "the", "first", "element", "with", "the", "specified", "value", ".", "return", "-", "1", "if", "it", "wasn", "t", "found" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I8.java#L291-L297
train
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/ApproximateSort_F32.java
ApproximateSort_F32.computeRange
public void computeRange( SortableParameter_F32 input[] , int start , int length ) { if( length == 0 ) { divisor = 0; return; } float min,max; min = max = input[start].sortValue; for( int i = 1; i < length; i++ ) { float val = input[start+i].sortValue; if( val < min ) min = val; else if(...
java
public void computeRange( SortableParameter_F32 input[] , int start , int length ) { if( length == 0 ) { divisor = 0; return; } float min,max; min = max = input[start].sortValue; for( int i = 1; i < length; i++ ) { float val = input[start+i].sortValue; if( val < min ) min = val; else if(...
[ "public", "void", "computeRange", "(", "SortableParameter_F32", "input", "[", "]", ",", "int", "start", ",", "int", "length", ")", "{", "if", "(", "length", "==", "0", ")", "{", "divisor", "=", "0", ";", "return", ";", "}", "float", "min", ",", "max"...
Examines the list and computes the range from it
[ "Examines", "the", "list", "and", "computes", "the", "range", "from", "it" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/ApproximateSort_F32.java#L95-L114
train
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/ApproximateSort_F32.java
ApproximateSort_F32.sortIndex
public void sortIndex( float input[] , int start , int length , int indexes[] ) { for( int i = 0; i < length; i++ ) indexes[i] = i; for( int i = 0; i < histIndexes.size; i++ ) { histIndexes.get(i).reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; int discretized = (int)((inp...
java
public void sortIndex( float input[] , int start , int length , int indexes[] ) { for( int i = 0; i < length; i++ ) indexes[i] = i; for( int i = 0; i < histIndexes.size; i++ ) { histIndexes.get(i).reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; int discretized = (int)((inp...
[ "public", "void", "sortIndex", "(", "float", "input", "[", "]", ",", "int", "start", ",", "int", "length", ",", "int", "indexes", "[", "]", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "indexes", "["...
Sort routine which does not modify the input array and instead maintains a list of indexes. @param input (Input) Data which is to be sorted. Not modified. @param start First element in input list @param length Length of the input list @param indexes Number of elements
[ "Sort", "routine", "which", "does", "not", "modify", "the", "input", "array", "and", "instead", "maintains", "a", "list", "of", "indexes", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/ApproximateSort_F32.java#L124-L146
train
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/ApproximateSort_F32.java
ApproximateSort_F32.sortObject
public void sortObject( SortableParameter_F32 input[] , int start , int length ) { for( int i = 0; i < histIndexes.size; i++ ) { histObjs[i].reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; SortableParameter_F32 p = input[indexInput]; int discretized = (int)((p.sortValue-minV...
java
public void sortObject( SortableParameter_F32 input[] , int start , int length ) { for( int i = 0; i < histIndexes.size; i++ ) { histObjs[i].reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; SortableParameter_F32 p = input[indexInput]; int discretized = (int)((p.sortValue-minV...
[ "public", "void", "sortObject", "(", "SortableParameter_F32", "input", "[", "]", ",", "int", "start", ",", "int", "length", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "histIndexes", ".", "size", ";", "i", "++", ")", "{", "histObjs", ...
Sorts the input list @param input (Input) Data which is to be sorted. Not modified. @param start First element in input list @param length Length of the input list
[ "Sorts", "the", "input", "list" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/ApproximateSort_F32.java#L155-L176
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java
KdTreeSearchBestBinFirst.searchNode
protected void searchNode(P target, KdTree.Node n) { while( n != null) { checkBestDistance(n, target); if( n.isLeaf() ) break; // select the most promising branch to investigate first KdTree.Node nearer,further; double splitValue = distance.valueAt( (P)n.point , n.split ); if( distance.value...
java
protected void searchNode(P target, KdTree.Node n) { while( n != null) { checkBestDistance(n, target); if( n.isLeaf() ) break; // select the most promising branch to investigate first KdTree.Node nearer,further; double splitValue = distance.valueAt( (P)n.point , n.split ); if( distance.value...
[ "protected", "void", "searchNode", "(", "P", "target", ",", "KdTree", ".", "Node", "n", ")", "{", "while", "(", "n", "!=", "null", ")", "{", "checkBestDistance", "(", "n", ",", "target", ")", ";", "if", "(", "n", ".", "isLeaf", "(", ")", ")", "br...
Traverse a node down to a leaf. Unexplored branches are added to the priority queue.
[ "Traverse", "a", "node", "down", "to", "a", "leaf", ".", "Unexplored", "branches", "are", "added", "to", "the", "priority", "queue", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java#L136-L164
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java
KdTreeSearchBestBinFirst.addToQueue
protected void addToQueue(double closestDistanceSq , KdTree.Node node , P target ) { if( !node.isLeaf() ) { Helper h; if( unused.isEmpty() ) { h = new Helper(); } else { h = unused.remove( unused.size()-1 ); } h.closestPossibleSq = closestDistanceSq; h.node = node; queue.add(h); } el...
java
protected void addToQueue(double closestDistanceSq , KdTree.Node node , P target ) { if( !node.isLeaf() ) { Helper h; if( unused.isEmpty() ) { h = new Helper(); } else { h = unused.remove( unused.size()-1 ); } h.closestPossibleSq = closestDistanceSq; h.node = node; queue.add(h); } el...
[ "protected", "void", "addToQueue", "(", "double", "closestDistanceSq", ",", "KdTree", ".", "Node", "node", ",", "P", "target", ")", "{", "if", "(", "!", "node", ".", "isLeaf", "(", ")", ")", "{", "Helper", "h", ";", "if", "(", "unused", ".", "isEmpty...
Adds a node to the priority queue. @param closestDistanceSq The closest distance that a point in the region could possibly be target
[ "Adds", "a", "node", "to", "the", "priority", "queue", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java#L171-L188
train
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java
InitializePlusPlus.selectNextSeed
protected final double[] selectNextSeed( List<double[]> points , double target ) { // this won't select previously selected points because the distance will be zero // If the distance is zero it will simply skip over it double sum = 0; for (int i = 0; i < distance.size(); i++) { sum += distance.get(i); do...
java
protected final double[] selectNextSeed( List<double[]> points , double target ) { // this won't select previously selected points because the distance will be zero // If the distance is zero it will simply skip over it double sum = 0; for (int i = 0; i < distance.size(); i++) { sum += distance.get(i); do...
[ "protected", "final", "double", "[", "]", "selectNextSeed", "(", "List", "<", "double", "[", "]", ">", "points", ",", "double", "target", ")", "{", "// this won't select previously selected points because the distance will be zero", "// If the distance is zero it will simply ...
Randomly selects the next seed. The chance of a seed is based upon its distance from the closest cluster. Larger distances mean more likely. @param points List of all the points @param target Number from 0 to 1, inclusive @return Index of the selected seed
[ "Randomly", "selects", "the", "next", "seed", ".", "The", "chance", "of", "a", "seed", "is", "based", "upon", "its", "distance", "from", "the", "closest", "cluster", ".", "Larger", "distances", "mean", "more", "likely", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java#L94-L105
train
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java
InitializePlusPlus.updateDistances
protected final void updateDistances( List<double[]> points , double []clusterNew ) { totalDistance = 0; for (int i = 0; i < distance.size(); i++) { double dOld = distance.get(i); double dNew = StandardKMeans_F64.distanceSq(points.get(i),clusterNew); if( dNew < dOld ) { distance.data[i] = dNew; tot...
java
protected final void updateDistances( List<double[]> points , double []clusterNew ) { totalDistance = 0; for (int i = 0; i < distance.size(); i++) { double dOld = distance.get(i); double dNew = StandardKMeans_F64.distanceSq(points.get(i),clusterNew); if( dNew < dOld ) { distance.data[i] = dNew; tot...
[ "protected", "final", "void", "updateDistances", "(", "List", "<", "double", "[", "]", ">", "points", ",", "double", "[", "]", "clusterNew", ")", "{", "totalDistance", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "distance", ".", ...
Updates the list of distances from a point to the closest cluster. Update list of total distances
[ "Updates", "the", "list", "of", "distances", "from", "a", "point", "to", "the", "closest", "cluster", ".", "Update", "list", "of", "total", "distances" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java#L110-L122
train
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/gmm/GaussianLikelihoodManager.java
GaussianLikelihoodManager.precomputeAll
public void precomputeAll() { precomputes.resize(mixtures.size()); for (int i = 0; i < precomputes.size; i++) { precomputes.get(i).setGaussian(mixtures.get(i)); } }
java
public void precomputeAll() { precomputes.resize(mixtures.size()); for (int i = 0; i < precomputes.size; i++) { precomputes.get(i).setGaussian(mixtures.get(i)); } }
[ "public", "void", "precomputeAll", "(", ")", "{", "precomputes", ".", "resize", "(", "mixtures", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "precomputes", ".", "size", ";", "i", "++", ")", "{", "precomputes", ...
Precomputes likelihood for all the mixtures
[ "Precomputes", "likelihood", "for", "all", "the", "mixtures" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/gmm/GaussianLikelihoodManager.java#L69-L74
train
lessthanoptimal/ddogleg
src/org/ddogleg/util/PrimitiveArrays.java
PrimitiveArrays.fillCounting
public static void fillCounting(int[] array , int offset, int length ) { for (int i = 0; i < length; i++) { array[i+offset] = i; } }
java
public static void fillCounting(int[] array , int offset, int length ) { for (int i = 0; i < length; i++) { array[i+offset] = i; } }
[ "public", "static", "void", "fillCounting", "(", "int", "[", "]", "array", ",", "int", "offset", ",", "int", "length", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "array", "[", "i", "+", "offse...
Sets each element within range to a number counting up
[ "Sets", "each", "element", "within", "range", "to", "a", "number", "counting", "up" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/util/PrimitiveArrays.java#L33-L37
train
lessthanoptimal/ddogleg
src/org/ddogleg/util/PrimitiveArrays.java
PrimitiveArrays.shuffle
public static void shuffle( byte []array , int offset , int length , Random rand ) { for (int i = 0; i < length; i++) { int src = rand.nextInt(length-i); byte tmp = array[offset+src+i]; array[offset+src+i]=array[offset+i]; array[offset+i] = tmp; } }
java
public static void shuffle( byte []array , int offset , int length , Random rand ) { for (int i = 0; i < length; i++) { int src = rand.nextInt(length-i); byte tmp = array[offset+src+i]; array[offset+src+i]=array[offset+i]; array[offset+i] = tmp; } }
[ "public", "static", "void", "shuffle", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "int", "length", ",", "Random", "rand", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "int", "src...
Randomly shuffle the array
[ "Randomly", "shuffle", "the", "array" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/util/PrimitiveArrays.java#L48-L55
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.setConvergence
public LineSearchMore94 setConvergence(double ftol, double gtol, double xtol) { if( ftol < 0 ) throw new IllegalArgumentException("ftol must be >= 0 "); if( gtol < 0 ) throw new IllegalArgumentException("gtol must be >= 0 "); if( xtol < 0 ) throw new IllegalArgumentException("xtol must be >= 0 "); thi...
java
public LineSearchMore94 setConvergence(double ftol, double gtol, double xtol) { if( ftol < 0 ) throw new IllegalArgumentException("ftol must be >= 0 "); if( gtol < 0 ) throw new IllegalArgumentException("gtol must be >= 0 "); if( xtol < 0 ) throw new IllegalArgumentException("xtol must be >= 0 "); thi...
[ "public", "LineSearchMore94", "setConvergence", "(", "double", "ftol", ",", "double", "gtol", ",", "double", "xtol", ")", "{", "if", "(", "ftol", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"ftol must be >= 0 \"", ")", ";", "if", "(", "...
Configures the line search. @param ftol Tolerance for sufficient decrease. ftol {@code >} 0. Smaller value for loose tolerance. Try 1e-4 @param gtol Tolerance for curvature condition. gtol &ge; 0. Larger value for loose tolerance. Try 0.9 @param xtol Relative tolerance for acceptable step. xtol &ge; 0. Larger value ...
[ "Configures", "the", "line", "search", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L124-L136
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.dcstep
private void dcstep() { double sgnd = gp*Math.signum(gx); // the new step double stpf; if( fp > fx ) { stpf = handleCase1(); } else if( sgnd < 0 ) { stpf = handleCase2(); } else if( Math.abs(gp) < Math.abs(gx) ) { stpf = handleCase3(); } else { stpf = handleCase4(); } // update the brac...
java
private void dcstep() { double sgnd = gp*Math.signum(gx); // the new step double stpf; if( fp > fx ) { stpf = handleCase1(); } else if( sgnd < 0 ) { stpf = handleCase2(); } else if( Math.abs(gp) < Math.abs(gx) ) { stpf = handleCase3(); } else { stpf = handleCase4(); } // update the brac...
[ "private", "void", "dcstep", "(", ")", "{", "double", "sgnd", "=", "gp", "*", "Math", ".", "signum", "(", "gx", ")", ";", "// the new step", "double", "stpf", ";", "if", "(", "fp", ">", "fx", ")", "{", "stpf", "=", "handleCase1", "(", ")", ";", "...
Computes the new step and updates fx,fy,gx,dy.
[ "Computes", "the", "new", "step", "and", "updates", "fx", "fy", "gx", "dy", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L311-L347
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase1
private double handleCase1() { double stpc = SearchInterpolate.cubic2(fx, gx, stx, fp, gp, stp); double stpq = SearchInterpolate.quadratic(fx,gx,stx,fp,stp); // If the cubic step is closer to stx than the quadratic step take that bracket = true; if( Math.abs(stpc-stx) < Math.abs(stpq-stx)) { return stpc;...
java
private double handleCase1() { double stpc = SearchInterpolate.cubic2(fx, gx, stx, fp, gp, stp); double stpq = SearchInterpolate.quadratic(fx,gx,stx,fp,stp); // If the cubic step is closer to stx than the quadratic step take that bracket = true; if( Math.abs(stpc-stx) < Math.abs(stpq-stx)) { return stpc;...
[ "private", "double", "handleCase1", "(", ")", "{", "double", "stpc", "=", "SearchInterpolate", ".", "cubic2", "(", "fx", ",", "gx", ",", "stx", ",", "fp", ",", "gp", ",", "stp", ")", ";", "double", "stpq", "=", "SearchInterpolate", ".", "quadratic", "(...
stp has a higher value than stx. The minimum must be between these two values. Pick a point which is close to stx since it has a lower value. @return The new step.
[ "stp", "has", "a", "higher", "value", "than", "stx", ".", "The", "minimum", "must", "be", "between", "these", "two", "values", ".", "Pick", "a", "point", "which", "is", "close", "to", "stx", "since", "it", "has", "a", "lower", "value", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L355-L368
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase2
private double handleCase2() { double stpc = SearchInterpolate.cubic2(fp, gp, stp, fx, gx, stx); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); // use which ever is closest to stp since it is lower than stx bracket = true; if( Math.abs(stpc - stp) > Math.abs(stpq - stp)) { return stpc; } els...
java
private double handleCase2() { double stpc = SearchInterpolate.cubic2(fp, gp, stp, fx, gx, stx); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); // use which ever is closest to stp since it is lower than stx bracket = true; if( Math.abs(stpc - stp) > Math.abs(stpq - stp)) { return stpc; } els...
[ "private", "double", "handleCase2", "(", ")", "{", "double", "stpc", "=", "SearchInterpolate", ".", "cubic2", "(", "fp", ",", "gp", ",", "stp", ",", "fx", ",", "gx", ",", "stx", ")", ";", "double", "stpq", "=", "SearchInterpolate", ".", "quadratic2", "...
The sign of the derivative has swapped, indicating that the function is on the other side of the dip and that a bracket has been found. @return The new step.
[ "The", "sign", "of", "the", "derivative", "has", "swapped", "indicating", "that", "the", "function", "is", "on", "the", "other", "side", "of", "the", "dip", "and", "that", "a", "bracket", "has", "been", "found", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L376-L387
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase3
private double handleCase3() { double stpf; // use cubic interpolation only if it is safe double stpc = SearchInterpolate.cubicSafe(fp, gp, stp, fx, gx, stx, stmin, stmax); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); if( bracket ) { // Use which ever step is closer to stp if( Math.abs(st...
java
private double handleCase3() { double stpf; // use cubic interpolation only if it is safe double stpc = SearchInterpolate.cubicSafe(fp, gp, stp, fx, gx, stx, stmin, stmax); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); if( bracket ) { // Use which ever step is closer to stp if( Math.abs(st...
[ "private", "double", "handleCase3", "(", ")", "{", "double", "stpf", ";", "// use cubic interpolation only if it is safe", "double", "stpc", "=", "SearchInterpolate", ".", "cubicSafe", "(", "fp", ",", "gp", ",", "stp", ",", "fx", ",", "gx", ",", "stx", ",", ...
The derivative at stp has a smaller magnitude than at stx and is likely to be closer to the minimum. However there are special cases that need to be dealt with here. @return The new step.
[ "The", "derivative", "at", "stp", "has", "a", "smaller", "magnitude", "than", "at", "stx", "and", "is", "likely", "to", "be", "closer", "to", "the", "minimum", ".", "However", "there", "are", "special", "cases", "that", "need", "to", "be", "dealt", "with...
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L395-L424
train
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase4
private double handleCase4() { if( bracket ) { return SearchInterpolate.cubic2(fp, gp, stp, fy, gy, sty); } else if( stp > stx ) { return stmax; // see comment in case 3 about stmax and stmin } else { return stmin; } }
java
private double handleCase4() { if( bracket ) { return SearchInterpolate.cubic2(fp, gp, stp, fy, gy, sty); } else if( stp > stx ) { return stmax; // see comment in case 3 about stmax and stmin } else { return stmin; } }
[ "private", "double", "handleCase4", "(", ")", "{", "if", "(", "bracket", ")", "{", "return", "SearchInterpolate", ".", "cubic2", "(", "fp", ",", "gp", ",", "stp", ",", "fy", ",", "gy", ",", "sty", ")", ";", "}", "else", "if", "(", "stp", ">", "st...
Lower function value. On the same side of the dip because the gradients have the same sign. The magnitude of the derivative did not decrease. @return The new step.
[ "Lower", "function", "value", ".", "On", "the", "same", "side", "of", "the", "dip", "because", "the", "gradients", "have", "the", "same", "sign", ".", "The", "magnitude", "of", "the", "derivative", "did", "not", "decrease", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L432-L440
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/AxisSplitterMedian.java
AxisSplitterMedian.computeAxisVariance
private void computeAxisVariance(List<P> points) { int numPoints = points.size(); for( int i = 0; i < N; i++ ) { mean[i] = 0; var[i] = 0; } // compute the mean for( int i = 0; i < numPoints; i++ ) { P p = points.get(i); for( int j = 0; j < N; j++ ) { mean[j] += distance.valueAt(p,j); } ...
java
private void computeAxisVariance(List<P> points) { int numPoints = points.size(); for( int i = 0; i < N; i++ ) { mean[i] = 0; var[i] = 0; } // compute the mean for( int i = 0; i < numPoints; i++ ) { P p = points.get(i); for( int j = 0; j < N; j++ ) { mean[j] += distance.valueAt(p,j); } ...
[ "private", "void", "computeAxisVariance", "(", "List", "<", "P", ">", "points", ")", "{", "int", "numPoints", "=", "points", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "mean", "["...
Select the maximum variance as the split
[ "Select", "the", "maximum", "variance", "as", "the", "split" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/AxisSplitterMedian.java#L145-L175
train
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/AxisSplitterMedian.java
AxisSplitterMedian.quickSelect
private void quickSelect(List<P> points, int splitAxis, int medianNum) { int numPoints = points.size(); if( tmp.length < numPoints ) { tmp = new double[numPoints]; indexes = new int[ numPoints ]; } for( int i = 0; i < numPoints; i++ ) { tmp[i] = distance.valueAt(points.get(i),splitAxis); } QuickS...
java
private void quickSelect(List<P> points, int splitAxis, int medianNum) { int numPoints = points.size(); if( tmp.length < numPoints ) { tmp = new double[numPoints]; indexes = new int[ numPoints ]; } for( int i = 0; i < numPoints; i++ ) { tmp[i] = distance.valueAt(points.get(i),splitAxis); } QuickS...
[ "private", "void", "quickSelect", "(", "List", "<", "P", ">", "points", ",", "int", "splitAxis", ",", "int", "medianNum", ")", "{", "int", "numPoints", "=", "points", ".", "size", "(", ")", ";", "if", "(", "tmp", ".", "length", "<", "numPoints", ")",...
Uses quick-select to find the median value
[ "Uses", "quick", "-", "select", "to", "find", "the", "median", "value" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/AxisSplitterMedian.java#L180-L192
train
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.init
public void init( List<T> list , int bucketSize ) { if( list.size() < bucketSize ) { throw new RuntimeException("There needs to be more than or equal to elements in the 'list' that there are in the bucket"); } this.k = bucketSize; this.c = bucketSize - 1; N = list.size(); bins = new int[ bucketSize ]; ...
java
public void init( List<T> list , int bucketSize ) { if( list.size() < bucketSize ) { throw new RuntimeException("There needs to be more than or equal to elements in the 'list' that there are in the bucket"); } this.k = bucketSize; this.c = bucketSize - 1; N = list.size(); bins = new int[ bucketSize ]; ...
[ "public", "void", "init", "(", "List", "<", "T", ">", "list", ",", "int", "bucketSize", ")", "{", "if", "(", "list", ".", "size", "(", ")", "<", "bucketSize", ")", "{", "throw", "new", "RuntimeException", "(", "\"There needs to be more than or equal to eleme...
Initialize with a new list and bucket size @param list List which is to be symbols @param bucketSize Size of the bucket
[ "Initialize", "with", "a", "new", "list", "and", "bucket", "size" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L95-L112
train
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.next
public boolean next() { if( state == 2 ) return false; else state = 1; bins[c]++; if( bins[c] >= N ) { boolean allgood = false; for( int i = c-1; i >= 0; i-- ) { bins[i]++; if( bins[i] <= (N-(k-i)) ) { allgood = true; for( int j = i + 1; j < k; j++ ) { bins[j] = bins[j-1]...
java
public boolean next() { if( state == 2 ) return false; else state = 1; bins[c]++; if( bins[c] >= N ) { boolean allgood = false; for( int i = c-1; i >= 0; i-- ) { bins[i]++; if( bins[i] <= (N-(k-i)) ) { allgood = true; for( int j = i + 1; j < k; j++ ) { bins[j] = bins[j-1]...
[ "public", "boolean", "next", "(", ")", "{", "if", "(", "state", "==", "2", ")", "return", "false", ";", "else", "state", "=", "1", ";", "bins", "[", "c", "]", "++", ";", "if", "(", "bins", "[", "c", "]", ">=", "N", ")", "{", "boolean", "allgo...
This will shuffle the elements in and out of the bins. When all combinations have been exhausted an ExhaustedException will be thrown. @return true if the next combination was successfully found or false is it has been exhausted
[ "This", "will", "shuffle", "the", "elements", "in", "and", "out", "of", "the", "bins", ".", "When", "all", "combinations", "have", "been", "exhausted", "an", "ExhaustedException", "will", "be", "thrown", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L121-L155
train
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.getBucket
public List<T> getBucket(List<T> storage) { if( storage == null ) storage = new ArrayList<T>(); else storage.clear(); for( int i = 0; i < bins.length; i++ ) { storage.add( a.get( bins[i] ) ); } return storage; }
java
public List<T> getBucket(List<T> storage) { if( storage == null ) storage = new ArrayList<T>(); else storage.clear(); for( int i = 0; i < bins.length; i++ ) { storage.add( a.get( bins[i] ) ); } return storage; }
[ "public", "List", "<", "T", ">", "getBucket", "(", "List", "<", "T", ">", "storage", ")", "{", "if", "(", "storage", "==", "null", ")", "storage", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "else", "storage", ".", "clear", "(", ")", ...
Extracts the entire bucket. Will add elements to the provided list or create a new one @param storage Optional storage. If null a list is created. clear() is automatically called. @return List containing the bucket
[ "Extracts", "the", "entire", "bucket", ".", "Will", "add", "elements", "to", "the", "provided", "list", "or", "create", "a", "new", "one" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L236-L248
train
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.getOutside
public List<T> getOutside( List<T> storage ) { if( storage == null ) { storage = new ArrayList<T>(); } else { storage.clear(); } storage.addAll(a); // bins specifies elements in order of first in 'a' to last for( int i = bins.length-1; i >= 0; i-- ) { storage.remove(bins[i]); } return stor...
java
public List<T> getOutside( List<T> storage ) { if( storage == null ) { storage = new ArrayList<T>(); } else { storage.clear(); } storage.addAll(a); // bins specifies elements in order of first in 'a' to last for( int i = bins.length-1; i >= 0; i-- ) { storage.remove(bins[i]); } return stor...
[ "public", "List", "<", "T", ">", "getOutside", "(", "List", "<", "T", ">", "storage", ")", "{", "if", "(", "storage", "==", "null", ")", "{", "storage", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "}", "else", "{", "storage", ".", "c...
This returns all the items that are not currently inside the bucket @param storage Optional storage. If null a list is created. clear() is automatically called. @return List containing the bucket
[ "This", "returns", "all", "the", "items", "that", "are", "not", "currently", "inside", "the", "bucket" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L256-L272
train
lessthanoptimal/ddogleg
src/org/ddogleg/fitting/modelset/distance/FitByMedianStatistics.java
FitByMedianStatistics.prune
@Override public void prune() { Iterator<PointIndex<Point>> iter = allPoints.iterator(); int index = 0; while( iter.hasNext() ) { iter.next(); if (origErrors[index++] >= pruneVal) { iter.remove(); } } }
java
@Override public void prune() { Iterator<PointIndex<Point>> iter = allPoints.iterator(); int index = 0; while( iter.hasNext() ) { iter.next(); if (origErrors[index++] >= pruneVal) { iter.remove(); } } }
[ "@", "Override", "public", "void", "prune", "(", ")", "{", "Iterator", "<", "PointIndex", "<", "Point", ">>", "iter", "=", "allPoints", ".", "iterator", "(", ")", ";", "int", "index", "=", "0", ";", "while", "(", "iter", ".", "hasNext", "(", ")", "...
Removes all samples which have an error larger than the specified percentile error.
[ "Removes", "all", "samples", "which", "have", "an", "error", "larger", "than", "the", "specified", "percentile", "error", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/fitting/modelset/distance/FitByMedianStatistics.java#L100-L110
train