repo stringclasses 11 values | path stringlengths 41 214 | func_name stringlengths 7 82 | original_string stringlengths 77 11.9k | language stringclasses 1 value | code stringlengths 77 11.9k | code_tokens listlengths 22 1.57k | docstring stringlengths 2 2.27k | docstring_tokens listlengths 1 352 | sha stringclasses 11 values | url stringlengths 129 319 | partition stringclasses 1 value | summary stringlengths 7 191 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
hankcs/HanLP | src/main/java/com/hankcs/hanlp/utility/TextUtility.java | TextUtility.cint | public static int cint(String str)
{
if (str != null)
try
{
int i = new Integer(str).intValue();
return i;
}
catch (NumberFormatException e)
{
}
return -1;
} | java | public static int cint(String str)
{
if (str != null)
try
{
int i = new Integer(str).intValue();
return i;
}
catch (NumberFormatException e)
{
}
return -1;
} | [
"public",
"static",
"int",
"cint",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"!=",
"null",
")",
"try",
"{",
"int",
"i",
"=",
"new",
"Integer",
"(",
"str",
")",
".",
"intValue",
"(",
")",
";",
"return",
"i",
";",
"}",
"catch",
"(",
"Numb... | 把表示数字含义的字符串转成整形
@param str 要转换的字符串
@return 如果是有意义的整数,则返回此整数值。否则,返回-1。 | [
"把表示数字含义的字符串转成整形"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/utility/TextUtility.java#L133-L147 | train | Get the cint value of a String. | [
30522,
2270,
10763,
20014,
25022,
3372,
1006,
5164,
2358,
2099,
1007,
1063,
2065,
1006,
2358,
2099,
999,
1027,
19701,
1007,
3046,
1063,
20014,
1045,
1027,
2047,
16109,
1006,
2358,
2099,
1007,
1012,
20014,
10175,
5657,
1006,
1007,
1025,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/ClosableBlockingQueue.java | ClosableBlockingQueue.getElementBlocking | public E getElementBlocking() throws InterruptedException {
lock.lock();
try {
while (open && elements.isEmpty()) {
nonEmpty.await();
}
if (open) {
return elements.removeFirst();
} else {
throw new IllegalStateException("queue is closed");
}
} finally {
lock.unlock();
}
} | java | public E getElementBlocking() throws InterruptedException {
lock.lock();
try {
while (open && elements.isEmpty()) {
nonEmpty.await();
}
if (open) {
return elements.removeFirst();
} else {
throw new IllegalStateException("queue is closed");
}
} finally {
lock.unlock();
}
} | [
"public",
"E",
"getElementBlocking",
"(",
")",
"throws",
"InterruptedException",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"while",
"(",
"open",
"&&",
"elements",
".",
"isEmpty",
"(",
")",
")",
"{",
"nonEmpty",
".",
"await",
"(",
")",
";",
... | Returns the next element in the queue. If the queue is empty, this method
waits until at least one element is added.
<p>The method throws an {@code IllegalStateException} if the queue is closed.
Checking whether the queue is open and removing the next element is one atomic operation.
@return The next element in the queue, never null.
@throws IllegalStateException Thrown, if the queue is closed.
@throws InterruptedException Throw, if the thread is interrupted while waiting for an
element to be added. | [
"Returns",
"the",
"next",
"element",
"in",
"the",
"queue",
".",
"If",
"the",
"queue",
"is",
"empty",
"this",
"method",
"waits",
"until",
"at",
"least",
"one",
"element",
"is",
"added",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/ClosableBlockingQueue.java#L320-L335 | train | Get the next element from the queue blocking until it is empty. | [
30522,
2270,
1041,
2131,
12260,
3672,
23467,
2075,
1006,
1007,
11618,
7153,
10288,
24422,
1063,
5843,
1012,
5843,
1006,
1007,
1025,
3046,
1063,
2096,
1006,
2330,
1004,
1004,
3787,
1012,
2003,
6633,
13876,
2100,
1006,
1007,
1007,
1063,
3904,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java | ZipUtil.addFile | private static void addFile(File file, String path, ZipOutputStream out) throws UtilException {
BufferedInputStream in = null;
try {
in = FileUtil.getInputStream(file);
addFile(in, path, out);
} finally {
IoUtil.close(in);
}
} | java | private static void addFile(File file, String path, ZipOutputStream out) throws UtilException {
BufferedInputStream in = null;
try {
in = FileUtil.getInputStream(file);
addFile(in, path, out);
} finally {
IoUtil.close(in);
}
} | [
"private",
"static",
"void",
"addFile",
"(",
"File",
"file",
",",
"String",
"path",
",",
"ZipOutputStream",
"out",
")",
"throws",
"UtilException",
"{",
"BufferedInputStream",
"in",
"=",
"null",
";",
"try",
"{",
"in",
"=",
"FileUtil",
".",
"getInputStream",
"... | 添加文件到压缩包
@param file 需要压缩的文件
@param path 在压缩文件中的路径
@param out 压缩文件存储对象
@throws UtilException IO异常
@since 4.0.5 | [
"添加文件到压缩包"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java#L802-L810 | train | Adds a file to a zip output stream. | [
30522,
2797,
10763,
11675,
5587,
8873,
2571,
1006,
5371,
5371,
1010,
5164,
4130,
1010,
14101,
5833,
18780,
21422,
2041,
1007,
11618,
21183,
9463,
2595,
24422,
1063,
17698,
2098,
2378,
18780,
21422,
1999,
1027,
19701,
1025,
3046,
1063,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/MetricRegistry.java | MetricRegistry.addListener | public void addListener(MetricRegistryListener listener) {
listeners.add(listener);
for (Map.Entry<MetricName, Metric> entry : metrics.entrySet()) {
notifyListenerOfAddedMetric(listener, entry.getValue(), entry.getKey());
}
} | java | public void addListener(MetricRegistryListener listener) {
listeners.add(listener);
for (Map.Entry<MetricName, Metric> entry : metrics.entrySet()) {
notifyListenerOfAddedMetric(listener, entry.getValue(), entry.getKey());
}
} | [
"public",
"void",
"addListener",
"(",
"MetricRegistryListener",
"listener",
")",
"{",
"listeners",
".",
"add",
"(",
"listener",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"MetricName",
",",
"Metric",
">",
"entry",
":",
"metrics",
".",
"entrySet",
"(",... | Adds a {@link MetricRegistryListener} to a collection of listeners that will be notified on
metric creation. Listeners will be notified in the order in which they are added.
<b>N.B.:</b> The listener will be notified of all existing metrics when it first registers.
@param listener the listener that will be notified | [
"Adds",
"a",
"{",
"@link",
"MetricRegistryListener",
"}",
"to",
"a",
"collection",
"of",
"listeners",
"that",
"will",
"be",
"notified",
"on",
"metric",
"creation",
".",
"Listeners",
"will",
"be",
"notified",
"in",
"the",
"order",
"in",
"which",
"they",
"are"... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/MetricRegistry.java#L274-L280 | train | Add a listener to be notified of metrics added to the registry. | [
30522,
2270,
11675,
5587,
9863,
24454,
1006,
12046,
2890,
24063,
23320,
27870,
3678,
19373,
1007,
1063,
13810,
1012,
5587,
1006,
19373,
1007,
1025,
2005,
1006,
4949,
1012,
4443,
1026,
12046,
18442,
1010,
12046,
1028,
4443,
1024,
12046,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java | CollUtil.zip | public static Map<String, String> zip(String keys, String values, String delimiter) {
return zip(keys, values, delimiter, false);
} | java | public static Map<String, String> zip(String keys, String values, String delimiter) {
return zip(keys, values, delimiter, false);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"zip",
"(",
"String",
"keys",
",",
"String",
"values",
",",
"String",
"delimiter",
")",
"{",
"return",
"zip",
"(",
"keys",
",",
"values",
",",
"delimiter",
",",
"false",
")",
";",
"}"
] | 映射键值(参考Python的zip()函数),返回Map无序<br>
例如:<br>
keys = a,b,c,d<br>
values = 1,2,3,4<br>
delimiter = , 则得到的Map是 {a=1, b=2, c=3, d=4}<br>
如果两个数组长度不同,则只对应最短部分
@param keys 键列表
@param values 值列表
@param delimiter 分隔符
@return Map | [
"映射键值(参考Python的zip",
"()",
"函数),返回Map无序<br",
">",
"例如:<br",
">",
"keys",
"=",
"a",
"b",
"c",
"d<br",
">",
"values",
"=",
"1",
"2",
"3",
"4<br",
">",
"delimiter",
"=",
"则得到的Map是",
"{",
"a",
"=",
"1",
"b",
"=",
"2",
"c",
"=",
"3",
"d",
"=",
"4",
... | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java#L1468-L1470 | train | Create a map of strings from the given strings. | [
30522,
2270,
10763,
4949,
1026,
5164,
1010,
5164,
1028,
14101,
1006,
5164,
6309,
1010,
5164,
5300,
1010,
5164,
3972,
27605,
3334,
1007,
1063,
2709,
14101,
1006,
6309,
1010,
5300,
1010,
3972,
27605,
3334,
1010,
6270,
1007,
1025,
1065,
102,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/sharedbuffer/SharedBuffer.java | SharedBuffer.removeEntry | void removeEntry(NodeId nodeId) throws Exception {
this.entryCache.remove(nodeId);
this.entries.remove(nodeId);
} | java | void removeEntry(NodeId nodeId) throws Exception {
this.entryCache.remove(nodeId);
this.entries.remove(nodeId);
} | [
"void",
"removeEntry",
"(",
"NodeId",
"nodeId",
")",
"throws",
"Exception",
"{",
"this",
".",
"entryCache",
".",
"remove",
"(",
"nodeId",
")",
";",
"this",
".",
"entries",
".",
"remove",
"(",
"nodeId",
")",
";",
"}"
] | Removes a ShareBufferNode from cache and state.
@param nodeId id of the event | [
"Removes",
"a",
"ShareBufferNode",
"from",
"cache",
"and",
"state",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/sharedbuffer/SharedBuffer.java#L191-L194 | train | Remove the entry for the given nodeId from the cache and entries. | [
30522,
11675,
6366,
4765,
2854,
1006,
13045,
3593,
13045,
3593,
1007,
11618,
6453,
1063,
2023,
1012,
4443,
3540,
5403,
1012,
6366,
1006,
13045,
3593,
1007,
1025,
2023,
1012,
10445,
1012,
6366,
1006,
13045,
3593,
1007,
1025,
1065,
102,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java | DirectLogFetcher.open | public void open(Connection conn, String fileName, final int serverId, boolean nonBlocking) throws IOException {
open(conn, fileName, BIN_LOG_HEADER_SIZE, serverId, nonBlocking);
} | java | public void open(Connection conn, String fileName, final int serverId, boolean nonBlocking) throws IOException {
open(conn, fileName, BIN_LOG_HEADER_SIZE, serverId, nonBlocking);
} | [
"public",
"void",
"open",
"(",
"Connection",
"conn",
",",
"String",
"fileName",
",",
"final",
"int",
"serverId",
",",
"boolean",
"nonBlocking",
")",
"throws",
"IOException",
"{",
"open",
"(",
"conn",
",",
"fileName",
",",
"BIN_LOG_HEADER_SIZE",
",",
"serverId"... | Connect MySQL master to fetch binlog. | [
"Connect",
"MySQL",
"master",
"to",
"fetch",
"binlog",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java#L154-L156 | train | Opens a new instance of the base class. | [
30522,
2270,
11675,
2330,
1006,
4434,
9530,
2078,
1010,
5164,
5371,
18442,
1010,
2345,
20014,
8241,
3593,
1010,
22017,
20898,
2512,
23467,
2075,
1007,
11618,
22834,
10288,
24422,
1063,
2330,
1006,
9530,
2078,
1010,
5371,
18442,
1010,
8026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/StatementUtil.java | StatementUtil.fillParams | public static PreparedStatement fillParams(PreparedStatement ps, Object... params) throws SQLException {
if (ArrayUtil.isEmpty(params)) {
return ps;// 无参数
}
Object param;
for (int i = 0; i < params.length; i++) {
int paramIndex = i + 1;
param = params[i];
if (null != param) {
if (param instanceof java.util.Date) {
// 日期特殊处理
if (param instanceof java.sql.Date) {
ps.setDate(paramIndex, (java.sql.Date) param);
} else if (param instanceof java.sql.Time) {
ps.setTime(paramIndex, (java.sql.Time) param);
} else {
ps.setTimestamp(paramIndex, SqlUtil.toSqlTimestamp((java.util.Date) param));
}
} else if (param instanceof Number) {
// 针对大数字类型的特殊处理
if (param instanceof BigInteger) {
// BigInteger转为Long
ps.setLong(paramIndex, ((BigInteger) param).longValue());
} else if (param instanceof BigDecimal) {
// BigDecimal的转换交给JDBC驱动处理
ps.setBigDecimal(paramIndex, (BigDecimal) param);
} else {
// 普通数字类型按照默认传入
ps.setObject(paramIndex, param);
}
} else {
ps.setObject(paramIndex, param);
}
} else {
final ParameterMetaData pmd = ps.getParameterMetaData();
int sqlType = Types.VARCHAR;
try {
sqlType = pmd.getParameterType(paramIndex);
} catch (SQLException e) {
// ignore
// log.warn("Null param of index [{}] type get failed, by: {}", paramIndex, e.getMessage());
}
ps.setNull(paramIndex, sqlType);
}
}
return ps;
} | java | public static PreparedStatement fillParams(PreparedStatement ps, Object... params) throws SQLException {
if (ArrayUtil.isEmpty(params)) {
return ps;// 无参数
}
Object param;
for (int i = 0; i < params.length; i++) {
int paramIndex = i + 1;
param = params[i];
if (null != param) {
if (param instanceof java.util.Date) {
// 日期特殊处理
if (param instanceof java.sql.Date) {
ps.setDate(paramIndex, (java.sql.Date) param);
} else if (param instanceof java.sql.Time) {
ps.setTime(paramIndex, (java.sql.Time) param);
} else {
ps.setTimestamp(paramIndex, SqlUtil.toSqlTimestamp((java.util.Date) param));
}
} else if (param instanceof Number) {
// 针对大数字类型的特殊处理
if (param instanceof BigInteger) {
// BigInteger转为Long
ps.setLong(paramIndex, ((BigInteger) param).longValue());
} else if (param instanceof BigDecimal) {
// BigDecimal的转换交给JDBC驱动处理
ps.setBigDecimal(paramIndex, (BigDecimal) param);
} else {
// 普通数字类型按照默认传入
ps.setObject(paramIndex, param);
}
} else {
ps.setObject(paramIndex, param);
}
} else {
final ParameterMetaData pmd = ps.getParameterMetaData();
int sqlType = Types.VARCHAR;
try {
sqlType = pmd.getParameterType(paramIndex);
} catch (SQLException e) {
// ignore
// log.warn("Null param of index [{}] type get failed, by: {}", paramIndex, e.getMessage());
}
ps.setNull(paramIndex, sqlType);
}
}
return ps;
} | [
"public",
"static",
"PreparedStatement",
"fillParams",
"(",
"PreparedStatement",
"ps",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"ArrayUtil",
".",
"isEmpty",
"(",
"params",
")",
")",
"{",
"return",
"ps",
";",
"// 无参数\r",
... | 填充SQL的参数。<br>
对于日期对象特殊处理:传入java.util.Date默认按照Timestamp处理
@param ps PreparedStatement
@param params SQL参数
@return {@link PreparedStatement}
@throws SQLException SQL执行异常 | [
"填充SQL的参数。<br",
">",
"对于日期对象特殊处理:传入java",
".",
"util",
".",
"Date默认按照Timestamp处理"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/StatementUtil.java#L53-L99 | train | Fill the given PreparedStatement with the data from the given parameters. | [
30522,
2270,
10763,
4810,
9153,
18532,
4765,
6039,
28689,
5244,
1006,
4810,
9153,
18532,
4765,
8827,
1010,
4874,
1012,
1012,
1012,
11498,
5244,
1007,
11618,
29296,
10288,
24422,
1063,
2065,
1006,
9140,
21823,
2140,
1012,
2003,
6633,
13876,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/accumulators/AccumulatorHelper.java | AccumulatorHelper.compareAccumulatorTypes | @SuppressWarnings("rawtypes")
public static void compareAccumulatorTypes(
Object name,
Class<? extends Accumulator> first,
Class<? extends Accumulator> second) throws UnsupportedOperationException {
if (first == null || second == null) {
throw new NullPointerException();
}
if (first != second) {
if (!first.getName().equals(second.getName())) {
throw new UnsupportedOperationException("The accumulator object '" + name
+ "' was created with two different types: " + first.getName() + " and " + second.getName());
} else {
// damn, name is the same, but different classloaders
throw new UnsupportedOperationException("The accumulator object '" + name
+ "' was created with two different classes: " + first + " and " + second
+ " Both have the same type (" + first.getName() + ") but different classloaders: "
+ first.getClassLoader() + " and " + second.getClassLoader());
}
}
} | java | @SuppressWarnings("rawtypes")
public static void compareAccumulatorTypes(
Object name,
Class<? extends Accumulator> first,
Class<? extends Accumulator> second) throws UnsupportedOperationException {
if (first == null || second == null) {
throw new NullPointerException();
}
if (first != second) {
if (!first.getName().equals(second.getName())) {
throw new UnsupportedOperationException("The accumulator object '" + name
+ "' was created with two different types: " + first.getName() + " and " + second.getName());
} else {
// damn, name is the same, but different classloaders
throw new UnsupportedOperationException("The accumulator object '" + name
+ "' was created with two different classes: " + first + " and " + second
+ " Both have the same type (" + first.getName() + ") but different classloaders: "
+ first.getClassLoader() + " and " + second.getClassLoader());
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"void",
"compareAccumulatorTypes",
"(",
"Object",
"name",
",",
"Class",
"<",
"?",
"extends",
"Accumulator",
">",
"first",
",",
"Class",
"<",
"?",
"extends",
"Accumulator",
">",
"second",
")... | Compare both classes and throw {@link UnsupportedOperationException} if
they differ. | [
"Compare",
"both",
"classes",
"and",
"throw",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/accumulators/AccumulatorHelper.java#L100-L121 | train | Compare two accumulator objects. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
6315,
13874,
2015,
1000,
1007,
2270,
10763,
11675,
12826,
6305,
24894,
20350,
13874,
2015,
1006,
4874,
2171,
1010,
2465,
1026,
1029,
8908,
16222,
2819,
20350,
1028,
2034,
1010,
2465,
1026,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-socket/src/main/java/cn/hutool/socket/aio/AioServer.java | AioServer.init | public AioServer init(InetSocketAddress address) {
try {
this.group = AsynchronousChannelGroup.withFixedThreadPool(//
config.getThreadPoolSize(), // 默认线程池大小
ThreadFactoryBuilder.create().setNamePrefix("Hutool-socket-").build()//
);
this.channel = AsynchronousServerSocketChannel.open(group).bind(address);
} catch (IOException e) {
throw new IORuntimeException(e);
}
return this;
} | java | public AioServer init(InetSocketAddress address) {
try {
this.group = AsynchronousChannelGroup.withFixedThreadPool(//
config.getThreadPoolSize(), // 默认线程池大小
ThreadFactoryBuilder.create().setNamePrefix("Hutool-socket-").build()//
);
this.channel = AsynchronousServerSocketChannel.open(group).bind(address);
} catch (IOException e) {
throw new IORuntimeException(e);
}
return this;
} | [
"public",
"AioServer",
"init",
"(",
"InetSocketAddress",
"address",
")",
"{",
"try",
"{",
"this",
".",
"group",
"=",
"AsynchronousChannelGroup",
".",
"withFixedThreadPool",
"(",
"//\r",
"config",
".",
"getThreadPoolSize",
"(",
")",
",",
"// 默认线程池大小\r",
"ThreadFact... | 初始化
@param address 地址和端口
@return this | [
"初始化"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-socket/src/main/java/cn/hutool/socket/aio/AioServer.java#L60-L71 | train | Initializes the server with the given address. | [
30522,
2270,
9932,
9232,
2099,
6299,
1999,
4183,
1006,
1999,
8454,
7432,
12928,
14141,
8303,
4769,
1007,
1063,
3046,
1063,
2023,
1012,
2177,
1027,
2004,
6038,
2818,
4948,
3560,
26058,
17058,
1012,
2007,
23901,
2705,
16416,
18927,
13669,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | java/server/src/org/openqa/grid/internal/utils/configuration/StandaloneConfiguration.java | StandaloneConfiguration.merge | public void merge(StandaloneConfiguration other) {
if (other == null) {
return;
}
if (isMergeAble(Integer.class, other.browserTimeout, browserTimeout)) {
browserTimeout = other.browserTimeout;
}
if (isMergeAble(Integer.class, other.jettyMaxThreads, jettyMaxThreads)) {
jettyMaxThreads = other.jettyMaxThreads;
}
if (isMergeAble(Integer.class, other.timeout, timeout)) {
timeout = other.timeout;
}
// role, host, port, log, debug, version, enablePassThrough, and help are not merged,
// they are only consumed by the immediately running process and should never affect a remote
} | java | public void merge(StandaloneConfiguration other) {
if (other == null) {
return;
}
if (isMergeAble(Integer.class, other.browserTimeout, browserTimeout)) {
browserTimeout = other.browserTimeout;
}
if (isMergeAble(Integer.class, other.jettyMaxThreads, jettyMaxThreads)) {
jettyMaxThreads = other.jettyMaxThreads;
}
if (isMergeAble(Integer.class, other.timeout, timeout)) {
timeout = other.timeout;
}
// role, host, port, log, debug, version, enablePassThrough, and help are not merged,
// they are only consumed by the immediately running process and should never affect a remote
} | [
"public",
"void",
"merge",
"(",
"StandaloneConfiguration",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isMergeAble",
"(",
"Integer",
".",
"class",
",",
"other",
".",
"browserTimeout",
",",
"browserTimeout"... | copy another configuration's values into this one if they are set. | [
"copy",
"another",
"configuration",
"s",
"values",
"into",
"this",
"one",
"if",
"they",
"are",
"set",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/grid/internal/utils/configuration/StandaloneConfiguration.java#L180-L196 | train | Merge the configuration with another configuration. | [
30522,
2270,
11675,
13590,
1006,
26609,
8663,
8873,
27390,
3370,
2060,
1007,
1063,
2065,
1006,
2060,
1027,
1027,
19701,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
2003,
5017,
3351,
3085,
1006,
16109,
1012,
2465,
1010,
2060,
1012,
16602,
7292... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/BinaryInMemorySortBuffer.java | BinaryInMemorySortBuffer.getIterator | public final MutableObjectIterator<BinaryRow> getIterator() {
return new MutableObjectIterator<BinaryRow>() {
private final int size = size();
private int current = 0;
private int currentSegment = 0;
private int currentOffset = 0;
private MemorySegment currentIndexSegment = sortIndex.get(0);
@Override
public BinaryRow next(BinaryRow target) {
if (this.current < this.size) {
this.current++;
if (this.currentOffset > lastIndexEntryOffset) {
this.currentOffset = 0;
this.currentIndexSegment = sortIndex.get(++this.currentSegment);
}
long pointer = this.currentIndexSegment.getLong(this.currentOffset);
this.currentOffset += indexEntrySize;
try {
return getRecordFromBuffer(target, pointer);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} else {
return null;
}
}
@Override
public BinaryRow next() {
throw new RuntimeException("Not support!");
}
};
} | java | public final MutableObjectIterator<BinaryRow> getIterator() {
return new MutableObjectIterator<BinaryRow>() {
private final int size = size();
private int current = 0;
private int currentSegment = 0;
private int currentOffset = 0;
private MemorySegment currentIndexSegment = sortIndex.get(0);
@Override
public BinaryRow next(BinaryRow target) {
if (this.current < this.size) {
this.current++;
if (this.currentOffset > lastIndexEntryOffset) {
this.currentOffset = 0;
this.currentIndexSegment = sortIndex.get(++this.currentSegment);
}
long pointer = this.currentIndexSegment.getLong(this.currentOffset);
this.currentOffset += indexEntrySize;
try {
return getRecordFromBuffer(target, pointer);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} else {
return null;
}
}
@Override
public BinaryRow next() {
throw new RuntimeException("Not support!");
}
};
} | [
"public",
"final",
"MutableObjectIterator",
"<",
"BinaryRow",
">",
"getIterator",
"(",
")",
"{",
"return",
"new",
"MutableObjectIterator",
"<",
"BinaryRow",
">",
"(",
")",
"{",
"private",
"final",
"int",
"size",
"=",
"size",
"(",
")",
";",
"private",
"int",
... | Gets an iterator over all records in this buffer in their logical order.
@return An iterator returning the records in their logical order. | [
"Gets",
"an",
"iterator",
"over",
"all",
"records",
"in",
"this",
"buffer",
"in",
"their",
"logical",
"order",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/BinaryInMemorySortBuffer.java#L186-L223 | train | Returns an iterator over the records in this list. | [
30522,
2270,
2345,
14163,
10880,
16429,
20614,
21646,
8844,
1026,
12441,
10524,
1028,
2131,
21646,
8844,
1006,
1007,
1063,
2709,
2047,
14163,
10880,
16429,
20614,
21646,
8844,
1026,
12441,
10524,
1028,
1006,
1007,
1063,
2797,
2345,
20014,
294... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/HashUtil.java | HashUtil.sdbmHash | public static int sdbmHash(String str) {
int hash = 0;
for (int i = 0; i < str.length(); i++) {
hash = str.charAt(i) + (hash << 6) + (hash << 16) - hash;
}
return hash & 0x7FFFFFFF;
} | java | public static int sdbmHash(String str) {
int hash = 0;
for (int i = 0; i < str.length(); i++) {
hash = str.charAt(i) + (hash << 6) + (hash << 16) - hash;
}
return hash & 0x7FFFFFFF;
} | [
"public",
"static",
"int",
"sdbmHash",
"(",
"String",
"str",
")",
"{",
"int",
"hash",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"hash",
"=",
"str",
".",
"charAt",... | SDBM算法
@param str 字符串
@return hash值 | [
"SDBM算法"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/HashUtil.java#L298-L306 | train | Returns the hash code of the specified string. | [
30522,
2270,
10763,
20014,
17371,
25526,
14949,
2232,
1006,
5164,
2358,
2099,
30524,
2358,
2099,
1012,
25869,
4017,
1006,
1045,
1007,
1009,
1006,
23325,
1026,
1026,
1020,
1007,
1009,
1006,
23325,
1026,
1026,
2385,
1007,
1011,
23325,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
alibaba/canal | client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/loader/CanalAdapterLoader.java | CanalAdapterLoader.init | public void init() {
loader = ExtensionLoader.getExtensionLoader(OuterAdapter.class);
String canalServerHost = this.canalClientConfig.getCanalServerHost();
SocketAddress sa = null;
if (canalServerHost != null) {
String[] ipPort = canalServerHost.split(":");
sa = new InetSocketAddress(ipPort[0], Integer.parseInt(ipPort[1]));
}
String zkHosts = this.canalClientConfig.getZookeeperHosts();
if ("tcp".equalsIgnoreCase(canalClientConfig.getMode())) {
// 初始化canal-client的适配器
for (CanalClientConfig.CanalAdapter canalAdapter : canalClientConfig.getCanalAdapters()) {
List<List<OuterAdapter>> canalOuterAdapterGroups = new ArrayList<>();
for (CanalClientConfig.Group connectorGroup : canalAdapter.getGroups()) {
List<OuterAdapter> canalOutConnectors = new ArrayList<>();
for (OuterAdapterConfig c : connectorGroup.getOuterAdapters()) {
loadAdapter(c, canalOutConnectors);
}
canalOuterAdapterGroups.add(canalOutConnectors);
}
CanalAdapterWorker worker;
if (sa != null) {
worker = new CanalAdapterWorker(canalClientConfig,
canalAdapter.getInstance(),
sa,
canalOuterAdapterGroups);
} else if (zkHosts != null) {
worker = new CanalAdapterWorker(canalClientConfig,
canalAdapter.getInstance(),
zkHosts,
canalOuterAdapterGroups);
} else {
throw new RuntimeException("No canal server connector found");
}
canalWorkers.put(canalAdapter.getInstance(), worker);
worker.start();
logger.info("Start adapter for canal instance: {} succeed", canalAdapter.getInstance());
}
} else if ("kafka".equalsIgnoreCase(canalClientConfig.getMode())) {
// 初始化canal-client-kafka的适配器
for (CanalClientConfig.CanalAdapter canalAdapter : canalClientConfig.getCanalAdapters()) {
for (CanalClientConfig.Group group : canalAdapter.getGroups()) {
List<List<OuterAdapter>> canalOuterAdapterGroups = new ArrayList<>();
List<OuterAdapter> canalOuterAdapters = new ArrayList<>();
for (OuterAdapterConfig config : group.getOuterAdapters()) {
loadAdapter(config, canalOuterAdapters);
}
canalOuterAdapterGroups.add(canalOuterAdapters);
CanalAdapterKafkaWorker canalKafkaWorker = new CanalAdapterKafkaWorker(canalClientConfig,
canalClientConfig.getMqServers(),
canalAdapter.getInstance(),
group.getGroupId(),
canalOuterAdapterGroups,
canalClientConfig.getFlatMessage());
canalMQWorker.put(canalAdapter.getInstance() + "-kafka-" + group.getGroupId(), canalKafkaWorker);
canalKafkaWorker.start();
logger.info("Start adapter for canal-client mq topic: {} succeed",
canalAdapter.getInstance() + "-" + group.getGroupId());
}
}
} else if ("rocketMQ".equalsIgnoreCase(canalClientConfig.getMode())) {
// 初始化canal-client-rocketMQ的适配器
for (CanalClientConfig.CanalAdapter canalAdapter : canalClientConfig.getCanalAdapters()) {
for (CanalClientConfig.Group group : canalAdapter.getGroups()) {
List<List<OuterAdapter>> canalOuterAdapterGroups = new ArrayList<>();
List<OuterAdapter> canalOuterAdapters = new ArrayList<>();
for (OuterAdapterConfig config : group.getOuterAdapters()) {
loadAdapter(config, canalOuterAdapters);
}
canalOuterAdapterGroups.add(canalOuterAdapters);
CanalAdapterRocketMQWorker rocketMQWorker = new CanalAdapterRocketMQWorker(canalClientConfig,
canalClientConfig.getMqServers(),
canalAdapter.getInstance(),
group.getGroupId(),
canalOuterAdapterGroups,
canalClientConfig.getAccessKey(),
canalClientConfig.getSecretKey(),
canalClientConfig.getFlatMessage());
canalMQWorker.put(canalAdapter.getInstance() + "-rocketmq-" + group.getGroupId(), rocketMQWorker);
rocketMQWorker.start();
logger.info("Start adapter for canal-client mq topic: {} succeed",
canalAdapter.getInstance() + "-" + group.getGroupId());
}
}
}
} | java | public void init() {
loader = ExtensionLoader.getExtensionLoader(OuterAdapter.class);
String canalServerHost = this.canalClientConfig.getCanalServerHost();
SocketAddress sa = null;
if (canalServerHost != null) {
String[] ipPort = canalServerHost.split(":");
sa = new InetSocketAddress(ipPort[0], Integer.parseInt(ipPort[1]));
}
String zkHosts = this.canalClientConfig.getZookeeperHosts();
if ("tcp".equalsIgnoreCase(canalClientConfig.getMode())) {
// 初始化canal-client的适配器
for (CanalClientConfig.CanalAdapter canalAdapter : canalClientConfig.getCanalAdapters()) {
List<List<OuterAdapter>> canalOuterAdapterGroups = new ArrayList<>();
for (CanalClientConfig.Group connectorGroup : canalAdapter.getGroups()) {
List<OuterAdapter> canalOutConnectors = new ArrayList<>();
for (OuterAdapterConfig c : connectorGroup.getOuterAdapters()) {
loadAdapter(c, canalOutConnectors);
}
canalOuterAdapterGroups.add(canalOutConnectors);
}
CanalAdapterWorker worker;
if (sa != null) {
worker = new CanalAdapterWorker(canalClientConfig,
canalAdapter.getInstance(),
sa,
canalOuterAdapterGroups);
} else if (zkHosts != null) {
worker = new CanalAdapterWorker(canalClientConfig,
canalAdapter.getInstance(),
zkHosts,
canalOuterAdapterGroups);
} else {
throw new RuntimeException("No canal server connector found");
}
canalWorkers.put(canalAdapter.getInstance(), worker);
worker.start();
logger.info("Start adapter for canal instance: {} succeed", canalAdapter.getInstance());
}
} else if ("kafka".equalsIgnoreCase(canalClientConfig.getMode())) {
// 初始化canal-client-kafka的适配器
for (CanalClientConfig.CanalAdapter canalAdapter : canalClientConfig.getCanalAdapters()) {
for (CanalClientConfig.Group group : canalAdapter.getGroups()) {
List<List<OuterAdapter>> canalOuterAdapterGroups = new ArrayList<>();
List<OuterAdapter> canalOuterAdapters = new ArrayList<>();
for (OuterAdapterConfig config : group.getOuterAdapters()) {
loadAdapter(config, canalOuterAdapters);
}
canalOuterAdapterGroups.add(canalOuterAdapters);
CanalAdapterKafkaWorker canalKafkaWorker = new CanalAdapterKafkaWorker(canalClientConfig,
canalClientConfig.getMqServers(),
canalAdapter.getInstance(),
group.getGroupId(),
canalOuterAdapterGroups,
canalClientConfig.getFlatMessage());
canalMQWorker.put(canalAdapter.getInstance() + "-kafka-" + group.getGroupId(), canalKafkaWorker);
canalKafkaWorker.start();
logger.info("Start adapter for canal-client mq topic: {} succeed",
canalAdapter.getInstance() + "-" + group.getGroupId());
}
}
} else if ("rocketMQ".equalsIgnoreCase(canalClientConfig.getMode())) {
// 初始化canal-client-rocketMQ的适配器
for (CanalClientConfig.CanalAdapter canalAdapter : canalClientConfig.getCanalAdapters()) {
for (CanalClientConfig.Group group : canalAdapter.getGroups()) {
List<List<OuterAdapter>> canalOuterAdapterGroups = new ArrayList<>();
List<OuterAdapter> canalOuterAdapters = new ArrayList<>();
for (OuterAdapterConfig config : group.getOuterAdapters()) {
loadAdapter(config, canalOuterAdapters);
}
canalOuterAdapterGroups.add(canalOuterAdapters);
CanalAdapterRocketMQWorker rocketMQWorker = new CanalAdapterRocketMQWorker(canalClientConfig,
canalClientConfig.getMqServers(),
canalAdapter.getInstance(),
group.getGroupId(),
canalOuterAdapterGroups,
canalClientConfig.getAccessKey(),
canalClientConfig.getSecretKey(),
canalClientConfig.getFlatMessage());
canalMQWorker.put(canalAdapter.getInstance() + "-rocketmq-" + group.getGroupId(), rocketMQWorker);
rocketMQWorker.start();
logger.info("Start adapter for canal-client mq topic: {} succeed",
canalAdapter.getInstance() + "-" + group.getGroupId());
}
}
}
} | [
"public",
"void",
"init",
"(",
")",
"{",
"loader",
"=",
"ExtensionLoader",
".",
"getExtensionLoader",
"(",
"OuterAdapter",
".",
"class",
")",
";",
"String",
"canalServerHost",
"=",
"this",
".",
"canalClientConfig",
".",
"getCanalServerHost",
"(",
")",
";",
"So... | 初始化canal-client | [
"初始化canal",
"-",
"client"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/loader/CanalAdapterLoader.java#L52-L142 | train | Initializes the instance of the class. | [
30522,
2270,
11675,
1999,
4183,
1006,
1007,
1063,
7170,
2121,
1027,
5331,
11066,
2121,
1012,
2131,
10288,
29048,
11066,
2121,
1006,
6058,
8447,
13876,
2121,
1012,
2465,
1007,
1025,
5164,
17263,
2121,
6299,
15006,
2102,
1027,
2023,
1012,
503... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java | FutureUtils.retry | public static <T> CompletableFuture<T> retry(
final Supplier<CompletableFuture<T>> operation,
final int retries,
final Executor executor) {
final CompletableFuture<T> resultFuture = new CompletableFuture<>();
retryOperation(resultFuture, operation, retries, executor);
return resultFuture;
} | java | public static <T> CompletableFuture<T> retry(
final Supplier<CompletableFuture<T>> operation,
final int retries,
final Executor executor) {
final CompletableFuture<T> resultFuture = new CompletableFuture<>();
retryOperation(resultFuture, operation, retries, executor);
return resultFuture;
} | [
"public",
"static",
"<",
"T",
">",
"CompletableFuture",
"<",
"T",
">",
"retry",
"(",
"final",
"Supplier",
"<",
"CompletableFuture",
"<",
"T",
">",
">",
"operation",
",",
"final",
"int",
"retries",
",",
"final",
"Executor",
"executor",
")",
"{",
"final",
... | Retry the given operation the given number of times in case of a failure.
@param operation to executed
@param retries if the operation failed
@param executor to use to run the futures
@param <T> type of the result
@return Future containing either the result of the operation or a {@link RetryException} | [
"Retry",
"the",
"given",
"operation",
"the",
"given",
"number",
"of",
"times",
"in",
"case",
"of",
"a",
"failure",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java#L76-L86 | train | Retry a sequence of operations. | [
30522,
2270,
10763,
1026,
1056,
1028,
4012,
10814,
10880,
11263,
11244,
1026,
1056,
1028,
2128,
11129,
1006,
2345,
17024,
1026,
4012,
10814,
10880,
11263,
11244,
1026,
1056,
1028,
1028,
3169,
1010,
2345,
20014,
2128,
21011,
1010,
2345,
4654,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-optimizer/src/main/java/org/apache/flink/optimizer/dataproperties/RequestedGlobalProperties.java | RequestedGlobalProperties.setCustomPartitioned | public void setCustomPartitioned(FieldSet partitionedFields, Partitioner<?> partitioner) {
if (partitionedFields == null || partitioner == null) {
throw new NullPointerException();
}
this.partitioning = PartitioningProperty.CUSTOM_PARTITIONING;
this.partitioningFields = partitionedFields;
this.ordering = null;
this.customPartitioner = partitioner;
} | java | public void setCustomPartitioned(FieldSet partitionedFields, Partitioner<?> partitioner) {
if (partitionedFields == null || partitioner == null) {
throw new NullPointerException();
}
this.partitioning = PartitioningProperty.CUSTOM_PARTITIONING;
this.partitioningFields = partitionedFields;
this.ordering = null;
this.customPartitioner = partitioner;
} | [
"public",
"void",
"setCustomPartitioned",
"(",
"FieldSet",
"partitionedFields",
",",
"Partitioner",
"<",
"?",
">",
"partitioner",
")",
"{",
"if",
"(",
"partitionedFields",
"==",
"null",
"||",
"partitioner",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerExc... | Sets these properties to request a custom partitioning with the given {@link Partitioner} instance.
If the fields are provided as {@link FieldSet}, then any permutation of the fields is a
valid partitioning, including subsets. If the fields are given as a {@link FieldList},
then only an exact partitioning on the fields matches this requested partitioning.
@param partitionedFields The key fields for the partitioning. | [
"Sets",
"these",
"properties",
"to",
"request",
"a",
"custom",
"partitioning",
"with",
"the",
"given",
"{",
"@link",
"Partitioner",
"}",
"instance",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/dataproperties/RequestedGlobalProperties.java#L154-L163 | train | Sets the custom partitioning property. | [
30522,
2270,
11675,
2275,
7874,
20389,
19362,
3775,
3508,
2098,
1006,
4249,
3388,
13571,
2098,
15155,
1010,
13571,
2121,
1026,
1029,
1028,
13571,
2121,
1007,
1063,
2065,
1006,
13571,
2098,
15155,
1027,
1027,
19701,
1064,
1064,
13571,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/seg/NShort/Path/NShortPath.java | NShortPath.calculate | private void calculate(Graph inGraph, int nValueKind)
{
initNShortPath(inGraph, nValueKind);
QueueElement tmpElement;
CQueue queWork = new CQueue();
double eWeight;
for (int nCurNode = 1; nCurNode < vertexCount; ++nCurNode)
{
// 将所有到当前结点(nCurNode)可能到达的边根据eWeight排序并压入队列
enQueueCurNodeEdges(queWork, nCurNode);
// 初始化当前结点所有边的eWeight值
for (int i = 0; i < N; ++i)
weightArray[nCurNode - 1][i] = Double.MAX_VALUE;
// 将queWork中的内容装入fromArray
tmpElement = queWork.deQueue();
if (tmpElement != null)
{
for (int i = 0; i < N; ++i)
{
eWeight = tmpElement.weight;
weightArray[nCurNode - 1][i] = eWeight;
do
{
fromArray[nCurNode - 1][i].enQueue(new QueueElement(tmpElement.from, tmpElement.index, 0));
tmpElement = queWork.deQueue();
if (tmpElement == null)
{
i = N;
break;
}
} while (tmpElement.weight == eWeight);
}
}
}
} | java | private void calculate(Graph inGraph, int nValueKind)
{
initNShortPath(inGraph, nValueKind);
QueueElement tmpElement;
CQueue queWork = new CQueue();
double eWeight;
for (int nCurNode = 1; nCurNode < vertexCount; ++nCurNode)
{
// 将所有到当前结点(nCurNode)可能到达的边根据eWeight排序并压入队列
enQueueCurNodeEdges(queWork, nCurNode);
// 初始化当前结点所有边的eWeight值
for (int i = 0; i < N; ++i)
weightArray[nCurNode - 1][i] = Double.MAX_VALUE;
// 将queWork中的内容装入fromArray
tmpElement = queWork.deQueue();
if (tmpElement != null)
{
for (int i = 0; i < N; ++i)
{
eWeight = tmpElement.weight;
weightArray[nCurNode - 1][i] = eWeight;
do
{
fromArray[nCurNode - 1][i].enQueue(new QueueElement(tmpElement.from, tmpElement.index, 0));
tmpElement = queWork.deQueue();
if (tmpElement == null)
{
i = N;
break;
}
} while (tmpElement.weight == eWeight);
}
}
}
} | [
"private",
"void",
"calculate",
"(",
"Graph",
"inGraph",
",",
"int",
"nValueKind",
")",
"{",
"initNShortPath",
"(",
"inGraph",
",",
"nValueKind",
")",
";",
"QueueElement",
"tmpElement",
";",
"CQueue",
"queWork",
"=",
"new",
"CQueue",
"(",
")",
";",
"double",... | 计算出所有结点上可能的路径,为路径数据提供数据准备
@param inGraph 输入图
@param nValueKind 前N个结果 | [
"计算出所有结点上可能的路径,为路径数据提供数据准备"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/seg/NShort/Path/NShortPath.java#L90-L128 | train | Calculate the nValueKind of the nValueKind | [
30522,
30524,
24342,
1010,
1050,
10175,
5657,
18824,
1007,
1025,
24240,
12260,
3672,
1056,
8737,
12260,
3672,
1025,
1039,
4226,
5657,
10861,
6198,
1027,
2047,
1039,
4226,
5657,
1006,
1007,
1025,
3313,
1041,
11179,
1025,
2005,
1006,
20014,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.getLong | public long getLong(String name, long defaultValue) {
String valueString = getTrimmed(name);
if (valueString == null)
return defaultValue;
String hexString = getHexDigits(valueString);
if (hexString != null) {
return Long.parseLong(hexString, 16);
}
return Long.parseLong(valueString);
} | java | public long getLong(String name, long defaultValue) {
String valueString = getTrimmed(name);
if (valueString == null)
return defaultValue;
String hexString = getHexDigits(valueString);
if (hexString != null) {
return Long.parseLong(hexString, 16);
}
return Long.parseLong(valueString);
} | [
"public",
"long",
"getLong",
"(",
"String",
"name",
",",
"long",
"defaultValue",
")",
"{",
"String",
"valueString",
"=",
"getTrimmed",
"(",
"name",
")",
";",
"if",
"(",
"valueString",
"==",
"null",
")",
"return",
"defaultValue",
";",
"String",
"hexString",
... | Get the value of the <code>name</code> property as a <code>long</code>.
If no such property exists, the provided default value is returned,
or if the specified value is not a valid <code>long</code>,
then an error is thrown.
@param name property name.
@param defaultValue default value.
@throws NumberFormatException when the value is invalid
@return property value as a <code>long</code>,
or <code>defaultValue</code>. | [
"Get",
"the",
"value",
"of",
"the",
"<code",
">",
"name<",
"/",
"code",
">",
"property",
"as",
"a",
"<code",
">",
"long<",
"/",
"code",
">",
".",
"If",
"no",
"such",
"property",
"exists",
"the",
"provided",
"default",
"value",
"is",
"returned",
"or",
... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L1406-L1415 | train | Returns the value of the specified attribute as a long. | [
30522,
2270,
2146,
2131,
10052,
1006,
5164,
2171,
1010,
2146,
12398,
10175,
5657,
1007,
1063,
5164,
5300,
18886,
3070,
1027,
30524,
1006,
5300,
18886,
3070,
1007,
1025,
2065,
1006,
2002,
2595,
3367,
4892,
999,
1027,
19701,
1007,
1063,
2709,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java | NumberUtil.mul | public static double mul(float v1, float v2) {
return mul(Float.toString(v1), Float.toString(v2)).doubleValue();
} | java | public static double mul(float v1, float v2) {
return mul(Float.toString(v1), Float.toString(v2)).doubleValue();
} | [
"public",
"static",
"double",
"mul",
"(",
"float",
"v1",
",",
"float",
"v2",
")",
"{",
"return",
"mul",
"(",
"Float",
".",
"toString",
"(",
"v1",
")",
",",
"Float",
".",
"toString",
"(",
"v2",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"}"
] | 提供精确的乘法运算
@param v1 被乘数
@param v2 乘数
@return 积 | [
"提供精确的乘法运算"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java#L331-L333 | train | Multiply two floating point numbers. | [
30522,
2270,
10763,
3313,
14163,
2140,
1006,
14257,
1058,
2487,
1010,
14257,
1058,
2475,
1007,
1063,
2709,
14163,
2140,
1006,
14257,
1012,
2000,
3367,
4892,
1006,
1058,
2487,
1007,
1010,
14257,
1012,
2000,
3367,
4892,
1006,
1058,
2475,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java | LogBuffer.getBeUlong40 | public final long getBeUlong40(final int pos) {
final int position = origin + pos;
if (pos + 4 >= limit || pos < 0) throw new IllegalArgumentException("limit excceed: "
+ (pos < 0 ? pos : (pos + 4)));
byte[] buf = buffer;
return ((long) (0xff & buf[position + 4])) | ((long) (0xff & buf[position + 3]) << 8)
| ((long) (0xff & buf[position + 2]) << 16) | ((long) (0xff & buf[position + 1]) << 24)
| ((long) (0xff & buf[position]) << 32);
} | java | public final long getBeUlong40(final int pos) {
final int position = origin + pos;
if (pos + 4 >= limit || pos < 0) throw new IllegalArgumentException("limit excceed: "
+ (pos < 0 ? pos : (pos + 4)));
byte[] buf = buffer;
return ((long) (0xff & buf[position + 4])) | ((long) (0xff & buf[position + 3]) << 8)
| ((long) (0xff & buf[position + 2]) << 16) | ((long) (0xff & buf[position + 1]) << 24)
| ((long) (0xff & buf[position]) << 32);
} | [
"public",
"final",
"long",
"getBeUlong40",
"(",
"final",
"int",
"pos",
")",
"{",
"final",
"int",
"position",
"=",
"origin",
"+",
"pos",
";",
"if",
"(",
"pos",
"+",
"4",
">=",
"limit",
"||",
"pos",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentExceptio... | Return 40-bit unsigned int from buffer. (big-endian)
@see mysql-5.6.10/include/myisampack.h - mi_uint5korr | [
"Return",
"40",
"-",
"bit",
"unsigned",
"int",
"from",
"buffer",
".",
"(",
"big",
"-",
"endian",
")"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L617-L627 | train | Gets a long from the buffer starting at the given position in the beacon. | [
30522,
2270,
2345,
2146,
2131,
4783,
18845,
3070,
12740,
1006,
2345,
20014,
13433,
2015,
1007,
1063,
2345,
20014,
2597,
1027,
4761,
1009,
13433,
2015,
1025,
2065,
1006,
13433,
2015,
1009,
1018,
1028,
1027,
5787,
1064,
1064,
13433,
2015,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/ClassScaner.java | ClassScaner.scan | public Set<Class<?>> scan() {
for (URL url : ResourceUtil.getResourceIter(this.packagePath)) {
switch (url.getProtocol()) {
case "file":
scanFile(new File(URLUtil.decode(url.getFile(), this.charset.name())), null);
break;
case "jar":
scanJar(URLUtil.getJarFile(url));
break;
}
}
if(CollUtil.isEmpty(this.classes)) {
scanJavaClassPaths();
}
return Collections.unmodifiableSet(this.classes);
} | java | public Set<Class<?>> scan() {
for (URL url : ResourceUtil.getResourceIter(this.packagePath)) {
switch (url.getProtocol()) {
case "file":
scanFile(new File(URLUtil.decode(url.getFile(), this.charset.name())), null);
break;
case "jar":
scanJar(URLUtil.getJarFile(url));
break;
}
}
if(CollUtil.isEmpty(this.classes)) {
scanJavaClassPaths();
}
return Collections.unmodifiableSet(this.classes);
} | [
"public",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"scan",
"(",
")",
"{",
"for",
"(",
"URL",
"url",
":",
"ResourceUtil",
".",
"getResourceIter",
"(",
"this",
".",
"packagePath",
")",
")",
"{",
"switch",
"(",
"url",
".",
"getProtocol",
"(",
")",
")"... | 扫描包路径下满足class过滤器条件的所有class文件
@return 类集合 | [
"扫描包路径下满足class过滤器条件的所有class文件"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/ClassScaner.java#L163-L180 | train | Scans the classpath for classes. | [
30522,
2270,
2275,
1026,
2465,
1026,
1029,
1028,
1028,
13594,
1006,
1007,
1063,
2005,
1006,
24471,
2140,
24471,
2140,
1024,
7692,
21823,
2140,
1012,
2131,
6072,
8162,
3401,
21646,
1006,
2023,
1012,
7427,
15069,
1007,
1007,
1063,
6942,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java | RandomUtil.weightRandom | public static <T> WeightRandom<T> weightRandom(Iterable<WeightObj<T>> weightObjs) {
return new WeightRandom<>(weightObjs);
} | java | public static <T> WeightRandom<T> weightRandom(Iterable<WeightObj<T>> weightObjs) {
return new WeightRandom<>(weightObjs);
} | [
"public",
"static",
"<",
"T",
">",
"WeightRandom",
"<",
"T",
">",
"weightRandom",
"(",
"Iterable",
"<",
"WeightObj",
"<",
"T",
">",
">",
"weightObjs",
")",
"{",
"return",
"new",
"WeightRandom",
"<>",
"(",
"weightObjs",
")",
";",
"}"
] | 带有权重的随机生成器
@param weightObjs 带有权重的对象列表
@return {@link WeightRandom}
@since 4.0.3 | [
"带有权重的随机生成器"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java#L457-L459 | train | Returns a random object that combines the given weight objects. | [
30522,
2270,
10763,
1026,
1056,
1028,
3635,
13033,
5358,
1026,
1056,
1028,
3635,
13033,
5358,
1006,
2009,
6906,
3468,
1026,
3635,
16429,
3501,
1026,
1056,
1028,
1028,
3635,
16429,
22578,
1007,
1063,
2709,
2047,
3635,
13033,
5358,
1026,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/unsafe/src/main/java/org/apache/spark/unsafe/array/LongArray.java | LongArray.get | public long get(int index) {
assert index >= 0 : "index (" + index + ") should >= 0";
assert index < length : "index (" + index + ") should < length (" + length + ")";
return Platform.getLong(baseObj, baseOffset + index * WIDTH);
} | java | public long get(int index) {
assert index >= 0 : "index (" + index + ") should >= 0";
assert index < length : "index (" + index + ") should < length (" + length + ")";
return Platform.getLong(baseObj, baseOffset + index * WIDTH);
} | [
"public",
"long",
"get",
"(",
"int",
"index",
")",
"{",
"assert",
"index",
">=",
"0",
":",
"\"index (\"",
"+",
"index",
"+",
"\") should >= 0\"",
";",
"assert",
"index",
"<",
"length",
":",
"\"index (\"",
"+",
"index",
"+",
"\") should < length (\"",
"+",
... | Returns the value at position {@code index}. | [
"Returns",
"the",
"value",
"at",
"position",
"{"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/unsafe/src/main/java/org/apache/spark/unsafe/array/LongArray.java#L89-L93 | train | Gets the value at the specified index in the surrogate. | [
30522,
2270,
2146,
2131,
1006,
20014,
5950,
1007,
1063,
20865,
5950,
1028,
1027,
1014,
1024,
1000,
5950,
1006,
1000,
1009,
5950,
1009,
1000,
1007,
2323,
1028,
1027,
1014,
1000,
1025,
20865,
30524,
3388,
1009,
5950,
1008,
9381,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java | ArrayUtil.reverse | public static double[] reverse(final double[] array, final int startIndexInclusive, final int endIndexExclusive) {
if (isEmpty(array)) {
return array;
}
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
int j = Math.min(array.length, endIndexExclusive) - 1;
double tmp;
while (j > i) {
tmp = array[j];
array[j] = array[i];
array[i] = tmp;
j--;
i++;
}
return array;
} | java | public static double[] reverse(final double[] array, final int startIndexInclusive, final int endIndexExclusive) {
if (isEmpty(array)) {
return array;
}
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
int j = Math.min(array.length, endIndexExclusive) - 1;
double tmp;
while (j > i) {
tmp = array[j];
array[j] = array[i];
array[i] = tmp;
j--;
i++;
}
return array;
} | [
"public",
"static",
"double",
"[",
"]",
"reverse",
"(",
"final",
"double",
"[",
"]",
"array",
",",
"final",
"int",
"startIndexInclusive",
",",
"final",
"int",
"endIndexExclusive",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"return",
"ar... | 反转数组,会变更原数组
@param array 数组,会变更
@param startIndexInclusive 其实位置(包含)
@param endIndexExclusive 结束位置(不包含)
@return 变更后的原数组
@since 3.0.9 | [
"反转数组,会变更原数组"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java#L3156-L3171 | train | Reverses the elements of the specified double array in reverse order. | [
30522,
2270,
10763,
3313,
1031,
1033,
7901,
1006,
2345,
3313,
1031,
1033,
9140,
1010,
2345,
20014,
2707,
22254,
10288,
2378,
23633,
1010,
2345,
20014,
2203,
22254,
10288,
10288,
23633,
1007,
1063,
2065,
1006,
2003,
6633,
13876,
2100,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java | ParameterTool.addToDefaults | protected void addToDefaults(String key, String value) {
final String currentValue = defaultData.get(key);
if (currentValue == null) {
if (value == null) {
value = DEFAULT_UNDEFINED;
}
defaultData.put(key, value);
} else {
// there is already an entry for this key. Check if the value is the undefined
if (currentValue.equals(DEFAULT_UNDEFINED) && value != null) {
// update key with better default value
defaultData.put(key, value);
}
}
} | java | protected void addToDefaults(String key, String value) {
final String currentValue = defaultData.get(key);
if (currentValue == null) {
if (value == null) {
value = DEFAULT_UNDEFINED;
}
defaultData.put(key, value);
} else {
// there is already an entry for this key. Check if the value is the undefined
if (currentValue.equals(DEFAULT_UNDEFINED) && value != null) {
// update key with better default value
defaultData.put(key, value);
}
}
} | [
"protected",
"void",
"addToDefaults",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"final",
"String",
"currentValue",
"=",
"defaultData",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"currentValue",
"==",
"null",
")",
"{",
"if",
"(",
"value",
... | --------------- Internals | [
"---------------",
"Internals"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java#L461-L475 | train | Add a value to the default data. | [
30522,
5123,
11675,
5587,
3406,
3207,
7011,
11314,
2015,
1006,
5164,
3145,
1010,
5164,
3643,
1007,
1063,
2345,
5164,
2783,
10175,
5657,
1027,
12398,
2850,
2696,
1012,
2131,
1006,
3145,
1007,
1025,
2065,
1006,
2783,
10175,
5657,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/seg/common/CWSEvaluator.java | CWSEvaluator.evaluate | public static CWSEvaluator.Result evaluate(Segment segment, String testFile, String outputPath, String goldFile, String dictPath) throws IOException
{
return evaluate(segment, outputPath, goldFile, dictPath);
} | java | public static CWSEvaluator.Result evaluate(Segment segment, String testFile, String outputPath, String goldFile, String dictPath) throws IOException
{
return evaluate(segment, outputPath, goldFile, dictPath);
} | [
"public",
"static",
"CWSEvaluator",
".",
"Result",
"evaluate",
"(",
"Segment",
"segment",
",",
"String",
"testFile",
",",
"String",
"outputPath",
",",
"String",
"goldFile",
",",
"String",
"dictPath",
")",
"throws",
"IOException",
"{",
"return",
"evaluate",
"(",
... | 标准化评测分词器
@param segment 分词器
@param testFile 测试集raw text
@param outputPath 分词预测输出文件
@param goldFile 测试集segmented file
@param dictPath 训练集单词列表
@return 一个储存准确率的结构
@throws IOException | [
"标准化评测分词器"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/seg/common/CWSEvaluator.java#L223-L226 | train | Evaluate a CWSE value on a segment. | [
30522,
2270,
10763,
19296,
3366,
10175,
6692,
4263,
1012,
2765,
16157,
1006,
6903,
6903,
1010,
5164,
3231,
8873,
2571,
1010,
5164,
6434,
15069,
1010,
5164,
2751,
8873,
2571,
1010,
5164,
4487,
6593,
15069,
1007,
11618,
22834,
10288,
24422,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/mining/word2vec/DocVectorModel.java | DocVectorModel.nearest | public List<Map.Entry<Integer, Float>> nearest(String query)
{
return queryNearest(query, 10);
} | java | public List<Map.Entry<Integer, Float>> nearest(String query)
{
return queryNearest(query, 10);
} | [
"public",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"Float",
">",
">",
"nearest",
"(",
"String",
"query",
")",
"{",
"return",
"queryNearest",
"(",
"query",
",",
"10",
")",
";",
"}"
] | 查询最相似的前10个文档
@param query 查询语句(或者说一个文档的内容)
@return | [
"查询最相似的前10个文档"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/mining/word2vec/DocVectorModel.java#L56-L59 | train | Query nearest segment. | [
30522,
2270,
2862,
1026,
4949,
1012,
4443,
1026,
16109,
1010,
14257,
1028,
1028,
7205,
1006,
5164,
23032,
1007,
1063,
2709,
23032,
22084,
28533,
1006,
23032,
1010,
2184,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ObjectUtil.java | ObjectUtil.compare | public static <T extends Comparable<? super T>> int compare(T c1, T c2) {
return CompareUtil.compare(c1, c2);
} | java | public static <T extends Comparable<? super T>> int compare(T c1, T c2) {
return CompareUtil.compare(c1, c2);
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"int",
"compare",
"(",
"T",
"c1",
",",
"T",
"c2",
")",
"{",
"return",
"CompareUtil",
".",
"compare",
"(",
"c1",
",",
"c2",
")",
";",
"}"
] | {@code null}安全的对象比较,{@code null}对象排在末尾
@param <T> 被比较对象类型
@param c1 对象1,可以为{@code null}
@param c2 对象2,可以为{@code null}
@return 比较结果,如果c1 < c2,返回数小于0,c1==c2返回0,c1 > c2 大于0
@since 3.0.7
@see java.util.Comparator#compare(Object, Object) | [
"{",
"@code",
"null",
"}",
"安全的对象比较,",
"{",
"@code",
"null",
"}",
"对象排在末尾"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ObjectUtil.java#L437-L439 | train | Compares two Comparable objects. | [
30522,
2270,
10763,
1026,
1056,
8908,
12435,
1026,
1029,
3565,
1056,
1028,
1028,
20014,
12826,
1006,
1056,
27723,
1010,
1056,
29248,
1007,
1063,
2709,
12826,
21823,
2140,
1012,
12826,
1006,
27723,
1010,
29248,
1007,
1025,
1065,
102,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-dfa/src/main/java/cn/hutool/dfa/WordTree.java | WordTree.match | public String match(String text){
if(null == text){
return null;
}
List<String> matchAll = matchAll(text, 1);
if(CollectionUtil.isNotEmpty(matchAll)){
return matchAll.get(0);
}
return null;
} | java | public String match(String text){
if(null == text){
return null;
}
List<String> matchAll = matchAll(text, 1);
if(CollectionUtil.isNotEmpty(matchAll)){
return matchAll.get(0);
}
return null;
} | [
"public",
"String",
"match",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"null",
"==",
"text",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"String",
">",
"matchAll",
"=",
"matchAll",
"(",
"text",
",",
"1",
")",
";",
"if",
"(",
"CollectionUti... | 获得第一个匹配的关键字
@param text 被检查的文本
@return 匹配到的关键字 | [
"获得第一个匹配的关键字"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-dfa/src/main/java/cn/hutool/dfa/WordTree.java#L115-L124 | train | Match a string. | [
30522,
2270,
5164,
2674,
1006,
5164,
3793,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
3793,
1007,
1063,
2709,
19701,
1025,
1065,
2862,
1026,
5164,
1028,
2674,
8095,
1027,
2674,
8095,
1006,
3793,
1010,
1015,
1007,
1025,
2065,
1006,
3074,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
redisson/redisson | redisson/src/main/java/org/redisson/api/BatchResult.java | BatchResult.set | @Deprecated
public E set(int index, E element) {
return responses.set(index, element);
} | java | @Deprecated
public E set(int index, E element) {
return responses.set(index, element);
} | [
"@",
"Deprecated",
"public",
"E",
"set",
"(",
"int",
"index",
",",
"E",
"element",
")",
"{",
"return",
"responses",
".",
"set",
"(",
"index",
",",
"element",
")",
";",
"}"
] | Use {@link #getResponses()} | [
"Use",
"{"
] | d3acc0249b2d5d658d36d99e2c808ce49332ea44 | https://github.com/redisson/redisson/blob/d3acc0249b2d5d658d36d99e2c808ce49332ea44/redisson/src/main/java/org/redisson/api/BatchResult.java#L180-L183 | train | Sets the element at the given index. | [
30522,
1030,
2139,
28139,
12921,
2270,
1041,
2275,
1006,
20014,
5950,
1010,
1041,
5783,
1007,
1063,
2709,
10960,
1012,
2275,
1006,
5950,
1010,
5783,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java | RestTemplateBuilder.setConnectTimeout | public RestTemplateBuilder setConnectTimeout(Duration connectTimeout) {
return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri,
this.messageConverters, this.requestFactorySupplier,
this.uriTemplateHandler, this.errorHandler, this.basicAuthentication,
this.restTemplateCustomizers,
this.requestFactoryCustomizer.connectTimeout(connectTimeout),
this.interceptors);
} | java | public RestTemplateBuilder setConnectTimeout(Duration connectTimeout) {
return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri,
this.messageConverters, this.requestFactorySupplier,
this.uriTemplateHandler, this.errorHandler, this.basicAuthentication,
this.restTemplateCustomizers,
this.requestFactoryCustomizer.connectTimeout(connectTimeout),
this.interceptors);
} | [
"public",
"RestTemplateBuilder",
"setConnectTimeout",
"(",
"Duration",
"connectTimeout",
")",
"{",
"return",
"new",
"RestTemplateBuilder",
"(",
"this",
".",
"detectRequestFactory",
",",
"this",
".",
"rootUri",
",",
"this",
".",
"messageConverters",
",",
"this",
".",... | Sets the connection timeout on the underlying {@link ClientHttpRequestFactory}.
@param connectTimeout the connection timeout
@return a new builder instance.
@since 2.1.0 | [
"Sets",
"the",
"connection",
"timeout",
"on",
"the",
"underlying",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java#L466-L473 | train | Sets the connect timeout. | [
30522,
2270,
2717,
18532,
15725,
8569,
23891,
2099,
2275,
8663,
2638,
6593,
7292,
5833,
1006,
9367,
7532,
7292,
5833,
1007,
1063,
2709,
2047,
2717,
18532,
15725,
8569,
23891,
2099,
1006,
2023,
1012,
11487,
2890,
15500,
21450,
1010,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-common/src/main/java/org/apache/flink/table/descriptors/Schema.java | Schema.from | public Schema from(String originFieldName) {
if (lastField == null) {
throw new ValidationException("No field previously defined. Use field() before.");
}
tableSchema.get(lastField).put(SCHEMA_FROM, originFieldName);
lastField = null;
return this;
} | java | public Schema from(String originFieldName) {
if (lastField == null) {
throw new ValidationException("No field previously defined. Use field() before.");
}
tableSchema.get(lastField).put(SCHEMA_FROM, originFieldName);
lastField = null;
return this;
} | [
"public",
"Schema",
"from",
"(",
"String",
"originFieldName",
")",
"{",
"if",
"(",
"lastField",
"==",
"null",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"\"No field previously defined. Use field() before.\"",
")",
";",
"}",
"tableSchema",
".",
"get",
"(... | Specifies the origin of the previously defined field. The origin field is defined by a
connector or format.
<p>E.g. field("myString", Types.STRING).from("CSV_MY_STRING")
<p>Note: Field names are matched by the exact name by default (case sensitive). | [
"Specifies",
"the",
"origin",
"of",
"the",
"previously",
"defined",
"field",
".",
"The",
"origin",
"field",
"is",
"defined",
"by",
"a",
"connector",
"or",
"format",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/descriptors/Schema.java#L111-L118 | train | Sets the origin field name. | [
30522,
2270,
8040,
28433,
2013,
1006,
5164,
4761,
3790,
18442,
1007,
1063,
2065,
1006,
2197,
3790,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
27354,
10288,
24422,
1006,
1000,
2053,
2492,
3130,
4225,
1012,
2224,
2492,
1006,
1007,
2077,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManager.java | SlotManager.suspend | public void suspend() {
LOG.info("Suspending the SlotManager.");
// stop the timeout checks for the TaskManagers and the SlotRequests
if (taskManagerTimeoutCheck != null) {
taskManagerTimeoutCheck.cancel(false);
taskManagerTimeoutCheck = null;
}
if (slotRequestTimeoutCheck != null) {
slotRequestTimeoutCheck.cancel(false);
slotRequestTimeoutCheck = null;
}
for (PendingSlotRequest pendingSlotRequest : pendingSlotRequests.values()) {
cancelPendingSlotRequest(pendingSlotRequest);
}
pendingSlotRequests.clear();
ArrayList<InstanceID> registeredTaskManagers = new ArrayList<>(taskManagerRegistrations.keySet());
for (InstanceID registeredTaskManager : registeredTaskManagers) {
unregisterTaskManager(registeredTaskManager);
}
resourceManagerId = null;
resourceActions = null;
started = false;
} | java | public void suspend() {
LOG.info("Suspending the SlotManager.");
// stop the timeout checks for the TaskManagers and the SlotRequests
if (taskManagerTimeoutCheck != null) {
taskManagerTimeoutCheck.cancel(false);
taskManagerTimeoutCheck = null;
}
if (slotRequestTimeoutCheck != null) {
slotRequestTimeoutCheck.cancel(false);
slotRequestTimeoutCheck = null;
}
for (PendingSlotRequest pendingSlotRequest : pendingSlotRequests.values()) {
cancelPendingSlotRequest(pendingSlotRequest);
}
pendingSlotRequests.clear();
ArrayList<InstanceID> registeredTaskManagers = new ArrayList<>(taskManagerRegistrations.keySet());
for (InstanceID registeredTaskManager : registeredTaskManagers) {
unregisterTaskManager(registeredTaskManager);
}
resourceManagerId = null;
resourceActions = null;
started = false;
} | [
"public",
"void",
"suspend",
"(",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Suspending the SlotManager.\"",
")",
";",
"// stop the timeout checks for the TaskManagers and the SlotRequests",
"if",
"(",
"taskManagerTimeoutCheck",
"!=",
"null",
")",
"{",
"taskManagerTimeoutCheck",... | Suspends the component. This clears the internal state of the slot manager. | [
"Suspends",
"the",
"component",
".",
"This",
"clears",
"the",
"internal",
"state",
"of",
"the",
"slot",
"manager",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManager.java#L230-L259 | train | Suspend the slot manager. | [
30522,
2270,
11675,
28324,
1006,
1007,
1063,
8833,
1012,
18558,
1006,
1000,
28324,
2075,
1996,
10453,
24805,
4590,
1012,
1000,
1007,
1025,
1013,
1013,
2644,
1996,
2051,
5833,
14148,
2005,
1996,
4708,
24805,
15776,
1998,
1996,
10453,
2890,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | dump/src/main/java/com/networknt/dump/QueryParametersDumper.java | QueryParametersDumper.putDumpInfoTo | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(this.queryParametersMap.size() > 0) {
result.put(DumpConstants.QUERY_PARAMETERS, queryParametersMap);
}
} | java | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(this.queryParametersMap.size() > 0) {
result.put(DumpConstants.QUERY_PARAMETERS, queryParametersMap);
}
} | [
"@",
"Override",
"protected",
"void",
"putDumpInfoTo",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"if",
"(",
"this",
".",
"queryParametersMap",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"result",
".",
"put",
"(",
"DumpConstants... | put queryParametersMap to result.
@param result a Map you want to put dumping info to. | [
"put",
"queryParametersMap",
"to",
"result",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/QueryParametersDumper.java#L55-L60 | train | Put the dump info to the result map. | [
30522,
1030,
2058,
15637,
5123,
11675,
2404,
8566,
8737,
2378,
14876,
3406,
1006,
4949,
1026,
5164,
1010,
4874,
1028,
2765,
1007,
1063,
2065,
1006,
2023,
1012,
23032,
28689,
22828,
26212,
2361,
1012,
2946,
1006,
1007,
1028,
1014,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-optimizer/src/main/java/org/apache/flink/optimizer/DataStatistics.java | DataStatistics.cacheBaseStatistics | public void cacheBaseStatistics(BaseStatistics statistics, String identifier) {
synchronized (this.baseStatisticsCache) {
this.baseStatisticsCache.put(identifier, statistics);
}
} | java | public void cacheBaseStatistics(BaseStatistics statistics, String identifier) {
synchronized (this.baseStatisticsCache) {
this.baseStatisticsCache.put(identifier, statistics);
}
} | [
"public",
"void",
"cacheBaseStatistics",
"(",
"BaseStatistics",
"statistics",
",",
"String",
"identifier",
")",
"{",
"synchronized",
"(",
"this",
".",
"baseStatisticsCache",
")",
"{",
"this",
".",
"baseStatisticsCache",
".",
"put",
"(",
"identifier",
",",
"statist... | Caches the given statistics. They are later retrievable under the given identifier.
@param statistics The statistics to cache.
@param identifier The identifier which may be later used to retrieve the statistics. | [
"Caches",
"the",
"given",
"statistics",
".",
"They",
"are",
"later",
"retrievable",
"under",
"the",
"given",
"identifier",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/DataStatistics.java#L64-L68 | train | Cache a base statistics object. | [
30522,
2270,
11675,
17053,
15058,
9153,
16774,
6558,
1006,
7888,
29336,
6553,
2015,
6747,
1010,
5164,
8909,
4765,
18095,
1007,
1063,
25549,
1006,
2023,
1012,
7888,
29336,
6553,
15782,
5403,
1007,
1063,
2023,
1012,
7888,
29336,
6553,
15782,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/model/perceptron/PerceptronLexicalAnalyzer.java | PerceptronLexicalAnalyzer.learn | public boolean learn(String segmentedTaggedSentence)
{
Sentence sentence = Sentence.create(segmentedTaggedSentence);
return learn(sentence);
} | java | public boolean learn(String segmentedTaggedSentence)
{
Sentence sentence = Sentence.create(segmentedTaggedSentence);
return learn(sentence);
} | [
"public",
"boolean",
"learn",
"(",
"String",
"segmentedTaggedSentence",
")",
"{",
"Sentence",
"sentence",
"=",
"Sentence",
".",
"create",
"(",
"segmentedTaggedSentence",
")",
";",
"return",
"learn",
"(",
"sentence",
")",
";",
"}"
] | 在线学习
@param segmentedTaggedSentence 已分词、标好词性和命名实体的人民日报2014格式的句子
@return 是否学习成果(失败的原因是句子格式不合法) | [
"在线学习"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/model/perceptron/PerceptronLexicalAnalyzer.java#L147-L151 | train | This method is used to learn a single class from a sentence. | [
30522,
2270,
22017,
20898,
4553,
1006,
5164,
6903,
2098,
15900,
5999,
5054,
6528,
3401,
1007,
1063,
6251,
6251,
1027,
6251,
1012,
3443,
1006,
6903,
2098,
15900,
5999,
5054,
6528,
3401,
1007,
1025,
2709,
4553,
1006,
6251,
1007,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/SqlBuilder.java | SqlBuilder.validateEntity | private static void validateEntity(Entity entity) throws DbRuntimeException {
if (null == entity) {
throw new DbRuntimeException("Entity is null !");
}
if (StrUtil.isBlank(entity.getTableName())) {
throw new DbRuntimeException("Entity`s table name is null !");
}
if (entity.isEmpty()) {
throw new DbRuntimeException("No filed and value in this entity !");
}
} | java | private static void validateEntity(Entity entity) throws DbRuntimeException {
if (null == entity) {
throw new DbRuntimeException("Entity is null !");
}
if (StrUtil.isBlank(entity.getTableName())) {
throw new DbRuntimeException("Entity`s table name is null !");
}
if (entity.isEmpty()) {
throw new DbRuntimeException("No filed and value in this entity !");
}
} | [
"private",
"static",
"void",
"validateEntity",
"(",
"Entity",
"entity",
")",
"throws",
"DbRuntimeException",
"{",
"if",
"(",
"null",
"==",
"entity",
")",
"{",
"throw",
"new",
"DbRuntimeException",
"(",
"\"Entity is null !\"",
")",
";",
"}",
"if",
"(",
"StrUtil... | 验证实体类对象的有效性
@param entity 实体类对象
@throws DbRuntimeException SQL异常包装,获取元数据信息失败 | [
"验证实体类对象的有效性"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/SqlBuilder.java#L619-L629 | train | Validate the entity. | [
30522,
2797,
10763,
11675,
9398,
3686,
4765,
3012,
1006,
9178,
9178,
1007,
11618,
16962,
15532,
7292,
10288,
24422,
1063,
2065,
1006,
19701,
1027,
1027,
9178,
1007,
1063,
5466,
2047,
16962,
15532,
7292,
10288,
24422,
1006,
1000,
9178,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java | InstantiationUtil.instantiate | public static <T> T instantiate(final String className, final Class<T> targetType, final ClassLoader classLoader) throws ClassNotFoundException {
final Class<? extends T> clazz = Class.forName(
className,
false,
classLoader).asSubclass(targetType);
return instantiate(clazz);
} | java | public static <T> T instantiate(final String className, final Class<T> targetType, final ClassLoader classLoader) throws ClassNotFoundException {
final Class<? extends T> clazz = Class.forName(
className,
false,
classLoader).asSubclass(targetType);
return instantiate(clazz);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"instantiate",
"(",
"final",
"String",
"className",
",",
"final",
"Class",
"<",
"T",
">",
"targetType",
",",
"final",
"ClassLoader",
"classLoader",
")",
"throws",
"ClassNotFoundException",
"{",
"final",
"Class",
"<",
"... | Creates a new instance of the given class name and type using the provided {@link ClassLoader}.
@param className of the class to load
@param targetType type of the instantiated class
@param classLoader to use for loading the class
@param <T> type of the instantiated class
@return Instance of the given class name
@throws ClassNotFoundException if the class could not be found | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"given",
"class",
"name",
"and",
"type",
"using",
"the",
"provided",
"{",
"@link",
"ClassLoader",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java#L343-L350 | train | Instantiate a class with the specified name and class type. | [
30522,
2270,
10763,
1026,
1056,
1028,
1056,
7107,
13143,
1006,
2345,
5164,
2465,
18442,
1010,
2345,
2465,
1026,
1056,
1028,
4539,
13874,
1010,
2345,
2465,
11066,
2121,
2465,
11066,
2121,
1007,
11618,
2465,
17048,
14876,
8630,
10288,
24422,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/comparator/ComparatorChain.java | ComparatorChain.compare | @Override
public int compare(final E o1, final E o2) throws UnsupportedOperationException {
if (lock == false) {
checkChainIntegrity();
lock = true;
}
final Iterator<Comparator<E>> comparators = chain.iterator();
Comparator<? super E> comparator;
int retval;
for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) {
comparator = comparators.next();
retval = comparator.compare(o1, o2);
if (retval != 0) {
// invert the order if it is a reverse sort
if (true == orderingBits.get(comparatorIndex)) {
retval = (retval > 0) ? -1 : 1;
}
return retval;
}
}
// if comparators are exhausted, return 0
return 0;
} | java | @Override
public int compare(final E o1, final E o2) throws UnsupportedOperationException {
if (lock == false) {
checkChainIntegrity();
lock = true;
}
final Iterator<Comparator<E>> comparators = chain.iterator();
Comparator<? super E> comparator;
int retval;
for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) {
comparator = comparators.next();
retval = comparator.compare(o1, o2);
if (retval != 0) {
// invert the order if it is a reverse sort
if (true == orderingBits.get(comparatorIndex)) {
retval = (retval > 0) ? -1 : 1;
}
return retval;
}
}
// if comparators are exhausted, return 0
return 0;
} | [
"@",
"Override",
"public",
"int",
"compare",
"(",
"final",
"E",
"o1",
",",
"final",
"E",
"o2",
")",
"throws",
"UnsupportedOperationException",
"{",
"if",
"(",
"lock",
"==",
"false",
")",
"{",
"checkChainIntegrity",
"(",
")",
";",
"lock",
"=",
"true",
";"... | 执行比较<br>
按照比较器链的顺序分别比较,如果比较出相等则转向下一个比较器,否则直接返回
@param o1 第一个对象
@param o2 第二个对象
@return -1, 0, or 1
@throws UnsupportedOperationException 如果比较器链为空,无法完成比较 | [
"执行比较<br",
">",
"按照比较器链的顺序分别比较,如果比较出相等则转向下一个比较器,否则直接返回"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/comparator/ComparatorChain.java#L203-L227 | train | Compares two entities using the chain of Comparators. | [
30522,
1030,
2058,
15637,
2270,
20014,
12826,
1006,
2345,
1041,
1051,
2487,
1010,
2345,
1041,
1051,
2475,
1007,
11618,
4895,
6342,
9397,
15613,
25918,
3370,
10288,
24422,
1063,
2065,
1006,
5843,
1027,
1027,
6270,
1007,
1063,
4638,
24925,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/configuration/Configuration.java | Configuration.getDouble | public double getDouble(String key, double defaultValue) {
Object o = getRawValue(key);
if (o == null) {
return defaultValue;
}
return convertToDouble(o, defaultValue);
} | java | public double getDouble(String key, double defaultValue) {
Object o = getRawValue(key);
if (o == null) {
return defaultValue;
}
return convertToDouble(o, defaultValue);
} | [
"public",
"double",
"getDouble",
"(",
"String",
"key",
",",
"double",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"getRawValue",
"(",
"key",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"convertToDoubl... | Returns the value associated with the given key as a double.
@param key
the key pointing to the associated value
@param defaultValue
the default value which is returned in case there is no value associated with the given key
@return the (default) value associated with the given key | [
"Returns",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"as",
"a",
"double",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java#L500-L507 | train | Returns the double value for the given key. The defaultValue is returned if the key does not exist or if the value is not a double value. | [
30522,
2270,
3313,
2131,
26797,
3468,
1006,
5164,
3145,
1010,
3313,
12398,
10175,
5657,
1007,
1063,
4874,
1051,
1027,
2131,
2527,
2860,
10175,
5657,
1006,
3145,
1007,
1025,
2065,
1006,
1051,
1027,
1027,
19701,
1007,
1063,
2709,
12398,
10175... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/file/FileReader.java | FileReader.read | public <T> T read(ReaderHandler<T> readerHandler) throws IORuntimeException {
BufferedReader reader = null;
T result = null;
try {
reader = FileUtil.getReader(this.file, charset);
result = readerHandler.handle(reader);
} catch (IOException e) {
throw new IORuntimeException(e);
} finally {
IoUtil.close(reader);
}
return result;
} | java | public <T> T read(ReaderHandler<T> readerHandler) throws IORuntimeException {
BufferedReader reader = null;
T result = null;
try {
reader = FileUtil.getReader(this.file, charset);
result = readerHandler.handle(reader);
} catch (IOException e) {
throw new IORuntimeException(e);
} finally {
IoUtil.close(reader);
}
return result;
} | [
"public",
"<",
"T",
">",
"T",
"read",
"(",
"ReaderHandler",
"<",
"T",
">",
"readerHandler",
")",
"throws",
"IORuntimeException",
"{",
"BufferedReader",
"reader",
"=",
"null",
";",
"T",
"result",
"=",
"null",
";",
"try",
"{",
"reader",
"=",
"FileUtil",
".... | 按照给定的readerHandler读取文件中的数据
@param <T> 读取的结果对象类型
@param readerHandler Reader处理类
@return 从文件中read出的数据
@throws IORuntimeException IO异常 | [
"按照给定的readerHandler读取文件中的数据"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/file/FileReader.java#L209-L221 | train | Reads the file and invokes the specified reader handler for each file. | [
30522,
2270,
1026,
1056,
1028,
1056,
3191,
1006,
8068,
11774,
3917,
1026,
1056,
1028,
8068,
11774,
3917,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
17698,
2098,
16416,
4063,
8068,
1027,
19701,
1025,
1056,
2765,
1027,
19701,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-setting/src/main/java/cn/hutool/setting/Setting.java | Setting.getProps | public Props getProps(String group) {
final Props props = new Props();
props.putAll(getMap(group));
return props;
} | java | public Props getProps(String group) {
final Props props = new Props();
props.putAll(getMap(group));
return props;
} | [
"public",
"Props",
"getProps",
"(",
"String",
"group",
")",
"{",
"final",
"Props",
"props",
"=",
"new",
"Props",
"(",
")",
";",
"props",
".",
"putAll",
"(",
"getMap",
"(",
"group",
")",
")",
";",
"return",
"props",
";",
"}"
] | 获取group分组下所有配置键值对,组成新的{@link Props}
@param group 分组
@return Props对象
@since 4.1.21 | [
"获取group分组下所有配置键值对,组成新的",
"{",
"@link",
"Props",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/Setting.java#L300-L304 | train | Gets the Props for a given group. | [
30522,
2270,
24387,
2131,
21572,
4523,
1006,
5164,
2177,
1007,
1063,
2345,
24387,
24387,
1027,
2047,
24387,
1006,
1007,
1025,
24387,
1012,
2404,
8095,
1006,
2131,
2863,
2361,
1006,
2177,
1007,
1007,
1025,
2709,
24387,
1025,
1065,
30524,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/connection/ConnectionStateHandler.java | ConnectionStateHandler.setRunningStatusIfNecessary | public void setRunningStatusIfNecessary() {
if (ConnectionStatus.TRANSACTION != status.get() && ConnectionStatus.RUNNING != status.get()) {
status.getAndSet(ConnectionStatus.RUNNING);
}
} | java | public void setRunningStatusIfNecessary() {
if (ConnectionStatus.TRANSACTION != status.get() && ConnectionStatus.RUNNING != status.get()) {
status.getAndSet(ConnectionStatus.RUNNING);
}
} | [
"public",
"void",
"setRunningStatusIfNecessary",
"(",
")",
"{",
"if",
"(",
"ConnectionStatus",
".",
"TRANSACTION",
"!=",
"status",
".",
"get",
"(",
")",
"&&",
"ConnectionStatus",
".",
"RUNNING",
"!=",
"status",
".",
"get",
"(",
")",
")",
"{",
"status",
"."... | Change connection status to running if necessary. | [
"Change",
"connection",
"status",
"to",
"running",
"if",
"necessary",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/connection/ConnectionStateHandler.java#L60-L64 | train | Sets the running status if necessary. | [
30522,
2270,
11675,
2275,
15532,
5582,
9153,
5809,
10128,
2638,
9623,
10286,
2100,
1006,
1007,
1063,
2065,
1006,
7264,
29336,
2271,
1012,
12598,
999,
1027,
3570,
1012,
2131,
1006,
1007,
1004,
1004,
7264,
29336,
2271,
1012,
2770,
999,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONArray.java | JSONArray.getDouble | public double getDouble(int index) throws JSONException {
Object object = get(index);
Double result = JSON.toDouble(object);
if (result == null) {
throw JSON.typeMismatch(index, object, "double");
}
return result;
} | java | public double getDouble(int index) throws JSONException {
Object object = get(index);
Double result = JSON.toDouble(object);
if (result == null) {
throw JSON.typeMismatch(index, object, "double");
}
return result;
} | [
"public",
"double",
"getDouble",
"(",
"int",
"index",
")",
"throws",
"JSONException",
"{",
"Object",
"object",
"=",
"get",
"(",
"index",
")",
";",
"Double",
"result",
"=",
"JSON",
".",
"toDouble",
"(",
"object",
")",
";",
"if",
"(",
"result",
"==",
"nu... | Returns the value at {@code index} if it exists and is a double or can be coerced
to a double.
@param index the index to get the value from
@return the {@code value}
@throws JSONException if the value at {@code index} doesn't exist or cannot be
coerced to a double. | [
"Returns",
"the",
"value",
"at",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONArray.java#L370-L377 | train | Get the double value at the given index. | [
30522,
2270,
3313,
2131,
26797,
3468,
1006,
20014,
5950,
1007,
11618,
1046,
3385,
10288,
24422,
1063,
4874,
4874,
1027,
2131,
1006,
5950,
1007,
1025,
3313,
30524,
1063,
5466,
1046,
3385,
1012,
2828,
26725,
4017,
2818,
1006,
5950,
1010,
4874... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/state/SnapshotDirectory.java | SnapshotDirectory.cleanup | public boolean cleanup() throws IOException {
return !state.compareAndSet(State.ONGOING, State.DELETED) || fileSystem.delete(directory, true);
} | java | public boolean cleanup() throws IOException {
return !state.compareAndSet(State.ONGOING, State.DELETED) || fileSystem.delete(directory, true);
} | [
"public",
"boolean",
"cleanup",
"(",
")",
"throws",
"IOException",
"{",
"return",
"!",
"state",
".",
"compareAndSet",
"(",
"State",
".",
"ONGOING",
",",
"State",
".",
"DELETED",
")",
"||",
"fileSystem",
".",
"delete",
"(",
"directory",
",",
"true",
")",
... | Calling this method will attempt delete the underlying snapshot directory recursively, if the state is
"ongoing". In this case, the state will be set to "deleted" as a result of this call.
@return <code>true</code> if delete is successful, <code>false</code> otherwise.
@throws IOException if an exception happens during the delete. | [
"Calling",
"this",
"method",
"will",
"attempt",
"delete",
"the",
"underlying",
"snapshot",
"directory",
"recursively",
"if",
"the",
"state",
"is",
"ongoing",
".",
"In",
"this",
"case",
"the",
"state",
"will",
"be",
"set",
"to",
"deleted",
"as",
"a",
"result"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/state/SnapshotDirectory.java#L105-L107 | train | Deletes the directory. | [
30522,
2270,
22017,
20898,
27686,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
2709,
999,
2110,
1012,
12826,
29560,
3388,
1006,
2110,
1012,
7552,
1010,
2110,
1012,
17159,
1007,
1064,
1064,
6764,
27268,
30524,
14176,
1010,
2995,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-cache/src/main/java/cn/hutool/cache/file/AbstractFileCache.java | AbstractFileCache.getFileBytes | public byte[] getFileBytes(File file) throws IORuntimeException {
byte[] bytes = cache.get(file);
if (bytes != null) {
return bytes;
}
// add file
bytes = FileUtil.readBytes(file);
if ((maxFileSize != 0) && (file.length() > maxFileSize)) {
//大于缓存空间,不缓存,直接返回
return bytes;
}
usedSize += bytes.length;
//文件放入缓存,如果usedSize > capacity,purge()方法将被调用
cache.put(file, bytes);
return bytes;
} | java | public byte[] getFileBytes(File file) throws IORuntimeException {
byte[] bytes = cache.get(file);
if (bytes != null) {
return bytes;
}
// add file
bytes = FileUtil.readBytes(file);
if ((maxFileSize != 0) && (file.length() > maxFileSize)) {
//大于缓存空间,不缓存,直接返回
return bytes;
}
usedSize += bytes.length;
//文件放入缓存,如果usedSize > capacity,purge()方法将被调用
cache.put(file, bytes);
return bytes;
} | [
"public",
"byte",
"[",
"]",
"getFileBytes",
"(",
"File",
"file",
")",
"throws",
"IORuntimeException",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"cache",
".",
"get",
"(",
"file",
")",
";",
"if",
"(",
"bytes",
"!=",
"null",
")",
"{",
"return",
"bytes",
";",... | 获得缓存过的文件bytes
@param file 文件
@return 缓存过的文件bytes
@throws IORuntimeException IO异常 | [
"获得缓存过的文件bytes"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cache/src/main/java/cn/hutool/cache/file/AbstractFileCache.java#L102-L122 | train | Gets the bytes of a file. | [
30522,
2270,
24880,
1031,
1033,
2131,
8873,
2571,
3762,
4570,
1006,
5371,
5371,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
24880,
1031,
1033,
27507,
1027,
17053,
1012,
2131,
1006,
5371,
1007,
1025,
2065,
1006,
27507,
999,
1027,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java | URLUtil.url | public static URL url(String url, URLStreamHandler handler) {
Assert.notNull(url, "URL must not be null");
// 兼容Spring的ClassPath路径
if (url.startsWith(CLASSPATH_URL_PREFIX)) {
url = url.substring(CLASSPATH_URL_PREFIX.length());
return ClassLoaderUtil.getClassLoader().getResource(url);
}
try {
return new URL(null, url, handler);
} catch (MalformedURLException e) {
// 尝试文件路径
try {
return new File(url).toURI().toURL();
} catch (MalformedURLException ex2) {
throw new UtilException(e);
}
}
} | java | public static URL url(String url, URLStreamHandler handler) {
Assert.notNull(url, "URL must not be null");
// 兼容Spring的ClassPath路径
if (url.startsWith(CLASSPATH_URL_PREFIX)) {
url = url.substring(CLASSPATH_URL_PREFIX.length());
return ClassLoaderUtil.getClassLoader().getResource(url);
}
try {
return new URL(null, url, handler);
} catch (MalformedURLException e) {
// 尝试文件路径
try {
return new File(url).toURI().toURL();
} catch (MalformedURLException ex2) {
throw new UtilException(e);
}
}
} | [
"public",
"static",
"URL",
"url",
"(",
"String",
"url",
",",
"URLStreamHandler",
"handler",
")",
"{",
"Assert",
".",
"notNull",
"(",
"url",
",",
"\"URL must not be null\"",
")",
";",
"// 兼容Spring的ClassPath路径\r",
"if",
"(",
"url",
".",
"startsWith",
"(",
"CLASS... | 通过一个字符串形式的URL地址创建URL对象
@param url URL
@param handler {@link URLStreamHandler}
@return URL对象
@since 4.1.1 | [
"通过一个字符串形式的URL地址创建URL对象"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java#L79-L98 | train | Creates a new URL from the given URL. | [
30522,
2270,
10763,
24471,
2140,
24471,
2140,
1006,
5164,
24471,
2140,
1010,
24471,
4877,
25379,
11774,
3917,
28213,
1007,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
24471,
2140,
1010,
1000,
24471,
2140,
2442,
2025,
2022,
19701,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/generator/GridGraph.java | GridGraph.addDimension | public GridGraph addDimension(long size, boolean wrapEndpoints) {
Preconditions.checkArgument(size >= 2, "Dimension size must be at least 2");
vertexCount = Math.multiplyExact(vertexCount, size);
// prevent duplicate edges
if (size == 2) {
wrapEndpoints = false;
}
dimensions.add(new Tuple2<>(size, wrapEndpoints));
return this;
} | java | public GridGraph addDimension(long size, boolean wrapEndpoints) {
Preconditions.checkArgument(size >= 2, "Dimension size must be at least 2");
vertexCount = Math.multiplyExact(vertexCount, size);
// prevent duplicate edges
if (size == 2) {
wrapEndpoints = false;
}
dimensions.add(new Tuple2<>(size, wrapEndpoints));
return this;
} | [
"public",
"GridGraph",
"addDimension",
"(",
"long",
"size",
",",
"boolean",
"wrapEndpoints",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"size",
">=",
"2",
",",
"\"Dimension size must be at least 2\"",
")",
";",
"vertexCount",
"=",
"Math",
".",
"multiply... | Required configuration for each dimension of the graph.
@param size number of vertices; dimensions of size 1 are prohibited due to having no effect
on the generated graph
@param wrapEndpoints whether to connect first and last vertices; this has no effect on
dimensions of size 2
@return this | [
"Required",
"configuration",
"for",
"each",
"dimension",
"of",
"the",
"graph",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/generator/GridGraph.java#L71-L84 | train | Adds a dimension to the graph. | [
30522,
2270,
8370,
14413,
5587,
22172,
6132,
3258,
1006,
2146,
2946,
1010,
22017,
20898,
10236,
10497,
26521,
1007,
1063,
3653,
8663,
20562,
2015,
1012,
4638,
2906,
22850,
4765,
1006,
2946,
1028,
1027,
1016,
1010,
1000,
9812,
2946,
2442,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerSnapshotData.java | PojoSerializerSnapshotData.createFrom | static <T> PojoSerializerSnapshotData<T> createFrom(DataInputView in, ClassLoader userCodeClassLoader) throws IOException {
return PojoSerializerSnapshotData.readSnapshotData(in, userCodeClassLoader);
} | java | static <T> PojoSerializerSnapshotData<T> createFrom(DataInputView in, ClassLoader userCodeClassLoader) throws IOException {
return PojoSerializerSnapshotData.readSnapshotData(in, userCodeClassLoader);
} | [
"static",
"<",
"T",
">",
"PojoSerializerSnapshotData",
"<",
"T",
">",
"createFrom",
"(",
"DataInputView",
"in",
",",
"ClassLoader",
"userCodeClassLoader",
")",
"throws",
"IOException",
"{",
"return",
"PojoSerializerSnapshotData",
".",
"readSnapshotData",
"(",
"in",
... | Creates a {@link PojoSerializerSnapshotData} from serialized data stream.
<p>This factory method is meant to be used in regular read paths, i.e. when reading back a snapshot
of the {@link PojoSerializer}. POJO fields, registered subclass classes, and non-registered subclass
classes may no longer be present anymore. | [
"Creates",
"a",
"{",
"@link",
"PojoSerializerSnapshotData",
"}",
"from",
"serialized",
"data",
"stream",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerSnapshotData.java#L121-L123 | train | Creates a snapshot data from the given input view. | [
30522,
10763,
1026,
1056,
1028,
13433,
19929,
11610,
28863,
2015,
2532,
4523,
12326,
2850,
2696,
1026,
1056,
1028,
3443,
19699,
5358,
1006,
2951,
2378,
18780,
8584,
1999,
1010,
2465,
11066,
2121,
5310,
16044,
26266,
11066,
2121,
1007,
11618,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/comparator/CompareUtil.java | CompareUtil.compare | @SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> int compare(T o1, T o2, boolean isNullGreater) {
if (o1 == o2) {
return 0;
} else if (null == o1) {// null 排在后面
return isNullGreater ? 1 : -1;
} else if (null == o2) {
return isNullGreater ? -1 : 1;
}
if(o1 instanceof Comparable && o2 instanceof Comparable) {
//如果bean可比较,直接比较bean
return ((Comparable)o1).compareTo(o2);
}
if(o1.equals(o2)) {
return 0;
}
int result = Integer.compare(o1.hashCode(), o2.hashCode());
if(0 == result) {
result = compare(o1.toString(), o2.toString());
}
return result;
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> int compare(T o1, T o2, boolean isNullGreater) {
if (o1 == o2) {
return 0;
} else if (null == o1) {// null 排在后面
return isNullGreater ? 1 : -1;
} else if (null == o2) {
return isNullGreater ? -1 : 1;
}
if(o1 instanceof Comparable && o2 instanceof Comparable) {
//如果bean可比较,直接比较bean
return ((Comparable)o1).compareTo(o2);
}
if(o1.equals(o2)) {
return 0;
}
int result = Integer.compare(o1.hashCode(), o2.hashCode());
if(0 == result) {
result = compare(o1.toString(), o2.toString());
}
return result;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"<",
"T",
">",
"int",
"compare",
"(",
"T",
"o1",
",",
"T",
"o2",
",",
"boolean",
"isNullGreater",
")",
"{",
"if",
"(",
"o1",
"==",
"o2",
")",
"{",
... | 自然比较两个对象的大小,比较规则如下:
<pre>
1、如果实现Comparable调用compareTo比较
2、o1.equals(o2)返回0
3、比较hashCode值
4、比较toString值
</pre>
@param o1 对象1
@param o2 对象2
@param isNullGreater null值是否做为最大值
@return 比较结果,如果o1 < o2,返回数小于0,o1==o2返回0,o1 > o2 大于0 | [
"自然比较两个对象的大小,比较规则如下:"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/comparator/CompareUtil.java#L54-L79 | train | Compares two objects using the Java standard compare method. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1063,
1000,
4895,
5403,
18141,
1000,
1010,
1000,
6315,
13874,
2015,
1000,
1065,
1007,
2270,
10763,
1026,
1056,
1028,
20014,
12826,
1006,
1056,
1051,
2487,
1010,
1056,
1051,
2475,
1010,
22017,
2089... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/collection/trie/datrie/MutableDoubleArrayTrieInteger.java | MutableDoubleArrayTrieInteger.delete | public int delete(String key)
{
if (key == null)
{
return -1;
}
int curState = 1;
int[] ids = this.charMap.toIdList(key);
int[] path = new int[ids.length + 1];
int i = 0;
for (; i < ids.length; i++)
{
int c = ids[i];
if ((getBase(curState) + c >= getBaseArraySize())
|| (getCheck(getBase(curState) + c) != curState))
{
break;
}
curState = getBase(curState) + c;
path[i] = curState;
}
int ret = -1;
if (i == ids.length)
{
if (getCheck(getBase(curState) + UNUSED_CHAR_VALUE) == curState)
{
--this.size;
ret = getLeafValue(getBase(getBase(curState) + UNUSED_CHAR_VALUE));
path[(path.length - 1)] = (getBase(curState) + UNUSED_CHAR_VALUE);
for (int j = path.length - 1; j >= 0; --j)
{
boolean isLeaf = true;
int state = path[j];
for (int k = 0; k < this.charMap.getCharsetSize(); k++)
{
if (isLeafValue(getBase(state)))
{
break;
}
if ((getBase(state) + k < getBaseArraySize())
&& (getCheck(getBase(state) + k) == state))
{
isLeaf = false;
break;
}
}
if (!isLeaf)
{
break;
}
addFreeLink(state);
}
}
}
return ret;
} | java | public int delete(String key)
{
if (key == null)
{
return -1;
}
int curState = 1;
int[] ids = this.charMap.toIdList(key);
int[] path = new int[ids.length + 1];
int i = 0;
for (; i < ids.length; i++)
{
int c = ids[i];
if ((getBase(curState) + c >= getBaseArraySize())
|| (getCheck(getBase(curState) + c) != curState))
{
break;
}
curState = getBase(curState) + c;
path[i] = curState;
}
int ret = -1;
if (i == ids.length)
{
if (getCheck(getBase(curState) + UNUSED_CHAR_VALUE) == curState)
{
--this.size;
ret = getLeafValue(getBase(getBase(curState) + UNUSED_CHAR_VALUE));
path[(path.length - 1)] = (getBase(curState) + UNUSED_CHAR_VALUE);
for (int j = path.length - 1; j >= 0; --j)
{
boolean isLeaf = true;
int state = path[j];
for (int k = 0; k < this.charMap.getCharsetSize(); k++)
{
if (isLeafValue(getBase(state)))
{
break;
}
if ((getBase(state) + k < getBaseArraySize())
&& (getCheck(getBase(state) + k) == state))
{
isLeaf = false;
break;
}
}
if (!isLeaf)
{
break;
}
addFreeLink(state);
}
}
}
return ret;
} | [
"public",
"int",
"delete",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"curState",
"=",
"1",
";",
"int",
"[",
"]",
"ids",
"=",
"this",
".",
"charMap",
".",
"toIdList",
"(",
"key... | 删除键
@param key
@return 值 | [
"删除键"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/trie/datrie/MutableDoubleArrayTrieInteger.java#L856-L912 | train | Delete a single entry from the cache. | [
30522,
2270,
20014,
3972,
12870,
1006,
5164,
3145,
1007,
1063,
2065,
1006,
3145,
1027,
1027,
19701,
1007,
1063,
2709,
1011,
1015,
1025,
1065,
20014,
12731,
12096,
3686,
1027,
1015,
1025,
20014,
1031,
1033,
8909,
2015,
1027,
2023,
1012,
1108... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | common/src/main/java/io/netty/util/CharsetUtil.java | CharsetUtil.decoder | public static CharsetDecoder decoder(Charset charset) {
checkNotNull(charset, "charset");
Map<Charset, CharsetDecoder> map = InternalThreadLocalMap.get().charsetDecoderCache();
CharsetDecoder d = map.get(charset);
if (d != null) {
d.reset().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
return d;
}
d = decoder(charset, CodingErrorAction.REPLACE, CodingErrorAction.REPLACE);
map.put(charset, d);
return d;
} | java | public static CharsetDecoder decoder(Charset charset) {
checkNotNull(charset, "charset");
Map<Charset, CharsetDecoder> map = InternalThreadLocalMap.get().charsetDecoderCache();
CharsetDecoder d = map.get(charset);
if (d != null) {
d.reset().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
return d;
}
d = decoder(charset, CodingErrorAction.REPLACE, CodingErrorAction.REPLACE);
map.put(charset, d);
return d;
} | [
"public",
"static",
"CharsetDecoder",
"decoder",
"(",
"Charset",
"charset",
")",
"{",
"checkNotNull",
"(",
"charset",
",",
"\"charset\"",
")",
";",
"Map",
"<",
"Charset",
",",
"CharsetDecoder",
">",
"map",
"=",
"InternalThreadLocalMap",
".",
"get",
"(",
")",
... | Returns a cached thread-local {@link CharsetDecoder} for the specified {@link Charset}.
@param charset The specified charset
@return The decoder for the specified {@code charset} | [
"Returns",
"a",
"cached",
"thread",
"-",
"local",
"{",
"@link",
"CharsetDecoder",
"}",
"for",
"the",
"specified",
"{",
"@link",
"Charset",
"}",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/CharsetUtil.java#L169-L182 | train | Gets the charset decoder. | [
30522,
2270,
10763,
25869,
13462,
3207,
16044,
2099,
21933,
4063,
1006,
25869,
13462,
25869,
13462,
1007,
1063,
4638,
17048,
11231,
3363,
1006,
25869,
13462,
1010,
1000,
25869,
13462,
1000,
1007,
1025,
4949,
1026,
25869,
13462,
1010,
25869,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/util/HadoopUtils.java | HadoopUtils.isMinHadoopVersion | public static boolean isMinHadoopVersion(int major, int minor) throws FlinkRuntimeException {
String versionString = VersionInfo.getVersion();
String[] versionParts = versionString.split("\\.");
if (versionParts.length < 2) {
throw new FlinkRuntimeException(
"Cannot determine version of Hadoop, unexpected version string: " + versionString);
}
int maj = Integer.parseInt(versionParts[0]);
int min = Integer.parseInt(versionParts[1]);
return maj > major || (maj == major && min >= minor);
} | java | public static boolean isMinHadoopVersion(int major, int minor) throws FlinkRuntimeException {
String versionString = VersionInfo.getVersion();
String[] versionParts = versionString.split("\\.");
if (versionParts.length < 2) {
throw new FlinkRuntimeException(
"Cannot determine version of Hadoop, unexpected version string: " + versionString);
}
int maj = Integer.parseInt(versionParts[0]);
int min = Integer.parseInt(versionParts[1]);
return maj > major || (maj == major && min >= minor);
} | [
"public",
"static",
"boolean",
"isMinHadoopVersion",
"(",
"int",
"major",
",",
"int",
"minor",
")",
"throws",
"FlinkRuntimeException",
"{",
"String",
"versionString",
"=",
"VersionInfo",
".",
"getVersion",
"(",
")",
";",
"String",
"[",
"]",
"versionParts",
"=",
... | Checks if the Hadoop dependency is at least of the given version. | [
"Checks",
"if",
"the",
"Hadoop",
"dependency",
"is",
"at",
"least",
"of",
"the",
"given",
"version",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/util/HadoopUtils.java#L132-L145 | train | Checks if the Hadoop version is at least the given major and minor version. | [
30522,
2270,
10763,
22017,
20898,
2003,
10020,
16102,
18589,
27774,
1006,
20014,
2350,
1010,
20014,
3576,
1007,
11618,
13109,
19839,
15532,
7292,
10288,
24422,
1063,
5164,
4617,
18886,
3070,
1027,
2544,
2378,
14876,
1012,
2131,
27774,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/classification/statistics/ContinuousDistributions.java | ContinuousDistributions.GammaCdf | protected static double GammaCdf(double x, double a) throws IllegalArgumentException
{
if (x < 0)
{
throw new IllegalArgumentException();
}
double GI = 0;
if (a > 200)
{
double z = (x - a) / Math.sqrt(a);
double y = GaussCdf(z);
double b1 = 2 / Math.sqrt(a);
double phiz = 0.39894228 * Math.exp(-z * z / 2);
double w = y - b1 * (z * z - 1) * phiz / 6; //Edgeworth1
double b2 = 6 / a;
int zXor4 = ((int) z) ^ 4;
double u = 3 * b2 * (z * z - 3) + b1 * b1 * (zXor4 - 10 * z * z + 15);
GI = w - phiz * z * u / 72; //Edgeworth2
}
else if (x < a + 1)
{
GI = Gser(x, a);
}
else
{
GI = Gcf(x, a);
}
return GI;
} | java | protected static double GammaCdf(double x, double a) throws IllegalArgumentException
{
if (x < 0)
{
throw new IllegalArgumentException();
}
double GI = 0;
if (a > 200)
{
double z = (x - a) / Math.sqrt(a);
double y = GaussCdf(z);
double b1 = 2 / Math.sqrt(a);
double phiz = 0.39894228 * Math.exp(-z * z / 2);
double w = y - b1 * (z * z - 1) * phiz / 6; //Edgeworth1
double b2 = 6 / a;
int zXor4 = ((int) z) ^ 4;
double u = 3 * b2 * (z * z - 3) + b1 * b1 * (zXor4 - 10 * z * z + 15);
GI = w - phiz * z * u / 72; //Edgeworth2
}
else if (x < a + 1)
{
GI = Gser(x, a);
}
else
{
GI = Gcf(x, a);
}
return GI;
} | [
"protected",
"static",
"double",
"GammaCdf",
"(",
"double",
"x",
",",
"double",
"a",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"x",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"double",
"GI",
"=",
... | 伽马函数
@param x
@param a
@return
@throws IllegalArgumentException | [
"伽马函数"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/classification/statistics/ContinuousDistributions.java#L184-L214 | train | Gamma Cdf for a single value x | [
30522,
5123,
10763,
3313,
13091,
19797,
2546,
1006,
3313,
1060,
1010,
3313,
1037,
1007,
11618,
6206,
2906,
22850,
15781,
2595,
24422,
1063,
2065,
1006,
1060,
1026,
1014,
1007,
1063,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24422,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java | CalendarInterval.parseSecondNano | public static long parseSecondNano(String secondNano) throws IllegalArgumentException {
String[] parts = secondNano.split("\\.");
if (parts.length == 1) {
return toLongWithRange("second", parts[0], Long.MIN_VALUE / MICROS_PER_SECOND,
Long.MAX_VALUE / MICROS_PER_SECOND) * MICROS_PER_SECOND;
} else if (parts.length == 2) {
long seconds = parts[0].equals("") ? 0L : toLongWithRange("second", parts[0],
Long.MIN_VALUE / MICROS_PER_SECOND, Long.MAX_VALUE / MICROS_PER_SECOND);
long nanos = toLongWithRange("nanosecond", parts[1], 0L, 999999999L);
return seconds * MICROS_PER_SECOND + nanos / 1000L;
} else {
throw new IllegalArgumentException(
"Interval string does not match second-nano format of ss.nnnnnnnnn");
}
} | java | public static long parseSecondNano(String secondNano) throws IllegalArgumentException {
String[] parts = secondNano.split("\\.");
if (parts.length == 1) {
return toLongWithRange("second", parts[0], Long.MIN_VALUE / MICROS_PER_SECOND,
Long.MAX_VALUE / MICROS_PER_SECOND) * MICROS_PER_SECOND;
} else if (parts.length == 2) {
long seconds = parts[0].equals("") ? 0L : toLongWithRange("second", parts[0],
Long.MIN_VALUE / MICROS_PER_SECOND, Long.MAX_VALUE / MICROS_PER_SECOND);
long nanos = toLongWithRange("nanosecond", parts[1], 0L, 999999999L);
return seconds * MICROS_PER_SECOND + nanos / 1000L;
} else {
throw new IllegalArgumentException(
"Interval string does not match second-nano format of ss.nnnnnnnnn");
}
} | [
"public",
"static",
"long",
"parseSecondNano",
"(",
"String",
"secondNano",
")",
"throws",
"IllegalArgumentException",
"{",
"String",
"[",
"]",
"parts",
"=",
"secondNano",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"if",
"(",
"parts",
".",
"length",
"==",
"1"... | Parse second_nano string in ss.nnnnnnnnn format to microseconds | [
"Parse",
"second_nano",
"string",
"in",
"ss",
".",
"nnnnnnnnn",
"format",
"to",
"microseconds"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java#L238-L254 | train | Parse second - nano string. | [
30522,
2270,
10763,
2146,
11968,
8583,
8586,
30524,
3091,
1027,
1027,
1015,
1007,
1063,
2709,
2000,
10052,
24415,
24388,
2063,
1006,
1000,
2117,
1000,
1010,
3033,
1031,
1014,
1033,
1010,
2146,
1012,
8117,
1035,
3643,
1013,
12702,
2015,
1035... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/sketch/src/main/java/org/apache/spark/util/sketch/BitArray.java | BitArray.set | boolean set(long index) {
if (!get(index)) {
data[(int) (index >>> 6)] |= (1L << index);
bitCount++;
return true;
}
return false;
} | java | boolean set(long index) {
if (!get(index)) {
data[(int) (index >>> 6)] |= (1L << index);
bitCount++;
return true;
}
return false;
} | [
"boolean",
"set",
"(",
"long",
"index",
")",
"{",
"if",
"(",
"!",
"get",
"(",
"index",
")",
")",
"{",
"data",
"[",
"(",
"int",
")",
"(",
"index",
">>>",
"6",
")",
"]",
"|=",
"(",
"1L",
"<<",
"index",
")",
";",
"bitCount",
"++",
";",
"return",... | Returns true if the bit changed value. | [
"Returns",
"true",
"if",
"the",
"bit",
"changed",
"value",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/sketch/src/main/java/org/apache/spark/util/sketch/BitArray.java#L54-L61 | train | Sets the bit at the given index. | [
30522,
22017,
20898,
2275,
1006,
2146,
5950,
1007,
1063,
2065,
1006,
999,
2131,
1006,
5950,
1007,
1007,
1063,
2951,
1031,
1006,
20014,
1007,
1006,
5950,
1028,
1028,
1028,
1020,
1007,
1033,
1064,
1027,
1006,
1015,
2140,
1026,
1026,
5950,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpUtil.java | HttpUtil.toParams | public static String toParams(Map<String, Object> paramMap, String charsetName) {
return toParams(paramMap, CharsetUtil.charset(charsetName));
} | java | public static String toParams(Map<String, Object> paramMap, String charsetName) {
return toParams(paramMap, CharsetUtil.charset(charsetName));
} | [
"public",
"static",
"String",
"toParams",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"paramMap",
",",
"String",
"charsetName",
")",
"{",
"return",
"toParams",
"(",
"paramMap",
",",
"CharsetUtil",
".",
"charset",
"(",
"charsetName",
")",
")",
";",
"}"
] | 将Map形式的Form表单数据转换为Url参数形式<br>
编码键和值对
@param paramMap 表单数据
@param charsetName 编码
@return url参数 | [
"将Map形式的Form表单数据转换为Url参数形式<br",
">",
"编码键和值对"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java#L372-L374 | train | Converts a Map of parameters to a String. | [
30522,
2270,
10763,
5164,
2327,
5400,
5244,
1006,
4949,
1026,
5164,
1010,
4874,
1028,
11498,
14760,
2361,
1010,
5164,
25869,
13462,
18442,
1007,
1063,
2709,
2327,
5400,
5244,
1006,
11498,
14760,
2361,
1010,
25869,
13462,
21823,
2140,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.lastModifiedTime | public static Date lastModifiedTime(File file) {
if (!exist(file)) {
return null;
}
return new Date(file.lastModified());
} | java | public static Date lastModifiedTime(File file) {
if (!exist(file)) {
return null;
}
return new Date(file.lastModified());
} | [
"public",
"static",
"Date",
"lastModifiedTime",
"(",
"File",
"file",
")",
"{",
"if",
"(",
"!",
"exist",
"(",
"file",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"Date",
"(",
"file",
".",
"lastModified",
"(",
")",
")",
";",
"}"
] | 指定文件最后修改时间
@param file 文件
@return 最后修改时间 | [
"指定文件最后修改时间"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L512-L518 | train | Returns the last modified time of the specified file. | [
30522,
2270,
10763,
3058,
2197,
5302,
4305,
10451,
7292,
1006,
5371,
5371,
1007,
1063,
2065,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java | ParameterTool.getByte | public byte getByte(String key) {
addToDefaults(key, null);
String value = getRequired(key);
return Byte.valueOf(value);
} | java | public byte getByte(String key) {
addToDefaults(key, null);
String value = getRequired(key);
return Byte.valueOf(value);
} | [
"public",
"byte",
"getByte",
"(",
"String",
"key",
")",
"{",
"addToDefaults",
"(",
"key",
",",
"null",
")",
";",
"String",
"value",
"=",
"getRequired",
"(",
"key",
")",
";",
"return",
"Byte",
".",
"valueOf",
"(",
"value",
")",
";",
"}"
] | Returns the Byte value for the given key.
The method fails if the key does not exist. | [
"Returns",
"the",
"Byte",
"value",
"for",
"the",
"given",
"key",
".",
"The",
"method",
"fails",
"if",
"the",
"key",
"does",
"not",
"exist",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java#L439-L443 | train | Gets a property as a byte. | [
30522,
2270,
24880,
2131,
3762,
2618,
1006,
5164,
3145,
1007,
1063,
5587,
3406,
3207,
7011,
11314,
2015,
1006,
3145,
1010,
19701,
1007,
1025,
5164,
3643,
1027,
2131,
2890,
15549,
5596,
1006,
3145,
1007,
1025,
2709,
24880,
1012,
3643,
11253,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java | HttpHeaders.getDate | @Deprecated
public static Date getDate(HttpMessage message) throws ParseException {
return getDateHeader(message, HttpHeaderNames.DATE);
} | java | @Deprecated
public static Date getDate(HttpMessage message) throws ParseException {
return getDateHeader(message, HttpHeaderNames.DATE);
} | [
"@",
"Deprecated",
"public",
"static",
"Date",
"getDate",
"(",
"HttpMessage",
"message",
")",
"throws",
"ParseException",
"{",
"return",
"getDateHeader",
"(",
"message",
",",
"HttpHeaderNames",
".",
"DATE",
")",
";",
"}"
] | @deprecated Use {@link #getTimeMillis(CharSequence)} instead.
Returns the value of the {@code "Date"} header.
@throws ParseException
if there is no such header or the header value is not a formatted date | [
"@deprecated",
"Use",
"{",
"@link",
"#getTimeMillis",
"(",
"CharSequence",
")",
"}",
"instead",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java#L1047-L1050 | train | Gets the Date value from the message. | [
30522,
1030,
2139,
28139,
12921,
2270,
10763,
3058,
2131,
13701,
1006,
8299,
7834,
3736,
3351,
4471,
1007,
11618,
11968,
19763,
2595,
24422,
1063,
2709,
2131,
13701,
4974,
2121,
1006,
4471,
1010,
8299,
4974,
11795,
14074,
2015,
1012,
3058,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/Runner.java | Runner.getAlgorithmsListing | private static String getAlgorithmsListing() {
StrBuilder strBuilder = new StrBuilder();
strBuilder
.appendNewLine()
.appendln("Select an algorithm to view usage: flink run examples/flink-gelly-examples_<version>.jar --algorithm <algorithm>")
.appendNewLine()
.appendln("Available algorithms:");
for (Driver algorithm : driverFactory) {
strBuilder.append(" ")
.appendFixedWidthPadRight(algorithm.getName(), 30, ' ')
.append(algorithm.getShortDescription()).appendNewLine();
}
return strBuilder.toString();
} | java | private static String getAlgorithmsListing() {
StrBuilder strBuilder = new StrBuilder();
strBuilder
.appendNewLine()
.appendln("Select an algorithm to view usage: flink run examples/flink-gelly-examples_<version>.jar --algorithm <algorithm>")
.appendNewLine()
.appendln("Available algorithms:");
for (Driver algorithm : driverFactory) {
strBuilder.append(" ")
.appendFixedWidthPadRight(algorithm.getName(), 30, ' ')
.append(algorithm.getShortDescription()).appendNewLine();
}
return strBuilder.toString();
} | [
"private",
"static",
"String",
"getAlgorithmsListing",
"(",
")",
"{",
"StrBuilder",
"strBuilder",
"=",
"new",
"StrBuilder",
"(",
")",
";",
"strBuilder",
".",
"appendNewLine",
"(",
")",
".",
"appendln",
"(",
"\"Select an algorithm to view usage: flink run examples/flink-... | List available algorithms. This is displayed to the user when no valid
algorithm is given in the program parameterization.
@return usage string listing available algorithms | [
"List",
"available",
"algorithms",
".",
"This",
"is",
"displayed",
"to",
"the",
"user",
"when",
"no",
"valid",
"algorithm",
"is",
"given",
"in",
"the",
"program",
"parameterization",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/Runner.java#L191-L207 | train | Get a string listing of available algorithms. | [
30522,
2797,
10763,
5164,
2131,
2389,
20255,
8939,
5244,
9863,
2075,
1006,
1007,
1063,
2358,
15185,
19231,
4063,
2358,
15185,
19231,
4063,
1027,
2047,
2358,
15185,
19231,
4063,
1006,
1007,
1025,
2358,
15185,
19231,
4063,
1012,
10439,
10497,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.ls | public static File[] ls(String path) {
if (path == null) {
return null;
}
path = getAbsolutePath(path);
File file = file(path);
if (file.isDirectory()) {
return file.listFiles();
}
throw new IORuntimeException(StrUtil.format("Path [{}] is not directory!", path));
} | java | public static File[] ls(String path) {
if (path == null) {
return null;
}
path = getAbsolutePath(path);
File file = file(path);
if (file.isDirectory()) {
return file.listFiles();
}
throw new IORuntimeException(StrUtil.format("Path [{}] is not directory!", path));
} | [
"public",
"static",
"File",
"[",
"]",
"ls",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"path",
"=",
"getAbsolutePath",
"(",
"path",
")",
";",
"File",
"file",
"=",
"file",
"(",
"path",
"... | 列出目录文件<br>
给定的绝对路径不能是压缩包中的路径
@param path 目录绝对路径或者相对路径
@return 文件列表(包含目录) | [
"列出目录文件<br",
">",
"给定的绝对路径不能是压缩包中的路径"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L105-L117 | train | Returns an array of files in the specified path. | [
30522,
2270,
10763,
5371,
1031,
1033,
1048,
2015,
1006,
5164,
4130,
1007,
1063,
2065,
1006,
4130,
1027,
1027,
19701,
1007,
1063,
2709,
19701,
1025,
1065,
4130,
1027,
2131,
7875,
19454,
10421,
15069,
1006,
4130,
1007,
1025,
5371,
5371,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | utility/src/main/java/com/networknt/utility/RegExUtils.java | RegExUtils.replaceFirst | public static String replaceFirst(final String text, final String regex, final String replacement) {
if (text == null || regex == null|| replacement == null ) {
return text;
}
return text.replaceFirst(regex, replacement);
} | java | public static String replaceFirst(final String text, final String regex, final String replacement) {
if (text == null || regex == null|| replacement == null ) {
return text;
}
return text.replaceFirst(regex, replacement);
} | [
"public",
"static",
"String",
"replaceFirst",
"(",
"final",
"String",
"text",
",",
"final",
"String",
"regex",
",",
"final",
"String",
"replacement",
")",
"{",
"if",
"(",
"text",
"==",
"null",
"||",
"regex",
"==",
"null",
"||",
"replacement",
"==",
"null",... | <p>Replaces the first substring of the text string that matches the given regular expression
with the given replacement.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code text.replaceFirst(regex, replacement)}</li>
<li>{@code Pattern.compile(regex).matcher(text).replaceFirst(replacement)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<p>The {@link Pattern#DOTALL} option is NOT automatically added.
To use the DOTALL option prepend <code>"(?s)"</code> to the regex.
DOTALL is also known as single-line mode in Perl.</p>
<pre>
StringUtils.replaceFirst(null, *, *) = null
StringUtils.replaceFirst("any", (String) null, *) = "any"
StringUtils.replaceFirst("any", *, null) = "any"
StringUtils.replaceFirst("", "", "zzz") = "zzz"
StringUtils.replaceFirst("", ".*", "zzz") = "zzz"
StringUtils.replaceFirst("", ".+", "zzz") = ""
StringUtils.replaceFirst("abc", "", "ZZ") = "ZZabc"
StringUtils.replaceFirst("<__>\n<__>", "<.*>", "z") = "z\n<__>"
StringUtils.replaceFirst("<__>\n<__>", "(?s)<.*>", "z") = "z"
StringUtils.replaceFirst("ABCabc123", "[a-z]", "_") = "ABC_bc123"
StringUtils.replaceFirst("ABCabc123abc", "[^A-Z0-9]+", "_") = "ABC_123abc"
StringUtils.replaceFirst("ABCabc123abc", "[^A-Z0-9]+", "") = "ABC123abc"
StringUtils.replaceFirst("Lorem ipsum dolor sit", "( +)([a-z]+)", "_$2") = "Lorem_ipsum dolor sit"
</pre>
@param text text to search and replace in, may be null
@param regex the regular expression to which this string is to be matched
@param replacement the string to be substituted for the first match
@return the text with the first replacement processed,
{@code null} if null String input
@throws java.util.regex.PatternSyntaxException
if the regular expression's syntax is invalid
@see String#replaceFirst(String, String)
@see java.util.regex.Pattern
@see java.util.regex.Pattern#DOTALL | [
"<p",
">",
"Replaces",
"the",
"first",
"substring",
"of",
"the",
"text",
"string",
"that",
"matches",
"the",
"given",
"regular",
"expression",
"with",
"the",
"given",
"replacement",
".",
"<",
"/",
"p",
">"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/RegExUtils.java#L407-L412 | train | Replace first occurrence of a regular expression with a replacement string. | [
30522,
2270,
10763,
5164,
5672,
8873,
12096,
1006,
2345,
5164,
3793,
1010,
2345,
5164,
19723,
10288,
1010,
2345,
5164,
6110,
1007,
1063,
2065,
1006,
3793,
1027,
1027,
19701,
1064,
1064,
19723,
10288,
1027,
1027,
19701,
1064,
1064,
6110,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java | ImgUtil.pressImage | public static BufferedImage pressImage(Image srcImage, Image pressImg, Rectangle rectangle, float alpha) {
return Img.from(srcImage).pressImage(pressImg, rectangle, alpha).getImg();
} | java | public static BufferedImage pressImage(Image srcImage, Image pressImg, Rectangle rectangle, float alpha) {
return Img.from(srcImage).pressImage(pressImg, rectangle, alpha).getImg();
} | [
"public",
"static",
"BufferedImage",
"pressImage",
"(",
"Image",
"srcImage",
",",
"Image",
"pressImg",
",",
"Rectangle",
"rectangle",
",",
"float",
"alpha",
")",
"{",
"return",
"Img",
".",
"from",
"(",
"srcImage",
")",
".",
"pressImage",
"(",
"pressImg",
","... | 给图片添加图片水印<br>
此方法并不关闭流
@param srcImage 源图像流
@param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
@param rectangle 矩形对象,表示矩形区域的x,y,width,height,x,y从背景图片中心计算
@param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
@return 结果图片
@since 4.1.14 | [
"给图片添加图片水印<br",
">",
"此方法并不关闭流"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L987-L989 | train | Press an image on the specified rectangle. | [
30522,
2270,
10763,
17698,
2098,
9581,
3351,
2811,
9581,
3351,
1006,
3746,
5034,
6895,
26860,
1010,
3746,
2811,
5714,
2290,
1010,
28667,
23395,
28667,
23395,
1010,
14257,
6541,
1007,
1063,
2709,
10047,
2290,
1012,
2013,
1006,
5034,
6895,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-connectors/flink-orc/src/main/java/org/apache/flink/orc/OrcRowInputFormat.java | OrcRowInputFormat.ensureBatch | private boolean ensureBatch() throws IOException {
if (nextRow >= rowsInBatch) {
// No more rows available in the Rows array.
nextRow = 0;
// Try to read the next batch if rows from the ORC file.
boolean moreRows = orcRowsReader.nextBatch(rowBatch);
if (moreRows) {
// Load the data into the Rows array.
rowsInBatch = fillRows(rows, schema, rowBatch, selectedFields);
}
return moreRows;
}
// there is at least one Row left in the Rows array.
return true;
} | java | private boolean ensureBatch() throws IOException {
if (nextRow >= rowsInBatch) {
// No more rows available in the Rows array.
nextRow = 0;
// Try to read the next batch if rows from the ORC file.
boolean moreRows = orcRowsReader.nextBatch(rowBatch);
if (moreRows) {
// Load the data into the Rows array.
rowsInBatch = fillRows(rows, schema, rowBatch, selectedFields);
}
return moreRows;
}
// there is at least one Row left in the Rows array.
return true;
} | [
"private",
"boolean",
"ensureBatch",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"nextRow",
">=",
"rowsInBatch",
")",
"{",
"// No more rows available in the Rows array.",
"nextRow",
"=",
"0",
";",
"// Try to read the next batch if rows from the ORC file.",
"boolean",... | Checks if there is at least one row left in the batch to return.
If no more row are available, it reads another batch of rows.
@return Returns true if there is one more row to return, false otherwise.
@throws IOException throw if an exception happens while reading a batch. | [
"Checks",
"if",
"there",
"is",
"at",
"least",
"one",
"row",
"left",
"in",
"the",
"batch",
"to",
"return",
".",
"If",
"no",
"more",
"row",
"are",
"available",
"it",
"reads",
"another",
"batch",
"of",
"rows",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-orc/src/main/java/org/apache/flink/orc/OrcRowInputFormat.java#L323-L339 | train | Ensures that the next batch is available. | [
30522,
2797,
22017,
20898,
5676,
14479,
2818,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
2065,
1006,
2279,
10524,
1028,
1027,
10281,
2378,
14479,
2818,
1007,
1063,
1013,
1013,
2053,
2062,
10281,
2800,
1999,
1996,
10281,
9140,
1012,
2279,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/convert/impl/CollectionConverter.java | CollectionConverter.convertInternal | protected Collection<?> convertInternal(Object value) {
final Collection<Object> collection = CollectionUtil.create(TypeUtil.getClass(this.collectionType));
return CollUtil.addAll(collection, value, this.elementType);
} | java | protected Collection<?> convertInternal(Object value) {
final Collection<Object> collection = CollectionUtil.create(TypeUtil.getClass(this.collectionType));
return CollUtil.addAll(collection, value, this.elementType);
} | [
"protected",
"Collection",
"<",
"?",
">",
"convertInternal",
"(",
"Object",
"value",
")",
"{",
"final",
"Collection",
"<",
"Object",
">",
"collection",
"=",
"CollectionUtil",
".",
"create",
"(",
"TypeUtil",
".",
"getClass",
"(",
"this",
".",
"collectionType",
... | 内部转换
@param value 值
@return 转换后的集合对象 | [
"内部转换"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/convert/impl/CollectionConverter.java#L79-L82 | train | Convert internal. | [
30522,
5123,
3074,
1026,
1029,
1028,
10463,
18447,
11795,
2389,
1006,
4874,
3643,
1007,
1063,
2345,
3074,
1026,
4874,
1028,
3074,
1027,
3074,
21823,
2140,
1012,
3443,
1006,
2828,
21823,
2140,
1012,
2131,
26266,
1006,
2023,
1012,
3074,
13874... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/util/ShutdownHookUtil.java | ShutdownHookUtil.addShutdownHookThread | public static boolean addShutdownHookThread(
final Thread shutdownHook,
final String serviceName,
final Logger logger) {
checkNotNull(shutdownHook);
checkNotNull(logger);
try {
// Add JVM shutdown hook to call shutdown of service
Runtime.getRuntime().addShutdownHook(shutdownHook);
return true;
} catch (IllegalStateException e) {
// JVM is already shutting down. no need to do our work
} catch (Throwable t) {
logger.error("Cannot register shutdown hook that cleanly terminates {}.", serviceName, t);
}
return false;
} | java | public static boolean addShutdownHookThread(
final Thread shutdownHook,
final String serviceName,
final Logger logger) {
checkNotNull(shutdownHook);
checkNotNull(logger);
try {
// Add JVM shutdown hook to call shutdown of service
Runtime.getRuntime().addShutdownHook(shutdownHook);
return true;
} catch (IllegalStateException e) {
// JVM is already shutting down. no need to do our work
} catch (Throwable t) {
logger.error("Cannot register shutdown hook that cleanly terminates {}.", serviceName, t);
}
return false;
} | [
"public",
"static",
"boolean",
"addShutdownHookThread",
"(",
"final",
"Thread",
"shutdownHook",
",",
"final",
"String",
"serviceName",
",",
"final",
"Logger",
"logger",
")",
"{",
"checkNotNull",
"(",
"shutdownHook",
")",
";",
"checkNotNull",
"(",
"logger",
")",
... | Adds a shutdown hook to the JVM.
@param shutdownHook Shutdown hook to be registered.
@param serviceName The name of service.
@param logger The logger to log.
@return Whether the hook has been successfully registered. | [
"Adds",
"a",
"shutdown",
"hook",
"to",
"the",
"JVM",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/ShutdownHookUtil.java#L60-L78 | train | Add a shutdown hook to the JVM. | [
30522,
2270,
10763,
22017,
20898,
9909,
6979,
2102,
7698,
6806,
6559,
2705,
16416,
2094,
1006,
2345,
11689,
3844,
7698,
6806,
6559,
1010,
2345,
5164,
2326,
18442,
1010,
2345,
8833,
4590,
8833,
4590,
1007,
1063,
4638,
17048,
11231,
3363,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/digest/DigestUtil.java | DigestUtil.sha1Hex | public static String sha1Hex(String data, String charset) {
return new Digester(DigestAlgorithm.SHA1).digestHex(data, charset);
} | java | public static String sha1Hex(String data, String charset) {
return new Digester(DigestAlgorithm.SHA1).digestHex(data, charset);
} | [
"public",
"static",
"String",
"sha1Hex",
"(",
"String",
"data",
",",
"String",
"charset",
")",
"{",
"return",
"new",
"Digester",
"(",
"DigestAlgorithm",
".",
"SHA1",
")",
".",
"digestHex",
"(",
"data",
",",
"charset",
")",
";",
"}"
] | 计算SHA-1摘要值,并转为16进制字符串
@param data 被摘要数据
@param charset 编码
@return SHA-1摘要的16进制表示 | [
"计算SHA",
"-",
"1摘要值,并转为16进制字符串"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/digest/DigestUtil.java#L201-L203 | train | Returns the hexadecimal value of the given data using the SHA1 algorithm. | [
30522,
2270,
10763,
5164,
21146,
2487,
5369,
2595,
1006,
5164,
2951,
1010,
5164,
25869,
13462,
1007,
1063,
2709,
2047,
17886,
2121,
1006,
17886,
2389,
20255,
8939,
2213,
1012,
21146,
2487,
1007,
1012,
17886,
5369,
2595,
1006,
2951,
1010,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/constant/properties/ShardingProperties.java | ShardingProperties.getValue | @SuppressWarnings("unchecked")
public <T> T getValue(final ShardingPropertiesConstant shardingPropertiesConstant) {
if (cachedProperties.containsKey(shardingPropertiesConstant)) {
return (T) cachedProperties.get(shardingPropertiesConstant);
}
String value = props.getProperty(shardingPropertiesConstant.getKey());
if (Strings.isNullOrEmpty(value)) {
Object obj = props.get(shardingPropertiesConstant.getKey());
if (null == obj) {
value = shardingPropertiesConstant.getDefaultValue();
} else {
value = obj.toString();
}
}
Object result;
if (boolean.class == shardingPropertiesConstant.getType()) {
result = Boolean.valueOf(value);
} else if (int.class == shardingPropertiesConstant.getType()) {
result = Integer.valueOf(value);
} else if (long.class == shardingPropertiesConstant.getType()) {
result = Long.valueOf(value);
} else {
result = value;
}
cachedProperties.put(shardingPropertiesConstant, result);
return (T) result;
} | java | @SuppressWarnings("unchecked")
public <T> T getValue(final ShardingPropertiesConstant shardingPropertiesConstant) {
if (cachedProperties.containsKey(shardingPropertiesConstant)) {
return (T) cachedProperties.get(shardingPropertiesConstant);
}
String value = props.getProperty(shardingPropertiesConstant.getKey());
if (Strings.isNullOrEmpty(value)) {
Object obj = props.get(shardingPropertiesConstant.getKey());
if (null == obj) {
value = shardingPropertiesConstant.getDefaultValue();
} else {
value = obj.toString();
}
}
Object result;
if (boolean.class == shardingPropertiesConstant.getType()) {
result = Boolean.valueOf(value);
} else if (int.class == shardingPropertiesConstant.getType()) {
result = Integer.valueOf(value);
} else if (long.class == shardingPropertiesConstant.getType()) {
result = Long.valueOf(value);
} else {
result = value;
}
cachedProperties.put(shardingPropertiesConstant, result);
return (T) result;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"getValue",
"(",
"final",
"ShardingPropertiesConstant",
"shardingPropertiesConstant",
")",
"{",
"if",
"(",
"cachedProperties",
".",
"containsKey",
"(",
"shardingPropertiesConstant",
")",... | Get property value.
@param shardingPropertiesConstant sharding properties constant
@param <T> class type of return value
@return property value | [
"Get",
"property",
"value",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/constant/properties/ShardingProperties.java#L85-L111 | train | Gets the value of the sharding properties constant. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2270,
1026,
1056,
1028,
1056,
2131,
10175,
5657,
1006,
2345,
21146,
17080,
3070,
21572,
4842,
7368,
8663,
12693,
2102,
21146,
17080,
3070,
21572,
4842,
7368,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java | SqlValidatorImpl.getParentCursor | public String getParentCursor(String columnListParamName) {
FunctionParamInfo funcParamInfo = functionCallStack.peek();
Map<String, String> parentCursorMap =
funcParamInfo.columnListParamToParentCursorMap;
return parentCursorMap.get(columnListParamName);
} | java | public String getParentCursor(String columnListParamName) {
FunctionParamInfo funcParamInfo = functionCallStack.peek();
Map<String, String> parentCursorMap =
funcParamInfo.columnListParamToParentCursorMap;
return parentCursorMap.get(columnListParamName);
} | [
"public",
"String",
"getParentCursor",
"(",
"String",
"columnListParamName",
")",
"{",
"FunctionParamInfo",
"funcParamInfo",
"=",
"functionCallStack",
".",
"peek",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"parentCursorMap",
"=",
"funcParamInfo",
".... | implement SqlValidator | [
"implement",
"SqlValidator"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L401-L406 | train | Get the parent cursor for the given column list parameter name. | [
30522,
2270,
5164,
2131,
19362,
4765,
10841,
25301,
2099,
1006,
5164,
5930,
9863,
28689,
2213,
18442,
1007,
1063,
3853,
28689,
10020,
14876,
4569,
21906,
5400,
10020,
14876,
1027,
3853,
9289,
4877,
2696,
3600,
1012,
19043,
1006,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java | Ftp.upload | @Override
public boolean upload(String path, File file) {
Assert.notNull(file, "file to upload is null !");
return upload(path, file.getName(), file);
} | java | @Override
public boolean upload(String path, File file) {
Assert.notNull(file, "file to upload is null !");
return upload(path, file.getName(), file);
} | [
"@",
"Override",
"public",
"boolean",
"upload",
"(",
"String",
"path",
",",
"File",
"file",
")",
"{",
"Assert",
".",
"notNull",
"(",
"file",
",",
"\"file to upload is null !\"",
")",
";",
"return",
"upload",
"(",
"path",
",",
"file",
".",
"getName",
"(",
... | 上传文件到指定目录,可选:
<pre>
1. path为null或""上传到当前路径
2. path为相对路径则相对于当前路径的子路径
3. path为绝对路径则上传到此路径
</pre>
@param path 服务端路径,可以为{@code null} 或者相对路径或绝对路径
@param file 文件
@return 是否上传成功 | [
"上传文件到指定目录,可选:"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java#L362-L366 | train | Uploads a file to the server. | [
30522,
1030,
2058,
15637,
2270,
22017,
20898,
2039,
11066,
1006,
5164,
4130,
1010,
5371,
5371,
1007,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
5371,
1010,
1000,
5371,
2000,
2039,
11066,
2003,
19701,
999,
1000,
1007,
1025,
2709,
2039,
1106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/LocalInputChannel.java | LocalInputChannel.requestSubpartition | @Override
void requestSubpartition(int subpartitionIndex) throws IOException, InterruptedException {
boolean retriggerRequest = false;
// The lock is required to request only once in the presence of retriggered requests.
synchronized (requestLock) {
checkState(!isReleased, "LocalInputChannel has been released already");
if (subpartitionView == null) {
LOG.debug("{}: Requesting LOCAL subpartition {} of partition {}.",
this, subpartitionIndex, partitionId);
try {
ResultSubpartitionView subpartitionView = partitionManager.createSubpartitionView(
partitionId, subpartitionIndex, this);
if (subpartitionView == null) {
throw new IOException("Error requesting subpartition.");
}
// make the subpartition view visible
this.subpartitionView = subpartitionView;
// check if the channel was released in the meantime
if (isReleased) {
subpartitionView.releaseAllResources();
this.subpartitionView = null;
}
} catch (PartitionNotFoundException notFound) {
if (increaseBackoff()) {
retriggerRequest = true;
} else {
throw notFound;
}
}
}
}
// Do this outside of the lock scope as this might lead to a
// deadlock with a concurrent release of the channel via the
// input gate.
if (retriggerRequest) {
inputGate.retriggerPartitionRequest(partitionId.getPartitionId());
}
} | java | @Override
void requestSubpartition(int subpartitionIndex) throws IOException, InterruptedException {
boolean retriggerRequest = false;
// The lock is required to request only once in the presence of retriggered requests.
synchronized (requestLock) {
checkState(!isReleased, "LocalInputChannel has been released already");
if (subpartitionView == null) {
LOG.debug("{}: Requesting LOCAL subpartition {} of partition {}.",
this, subpartitionIndex, partitionId);
try {
ResultSubpartitionView subpartitionView = partitionManager.createSubpartitionView(
partitionId, subpartitionIndex, this);
if (subpartitionView == null) {
throw new IOException("Error requesting subpartition.");
}
// make the subpartition view visible
this.subpartitionView = subpartitionView;
// check if the channel was released in the meantime
if (isReleased) {
subpartitionView.releaseAllResources();
this.subpartitionView = null;
}
} catch (PartitionNotFoundException notFound) {
if (increaseBackoff()) {
retriggerRequest = true;
} else {
throw notFound;
}
}
}
}
// Do this outside of the lock scope as this might lead to a
// deadlock with a concurrent release of the channel via the
// input gate.
if (retriggerRequest) {
inputGate.retriggerPartitionRequest(partitionId.getPartitionId());
}
} | [
"@",
"Override",
"void",
"requestSubpartition",
"(",
"int",
"subpartitionIndex",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"boolean",
"retriggerRequest",
"=",
"false",
";",
"// The lock is required to request only once in the presence of retriggered requests... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/LocalInputChannel.java#L96-L141 | train | Requests a subpartition of the local input channel. | [
30522,
1030,
2058,
15637,
11675,
11186,
30524,
5843,
2003,
3223,
2000,
5227,
2069,
2320,
1999,
1996,
3739,
1997,
2128,
18886,
13327,
2098,
11186,
1012,
25549,
1006,
5227,
7878,
1007,
1063,
14148,
12259,
1006,
999,
2003,
16570,
25063,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | common/src/main/java/io/netty/util/internal/PromiseNotificationUtil.java | PromiseNotificationUtil.trySuccess | public static <V> void trySuccess(Promise<? super V> p, V result, InternalLogger logger) {
if (!p.trySuccess(result) && logger != null) {
Throwable err = p.cause();
if (err == null) {
logger.warn("Failed to mark a promise as success because it has succeeded already: {}", p);
} else {
logger.warn(
"Failed to mark a promise as success because it has failed already: {}, unnotified cause:",
p, err);
}
}
} | java | public static <V> void trySuccess(Promise<? super V> p, V result, InternalLogger logger) {
if (!p.trySuccess(result) && logger != null) {
Throwable err = p.cause();
if (err == null) {
logger.warn("Failed to mark a promise as success because it has succeeded already: {}", p);
} else {
logger.warn(
"Failed to mark a promise as success because it has failed already: {}, unnotified cause:",
p, err);
}
}
} | [
"public",
"static",
"<",
"V",
">",
"void",
"trySuccess",
"(",
"Promise",
"<",
"?",
"super",
"V",
">",
"p",
",",
"V",
"result",
",",
"InternalLogger",
"logger",
")",
"{",
"if",
"(",
"!",
"p",
".",
"trySuccess",
"(",
"result",
")",
"&&",
"logger",
"!... | Try to mark the {@link Promise} as success and log if {@code logger} is not {@code null} in case this fails. | [
"Try",
"to",
"mark",
"the",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/PromiseNotificationUtil.java#L47-L58 | train | Try to mark a promise as success. | [
30522,
2270,
10763,
1026,
1058,
1028,
11675,
3046,
6342,
9468,
7971,
1006,
4872,
1026,
1029,
3565,
1058,
1028,
1052,
1010,
1058,
2765,
1010,
4722,
21197,
4590,
8833,
4590,
1007,
1063,
2065,
1006,
999,
1052,
1012,
3046,
6342,
9468,
7971,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPattern.java | CronPattern.parseSinglePattern | private void parseSinglePattern(String pattern) {
final String[] parts = pattern.split("\\s");
int offset = 0;// 偏移量用于兼容Quartz表达式,当表达式有6或7项时,第一项为秒
if (parts.length == 6 || parts.length == 7) {
offset = 1;
} else if (parts.length != 5) {
throw new CronException("Pattern [{}] is invalid, it must be 5-7 parts!", pattern);
}
// 秒
if (1 == offset) {// 支持秒的表达式
try {
this.secondMatchers.add(ValueMatcherBuilder.build(parts[0], SECOND_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'second' field error!", pattern);
}
} else {// 不支持秒的表达式,则第一位按照表达式生成时间的秒数赋值,表示整分匹配
this.secondMatchers.add(ValueMatcherBuilder.build(String.valueOf(DateUtil.date().second()), SECOND_VALUE_PARSER));
}
// 分
try {
this.minuteMatchers.add(ValueMatcherBuilder.build(parts[0 + offset], MINUTE_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'minute' field error!", pattern);
}
// 小时
try {
this.hourMatchers.add(ValueMatcherBuilder.build(parts[1 + offset], HOUR_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'hour' field error!", pattern);
}
// 每月第几天
try {
this.dayOfMonthMatchers.add(ValueMatcherBuilder.build(parts[2 + offset], DAY_OF_MONTH_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'day of month' field error!", pattern);
}
// 月
try {
this.monthMatchers.add(ValueMatcherBuilder.build(parts[3 + offset], MONTH_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'month' field error!", pattern);
}
// 星期几
try {
this.dayOfWeekMatchers.add(ValueMatcherBuilder.build(parts[4 + offset], DAY_OF_WEEK_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'day of week' field error!", pattern);
}
// 年
if (parts.length == 7) {// 支持年的表达式
try {
this.yearMatchers.add(ValueMatcherBuilder.build(parts[6], YEAR_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'year' field error!", pattern);
}
} else {// 不支持年的表达式,全部匹配
this.secondMatchers.add(new AlwaysTrueValueMatcher());
}
matcherSize++;
} | java | private void parseSinglePattern(String pattern) {
final String[] parts = pattern.split("\\s");
int offset = 0;// 偏移量用于兼容Quartz表达式,当表达式有6或7项时,第一项为秒
if (parts.length == 6 || parts.length == 7) {
offset = 1;
} else if (parts.length != 5) {
throw new CronException("Pattern [{}] is invalid, it must be 5-7 parts!", pattern);
}
// 秒
if (1 == offset) {// 支持秒的表达式
try {
this.secondMatchers.add(ValueMatcherBuilder.build(parts[0], SECOND_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'second' field error!", pattern);
}
} else {// 不支持秒的表达式,则第一位按照表达式生成时间的秒数赋值,表示整分匹配
this.secondMatchers.add(ValueMatcherBuilder.build(String.valueOf(DateUtil.date().second()), SECOND_VALUE_PARSER));
}
// 分
try {
this.minuteMatchers.add(ValueMatcherBuilder.build(parts[0 + offset], MINUTE_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'minute' field error!", pattern);
}
// 小时
try {
this.hourMatchers.add(ValueMatcherBuilder.build(parts[1 + offset], HOUR_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'hour' field error!", pattern);
}
// 每月第几天
try {
this.dayOfMonthMatchers.add(ValueMatcherBuilder.build(parts[2 + offset], DAY_OF_MONTH_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'day of month' field error!", pattern);
}
// 月
try {
this.monthMatchers.add(ValueMatcherBuilder.build(parts[3 + offset], MONTH_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'month' field error!", pattern);
}
// 星期几
try {
this.dayOfWeekMatchers.add(ValueMatcherBuilder.build(parts[4 + offset], DAY_OF_WEEK_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'day of week' field error!", pattern);
}
// 年
if (parts.length == 7) {// 支持年的表达式
try {
this.yearMatchers.add(ValueMatcherBuilder.build(parts[6], YEAR_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'year' field error!", pattern);
}
} else {// 不支持年的表达式,全部匹配
this.secondMatchers.add(new AlwaysTrueValueMatcher());
}
matcherSize++;
} | [
"private",
"void",
"parseSinglePattern",
"(",
"String",
"pattern",
")",
"{",
"final",
"String",
"[",
"]",
"parts",
"=",
"pattern",
".",
"split",
"(",
"\"\\\\s\"",
")",
";",
"int",
"offset",
"=",
"0",
";",
"// 偏移量用于兼容Quartz表达式,当表达式有6或7项时,第一项为秒\r",
"if",
"(",
... | 解析单一定时任务表达式
@param pattern 表达式 | [
"解析单一定时任务表达式"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPattern.java#L234-L295 | train | Parses a single pattern. | [
30522,
2797,
11675,
11968,
8583,
2075,
2571,
4502,
12079,
2078,
1006,
5164,
5418,
1007,
1063,
2345,
5164,
1031,
1033,
3033,
1027,
5418,
1012,
3975,
1006,
1000,
1032,
1032,
1055,
1000,
1007,
1025,
20014,
16396,
1027,
1014,
1025,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-setting/src/main/java/cn/hutool/setting/GroupedMap.java | GroupedMap.containsKey | public boolean containsKey(String group, String key) {
group = StrUtil.nullToEmpty(group).trim();
readLock.lock();
try {
final LinkedHashMap<String, String> valueMap = this.get(group);
if (MapUtil.isNotEmpty(valueMap)) {
return valueMap.containsKey(key);
}
} finally {
readLock.unlock();
}
return false;
} | java | public boolean containsKey(String group, String key) {
group = StrUtil.nullToEmpty(group).trim();
readLock.lock();
try {
final LinkedHashMap<String, String> valueMap = this.get(group);
if (MapUtil.isNotEmpty(valueMap)) {
return valueMap.containsKey(key);
}
} finally {
readLock.unlock();
}
return false;
} | [
"public",
"boolean",
"containsKey",
"(",
"String",
"group",
",",
"String",
"key",
")",
"{",
"group",
"=",
"StrUtil",
".",
"nullToEmpty",
"(",
"group",
")",
".",
"trim",
"(",
")",
";",
"readLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"final",
"Link... | 指定分组中是否包含指定key
@param group 分组
@param key 键
@return 是否包含key | [
"指定分组中是否包含指定key"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/GroupedMap.java#L177-L189 | train | Checks if the specified key is present in the specified group. | [
30522,
2270,
22017,
20898,
3397,
14839,
1006,
5164,
2177,
1010,
5164,
3145,
1007,
1063,
2177,
1027,
2358,
22134,
4014,
1012,
19701,
3406,
6633,
13876,
2100,
1006,
2177,
1007,
1012,
12241,
1006,
1007,
1025,
3191,
7878,
1012,
5843,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/builder/EqualsBuilder.java | EqualsBuilder.reflectionAppend | private static void reflectionAppend(
final Object lhs,
final Object rhs,
final Class<?> clazz,
final EqualsBuilder builder,
final boolean useTransients,
final String[] excludeFields) {
if (isRegistered(lhs, rhs)) {
return;
}
try {
register(lhs, rhs);
final Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.isEquals; i++) {
final Field f = fields[i];
if (false == ArrayUtil.contains(excludeFields, f.getName())
&& (f.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
&& (!Modifier.isStatic(f.getModifiers()))) {
try {
builder.append(f.get(lhs), f.get(rhs));
} catch (final IllegalAccessException e) {
//this can't happen. Would get a Security exception instead
//throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
}
}
}
} finally {
unregister(lhs, rhs);
}
} | java | private static void reflectionAppend(
final Object lhs,
final Object rhs,
final Class<?> clazz,
final EqualsBuilder builder,
final boolean useTransients,
final String[] excludeFields) {
if (isRegistered(lhs, rhs)) {
return;
}
try {
register(lhs, rhs);
final Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.isEquals; i++) {
final Field f = fields[i];
if (false == ArrayUtil.contains(excludeFields, f.getName())
&& (f.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
&& (!Modifier.isStatic(f.getModifiers()))) {
try {
builder.append(f.get(lhs), f.get(rhs));
} catch (final IllegalAccessException e) {
//this can't happen. Would get a Security exception instead
//throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
}
}
}
} finally {
unregister(lhs, rhs);
}
} | [
"private",
"static",
"void",
"reflectionAppend",
"(",
"final",
"Object",
"lhs",
",",
"final",
"Object",
"rhs",
",",
"final",
"Class",
"<",
"?",
">",
"clazz",
",",
"final",
"EqualsBuilder",
"builder",
",",
"final",
"boolean",
"useTransients",
",",
"final",
"S... | <p>Appends the fields and values defined by the given object of the
given Class.</p>
@param lhs the left hand object
@param rhs the right hand object
@param clazz the class to append details of
@param builder the builder to append to
@param useTransients whether to test transient fields
@param excludeFields array of field names to exclude from testing | [
"<p",
">",
"Appends",
"the",
"fields",
"and",
"values",
"defined",
"by",
"the",
"given",
"object",
"of",
"the",
"given",
"Class",
".",
"<",
"/",
"p",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/builder/EqualsBuilder.java#L377-L411 | train | Append to the EqualsBuilder. | [
30522,
2797,
10763,
11675,
9185,
29098,
10497,
1006,
2345,
4874,
1048,
7898,
1010,
2345,
4874,
1054,
7898,
1010,
2345,
2465,
1026,
1029,
1028,
18856,
10936,
2480,
1010,
2345,
19635,
8569,
23891,
2099,
12508,
1010,
2345,
22017,
20898,
2224,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/mining/word2vec/Utility.java | Utility.shrink | public static <T> T[] shrink(T[] from, T[] to)
{
assert to.length <= from.length;
System.arraycopy(from, 0, to, 0, to.length);
return to;
} | java | public static <T> T[] shrink(T[] from, T[] to)
{
assert to.length <= from.length;
System.arraycopy(from, 0, to, 0, to.length);
return to;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"shrink",
"(",
"T",
"[",
"]",
"from",
",",
"T",
"[",
"]",
"to",
")",
"{",
"assert",
"to",
".",
"length",
"<=",
"from",
".",
"length",
";",
"System",
".",
"arraycopy",
"(",
"from",
",",
"0",
",... | 数组分割
@param from 源
@param to 目标
@param <T> 类型
@return 目标 | [
"数组分割"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/mining/word2vec/Utility.java#L129-L134 | train | Shrink the array to a size of the array. | [
30522,
2270,
10763,
1026,
1056,
1028,
1056,
1031,
1033,
22802,
1006,
1056,
1031,
1033,
2013,
1010,
1056,
1031,
1033,
2000,
1007,
1063,
20865,
2000,
1012,
3091,
1026,
1027,
2013,
1012,
3091,
1025,
2291,
1012,
9140,
3597,
7685,
1006,
2013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/QuickSort.java | QuickSort.fix | private static void fix(IndexedSortable s, int pN, int pO, int rN, int rO) {
if (s.compare(pN, pO, rN, rO) > 0) {
s.swap(pN, pO, rN, rO);
}
} | java | private static void fix(IndexedSortable s, int pN, int pO, int rN, int rO) {
if (s.compare(pN, pO, rN, rO) > 0) {
s.swap(pN, pO, rN, rO);
}
} | [
"private",
"static",
"void",
"fix",
"(",
"IndexedSortable",
"s",
",",
"int",
"pN",
",",
"int",
"pO",
",",
"int",
"rN",
",",
"int",
"rO",
")",
"{",
"if",
"(",
"s",
".",
"compare",
"(",
"pN",
",",
"pO",
",",
"rN",
",",
"rO",
")",
">",
"0",
")",... | Fix the records into sorted order, swapping when the first record is
greater than the second record.
@param s paged sortable
@param pN page number of first record
@param pO page offset of first record
@param rN page number of second record
@param rO page offset of second record | [
"Fix",
"the",
"records",
"into",
"sorted",
"order",
"swapping",
"when",
"the",
"first",
"record",
"is",
"greater",
"than",
"the",
"second",
"record",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/QuickSort.java#L39-L43 | train | Fixes the case where the elements are greater than or equal to the elements of the specified indexed sortable. | [
30522,
2797,
10763,
11675,
8081,
1006,
25331,
21748,
10880,
1055,
1010,
20014,
1052,
2078,
1010,
20014,
13433,
1010,
20014,
29300,
1010,
20014,
20996,
1007,
1063,
2065,
1006,
1055,
1012,
12826,
1006,
1052,
2078,
1010,
13433,
1010,
29300,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java | DirectLogFetcher.fetch | public boolean fetch() throws IOException {
try {
// Fetching packet header from input.
if (!fetch0(0, NET_HEADER_SIZE)) {
logger.warn("Reached end of input stream while fetching header");
return false;
}
// Fetching the first packet(may a multi-packet).
int netlen = getUint24(PACKET_LEN_OFFSET);
int netnum = getUint8(PACKET_SEQ_OFFSET);
if (!fetch0(NET_HEADER_SIZE, netlen)) {
logger.warn("Reached end of input stream: packet #" + netnum + ", len = " + netlen);
return false;
}
// Detecting error code.
final int mark = getUint8(NET_HEADER_SIZE);
if (mark != 0) {
if (mark == 255) // error from master
{
// Indicates an error, for example trying to fetch from
// wrong
// binlog position.
position = NET_HEADER_SIZE + 1;
final int errno = getInt16();
String sqlstate = forward(1).getFixString(SQLSTATE_LENGTH);
String errmsg = getFixString(limit - position);
throw new IOException("Received error packet:" + " errno = " + errno + ", sqlstate = " + sqlstate
+ " errmsg = " + errmsg);
} else if (mark == 254) {
// Indicates end of stream. It's not clear when this would
// be sent.
logger.warn("Received EOF packet from server, apparent" + " master disconnected.");
return false;
} else {
// Should not happen.
throw new IOException("Unexpected response " + mark + " while fetching binlog: packet #" + netnum
+ ", len = " + netlen);
}
}
// The first packet is a multi-packet, concatenate the packets.
while (netlen == MAX_PACKET_LENGTH) {
if (!fetch0(0, NET_HEADER_SIZE)) {
logger.warn("Reached end of input stream while fetching header");
return false;
}
netlen = getUint24(PACKET_LEN_OFFSET);
netnum = getUint8(PACKET_SEQ_OFFSET);
if (!fetch0(limit, netlen)) {
logger.warn("Reached end of input stream: packet #" + netnum + ", len = " + netlen);
return false;
}
}
// Preparing buffer variables to decoding.
origin = NET_HEADER_SIZE + 1;
position = origin;
limit -= origin;
return true;
} catch (SocketTimeoutException e) {
close(); /* Do cleanup */
logger.error("Socket timeout expired, closing connection", e);
throw e;
} catch (InterruptedIOException e) {
close(); /* Do cleanup */
logger.warn("I/O interrupted while reading from client socket", e);
throw e;
} catch (IOException e) {
close(); /* Do cleanup */
logger.error("I/O error while reading from client socket", e);
throw e;
}
} | java | public boolean fetch() throws IOException {
try {
// Fetching packet header from input.
if (!fetch0(0, NET_HEADER_SIZE)) {
logger.warn("Reached end of input stream while fetching header");
return false;
}
// Fetching the first packet(may a multi-packet).
int netlen = getUint24(PACKET_LEN_OFFSET);
int netnum = getUint8(PACKET_SEQ_OFFSET);
if (!fetch0(NET_HEADER_SIZE, netlen)) {
logger.warn("Reached end of input stream: packet #" + netnum + ", len = " + netlen);
return false;
}
// Detecting error code.
final int mark = getUint8(NET_HEADER_SIZE);
if (mark != 0) {
if (mark == 255) // error from master
{
// Indicates an error, for example trying to fetch from
// wrong
// binlog position.
position = NET_HEADER_SIZE + 1;
final int errno = getInt16();
String sqlstate = forward(1).getFixString(SQLSTATE_LENGTH);
String errmsg = getFixString(limit - position);
throw new IOException("Received error packet:" + " errno = " + errno + ", sqlstate = " + sqlstate
+ " errmsg = " + errmsg);
} else if (mark == 254) {
// Indicates end of stream. It's not clear when this would
// be sent.
logger.warn("Received EOF packet from server, apparent" + " master disconnected.");
return false;
} else {
// Should not happen.
throw new IOException("Unexpected response " + mark + " while fetching binlog: packet #" + netnum
+ ", len = " + netlen);
}
}
// The first packet is a multi-packet, concatenate the packets.
while (netlen == MAX_PACKET_LENGTH) {
if (!fetch0(0, NET_HEADER_SIZE)) {
logger.warn("Reached end of input stream while fetching header");
return false;
}
netlen = getUint24(PACKET_LEN_OFFSET);
netnum = getUint8(PACKET_SEQ_OFFSET);
if (!fetch0(limit, netlen)) {
logger.warn("Reached end of input stream: packet #" + netnum + ", len = " + netlen);
return false;
}
}
// Preparing buffer variables to decoding.
origin = NET_HEADER_SIZE + 1;
position = origin;
limit -= origin;
return true;
} catch (SocketTimeoutException e) {
close(); /* Do cleanup */
logger.error("Socket timeout expired, closing connection", e);
throw e;
} catch (InterruptedIOException e) {
close(); /* Do cleanup */
logger.warn("I/O interrupted while reading from client socket", e);
throw e;
} catch (IOException e) {
close(); /* Do cleanup */
logger.error("I/O error while reading from client socket", e);
throw e;
}
} | [
"public",
"boolean",
"fetch",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"// Fetching packet header from input.\r",
"if",
"(",
"!",
"fetch0",
"(",
"0",
",",
"NET_HEADER_SIZE",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Reached end of input stream while... | {@inheritDoc}
@see com.taobao.tddl.dbsync.binlog.LogFetcher#fetch() | [
"{",
"@inheritDoc",
"}"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java#L279-L354 | train | Fetches the data from the binlog. | [
30522,
2270,
22017,
20898,
18584,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
3046,
1063,
1013,
1013,
18584,
2075,
14771,
20346,
2013,
7953,
1012,
2065,
1006,
999,
18584,
2692,
1006,
1014,
1010,
5658,
1035,
20346,
1035,
2946,
1007,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | common/src/main/java/io/netty/util/internal/ThrowableUtil.java | ThrowableUtil.stackTraceToString | public static String stackTraceToString(Throwable cause) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream pout = new PrintStream(out);
cause.printStackTrace(pout);
pout.flush();
try {
return new String(out.toByteArray());
} finally {
try {
out.close();
} catch (IOException ignore) {
// ignore as should never happen
}
}
} | java | public static String stackTraceToString(Throwable cause) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream pout = new PrintStream(out);
cause.printStackTrace(pout);
pout.flush();
try {
return new String(out.toByteArray());
} finally {
try {
out.close();
} catch (IOException ignore) {
// ignore as should never happen
}
}
} | [
"public",
"static",
"String",
"stackTraceToString",
"(",
"Throwable",
"cause",
")",
"{",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"PrintStream",
"pout",
"=",
"new",
"PrintStream",
"(",
"out",
")",
";",
"cause",
".",
"... | Gets the stack trace from a Throwable as a String.
@param cause the {@link Throwable} to be examined
@return the stack trace as generated by {@link Throwable#printStackTrace(java.io.PrintWriter)} method. | [
"Gets",
"the",
"stack",
"trace",
"from",
"a",
"Throwable",
"as",
"a",
"String",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/ThrowableUtil.java#L41-L55 | train | This method is used to get a stack trace string from a Throwable. | [
30522,
2270,
10763,
5164,
9991,
6494,
3401,
13122,
18886,
3070,
1006,
5466,
3085,
3426,
1007,
1063,
24880,
2906,
9447,
5833,
18780,
21422,
2041,
1027,
2047,
24880,
2906,
9447,
5833,
18780,
21422,
1006,
1007,
1025,
11204,
25379,
13433,
4904,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/QuickSort.java | QuickSort.sort | public void sort(final IndexedSortable s, int p, int r) {
int recordsPerSegment = s.recordsPerSegment();
int recordSize = s.recordSize();
int maxOffset = recordSize * (recordsPerSegment - 1);
int pN = p / recordsPerSegment;
int pO = (p % recordsPerSegment) * recordSize;
int rN = r / recordsPerSegment;
int rO = (r % recordsPerSegment) * recordSize;
sortInternal(s, recordsPerSegment, recordSize, maxOffset, p, pN, pO, r, rN, rO, getMaxDepth(r - p));
} | java | public void sort(final IndexedSortable s, int p, int r) {
int recordsPerSegment = s.recordsPerSegment();
int recordSize = s.recordSize();
int maxOffset = recordSize * (recordsPerSegment - 1);
int pN = p / recordsPerSegment;
int pO = (p % recordsPerSegment) * recordSize;
int rN = r / recordsPerSegment;
int rO = (r % recordsPerSegment) * recordSize;
sortInternal(s, recordsPerSegment, recordSize, maxOffset, p, pN, pO, r, rN, rO, getMaxDepth(r - p));
} | [
"public",
"void",
"sort",
"(",
"final",
"IndexedSortable",
"s",
",",
"int",
"p",
",",
"int",
"r",
")",
"{",
"int",
"recordsPerSegment",
"=",
"s",
".",
"recordsPerSegment",
"(",
")",
";",
"int",
"recordSize",
"=",
"s",
".",
"recordSize",
"(",
")",
";",
... | Sort the given range of items using quick sort. {@inheritDoc} If the recursion depth falls below
{@link #getMaxDepth}, then switch to {@link HeapSort}. | [
"Sort",
"the",
"given",
"range",
"of",
"items",
"using",
"quick",
"sort",
".",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/QuickSort.java#L60-L72 | train | Sort the given indexed sortable. | [
30522,
2270,
11675,
4066,
1006,
2345,
25331,
21748,
10880,
1055,
1010,
20014,
1052,
1010,
20014,
1054,
1007,
1063,
20014,
2636,
7347,
13910,
3672,
1027,
1055,
1012,
2636,
7347,
13910,
3672,
1006,
1007,
1025,
20014,
2636,
4697,
1027,
1055,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java | TaskExecutor.updatePartitions | @Override
public CompletableFuture<Acknowledge> updatePartitions(
final ExecutionAttemptID executionAttemptID,
Iterable<PartitionInfo> partitionInfos,
Time timeout) {
final Task task = taskSlotTable.getTask(executionAttemptID);
if (task != null) {
for (final PartitionInfo partitionInfo: partitionInfos) {
IntermediateDataSetID intermediateResultPartitionID = partitionInfo.getIntermediateDataSetID();
final SingleInputGate singleInputGate = task.getInputGateById(intermediateResultPartitionID);
if (singleInputGate != null) {
// Run asynchronously because it might be blocking
getRpcService().execute(
() -> {
try {
singleInputGate.updateInputChannel(partitionInfo.getInputChannelDeploymentDescriptor());
} catch (IOException | InterruptedException e) {
log.error("Could not update input data location for task {}. Trying to fail task.", task.getTaskInfo().getTaskName(), e);
try {
task.failExternally(e);
} catch (RuntimeException re) {
// TODO: Check whether we need this or make exception in failExtenally checked
log.error("Failed canceling task with execution ID {} after task update failure.", executionAttemptID, re);
}
}
});
} else {
return FutureUtils.completedExceptionally(
new PartitionException("No reader with ID " + intermediateResultPartitionID +
" for task " + executionAttemptID + " was found."));
}
}
return CompletableFuture.completedFuture(Acknowledge.get());
} else {
log.debug("Discard update for input partitions of task {}. Task is no longer running.", executionAttemptID);
return CompletableFuture.completedFuture(Acknowledge.get());
}
} | java | @Override
public CompletableFuture<Acknowledge> updatePartitions(
final ExecutionAttemptID executionAttemptID,
Iterable<PartitionInfo> partitionInfos,
Time timeout) {
final Task task = taskSlotTable.getTask(executionAttemptID);
if (task != null) {
for (final PartitionInfo partitionInfo: partitionInfos) {
IntermediateDataSetID intermediateResultPartitionID = partitionInfo.getIntermediateDataSetID();
final SingleInputGate singleInputGate = task.getInputGateById(intermediateResultPartitionID);
if (singleInputGate != null) {
// Run asynchronously because it might be blocking
getRpcService().execute(
() -> {
try {
singleInputGate.updateInputChannel(partitionInfo.getInputChannelDeploymentDescriptor());
} catch (IOException | InterruptedException e) {
log.error("Could not update input data location for task {}. Trying to fail task.", task.getTaskInfo().getTaskName(), e);
try {
task.failExternally(e);
} catch (RuntimeException re) {
// TODO: Check whether we need this or make exception in failExtenally checked
log.error("Failed canceling task with execution ID {} after task update failure.", executionAttemptID, re);
}
}
});
} else {
return FutureUtils.completedExceptionally(
new PartitionException("No reader with ID " + intermediateResultPartitionID +
" for task " + executionAttemptID + " was found."));
}
}
return CompletableFuture.completedFuture(Acknowledge.get());
} else {
log.debug("Discard update for input partitions of task {}. Task is no longer running.", executionAttemptID);
return CompletableFuture.completedFuture(Acknowledge.get());
}
} | [
"@",
"Override",
"public",
"CompletableFuture",
"<",
"Acknowledge",
">",
"updatePartitions",
"(",
"final",
"ExecutionAttemptID",
"executionAttemptID",
",",
"Iterable",
"<",
"PartitionInfo",
">",
"partitionInfos",
",",
"Time",
"timeout",
")",
"{",
"final",
"Task",
"t... | ---------------------------------------------------------------------- | [
"----------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java#L608-L650 | train | Update the input partitions of the task slot table. | [
30522,
1030,
2058,
15637,
2270,
4012,
10814,
10880,
11263,
11244,
1026,
13399,
1028,
10651,
19362,
3775,
9285,
1006,
2345,
7781,
19321,
6633,
13876,
3593,
7781,
19321,
6633,
13876,
3593,
1010,
2009,
6906,
3468,
1026,
13571,
2378,
14876,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java | HttpUtil.setContentLength | public static void setContentLength(HttpMessage message, long length) {
message.headers().set(HttpHeaderNames.CONTENT_LENGTH, length);
} | java | public static void setContentLength(HttpMessage message, long length) {
message.headers().set(HttpHeaderNames.CONTENT_LENGTH, length);
} | [
"public",
"static",
"void",
"setContentLength",
"(",
"HttpMessage",
"message",
",",
"long",
"length",
")",
"{",
"message",
".",
"headers",
"(",
")",
".",
"set",
"(",
"HttpHeaderNames",
".",
"CONTENT_LENGTH",
",",
"length",
")",
";",
"}"
] | Sets the {@code "Content-Length"} header. | [
"Sets",
"the",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java#L229-L231 | train | Sets the content length header of the given message. | [
30522,
2270,
10763,
11675,
2275,
8663,
6528,
9286,
3070,
2705,
1006,
8299,
7834,
3736,
3351,
4471,
1010,
2146,
3091,
1007,
1063,
4471,
1012,
20346,
2015,
1006,
1007,
1012,
2275,
1006,
8299,
4974,
11795,
14074,
2015,
1012,
4180,
1035,
3091,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
redisson/redisson | redisson/src/main/java/org/redisson/executor/CronExpression.java | CronExpression.setCalendarHour | protected void setCalendarHour(Calendar cal, int hour) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
if (cal.get(java.util.Calendar.HOUR_OF_DAY) != hour && hour != 24) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour + 1);
}
} | java | protected void setCalendarHour(Calendar cal, int hour) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
if (cal.get(java.util.Calendar.HOUR_OF_DAY) != hour && hour != 24) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour + 1);
}
} | [
"protected",
"void",
"setCalendarHour",
"(",
"Calendar",
"cal",
",",
"int",
"hour",
")",
"{",
"cal",
".",
"set",
"(",
"java",
".",
"util",
".",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"hour",
")",
";",
"if",
"(",
"cal",
".",
"get",
"(",
"java",
".",
"... | Advance the calendar to the particular hour paying particular attention
to daylight saving problems.
@param cal the calendar to operate on
@param hour the hour to set | [
"Advance",
"the",
"calendar",
"to",
"the",
"particular",
"hour",
"paying",
"particular",
"attention",
"to",
"daylight",
"saving",
"problems",
"."
] | d3acc0249b2d5d658d36d99e2c808ce49332ea44 | https://github.com/redisson/redisson/blob/d3acc0249b2d5d658d36d99e2c808ce49332ea44/redisson/src/main/java/org/redisson/executor/CronExpression.java#L1434-L1439 | train | setCalendarHour This sets the hour of the calendar. | [
30522,
5123,
11675,
2275,
9289,
10497,
2906,
6806,
3126,
1006,
8094,
10250,
1010,
20014,
3178,
1007,
1063,
10250,
1012,
2275,
1006,
9262,
1012,
21183,
4014,
1012,
8094,
1012,
3178,
1035,
1997,
1035,
2154,
1010,
3178,
1007,
1025,
2065,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/configuration/Configuration.java | Configuration.getValue | @PublicEvolving
public String getValue(ConfigOption<?> configOption) {
Object o = getValueOrDefaultFromOption(configOption);
return o == null ? null : o.toString();
} | java | @PublicEvolving
public String getValue(ConfigOption<?> configOption) {
Object o = getValueOrDefaultFromOption(configOption);
return o == null ? null : o.toString();
} | [
"@",
"PublicEvolving",
"public",
"String",
"getValue",
"(",
"ConfigOption",
"<",
"?",
">",
"configOption",
")",
"{",
"Object",
"o",
"=",
"getValueOrDefaultFromOption",
"(",
"configOption",
")",
";",
"return",
"o",
"==",
"null",
"?",
"null",
":",
"o",
".",
... | Returns the value associated with the given config option as a string.
@param configOption The configuration option
@return the (default) value associated with the given config option | [
"Returns",
"the",
"value",
"associated",
"with",
"the",
"given",
"config",
"option",
"as",
"a",
"string",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java#L608-L612 | train | Returns the value associated with the given config option as a string. | [
30522,
1030,
2270,
6777,
4747,
6455,
2270,
5164,
2131,
10175,
5657,
1006,
9530,
8873,
3995,
16790,
1026,
1029,
1028,
9530,
8873,
3995,
16790,
1007,
1063,
4874,
1051,
1027,
2131,
10175,
5657,
8551,
12879,
23505,
19699,
19506,
16790,
1006,
95... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java | ExpectedConditions.visibilityOfAllElementsLocatedBy | public static ExpectedCondition<List<WebElement>> visibilityOfAllElementsLocatedBy(
final By locator) {
return new ExpectedCondition<List<WebElement>>() {
@Override
public List<WebElement> apply(WebDriver driver) {
List<WebElement> elements = driver.findElements(locator);
for (WebElement element : elements) {
if (!element.isDisplayed()) {
return null;
}
}
return elements.size() > 0 ? elements : null;
}
@Override
public String toString() {
return "visibility of all elements located by " + locator;
}
};
} | java | public static ExpectedCondition<List<WebElement>> visibilityOfAllElementsLocatedBy(
final By locator) {
return new ExpectedCondition<List<WebElement>>() {
@Override
public List<WebElement> apply(WebDriver driver) {
List<WebElement> elements = driver.findElements(locator);
for (WebElement element : elements) {
if (!element.isDisplayed()) {
return null;
}
}
return elements.size() > 0 ? elements : null;
}
@Override
public String toString() {
return "visibility of all elements located by " + locator;
}
};
} | [
"public",
"static",
"ExpectedCondition",
"<",
"List",
"<",
"WebElement",
">",
">",
"visibilityOfAllElementsLocatedBy",
"(",
"final",
"By",
"locator",
")",
"{",
"return",
"new",
"ExpectedCondition",
"<",
"List",
"<",
"WebElement",
">",
">",
"(",
")",
"{",
"@",
... | An expectation for checking that all elements present on the web page that match the locator
are visible. Visibility means that the elements are not only displayed but also have a height
and width that is greater than 0.
@param locator used to find the element
@return the list of WebElements once they are located | [
"An",
"expectation",
"for",
"checking",
"that",
"all",
"elements",
"present",
"on",
"the",
"web",
"page",
"that",
"match",
"the",
"locator",
"are",
"visible",
".",
"Visibility",
"means",
"that",
"the",
"elements",
"are",
"not",
"only",
"displayed",
"but",
"a... | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java#L226-L245 | train | An expectation for checking that all elements in a SECTYPE are visible. | [
30522,
2270,
10763,
3517,
8663,
20562,
1026,
2862,
1026,
4773,
12260,
3672,
1028,
1028,
16476,
11253,
24164,
16930,
11187,
4135,
12921,
3762,
1006,
2345,
2011,
8840,
11266,
2953,
1007,
1063,
2709,
2047,
3517,
8663,
20562,
1026,
2862,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
alibaba/canal | client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/service/RdbMirrorDbSyncService.java | RdbMirrorDbSyncService.initMappingConfig | private void initMappingConfig(String key, MappingConfig baseConfigMap, MirrorDbConfig mirrorDbConfig, Dml dml) {
MappingConfig mappingConfig = mirrorDbConfig.getTableConfig().get(key);
if (mappingConfig == null) {
// 构造表配置
mappingConfig = new MappingConfig();
mappingConfig.setDataSourceKey(baseConfigMap.getDataSourceKey());
mappingConfig.setDestination(baseConfigMap.getDestination());
mappingConfig.setGroupId(baseConfigMap.getGroupId());
mappingConfig.setOuterAdapterKey(baseConfigMap.getOuterAdapterKey());
mappingConfig.setConcurrent(baseConfigMap.getConcurrent());
MappingConfig.DbMapping dbMapping = new MappingConfig.DbMapping();
mappingConfig.setDbMapping(dbMapping);
dbMapping.setDatabase(dml.getDatabase());
dbMapping.setTable(dml.getTable());
dbMapping.setTargetDb(dml.getDatabase());
dbMapping.setTargetTable(dml.getTable());
dbMapping.setMapAll(true);
List<String> pkNames = dml.getPkNames();
Map<String, String> pkMapping = new LinkedHashMap<>();
pkNames.forEach(pkName -> pkMapping.put(pkName, pkName));
dbMapping.setTargetPk(pkMapping);
mirrorDbConfig.getTableConfig().put(key, mappingConfig);
}
} | java | private void initMappingConfig(String key, MappingConfig baseConfigMap, MirrorDbConfig mirrorDbConfig, Dml dml) {
MappingConfig mappingConfig = mirrorDbConfig.getTableConfig().get(key);
if (mappingConfig == null) {
// 构造表配置
mappingConfig = new MappingConfig();
mappingConfig.setDataSourceKey(baseConfigMap.getDataSourceKey());
mappingConfig.setDestination(baseConfigMap.getDestination());
mappingConfig.setGroupId(baseConfigMap.getGroupId());
mappingConfig.setOuterAdapterKey(baseConfigMap.getOuterAdapterKey());
mappingConfig.setConcurrent(baseConfigMap.getConcurrent());
MappingConfig.DbMapping dbMapping = new MappingConfig.DbMapping();
mappingConfig.setDbMapping(dbMapping);
dbMapping.setDatabase(dml.getDatabase());
dbMapping.setTable(dml.getTable());
dbMapping.setTargetDb(dml.getDatabase());
dbMapping.setTargetTable(dml.getTable());
dbMapping.setMapAll(true);
List<String> pkNames = dml.getPkNames();
Map<String, String> pkMapping = new LinkedHashMap<>();
pkNames.forEach(pkName -> pkMapping.put(pkName, pkName));
dbMapping.setTargetPk(pkMapping);
mirrorDbConfig.getTableConfig().put(key, mappingConfig);
}
} | [
"private",
"void",
"initMappingConfig",
"(",
"String",
"key",
",",
"MappingConfig",
"baseConfigMap",
",",
"MirrorDbConfig",
"mirrorDbConfig",
",",
"Dml",
"dml",
")",
"{",
"MappingConfig",
"mappingConfig",
"=",
"mirrorDbConfig",
".",
"getTableConfig",
"(",
")",
".",
... | 初始化表配置
@param key 配置key: destination.database.table
@param baseConfigMap db sync config
@param dml DML | [
"初始化表配置"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/service/RdbMirrorDbSyncService.java#L122-L146 | train | init mapping config | [
30522,
2797,
11675,
1999,
4183,
2863,
14853,
8663,
8873,
2290,
1006,
5164,
3145,
1010,
12375,
8663,
8873,
2290,
2918,
8663,
8873,
21693,
9331,
1010,
5259,
18939,
8663,
8873,
2290,
5259,
18939,
8663,
8873,
2290,
1010,
1040,
19968,
1040,
1996... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.getConfResourceAsReader | public Reader getConfResourceAsReader(String name) {
try {
URL url= getResource(name);
if (url == null) {
LOG.info(name + " not found");
return null;
} else {
LOG.info("found resource " + name + " at " + url);
}
return new InputStreamReader(url.openStream(), Charsets.UTF_8);
} catch (Exception e) {
return null;
}
} | java | public Reader getConfResourceAsReader(String name) {
try {
URL url= getResource(name);
if (url == null) {
LOG.info(name + " not found");
return null;
} else {
LOG.info("found resource " + name + " at " + url);
}
return new InputStreamReader(url.openStream(), Charsets.UTF_8);
} catch (Exception e) {
return null;
}
} | [
"public",
"Reader",
"getConfResourceAsReader",
"(",
"String",
"name",
")",
"{",
"try",
"{",
"URL",
"url",
"=",
"getResource",
"(",
"name",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"LOG",
".",
"info",
"(",
"name",
"+",
"\" not found\"",
")",
... | Get a {@link Reader} attached to the configuration resource with the
given <code>name</code>.
@param name configuration resource name.
@return a reader attached to the resource. | [
"Get",
"a",
"{",
"@link",
"Reader",
"}",
"attached",
"to",
"the",
"configuration",
"resource",
"with",
"the",
"given",
"<code",
">",
"name<",
"/",
"code",
">",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L2647-L2662 | train | Get a resource as a reader. | [
30522,
2270,
8068,
2131,
8663,
19699,
2229,
8162,
21456,
21338,
13775,
2121,
1006,
5164,
2171,
1007,
1063,
3046,
1063,
24471,
2140,
24471,
2140,
1027,
2131,
6072,
8162,
3401,
1006,
2171,
1007,
1025,
2065,
1006,
24471,
2140,
1027,
1027,
1970... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | java/server/src/org/openqa/grid/web/servlet/handler/RequestHandler.java | RequestHandler.process | public void process() {
switch (request.getRequestType()) {
case START_SESSION:
log.info("Got a request to create a new session: "
+ new DesiredCapabilities(request.getDesiredCapabilities()));
try {
registry.addNewSessionRequest(this);
waitForSessionBound();
beforeSessionEvent();
forwardNewSessionRequestAndUpdateRegistry(session);
} catch (Exception e) {
cleanup();
log.log(Level.INFO, "Error forwarding the new session " + e.getMessage(), e);
throw new GridException("Error forwarding the new session " + e.getMessage(), e);
}
break;
case REGULAR:
case STOP_SESSION:
session = getSession();
if (session == null) {
ExternalSessionKey sessionKey = null;
try {
sessionKey = request.extractSession();
} catch (RuntimeException ignore) {}
throw new GridException("Session [" + sessionKey + "] not available - "
+ registry.getActiveSessions());
}
try {
forwardRequest(session, this);
} catch (ClientGoneException e) {
log.log(Level.WARNING, "The client is gone for session " + session + ", terminating");
registry.terminate(session, SessionTerminationReason.CLIENT_GONE);
} catch (SocketTimeoutException e) {
log.log(Level.SEVERE, "Socket timed out for session " + session + ", " + e.getMessage());
registry.terminate(session, SessionTerminationReason.SO_TIMEOUT);
} catch (Throwable t) {
log.log(Level.SEVERE, "cannot forward the request " + t.getMessage(), t);
registry.terminate(session, SessionTerminationReason.FORWARDING_TO_NODE_FAILED);
throw new GridException("cannot forward the request " + t.getMessage(), t);
}
if (request.getRequestType() == RequestType.STOP_SESSION) {
registry.terminate(session, SessionTerminationReason.CLIENT_STOPPED_SESSION);
}
break;
default:
throw new RuntimeException("NI");
}
} | java | public void process() {
switch (request.getRequestType()) {
case START_SESSION:
log.info("Got a request to create a new session: "
+ new DesiredCapabilities(request.getDesiredCapabilities()));
try {
registry.addNewSessionRequest(this);
waitForSessionBound();
beforeSessionEvent();
forwardNewSessionRequestAndUpdateRegistry(session);
} catch (Exception e) {
cleanup();
log.log(Level.INFO, "Error forwarding the new session " + e.getMessage(), e);
throw new GridException("Error forwarding the new session " + e.getMessage(), e);
}
break;
case REGULAR:
case STOP_SESSION:
session = getSession();
if (session == null) {
ExternalSessionKey sessionKey = null;
try {
sessionKey = request.extractSession();
} catch (RuntimeException ignore) {}
throw new GridException("Session [" + sessionKey + "] not available - "
+ registry.getActiveSessions());
}
try {
forwardRequest(session, this);
} catch (ClientGoneException e) {
log.log(Level.WARNING, "The client is gone for session " + session + ", terminating");
registry.terminate(session, SessionTerminationReason.CLIENT_GONE);
} catch (SocketTimeoutException e) {
log.log(Level.SEVERE, "Socket timed out for session " + session + ", " + e.getMessage());
registry.terminate(session, SessionTerminationReason.SO_TIMEOUT);
} catch (Throwable t) {
log.log(Level.SEVERE, "cannot forward the request " + t.getMessage(), t);
registry.terminate(session, SessionTerminationReason.FORWARDING_TO_NODE_FAILED);
throw new GridException("cannot forward the request " + t.getMessage(), t);
}
if (request.getRequestType() == RequestType.STOP_SESSION) {
registry.terminate(session, SessionTerminationReason.CLIENT_STOPPED_SESSION);
}
break;
default:
throw new RuntimeException("NI");
}
} | [
"public",
"void",
"process",
"(",
")",
"{",
"switch",
"(",
"request",
".",
"getRequestType",
"(",
")",
")",
"{",
"case",
"START_SESSION",
":",
"log",
".",
"info",
"(",
"\"Got a request to create a new session: \"",
"+",
"new",
"DesiredCapabilities",
"(",
"reques... | forwards the request to the remote, allocating / releasing the resources if necessary. | [
"forwards",
"the",
"request",
"to",
"the",
"remote",
"allocating",
"/",
"releasing",
"the",
"resources",
"if",
"necessary",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/grid/web/servlet/handler/RequestHandler.java#L105-L153 | train | Process the request. | [
30522,
2270,
11675,
2832,
1006,
1007,
1063,
6942,
1006,
5227,
1012,
2131,
2890,
15500,
13874,
1006,
1007,
1007,
1063,
2553,
2707,
1035,
5219,
1024,
8833,
1012,
18558,
1006,
1000,
2288,
1037,
5227,
2000,
3443,
1037,
2047,
5219,
1024,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/data/PythonReceiver.java | PythonReceiver.collectBuffer | @SuppressWarnings({ "rawtypes", "unchecked" })
public void collectBuffer(Collector<OUT> c, int bufferSize) throws IOException {
fileBuffer.position(0);
while (fileBuffer.position() < bufferSize) {
c.collect(deserializer.deserialize());
}
} | java | @SuppressWarnings({ "rawtypes", "unchecked" })
public void collectBuffer(Collector<OUT> c, int bufferSize) throws IOException {
fileBuffer.position(0);
while (fileBuffer.position() < bufferSize) {
c.collect(deserializer.deserialize());
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"public",
"void",
"collectBuffer",
"(",
"Collector",
"<",
"OUT",
">",
"c",
",",
"int",
"bufferSize",
")",
"throws",
"IOException",
"{",
"fileBuffer",
".",
"position",
"(",
"0"... | Reads a buffer of the given size from the memory-mapped file, and collects all records contained. This method
assumes that all values in the buffer are of the same type. This method does NOT take care of synchronization.
The user must guarantee that the buffer was completely written before calling this method.
@param c Collector to collect records
@param bufferSize size of the buffer
@throws IOException | [
"Reads",
"a",
"buffer",
"of",
"the",
"given",
"size",
"from",
"the",
"memory",
"-",
"mapped",
"file",
"and",
"collects",
"all",
"records",
"contained",
".",
"This",
"method",
"assumes",
"that",
"all",
"values",
"in",
"the",
"buffer",
"are",
"of",
"the",
... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/data/PythonReceiver.java#L91-L98 | train | Reads the contents of the file into the given collector. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1063,
1000,
6315,
13874,
2015,
1000,
1010,
1000,
4895,
5403,
18141,
1000,
1065,
1007,
2270,
11675,
8145,
8569,
12494,
1006,
10018,
1026,
2041,
1028,
1039,
1010,
20014,
17698,
5332,
4371,
1007,
116... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java | KryoSerializer.readObject | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
// kryoRegistrations may be null if this Kryo serializer is deserialized from an old version
if (kryoRegistrations == null) {
this.kryoRegistrations = buildKryoRegistrations(
type,
registeredTypes,
registeredTypesWithSerializerClasses,
registeredTypesWithSerializers);
}
} | java | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
// kryoRegistrations may be null if this Kryo serializer is deserialized from an old version
if (kryoRegistrations == null) {
this.kryoRegistrations = buildKryoRegistrations(
type,
registeredTypes,
registeredTypesWithSerializerClasses,
registeredTypesWithSerializers);
}
} | [
"private",
"void",
"readObject",
"(",
"ObjectInputStream",
"in",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"in",
".",
"defaultReadObject",
"(",
")",
";",
"// kryoRegistrations may be null if this Kryo serializer is deserialized from an old version",
"if"... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java#L589-L600 | train | Read the object from an input stream. | [
30522,
2797,
11675,
3191,
16429,
20614,
1006,
4874,
2378,
18780,
21422,
1999,
1007,
11618,
22834,
10288,
24422,
1010,
2465,
17048,
14876,
8630,
10288,
24422,
1063,
1999,
1012,
12398,
16416,
3527,
2497,
20614,
1006,
1007,
1025,
1013,
1013,
104... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java | DateUtil.offsetDate | @Deprecated
public static DateTime offsetDate(Date date, DateField dateField, int offset) {
return offset(date, dateField, offset);
} | java | @Deprecated
public static DateTime offsetDate(Date date, DateField dateField, int offset) {
return offset(date, dateField, offset);
} | [
"@",
"Deprecated",
"public",
"static",
"DateTime",
"offsetDate",
"(",
"Date",
"date",
",",
"DateField",
"dateField",
",",
"int",
"offset",
")",
"{",
"return",
"offset",
"(",
"date",
",",
"dateField",
",",
"offset",
")",
";",
"}"
] | 获取指定日期偏移指定时间后的时间
@param date 基准日期
@param dateField 偏移的粒度大小(小时、天、月等){@link DateField}
@param offset 偏移量,正数为向后偏移,负数为向前偏移
@return 偏移后的日期
@deprecated please use {@link DateUtil#offset(Date, DateField, int)} | [
"获取指定日期偏移指定时间后的时间"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L1214-L1217 | train | Create an offset value for a date field. | [
30522,
1030,
2139,
28139,
12921,
2270,
10763,
3058,
7292,
16396,
13701,
1006,
3058,
3058,
1010,
3058,
3790,
3058,
3790,
1010,
20014,
16396,
1007,
1063,
2709,
16396,
1006,
3058,
1010,
3058,
3790,
1010,
16396,
1007,
1025,
1065,
102,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-docs/src/main/java/org/apache/flink/docs/configuration/ConfigOptionsDocGenerator.java | ConfigOptionsDocGenerator.toHtmlString | private static String toHtmlString(final OptionWithMetaInfo optionWithMetaInfo) {
ConfigOption<?> option = optionWithMetaInfo.option;
String defaultValue = stringifyDefault(optionWithMetaInfo);
return "" +
" <tr>\n" +
" <td><h5>" + escapeCharacters(option.key()) + "</h5></td>\n" +
" <td style=\"word-wrap: break-word;\">" + escapeCharacters(addWordBreakOpportunities(defaultValue)) + "</td>\n" +
" <td>" + formatter.format(option.description()) + "</td>\n" +
" </tr>\n";
} | java | private static String toHtmlString(final OptionWithMetaInfo optionWithMetaInfo) {
ConfigOption<?> option = optionWithMetaInfo.option;
String defaultValue = stringifyDefault(optionWithMetaInfo);
return "" +
" <tr>\n" +
" <td><h5>" + escapeCharacters(option.key()) + "</h5></td>\n" +
" <td style=\"word-wrap: break-word;\">" + escapeCharacters(addWordBreakOpportunities(defaultValue)) + "</td>\n" +
" <td>" + formatter.format(option.description()) + "</td>\n" +
" </tr>\n";
} | [
"private",
"static",
"String",
"toHtmlString",
"(",
"final",
"OptionWithMetaInfo",
"optionWithMetaInfo",
")",
"{",
"ConfigOption",
"<",
"?",
">",
"option",
"=",
"optionWithMetaInfo",
".",
"option",
";",
"String",
"defaultValue",
"=",
"stringifyDefault",
"(",
"option... | Transforms option to table row.
@param optionWithMetaInfo option to transform
@return row with the option description | [
"Transforms",
"option",
"to",
"table",
"row",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-docs/src/main/java/org/apache/flink/docs/configuration/ConfigOptionsDocGenerator.java#L260-L270 | train | To html string. | [
30522,
2797,
10763,
5164,
2000,
11039,
19968,
3367,
4892,
30524,
3995,
16790,
1026,
1029,
1028,
5724,
1027,
5724,
24415,
11368,
8113,
14876,
1012,
5724,
1025,
5164,
12398,
10175,
5657,
1027,
5164,
8757,
3207,
7011,
11314,
1006,
5724,
24415,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java | SpringApplication.load | protected void load(ApplicationContext context, Object[] sources) {
if (logger.isDebugEnabled()) {
logger.debug(
"Loading source " + StringUtils.arrayToCommaDelimitedString(sources));
}
BeanDefinitionLoader loader = createBeanDefinitionLoader(
getBeanDefinitionRegistry(context), sources);
if (this.beanNameGenerator != null) {
loader.setBeanNameGenerator(this.beanNameGenerator);
}
if (this.resourceLoader != null) {
loader.setResourceLoader(this.resourceLoader);
}
if (this.environment != null) {
loader.setEnvironment(this.environment);
}
loader.load();
} | java | protected void load(ApplicationContext context, Object[] sources) {
if (logger.isDebugEnabled()) {
logger.debug(
"Loading source " + StringUtils.arrayToCommaDelimitedString(sources));
}
BeanDefinitionLoader loader = createBeanDefinitionLoader(
getBeanDefinitionRegistry(context), sources);
if (this.beanNameGenerator != null) {
loader.setBeanNameGenerator(this.beanNameGenerator);
}
if (this.resourceLoader != null) {
loader.setResourceLoader(this.resourceLoader);
}
if (this.environment != null) {
loader.setEnvironment(this.environment);
}
loader.load();
} | [
"protected",
"void",
"load",
"(",
"ApplicationContext",
"context",
",",
"Object",
"[",
"]",
"sources",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Loading source \"",
"+",
"StringUtils",
".",
"a... | Load beans into the application context.
@param context the context to load beans into
@param sources the sources to load | [
"Load",
"beans",
"into",
"the",
"application",
"context",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java#L708-L725 | train | Load the bean definitions from the given sources. | [
30522,
5123,
11675,
7170,
1006,
4646,
8663,
18209,
6123,
1010,
4874,
1031,
1033,
4216,
1007,
1063,
2065,
1006,
8833,
4590,
1012,
2003,
3207,
8569,
6914,
3085,
2094,
1006,
1007,
1007,
1063,
8833,
4590,
1012,
2139,
8569,
2290,
1006,
1000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/router/RouteResult.java | RouteResult.params | public List<String> params(String name) {
List<String> values = queryParams.get(name);
String value = pathParams.get(name);
if (values == null) {
return (value == null) ? Collections.<String>emptyList() : Collections.singletonList(value);
}
if (value == null) {
return Collections.unmodifiableList(values);
} else {
List<String> aggregated = new ArrayList<String>(values.size() + 1);
aggregated.addAll(values);
aggregated.add(value);
return Collections.unmodifiableList(aggregated);
}
} | java | public List<String> params(String name) {
List<String> values = queryParams.get(name);
String value = pathParams.get(name);
if (values == null) {
return (value == null) ? Collections.<String>emptyList() : Collections.singletonList(value);
}
if (value == null) {
return Collections.unmodifiableList(values);
} else {
List<String> aggregated = new ArrayList<String>(values.size() + 1);
aggregated.addAll(values);
aggregated.add(value);
return Collections.unmodifiableList(aggregated);
}
} | [
"public",
"List",
"<",
"String",
">",
"params",
"(",
"String",
"name",
")",
"{",
"List",
"<",
"String",
">",
"values",
"=",
"queryParams",
".",
"get",
"(",
"name",
")",
";",
"String",
"value",
"=",
"pathParams",
".",
"get",
"(",
"name",
")",
";",
"... | Extracts all params in {@code pathParams} and {@code queryParams} matching the name.
@return Unmodifiable list; the list is empty if there's no match | [
"Extracts",
"all",
"params",
"in",
"{",
"@code",
"pathParams",
"}",
"and",
"{",
"@code",
"queryParams",
"}",
"matching",
"the",
"name",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/router/RouteResult.java#L121-L137 | train | Returns the list of query parameters for the given name. | [
30522,
2270,
2862,
1026,
5164,
1028,
11498,
5244,
1006,
5164,
2171,
1007,
1063,
2862,
1026,
5164,
1028,
5300,
1027,
23032,
28689,
5244,
1012,
2131,
1006,
2171,
1007,
1025,
5164,
3643,
1027,
4130,
28689,
5244,
1012,
2131,
1006,
2171,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | common/src/main/java/io/netty/util/internal/PlatformDependent.java | PlatformDependent.hashCodeAsciiSanitizeShort | private static int hashCodeAsciiSanitizeShort(CharSequence value, int offset) {
if (BIG_ENDIAN_NATIVE_ORDER) {
// mimic a unsafe.getShort call on a big endian machine
return (value.charAt(offset + 1) & 0x1f) |
(value.charAt(offset) & 0x1f) << 8;
}
return (value.charAt(offset + 1) & 0x1f) << 8 |
(value.charAt(offset) & 0x1f);
} | java | private static int hashCodeAsciiSanitizeShort(CharSequence value, int offset) {
if (BIG_ENDIAN_NATIVE_ORDER) {
// mimic a unsafe.getShort call on a big endian machine
return (value.charAt(offset + 1) & 0x1f) |
(value.charAt(offset) & 0x1f) << 8;
}
return (value.charAt(offset + 1) & 0x1f) << 8 |
(value.charAt(offset) & 0x1f);
} | [
"private",
"static",
"int",
"hashCodeAsciiSanitizeShort",
"(",
"CharSequence",
"value",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"BIG_ENDIAN_NATIVE_ORDER",
")",
"{",
"// mimic a unsafe.getShort call on a big endian machine",
"return",
"(",
"value",
".",
"charAt",
"(",... | Identical to {@link PlatformDependent0#hashCodeAsciiSanitize(short)} but for {@link CharSequence}. | [
"Identical",
"to",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/PlatformDependent.java#L538-L546 | train | Sanitize a char sequence to be safe for a short hash code. | [
30522,
2797,
10763,
20014,
23325,
16044,
3022,
6895,
29196,
25090,
11254,
27794,
1006,
25869,
3366,
4226,
5897,
3643,
1010,
20014,
16396,
1007,
1063,
2065,
1006,
2502,
1035,
2203,
2937,
1035,
3128,
1035,
2344,
1007,
1063,
1013,
1013,
23150,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySource.java | SpringConfigurationPropertySource.from | public static SpringConfigurationPropertySource from(PropertySource<?> source) {
Assert.notNull(source, "Source must not be null");
PropertyMapper mapper = getPropertyMapper(source);
if (isFullEnumerable(source)) {
return new SpringIterableConfigurationPropertySource(
(EnumerablePropertySource<?>) source, mapper);
}
return new SpringConfigurationPropertySource(source, mapper,
getContainsDescendantOfForSource(source));
} | java | public static SpringConfigurationPropertySource from(PropertySource<?> source) {
Assert.notNull(source, "Source must not be null");
PropertyMapper mapper = getPropertyMapper(source);
if (isFullEnumerable(source)) {
return new SpringIterableConfigurationPropertySource(
(EnumerablePropertySource<?>) source, mapper);
}
return new SpringConfigurationPropertySource(source, mapper,
getContainsDescendantOfForSource(source));
} | [
"public",
"static",
"SpringConfigurationPropertySource",
"from",
"(",
"PropertySource",
"<",
"?",
">",
"source",
")",
"{",
"Assert",
".",
"notNull",
"(",
"source",
",",
"\"Source must not be null\"",
")",
";",
"PropertyMapper",
"mapper",
"=",
"getPropertyMapper",
"(... | Create a new {@link SpringConfigurationPropertySource} for the specified
{@link PropertySource}.
@param source the source Spring {@link PropertySource}
@return a {@link SpringConfigurationPropertySource} or
{@link SpringIterableConfigurationPropertySource} instance | [
"Create",
"a",
"new",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySource.java#L147-L156 | train | Creates a SpringConfigurationPropertySource from the given property source. | [
30522,
2270,
10763,
3500,
8663,
8873,
27390,
3370,
21572,
4842,
3723,
6499,
3126,
3401,
2013,
1006,
3200,
6499,
3126,
3401,
1026,
1029,
1028,
3120,
1007,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
3120,
1010,
1000,
3120,
2442,
2025,
2022,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/collection/trie/datrie/MutableDoubleArrayTrieInteger.java | MutableDoubleArrayTrieInteger.deleteFreeLink | private void deleteFreeLink(int index)
{
this.base.set(-this.check.get(index), this.base.get(index));
this.check.set(-this.base.get(index), this.check.get(index));
} | java | private void deleteFreeLink(int index)
{
this.base.set(-this.check.get(index), this.base.get(index));
this.check.set(-this.base.get(index), this.check.get(index));
} | [
"private",
"void",
"deleteFreeLink",
"(",
"int",
"index",
")",
"{",
"this",
".",
"base",
".",
"set",
"(",
"-",
"this",
".",
"check",
".",
"get",
"(",
"index",
")",
",",
"this",
".",
"base",
".",
"get",
"(",
"index",
")",
")",
";",
"this",
".",
... | 将index从空闲循环链表中删除
@param index | [
"将index从空闲循环链表中删除"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/trie/datrie/MutableDoubleArrayTrieInteger.java#L213-L217 | train | Delete free link. | [
30522,
2797,
11675,
3972,
12870,
23301,
13767,
1006,
20014,
5950,
1007,
1063,
2023,
1012,
2918,
1012,
2275,
1006,
1011,
2023,
1012,
4638,
1012,
2131,
1006,
5950,
1007,
1010,
2023,
1012,
2918,
1012,
2131,
1006,
5950,
1007,
1007,
1025,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/format/FastDatePrinter.java | FastDatePrinter.applyRules | private <B extends Appendable> B applyRules(final Calendar calendar, final B buf) {
try {
for (final Rule rule : this.rules) {
rule.appendTo(buf, calendar);
}
} catch (final IOException e) {
throw new DateException(e);
}
return buf;
} | java | private <B extends Appendable> B applyRules(final Calendar calendar, final B buf) {
try {
for (final Rule rule : this.rules) {
rule.appendTo(buf, calendar);
}
} catch (final IOException e) {
throw new DateException(e);
}
return buf;
} | [
"private",
"<",
"B",
"extends",
"Appendable",
">",
"B",
"applyRules",
"(",
"final",
"Calendar",
"calendar",
",",
"final",
"B",
"buf",
")",
"{",
"try",
"{",
"for",
"(",
"final",
"Rule",
"rule",
":",
"this",
".",
"rules",
")",
"{",
"rule",
".",
"append... | <p>
Performs the formatting by applying the rules to the specified calendar.
</p>
@param calendar the calendar to format
@param buf the buffer to format into
@param <B> the Appendable class type, usually StringBuilder or StringBuffer.
@return the specified string buffer | [
"<p",
">",
"Performs",
"the",
"formatting",
"by",
"applying",
"the",
"rules",
"to",
"the",
"specified",
"calendar",
".",
"<",
"/",
"p",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/format/FastDatePrinter.java#L372-L381 | train | Applies the rules to the given appendable. | [
30522,
2797,
1026,
1038,
8908,
10439,
10497,
3085,
1028,
1038,
6611,
6820,
4244,
1006,
2345,
8094,
8094,
1010,
2345,
1038,
20934,
2546,
1007,
1063,
3046,
1063,
2005,
1006,
2345,
3627,
3627,
1024,
2023,
1012,
3513,
1007,
1063,
3627,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/io/TextValueInputFormat.java | TextValueInputFormat.readRecord | @Override
public StringValue readRecord(StringValue reuse, byte[] bytes, int offset, int numBytes) {
if (this.ascii) {
reuse.setValueAscii(bytes, offset, numBytes);
return reuse;
}
else {
ByteBuffer byteWrapper = this.byteWrapper;
if (bytes != byteWrapper.array()) {
byteWrapper = ByteBuffer.wrap(bytes, 0, bytes.length);
this.byteWrapper = byteWrapper;
}
byteWrapper.limit(offset + numBytes);
byteWrapper.position(offset);
try {
CharBuffer result = this.decoder.decode(byteWrapper);
reuse.setValue(result);
return reuse;
}
catch (CharacterCodingException e) {
if (skipInvalidLines) {
return null;
} else {
byte[] copy = new byte[numBytes];
System.arraycopy(bytes, offset, copy, 0, numBytes);
throw new RuntimeException("Line could not be encoded: " + Arrays.toString(copy), e);
}
}
}
} | java | @Override
public StringValue readRecord(StringValue reuse, byte[] bytes, int offset, int numBytes) {
if (this.ascii) {
reuse.setValueAscii(bytes, offset, numBytes);
return reuse;
}
else {
ByteBuffer byteWrapper = this.byteWrapper;
if (bytes != byteWrapper.array()) {
byteWrapper = ByteBuffer.wrap(bytes, 0, bytes.length);
this.byteWrapper = byteWrapper;
}
byteWrapper.limit(offset + numBytes);
byteWrapper.position(offset);
try {
CharBuffer result = this.decoder.decode(byteWrapper);
reuse.setValue(result);
return reuse;
}
catch (CharacterCodingException e) {
if (skipInvalidLines) {
return null;
} else {
byte[] copy = new byte[numBytes];
System.arraycopy(bytes, offset, copy, 0, numBytes);
throw new RuntimeException("Line could not be encoded: " + Arrays.toString(copy), e);
}
}
}
} | [
"@",
"Override",
"public",
"StringValue",
"readRecord",
"(",
"StringValue",
"reuse",
",",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"numBytes",
")",
"{",
"if",
"(",
"this",
".",
"ascii",
")",
"{",
"reuse",
".",
"setValueAscii",
"(",
... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/io/TextValueInputFormat.java#L101-L131 | train | Read a single value from the byte array. | [
30522,
1030,
2058,
15637,
2270,
5164,
10175,
5657,
3191,
2890,
27108,
2094,
1006,
5164,
10175,
5657,
2128,
8557,
1010,
24880,
1031,
1033,
27507,
1010,
20014,
16396,
1010,
20014,
15903,
17250,
2015,
1007,
1063,
2065,
1006,
2023,
1012,
2004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.