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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
looly/hutool | hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java | ImgUtil.randomColor | public static Color randomColor(Random random) {
if (null == random) {
random = RandomUtil.getRandom();
}
return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
} | java | public static Color randomColor(Random random) {
if (null == random) {
random = RandomUtil.getRandom();
}
return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
} | [
"public",
"static",
"Color",
"randomColor",
"(",
"Random",
"random",
")",
"{",
"if",
"(",
"null",
"==",
"random",
")",
"{",
"random",
"=",
"RandomUtil",
".",
"getRandom",
"(",
")",
";",
"}",
"return",
"new",
"Color",
"(",
"random",
".",
"nextInt",
"(",... | 生成随机颜色
@param random 随机对象 {@link Random}
@return 随机颜色
@since 3.1.2 | [
"生成随机颜色"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L1815-L1820 | train | Creates a random color which is a random one. | [
30522,
2270,
10763,
3609,
6721,
18717,
1006,
6721,
6721,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
6721,
1007,
1063,
6721,
1027,
6721,
21823,
2140,
1012,
2131,
13033,
5358,
1006,
1007,
1025,
1065,
2709,
2047,
3609,
1006,
6721,
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/date/SystemClock.java | SystemClock.scheduleClockUpdating | private void scheduleClockUpdating() {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory(){
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "System Clock");
thread.setDaemon(true);
return thread;
}
});
scheduler.scheduleAtFixedRate(new Runnable(){
@Override
public void run() {
now = System.currentTimeMillis();
}
}, period, period, TimeUnit.MILLISECONDS);
} | java | private void scheduleClockUpdating() {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory(){
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "System Clock");
thread.setDaemon(true);
return thread;
}
});
scheduler.scheduleAtFixedRate(new Runnable(){
@Override
public void run() {
now = System.currentTimeMillis();
}
}, period, period, TimeUnit.MILLISECONDS);
} | [
"private",
"void",
"scheduleClockUpdating",
"(",
")",
"{",
"ScheduledExecutorService",
"scheduler",
"=",
"Executors",
".",
"newSingleThreadScheduledExecutor",
"(",
"new",
"ThreadFactory",
"(",
")",
"{",
"@",
"Override",
"public",
"Thread",
"newThread",
"(",
"Runnable"... | 开启计时器线程 | [
"开启计时器线程"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/SystemClock.java#L39-L54 | train | Schedules the clock updating. | [
30522,
2797,
11675,
6134,
20464,
7432,
6279,
16616,
1006,
1007,
1063,
5115,
10288,
8586,
16161,
22573,
2099,
7903,
2063,
6134,
2099,
1027,
4654,
8586,
16161,
2869,
1012,
2739,
2075,
7485,
28362,
19303,
7690,
18696,
10288,
8586,
16161,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/src/main/java/io/netty/handler/codec/compression/Snappy.java | Snappy.validateChecksum | static void validateChecksum(int expectedChecksum, ByteBuf data) {
validateChecksum(expectedChecksum, data, data.readerIndex(), data.readableBytes());
} | java | static void validateChecksum(int expectedChecksum, ByteBuf data) {
validateChecksum(expectedChecksum, data, data.readerIndex(), data.readableBytes());
} | [
"static",
"void",
"validateChecksum",
"(",
"int",
"expectedChecksum",
",",
"ByteBuf",
"data",
")",
"{",
"validateChecksum",
"(",
"expectedChecksum",
",",
"data",
",",
"data",
".",
"readerIndex",
"(",
")",
",",
"data",
".",
"readableBytes",
"(",
")",
")",
";"... | Computes the CRC32C checksum of the supplied data, performs the "mask" operation
on the computed checksum, and then compares the resulting masked checksum to the
supplied checksum.
@param expectedChecksum The checksum decoded from the stream to compare against
@param data The input data to calculate the CRC32C checksum of
@throws DecompressionException If the calculated and supplied checksums do not match | [
"Computes",
"the",
"CRC32C",
"checksum",
"of",
"the",
"supplied",
"data",
"performs",
"the",
"mask",
"operation",
"on",
"the",
"computed",
"checksum",
"and",
"then",
"compares",
"the",
"resulting",
"masked",
"checksum",
"to",
"the",
"supplied",
"checksum",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/compression/Snappy.java#L625-L627 | train | Validate the checksum of the given data. | [
30522,
10763,
11675,
9398,
3686,
5403,
10603,
2819,
1006,
20014,
3517,
5403,
10603,
2819,
1010,
24880,
8569,
2546,
2951,
1007,
1063,
9398,
3686,
5403,
10603,
2819,
1006,
3517,
5403,
10603,
2819,
1010,
2951,
1010,
2951,
1012,
8068,
22254,
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... |
looly/hutool | hutool-socket/src/main/java/cn/hutool/socket/nio/NioClient.java | NioClient.init | public NioClient init(InetSocketAddress address) {
try {
this.channel = SocketChannel.open(address);
} catch (IOException e) {
throw new IORuntimeException(e);
}
return this;
} | java | public NioClient init(InetSocketAddress address) {
try {
this.channel = SocketChannel.open(address);
} catch (IOException e) {
throw new IORuntimeException(e);
}
return this;
} | [
"public",
"NioClient",
"init",
"(",
"InetSocketAddress",
"address",
")",
"{",
"try",
"{",
"this",
".",
"channel",
"=",
"SocketChannel",
".",
"open",
"(",
"address",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IORuntimeExcept... | 初始化
@param address 地址和端口
@return this | [
"初始化"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-socket/src/main/java/cn/hutool/socket/nio/NioClient.java#L45-L52 | train | Initializes the NioClient with the specified address. | [
30522,
2270,
9152,
10085,
8751,
3372,
1999,
4183,
1006,
1999,
8454,
7432,
12928,
14141,
8303,
4769,
1007,
1063,
3046,
1063,
2023,
1012,
3149,
1027,
22278,
26058,
1012,
2330,
1006,
4769,
1007,
1025,
1065,
4608,
1006,
22834,
10288,
24422,
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.truncate | public static Calendar truncate(Calendar calendar, DateField dateField) {
return DateModifier.modify(calendar, dateField.getValue(), ModifyType.TRUNCATE);
} | java | public static Calendar truncate(Calendar calendar, DateField dateField) {
return DateModifier.modify(calendar, dateField.getValue(), ModifyType.TRUNCATE);
} | [
"public",
"static",
"Calendar",
"truncate",
"(",
"Calendar",
"calendar",
",",
"DateField",
"dateField",
")",
"{",
"return",
"DateModifier",
".",
"modify",
"(",
"calendar",
",",
"dateField",
".",
"getValue",
"(",
")",
",",
"ModifyType",
".",
"TRUNCATE",
")",
... | 修改日期为某个时间字段起始时间
@param calendar {@link Calendar}
@param dateField 时间字段
@return 原{@link Calendar}
@since 4.5.7 | [
"修改日期为某个时间字段起始时间"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L767-L769 | train | Truncate the given calendar to the specified value. | [
30522,
2270,
10763,
8094,
19817,
4609,
16280,
1006,
8094,
8094,
1010,
3058,
3790,
3058,
3790,
1007,
1063,
2709,
3058,
5302,
4305,
8873,
2121,
1012,
19933,
1006,
8094,
1010,
3058,
3790,
1012,
2131,
10175,
5657,
1006,
1007,
1010,
19933,
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... |
networknt/light-4j | dump/src/main/java/com/networknt/dump/StatusCodeDumper.java | StatusCodeDumper.putDumpInfoTo | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(StringUtils.isNotBlank(this.statusCodeResult)) {
result.put(DumpConstants.STATUS_CODE, this.statusCodeResult);
}
} | java | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(StringUtils.isNotBlank(this.statusCodeResult)) {
result.put(DumpConstants.STATUS_CODE, this.statusCodeResult);
}
} | [
"@",
"Override",
"protected",
"void",
"putDumpInfoTo",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"this",
".",
"statusCodeResult",
")",
")",
"{",
"result",
".",
"put",
"(",
"DumpCo... | put this.statusCodeResult to result
@param result a Map you want to put dumping info to. | [
"put",
"this",
".",
"statusCodeResult",
"to",
"result"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/StatusCodeDumper.java#L48-L53 | 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,
5164,
21823,
4877,
1012,
3475,
4140,
28522,
8950,
1006,
2023,
1012,
3570,
16044,
6072,
11314... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/AbstractDb.java | AbstractDb.del | public int del(String tableName, String field, Object value) throws SQLException {
return del(Entity.create(tableName).set(field, value));
} | java | public int del(String tableName, String field, Object value) throws SQLException {
return del(Entity.create(tableName).set(field, value));
} | [
"public",
"int",
"del",
"(",
"String",
"tableName",
",",
"String",
"field",
",",
"Object",
"value",
")",
"throws",
"SQLException",
"{",
"return",
"del",
"(",
"Entity",
".",
"create",
"(",
"tableName",
")",
".",
"set",
"(",
"field",
",",
"value",
")",
"... | 删除数据
@param tableName 表名
@param field 字段名,最好是主键
@param value 值,值可以是列表或数组,被当作IN查询处理
@return 删除行数
@throws SQLException SQL执行异常 | [
"删除数据"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java#L348-L350 | train | Delete an entity from the database. | [
30522,
2270,
20014,
3972,
1006,
5164,
2795,
18442,
1010,
5164,
2492,
1010,
4874,
3643,
1007,
11618,
29296,
10288,
24422,
1063,
2709,
3972,
1006,
9178,
1012,
3443,
1006,
2795,
18442,
1007,
1012,
2275,
1006,
2492,
1010,
3643,
1007,
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... |
apache/flink | flink-docs/src/main/java/org/apache/flink/docs/rest/RestAPIDocGenerator.java | RestAPIDocGenerator.main | public static void main(String[] args) throws IOException {
String outputDirectory = args[0];
for (final RestAPIVersion apiVersion : RestAPIVersion.values()) {
if (apiVersion == RestAPIVersion.V0) {
// this version exists only for testing purposes
continue;
}
createHtmlFile(
new DocumentingDispatcherRestEndpoint(),
apiVersion,
Paths.get(outputDirectory, "rest_" + apiVersion.getURLVersionPrefix() + "_dispatcher.html"));
}
} | java | public static void main(String[] args) throws IOException {
String outputDirectory = args[0];
for (final RestAPIVersion apiVersion : RestAPIVersion.values()) {
if (apiVersion == RestAPIVersion.V0) {
// this version exists only for testing purposes
continue;
}
createHtmlFile(
new DocumentingDispatcherRestEndpoint(),
apiVersion,
Paths.get(outputDirectory, "rest_" + apiVersion.getURLVersionPrefix() + "_dispatcher.html"));
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
"{",
"String",
"outputDirectory",
"=",
"args",
"[",
"0",
"]",
";",
"for",
"(",
"final",
"RestAPIVersion",
"apiVersion",
":",
"RestAPIVersion",
".",
"values",
... | Generates the REST API documentation.
@param args args[0] contains the directory into which the generated files are placed
@throws IOException if any file operation failed | [
"Generates",
"the",
"REST",
"API",
"documentation",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-docs/src/main/java/org/apache/flink/docs/rest/RestAPIDocGenerator.java#L102-L115 | train | Main method for creating a DocsDispatcher. html file. | [
30522,
2270,
10763,
11675,
2364,
1006,
5164,
1031,
1033,
12098,
5620,
1007,
11618,
22834,
10288,
24422,
1063,
5164,
6434,
4305,
2890,
16761,
2100,
1027,
12098,
5620,
1031,
1014,
1033,
1025,
2005,
1006,
2345,
2717,
9331,
16402,
10992,
17928,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/SelfRegisteringRemote.java | SelfRegisteringRemote.getHubConfiguration | private GridHubConfiguration getHubConfiguration() throws Exception {
String hubApi =
"http://" + registrationRequest.getConfiguration().getHubHost() + ":"
+ registrationRequest.getConfiguration().getHubPort() + "/grid/api/hub";
URL api = new URL(hubApi);
HttpClient client = httpClientFactory.createClient(api);
String url = api.toExternalForm();
HttpRequest request = new HttpRequest(GET, url);
HttpResponse response = client.execute(request);
try (Reader reader = new StringReader(response.getContentString());
JsonInput jsonInput = new Json().newInput(reader)) {
return GridHubConfiguration.loadFromJSON(jsonInput);
}
} | java | private GridHubConfiguration getHubConfiguration() throws Exception {
String hubApi =
"http://" + registrationRequest.getConfiguration().getHubHost() + ":"
+ registrationRequest.getConfiguration().getHubPort() + "/grid/api/hub";
URL api = new URL(hubApi);
HttpClient client = httpClientFactory.createClient(api);
String url = api.toExternalForm();
HttpRequest request = new HttpRequest(GET, url);
HttpResponse response = client.execute(request);
try (Reader reader = new StringReader(response.getContentString());
JsonInput jsonInput = new Json().newInput(reader)) {
return GridHubConfiguration.loadFromJSON(jsonInput);
}
} | [
"private",
"GridHubConfiguration",
"getHubConfiguration",
"(",
")",
"throws",
"Exception",
"{",
"String",
"hubApi",
"=",
"\"http://\"",
"+",
"registrationRequest",
".",
"getConfiguration",
"(",
")",
".",
"getHubHost",
"(",
")",
"+",
"\":\"",
"+",
"registrationReques... | uses the hub API to get some of its configuration.
@return json object of the current hub configuration | [
"uses",
"the",
"hub",
"API",
"to",
"get",
"some",
"of",
"its",
"configuration",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/grid/internal/utils/SelfRegisteringRemote.java#L359-L374 | train | Get the hub configuration | [
30522,
2797,
8370,
6979,
9818,
2239,
8873,
27390,
3370,
2131,
6979,
9818,
2239,
8873,
27390,
3370,
1006,
1007,
11618,
6453,
1063,
5164,
9594,
9331,
2072,
1027,
1000,
8299,
1024,
1013,
1013,
1000,
1009,
8819,
2890,
15500,
1012,
2131,
8663,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/old/parser/sql/SQLParserFactory.java | SQLParserFactory.newInstance | public static SQLParser newInstance(final DatabaseType dbType, final EncryptRule encryptRule, final ShardingTableMetaData shardingTableMetaData, final String sql) {
if (DatabaseType.MySQL == dbType || DatabaseType.H2 == dbType) {
return new AntlrParsingEngine(dbType, sql, encryptRule, shardingTableMetaData);
}
throw new SQLParsingUnsupportedException(String.format("Can not support %s", dbType));
} | java | public static SQLParser newInstance(final DatabaseType dbType, final EncryptRule encryptRule, final ShardingTableMetaData shardingTableMetaData, final String sql) {
if (DatabaseType.MySQL == dbType || DatabaseType.H2 == dbType) {
return new AntlrParsingEngine(dbType, sql, encryptRule, shardingTableMetaData);
}
throw new SQLParsingUnsupportedException(String.format("Can not support %s", dbType));
} | [
"public",
"static",
"SQLParser",
"newInstance",
"(",
"final",
"DatabaseType",
"dbType",
",",
"final",
"EncryptRule",
"encryptRule",
",",
"final",
"ShardingTableMetaData",
"shardingTableMetaData",
",",
"final",
"String",
"sql",
")",
"{",
"if",
"(",
"DatabaseType",
".... | Create Encrypt SQL parser.
@param dbType db type
@param encryptRule encrypt rule
@param shardingTableMetaData sharding table meta data
@param sql sql
@return sql parser | [
"Create",
"Encrypt",
"SQL",
"parser",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/old/parser/sql/SQLParserFactory.java#L125-L130 | train | Create an instance of SQLParser. | [
30522,
2270,
10763,
29296,
19362,
8043,
2047,
7076,
26897,
1006,
2345,
7809,
13874,
16962,
13874,
1010,
2345,
4372,
26775,
22571,
16344,
9307,
4372,
26775,
22571,
16344,
9307,
1010,
2345,
21146,
17080,
3070,
10880,
11368,
8447,
2696,
21146,
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-core/src/main/java/cn/hutool/core/img/ImgUtil.java | ImgUtil.getImageOutputStream | public static ImageOutputStream getImageOutputStream(OutputStream out) throws IORuntimeException {
try {
return ImageIO.createImageOutputStream(out);
} catch (IOException e) {
throw new IORuntimeException(e);
}
} | java | public static ImageOutputStream getImageOutputStream(OutputStream out) throws IORuntimeException {
try {
return ImageIO.createImageOutputStream(out);
} catch (IOException e) {
throw new IORuntimeException(e);
}
} | [
"public",
"static",
"ImageOutputStream",
"getImageOutputStream",
"(",
"OutputStream",
"out",
")",
"throws",
"IORuntimeException",
"{",
"try",
"{",
"return",
"ImageIO",
".",
"createImageOutputStream",
"(",
"out",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")"... | 获取{@link ImageOutputStream}
@param out {@link OutputStream}
@return {@link ImageOutputStream}
@throws IORuntimeException IO异常
@since 3.1.2 | [
"获取",
"{",
"@link",
"ImageOutputStream",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L1606-L1612 | train | Gets an ImageOutputStream for writing to an OutputStream. | [
30522,
2270,
10763,
3746,
5833,
18780,
21422,
2131,
9581,
3351,
5833,
18780,
21422,
1006,
27852,
25379,
2041,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
3046,
1063,
2709,
3746,
3695,
1012,
3443,
9581,
3351,
5833,
18780,
21422,
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... |
spring-projects/spring-boot | spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java | DataSourceProperties.initializeDataSourceBuilder | public DataSourceBuilder<?> initializeDataSourceBuilder() {
return DataSourceBuilder.create(getClassLoader()).type(getType())
.driverClassName(determineDriverClassName()).url(determineUrl())
.username(determineUsername()).password(determinePassword());
} | java | public DataSourceBuilder<?> initializeDataSourceBuilder() {
return DataSourceBuilder.create(getClassLoader()).type(getType())
.driverClassName(determineDriverClassName()).url(determineUrl())
.username(determineUsername()).password(determinePassword());
} | [
"public",
"DataSourceBuilder",
"<",
"?",
">",
"initializeDataSourceBuilder",
"(",
")",
"{",
"return",
"DataSourceBuilder",
".",
"create",
"(",
"getClassLoader",
"(",
")",
")",
".",
"type",
"(",
"getType",
"(",
")",
")",
".",
"driverClassName",
"(",
"determineD... | Initialize a {@link DataSourceBuilder} with the state of this instance.
@return a {@link DataSourceBuilder} initialized with the customizations defined on
this instance | [
"Initialize",
"a",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java#L174-L178 | train | Initialize the DataSourceBuilder. | [
30522,
2270,
2951,
6499,
3126,
3401,
8569,
23891,
2099,
1026,
1029,
1028,
3988,
3550,
6790,
6499,
3126,
3401,
8569,
23891,
2099,
1006,
1007,
1063,
2709,
2951,
6499,
3126,
3401,
8569,
23891,
2099,
1012,
3443,
1006,
2131,
26266,
11066,
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... |
apache/flink | flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.getRange | public IntegerRanges getRange(String name, String defaultValue) {
return new IntegerRanges(get(name, defaultValue));
} | java | public IntegerRanges getRange(String name, String defaultValue) {
return new IntegerRanges(get(name, defaultValue));
} | [
"public",
"IntegerRanges",
"getRange",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"return",
"new",
"IntegerRanges",
"(",
"get",
"(",
"name",
",",
"defaultValue",
")",
")",
";",
"}"
] | Parse the given attribute as a set of integer ranges
@param name the attribute name
@param defaultValue the default value if it is not set
@return a new set of ranges from the configured value | [
"Parse",
"the",
"given",
"attribute",
"as",
"a",
"set",
"of",
"integer",
"ranges"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L2033-L2035 | train | Get the IntegerRanges value for the given name. | [
30522,
2270,
16109,
24388,
2229,
2131,
24388,
2063,
1006,
5164,
2171,
1010,
5164,
12398,
10175,
5657,
1007,
1063,
2709,
2047,
16109,
24388,
2229,
1006,
2131,
1006,
2171,
1010,
12398,
10175,
5657,
1007,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 | store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java | MemoryEventStoreWithBuffer.doPut | private void doPut(List<Event> data) {
long current = putSequence.get();
long end = current + data.size();
// 先写数据,再更新对应的cursor,并发度高的情况,putSequence会被get请求可见,拿出了ringbuffer中的老的Entry值
for (long next = current + 1; next <= end; next++) {
entries[getIndex(next)] = data.get((int) (next - current - 1));
}
putSequence.set(end);
// 记录一下gets memsize信息,方便快速检索
if (batchMode.isMemSize()) {
long size = 0;
for (Event event : data) {
size += calculateSize(event);
}
putMemSize.getAndAdd(size);
}
profiling(data, OP.PUT);
// tell other threads that store is not empty
notEmpty.signal();
} | java | private void doPut(List<Event> data) {
long current = putSequence.get();
long end = current + data.size();
// 先写数据,再更新对应的cursor,并发度高的情况,putSequence会被get请求可见,拿出了ringbuffer中的老的Entry值
for (long next = current + 1; next <= end; next++) {
entries[getIndex(next)] = data.get((int) (next - current - 1));
}
putSequence.set(end);
// 记录一下gets memsize信息,方便快速检索
if (batchMode.isMemSize()) {
long size = 0;
for (Event event : data) {
size += calculateSize(event);
}
putMemSize.getAndAdd(size);
}
profiling(data, OP.PUT);
// tell other threads that store is not empty
notEmpty.signal();
} | [
"private",
"void",
"doPut",
"(",
"List",
"<",
"Event",
">",
"data",
")",
"{",
"long",
"current",
"=",
"putSequence",
".",
"get",
"(",
")",
";",
"long",
"end",
"=",
"current",
"+",
"data",
".",
"size",
"(",
")",
";",
"// 先写数据,再更新对应的cursor,并发度高的情况,putSeque... | 执行具体的put操作 | [
"执行具体的put操作"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java#L188-L211 | train | Put data into the cache. | [
30522,
2797,
11675,
2079,
18780,
1006,
2862,
1026,
2724,
1028,
2951,
1007,
1063,
2146,
2783,
1027,
8509,
2063,
4226,
5897,
1012,
2131,
1006,
1007,
1025,
2146,
2203,
1027,
2783,
1009,
2951,
1012,
2946,
1006,
1007,
1025,
1013,
1013,
100,
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.writeUtf8String | public static File writeUtf8String(String content, String path) throws IORuntimeException {
return writeString(content, path, CharsetUtil.CHARSET_UTF_8);
} | java | public static File writeUtf8String(String content, String path) throws IORuntimeException {
return writeString(content, path, CharsetUtil.CHARSET_UTF_8);
} | [
"public",
"static",
"File",
"writeUtf8String",
"(",
"String",
"content",
",",
"String",
"path",
")",
"throws",
"IORuntimeException",
"{",
"return",
"writeString",
"(",
"content",
",",
"path",
",",
"CharsetUtil",
".",
"CHARSET_UTF_8",
")",
";",
"}"
] | 将String写入文件,覆盖模式,字符集为UTF-8
@param content 写入的内容
@param path 文件路径
@return 写入的文件
@throws IORuntimeException IO异常 | [
"将String写入文件,覆盖模式,字符集为UTF",
"-",
"8"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2695-L2697 | train | Write a UTF - 8 string to a file. | [
30522,
2270,
10763,
5371,
4339,
4904,
2546,
2620,
3367,
4892,
1006,
5164,
4180,
1010,
5164,
4130,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
2709,
7009,
18886,
3070,
1006,
4180,
1010,
4130,
1010,
25869,
13462,
21823,
2140,
1012,
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... |
networknt/light-4j | client/src/main/java/com/networknt/client/oauth/OauthHelper.java | OauthHelper.renewCCTokenSync | private static Result<Jwt> renewCCTokenSync(final Jwt jwt) {
// Already expired, try to renew getCCTokenSynchronously but let requests use the old token.
logger.trace("In renew window and token is already expired.");
//the token can be renew when it's not on renewing or current time is lager than retrying interval
if (!jwt.isRenewing() || System.currentTimeMillis() > jwt.getExpiredRetryTimeout()) {
jwt.setRenewing(true);
jwt.setEarlyRetryTimeout(System.currentTimeMillis() + Jwt.getExpiredRefreshRetryDelay());
Result<Jwt> result = getCCTokenRemotely(jwt);
//set renewing flag to false no mater fail or success
jwt.setRenewing(false);
return result;
} else {
if(logger.isTraceEnabled()) logger.trace("Circuit breaker is tripped and not timeout yet!");
// token is renewing
return Failure.of(new Status(STATUS_CLIENT_CREDENTIALS_TOKEN_NOT_AVAILABLE));
}
} | java | private static Result<Jwt> renewCCTokenSync(final Jwt jwt) {
// Already expired, try to renew getCCTokenSynchronously but let requests use the old token.
logger.trace("In renew window and token is already expired.");
//the token can be renew when it's not on renewing or current time is lager than retrying interval
if (!jwt.isRenewing() || System.currentTimeMillis() > jwt.getExpiredRetryTimeout()) {
jwt.setRenewing(true);
jwt.setEarlyRetryTimeout(System.currentTimeMillis() + Jwt.getExpiredRefreshRetryDelay());
Result<Jwt> result = getCCTokenRemotely(jwt);
//set renewing flag to false no mater fail or success
jwt.setRenewing(false);
return result;
} else {
if(logger.isTraceEnabled()) logger.trace("Circuit breaker is tripped and not timeout yet!");
// token is renewing
return Failure.of(new Status(STATUS_CLIENT_CREDENTIALS_TOKEN_NOT_AVAILABLE));
}
} | [
"private",
"static",
"Result",
"<",
"Jwt",
">",
"renewCCTokenSync",
"(",
"final",
"Jwt",
"jwt",
")",
"{",
"// Already expired, try to renew getCCTokenSynchronously but let requests use the old token.",
"logger",
".",
"trace",
"(",
"\"In renew window and token is already expired.\... | renew Client Credential token synchronously.
When success will renew the Jwt jwt passed in.
When fail will return Status code so that can be handled by caller.
@param jwt the jwt you want to renew
@return Jwt when success, it will be the same object as the jwt you passed in; return Status when fail; | [
"renew",
"Client",
"Credential",
"token",
"synchronously",
".",
"When",
"success",
"will",
"renew",
"the",
"Jwt",
"jwt",
"passed",
"in",
".",
"When",
"fail",
"will",
"return",
"Status",
"code",
"so",
"that",
"can",
"be",
"handled",
"by",
"caller",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/oauth/OauthHelper.java#L593-L609 | train | Renew the CCToken asynchronously. | [
30522,
2797,
10763,
2765,
1026,
1046,
26677,
1028,
20687,
9468,
18715,
6132,
6038,
2278,
1006,
2345,
1046,
26677,
1046,
26677,
1007,
1063,
1013,
1013,
2525,
13735,
1010,
3046,
2000,
20687,
2131,
9468,
18715,
6132,
6038,
2818,
4948,
13453,
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/codec/Base64.java | Base64.decodeToFile | public static File decodeToFile(String base64, File destFile) {
return FileUtil.writeBytes(Base64Decoder.decode(base64), destFile);
} | java | public static File decodeToFile(String base64, File destFile) {
return FileUtil.writeBytes(Base64Decoder.decode(base64), destFile);
} | [
"public",
"static",
"File",
"decodeToFile",
"(",
"String",
"base64",
",",
"File",
"destFile",
")",
"{",
"return",
"FileUtil",
".",
"writeBytes",
"(",
"Base64Decoder",
".",
"decode",
"(",
"base64",
")",
",",
"destFile",
")",
";",
"}"
] | base64解码
@param base64 被解码的base64字符串
@param destFile 目标文件
@return 目标文件
@since 4.0.9 | [
"base64解码"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/codec/Base64.java#L289-L291 | train | Decodes a base64 string into a file. | [
30522,
2270,
10763,
5371,
21933,
3207,
3406,
8873,
2571,
1006,
5164,
2918,
21084,
1010,
5371,
4078,
24475,
9463,
1007,
1063,
2709,
5371,
21823,
2140,
1012,
4339,
3762,
4570,
1006,
2918,
21084,
3207,
16044,
2099,
1012,
21933,
3207,
1006,
291... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/CharsetConversion.java | CharsetConversion.getCollation | public static String getCollation(final int id) {
Entry entry = getEntry(id);
if (entry != null) {
return entry.mysqlCollation;
} else {
logger.warn("Unexpect mysql charset: " + id);
return null;
}
} | java | public static String getCollation(final int id) {
Entry entry = getEntry(id);
if (entry != null) {
return entry.mysqlCollation;
} else {
logger.warn("Unexpect mysql charset: " + id);
return null;
}
} | [
"public",
"static",
"String",
"getCollation",
"(",
"final",
"int",
"id",
")",
"{",
"Entry",
"entry",
"=",
"getEntry",
"(",
"id",
")",
";",
"if",
"(",
"entry",
"!=",
"null",
")",
"{",
"return",
"entry",
".",
"mysqlCollation",
";",
"}",
"else",
"{",
"l... | Return defined collaction name for mysql. | [
"Return",
"defined",
"collaction",
"name",
"for",
"mysql",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/CharsetConversion.java#L362-L371 | train | Gets the collation name for a
object. | [
30522,
2270,
10763,
5164,
2131,
26895,
3370,
1006,
2345,
20014,
8909,
1007,
1063,
4443,
4443,
1027,
2131,
4765,
2854,
1006,
8909,
1007,
1025,
2065,
1006,
4443,
999,
1027,
19701,
1007,
1063,
2709,
4443,
1012,
2026,
2015,
4160,
22499,
20382,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DaoTemplate.java | DaoTemplate.get | public <T> Entity get(String field, T value) throws SQLException {
return this.get(Entity.create(tableName).set(field, value));
} | java | public <T> Entity get(String field, T value) throws SQLException {
return this.get(Entity.create(tableName).set(field, value));
} | [
"public",
"<",
"T",
">",
"Entity",
"get",
"(",
"String",
"field",
",",
"T",
"value",
")",
"throws",
"SQLException",
"{",
"return",
"this",
".",
"get",
"(",
"Entity",
".",
"create",
"(",
"tableName",
")",
".",
"set",
"(",
"field",
",",
"value",
")",
... | 根据某个字段(最好是唯一字段)查询单个记录<br>
当有多条返回时,只显示查询到的第一条
@param <T> 字段值类型
@param field 字段名
@param value 字段值
@return 记录
@throws SQLException SQL执行异常 | [
"根据某个字段(最好是唯一字段)查询单个记录<br",
">",
"当有多条返回时,只显示查询到的第一条"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/DaoTemplate.java#L232-L234 | train | Gets an entity by field. | [
30522,
2270,
1026,
1056,
1028,
9178,
2131,
1006,
5164,
2492,
1010,
1056,
3643,
1007,
11618,
29296,
10288,
24422,
1063,
2709,
2023,
1012,
2131,
1006,
9178,
1012,
3443,
1006,
2795,
18442,
1007,
1012,
2275,
1006,
2492,
1010,
3643,
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... |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryString.java | BinaryString.toLowerCase | public BinaryString toLowerCase() {
if (javaObject != null) {
return toLowerCaseSlow();
}
if (sizeInBytes == 0) {
return EMPTY_UTF8;
}
int size = segments[0].size();
SegmentAndOffset segmentAndOffset = startSegmentAndOffset(size);
byte[] bytes = new byte[sizeInBytes];
bytes[0] = (byte) Character.toTitleCase(segmentAndOffset.value());
for (int i = 0; i < sizeInBytes; i++) {
byte b = segmentAndOffset.value();
if (numBytesForFirstByte(b) != 1) {
// fallback
return toLowerCaseSlow();
}
int lower = Character.toLowerCase((int) b);
if (lower > 127) {
// fallback
return toLowerCaseSlow();
}
bytes[i] = (byte) lower;
segmentAndOffset.nextByte(size);
}
return fromBytes(bytes);
} | java | public BinaryString toLowerCase() {
if (javaObject != null) {
return toLowerCaseSlow();
}
if (sizeInBytes == 0) {
return EMPTY_UTF8;
}
int size = segments[0].size();
SegmentAndOffset segmentAndOffset = startSegmentAndOffset(size);
byte[] bytes = new byte[sizeInBytes];
bytes[0] = (byte) Character.toTitleCase(segmentAndOffset.value());
for (int i = 0; i < sizeInBytes; i++) {
byte b = segmentAndOffset.value();
if (numBytesForFirstByte(b) != 1) {
// fallback
return toLowerCaseSlow();
}
int lower = Character.toLowerCase((int) b);
if (lower > 127) {
// fallback
return toLowerCaseSlow();
}
bytes[i] = (byte) lower;
segmentAndOffset.nextByte(size);
}
return fromBytes(bytes);
} | [
"public",
"BinaryString",
"toLowerCase",
"(",
")",
"{",
"if",
"(",
"javaObject",
"!=",
"null",
")",
"{",
"return",
"toLowerCaseSlow",
"(",
")",
";",
"}",
"if",
"(",
"sizeInBytes",
"==",
"0",
")",
"{",
"return",
"EMPTY_UTF8",
";",
"}",
"int",
"size",
"=... | Returns the lower case of this string. | [
"Returns",
"the",
"lower",
"case",
"of",
"this",
"string",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryString.java#L1696-L1722 | train | Returns a new string with the lower case of this string. | [
30522,
2270,
12441,
3367,
4892,
2000,
27663,
18992,
3366,
1006,
1007,
1063,
2065,
1006,
9262,
16429,
20614,
999,
1027,
19701,
1007,
1063,
2709,
2000,
27663,
18992,
8583,
8261,
1006,
1007,
1025,
1065,
2065,
1006,
2946,
2378,
3762,
4570,
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... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java | FirefoxBinary.locateFirefoxBinaryFromSystemProperty | private static Executable locateFirefoxBinaryFromSystemProperty() {
String binaryName = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_BINARY);
if (binaryName == null)
return null;
File binary = new File(binaryName);
if (binary.exists() && !binary.isDirectory())
return new Executable(binary);
Platform current = Platform.getCurrent();
if (current.is(WINDOWS)) {
if (!binaryName.endsWith(".exe")) {
binaryName += ".exe";
}
} else if (current.is(MAC)) {
if (!binaryName.endsWith(".app")) {
binaryName += ".app";
}
binaryName += "/Contents/MacOS/firefox-bin";
}
binary = new File(binaryName);
if (binary.exists())
return new Executable(binary);
throw new WebDriverException(
String.format("'%s' property set, but unable to locate the requested binary: %s",
FirefoxDriver.SystemProperty.BROWSER_BINARY, binaryName));
} | java | private static Executable locateFirefoxBinaryFromSystemProperty() {
String binaryName = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_BINARY);
if (binaryName == null)
return null;
File binary = new File(binaryName);
if (binary.exists() && !binary.isDirectory())
return new Executable(binary);
Platform current = Platform.getCurrent();
if (current.is(WINDOWS)) {
if (!binaryName.endsWith(".exe")) {
binaryName += ".exe";
}
} else if (current.is(MAC)) {
if (!binaryName.endsWith(".app")) {
binaryName += ".app";
}
binaryName += "/Contents/MacOS/firefox-bin";
}
binary = new File(binaryName);
if (binary.exists())
return new Executable(binary);
throw new WebDriverException(
String.format("'%s' property set, but unable to locate the requested binary: %s",
FirefoxDriver.SystemProperty.BROWSER_BINARY, binaryName));
} | [
"private",
"static",
"Executable",
"locateFirefoxBinaryFromSystemProperty",
"(",
")",
"{",
"String",
"binaryName",
"=",
"System",
".",
"getProperty",
"(",
"FirefoxDriver",
".",
"SystemProperty",
".",
"BROWSER_BINARY",
")",
";",
"if",
"(",
"binaryName",
"==",
"null",... | Locates the firefox binary from a system property. Will throw an exception if the binary cannot
be found. | [
"Locates",
"the",
"firefox",
"binary",
"from",
"a",
"system",
"property",
".",
"Will",
"throw",
"an",
"exception",
"if",
"the",
"binary",
"cannot",
"be",
"found",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java#L166-L195 | train | Locate the firefox binary from the system property firefox. binary. | [
30522,
2797,
10763,
4654,
8586,
23056,
12453,
10273,
14876,
2595,
21114,
2854,
19699,
22225,
27268,
6633,
21572,
4842,
3723,
1006,
1007,
1063,
5164,
12441,
18442,
1027,
2291,
1012,
2131,
21572,
4842,
3723,
1006,
2543,
14876,
2595,
23663,
2099... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/operator/CepRuntimeContext.java | CepRuntimeContext.addAccumulator | @Override
public <V, A extends Serializable> void addAccumulator(
final String name,
final Accumulator<V, A> accumulator) {
throw new UnsupportedOperationException("Accumulators are not supported.");
} | java | @Override
public <V, A extends Serializable> void addAccumulator(
final String name,
final Accumulator<V, A> accumulator) {
throw new UnsupportedOperationException("Accumulators are not supported.");
} | [
"@",
"Override",
"public",
"<",
"V",
",",
"A",
"extends",
"Serializable",
">",
"void",
"addAccumulator",
"(",
"final",
"String",
"name",
",",
"final",
"Accumulator",
"<",
"V",
",",
"A",
">",
"accumulator",
")",
"{",
"throw",
"new",
"UnsupportedOperationExcep... | ----------------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/operator/CepRuntimeContext.java#L122-L127 | train | Add an accumulator to the cache. | [
30522,
1030,
2058,
15637,
2270,
1026,
1058,
1010,
1037,
8908,
7642,
21335,
3468,
1028,
11675,
5587,
6305,
24894,
20350,
1006,
2345,
5164,
2171,
1010,
2345,
16222,
2819,
20350,
1026,
1058,
1010,
1037,
1028,
16222,
2819,
20350,
1007,
1063,
54... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | common/src/main/java/com/alibaba/otter/canal/common/zookeeper/running/ServerRunningMonitor.java | ServerRunningMonitor.check | public boolean check() {
String path = ZookeeperPathUtils.getDestinationServerRunning(destination);
try {
byte[] bytes = zkClient.readData(path);
ServerRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ServerRunningData.class);
activeData = eventData;// 更新下为最新值
// 检查下nid是否为自己
boolean result = isMine(activeData.getAddress());
if (!result) {
logger.warn("canal is running in node[{}] , but not in node[{}]",
activeData.getCid(),
serverData.getCid());
}
return result;
} catch (ZkNoNodeException e) {
logger.warn("canal is not run any in node");
return false;
} catch (ZkInterruptedException e) {
logger.warn("canal check is interrupt");
Thread.interrupted();// 清除interrupt标记
return check();
} catch (ZkException e) {
logger.warn("canal check is failed");
return false;
}
} | java | public boolean check() {
String path = ZookeeperPathUtils.getDestinationServerRunning(destination);
try {
byte[] bytes = zkClient.readData(path);
ServerRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ServerRunningData.class);
activeData = eventData;// 更新下为最新值
// 检查下nid是否为自己
boolean result = isMine(activeData.getAddress());
if (!result) {
logger.warn("canal is running in node[{}] , but not in node[{}]",
activeData.getCid(),
serverData.getCid());
}
return result;
} catch (ZkNoNodeException e) {
logger.warn("canal is not run any in node");
return false;
} catch (ZkInterruptedException e) {
logger.warn("canal check is interrupt");
Thread.interrupted();// 清除interrupt标记
return check();
} catch (ZkException e) {
logger.warn("canal check is failed");
return false;
}
} | [
"public",
"boolean",
"check",
"(",
")",
"{",
"String",
"path",
"=",
"ZookeeperPathUtils",
".",
"getDestinationServerRunning",
"(",
"destination",
")",
";",
"try",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"zkClient",
".",
"readData",
"(",
"path",
")",
";",
"Ser... | 检查当前的状态 | [
"检查当前的状态"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/common/src/main/java/com/alibaba/otter/canal/common/zookeeper/running/ServerRunningMonitor.java#L177-L202 | train | check if the canal is running in the node | [
30522,
2270,
22017,
20898,
4638,
1006,
1007,
1063,
5164,
4130,
1027,
9201,
13106,
15069,
21823,
4877,
1012,
2131,
6155,
13770,
9285,
2121,
6299,
15532,
5582,
1006,
7688,
1007,
1025,
3046,
1063,
24880,
1031,
1033,
27507,
1027,
1062,
2243,
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... |
netty/netty | codec/src/main/java/io/netty/handler/codec/compression/Bzip2HuffmanStageEncoder.java | Bzip2HuffmanStageEncoder.generateHuffmanOptimisationSeeds | private void generateHuffmanOptimisationSeeds() {
final int[][] huffmanCodeLengths = this.huffmanCodeLengths;
final int[] mtfSymbolFrequencies = this.mtfSymbolFrequencies;
final int mtfAlphabetSize = this.mtfAlphabetSize;
final int totalTables = huffmanCodeLengths.length;
int remainingLength = mtfLength;
int lowCostEnd = -1;
for (int i = 0; i < totalTables; i++) {
final int targetCumulativeFrequency = remainingLength / (totalTables - i);
final int lowCostStart = lowCostEnd + 1;
int actualCumulativeFrequency = 0;
while (actualCumulativeFrequency < targetCumulativeFrequency && lowCostEnd < mtfAlphabetSize - 1) {
actualCumulativeFrequency += mtfSymbolFrequencies[++lowCostEnd];
}
if (lowCostEnd > lowCostStart && i != 0 && i != totalTables - 1 && (totalTables - i & 1) == 0) {
actualCumulativeFrequency -= mtfSymbolFrequencies[lowCostEnd--];
}
final int[] tableCodeLengths = huffmanCodeLengths[i];
for (int j = 0; j < mtfAlphabetSize; j++) {
if (j < lowCostStart || j > lowCostEnd) {
tableCodeLengths[j] = HUFFMAN_HIGH_SYMBOL_COST;
}
}
remainingLength -= actualCumulativeFrequency;
}
} | java | private void generateHuffmanOptimisationSeeds() {
final int[][] huffmanCodeLengths = this.huffmanCodeLengths;
final int[] mtfSymbolFrequencies = this.mtfSymbolFrequencies;
final int mtfAlphabetSize = this.mtfAlphabetSize;
final int totalTables = huffmanCodeLengths.length;
int remainingLength = mtfLength;
int lowCostEnd = -1;
for (int i = 0; i < totalTables; i++) {
final int targetCumulativeFrequency = remainingLength / (totalTables - i);
final int lowCostStart = lowCostEnd + 1;
int actualCumulativeFrequency = 0;
while (actualCumulativeFrequency < targetCumulativeFrequency && lowCostEnd < mtfAlphabetSize - 1) {
actualCumulativeFrequency += mtfSymbolFrequencies[++lowCostEnd];
}
if (lowCostEnd > lowCostStart && i != 0 && i != totalTables - 1 && (totalTables - i & 1) == 0) {
actualCumulativeFrequency -= mtfSymbolFrequencies[lowCostEnd--];
}
final int[] tableCodeLengths = huffmanCodeLengths[i];
for (int j = 0; j < mtfAlphabetSize; j++) {
if (j < lowCostStart || j > lowCostEnd) {
tableCodeLengths[j] = HUFFMAN_HIGH_SYMBOL_COST;
}
}
remainingLength -= actualCumulativeFrequency;
}
} | [
"private",
"void",
"generateHuffmanOptimisationSeeds",
"(",
")",
"{",
"final",
"int",
"[",
"]",
"[",
"]",
"huffmanCodeLengths",
"=",
"this",
".",
"huffmanCodeLengths",
";",
"final",
"int",
"[",
"]",
"mtfSymbolFrequencies",
"=",
"this",
".",
"mtfSymbolFrequencies",... | Generate initial Huffman code length tables, giving each table a different low cost section
of the alphabet that is roughly equal in overall cumulative frequency. Note that the initial
tables are invalid for actual Huffman code generation, and only serve as the seed for later
iterative optimisation in {@link #optimiseSelectorsAndHuffmanTables(boolean)}. | [
"Generate",
"initial",
"Huffman",
"code",
"length",
"tables",
"giving",
"each",
"table",
"a",
"different",
"low",
"cost",
"section",
"of",
"the",
"alphabet",
"that",
"is",
"roughly",
"equal",
"in",
"overall",
"cumulative",
"frequency",
".",
"Note",
"that",
"th... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/compression/Bzip2HuffmanStageEncoder.java#L161-L194 | train | Generate Huffman optimisation seeds. | [
30522,
2797,
11675,
9699,
6979,
4246,
2386,
7361,
3775,
15630,
10708,
13089,
2015,
1006,
1007,
1063,
2345,
20014,
1031,
1033,
1031,
1033,
21301,
2386,
16044,
7770,
13512,
7898,
1027,
2023,
1012,
21301,
2386,
16044,
7770,
13512,
7898,
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... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/operators/base/CoGroupRawOperatorBase.java | CoGroupRawOperatorBase.setGroupOrder | public void setGroupOrder(int inputNum, Ordering order) {
if (inputNum == 0) {
this.groupOrder1 = order;
} else if (inputNum == 1) {
this.groupOrder2 = order;
} else {
throw new IndexOutOfBoundsException();
}
} | java | public void setGroupOrder(int inputNum, Ordering order) {
if (inputNum == 0) {
this.groupOrder1 = order;
} else if (inputNum == 1) {
this.groupOrder2 = order;
} else {
throw new IndexOutOfBoundsException();
}
} | [
"public",
"void",
"setGroupOrder",
"(",
"int",
"inputNum",
",",
"Ordering",
"order",
")",
"{",
"if",
"(",
"inputNum",
"==",
"0",
")",
"{",
"this",
".",
"groupOrder1",
"=",
"order",
";",
"}",
"else",
"if",
"(",
"inputNum",
"==",
"1",
")",
"{",
"this",... | Sets the order of the elements within a group for the given input.
@param inputNum The number of the input (here either <i>0</i> or <i>1</i>).
@param order The order for the elements in a group. | [
"Sets",
"the",
"order",
"of",
"the",
"elements",
"within",
"a",
"group",
"for",
"the",
"given",
"input",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/operators/base/CoGroupRawOperatorBase.java#L89-L97 | train | Sets the group order. | [
30522,
2270,
11675,
2275,
17058,
8551,
2121,
1006,
20014,
7953,
19172,
1010,
13063,
2344,
1007,
1063,
2065,
1006,
7953,
19172,
1027,
1027,
1014,
1007,
1063,
2023,
1012,
2177,
8551,
2121,
2487,
1027,
2344,
1025,
1065,
2842,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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/Statistics.java | Statistics.columnNullCount | public Statistics columnNullCount(String columnName, Long nullCount) {
this.columnStats
.computeIfAbsent(columnName, column -> new HashMap<>())
.put(NULL_COUNT, String.valueOf(nullCount));
return this;
} | java | public Statistics columnNullCount(String columnName, Long nullCount) {
this.columnStats
.computeIfAbsent(columnName, column -> new HashMap<>())
.put(NULL_COUNT, String.valueOf(nullCount));
return this;
} | [
"public",
"Statistics",
"columnNullCount",
"(",
"String",
"columnName",
",",
"Long",
"nullCount",
")",
"{",
"this",
".",
"columnStats",
".",
"computeIfAbsent",
"(",
"columnName",
",",
"column",
"->",
"new",
"HashMap",
"<>",
"(",
")",
")",
".",
"put",
"(",
... | Sets the number of null values statistic for the given column. | [
"Sets",
"the",
"number",
"of",
"null",
"values",
"statistic",
"for",
"the",
"given",
"column",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/descriptors/Statistics.java#L101-L106 | train | Sets the null count statistics for the specified column. | [
30522,
2270,
6747,
5930,
11231,
3363,
3597,
16671,
1006,
5164,
5930,
18442,
1010,
2146,
19701,
3597,
16671,
1007,
1063,
2023,
1012,
7753,
29336,
2015,
1012,
24134,
10128,
7875,
5054,
2102,
1006,
5930,
18442,
1010,
5930,
1011,
1028,
2047,
23... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | http-url/src/main/java/com/networknt/url/HttpURL.java | HttpURL.toURI | public URI toURI() {
String url = toString();
try {
return new URI(url);
} catch (URISyntaxException e) {
throw new RuntimeException("Cannot convert to URI: " + url, e);
}
} | java | public URI toURI() {
String url = toString();
try {
return new URI(url);
} catch (URISyntaxException e) {
throw new RuntimeException("Cannot convert to URI: " + url, e);
}
} | [
"public",
"URI",
"toURI",
"(",
")",
"{",
"String",
"url",
"=",
"toString",
"(",
")",
";",
"try",
"{",
"return",
"new",
"URI",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Ca... | Converts this HttpURL to a {@link URI}, making sure
appropriate characters are escaped properly.
@return a URI
@since 1.7.0
@throws RuntimeException when URL is malformed | [
"Converts",
"this",
"HttpURL",
"to",
"a",
"{"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/http-url/src/main/java/com/networknt/url/HttpURL.java#L299-L306 | train | Returns the URI of the record. | [
30522,
2270,
24471,
2072,
2778,
2072,
1006,
1007,
1063,
5164,
24471,
2140,
1027,
2000,
3367,
4892,
1006,
1007,
1025,
3046,
1063,
2709,
2047,
24471,
2072,
1006,
24471,
2140,
1007,
1025,
1065,
4608,
1006,
24471,
2483,
6038,
2696,
2595,
10288,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.thenAcceptAsyncIfNotDone | public static <IN> CompletableFuture<Void> thenAcceptAsyncIfNotDone(
CompletableFuture<IN> completableFuture,
Executor executor,
Consumer<? super IN> consumer) {
return completableFuture.isDone() ?
completableFuture.thenAccept(consumer) :
completableFuture.thenAcceptAsync(consumer, executor);
} | java | public static <IN> CompletableFuture<Void> thenAcceptAsyncIfNotDone(
CompletableFuture<IN> completableFuture,
Executor executor,
Consumer<? super IN> consumer) {
return completableFuture.isDone() ?
completableFuture.thenAccept(consumer) :
completableFuture.thenAcceptAsync(consumer, executor);
} | [
"public",
"static",
"<",
"IN",
">",
"CompletableFuture",
"<",
"Void",
">",
"thenAcceptAsyncIfNotDone",
"(",
"CompletableFuture",
"<",
"IN",
">",
"completableFuture",
",",
"Executor",
"executor",
",",
"Consumer",
"<",
"?",
"super",
"IN",
">",
"consumer",
")",
"... | This function takes a {@link CompletableFuture} and a consumer to accept the result of this future. If the input
future is already done, this function returns {@link CompletableFuture#thenAccept(Consumer)}. Otherwise, the
return value is {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)} with the given executor.
@param completableFuture the completable future for which we want to call #thenAccept.
@param executor the executor to run the thenAccept function if the future is not yet done.
@param consumer the consumer function to call when the future is completed.
@param <IN> type of the input future.
@return the new completion stage. | [
"This",
"function",
"takes",
"a",
"{",
"@link",
"CompletableFuture",
"}",
"and",
"a",
"consumer",
"to",
"accept",
"the",
"result",
"of",
"this",
"future",
".",
"If",
"the",
"input",
"future",
"is",
"already",
"done",
"this",
"function",
"returns",
"{",
"@l... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java#L899-L906 | train | A CompletableFuture that is asynchronously accepted by the given CompletableFuture if the CompletableFuture is done. | [
30522,
2270,
10763,
1026,
1999,
1028,
4012,
10814,
10880,
11263,
11244,
1026,
11675,
1028,
2059,
6305,
3401,
22799,
6508,
12273,
10128,
17048,
5280,
2063,
1006,
4012,
10814,
10880,
11263,
11244,
1026,
1999,
1028,
4012,
10814,
10880,
11263,
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... |
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.isNull | public boolean isNull(int index) {
Object value = opt(index);
return value == null || value == JSONObject.NULL;
} | java | public boolean isNull(int index) {
Object value = opt(index);
return value == null || value == JSONObject.NULL;
} | [
"public",
"boolean",
"isNull",
"(",
"int",
"index",
")",
"{",
"Object",
"value",
"=",
"opt",
"(",
"index",
")",
";",
"return",
"value",
"==",
"null",
"||",
"value",
"==",
"JSONObject",
".",
"NULL",
";",
"}"
] | Returns true if this array has no value at {@code index}, or if its value is the
{@code null} reference or {@link JSONObject#NULL}.
@param index the index to set the value to
@return true if this array has no value at {@code index} | [
"Returns",
"true",
"if",
"this",
"array",
"has",
"no",
"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#L269-L272 | train | Returns true if the value at the given index is null. | [
30522,
2270,
22017,
20898,
3475,
18083,
1006,
20014,
5950,
1007,
1063,
4874,
3643,
1027,
23569,
1006,
5950,
1007,
1025,
2709,
3643,
1027,
1027,
19701,
30524,
3385,
16429,
20614,
1012,
19701,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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/BinaryIndexedSortable.java | BinaryIndexedSortable.checkNextIndexOffset | protected boolean checkNextIndexOffset() {
if (this.currentSortIndexOffset > this.lastIndexEntryOffset) {
MemorySegment returnSegment = nextMemorySegment();
if (returnSegment != null) {
this.currentSortIndexSegment = returnSegment;
this.sortIndex.add(this.currentSortIndexSegment);
this.currentSortIndexOffset = 0;
} else {
return false;
}
}
return true;
} | java | protected boolean checkNextIndexOffset() {
if (this.currentSortIndexOffset > this.lastIndexEntryOffset) {
MemorySegment returnSegment = nextMemorySegment();
if (returnSegment != null) {
this.currentSortIndexSegment = returnSegment;
this.sortIndex.add(this.currentSortIndexSegment);
this.currentSortIndexOffset = 0;
} else {
return false;
}
}
return true;
} | [
"protected",
"boolean",
"checkNextIndexOffset",
"(",
")",
"{",
"if",
"(",
"this",
".",
"currentSortIndexOffset",
">",
"this",
".",
"lastIndexEntryOffset",
")",
"{",
"MemorySegment",
"returnSegment",
"=",
"nextMemorySegment",
"(",
")",
";",
"if",
"(",
"returnSegmen... | check if we need request next index memory. | [
"check",
"if",
"we",
"need",
"request",
"next",
"index",
"memory",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/BinaryIndexedSortable.java#L121-L133 | train | Check if the next index entry is available. | [
30522,
5123,
22017,
20898,
4638,
2638,
18413,
22254,
10288,
27475,
3388,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
14731,
11589,
22254,
10288,
27475,
3388,
1028,
2023,
1012,
2197,
22254,
10288,
4765,
2854,
27475,
3388,
1007,
1063,
3638,
3366,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/corpus/document/sentence/Sentence.java | Sentence.toSimpleWordList | public List<Word> toSimpleWordList()
{
List<Word> wordList = new LinkedList<Word>();
for (IWord word : this.wordList)
{
if (word instanceof CompoundWord)
{
wordList.addAll(((CompoundWord) word).innerList);
}
else
{
wordList.add((Word) word);
}
}
return wordList;
} | java | public List<Word> toSimpleWordList()
{
List<Word> wordList = new LinkedList<Word>();
for (IWord word : this.wordList)
{
if (word instanceof CompoundWord)
{
wordList.addAll(((CompoundWord) word).innerList);
}
else
{
wordList.add((Word) word);
}
}
return wordList;
} | [
"public",
"List",
"<",
"Word",
">",
"toSimpleWordList",
"(",
")",
"{",
"List",
"<",
"Word",
">",
"wordList",
"=",
"new",
"LinkedList",
"<",
"Word",
">",
"(",
")",
";",
"for",
"(",
"IWord",
"word",
":",
"this",
".",
"wordList",
")",
"{",
"if",
"(",
... | 转换为简单单词列表
@return | [
"转换为简单单词列表"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/corpus/document/sentence/Sentence.java#L395-L411 | train | To simple word list. | [
30522,
2270,
2862,
1026,
2773,
1028,
2000,
5332,
23344,
18351,
9863,
1006,
1007,
1063,
2862,
1026,
2773,
1028,
2773,
9863,
1027,
2047,
5799,
9863,
1026,
2773,
1028,
1006,
1007,
1025,
2005,
1006,
1045,
18351,
2773,
1024,
2023,
1012,
2773,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer.java | FlinkKafkaProducer.createTransactionalProducer | private FlinkKafkaInternalProducer<byte[], byte[]> createTransactionalProducer() throws FlinkKafkaException {
String transactionalId = availableTransactionalIds.poll();
if (transactionalId == null) {
throw new FlinkKafkaException(
FlinkKafkaErrorCode.PRODUCERS_POOL_EMPTY,
"Too many ongoing snapshots. Increase kafka producers pool size or decrease number of concurrent checkpoints.");
}
FlinkKafkaInternalProducer<byte[], byte[]> producer = initTransactionalProducer(transactionalId, true);
producer.initTransactions();
return producer;
} | java | private FlinkKafkaInternalProducer<byte[], byte[]> createTransactionalProducer() throws FlinkKafkaException {
String transactionalId = availableTransactionalIds.poll();
if (transactionalId == null) {
throw new FlinkKafkaException(
FlinkKafkaErrorCode.PRODUCERS_POOL_EMPTY,
"Too many ongoing snapshots. Increase kafka producers pool size or decrease number of concurrent checkpoints.");
}
FlinkKafkaInternalProducer<byte[], byte[]> producer = initTransactionalProducer(transactionalId, true);
producer.initTransactions();
return producer;
} | [
"private",
"FlinkKafkaInternalProducer",
"<",
"byte",
"[",
"]",
",",
"byte",
"[",
"]",
">",
"createTransactionalProducer",
"(",
")",
"throws",
"FlinkKafkaException",
"{",
"String",
"transactionalId",
"=",
"availableTransactionalIds",
".",
"poll",
"(",
")",
";",
"i... | For each checkpoint we create new {@link FlinkKafkaInternalProducer} so that new transactions will not clash
with transactions created during previous checkpoints ({@code producer.initTransactions()} assures that we
obtain new producerId and epoch counters). | [
"For",
"each",
"checkpoint",
"we",
"create",
"new",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer.java#L924-L934 | train | Creates a transactional producer. | [
30522,
2797,
13109,
19839,
2912,
24316,
22325,
11795,
2389,
21572,
8566,
17119,
1026,
24880,
1031,
1033,
1010,
24880,
1031,
1033,
1028,
3443,
6494,
3619,
18908,
19301,
21572,
8566,
17119,
1006,
1007,
11618,
13109,
19839,
2912,
24316,
6679,
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/flink | flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java | TupleComparator.hash | @SuppressWarnings("unchecked")
@Override
public int hash(T value) {
int i = 0;
try {
int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
for (i = 1; i < this.keyPositions.length; i++) {
code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
}
return code;
}
catch (NullFieldException nfex) {
throw new NullKeyFieldException(nfex);
}
catch (IndexOutOfBoundsException iobex) {
throw new KeyFieldOutOfBoundsException(keyPositions[i]);
}
} | java | @SuppressWarnings("unchecked")
@Override
public int hash(T value) {
int i = 0;
try {
int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
for (i = 1; i < this.keyPositions.length; i++) {
code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
}
return code;
}
catch (NullFieldException nfex) {
throw new NullKeyFieldException(nfex);
}
catch (IndexOutOfBoundsException iobex) {
throw new KeyFieldOutOfBoundsException(keyPositions[i]);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"int",
"hash",
"(",
"T",
"value",
")",
"{",
"int",
"i",
"=",
"0",
";",
"try",
"{",
"int",
"code",
"=",
"this",
".",
"comparators",
"[",
"0",
"]",
".",
"hash",
"(",
"valu... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java#L47-L65 | train | This method is used to compute the hash code for the given value. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
1030,
2058,
15637,
2270,
20014,
23325,
1006,
1056,
3643,
1007,
1063,
20014,
1045,
1027,
1014,
1025,
3046,
1063,
20014,
3642,
1027,
2023,
1012,
4012,
28689,
659... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-http2/src/main/java/io/netty/handler/codec/http2/HpackEncoder.java | HpackEncoder.encodeStringLiteral | private void encodeStringLiteral(ByteBuf out, CharSequence string) {
int huffmanLength = hpackHuffmanEncoder.getEncodedLength(string);
if (huffmanLength < string.length()) {
encodeInteger(out, 0x80, 7, huffmanLength);
hpackHuffmanEncoder.encode(out, string);
} else {
encodeInteger(out, 0x00, 7, string.length());
if (string instanceof AsciiString) {
// Fast-path
AsciiString asciiString = (AsciiString) string;
out.writeBytes(asciiString.array(), asciiString.arrayOffset(), asciiString.length());
} else {
// Only ASCII is allowed in http2 headers, so its fine to use this.
// https://tools.ietf.org/html/rfc7540#section-8.1.2
out.writeCharSequence(string, CharsetUtil.ISO_8859_1);
}
}
} | java | private void encodeStringLiteral(ByteBuf out, CharSequence string) {
int huffmanLength = hpackHuffmanEncoder.getEncodedLength(string);
if (huffmanLength < string.length()) {
encodeInteger(out, 0x80, 7, huffmanLength);
hpackHuffmanEncoder.encode(out, string);
} else {
encodeInteger(out, 0x00, 7, string.length());
if (string instanceof AsciiString) {
// Fast-path
AsciiString asciiString = (AsciiString) string;
out.writeBytes(asciiString.array(), asciiString.arrayOffset(), asciiString.length());
} else {
// Only ASCII is allowed in http2 headers, so its fine to use this.
// https://tools.ietf.org/html/rfc7540#section-8.1.2
out.writeCharSequence(string, CharsetUtil.ISO_8859_1);
}
}
} | [
"private",
"void",
"encodeStringLiteral",
"(",
"ByteBuf",
"out",
",",
"CharSequence",
"string",
")",
"{",
"int",
"huffmanLength",
"=",
"hpackHuffmanEncoder",
".",
"getEncodedLength",
"(",
"string",
")",
";",
"if",
"(",
"huffmanLength",
"<",
"string",
".",
"lengt... | Encode string literal according to Section 5.2. | [
"Encode",
"string",
"literal",
"according",
"to",
"Section",
"5",
".",
"2",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackEncoder.java#L252-L269 | train | Encode a string in UTF - 8 format. | [
30522,
2797,
11675,
4372,
23237,
18886,
3070,
22779,
7941,
1006,
24880,
8569,
2546,
2041,
1010,
25869,
3366,
4226,
5897,
5164,
1007,
1063,
20014,
21301,
2386,
7770,
13512,
2232,
1027,
6522,
8684,
6979,
4246,
2386,
2368,
16044,
2099,
1012,
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... |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/InternalTimeServiceManager.java | InternalTimeServiceManager.snapshotStateForKeyGroup | public void snapshotStateForKeyGroup(DataOutputView stream, int keyGroupIdx) throws IOException {
Preconditions.checkState(useLegacySynchronousSnapshots);
InternalTimerServiceSerializationProxy<K> serializationProxy =
new InternalTimerServiceSerializationProxy<>(this, keyGroupIdx);
serializationProxy.write(stream);
} | java | public void snapshotStateForKeyGroup(DataOutputView stream, int keyGroupIdx) throws IOException {
Preconditions.checkState(useLegacySynchronousSnapshots);
InternalTimerServiceSerializationProxy<K> serializationProxy =
new InternalTimerServiceSerializationProxy<>(this, keyGroupIdx);
serializationProxy.write(stream);
} | [
"public",
"void",
"snapshotStateForKeyGroup",
"(",
"DataOutputView",
"stream",
",",
"int",
"keyGroupIdx",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"useLegacySynchronousSnapshots",
")",
";",
"InternalTimerServiceSerializationProxy",
"<",
... | //////////////// Fault Tolerance Methods /////////////////// | [
"////////////////",
"Fault",
"Tolerance",
"Methods",
"///////////////////"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/InternalTimeServiceManager.java#L134-L140 | train | Writes the state of the timer service to the given output view. | [
30522,
2270,
11675,
20057,
12326,
9153,
2618,
29278,
14839,
17058,
1006,
2951,
5833,
18780,
8584,
5460,
1010,
20014,
3145,
17058,
3593,
2595,
1007,
11618,
22834,
10288,
24422,
1063,
3653,
8663,
20562,
2015,
1012,
14148,
12259,
1006,
2224,
231... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollChannelConfig.java | EpollChannelConfig.getEpollMode | public EpollMode getEpollMode() {
return ((AbstractEpollChannel) channel).isFlagSet(Native.EPOLLET)
? EpollMode.EDGE_TRIGGERED : EpollMode.LEVEL_TRIGGERED;
} | java | public EpollMode getEpollMode() {
return ((AbstractEpollChannel) channel).isFlagSet(Native.EPOLLET)
? EpollMode.EDGE_TRIGGERED : EpollMode.LEVEL_TRIGGERED;
} | [
"public",
"EpollMode",
"getEpollMode",
"(",
")",
"{",
"return",
"(",
"(",
"AbstractEpollChannel",
")",
"channel",
")",
".",
"isFlagSet",
"(",
"Native",
".",
"EPOLLET",
")",
"?",
"EpollMode",
".",
"EDGE_TRIGGERED",
":",
"EpollMode",
".",
"LEVEL_TRIGGERED",
";",... | Return the {@link EpollMode} used. Default is
{@link EpollMode#EDGE_TRIGGERED}. If you want to use {@link #isAutoRead()} {@code false} or
{@link #getMaxMessagesPerRead()} and have an accurate behaviour you should use
{@link EpollMode#LEVEL_TRIGGERED}. | [
"Return",
"the",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollChannelConfig.java#L136-L139 | train | Get the EpollMode for this channel | [
30522,
2270,
4958,
14511,
5302,
3207,
2131,
13699,
14511,
5302,
3207,
1006,
1007,
1063,
2709,
1006,
1006,
10061,
13699,
14511,
26058,
1007,
3149,
1007,
1012,
2003,
10258,
26454,
3388,
1006,
3128,
1012,
4958,
14511,
3388,
1007,
1029,
4958,
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/AbstractVectorModel.java | AbstractVectorModel.similarity | public float similarity(K what, K with)
{
Vector vectorWhat = storage.get(what);
if (vectorWhat == null)
{
return -1f;
}
Vector vectorWith = storage.get(with);
if (vectorWith == null)
{
return -1f;
}
return vectorWhat.cosineForUnitVector(vectorWith);
} | java | public float similarity(K what, K with)
{
Vector vectorWhat = storage.get(what);
if (vectorWhat == null)
{
return -1f;
}
Vector vectorWith = storage.get(with);
if (vectorWith == null)
{
return -1f;
}
return vectorWhat.cosineForUnitVector(vectorWith);
} | [
"public",
"float",
"similarity",
"(",
"K",
"what",
",",
"K",
"with",
")",
"{",
"Vector",
"vectorWhat",
"=",
"storage",
".",
"get",
"(",
"what",
")",
";",
"if",
"(",
"vectorWhat",
"==",
"null",
")",
"{",
"return",
"-",
"1f",
";",
"}",
"Vector",
"vec... | 余弦相似度
@param what 一个词
@param with 另一个词
@return 余弦相似度 | [
"余弦相似度"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/mining/word2vec/AbstractVectorModel.java#L56-L69 | train | Gets the similarity of two terms of a set of terms. | [
30522,
2270,
14257,
14402,
1006,
1047,
2054,
1010,
1047,
2007,
1007,
1063,
9207,
9207,
2860,
12707,
1027,
5527,
1012,
2131,
1006,
2054,
1007,
1025,
2065,
1006,
9207,
2860,
12707,
1027,
1027,
19701,
1007,
1063,
2709,
1011,
1015,
2546,
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... |
apache/flink | flink-core/src/main/java/org/apache/flink/util/PropertiesUtil.java | PropertiesUtil.getInt | public static int getInt(Properties config, String key, int defaultValue) {
String val = config.getProperty(key);
if (val == null) {
return defaultValue;
} else {
try {
return Integer.parseInt(val);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Value for configuration key='" + key + "' is not set correctly. " +
"Entered value='" + val + "'. Default value='" + defaultValue + "'");
}
}
} | java | public static int getInt(Properties config, String key, int defaultValue) {
String val = config.getProperty(key);
if (val == null) {
return defaultValue;
} else {
try {
return Integer.parseInt(val);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Value for configuration key='" + key + "' is not set correctly. " +
"Entered value='" + val + "'. Default value='" + defaultValue + "'");
}
}
} | [
"public",
"static",
"int",
"getInt",
"(",
"Properties",
"config",
",",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"String",
"val",
"=",
"config",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"return",
... | Get integer from properties.
This method throws an exception if the integer is not valid.
@param config Properties
@param key key in Properties
@param defaultValue default value if value is not set
@return default or value of key | [
"Get",
"integer",
"from",
"properties",
".",
"This",
"method",
"throws",
"an",
"exception",
"if",
"the",
"integer",
"is",
"not",
"valid",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/PropertiesUtil.java#L38-L50 | train | Get an int value from a properties object. | [
30522,
2270,
10763,
20014,
2131,
18447,
1006,
5144,
9530,
8873,
2290,
1010,
5164,
3145,
1010,
20014,
12398,
10175,
5657,
1007,
1063,
5164,
11748,
1027,
9530,
8873,
2290,
1012,
2131,
21572,
4842,
3723,
1006,
3145,
1007,
1025,
2065,
1006,
117... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraphGenerator.java | StreamGraphGenerator.transformOneInputTransform | private <IN, OUT> Collection<Integer> transformOneInputTransform(OneInputTransformation<IN, OUT> transform) {
Collection<Integer> inputIds = transform(transform.getInput());
// the recursive call might have already transformed this
if (alreadyTransformed.containsKey(transform)) {
return alreadyTransformed.get(transform);
}
String slotSharingGroup = determineSlotSharingGroup(transform.getSlotSharingGroup(), inputIds);
streamGraph.addOperator(transform.getId(),
slotSharingGroup,
transform.getCoLocationGroupKey(),
transform.getOperator(),
transform.getInputType(),
transform.getOutputType(),
transform.getName());
if (transform.getStateKeySelector() != null) {
TypeSerializer<?> keySerializer = transform.getStateKeyType().createSerializer(env.getConfig());
streamGraph.setOneInputStateKey(transform.getId(), transform.getStateKeySelector(), keySerializer);
}
streamGraph.setParallelism(transform.getId(), transform.getParallelism());
streamGraph.setMaxParallelism(transform.getId(), transform.getMaxParallelism());
for (Integer inputId: inputIds) {
streamGraph.addEdge(inputId, transform.getId(), 0);
}
return Collections.singleton(transform.getId());
} | java | private <IN, OUT> Collection<Integer> transformOneInputTransform(OneInputTransformation<IN, OUT> transform) {
Collection<Integer> inputIds = transform(transform.getInput());
// the recursive call might have already transformed this
if (alreadyTransformed.containsKey(transform)) {
return alreadyTransformed.get(transform);
}
String slotSharingGroup = determineSlotSharingGroup(transform.getSlotSharingGroup(), inputIds);
streamGraph.addOperator(transform.getId(),
slotSharingGroup,
transform.getCoLocationGroupKey(),
transform.getOperator(),
transform.getInputType(),
transform.getOutputType(),
transform.getName());
if (transform.getStateKeySelector() != null) {
TypeSerializer<?> keySerializer = transform.getStateKeyType().createSerializer(env.getConfig());
streamGraph.setOneInputStateKey(transform.getId(), transform.getStateKeySelector(), keySerializer);
}
streamGraph.setParallelism(transform.getId(), transform.getParallelism());
streamGraph.setMaxParallelism(transform.getId(), transform.getMaxParallelism());
for (Integer inputId: inputIds) {
streamGraph.addEdge(inputId, transform.getId(), 0);
}
return Collections.singleton(transform.getId());
} | [
"private",
"<",
"IN",
",",
"OUT",
">",
"Collection",
"<",
"Integer",
">",
"transformOneInputTransform",
"(",
"OneInputTransformation",
"<",
"IN",
",",
"OUT",
">",
"transform",
")",
"{",
"Collection",
"<",
"Integer",
">",
"inputIds",
"=",
"transform",
"(",
"t... | Transforms a {@code OneInputTransformation}.
<p>This recursively transforms the inputs, creates a new {@code StreamNode} in the graph and
wired the inputs to this new node. | [
"Transforms",
"a",
"{",
"@code",
"OneInputTransformation",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraphGenerator.java#L537-L569 | train | Transform one input transform. | [
30522,
2797,
1026,
1999,
1010,
2041,
1028,
3074,
1026,
16109,
1028,
10938,
5643,
2378,
18780,
6494,
3619,
14192,
1006,
2028,
2378,
18780,
6494,
3619,
14192,
3370,
1026,
1999,
1010,
2041,
1028,
10938,
1007,
1063,
3074,
1026,
16109,
1028,
795... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DataSinkTask.java | DataSinkTask.initInputReaders | @SuppressWarnings("unchecked")
private void initInputReaders() throws Exception {
int numGates = 0;
// ---------------- create the input readers ---------------------
// in case where a logical input unions multiple physical inputs, create a union reader
final int groupSize = this.config.getGroupSize(0);
numGates += groupSize;
if (groupSize == 1) {
// non-union case
inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
getEnvironment().getInputGate(0),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else if (groupSize > 1){
// union case
inputReader = new MutableRecordReader<IOReadableWritable>(
new UnionInputGate(getEnvironment().getAllInputGates()),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else {
throw new Exception("Illegal input group size in task configuration: " + groupSize);
}
this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
@SuppressWarnings({ "rawtypes" })
final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
this.reader = (MutableObjectIterator<IT>)iter;
// final sanity check
if (numGates != this.config.getNumInputs()) {
throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
}
} | java | @SuppressWarnings("unchecked")
private void initInputReaders() throws Exception {
int numGates = 0;
// ---------------- create the input readers ---------------------
// in case where a logical input unions multiple physical inputs, create a union reader
final int groupSize = this.config.getGroupSize(0);
numGates += groupSize;
if (groupSize == 1) {
// non-union case
inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
getEnvironment().getInputGate(0),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else if (groupSize > 1){
// union case
inputReader = new MutableRecordReader<IOReadableWritable>(
new UnionInputGate(getEnvironment().getAllInputGates()),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else {
throw new Exception("Illegal input group size in task configuration: " + groupSize);
}
this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
@SuppressWarnings({ "rawtypes" })
final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
this.reader = (MutableObjectIterator<IT>)iter;
// final sanity check
if (numGates != this.config.getNumInputs()) {
throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"initInputReaders",
"(",
")",
"throws",
"Exception",
"{",
"int",
"numGates",
"=",
"0",
";",
"// ---------------- create the input readers ---------------------",
"// in case where a logical input unions mul... | Initializes the input readers of the DataSinkTask.
@throws RuntimeException
Thrown in case of invalid task input configuration. | [
"Initializes",
"the",
"input",
"readers",
"of",
"the",
"DataSinkTask",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/DataSinkTask.java#L360-L390 | train | Initialize the input readers. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2797,
11675,
1999,
25090,
16275,
4904,
16416,
13375,
1006,
1007,
11618,
6453,
1063,
20014,
16371,
24798,
8520,
1027,
1014,
1025,
1013,
1013,
1011,
1011,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/messages/checkpoints/CheckpointStatistics.java | CheckpointStatistics.generateCheckpointStatistics | public static CheckpointStatistics generateCheckpointStatistics(AbstractCheckpointStats checkpointStats, boolean includeTaskCheckpointStatistics) {
Preconditions.checkNotNull(checkpointStats);
Map<JobVertexID, TaskCheckpointStatistics> checkpointStatisticsPerTask;
if (includeTaskCheckpointStatistics) {
Collection<TaskStateStats> taskStateStats = checkpointStats.getAllTaskStateStats();
checkpointStatisticsPerTask = new HashMap<>(taskStateStats.size());
for (TaskStateStats taskStateStat : taskStateStats) {
checkpointStatisticsPerTask.put(
taskStateStat.getJobVertexId(),
new TaskCheckpointStatistics(
checkpointStats.getCheckpointId(),
checkpointStats.getStatus(),
taskStateStat.getLatestAckTimestamp(),
taskStateStat.getStateSize(),
taskStateStat.getEndToEndDuration(checkpointStats.getTriggerTimestamp()),
taskStateStat.getAlignmentBuffered(),
taskStateStat.getNumberOfSubtasks(),
taskStateStat.getNumberOfAcknowledgedSubtasks()));
}
} else {
checkpointStatisticsPerTask = Collections.emptyMap();
}
if (checkpointStats instanceof CompletedCheckpointStats) {
final CompletedCheckpointStats completedCheckpointStats = ((CompletedCheckpointStats) checkpointStats);
return new CheckpointStatistics.CompletedCheckpointStatistics(
completedCheckpointStats.getCheckpointId(),
completedCheckpointStats.getStatus(),
completedCheckpointStats.getProperties().isSavepoint(),
completedCheckpointStats.getTriggerTimestamp(),
completedCheckpointStats.getLatestAckTimestamp(),
completedCheckpointStats.getStateSize(),
completedCheckpointStats.getEndToEndDuration(),
completedCheckpointStats.getAlignmentBuffered(),
completedCheckpointStats.getNumberOfSubtasks(),
completedCheckpointStats.getNumberOfAcknowledgedSubtasks(),
checkpointStatisticsPerTask,
completedCheckpointStats.getExternalPath(),
completedCheckpointStats.isDiscarded());
} else if (checkpointStats instanceof FailedCheckpointStats) {
final FailedCheckpointStats failedCheckpointStats = ((FailedCheckpointStats) checkpointStats);
return new CheckpointStatistics.FailedCheckpointStatistics(
failedCheckpointStats.getCheckpointId(),
failedCheckpointStats.getStatus(),
failedCheckpointStats.getProperties().isSavepoint(),
failedCheckpointStats.getTriggerTimestamp(),
failedCheckpointStats.getLatestAckTimestamp(),
failedCheckpointStats.getStateSize(),
failedCheckpointStats.getEndToEndDuration(),
failedCheckpointStats.getAlignmentBuffered(),
failedCheckpointStats.getNumberOfSubtasks(),
failedCheckpointStats.getNumberOfAcknowledgedSubtasks(),
checkpointStatisticsPerTask,
failedCheckpointStats.getFailureTimestamp(),
failedCheckpointStats.getFailureMessage());
} else if (checkpointStats instanceof PendingCheckpointStats) {
final PendingCheckpointStats pendingCheckpointStats = ((PendingCheckpointStats) checkpointStats);
return new CheckpointStatistics.PendingCheckpointStatistics(
pendingCheckpointStats.getCheckpointId(),
pendingCheckpointStats.getStatus(),
pendingCheckpointStats.getProperties().isSavepoint(),
pendingCheckpointStats.getTriggerTimestamp(),
pendingCheckpointStats.getLatestAckTimestamp(),
pendingCheckpointStats.getStateSize(),
pendingCheckpointStats.getEndToEndDuration(),
pendingCheckpointStats.getAlignmentBuffered(),
pendingCheckpointStats.getNumberOfSubtasks(),
pendingCheckpointStats.getNumberOfAcknowledgedSubtasks(),
checkpointStatisticsPerTask
);
} else {
throw new IllegalArgumentException("Given checkpoint stats object of type "
+ checkpointStats.getClass().getName() + " cannot be converted.");
}
} | java | public static CheckpointStatistics generateCheckpointStatistics(AbstractCheckpointStats checkpointStats, boolean includeTaskCheckpointStatistics) {
Preconditions.checkNotNull(checkpointStats);
Map<JobVertexID, TaskCheckpointStatistics> checkpointStatisticsPerTask;
if (includeTaskCheckpointStatistics) {
Collection<TaskStateStats> taskStateStats = checkpointStats.getAllTaskStateStats();
checkpointStatisticsPerTask = new HashMap<>(taskStateStats.size());
for (TaskStateStats taskStateStat : taskStateStats) {
checkpointStatisticsPerTask.put(
taskStateStat.getJobVertexId(),
new TaskCheckpointStatistics(
checkpointStats.getCheckpointId(),
checkpointStats.getStatus(),
taskStateStat.getLatestAckTimestamp(),
taskStateStat.getStateSize(),
taskStateStat.getEndToEndDuration(checkpointStats.getTriggerTimestamp()),
taskStateStat.getAlignmentBuffered(),
taskStateStat.getNumberOfSubtasks(),
taskStateStat.getNumberOfAcknowledgedSubtasks()));
}
} else {
checkpointStatisticsPerTask = Collections.emptyMap();
}
if (checkpointStats instanceof CompletedCheckpointStats) {
final CompletedCheckpointStats completedCheckpointStats = ((CompletedCheckpointStats) checkpointStats);
return new CheckpointStatistics.CompletedCheckpointStatistics(
completedCheckpointStats.getCheckpointId(),
completedCheckpointStats.getStatus(),
completedCheckpointStats.getProperties().isSavepoint(),
completedCheckpointStats.getTriggerTimestamp(),
completedCheckpointStats.getLatestAckTimestamp(),
completedCheckpointStats.getStateSize(),
completedCheckpointStats.getEndToEndDuration(),
completedCheckpointStats.getAlignmentBuffered(),
completedCheckpointStats.getNumberOfSubtasks(),
completedCheckpointStats.getNumberOfAcknowledgedSubtasks(),
checkpointStatisticsPerTask,
completedCheckpointStats.getExternalPath(),
completedCheckpointStats.isDiscarded());
} else if (checkpointStats instanceof FailedCheckpointStats) {
final FailedCheckpointStats failedCheckpointStats = ((FailedCheckpointStats) checkpointStats);
return new CheckpointStatistics.FailedCheckpointStatistics(
failedCheckpointStats.getCheckpointId(),
failedCheckpointStats.getStatus(),
failedCheckpointStats.getProperties().isSavepoint(),
failedCheckpointStats.getTriggerTimestamp(),
failedCheckpointStats.getLatestAckTimestamp(),
failedCheckpointStats.getStateSize(),
failedCheckpointStats.getEndToEndDuration(),
failedCheckpointStats.getAlignmentBuffered(),
failedCheckpointStats.getNumberOfSubtasks(),
failedCheckpointStats.getNumberOfAcknowledgedSubtasks(),
checkpointStatisticsPerTask,
failedCheckpointStats.getFailureTimestamp(),
failedCheckpointStats.getFailureMessage());
} else if (checkpointStats instanceof PendingCheckpointStats) {
final PendingCheckpointStats pendingCheckpointStats = ((PendingCheckpointStats) checkpointStats);
return new CheckpointStatistics.PendingCheckpointStatistics(
pendingCheckpointStats.getCheckpointId(),
pendingCheckpointStats.getStatus(),
pendingCheckpointStats.getProperties().isSavepoint(),
pendingCheckpointStats.getTriggerTimestamp(),
pendingCheckpointStats.getLatestAckTimestamp(),
pendingCheckpointStats.getStateSize(),
pendingCheckpointStats.getEndToEndDuration(),
pendingCheckpointStats.getAlignmentBuffered(),
pendingCheckpointStats.getNumberOfSubtasks(),
pendingCheckpointStats.getNumberOfAcknowledgedSubtasks(),
checkpointStatisticsPerTask
);
} else {
throw new IllegalArgumentException("Given checkpoint stats object of type "
+ checkpointStats.getClass().getName() + " cannot be converted.");
}
} | [
"public",
"static",
"CheckpointStatistics",
"generateCheckpointStatistics",
"(",
"AbstractCheckpointStats",
"checkpointStats",
",",
"boolean",
"includeTaskCheckpointStatistics",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"checkpointStats",
")",
";",
"Map",
"<",
"J... | ------------------------------------------------------------------------- | [
"-------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/checkpoints/CheckpointStatistics.java#L216-L297 | train | Generates a checkpoint statistics from the given checkpoint stats. | [
30522,
2270,
10763,
26520,
9153,
16774,
6558,
9699,
5403,
3600,
26521,
29336,
6553,
2015,
1006,
10061,
5403,
3600,
26521,
29336,
2015,
26520,
9153,
3215,
1010,
22017,
20898,
2421,
10230,
2243,
5403,
3600,
26521,
29336,
6553,
2015,
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-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java | AbstractUdfStreamOperator.setup | @Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output) {
super.setup(containingTask, config, output);
FunctionUtils.setFunctionRuntimeContext(userFunction, getRuntimeContext());
} | java | @Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output) {
super.setup(containingTask, config, output);
FunctionUtils.setFunctionRuntimeContext(userFunction, getRuntimeContext());
} | [
"@",
"Override",
"public",
"void",
"setup",
"(",
"StreamTask",
"<",
"?",
",",
"?",
">",
"containingTask",
",",
"StreamConfig",
"config",
",",
"Output",
"<",
"StreamRecord",
"<",
"OUT",
">",
">",
"output",
")",
"{",
"super",
".",
"setup",
"(",
"containing... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L80-L85 | train | Override setup to set the runtime context for the user function. | [
30522,
1030,
2058,
15637,
2270,
11675,
16437,
1006,
5460,
10230,
2243,
1026,
1029,
1010,
1029,
1028,
4820,
10230,
2243,
1010,
5460,
8663,
8873,
2290,
9530,
8873,
2290,
1010,
6434,
1026,
5460,
2890,
27108,
2094,
1026,
2041,
1028,
1028,
6434,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/TaskEventDispatcher.java | TaskEventDispatcher.unregisterPartition | public void unregisterPartition(ResultPartitionID partitionId) {
checkNotNull(partitionId);
synchronized (registeredHandlers) {
LOG.debug("unregistering {}", partitionId);
// NOTE: tolerate un-registration of non-registered task (unregister is always called
// in the cleanup phase of a task even if it never came to the registration - see
// Task.java)
registeredHandlers.remove(partitionId);
}
} | java | public void unregisterPartition(ResultPartitionID partitionId) {
checkNotNull(partitionId);
synchronized (registeredHandlers) {
LOG.debug("unregistering {}", partitionId);
// NOTE: tolerate un-registration of non-registered task (unregister is always called
// in the cleanup phase of a task even if it never came to the registration - see
// Task.java)
registeredHandlers.remove(partitionId);
}
} | [
"public",
"void",
"unregisterPartition",
"(",
"ResultPartitionID",
"partitionId",
")",
"{",
"checkNotNull",
"(",
"partitionId",
")",
";",
"synchronized",
"(",
"registeredHandlers",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"unregistering {}\"",
",",
"partitionId",
")",
... | Removes the given partition from listening to incoming task events, thus forbidding calls to
{@link #subscribeToEvent(ResultPartitionID, EventListener, Class)}.
@param partitionId
the partition ID | [
"Removes",
"the",
"given",
"partition",
"from",
"listening",
"to",
"incoming",
"task",
"events",
"thus",
"forbidding",
"calls",
"to",
"{",
"@link",
"#subscribeToEvent",
"(",
"ResultPartitionID",
"EventListener",
"Class",
")",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/TaskEventDispatcher.java#L74-L84 | train | Unregister a result partition. | [
30522,
2270,
11675,
4895,
2890,
24063,
2121,
19362,
3775,
3508,
1006,
2765,
19362,
3775,
3508,
3593,
13571,
3593,
1007,
1063,
4638,
17048,
11231,
3363,
1006,
13571,
3593,
1007,
1025,
25549,
1006,
5068,
11774,
12910,
1007,
1063,
8833,
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/img/Img.java | Img.gray | public Img gray() {
final ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
this.targetImage = op.filter(getValidSrcImg(), null);
return this;
} | java | public Img gray() {
final ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
this.targetImage = op.filter(getValidSrcImg(), null);
return this;
} | [
"public",
"Img",
"gray",
"(",
")",
"{",
"final",
"ColorConvertOp",
"op",
"=",
"new",
"ColorConvertOp",
"(",
"ColorSpace",
".",
"getInstance",
"(",
"ColorSpace",
".",
"CS_GRAY",
")",
",",
"null",
")",
";",
"this",
".",
"targetImage",
"=",
"op",
".",
"filt... | 彩色转为黑白
@return this | [
"彩色转为黑白"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/Img.java#L370-L374 | train | Converts the image to gray. | [
30522,
2270,
10047,
2290,
3897,
1006,
1007,
1063,
2345,
3609,
8663,
16874,
7361,
6728,
1027,
2047,
3609,
8663,
16874,
7361,
1006,
6087,
15327,
1012,
2131,
7076,
26897,
1006,
6087,
15327,
1012,
20116,
1035,
3897,
1007,
1010,
19701,
1007,
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-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCOutputFormat.java | JDBCOutputFormat.writeRecord | @Override
public void writeRecord(Row row) throws IOException {
if (typesArray != null && typesArray.length > 0 && typesArray.length != row.getArity()) {
LOG.warn("Column SQL types array doesn't match arity of passed Row! Check the passed array...");
}
try {
if (typesArray == null) {
// no types provided
for (int index = 0; index < row.getArity(); index++) {
LOG.warn("Unknown column type for column {}. Best effort approach to set its value: {}.", index + 1, row.getField(index));
upload.setObject(index + 1, row.getField(index));
}
} else {
// types provided
for (int index = 0; index < row.getArity(); index++) {
if (row.getField(index) == null) {
upload.setNull(index + 1, typesArray[index]);
} else {
try {
// casting values as suggested by http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html
switch (typesArray[index]) {
case java.sql.Types.NULL:
upload.setNull(index + 1, typesArray[index]);
break;
case java.sql.Types.BOOLEAN:
case java.sql.Types.BIT:
upload.setBoolean(index + 1, (boolean) row.getField(index));
break;
case java.sql.Types.CHAR:
case java.sql.Types.NCHAR:
case java.sql.Types.VARCHAR:
case java.sql.Types.LONGVARCHAR:
case java.sql.Types.LONGNVARCHAR:
upload.setString(index + 1, (String) row.getField(index));
break;
case java.sql.Types.TINYINT:
upload.setByte(index + 1, (byte) row.getField(index));
break;
case java.sql.Types.SMALLINT:
upload.setShort(index + 1, (short) row.getField(index));
break;
case java.sql.Types.INTEGER:
upload.setInt(index + 1, (int) row.getField(index));
break;
case java.sql.Types.BIGINT:
upload.setLong(index + 1, (long) row.getField(index));
break;
case java.sql.Types.REAL:
upload.setFloat(index + 1, (float) row.getField(index));
break;
case java.sql.Types.FLOAT:
case java.sql.Types.DOUBLE:
upload.setDouble(index + 1, (double) row.getField(index));
break;
case java.sql.Types.DECIMAL:
case java.sql.Types.NUMERIC:
upload.setBigDecimal(index + 1, (java.math.BigDecimal) row.getField(index));
break;
case java.sql.Types.DATE:
upload.setDate(index + 1, (java.sql.Date) row.getField(index));
break;
case java.sql.Types.TIME:
upload.setTime(index + 1, (java.sql.Time) row.getField(index));
break;
case java.sql.Types.TIMESTAMP:
upload.setTimestamp(index + 1, (java.sql.Timestamp) row.getField(index));
break;
case java.sql.Types.BINARY:
case java.sql.Types.VARBINARY:
case java.sql.Types.LONGVARBINARY:
upload.setBytes(index + 1, (byte[]) row.getField(index));
break;
default:
upload.setObject(index + 1, row.getField(index));
LOG.warn("Unmanaged sql type ({}) for column {}. Best effort approach to set its value: {}.",
typesArray[index], index + 1, row.getField(index));
// case java.sql.Types.SQLXML
// case java.sql.Types.ARRAY:
// case java.sql.Types.JAVA_OBJECT:
// case java.sql.Types.BLOB:
// case java.sql.Types.CLOB:
// case java.sql.Types.NCLOB:
// case java.sql.Types.DATALINK:
// case java.sql.Types.DISTINCT:
// case java.sql.Types.OTHER:
// case java.sql.Types.REF:
// case java.sql.Types.ROWID:
// case java.sql.Types.STRUC
}
} catch (ClassCastException e) {
// enrich the exception with detailed information.
String errorMessage = String.format(
"%s, field index: %s, field value: %s.", e.getMessage(), index, row.getField(index));
ClassCastException enrichedException = new ClassCastException(errorMessage);
enrichedException.setStackTrace(e.getStackTrace());
throw enrichedException;
}
}
}
}
upload.addBatch();
batchCount++;
} catch (SQLException e) {
throw new RuntimeException("Preparation of JDBC statement failed.", e);
}
if (batchCount >= batchInterval) {
// execute batch
flush();
}
} | java | @Override
public void writeRecord(Row row) throws IOException {
if (typesArray != null && typesArray.length > 0 && typesArray.length != row.getArity()) {
LOG.warn("Column SQL types array doesn't match arity of passed Row! Check the passed array...");
}
try {
if (typesArray == null) {
// no types provided
for (int index = 0; index < row.getArity(); index++) {
LOG.warn("Unknown column type for column {}. Best effort approach to set its value: {}.", index + 1, row.getField(index));
upload.setObject(index + 1, row.getField(index));
}
} else {
// types provided
for (int index = 0; index < row.getArity(); index++) {
if (row.getField(index) == null) {
upload.setNull(index + 1, typesArray[index]);
} else {
try {
// casting values as suggested by http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html
switch (typesArray[index]) {
case java.sql.Types.NULL:
upload.setNull(index + 1, typesArray[index]);
break;
case java.sql.Types.BOOLEAN:
case java.sql.Types.BIT:
upload.setBoolean(index + 1, (boolean) row.getField(index));
break;
case java.sql.Types.CHAR:
case java.sql.Types.NCHAR:
case java.sql.Types.VARCHAR:
case java.sql.Types.LONGVARCHAR:
case java.sql.Types.LONGNVARCHAR:
upload.setString(index + 1, (String) row.getField(index));
break;
case java.sql.Types.TINYINT:
upload.setByte(index + 1, (byte) row.getField(index));
break;
case java.sql.Types.SMALLINT:
upload.setShort(index + 1, (short) row.getField(index));
break;
case java.sql.Types.INTEGER:
upload.setInt(index + 1, (int) row.getField(index));
break;
case java.sql.Types.BIGINT:
upload.setLong(index + 1, (long) row.getField(index));
break;
case java.sql.Types.REAL:
upload.setFloat(index + 1, (float) row.getField(index));
break;
case java.sql.Types.FLOAT:
case java.sql.Types.DOUBLE:
upload.setDouble(index + 1, (double) row.getField(index));
break;
case java.sql.Types.DECIMAL:
case java.sql.Types.NUMERIC:
upload.setBigDecimal(index + 1, (java.math.BigDecimal) row.getField(index));
break;
case java.sql.Types.DATE:
upload.setDate(index + 1, (java.sql.Date) row.getField(index));
break;
case java.sql.Types.TIME:
upload.setTime(index + 1, (java.sql.Time) row.getField(index));
break;
case java.sql.Types.TIMESTAMP:
upload.setTimestamp(index + 1, (java.sql.Timestamp) row.getField(index));
break;
case java.sql.Types.BINARY:
case java.sql.Types.VARBINARY:
case java.sql.Types.LONGVARBINARY:
upload.setBytes(index + 1, (byte[]) row.getField(index));
break;
default:
upload.setObject(index + 1, row.getField(index));
LOG.warn("Unmanaged sql type ({}) for column {}. Best effort approach to set its value: {}.",
typesArray[index], index + 1, row.getField(index));
// case java.sql.Types.SQLXML
// case java.sql.Types.ARRAY:
// case java.sql.Types.JAVA_OBJECT:
// case java.sql.Types.BLOB:
// case java.sql.Types.CLOB:
// case java.sql.Types.NCLOB:
// case java.sql.Types.DATALINK:
// case java.sql.Types.DISTINCT:
// case java.sql.Types.OTHER:
// case java.sql.Types.REF:
// case java.sql.Types.ROWID:
// case java.sql.Types.STRUC
}
} catch (ClassCastException e) {
// enrich the exception with detailed information.
String errorMessage = String.format(
"%s, field index: %s, field value: %s.", e.getMessage(), index, row.getField(index));
ClassCastException enrichedException = new ClassCastException(errorMessage);
enrichedException.setStackTrace(e.getStackTrace());
throw enrichedException;
}
}
}
}
upload.addBatch();
batchCount++;
} catch (SQLException e) {
throw new RuntimeException("Preparation of JDBC statement failed.", e);
}
if (batchCount >= batchInterval) {
// execute batch
flush();
}
} | [
"@",
"Override",
"public",
"void",
"writeRecord",
"(",
"Row",
"row",
")",
"throws",
"IOException",
"{",
"if",
"(",
"typesArray",
"!=",
"null",
"&&",
"typesArray",
".",
"length",
">",
"0",
"&&",
"typesArray",
".",
"length",
"!=",
"row",
".",
"getArity",
"... | Adds a record to the prepared statement.
<p>When this method is called, the output format is guaranteed to be opened.
<p>WARNING: this may fail when no column types specified (because a best effort approach is attempted in order to
insert a null value but it's not guaranteed that the JDBC driver handles PreparedStatement.setObject(pos, null))
@param row The records to add to the output.
@see PreparedStatement
@throws IOException Thrown, if the records could not be added due to an I/O problem. | [
"Adds",
"a",
"record",
"to",
"the",
"prepared",
"statement",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCOutputFormat.java#L108-L221 | train | Write a row to the output stream. | [
30522,
1030,
2058,
15637,
2270,
11675,
3213,
8586,
8551,
1006,
5216,
5216,
1007,
11618,
22834,
10288,
24422,
1063,
2065,
1006,
4127,
2906,
9447,
999,
1027,
19701,
1004,
1004,
4127,
2906,
9447,
1012,
3091,
1028,
1014,
1004,
1004,
4127,
2906,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/logging/CommonsLogger.java | CommonsLogger.trace | @Override
public void trace(String format, Object arg) {
if (logger.isTraceEnabled()) {
FormattingTuple ft = MessageFormatter.format(format, arg);
logger.trace(ft.getMessage(), ft.getThrowable());
}
} | java | @Override
public void trace(String format, Object arg) {
if (logger.isTraceEnabled()) {
FormattingTuple ft = MessageFormatter.format(format, arg);
logger.trace(ft.getMessage(), ft.getThrowable());
}
} | [
"@",
"Override",
"public",
"void",
"trace",
"(",
"String",
"format",
",",
"Object",
"arg",
")",
"{",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"FormattingTuple",
"ft",
"=",
"MessageFormatter",
".",
"format",
"(",
"format",
",",
"arg... | Delegates to the {@link Log#trace(Object)} method of the underlying
{@link Log} instance.
<p>
However, this form avoids superfluous object creation when the logger is disabled
for level TRACE.
</p>
@param format
the format string
@param arg
the argument | [
"Delegates",
"to",
"the",
"{",
"@link",
"Log#trace",
"(",
"Object",
")",
"}",
"method",
"of",
"the",
"underlying",
"{",
"@link",
"Log",
"}",
"instance",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/logging/CommonsLogger.java#L100-L106 | train | Trace method. | [
30522,
1030,
2058,
15637,
2270,
11675,
7637,
1006,
5164,
4289,
1010,
4874,
12098,
2290,
1007,
1063,
2065,
1006,
8833,
4590,
1012,
21541,
22903,
8189,
23242,
1006,
1007,
1007,
1063,
4289,
3436,
8525,
10814,
3027,
1027,
4471,
14192,
20097,
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-yarn/src/main/java/org/apache/flink/yarn/RegisterApplicationMasterResponseReflector.java | RegisterApplicationMasterResponseReflector.getContainersFromPreviousAttemptsUnsafe | @VisibleForTesting
List<Container> getContainersFromPreviousAttemptsUnsafe(final Object response) {
if (method != null && response != null) {
try {
@SuppressWarnings("unchecked")
final List<Container> containers = (List<Container>) method.invoke(response);
if (containers != null && !containers.isEmpty()) {
return containers;
}
} catch (Exception t) {
logger.error("Error invoking 'getContainersFromPreviousAttempts()'", t);
}
}
return Collections.emptyList();
} | java | @VisibleForTesting
List<Container> getContainersFromPreviousAttemptsUnsafe(final Object response) {
if (method != null && response != null) {
try {
@SuppressWarnings("unchecked")
final List<Container> containers = (List<Container>) method.invoke(response);
if (containers != null && !containers.isEmpty()) {
return containers;
}
} catch (Exception t) {
logger.error("Error invoking 'getContainersFromPreviousAttempts()'", t);
}
}
return Collections.emptyList();
} | [
"@",
"VisibleForTesting",
"List",
"<",
"Container",
">",
"getContainersFromPreviousAttemptsUnsafe",
"(",
"final",
"Object",
"response",
")",
"{",
"if",
"(",
"method",
"!=",
"null",
"&&",
"response",
"!=",
"null",
")",
"{",
"try",
"{",
"@",
"SuppressWarnings",
... | Same as {@link #getContainersFromPreviousAttempts(RegisterApplicationMasterResponse)} but
allows to pass objects that are not of type {@link RegisterApplicationMasterResponse}. | [
"Same",
"as",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-yarn/src/main/java/org/apache/flink/yarn/RegisterApplicationMasterResponseReflector.java#L81-L96 | train | Get the containers from previous attempts. | [
30522,
1030,
5710,
13028,
4355,
2075,
2862,
1026,
11661,
1028,
2131,
8663,
18249,
2545,
19699,
25377,
2890,
24918,
19321,
6633,
22798,
4609,
3736,
7959,
1006,
2345,
4874,
3433,
1007,
1063,
2065,
1006,
4118,
999,
1027,
19701,
1004,
1004,
343... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/types/parser/FloatParser.java | FloatParser.parseField | public static final float parseField(byte[] bytes, int startPos, int length, char delimiter) {
final int limitedLen = nextStringLength(bytes, startPos, length, delimiter);
if (limitedLen > 0 &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[startPos + limitedLen - 1]))) {
throw new NumberFormatException("There is leading or trailing whitespace in the numeric field.");
}
final String str = new String(bytes, startPos, limitedLen, ConfigConstants.DEFAULT_CHARSET);
return Float.parseFloat(str);
} | java | public static final float parseField(byte[] bytes, int startPos, int length, char delimiter) {
final int limitedLen = nextStringLength(bytes, startPos, length, delimiter);
if (limitedLen > 0 &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[startPos + limitedLen - 1]))) {
throw new NumberFormatException("There is leading or trailing whitespace in the numeric field.");
}
final String str = new String(bytes, startPos, limitedLen, ConfigConstants.DEFAULT_CHARSET);
return Float.parseFloat(str);
} | [
"public",
"static",
"final",
"float",
"parseField",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"startPos",
",",
"int",
"length",
",",
"char",
"delimiter",
")",
"{",
"final",
"int",
"limitedLen",
"=",
"nextStringLength",
"(",
"bytes",
",",
"startPos",
",",... | Static utility to parse a field of type float from a byte sequence that represents text
characters
(such as when read from a file stream).
@param bytes The bytes containing the text data that should be parsed.
@param startPos The offset to start the parsing.
@param length The length of the byte sequence (counting from the offset).
@param delimiter The delimiter that terminates the field.
@return The parsed value.
@throws IllegalArgumentException Thrown when the value cannot be parsed because the text
represents not a correct number. | [
"Static",
"utility",
"to",
"parse",
"a",
"field",
"of",
"type",
"float",
"from",
"a",
"byte",
"sequence",
"that",
"represents",
"text",
"characters",
"(",
"such",
"as",
"when",
"read",
"from",
"a",
"file",
"stream",
")",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/parser/FloatParser.java#L95-L105 | train | Parses a field of a byte array into a float. | [
30522,
2270,
10763,
2345,
14257,
11968,
20106,
12891,
1006,
24880,
1031,
1033,
27507,
1010,
20014,
2707,
6873,
2015,
1010,
20014,
3091,
1010,
25869,
3972,
27605,
3334,
1007,
1063,
2345,
20014,
3132,
7770,
1027,
2279,
3367,
4892,
7770,
13512,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ConverterRegistry.java | ConverterRegistry.convertSpecial | @SuppressWarnings("unchecked")
private <T> T convertSpecial(Type type, Class<T> rowType, Object value, T defaultValue) {
if (null == rowType) {
return null;
}
// 集合转换(不可以默认强转)
if (Collection.class.isAssignableFrom(rowType)) {
final CollectionConverter collectionConverter = new CollectionConverter(type);
return (T) collectionConverter.convert(value, (Collection<?>) defaultValue);
}
// Map类型(不可以默认强转)
if (Map.class.isAssignableFrom(rowType)) {
final MapConverter mapConverter = new MapConverter(type);
return (T) mapConverter.convert(value, (Map<?, ?>) defaultValue);
}
// 默认强转
if (rowType.isInstance(value)) {
return (T) value;
}
// 数组转换
if (rowType.isArray()) {
final ArrayConverter arrayConverter = new ArrayConverter(rowType);
try {
return (T) arrayConverter.convert(value, defaultValue);
} catch (Exception e) {
// 数组转换失败进行下一步
}
}
// 枚举转换
if (rowType.isEnum()) {
return (T) new EnumConverter(rowType).convert(value, defaultValue);
}
// 表示非需要特殊转换的对象
return null;
} | java | @SuppressWarnings("unchecked")
private <T> T convertSpecial(Type type, Class<T> rowType, Object value, T defaultValue) {
if (null == rowType) {
return null;
}
// 集合转换(不可以默认强转)
if (Collection.class.isAssignableFrom(rowType)) {
final CollectionConverter collectionConverter = new CollectionConverter(type);
return (T) collectionConverter.convert(value, (Collection<?>) defaultValue);
}
// Map类型(不可以默认强转)
if (Map.class.isAssignableFrom(rowType)) {
final MapConverter mapConverter = new MapConverter(type);
return (T) mapConverter.convert(value, (Map<?, ?>) defaultValue);
}
// 默认强转
if (rowType.isInstance(value)) {
return (T) value;
}
// 数组转换
if (rowType.isArray()) {
final ArrayConverter arrayConverter = new ArrayConverter(rowType);
try {
return (T) arrayConverter.convert(value, defaultValue);
} catch (Exception e) {
// 数组转换失败进行下一步
}
}
// 枚举转换
if (rowType.isEnum()) {
return (T) new EnumConverter(rowType).convert(value, defaultValue);
}
// 表示非需要特殊转换的对象
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
">",
"T",
"convertSpecial",
"(",
"Type",
"type",
",",
"Class",
"<",
"T",
">",
"rowType",
",",
"Object",
"value",
",",
"T",
"defaultValue",
")",
"{",
"if",
"(",
"null",
"==",
"rowT... | 特殊类型转换<br>
包括:
<pre>
Collection
Map
强转(无需转换)
数组
</pre>
@param <T> 转换的目标类型(转换器转换到的类型)
@param type 类型
@param value 值
@param defaultValue 默认值
@return 转换后的值 | [
"特殊类型转换<br",
">",
"包括:"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/convert/ConverterRegistry.java#L277-L317 | train | Converts special types of the given value to the given type. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2797,
1026,
1056,
1028,
1056,
19884,
5051,
13247,
1006,
2828,
2828,
1010,
2465,
1026,
1056,
1028,
5216,
13874,
1010,
4874,
3643,
1010,
1056,
12398,
10175,
5657... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/util/ZooKeeperUtils.java | ZooKeeperUtils.createCheckpointIDCounter | public static ZooKeeperCheckpointIDCounter createCheckpointIDCounter(
CuratorFramework client,
Configuration configuration,
JobID jobId) {
String checkpointIdCounterPath = configuration.getString(
HighAvailabilityOptions.HA_ZOOKEEPER_CHECKPOINT_COUNTER_PATH);
checkpointIdCounterPath += ZooKeeperSubmittedJobGraphStore.getPathForJob(jobId);
return new ZooKeeperCheckpointIDCounter(client, checkpointIdCounterPath);
} | java | public static ZooKeeperCheckpointIDCounter createCheckpointIDCounter(
CuratorFramework client,
Configuration configuration,
JobID jobId) {
String checkpointIdCounterPath = configuration.getString(
HighAvailabilityOptions.HA_ZOOKEEPER_CHECKPOINT_COUNTER_PATH);
checkpointIdCounterPath += ZooKeeperSubmittedJobGraphStore.getPathForJob(jobId);
return new ZooKeeperCheckpointIDCounter(client, checkpointIdCounterPath);
} | [
"public",
"static",
"ZooKeeperCheckpointIDCounter",
"createCheckpointIDCounter",
"(",
"CuratorFramework",
"client",
",",
"Configuration",
"configuration",
",",
"JobID",
"jobId",
")",
"{",
"String",
"checkpointIdCounterPath",
"=",
"configuration",
".",
"getString",
"(",
"H... | Creates a {@link ZooKeeperCheckpointIDCounter} instance.
@param client The {@link CuratorFramework} ZooKeeper client to use
@param configuration {@link Configuration} object
@param jobId ID of job to create the instance for
@return {@link ZooKeeperCheckpointIDCounter} instance | [
"Creates",
"a",
"{",
"@link",
"ZooKeeperCheckpointIDCounter",
"}",
"instance",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java#L331-L342 | train | Creates a new ZooKeeperCheckpointIDCounter object. | [
30522,
2270,
10763,
9201,
13106,
5403,
3600,
8400,
3593,
3597,
16671,
2121,
3443,
5403,
3600,
8400,
3593,
3597,
16671,
2121,
1006,
13023,
15643,
6198,
7396,
1010,
9563,
9563,
1010,
3105,
3593,
3105,
3593,
1007,
1063,
5164,
26520,
3593,
3597... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getLong48 | public final long getLong48() {
if (position + 5 >= origin + limit) throw new IllegalArgumentException("limit excceed: "
+ (position - origin + 5));
byte[] buf = buffer;
return ((long) (0xff & buf[position++])) | ((long) (0xff & buf[position++]) << 8)
| ((long) (0xff & buf[position++]) << 16) | ((long) (0xff & buf[position++]) << 24)
| ((long) (0xff & buf[position++]) << 32) | ((long) (buf[position++]) << 40);
} | java | public final long getLong48() {
if (position + 5 >= origin + limit) throw new IllegalArgumentException("limit excceed: "
+ (position - origin + 5));
byte[] buf = buffer;
return ((long) (0xff & buf[position++])) | ((long) (0xff & buf[position++]) << 8)
| ((long) (0xff & buf[position++]) << 16) | ((long) (0xff & buf[position++]) << 24)
| ((long) (0xff & buf[position++]) << 32) | ((long) (buf[position++]) << 40);
} | [
"public",
"final",
"long",
"getLong48",
"(",
")",
"{",
"if",
"(",
"position",
"+",
"5",
">=",
"origin",
"+",
"limit",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"limit excceed: \"",
"+",
"(",
"position",
"-",
"origin",
"+",
"5",
")",
")",
";... | Return next 48-bit signed long from buffer. (little-endian)
@see mysql-5.1.60/include/my_global.h - sint6korr | [
"Return",
"next",
"48",
"-",
"bit",
"signed",
"long",
"from",
"buffer",
".",
"(",
"little",
"-",
"endian",
")"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L683-L691 | train | Gets a 48 - bit unsigned integer from the buffer. | [
30522,
2270,
2345,
2146,
2131,
10052,
18139,
1006,
1007,
1063,
2065,
1006,
2597,
1009,
1019,
1028,
1027,
4761,
1009,
5787,
1007,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24422,
1006,
1000,
5787,
4654,
9468,
13089,
1024,
1000,
1009,
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-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.getInstances | @SuppressWarnings("unchecked")
public <U> List<U> getInstances(String name, Class<U> xface) {
List<U> ret = new ArrayList<U>();
Class<?>[] classes = getClasses(name);
for (Class<?> cl: classes) {
if (!xface.isAssignableFrom(cl)) {
throw new RuntimeException(cl + " does not implement " + xface);
}
ret.add((U)ReflectionUtils.newInstance(cl, this));
}
return ret;
} | java | @SuppressWarnings("unchecked")
public <U> List<U> getInstances(String name, Class<U> xface) {
List<U> ret = new ArrayList<U>();
Class<?>[] classes = getClasses(name);
for (Class<?> cl: classes) {
if (!xface.isAssignableFrom(cl)) {
throw new RuntimeException(cl + " does not implement " + xface);
}
ret.add((U)ReflectionUtils.newInstance(cl, this));
}
return ret;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"U",
">",
"List",
"<",
"U",
">",
"getInstances",
"(",
"String",
"name",
",",
"Class",
"<",
"U",
">",
"xface",
")",
"{",
"List",
"<",
"U",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"... | Get the value of the <code>name</code> property as a <code>List</code>
of objects implementing the interface specified by <code>xface</code>.
An exception is thrown if any of the classes does not exist, or if it does
not implement the named interface.
@param name the property name.
@param xface the interface implemented by the classes named by
<code>name</code>.
@return a <code>List</code> of objects implementing <code>xface</code>. | [
"Get",
"the",
"value",
"of",
"the",
"<code",
">",
"name<",
"/",
"code",
">",
"property",
"as",
"a",
"<code",
">",
"List<",
"/",
"code",
">",
"of",
"objects",
"implementing",
"the",
"interface",
"specified",
"by",
"<code",
">",
"xface<",
"/",
"code",
">... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L2519-L2530 | train | Gets all instances of the specified class. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2270,
1026,
1057,
1028,
2862,
1026,
1057,
1028,
2131,
7076,
26897,
2015,
1006,
5164,
2171,
1010,
2465,
1026,
1057,
1028,
1060,
12172,
1007,
1063,
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... |
apache/flink | flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/KinesisDataFetcher.java | KinesisDataFetcher.runFetcher | public void runFetcher() throws Exception {
// check that we are running before proceeding
if (!running) {
return;
}
this.mainThread = Thread.currentThread();
// ------------------------------------------------------------------------
// Procedures before starting the infinite while loop:
// ------------------------------------------------------------------------
// 1. check that there is at least one shard in the subscribed streams to consume from (can be done by
// checking if at least one value in subscribedStreamsToLastDiscoveredShardIds is not null)
boolean hasShards = false;
StringBuilder streamsWithNoShardsFound = new StringBuilder();
for (Map.Entry<String, String> streamToLastDiscoveredShardEntry : subscribedStreamsToLastDiscoveredShardIds.entrySet()) {
if (streamToLastDiscoveredShardEntry.getValue() != null) {
hasShards = true;
} else {
streamsWithNoShardsFound.append(streamToLastDiscoveredShardEntry.getKey()).append(", ");
}
}
if (streamsWithNoShardsFound.length() != 0 && LOG.isWarnEnabled()) {
LOG.warn("Subtask {} has failed to find any shards for the following subscribed streams: {}",
indexOfThisConsumerSubtask, streamsWithNoShardsFound.toString());
}
if (!hasShards) {
throw new RuntimeException("No shards can be found for all subscribed streams: " + streams);
}
// 2. start consuming any shard state we already have in the subscribedShardState up to this point; the
// subscribedShardState may already be seeded with values due to step 1., or explicitly added by the
// consumer using a restored state checkpoint
for (int seededStateIndex = 0; seededStateIndex < subscribedShardsState.size(); seededStateIndex++) {
KinesisStreamShardState seededShardState = subscribedShardsState.get(seededStateIndex);
// only start a consuming thread if the seeded subscribed shard has not been completely read already
if (!seededShardState.getLastProcessedSequenceNum().equals(SentinelSequenceNumber.SENTINEL_SHARD_ENDING_SEQUENCE_NUM.get())) {
if (LOG.isInfoEnabled()) {
LOG.info("Subtask {} will start consuming seeded shard {} from sequence number {} with ShardConsumer {}",
indexOfThisConsumerSubtask, seededShardState.getStreamShardHandle().toString(),
seededShardState.getLastProcessedSequenceNum(), seededStateIndex);
}
shardConsumersExecutor.submit(
createShardConsumer(
seededStateIndex,
subscribedShardsState.get(seededStateIndex).getStreamShardHandle(),
subscribedShardsState.get(seededStateIndex).getLastProcessedSequenceNum(),
registerShardMetrics(consumerMetricGroup, subscribedShardsState.get(seededStateIndex))));
}
}
// start periodic watermark emitter, if a watermark assigner was configured
if (periodicWatermarkAssigner != null) {
long periodicWatermarkIntervalMillis = runtimeContext.getExecutionConfig().getAutoWatermarkInterval();
if (periodicWatermarkIntervalMillis > 0) {
ProcessingTimeService timerService = ((StreamingRuntimeContext) runtimeContext).getProcessingTimeService();
LOG.info("Starting periodic watermark emitter with interval {}", periodicWatermarkIntervalMillis);
new PeriodicWatermarkEmitter(timerService, periodicWatermarkIntervalMillis).start();
}
this.shardIdleIntervalMillis = Long.parseLong(
getConsumerConfiguration().getProperty(ConsumerConfigConstants.SHARD_IDLE_INTERVAL_MILLIS,
Long.toString(ConsumerConfigConstants.DEFAULT_SHARD_IDLE_INTERVAL_MILLIS)));
}
// ------------------------------------------------------------------------
// finally, start the infinite shard discovery and consumer launching loop;
// we will escape from this loop only when shutdownFetcher() or stopWithError() is called
final long discoveryIntervalMillis = Long.valueOf(
configProps.getProperty(
ConsumerConfigConstants.SHARD_DISCOVERY_INTERVAL_MILLIS,
Long.toString(ConsumerConfigConstants.DEFAULT_SHARD_DISCOVERY_INTERVAL_MILLIS)));
if (this.numberOfActiveShards.get() == 0) {
LOG.info("Subtask {} has no active shards to read on startup; marking the subtask as temporarily idle ...",
indexOfThisConsumerSubtask);
sourceContext.markAsTemporarilyIdle();
}
while (running) {
if (LOG.isDebugEnabled()) {
LOG.debug("Subtask {} is trying to discover new shards that were created due to resharding ...",
indexOfThisConsumerSubtask);
}
List<StreamShardHandle> newShardsDueToResharding = discoverNewShardsToSubscribe();
for (StreamShardHandle shard : newShardsDueToResharding) {
// since there may be delay in discovering a new shard, all new shards due to
// resharding should be read starting from the earliest record possible
KinesisStreamShardState newShardState =
new KinesisStreamShardState(convertToStreamShardMetadata(shard), shard, SentinelSequenceNumber.SENTINEL_EARLIEST_SEQUENCE_NUM.get());
int newStateIndex = registerNewSubscribedShardState(newShardState);
if (LOG.isInfoEnabled()) {
LOG.info("Subtask {} has discovered a new shard {} due to resharding, and will start consuming " +
"the shard from sequence number {} with ShardConsumer {}",
indexOfThisConsumerSubtask, newShardState.getStreamShardHandle().toString(),
newShardState.getLastProcessedSequenceNum(), newStateIndex);
}
shardConsumersExecutor.submit(
createShardConsumer(
newStateIndex,
newShardState.getStreamShardHandle(),
newShardState.getLastProcessedSequenceNum(),
registerShardMetrics(consumerMetricGroup, newShardState)));
}
// we also check if we are running here so that we won't start the discovery sleep
// interval if the running flag was set to false during the middle of the while loop
if (running && discoveryIntervalMillis != 0) {
try {
Thread.sleep(discoveryIntervalMillis);
} catch (InterruptedException iex) {
// the sleep may be interrupted by shutdownFetcher()
}
}
}
// make sure all resources have been terminated before leaving
try {
awaitTermination();
} catch (InterruptedException ie) {
// If there is an original exception, preserve it, since that's more important/useful.
this.error.compareAndSet(null, ie);
}
// any error thrown in the shard consumer threads will be thrown to the main thread
Throwable throwable = this.error.get();
if (throwable != null) {
if (throwable instanceof Exception) {
throw (Exception) throwable;
} else if (throwable instanceof Error) {
throw (Error) throwable;
} else {
throw new Exception(throwable);
}
}
} | java | public void runFetcher() throws Exception {
// check that we are running before proceeding
if (!running) {
return;
}
this.mainThread = Thread.currentThread();
// ------------------------------------------------------------------------
// Procedures before starting the infinite while loop:
// ------------------------------------------------------------------------
// 1. check that there is at least one shard in the subscribed streams to consume from (can be done by
// checking if at least one value in subscribedStreamsToLastDiscoveredShardIds is not null)
boolean hasShards = false;
StringBuilder streamsWithNoShardsFound = new StringBuilder();
for (Map.Entry<String, String> streamToLastDiscoveredShardEntry : subscribedStreamsToLastDiscoveredShardIds.entrySet()) {
if (streamToLastDiscoveredShardEntry.getValue() != null) {
hasShards = true;
} else {
streamsWithNoShardsFound.append(streamToLastDiscoveredShardEntry.getKey()).append(", ");
}
}
if (streamsWithNoShardsFound.length() != 0 && LOG.isWarnEnabled()) {
LOG.warn("Subtask {} has failed to find any shards for the following subscribed streams: {}",
indexOfThisConsumerSubtask, streamsWithNoShardsFound.toString());
}
if (!hasShards) {
throw new RuntimeException("No shards can be found for all subscribed streams: " + streams);
}
// 2. start consuming any shard state we already have in the subscribedShardState up to this point; the
// subscribedShardState may already be seeded with values due to step 1., or explicitly added by the
// consumer using a restored state checkpoint
for (int seededStateIndex = 0; seededStateIndex < subscribedShardsState.size(); seededStateIndex++) {
KinesisStreamShardState seededShardState = subscribedShardsState.get(seededStateIndex);
// only start a consuming thread if the seeded subscribed shard has not been completely read already
if (!seededShardState.getLastProcessedSequenceNum().equals(SentinelSequenceNumber.SENTINEL_SHARD_ENDING_SEQUENCE_NUM.get())) {
if (LOG.isInfoEnabled()) {
LOG.info("Subtask {} will start consuming seeded shard {} from sequence number {} with ShardConsumer {}",
indexOfThisConsumerSubtask, seededShardState.getStreamShardHandle().toString(),
seededShardState.getLastProcessedSequenceNum(), seededStateIndex);
}
shardConsumersExecutor.submit(
createShardConsumer(
seededStateIndex,
subscribedShardsState.get(seededStateIndex).getStreamShardHandle(),
subscribedShardsState.get(seededStateIndex).getLastProcessedSequenceNum(),
registerShardMetrics(consumerMetricGroup, subscribedShardsState.get(seededStateIndex))));
}
}
// start periodic watermark emitter, if a watermark assigner was configured
if (periodicWatermarkAssigner != null) {
long periodicWatermarkIntervalMillis = runtimeContext.getExecutionConfig().getAutoWatermarkInterval();
if (periodicWatermarkIntervalMillis > 0) {
ProcessingTimeService timerService = ((StreamingRuntimeContext) runtimeContext).getProcessingTimeService();
LOG.info("Starting periodic watermark emitter with interval {}", periodicWatermarkIntervalMillis);
new PeriodicWatermarkEmitter(timerService, periodicWatermarkIntervalMillis).start();
}
this.shardIdleIntervalMillis = Long.parseLong(
getConsumerConfiguration().getProperty(ConsumerConfigConstants.SHARD_IDLE_INTERVAL_MILLIS,
Long.toString(ConsumerConfigConstants.DEFAULT_SHARD_IDLE_INTERVAL_MILLIS)));
}
// ------------------------------------------------------------------------
// finally, start the infinite shard discovery and consumer launching loop;
// we will escape from this loop only when shutdownFetcher() or stopWithError() is called
final long discoveryIntervalMillis = Long.valueOf(
configProps.getProperty(
ConsumerConfigConstants.SHARD_DISCOVERY_INTERVAL_MILLIS,
Long.toString(ConsumerConfigConstants.DEFAULT_SHARD_DISCOVERY_INTERVAL_MILLIS)));
if (this.numberOfActiveShards.get() == 0) {
LOG.info("Subtask {} has no active shards to read on startup; marking the subtask as temporarily idle ...",
indexOfThisConsumerSubtask);
sourceContext.markAsTemporarilyIdle();
}
while (running) {
if (LOG.isDebugEnabled()) {
LOG.debug("Subtask {} is trying to discover new shards that were created due to resharding ...",
indexOfThisConsumerSubtask);
}
List<StreamShardHandle> newShardsDueToResharding = discoverNewShardsToSubscribe();
for (StreamShardHandle shard : newShardsDueToResharding) {
// since there may be delay in discovering a new shard, all new shards due to
// resharding should be read starting from the earliest record possible
KinesisStreamShardState newShardState =
new KinesisStreamShardState(convertToStreamShardMetadata(shard), shard, SentinelSequenceNumber.SENTINEL_EARLIEST_SEQUENCE_NUM.get());
int newStateIndex = registerNewSubscribedShardState(newShardState);
if (LOG.isInfoEnabled()) {
LOG.info("Subtask {} has discovered a new shard {} due to resharding, and will start consuming " +
"the shard from sequence number {} with ShardConsumer {}",
indexOfThisConsumerSubtask, newShardState.getStreamShardHandle().toString(),
newShardState.getLastProcessedSequenceNum(), newStateIndex);
}
shardConsumersExecutor.submit(
createShardConsumer(
newStateIndex,
newShardState.getStreamShardHandle(),
newShardState.getLastProcessedSequenceNum(),
registerShardMetrics(consumerMetricGroup, newShardState)));
}
// we also check if we are running here so that we won't start the discovery sleep
// interval if the running flag was set to false during the middle of the while loop
if (running && discoveryIntervalMillis != 0) {
try {
Thread.sleep(discoveryIntervalMillis);
} catch (InterruptedException iex) {
// the sleep may be interrupted by shutdownFetcher()
}
}
}
// make sure all resources have been terminated before leaving
try {
awaitTermination();
} catch (InterruptedException ie) {
// If there is an original exception, preserve it, since that's more important/useful.
this.error.compareAndSet(null, ie);
}
// any error thrown in the shard consumer threads will be thrown to the main thread
Throwable throwable = this.error.get();
if (throwable != null) {
if (throwable instanceof Exception) {
throw (Exception) throwable;
} else if (throwable instanceof Error) {
throw (Error) throwable;
} else {
throw new Exception(throwable);
}
}
} | [
"public",
"void",
"runFetcher",
"(",
")",
"throws",
"Exception",
"{",
"// check that we are running before proceeding",
"if",
"(",
"!",
"running",
")",
"{",
"return",
";",
"}",
"this",
".",
"mainThread",
"=",
"Thread",
".",
"currentThread",
"(",
")",
";",
"// ... | Starts the fetcher. After starting the fetcher, it can only
be stopped by calling {@link KinesisDataFetcher#shutdownFetcher()}.
@throws Exception the first error or exception thrown by the fetcher or any of the threads created by the fetcher. | [
"Starts",
"the",
"fetcher",
".",
"After",
"starting",
"the",
"fetcher",
"it",
"can",
"only",
"be",
"stopped",
"by",
"calling",
"{",
"@link",
"KinesisDataFetcher#shutdownFetcher",
"()",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/KinesisDataFetcher.java#L318-L464 | train | Run the fetcher | [
30522,
2270,
11675,
2448,
7959,
10649,
2121,
1006,
1007,
11618,
6453,
1063,
1013,
1013,
4638,
2008,
2057,
2024,
2770,
2077,
18207,
2065,
1006,
999,
2770,
1007,
1063,
2709,
1025,
1065,
2023,
1012,
2364,
2705,
16416,
2094,
1027,
11689,
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/state/KeyGroupPartitioner.java | KeyGroupPartitioner.partitionByKeyGroup | public StateSnapshot.StateKeyGroupWriter partitionByKeyGroup() {
if (computedResult == null) {
reportAllElementKeyGroups();
int outputNumberOfElements = buildHistogramByAccumulatingCounts();
executePartitioning(outputNumberOfElements);
}
return computedResult;
} | java | public StateSnapshot.StateKeyGroupWriter partitionByKeyGroup() {
if (computedResult == null) {
reportAllElementKeyGroups();
int outputNumberOfElements = buildHistogramByAccumulatingCounts();
executePartitioning(outputNumberOfElements);
}
return computedResult;
} | [
"public",
"StateSnapshot",
".",
"StateKeyGroupWriter",
"partitionByKeyGroup",
"(",
")",
"{",
"if",
"(",
"computedResult",
"==",
"null",
")",
"{",
"reportAllElementKeyGroups",
"(",
")",
";",
"int",
"outputNumberOfElements",
"=",
"buildHistogramByAccumulatingCounts",
"(",... | Partitions the data into key-groups and returns the result via {@link PartitioningResult}. | [
"Partitions",
"the",
"data",
"into",
"key",
"-",
"groups",
"and",
"returns",
"the",
"result",
"via",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/state/KeyGroupPartitioner.java#L135-L142 | train | Partition by group. | [
30522,
2270,
2163,
2532,
4523,
12326,
1012,
2110,
14839,
17058,
15994,
13571,
3762,
14839,
17058,
1006,
1007,
1063,
2065,
1006,
24806,
6072,
11314,
1027,
1027,
19701,
1007,
1063,
3189,
24164,
16930,
4765,
14839,
17058,
2015,
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... |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java | LogBuffer.getString | public final String getString(String charsetName) {
if (position >= origin + limit) throw new IllegalArgumentException("limit excceed: " + position);
byte[] buf = buffer;
final int len = (0xff & buf[position]);
if (position + len + 1 > origin + limit) throw new IllegalArgumentException("limit excceed: "
+ (position + len + 1 - origin));
try {
String string = new String(buf, position + 1, len, charsetName);
position += len + 1;
return string;
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Unsupported encoding: " + charsetName, e);
}
} | java | public final String getString(String charsetName) {
if (position >= origin + limit) throw new IllegalArgumentException("limit excceed: " + position);
byte[] buf = buffer;
final int len = (0xff & buf[position]);
if (position + len + 1 > origin + limit) throw new IllegalArgumentException("limit excceed: "
+ (position + len + 1 - origin));
try {
String string = new String(buf, position + 1, len, charsetName);
position += len + 1;
return string;
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Unsupported encoding: " + charsetName, e);
}
} | [
"public",
"final",
"String",
"getString",
"(",
"String",
"charsetName",
")",
"{",
"if",
"(",
"position",
">=",
"origin",
"+",
"limit",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"limit excceed: \"",
"+",
"position",
")",
";",
"byte",
"[",
"]",
"... | Return next dynamic length string from buffer. | [
"Return",
"next",
"dynamic",
"length",
"string",
"from",
"buffer",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L1169-L1184 | train | Gets a string in the buffer. | [
30522,
2270,
2345,
5164,
4152,
18886,
3070,
1006,
5164,
25869,
13462,
18442,
1007,
1063,
2065,
1006,
2597,
1028,
1027,
4761,
1009,
5787,
1007,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24422,
1006,
1000,
5787,
4654,
9468,
13089,
1024,
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-script/src/main/java/cn/hutool/script/ScriptRuntimeException.java | ScriptRuntimeException.getMessage | @Override
public String getMessage() {
String ret = super.getMessage();
if (fileName != null) {
ret += (" in " + fileName);
if (lineNumber != -1) {
ret += " at line number " + lineNumber;
}
if (columnNumber != -1) {
ret += " at column number " + columnNumber;
}
}
return ret;
} | java | @Override
public String getMessage() {
String ret = super.getMessage();
if (fileName != null) {
ret += (" in " + fileName);
if (lineNumber != -1) {
ret += " at line number " + lineNumber;
}
if (columnNumber != -1) {
ret += " at column number " + columnNumber;
}
}
return ret;
} | [
"@",
"Override",
"public",
"String",
"getMessage",
"(",
")",
"{",
"String",
"ret",
"=",
"super",
".",
"getMessage",
"(",
")",
";",
"if",
"(",
"fileName",
"!=",
"null",
")",
"{",
"ret",
"+=",
"(",
"\" in \"",
"+",
"fileName",
")",
";",
"if",
"(",
"l... | Returns a message containing the String passed to a constructor as well as line and column numbers and filename if any of these are known.
@return The error message. | [
"Returns",
"a",
"message",
"containing",
"the",
"String",
"passed",
"to",
"a",
"constructor",
"as",
"well",
"as",
"line",
"and",
"column",
"numbers",
"and",
"filename",
"if",
"any",
"of",
"these",
"are",
"known",
"."
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-script/src/main/java/cn/hutool/script/ScriptRuntimeException.java#L83-L98 | train | Returns a string describing the error with the details of the exception. | [
30522,
1030,
2058,
15637,
2270,
5164,
2131,
7834,
3736,
3351,
1006,
1007,
1063,
5164,
2128,
2102,
1027,
3565,
1012,
2131,
7834,
3736,
3351,
1006,
1007,
1025,
2065,
1006,
5371,
18442,
999,
1027,
19701,
1007,
1063,
2128,
2102,
1009,
1027,
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-db/src/main/java/cn/hutool/db/SqlConnRunner.java | SqlConnRunner.insertForGeneratedKey | public Long insertForGeneratedKey(Connection conn, Entity record) throws SQLException {
checkConn(conn);
if(CollectionUtil.isEmpty(record)){
throw new SQLException("Empty entity provided!");
}
PreparedStatement ps = null;
try {
ps = dialect.psForInsert(conn, record);
ps.executeUpdate();
return StatementUtil.getGeneratedKeyOfLong(ps);
} catch (SQLException e) {
throw e;
} finally {
DbUtil.close(ps);
}
} | java | public Long insertForGeneratedKey(Connection conn, Entity record) throws SQLException {
checkConn(conn);
if(CollectionUtil.isEmpty(record)){
throw new SQLException("Empty entity provided!");
}
PreparedStatement ps = null;
try {
ps = dialect.psForInsert(conn, record);
ps.executeUpdate();
return StatementUtil.getGeneratedKeyOfLong(ps);
} catch (SQLException e) {
throw e;
} finally {
DbUtil.close(ps);
}
} | [
"public",
"Long",
"insertForGeneratedKey",
"(",
"Connection",
"conn",
",",
"Entity",
"record",
")",
"throws",
"SQLException",
"{",
"checkConn",
"(",
"conn",
")",
";",
"if",
"(",
"CollectionUtil",
".",
"isEmpty",
"(",
"record",
")",
")",
"{",
"throw",
"new",
... | 插入数据<br>
此方法不会关闭Connection
@param conn 数据库连接
@param record 记录
@return 自增主键
@throws SQLException SQL执行异常 | [
"插入数据<br",
">",
"此方法不会关闭Connection"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/SqlConnRunner.java#L209-L225 | train | Insert a new generated key into the database. | [
30522,
2270,
2146,
19274,
29278,
6914,
16848,
14839,
1006,
4434,
9530,
2078,
1010,
9178,
2501,
1007,
11618,
29296,
10288,
24422,
1063,
4638,
8663,
2078,
1006,
9530,
2078,
1007,
1025,
2065,
1006,
3074,
21823,
2140,
1012,
2003,
6633,
13876,
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... |
netty/netty | buffer/src/main/java/io/netty/buffer/Unpooled.java | Unpooled.wrappedBuffer | public static ByteBuf wrappedBuffer(ByteBuffer buffer) {
if (!buffer.hasRemaining()) {
return EMPTY_BUFFER;
}
if (!buffer.isDirect() && buffer.hasArray()) {
return wrappedBuffer(
buffer.array(),
buffer.arrayOffset() + buffer.position(),
buffer.remaining()).order(buffer.order());
} else if (PlatformDependent.hasUnsafe()) {
if (buffer.isReadOnly()) {
if (buffer.isDirect()) {
return new ReadOnlyUnsafeDirectByteBuf(ALLOC, buffer);
} else {
return new ReadOnlyByteBufferBuf(ALLOC, buffer);
}
} else {
return new UnpooledUnsafeDirectByteBuf(ALLOC, buffer, buffer.remaining());
}
} else {
if (buffer.isReadOnly()) {
return new ReadOnlyByteBufferBuf(ALLOC, buffer);
} else {
return new UnpooledDirectByteBuf(ALLOC, buffer, buffer.remaining());
}
}
} | java | public static ByteBuf wrappedBuffer(ByteBuffer buffer) {
if (!buffer.hasRemaining()) {
return EMPTY_BUFFER;
}
if (!buffer.isDirect() && buffer.hasArray()) {
return wrappedBuffer(
buffer.array(),
buffer.arrayOffset() + buffer.position(),
buffer.remaining()).order(buffer.order());
} else if (PlatformDependent.hasUnsafe()) {
if (buffer.isReadOnly()) {
if (buffer.isDirect()) {
return new ReadOnlyUnsafeDirectByteBuf(ALLOC, buffer);
} else {
return new ReadOnlyByteBufferBuf(ALLOC, buffer);
}
} else {
return new UnpooledUnsafeDirectByteBuf(ALLOC, buffer, buffer.remaining());
}
} else {
if (buffer.isReadOnly()) {
return new ReadOnlyByteBufferBuf(ALLOC, buffer);
} else {
return new UnpooledDirectByteBuf(ALLOC, buffer, buffer.remaining());
}
}
} | [
"public",
"static",
"ByteBuf",
"wrappedBuffer",
"(",
"ByteBuffer",
"buffer",
")",
"{",
"if",
"(",
"!",
"buffer",
".",
"hasRemaining",
"(",
")",
")",
"{",
"return",
"EMPTY_BUFFER",
";",
"}",
"if",
"(",
"!",
"buffer",
".",
"isDirect",
"(",
")",
"&&",
"bu... | Creates a new buffer which wraps the specified NIO buffer's current
slice. A modification on the specified buffer's content will be
visible to the returned buffer. | [
"Creates",
"a",
"new",
"buffer",
"which",
"wraps",
"the",
"specified",
"NIO",
"buffer",
"s",
"current",
"slice",
".",
"A",
"modification",
"on",
"the",
"specified",
"buffer",
"s",
"content",
"will",
"be",
"visible",
"to",
"the",
"returned",
"buffer",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/Unpooled.java#L182-L208 | train | Returns a ByteBuf that wraps the specified ByteBuffer. | [
30522,
2270,
10763,
24880,
8569,
2546,
5058,
8569,
12494,
1006,
24880,
8569,
12494,
17698,
1007,
1063,
2065,
1006,
999,
17698,
1012,
2038,
28578,
8113,
2075,
1006,
1007,
1007,
1063,
2709,
4064,
1035,
17698,
1025,
1065,
2065,
1006,
999,
1769... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/pattern/Pattern.java | Pattern.next | public GroupPattern<T, F> next(Pattern<T, F> group) {
return new GroupPattern<>(this, group, ConsumingStrategy.STRICT, afterMatchSkipStrategy);
} | java | public GroupPattern<T, F> next(Pattern<T, F> group) {
return new GroupPattern<>(this, group, ConsumingStrategy.STRICT, afterMatchSkipStrategy);
} | [
"public",
"GroupPattern",
"<",
"T",
",",
"F",
">",
"next",
"(",
"Pattern",
"<",
"T",
",",
"F",
">",
"group",
")",
"{",
"return",
"new",
"GroupPattern",
"<>",
"(",
"this",
",",
"group",
",",
"ConsumingStrategy",
".",
"STRICT",
",",
"afterMatchSkipStrategy... | Appends a new group pattern to the existing one. The new pattern enforces strict
temporal contiguity. This means that the whole pattern sequence matches only
if an event which matches this pattern directly follows the preceding matching
event. Thus, there cannot be any events in between two matching events.
@param group the pattern to append
@return A new pattern which is appended to this one | [
"Appends",
"a",
"new",
"group",
"pattern",
"to",
"the",
"existing",
"one",
".",
"The",
"new",
"pattern",
"enforces",
"strict",
"temporal",
"contiguity",
".",
"This",
"means",
"that",
"the",
"whole",
"pattern",
"sequence",
"matches",
"only",
"if",
"an",
"even... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java#L541-L543 | train | Returns a new pattern that matches the next pattern in the given pattern. | [
30522,
2270,
2177,
4502,
12079,
2078,
1026,
1056,
1010,
1042,
1028,
2279,
1006,
5418,
1026,
1056,
1010,
1042,
1028,
2177,
1007,
1063,
2709,
2047,
2177,
4502,
12079,
2078,
1026,
1028,
1006,
2023,
1010,
2177,
1010,
15077,
20528,
2618,
6292,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/network/messages/MessageSerializer.java | MessageSerializer.serializeRequestFailure | public static ByteBuf serializeRequestFailure(
final ByteBufAllocator alloc,
final long requestId,
final Throwable cause) throws IOException {
final ByteBuf buf = alloc.ioBuffer();
// Frame length is set at the end
buf.writeInt(0);
writeHeader(buf, MessageType.REQUEST_FAILURE);
buf.writeLong(requestId);
try (ByteBufOutputStream bbos = new ByteBufOutputStream(buf);
ObjectOutput out = new ObjectOutputStream(bbos)) {
out.writeObject(cause);
}
// Set frame length
int frameLength = buf.readableBytes() - Integer.BYTES;
buf.setInt(0, frameLength);
return buf;
} | java | public static ByteBuf serializeRequestFailure(
final ByteBufAllocator alloc,
final long requestId,
final Throwable cause) throws IOException {
final ByteBuf buf = alloc.ioBuffer();
// Frame length is set at the end
buf.writeInt(0);
writeHeader(buf, MessageType.REQUEST_FAILURE);
buf.writeLong(requestId);
try (ByteBufOutputStream bbos = new ByteBufOutputStream(buf);
ObjectOutput out = new ObjectOutputStream(bbos)) {
out.writeObject(cause);
}
// Set frame length
int frameLength = buf.readableBytes() - Integer.BYTES;
buf.setInt(0, frameLength);
return buf;
} | [
"public",
"static",
"ByteBuf",
"serializeRequestFailure",
"(",
"final",
"ByteBufAllocator",
"alloc",
",",
"final",
"long",
"requestId",
",",
"final",
"Throwable",
"cause",
")",
"throws",
"IOException",
"{",
"final",
"ByteBuf",
"buf",
"=",
"alloc",
".",
"ioBuffer",... | Serializes the exception containing the failure message sent to the
{@link org.apache.flink.queryablestate.network.Client} in case of
protocol related errors.
@param alloc The {@link ByteBufAllocator} used to allocate the buffer to serialize the message into.
@param requestId The id of the request to which the message refers to.
@param cause The exception thrown at the server.
@return A {@link ByteBuf} containing the serialized message. | [
"Serializes",
"the",
"exception",
"containing",
"the",
"failure",
"message",
"sent",
"to",
"the",
"{",
"@link",
"org",
".",
"apache",
".",
"flink",
".",
"queryablestate",
".",
"network",
".",
"Client",
"}",
"in",
"case",
"of",
"protocol",
"related",
"errors"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/network/messages/MessageSerializer.java#L126-L147 | train | Serialize a request failure exception. | [
30522,
2270,
10763,
24880,
8569,
2546,
7642,
17629,
2063,
15500,
7011,
4014,
5397,
1006,
2345,
24880,
8569,
13976,
24755,
4263,
2035,
10085,
1010,
2345,
2146,
5227,
3593,
1010,
2345,
5466,
3085,
3426,
1007,
11618,
22834,
10288,
24422,
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-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumerBase.java | FlinkKafkaConsumerBase.initializeState | @Override
public final void initializeState(FunctionInitializationContext context) throws Exception {
OperatorStateStore stateStore = context.getOperatorStateStore();
ListState<Tuple2<KafkaTopicPartition, Long>> oldRoundRobinListState =
stateStore.getSerializableListState(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME);
this.unionOffsetStates = stateStore.getUnionListState(new ListStateDescriptor<>(
OFFSETS_STATE_NAME,
TypeInformation.of(new TypeHint<Tuple2<KafkaTopicPartition, Long>>() {})));
if (context.isRestored() && !restoredFromOldState) {
restoredState = new TreeMap<>(new KafkaTopicPartition.Comparator());
// migrate from 1.2 state, if there is any
for (Tuple2<KafkaTopicPartition, Long> kafkaOffset : oldRoundRobinListState.get()) {
restoredFromOldState = true;
unionOffsetStates.add(kafkaOffset);
}
oldRoundRobinListState.clear();
if (restoredFromOldState && discoveryIntervalMillis != PARTITION_DISCOVERY_DISABLED) {
throw new IllegalArgumentException(
"Topic / partition discovery cannot be enabled if the job is restored from a savepoint from Flink 1.2.x.");
}
// populate actual holder for restored state
for (Tuple2<KafkaTopicPartition, Long> kafkaOffset : unionOffsetStates.get()) {
restoredState.put(kafkaOffset.f0, kafkaOffset.f1);
}
LOG.info("Setting restore state in the FlinkKafkaConsumer: {}", restoredState);
} else {
LOG.info("No restore state for FlinkKafkaConsumer.");
}
} | java | @Override
public final void initializeState(FunctionInitializationContext context) throws Exception {
OperatorStateStore stateStore = context.getOperatorStateStore();
ListState<Tuple2<KafkaTopicPartition, Long>> oldRoundRobinListState =
stateStore.getSerializableListState(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME);
this.unionOffsetStates = stateStore.getUnionListState(new ListStateDescriptor<>(
OFFSETS_STATE_NAME,
TypeInformation.of(new TypeHint<Tuple2<KafkaTopicPartition, Long>>() {})));
if (context.isRestored() && !restoredFromOldState) {
restoredState = new TreeMap<>(new KafkaTopicPartition.Comparator());
// migrate from 1.2 state, if there is any
for (Tuple2<KafkaTopicPartition, Long> kafkaOffset : oldRoundRobinListState.get()) {
restoredFromOldState = true;
unionOffsetStates.add(kafkaOffset);
}
oldRoundRobinListState.clear();
if (restoredFromOldState && discoveryIntervalMillis != PARTITION_DISCOVERY_DISABLED) {
throw new IllegalArgumentException(
"Topic / partition discovery cannot be enabled if the job is restored from a savepoint from Flink 1.2.x.");
}
// populate actual holder for restored state
for (Tuple2<KafkaTopicPartition, Long> kafkaOffset : unionOffsetStates.get()) {
restoredState.put(kafkaOffset.f0, kafkaOffset.f1);
}
LOG.info("Setting restore state in the FlinkKafkaConsumer: {}", restoredState);
} else {
LOG.info("No restore state for FlinkKafkaConsumer.");
}
} | [
"@",
"Override",
"public",
"final",
"void",
"initializeState",
"(",
"FunctionInitializationContext",
"context",
")",
"throws",
"Exception",
"{",
"OperatorStateStore",
"stateStore",
"=",
"context",
".",
"getOperatorStateStore",
"(",
")",
";",
"ListState",
"<",
"Tuple2"... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumerBase.java#L848-L884 | train | Initialize the state of the FlinkKafkaConsumer. | [
30522,
1030,
2058,
15637,
2270,
2345,
11675,
3988,
10057,
12259,
1006,
3853,
5498,
20925,
3989,
8663,
18209,
6123,
1007,
11618,
6453,
1063,
9224,
12259,
23809,
2063,
2163,
19277,
1027,
6123,
1012,
2131,
25918,
18926,
12259,
23809,
2063,
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/spark | sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/SQLOperation.java | SQLOperation.getCurrentUGI | private UserGroupInformation getCurrentUGI(HiveConf opConfig) throws HiveSQLException {
try {
return Utils.getUGI();
} catch (Exception e) {
throw new HiveSQLException("Unable to get current user", e);
}
} | java | private UserGroupInformation getCurrentUGI(HiveConf opConfig) throws HiveSQLException {
try {
return Utils.getUGI();
} catch (Exception e) {
throw new HiveSQLException("Unable to get current user", e);
}
} | [
"private",
"UserGroupInformation",
"getCurrentUGI",
"(",
"HiveConf",
"opConfig",
")",
"throws",
"HiveSQLException",
"{",
"try",
"{",
"return",
"Utils",
".",
"getUGI",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"HiveSQLExcepti... | Returns the current UGI on the stack
@param opConfig
@return UserGroupInformation
@throws HiveSQLException | [
"Returns",
"the",
"current",
"UGI",
"on",
"the",
"stack"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/SQLOperation.java#L255-L261 | train | Get the UserGroupInformation for the current user | [
30522,
2797,
5310,
17058,
2378,
14192,
3370,
2131,
10841,
14343,
3372,
15916,
2072,
1006,
26736,
8663,
2546,
6728,
8663,
8873,
2290,
1007,
11618,
26736,
2015,
4160,
2571,
2595,
24422,
1063,
3046,
1063,
2709,
21183,
12146,
1012,
2131,
15916,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/reactive/context/ReactiveWebServerApplicationContext.java | ReactiveWebServerApplicationContext.getHttpHandler | protected HttpHandler getHttpHandler() {
// Use bean names so that we don't consider the hierarchy
String[] beanNames = getBeanFactory().getBeanNamesForType(HttpHandler.class);
if (beanNames.length == 0) {
throw new ApplicationContextException(
"Unable to start ReactiveWebApplicationContext due to missing HttpHandler bean.");
}
if (beanNames.length > 1) {
throw new ApplicationContextException(
"Unable to start ReactiveWebApplicationContext due to multiple HttpHandler beans : "
+ StringUtils.arrayToCommaDelimitedString(beanNames));
}
return getBeanFactory().getBean(beanNames[0], HttpHandler.class);
} | java | protected HttpHandler getHttpHandler() {
// Use bean names so that we don't consider the hierarchy
String[] beanNames = getBeanFactory().getBeanNamesForType(HttpHandler.class);
if (beanNames.length == 0) {
throw new ApplicationContextException(
"Unable to start ReactiveWebApplicationContext due to missing HttpHandler bean.");
}
if (beanNames.length > 1) {
throw new ApplicationContextException(
"Unable to start ReactiveWebApplicationContext due to multiple HttpHandler beans : "
+ StringUtils.arrayToCommaDelimitedString(beanNames));
}
return getBeanFactory().getBean(beanNames[0], HttpHandler.class);
} | [
"protected",
"HttpHandler",
"getHttpHandler",
"(",
")",
"{",
"// Use bean names so that we don't consider the hierarchy",
"String",
"[",
"]",
"beanNames",
"=",
"getBeanFactory",
"(",
")",
".",
"getBeanNamesForType",
"(",
"HttpHandler",
".",
"class",
")",
";",
"if",
"(... | Return the {@link HttpHandler} that should be used to process the reactive web
server. By default this method searches for a suitable bean in the context itself.
@return a {@link HttpHandler} (never {@code null} | [
"Return",
"the",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContext.java#L155-L168 | train | Get the HttpHandler instance. | [
30522,
5123,
8299,
11774,
3917,
2131,
11039,
25856,
11774,
3917,
1006,
1007,
1063,
1013,
1013,
2224,
14068,
3415,
2061,
2008,
2057,
2123,
1005,
1056,
5136,
1996,
12571,
5164,
1031,
1033,
14068,
18442,
2015,
1027,
2131,
4783,
2319,
21450,
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/codec/Base64.java | Base64.decodeStr | public static String decodeStr(String source, String charset) {
return Base64Decoder.decodeStr(source, charset);
} | java | public static String decodeStr(String source, String charset) {
return Base64Decoder.decodeStr(source, charset);
} | [
"public",
"static",
"String",
"decodeStr",
"(",
"String",
"source",
",",
"String",
"charset",
")",
"{",
"return",
"Base64Decoder",
".",
"decodeStr",
"(",
"source",
",",
"charset",
")",
";",
"}"
] | base64解码
@param source 被解码的base64字符串
@param charset 字符集
@return 被加密后的字符串 | [
"base64解码"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/codec/Base64.java#L266-L268 | train | Decodes a base64 string. | [
30522,
2270,
10763,
5164,
21933,
6155,
16344,
1006,
5164,
3120,
1010,
5164,
25869,
13462,
1007,
1063,
2709,
2918,
21084,
3207,
16044,
2099,
1012,
21933,
6155,
16344,
1006,
3120,
1010,
25869,
13462,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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/dependency/nnparser/util/PosTagUtil.java | PosTagUtil.to863 | public static List<String> to863(List<Term> termList)
{
List<String> posTagList = new ArrayList<String>(termList.size());
for (Term term : termList)
{
String posTag = posConverter.get(term.nature.toString());
if (posTag == null)
posTag = term.nature.toString();
posTagList.add(posTag);
}
return posTagList;
} | java | public static List<String> to863(List<Term> termList)
{
List<String> posTagList = new ArrayList<String>(termList.size());
for (Term term : termList)
{
String posTag = posConverter.get(term.nature.toString());
if (posTag == null)
posTag = term.nature.toString();
posTagList.add(posTag);
}
return posTagList;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"to863",
"(",
"List",
"<",
"Term",
">",
"termList",
")",
"{",
"List",
"<",
"String",
">",
"posTagList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"termList",
".",
"size",
"(",
")",
")",
";",
"... | 转为863标注集<br>
863词性标注集,其各个词性含义如下表:
<p>
Tag Description Example Tag Description Example
a adjective 美丽 ni organization name 保险公司
b other noun-modifier 大型, 西式 nl location noun 城郊
c conjunction 和, 虽然 ns geographical name 北京
d adverb 很 nt temporal noun 近日, 明代
e exclamation 哎 nz other proper noun 诺贝尔奖
g morpheme 茨, 甥 o onomatopoeia 哗啦
h prefix 阿, 伪 p preposition 在, 把
i idiom 百花齐放 q quantity 个
j abbreviation 公检法 r pronoun 我们
k suffix 界, 率 u auxiliary 的, 地
m number 一, 第一 v verb 跑, 学习
n general noun 苹果 wp punctuation ,。!
nd direction noun 右侧 ws foreign words CPU
nh person name 杜甫, 汤姆 x non-lexeme 萄, 翱
@param termList
@return | [
"转为863标注集<br",
">",
"863词性标注集,其各个词性含义如下表:",
"<p",
">",
"Tag",
"Description",
"Example",
"Tag",
"Description",
"Example",
"a",
"adjective",
"美丽",
"ni",
"organization",
"name",
"保险公司",
"b",
"other",
"noun",
"-",
"modifier",
"大型",
"西式",
"nl",
"location",
"noun",
... | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dependency/nnparser/util/PosTagUtil.java#L187-L199 | train | To 863 List of Terms | [
30522,
2270,
10763,
2862,
1026,
5164,
1028,
2000,
20842,
2509,
1006,
2862,
1026,
2744,
1028,
2744,
9863,
1007,
1063,
2862,
1026,
5164,
1028,
2695,
8490,
9863,
1027,
2047,
9140,
9863,
1026,
5164,
1028,
1006,
2744,
9863,
1012,
2946,
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... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java | ExpectedConditions.textMatches | public static ExpectedCondition<Boolean> textMatches(final By locator, final Pattern pattern) {
return new ExpectedCondition<Boolean>() {
private String currentValue = null;
@Override
public Boolean apply(WebDriver driver) {
try {
currentValue = driver.findElement(locator).getText();
return pattern.matcher(currentValue).find();
} catch (Exception e) {
return false;
}
}
@Override
public String toString() {
return String
.format("text found by %s to match pattern \"%s\". Current text: \"%s\"",
locator, pattern.pattern(), currentValue);
}
};
} | java | public static ExpectedCondition<Boolean> textMatches(final By locator, final Pattern pattern) {
return new ExpectedCondition<Boolean>() {
private String currentValue = null;
@Override
public Boolean apply(WebDriver driver) {
try {
currentValue = driver.findElement(locator).getText();
return pattern.matcher(currentValue).find();
} catch (Exception e) {
return false;
}
}
@Override
public String toString() {
return String
.format("text found by %s to match pattern \"%s\". Current text: \"%s\"",
locator, pattern.pattern(), currentValue);
}
};
} | [
"public",
"static",
"ExpectedCondition",
"<",
"Boolean",
">",
"textMatches",
"(",
"final",
"By",
"locator",
",",
"final",
"Pattern",
"pattern",
")",
"{",
"return",
"new",
"ExpectedCondition",
"<",
"Boolean",
">",
"(",
")",
"{",
"private",
"String",
"currentVal... | An expectation for checking WebElement with given locator has text with a value as a part of
it
@param locator used to find the element
@param pattern used as expected text matcher pattern
@return Boolean true when element has text value containing @value | [
"An",
"expectation",
"for",
"checking",
"WebElement",
"with",
"given",
"locator",
"has",
"text",
"with",
"a",
"value",
"as",
"a",
"part",
"of",
"it"
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java#L930-L951 | train | An expectation for checking WebElement s text matches a given pattern. | [
30522,
2270,
10763,
3517,
8663,
20562,
1026,
22017,
20898,
1028,
3793,
18900,
8376,
1006,
2345,
2011,
8840,
11266,
2953,
1010,
2345,
5418,
5418,
1007,
1063,
2709,
2047,
3517,
8663,
20562,
1026,
22017,
20898,
1028,
1006,
1007,
1063,
2797,
51... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-log/src/main/java/cn/hutool/log/StaticLog.java | StaticLog.error | public static void error(Log log, String format, Object... arguments) {
error(log, null, format, arguments);
} | java | public static void error(Log log, String format, Object... arguments) {
error(log, null, format, arguments);
} | [
"public",
"static",
"void",
"error",
"(",
"Log",
"log",
",",
"String",
"format",
",",
"Object",
"...",
"arguments",
")",
"{",
"error",
"(",
"log",
",",
"null",
",",
"format",
",",
"arguments",
")",
";",
"}"
] | Error等级日志<br>
@param log 日志对象
@param format 格式文本,{} 代表变量
@param arguments 变量对应的参数 | [
"Error等级日志<br",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-log/src/main/java/cn/hutool/log/StaticLog.java#L195-L197 | train | Logs an error message with the specified parameters. | [
30522,
2270,
10763,
11675,
7561,
1006,
8833,
8833,
1010,
5164,
4289,
1010,
4874,
1012,
1012,
1012,
9918,
1007,
1063,
7561,
1006,
8833,
1010,
19701,
1010,
4289,
1010,
9918,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/network/messages/MessageSerializer.java | MessageSerializer.deserializeRequest | public REQ deserializeRequest(final ByteBuf buf) {
Preconditions.checkNotNull(buf);
return requestDeserializer.deserializeMessage(buf);
} | java | public REQ deserializeRequest(final ByteBuf buf) {
Preconditions.checkNotNull(buf);
return requestDeserializer.deserializeMessage(buf);
} | [
"public",
"REQ",
"deserializeRequest",
"(",
"final",
"ByteBuf",
"buf",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"buf",
")",
";",
"return",
"requestDeserializer",
".",
"deserializeMessage",
"(",
"buf",
")",
";",
"}"
] | De-serializes the request sent to the
{@link org.apache.flink.queryablestate.network.AbstractServerBase}.
<pre>
<b>The buffer is expected to be at the request position.</b>
</pre>
@param buf The {@link ByteBuf} containing the serialized request.
@return The request. | [
"De",
"-",
"serializes",
"the",
"request",
"sent",
"to",
"the",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/network/messages/MessageSerializer.java#L264-L267 | train | Deserialize a request from a ByteBuf. | [
30522,
2270,
2128,
4160,
4078,
11610,
28863,
2063,
15500,
1006,
2345,
24880,
8569,
2546,
20934,
2546,
1007,
1063,
3653,
8663,
20562,
2015,
1012,
4638,
17048,
11231,
3363,
1006,
20934,
2546,
1007,
1025,
2709,
5227,
6155,
11610,
28863,
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-setting/src/main/java/cn/hutool/setting/SettingLoader.java | SettingLoader.load | public boolean load(UrlResource urlResource) {
if (urlResource == null) {
throw new NullPointerException("Null setting url define!");
}
log.debug("Load setting file [{}]", urlResource);
InputStream settingStream = null;
try {
settingStream = urlResource.getStream();
load(settingStream);
} catch (Exception e) {
log.error(e, "Load setting error!");
return false;
} finally {
IoUtil.close(settingStream);
}
return true;
} | java | public boolean load(UrlResource urlResource) {
if (urlResource == null) {
throw new NullPointerException("Null setting url define!");
}
log.debug("Load setting file [{}]", urlResource);
InputStream settingStream = null;
try {
settingStream = urlResource.getStream();
load(settingStream);
} catch (Exception e) {
log.error(e, "Load setting error!");
return false;
} finally {
IoUtil.close(settingStream);
}
return true;
} | [
"public",
"boolean",
"load",
"(",
"UrlResource",
"urlResource",
")",
"{",
"if",
"(",
"urlResource",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Null setting url define!\"",
")",
";",
"}",
"log",
".",
"debug",
"(",
"\"Load setting file... | 加载设置文件
@param urlResource 配置文件URL
@return 加载是否成功 | [
"加载设置文件"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/SettingLoader.java#L76-L92 | train | Loads a setting from the specified URL resource. | [
30522,
2270,
22017,
20898,
7170,
1006,
24471,
20974,
2229,
8162,
3401,
24471,
20974,
2229,
8162,
3401,
1007,
1063,
2065,
1006,
24471,
20974,
2229,
8162,
3401,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
19701,
8400,
7869,
2595,
24422,
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... |
redisson/redisson | redisson/src/main/java/org/redisson/pubsub/PubSubConnectionEntry.java | PubSubConnectionEntry.removeListener | public boolean removeListener(ChannelName channelName, EventListener msgListener) {
Queue<RedisPubSubListener<?>> listeners = channelListeners.get(channelName);
for (RedisPubSubListener<?> listener : listeners) {
if (listener instanceof PubSubMessageListener) {
if (((PubSubMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}
}
if (listener instanceof PubSubPatternMessageListener) {
if (((PubSubPatternMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}
}
}
return false;
} | java | public boolean removeListener(ChannelName channelName, EventListener msgListener) {
Queue<RedisPubSubListener<?>> listeners = channelListeners.get(channelName);
for (RedisPubSubListener<?> listener : listeners) {
if (listener instanceof PubSubMessageListener) {
if (((PubSubMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}
}
if (listener instanceof PubSubPatternMessageListener) {
if (((PubSubPatternMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}
}
}
return false;
} | [
"public",
"boolean",
"removeListener",
"(",
"ChannelName",
"channelName",
",",
"EventListener",
"msgListener",
")",
"{",
"Queue",
"<",
"RedisPubSubListener",
"<",
"?",
">",
">",
"listeners",
"=",
"channelListeners",
".",
"get",
"(",
"channelName",
")",
";",
"for... | TODO optimize | [
"TODO",
"optimize"
] | d3acc0249b2d5d658d36d99e2c808ce49332ea44 | https://github.com/redisson/redisson/blob/d3acc0249b2d5d658d36d99e2c808ce49332ea44/redisson/src/main/java/org/redisson/pubsub/PubSubConnectionEntry.java#L111-L128 | train | Removes a listener for a specific channel. | [
30522,
2270,
22017,
20898,
6366,
9863,
24454,
1006,
3149,
18442,
3149,
18442,
1010,
2724,
9863,
24454,
5796,
25394,
16173,
2121,
1007,
1063,
24240,
1026,
2417,
2483,
14289,
5910,
12083,
9863,
24454,
1026,
1029,
1028,
1028,
13810,
1027,
3149,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DateTime.java | DateTime.toCalendar | public Calendar toCalendar(TimeZone zone, Locale locale) {
if (null == locale) {
locale = Locale.getDefault(Locale.Category.FORMAT);
}
final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale);
cal.setFirstDayOfWeek(firstDayOfWeek.getValue());
cal.setTime(this);
return cal;
} | java | public Calendar toCalendar(TimeZone zone, Locale locale) {
if (null == locale) {
locale = Locale.getDefault(Locale.Category.FORMAT);
}
final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale);
cal.setFirstDayOfWeek(firstDayOfWeek.getValue());
cal.setTime(this);
return cal;
} | [
"public",
"Calendar",
"toCalendar",
"(",
"TimeZone",
"zone",
",",
"Locale",
"locale",
")",
"{",
"if",
"(",
"null",
"==",
"locale",
")",
"{",
"locale",
"=",
"Locale",
".",
"getDefault",
"(",
"Locale",
".",
"Category",
".",
"FORMAT",
")",
";",
"}",
"fina... | 转换为Calendar
@param zone 时区 {@link TimeZone}
@param locale 地域 {@link Locale}
@return {@link Calendar} | [
"转换为Calendar"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateTime.java#L541-L549 | train | Converts this object to a calendar object. | [
30522,
2270,
8094,
2000,
9289,
10497,
2906,
1006,
2051,
15975,
4224,
1010,
2334,
2063,
2334,
2063,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
2334,
2063,
1007,
1063,
2334,
2063,
1027,
2334,
2063,
1012,
2131,
3207,
7011,
11314,
1006,
2334,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ReferenceCountUtil.java | ReferenceCountUtil.safeRelease | public static void safeRelease(Object msg, int decrement) {
try {
release(msg, decrement);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to release a message: {} (decrement: {})", msg, decrement, t);
}
}
} | java | public static void safeRelease(Object msg, int decrement) {
try {
release(msg, decrement);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to release a message: {} (decrement: {})", msg, decrement, t);
}
}
} | [
"public",
"static",
"void",
"safeRelease",
"(",
"Object",
"msg",
",",
"int",
"decrement",
")",
"{",
"try",
"{",
"release",
"(",
"msg",
",",
"decrement",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"logger",
".",
"isWarnEnabled",... | Try to call {@link ReferenceCounted#release(int)} if the specified message implements {@link ReferenceCounted}.
If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
Unlike {@link #release(Object)} this method catches an exception raised by {@link ReferenceCounted#release(int)}
and logs it, rather than rethrowing it to the caller. It is usually recommended to use
{@link #release(Object, int)} instead, unless you absolutely need to swallow an exception. | [
"Try",
"to",
"call",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/ReferenceCountUtil.java#L126-L134 | train | Release a message. | [
30522,
2270,
10763,
11675,
13726,
12260,
11022,
1006,
4874,
5796,
2290,
1010,
20014,
30524,
3085,
1056,
1007,
1063,
2065,
1006,
8833,
4590,
1012,
2003,
9028,
10224,
3085,
2094,
1006,
1007,
1007,
1063,
8833,
4590,
1012,
11582,
1006,
1000,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/NetUtil.java | NetUtil.toSocketAddressString | public static String toSocketAddressString(String host, int port) {
String portStr = String.valueOf(port);
return newSocketAddressStringBuilder(
host, portStr, !isValidIpV6Address(host)).append(':').append(portStr).toString();
} | java | public static String toSocketAddressString(String host, int port) {
String portStr = String.valueOf(port);
return newSocketAddressStringBuilder(
host, portStr, !isValidIpV6Address(host)).append(':').append(portStr).toString();
} | [
"public",
"static",
"String",
"toSocketAddressString",
"(",
"String",
"host",
",",
"int",
"port",
")",
"{",
"String",
"portStr",
"=",
"String",
".",
"valueOf",
"(",
"port",
")",
";",
"return",
"newSocketAddressStringBuilder",
"(",
"host",
",",
"portStr",
",",
... | Returns the {@link String} representation of a host port combo. | [
"Returns",
"the",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/NetUtil.java#L957-L961 | train | Converts a host name and port number into a string. | [
30522,
2270,
10763,
5164,
2000,
6499,
19869,
17713,
16200,
4757,
3367,
4892,
1006,
5164,
3677,
1010,
20014,
3417,
1007,
1063,
5164,
8831,
16344,
1027,
5164,
1012,
3643,
11253,
1006,
3417,
1007,
1025,
2709,
2739,
7432,
12928,
14141,
8303,
33... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/BooleanUtil.java | BooleanUtil.toBoolean | public static boolean toBoolean(String valueStr) {
if (StrUtil.isNotBlank(valueStr)) {
valueStr = valueStr.trim().toLowerCase();
if (ArrayUtil.contains(TRUE_ARRAY, valueStr)) {
return true;
}
}
return false;
} | java | public static boolean toBoolean(String valueStr) {
if (StrUtil.isNotBlank(valueStr)) {
valueStr = valueStr.trim().toLowerCase();
if (ArrayUtil.contains(TRUE_ARRAY, valueStr)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"toBoolean",
"(",
"String",
"valueStr",
")",
"{",
"if",
"(",
"StrUtil",
".",
"isNotBlank",
"(",
"valueStr",
")",
")",
"{",
"valueStr",
"=",
"valueStr",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
... | 转换字符串为boolean值
@param valueStr 字符串
@return boolean值 | [
"转换字符串为boolean值"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/BooleanUtil.java#L77-L85 | train | Converts a string to a boolean. | [
30522,
2270,
10763,
22017,
20898,
2000,
5092,
9890,
2319,
1006,
5164,
5300,
16344,
1007,
1063,
2065,
1006,
2358,
22134,
4014,
1012,
3475,
4140,
28522,
8950,
1006,
5300,
16344,
1007,
1007,
1063,
5300,
16344,
1027,
5300,
16344,
1012,
12241,
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 | launcher/src/main/java/org/apache/spark/launcher/AbstractCommandBuilder.java | AbstractCommandBuilder.loadPropertiesFile | private Properties loadPropertiesFile() throws IOException {
Properties props = new Properties();
File propsFile;
if (propertiesFile != null) {
propsFile = new File(propertiesFile);
checkArgument(propsFile.isFile(), "Invalid properties file '%s'.", propertiesFile);
} else {
propsFile = new File(getConfDir(), DEFAULT_PROPERTIES_FILE);
}
if (propsFile.isFile()) {
try (InputStreamReader isr = new InputStreamReader(
new FileInputStream(propsFile), StandardCharsets.UTF_8)) {
props.load(isr);
for (Map.Entry<Object, Object> e : props.entrySet()) {
e.setValue(e.getValue().toString().trim());
}
}
}
return props;
} | java | private Properties loadPropertiesFile() throws IOException {
Properties props = new Properties();
File propsFile;
if (propertiesFile != null) {
propsFile = new File(propertiesFile);
checkArgument(propsFile.isFile(), "Invalid properties file '%s'.", propertiesFile);
} else {
propsFile = new File(getConfDir(), DEFAULT_PROPERTIES_FILE);
}
if (propsFile.isFile()) {
try (InputStreamReader isr = new InputStreamReader(
new FileInputStream(propsFile), StandardCharsets.UTF_8)) {
props.load(isr);
for (Map.Entry<Object, Object> e : props.entrySet()) {
e.setValue(e.getValue().toString().trim());
}
}
}
return props;
} | [
"private",
"Properties",
"loadPropertiesFile",
"(",
")",
"throws",
"IOException",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"File",
"propsFile",
";",
"if",
"(",
"propertiesFile",
"!=",
"null",
")",
"{",
"propsFile",
"=",
"new",
"Fi... | Loads the configuration file for the application, if it exists. This is either the
user-specified properties file, or the spark-defaults.conf file under the Spark configuration
directory. | [
"Loads",
"the",
"configuration",
"file",
"for",
"the",
"application",
"if",
"it",
"exists",
".",
"This",
"is",
"either",
"the",
"user",
"-",
"specified",
"properties",
"file",
"or",
"the",
"spark",
"-",
"defaults",
".",
"conf",
"file",
"under",
"the",
"Spa... | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/launcher/src/main/java/org/apache/spark/launcher/AbstractCommandBuilder.java#L291-L311 | train | Load the properties file. | [
30522,
2797,
5144,
7170,
21572,
4842,
7368,
8873,
2571,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
5144,
24387,
1027,
2047,
5144,
1006,
1007,
1025,
5371,
24387,
8873,
2571,
1025,
2065,
1006,
5144,
8873,
2571,
999,
1027,
19701,
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... |
spring-projects/spring-boot | spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java | ConfigurationMetadata.merge | public void merge(ConfigurationMetadata metadata) {
for (ItemMetadata additionalItem : metadata.getItems()) {
mergeItemMetadata(additionalItem);
}
for (ItemHint itemHint : metadata.getHints()) {
add(itemHint);
}
} | java | public void merge(ConfigurationMetadata metadata) {
for (ItemMetadata additionalItem : metadata.getItems()) {
mergeItemMetadata(additionalItem);
}
for (ItemHint itemHint : metadata.getHints()) {
add(itemHint);
}
} | [
"public",
"void",
"merge",
"(",
"ConfigurationMetadata",
"metadata",
")",
"{",
"for",
"(",
"ItemMetadata",
"additionalItem",
":",
"metadata",
".",
"getItems",
"(",
")",
")",
"{",
"mergeItemMetadata",
"(",
"additionalItem",
")",
";",
"}",
"for",
"(",
"ItemHint"... | Merge the content from another {@link ConfigurationMetadata}.
@param metadata the {@link ConfigurationMetadata} instance to merge | [
"Merge",
"the",
"content",
"from",
"another",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java#L80-L87 | train | Merge the given configuration metadata into this one. | [
30522,
2270,
11675,
13590,
1006,
9563,
11368,
8447,
2696,
27425,
1007,
1063,
2005,
1006,
8875,
11368,
8447,
2696,
3176,
4221,
2213,
1024,
27425,
1012,
2131,
4221,
5244,
1006,
1007,
1007,
1063,
13590,
4221,
20058,
17713,
6790,
1006,
3176,
42... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/template/engine/freemarker/FreemarkerEngine.java | FreemarkerEngine.getTemplate | @Override
public Template getTemplate(String resource) {
try {
return FreemarkerTemplate.wrap(this.cfg.getTemplate(resource));
} catch(IOException e) {
throw new IORuntimeException(e);
}catch (Exception e) {
throw new TemplateException(e);
}
} | java | @Override
public Template getTemplate(String resource) {
try {
return FreemarkerTemplate.wrap(this.cfg.getTemplate(resource));
} catch(IOException e) {
throw new IORuntimeException(e);
}catch (Exception e) {
throw new TemplateException(e);
}
} | [
"@",
"Override",
"public",
"Template",
"getTemplate",
"(",
"String",
"resource",
")",
"{",
"try",
"{",
"return",
"FreemarkerTemplate",
".",
"wrap",
"(",
"this",
".",
"cfg",
".",
"getTemplate",
"(",
"resource",
")",
")",
";",
"}",
"catch",
"(",
"IOException... | --------------------------------------------------------------------------------- Constructor end | [
"---------------------------------------------------------------------------------",
"Constructor",
"end"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/freemarker/FreemarkerEngine.java#L52-L61 | train | Override the default implementation to get the Template object for a given resource. | [
30522,
1030,
2058,
15637,
2270,
23561,
2131,
18532,
15725,
1006,
5164,
7692,
1007,
30524,
1006,
2023,
1012,
12935,
2290,
1012,
2131,
18532,
15725,
1006,
7692,
1007,
1007,
1025,
1065,
4608,
1006,
22834,
10288,
24422,
1041,
1007,
1063,
5466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/IoUtil.java | IoUtil.toMarkSupportStream | public static InputStream toMarkSupportStream(InputStream in) {
if (null == in) {
return null;
}
if (false == in.markSupported()) {
return new BufferedInputStream(in);
}
return in;
} | java | public static InputStream toMarkSupportStream(InputStream in) {
if (null == in) {
return null;
}
if (false == in.markSupported()) {
return new BufferedInputStream(in);
}
return in;
} | [
"public",
"static",
"InputStream",
"toMarkSupportStream",
"(",
"InputStream",
"in",
")",
"{",
"if",
"(",
"null",
"==",
"in",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"false",
"==",
"in",
".",
"markSupported",
"(",
")",
")",
"{",
"return",
"new"... | 将{@link InputStream}转换为支持mark标记的流<br>
若原流支持mark标记,则返回原流,否则使用{@link BufferedInputStream} 包装之
@param in 流
@return {@link InputStream}
@since 4.0.9 | [
"将",
"{",
"@link",
"InputStream",
"}",
"转换为支持mark标记的流<br",
">",
"若原流支持mark标记,则返回原流,否则使用",
"{",
"@link",
"BufferedInputStream",
"}",
"包装之"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java#L826-L834 | train | Returns a stream that can be used to mark the input stream as if it is not markSupported. | [
30522,
2270,
10763,
20407,
25379,
3419,
17007,
6342,
9397,
11589,
21422,
1006,
20407,
25379,
1999,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1999,
1007,
1063,
2709,
19701,
1025,
1065,
2065,
1006,
6270,
1027,
1027,
1999,
1012,
6017,
6279,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getUlong64 | public final BigInteger getUlong64() {
final long long64 = getLong64();
return (long64 >= 0) ? BigInteger.valueOf(long64) : BIGINT_MAX_VALUE.add(BigInteger.valueOf(1 + long64));
} | java | public final BigInteger getUlong64() {
final long long64 = getLong64();
return (long64 >= 0) ? BigInteger.valueOf(long64) : BIGINT_MAX_VALUE.add(BigInteger.valueOf(1 + long64));
} | [
"public",
"final",
"BigInteger",
"getUlong64",
"(",
")",
"{",
"final",
"long",
"long64",
"=",
"getLong64",
"(",
")",
";",
"return",
"(",
"long64",
">=",
"0",
")",
"?",
"BigInteger",
".",
"valueOf",
"(",
"long64",
")",
":",
"BIGINT_MAX_VALUE",
".",
"add",... | Return next 64-bit unsigned long from buffer. (little-endian)
@see mysql-5.1.60/include/my_global.h - uint8korr | [
"Return",
"next",
"64",
"-",
"bit",
"unsigned",
"long",
"from",
"buffer",
".",
"(",
"little",
"-",
"endian",
")"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L930-L934 | train | Gets the ulong64 value. | [
30522,
2270,
2345,
2502,
18447,
26320,
2131,
18845,
3070,
21084,
1006,
1007,
1063,
2345,
2146,
2146,
21084,
1027,
2131,
10052,
21084,
1006,
1007,
1025,
2709,
1006,
2146,
21084,
1028,
1027,
1014,
1007,
1029,
2502,
18447,
26320,
1012,
3643,
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... |
netty/netty | transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtProvider.java | NioUdtProvider.newAcceptorChannelUDT | static ServerSocketChannelUDT newAcceptorChannelUDT(
final TypeUDT type) {
try {
return SelectorProviderUDT.from(type).openServerSocketChannel();
} catch (final IOException e) {
throw new ChannelException("failed to open a server socket channel", e);
}
} | java | static ServerSocketChannelUDT newAcceptorChannelUDT(
final TypeUDT type) {
try {
return SelectorProviderUDT.from(type).openServerSocketChannel();
} catch (final IOException e) {
throw new ChannelException("failed to open a server socket channel", e);
}
} | [
"static",
"ServerSocketChannelUDT",
"newAcceptorChannelUDT",
"(",
"final",
"TypeUDT",
"type",
")",
"{",
"try",
"{",
"return",
"SelectorProviderUDT",
".",
"from",
"(",
"type",
")",
".",
"openServerSocketChannel",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOExce... | Convenience factory for {@link KindUDT#ACCEPTOR} channels. | [
"Convenience",
"factory",
"for",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtProvider.java#L136-L143 | train | New acceptor channel udt. | [
30522,
10763,
14903,
7432,
3388,
26058,
6784,
2102,
2047,
6305,
3401,
13876,
2953,
26058,
6784,
2102,
1006,
2345,
2828,
6784,
2102,
2828,
1007,
1063,
3046,
1063,
2709,
27000,
21572,
17258,
2121,
6784,
2102,
1012,
2013,
1006,
2828,
1007,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Graph.java | Graph.run | public <T> GraphAnalytic<K, VV, EV, T> run(GraphAnalytic<K, VV, EV, T> analytic) throws Exception {
analytic.run(this);
return analytic;
} | java | public <T> GraphAnalytic<K, VV, EV, T> run(GraphAnalytic<K, VV, EV, T> analytic) throws Exception {
analytic.run(this);
return analytic;
} | [
"public",
"<",
"T",
">",
"GraphAnalytic",
"<",
"K",
",",
"VV",
",",
"EV",
",",
"T",
">",
"run",
"(",
"GraphAnalytic",
"<",
"K",
",",
"VV",
",",
"EV",
",",
"T",
">",
"analytic",
")",
"throws",
"Exception",
"{",
"analytic",
".",
"run",
"(",
"this",... | A {@code GraphAnalytic} is similar to a {@link GraphAlgorithm} but is terminal
and results are retrieved via accumulators. A Flink program has a single
point of execution. A {@code GraphAnalytic} defers execution to the user to
allow composing multiple analytics and algorithms into a single program.
@param analytic the analytic to run on the Graph
@param <T> the result type
@throws Exception | [
"A",
"{",
"@code",
"GraphAnalytic",
"}",
"is",
"similar",
"to",
"a",
"{",
"@link",
"GraphAlgorithm",
"}",
"but",
"is",
"terminal",
"and",
"results",
"are",
"retrieved",
"via",
"accumulators",
".",
"A",
"Flink",
"program",
"has",
"a",
"single",
"point",
"of... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/Graph.java#L1875-L1878 | train | Run the graph analytic. | [
30522,
2270,
1026,
1056,
1028,
10629,
27953,
21252,
1026,
1047,
1010,
1058,
2615,
1010,
23408,
1010,
1056,
1028,
2448,
1006,
10629,
27953,
21252,
1026,
1047,
1010,
1058,
2615,
1010,
23408,
1010,
1056,
1028,
23521,
1007,
11618,
6453,
1063,
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... |
apache/flink | flink-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/network/messages/MessageSerializer.java | MessageSerializer.serializeResponse | public static <RESP extends MessageBody> ByteBuf serializeResponse(
final ByteBufAllocator alloc,
final long requestId,
final RESP response) {
Preconditions.checkNotNull(response);
return writePayload(alloc, requestId, MessageType.REQUEST_RESULT, response.serialize());
} | java | public static <RESP extends MessageBody> ByteBuf serializeResponse(
final ByteBufAllocator alloc,
final long requestId,
final RESP response) {
Preconditions.checkNotNull(response);
return writePayload(alloc, requestId, MessageType.REQUEST_RESULT, response.serialize());
} | [
"public",
"static",
"<",
"RESP",
"extends",
"MessageBody",
">",
"ByteBuf",
"serializeResponse",
"(",
"final",
"ByteBufAllocator",
"alloc",
",",
"final",
"long",
"requestId",
",",
"final",
"RESP",
"response",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"... | Serializes the response sent to the
{@link org.apache.flink.queryablestate.network.Client}.
@param alloc The {@link ByteBufAllocator} used to allocate the buffer to serialize the message into.
@param requestId The id of the request to which the message refers to.
@param response The response to be serialized.
@return A {@link ByteBuf} containing the serialized message. | [
"Serializes",
"the",
"response",
"sent",
"to",
"the",
"{",
"@link",
"org",
".",
"apache",
".",
"flink",
".",
"queryablestate",
".",
"network",
".",
"Client",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/network/messages/MessageSerializer.java#L108-L114 | train | Serializes a response message. | [
30522,
2270,
10763,
1026,
24501,
2361,
8908,
4471,
23684,
1028,
24880,
8569,
2546,
7642,
17629,
2229,
26029,
3366,
1006,
2345,
24880,
8569,
13976,
24755,
4263,
2035,
10085,
1010,
2345,
2146,
5227,
3593,
1010,
2345,
24501,
2361,
3433,
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-runtime/src/main/java/org/apache/flink/runtime/state/DefaultOperatorStateBackend.java | DefaultOperatorStateBackend.snapshot | @Nonnull
@Override
public RunnableFuture<SnapshotResult<OperatorStateHandle>> snapshot(
long checkpointId,
long timestamp,
@Nonnull CheckpointStreamFactory streamFactory,
@Nonnull CheckpointOptions checkpointOptions) throws Exception {
long syncStartTime = System.currentTimeMillis();
RunnableFuture<SnapshotResult<OperatorStateHandle>> snapshotRunner =
snapshotStrategy.snapshot(checkpointId, timestamp, streamFactory, checkpointOptions);
snapshotStrategy.logSyncCompleted(streamFactory, syncStartTime);
return snapshotRunner;
} | java | @Nonnull
@Override
public RunnableFuture<SnapshotResult<OperatorStateHandle>> snapshot(
long checkpointId,
long timestamp,
@Nonnull CheckpointStreamFactory streamFactory,
@Nonnull CheckpointOptions checkpointOptions) throws Exception {
long syncStartTime = System.currentTimeMillis();
RunnableFuture<SnapshotResult<OperatorStateHandle>> snapshotRunner =
snapshotStrategy.snapshot(checkpointId, timestamp, streamFactory, checkpointOptions);
snapshotStrategy.logSyncCompleted(streamFactory, syncStartTime);
return snapshotRunner;
} | [
"@",
"Nonnull",
"@",
"Override",
"public",
"RunnableFuture",
"<",
"SnapshotResult",
"<",
"OperatorStateHandle",
">",
">",
"snapshot",
"(",
"long",
"checkpointId",
",",
"long",
"timestamp",
",",
"@",
"Nonnull",
"CheckpointStreamFactory",
"streamFactory",
",",
"@",
... | ------------------------------------------------------------------------------------------- | [
"-------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/state/DefaultOperatorStateBackend.java#L250-L265 | train | Performs a single snapshot of the state of the specified block. | [
30522,
1030,
2512,
11231,
3363,
1030,
2058,
15637,
2270,
2448,
22966,
11263,
11244,
1026,
20057,
12326,
6072,
11314,
1026,
9224,
12259,
11774,
2571,
1028,
1028,
20057,
12326,
1006,
2146,
26520,
3593,
1010,
2146,
2335,
15464,
2361,
1010,
1030,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/StringUtils.java | StringUtils.byteToHexString | public static String byteToHexString(final byte[] bytes, final int start, final int end) {
if (bytes == null) {
throw new IllegalArgumentException("bytes == null");
}
int length = end - start;
char[] out = new char[length * 2];
for (int i = start, j = 0; i < end; i++) {
out[j++] = HEX_CHARS[(0xF0 & bytes[i]) >>> 4];
out[j++] = HEX_CHARS[0x0F & bytes[i]];
}
return new String(out);
} | java | public static String byteToHexString(final byte[] bytes, final int start, final int end) {
if (bytes == null) {
throw new IllegalArgumentException("bytes == null");
}
int length = end - start;
char[] out = new char[length * 2];
for (int i = start, j = 0; i < end; i++) {
out[j++] = HEX_CHARS[(0xF0 & bytes[i]) >>> 4];
out[j++] = HEX_CHARS[0x0F & bytes[i]];
}
return new String(out);
} | [
"public",
"static",
"String",
"byteToHexString",
"(",
"final",
"byte",
"[",
"]",
"bytes",
",",
"final",
"int",
"start",
",",
"final",
"int",
"end",
")",
"{",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"... | Given an array of bytes it will convert the bytes to a hex string
representation of the bytes.
@param bytes
the bytes to convert in a hex string
@param start
start index, inclusively
@param end
end index, exclusively
@return hex string representation of the byte array | [
"Given",
"an",
"array",
"of",
"bytes",
"it",
"will",
"convert",
"the",
"bytes",
"to",
"a",
"hex",
"string",
"representation",
"of",
"the",
"bytes",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/StringUtils.java#L58-L72 | train | Converts a byte array to a hexadecimal string. | [
30522,
2270,
10763,
5164,
24880,
3406,
5369,
2595,
3367,
4892,
1006,
2345,
24880,
1031,
1033,
27507,
1010,
2345,
20014,
2707,
1010,
2345,
20014,
2203,
1007,
1063,
2065,
1006,
27507,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
6206,
2906,
228... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DbUtil.java | DbUtil.use | public static Db use(DataSource ds, Dialect dialect) {
return Db.use(ds, dialect);
} | java | public static Db use(DataSource ds, Dialect dialect) {
return Db.use(ds, dialect);
} | [
"public",
"static",
"Db",
"use",
"(",
"DataSource",
"ds",
",",
"Dialect",
"dialect",
")",
"{",
"return",
"Db",
".",
"use",
"(",
"ds",
",",
"dialect",
")",
";",
"}"
] | 实例化一个新的SQL运行对象
@param ds 数据源
@param dialect SQL方言
@return SQL执行类 | [
"实例化一个新的SQL运行对象"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/DbUtil.java#L126-L128 | train | Use a DataSource to create a database. | [
30522,
2270,
10763,
16962,
2224,
1006,
2951,
6499,
3126,
3401,
16233,
1010,
9329,
9329,
1007,
1063,
2709,
16962,
1012,
2224,
1006,
16233,
1010,
9329,
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... |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/nosql/mongo/MongoFactory.java | MongoFactory.closeAll | public static void closeAll() {
if(CollectionUtil.isNotEmpty(dsMap)){
for(MongoDS ds : dsMap.values()) {
ds.close();
}
dsMap.clear();
}
} | java | public static void closeAll() {
if(CollectionUtil.isNotEmpty(dsMap)){
for(MongoDS ds : dsMap.values()) {
ds.close();
}
dsMap.clear();
}
} | [
"public",
"static",
"void",
"closeAll",
"(",
")",
"{",
"if",
"(",
"CollectionUtil",
".",
"isNotEmpty",
"(",
"dsMap",
")",
")",
"{",
"for",
"(",
"MongoDS",
"ds",
":",
"dsMap",
".",
"values",
"(",
")",
")",
"{",
"ds",
".",
"close",
"(",
")",
";",
"... | 关闭全部连接 | [
"关闭全部连接"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/nosql/mongo/MongoFactory.java#L117-L124 | train | Close all the database databases. | [
30522,
2270,
10763,
11675,
2485,
8095,
1006,
1007,
1063,
2065,
1006,
3074,
21823,
2140,
1012,
3475,
12184,
27718,
2100,
1006,
16233,
2863,
2361,
1007,
1007,
1063,
2005,
1006,
12256,
3995,
30524,
1006,
1007,
1007,
1063,
16233,
1012,
2485,
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-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java | ExecutionEnvironment.fromCollection | public <X> DataSource<X> fromCollection(Iterator<X> data, TypeInformation<X> type) {
return new DataSource<>(this, new IteratorInputFormat<>(data), type, Utils.getCallLocationName());
} | java | public <X> DataSource<X> fromCollection(Iterator<X> data, TypeInformation<X> type) {
return new DataSource<>(this, new IteratorInputFormat<>(data), type, Utils.getCallLocationName());
} | [
"public",
"<",
"X",
">",
"DataSource",
"<",
"X",
">",
"fromCollection",
"(",
"Iterator",
"<",
"X",
">",
"data",
",",
"TypeInformation",
"<",
"X",
">",
"type",
")",
"{",
"return",
"new",
"DataSource",
"<>",
"(",
"this",
",",
"new",
"IteratorInputFormat",
... | Creates a DataSet from the given iterator. Because the iterator will remain unmodified until
the actual execution happens, the type of data returned by the iterator must be given
explicitly in the form of the type information. This method is useful for cases where the type
is generic. In that case, the type class (as given in {@link #fromCollection(Iterator, Class)}
does not supply all type information.
<p>Note that this operation will result in a non-parallel data source, i.e. a data source with
a parallelism of one.
@param data The collection of elements to create the data set from.
@param type The TypeInformation for the produced data set.
@return A DataSet representing the elements in the iterator.
@see #fromCollection(Iterator, Class) | [
"Creates",
"a",
"DataSet",
"from",
"the",
"given",
"iterator",
".",
"Because",
"the",
"iterator",
"will",
"remain",
"unmodified",
"until",
"the",
"actual",
"execution",
"happens",
"the",
"type",
"of",
"data",
"returned",
"by",
"the",
"iterator",
"must",
"be",
... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java#L673-L675 | train | Creates a data source from an iterator. | [
30522,
2270,
1026,
1060,
1028,
2951,
6499,
3126,
3401,
1026,
1060,
1028,
2013,
26895,
18491,
1006,
2009,
6906,
4263,
1026,
1060,
1028,
2951,
1010,
2828,
2378,
14192,
3370,
1026,
1060,
1028,
2828,
1007,
1063,
2709,
2047,
2951,
6499,
3126,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/FluentWait.java | FluentWait.toChronoUnit | private ChronoUnit toChronoUnit(TimeUnit timeUnit) {
switch (timeUnit) {
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
case SECONDS:
return ChronoUnit.SECONDS;
case MINUTES:
return ChronoUnit.MINUTES;
case HOURS:
return ChronoUnit.HOURS;
case DAYS:
return ChronoUnit.DAYS;
default:
throw new IllegalArgumentException("No ChronoUnit equivalent for " + timeUnit);
}
} | java | private ChronoUnit toChronoUnit(TimeUnit timeUnit) {
switch (timeUnit) {
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
case SECONDS:
return ChronoUnit.SECONDS;
case MINUTES:
return ChronoUnit.MINUTES;
case HOURS:
return ChronoUnit.HOURS;
case DAYS:
return ChronoUnit.DAYS;
default:
throw new IllegalArgumentException("No ChronoUnit equivalent for " + timeUnit);
}
} | [
"private",
"ChronoUnit",
"toChronoUnit",
"(",
"TimeUnit",
"timeUnit",
")",
"{",
"switch",
"(",
"timeUnit",
")",
"{",
"case",
"NANOSECONDS",
":",
"return",
"ChronoUnit",
".",
"NANOS",
";",
"case",
"MICROSECONDS",
":",
"return",
"ChronoUnit",
".",
"MICROS",
";",... | Converts the {@code TimeUnit} to the equivalent {@code ChronoUnit}.
This is a backport from Java 9, see https://bugs.openjdk.java.net/browse/JDK-8141452.
@param timeUnit the TimeUnit to convert
@return the converted equivalent ChronoUnit | [
"Converts",
"the",
"{",
"@code",
"TimeUnit",
"}",
"to",
"the",
"equivalent",
"{",
"@code",
"ChronoUnit",
"}",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/ui/FluentWait.java#L277-L296 | train | Converts the time unit to the ChronoUnit equivalent. | [
30522,
2797,
10381,
4948,
23709,
4183,
2000,
2818,
4948,
23709,
4183,
1006,
2051,
19496,
2102,
2051,
19496,
2102,
1007,
1063,
6942,
1006,
2051,
19496,
2102,
1007,
1063,
2553,
28991,
3366,
8663,
5104,
1024,
2709,
10381,
4948,
23709,
4183,
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... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/corpus/io/IOUtil.java | IOUtil.writeLine | public static void writeLine(BufferedWriter bw, String... params) throws IOException
{
for (int i = 0; i < params.length - 1; i++)
{
bw.write(params[i]);
bw.write('\t');
}
bw.write(params[params.length - 1]);
} | java | public static void writeLine(BufferedWriter bw, String... params) throws IOException
{
for (int i = 0; i < params.length - 1; i++)
{
bw.write(params[i]);
bw.write('\t');
}
bw.write(params[params.length - 1]);
} | [
"public",
"static",
"void",
"writeLine",
"(",
"BufferedWriter",
"bw",
",",
"String",
"...",
"params",
")",
"throws",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"... | 写数组,用制表符分割
@param bw
@param params
@throws IOException | [
"写数组,用制表符分割"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/corpus/io/IOUtil.java#L658-L666 | train | Write a line of a Sequence of Attributes. | [
30522,
2270,
10763,
11675,
4339,
4179,
1006,
17698,
2098,
15994,
1038,
2860,
1010,
5164,
1012,
1012,
1012,
11498,
5244,
1007,
11618,
22834,
10288,
24422,
1063,
2005,
1006,
20014,
1045,
1027,
1014,
1025,
1045,
1026,
11498,
5244,
1012,
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... |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseStatus.java | HttpResponseStatus.parseLine | public static HttpResponseStatus parseLine(AsciiString line) {
try {
int space = line.forEachByte(FIND_ASCII_SPACE);
return space == -1 ? valueOf(line.parseInt()) : valueOf(line.parseInt(0, space), line.toString(space + 1));
} catch (Exception e) {
throw new IllegalArgumentException("malformed status line: " + line, e);
}
} | java | public static HttpResponseStatus parseLine(AsciiString line) {
try {
int space = line.forEachByte(FIND_ASCII_SPACE);
return space == -1 ? valueOf(line.parseInt()) : valueOf(line.parseInt(0, space), line.toString(space + 1));
} catch (Exception e) {
throw new IllegalArgumentException("malformed status line: " + line, e);
}
} | [
"public",
"static",
"HttpResponseStatus",
"parseLine",
"(",
"AsciiString",
"line",
")",
"{",
"try",
"{",
"int",
"space",
"=",
"line",
".",
"forEachByte",
"(",
"FIND_ASCII_SPACE",
")",
";",
"return",
"space",
"==",
"-",
"1",
"?",
"valueOf",
"(",
"line",
"."... | Parses the specified HTTP status line into a {@link HttpResponseStatus}. The expected formats of the line are:
<ul>
<li>{@code statusCode} (e.g. 200)</li>
<li>{@code statusCode} {@code reasonPhrase} (e.g. 404 Not Found)</li>
</ul>
@throws IllegalArgumentException if the specified status line is malformed | [
"Parses",
"the",
"specified",
"HTTP",
"status",
"line",
"into",
"a",
"{",
"@link",
"HttpResponseStatus",
"}",
".",
"The",
"expected",
"formats",
"of",
"the",
"line",
"are",
":",
"<ul",
">",
"<li",
">",
"{",
"@code",
"statusCode",
"}",
"(",
"e",
".",
"g... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseStatus.java#L511-L518 | train | Parses a single HTTP status line. | [
30522,
2270,
10763,
8299,
6072,
26029,
8583,
29336,
2271,
11968,
11246,
3170,
1006,
2004,
6895,
2923,
4892,
2240,
1007,
1063,
3046,
1063,
20014,
2686,
1027,
2240,
1012,
18921,
6776,
3762,
2618,
1006,
2424,
1035,
2004,
6895,
2072,
1035,
2686... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/util/MurmurHashUtil.java | MurmurHashUtil.hashBytesByWords | public static int hashBytesByWords(MemorySegment segment, int offset, int lengthInBytes) {
return hashBytesByWords(segment, offset, lengthInBytes, DEFAULT_SEED);
} | java | public static int hashBytesByWords(MemorySegment segment, int offset, int lengthInBytes) {
return hashBytesByWords(segment, offset, lengthInBytes, DEFAULT_SEED);
} | [
"public",
"static",
"int",
"hashBytesByWords",
"(",
"MemorySegment",
"segment",
",",
"int",
"offset",
",",
"int",
"lengthInBytes",
")",
"{",
"return",
"hashBytesByWords",
"(",
"segment",
",",
"offset",
",",
"lengthInBytes",
",",
"DEFAULT_SEED",
")",
";",
"}"
] | Hash bytes in MemorySegment, length must be aligned to 4 bytes.
@param segment segment.
@param offset offset for MemorySegment
@param lengthInBytes length in MemorySegment
@return hash code | [
"Hash",
"bytes",
"in",
"MemorySegment",
"length",
"must",
"be",
"aligned",
"to",
"4",
"bytes",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/MurmurHashUtil.java#L62-L64 | train | Hash bytes by words. | [
30522,
2270,
10763,
20014,
23325,
3762,
4570,
3762,
22104,
1006,
3638,
3366,
21693,
4765,
6903,
1010,
20014,
16396,
1010,
20014,
3091,
2378,
3762,
4570,
1007,
1063,
2709,
23325,
3762,
4570,
3762,
22104,
1006,
6903,
1010,
16396,
1010,
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... |
apache/flink | flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java | MemorySegment.copyFromUnsafe | public final void copyFromUnsafe(int offset, Object source, int sourcePointer, int numBytes) {
final long thisPointer = this.address + offset;
if (thisPointer + numBytes > addressLimit) {
throw new IndexOutOfBoundsException(
String.format("offset=%d, numBytes=%d, address=%d",
offset, numBytes, this.address));
}
UNSAFE.copyMemory(source, sourcePointer, this.heapMemory, thisPointer, numBytes);
} | java | public final void copyFromUnsafe(int offset, Object source, int sourcePointer, int numBytes) {
final long thisPointer = this.address + offset;
if (thisPointer + numBytes > addressLimit) {
throw new IndexOutOfBoundsException(
String.format("offset=%d, numBytes=%d, address=%d",
offset, numBytes, this.address));
}
UNSAFE.copyMemory(source, sourcePointer, this.heapMemory, thisPointer, numBytes);
} | [
"public",
"final",
"void",
"copyFromUnsafe",
"(",
"int",
"offset",
",",
"Object",
"source",
",",
"int",
"sourcePointer",
",",
"int",
"numBytes",
")",
"{",
"final",
"long",
"thisPointer",
"=",
"this",
".",
"address",
"+",
"offset",
";",
"if",
"(",
"thisPoin... | Bulk copy method. Copies {@code numBytes} bytes from source unsafe object and pointer.
NOTE: This is a unsafe method, no check here, please be carefully.
@param offset The position where the bytes are started to be write in this memory segment.
@param source The unsafe memory to copy the bytes from.
@param sourcePointer The position in the source unsafe memory to copy the chunk from.
@param numBytes The number of bytes to copy.
@throws IndexOutOfBoundsException If this segment can not contain the given number
of bytes (starting from offset). | [
"Bulk",
"copy",
"method",
".",
"Copies",
"{",
"@code",
"numBytes",
"}",
"bytes",
"from",
"source",
"unsafe",
"object",
"and",
"pointer",
".",
"NOTE",
":",
"This",
"is",
"a",
"unsafe",
"method",
"no",
"check",
"here",
"please",
"be",
"carefully",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java#L1307-L1315 | train | Copies the contents of the given object from the given offset to this object s memory. | [
30522,
2270,
2345,
11675,
6100,
19699,
5358,
4609,
3736,
7959,
1006,
20014,
16396,
1010,
4874,
3120,
1010,
20014,
3120,
8400,
2121,
1010,
20014,
15903,
17250,
2015,
1007,
1063,
2345,
2146,
2023,
8400,
2121,
1027,
2023,
1012,
4769,
1009,
163... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/dependency/nnparser/Matrix.java | Matrix.setMatrix | public void setMatrix(int[] r, int j0, int j1, Matrix X)
{
try
{
for (int i = 0; i < r.length; i++)
{
for (int j = j0; j <= j1; j++)
{
A[r[i]][j] = X.get(i, j - j0);
}
}
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new ArrayIndexOutOfBoundsException("Submatrix indices");
}
} | java | public void setMatrix(int[] r, int j0, int j1, Matrix X)
{
try
{
for (int i = 0; i < r.length; i++)
{
for (int j = j0; j <= j1; j++)
{
A[r[i]][j] = X.get(i, j - j0);
}
}
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new ArrayIndexOutOfBoundsException("Submatrix indices");
}
} | [
"public",
"void",
"setMatrix",
"(",
"int",
"[",
"]",
"r",
",",
"int",
"j0",
",",
"int",
"j1",
",",
"Matrix",
"X",
")",
"{",
"try",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"r",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
... | Set a submatrix.
@param r Array of row indices.
@param j0 Initial column index
@param j1 Final column index
@param X A(r(:),j0:j1)
@throws ArrayIndexOutOfBoundsException Submatrix indices | [
"Set",
"a",
"submatrix",
"."
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dependency/nnparser/Matrix.java#L555-L571 | train | Sets the matrix of the matrix r. | [
30522,
2270,
11675,
2275,
18900,
17682,
1006,
20014,
1031,
1033,
1054,
1010,
20014,
1046,
2692,
1010,
20014,
1046,
2487,
1010,
8185,
1060,
1007,
1063,
3046,
1063,
2005,
1006,
20014,
1045,
1027,
1014,
1025,
1045,
1026,
1054,
1012,
3091,
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... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/interactions/Actions.java | Actions.build | public Action build() {
Action toReturn = new BuiltAction(driver, new LinkedHashMap<>(sequences), action);
action = new CompositeAction();
sequences.clear();
return toReturn;
} | java | public Action build() {
Action toReturn = new BuiltAction(driver, new LinkedHashMap<>(sequences), action);
action = new CompositeAction();
sequences.clear();
return toReturn;
} | [
"public",
"Action",
"build",
"(",
")",
"{",
"Action",
"toReturn",
"=",
"new",
"BuiltAction",
"(",
"driver",
",",
"new",
"LinkedHashMap",
"<>",
"(",
"sequences",
")",
",",
"action",
")",
";",
"action",
"=",
"new",
"CompositeAction",
"(",
")",
";",
"sequen... | Generates a composite action containing all actions so far, ready to be performed (and
resets the internal builder state, so subsequent calls to {@link #build()} will contain fresh
sequences).
@return the composite action | [
"Generates",
"a",
"composite",
"action",
"containing",
"all",
"actions",
"so",
"far",
"ready",
"to",
"be",
"performed",
"(",
"and",
"resets",
"the",
"internal",
"builder",
"state",
"so",
"subsequent",
"calls",
"to",
"{",
"@link",
"#build",
"()",
"}",
"will",... | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/interactions/Actions.java#L558-L563 | train | Build a new action. | [
30522,
2270,
2895,
3857,
1006,
1007,
1063,
2895,
9538,
22299,
1027,
2047,
2328,
18908,
3258,
1006,
4062,
1010,
2047,
5799,
14949,
22444,
2361,
1026,
1028,
1006,
10071,
1007,
1010,
2895,
1007,
1025,
2895,
1027,
2047,
12490,
18908,
3258,
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/ReflectUtil.java | ReflectUtil.getMethodByName | public static Method getMethodByName(Class<?> clazz, boolean ignoreCase, String methodName) throws SecurityException {
if (null == clazz || StrUtil.isBlank(methodName)) {
return null;
}
final Method[] methods = getMethods(clazz);
if (ArrayUtil.isNotEmpty(methods)) {
for (Method method : methods) {
if (StrUtil.equals(methodName, method.getName(), ignoreCase)) {
return method;
}
}
}
return null;
} | java | public static Method getMethodByName(Class<?> clazz, boolean ignoreCase, String methodName) throws SecurityException {
if (null == clazz || StrUtil.isBlank(methodName)) {
return null;
}
final Method[] methods = getMethods(clazz);
if (ArrayUtil.isNotEmpty(methods)) {
for (Method method : methods) {
if (StrUtil.equals(methodName, method.getName(), ignoreCase)) {
return method;
}
}
}
return null;
} | [
"public",
"static",
"Method",
"getMethodByName",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"boolean",
"ignoreCase",
",",
"String",
"methodName",
")",
"throws",
"SecurityException",
"{",
"if",
"(",
"null",
"==",
"clazz",
"||",
"StrUtil",
".",
"isBlank",
"(",... | 按照方法名查找指定方法名的方法,只返回匹配到的第一个方法,如果找不到对应的方法则返回<code>null</code>
<p>
此方法只检查方法名是否一致,并不检查参数的一致性。
</p>
@param clazz 类,如果为{@code null}返回{@code null}
@param ignoreCase 是否忽略大小写
@param methodName 方法名,如果为空字符串返回{@code null}
@return 方法
@throws SecurityException 无权访问抛出异常
@since 4.3.2 | [
"按照方法名查找指定方法名的方法,只返回匹配到的第一个方法,如果找不到对应的方法则返回<code",
">",
"null<",
"/",
"code",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java#L516-L530 | train | Gets the method with the specified name from the specified class. | [
30522,
2270,
10763,
4118,
2131,
11368,
6806,
18939,
18279,
4168,
1006,
2465,
1026,
1029,
1028,
18856,
10936,
2480,
1010,
22017,
20898,
8568,
18382,
1010,
5164,
4118,
18442,
1007,
11618,
3036,
10288,
24422,
1063,
2065,
1006,
19701,
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/IdcardUtil.java | IdcardUtil.getBirthDate | public static DateTime getBirthDate(String idCard) {
final String birthByIdCard = getBirthByIdCard(idCard);
return null == birthByIdCard ? null : DateUtil.parse(birthByIdCard, DatePattern.PURE_DATE_FORMAT);
} | java | public static DateTime getBirthDate(String idCard) {
final String birthByIdCard = getBirthByIdCard(idCard);
return null == birthByIdCard ? null : DateUtil.parse(birthByIdCard, DatePattern.PURE_DATE_FORMAT);
} | [
"public",
"static",
"DateTime",
"getBirthDate",
"(",
"String",
"idCard",
")",
"{",
"final",
"String",
"birthByIdCard",
"=",
"getBirthByIdCard",
"(",
"idCard",
")",
";",
"return",
"null",
"==",
"birthByIdCard",
"?",
"null",
":",
"DateUtil",
".",
"parse",
"(",
... | 从身份证号码中获取生日日期,只支持15或18位身份证号码
@param idCard 身份证号码
@return 日期 | [
"从身份证号码中获取生日日期,只支持15或18位身份证号码"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/IdcardUtil.java#L399-L402 | train | Gets the birth date from an id card. | [
30522,
2270,
10763,
3058,
7292,
2131,
17706,
2705,
13701,
1006,
5164,
8909,
11522,
1007,
1063,
2345,
5164,
4182,
3762,
3593,
11522,
1027,
2131,
17706,
2705,
3762,
3593,
11522,
1006,
8909,
11522,
1007,
1025,
2709,
19701,
1027,
1027,
4182,
37... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/TypeExtractor.java | TypeExtractor.materializeTypeVariable | private static Type materializeTypeVariable(ArrayList<Type> typeHierarchy, TypeVariable<?> typeVar) {
TypeVariable<?> inTypeTypeVar = typeVar;
// iterate thru hierarchy from top to bottom until type variable gets a class assigned
for (int i = typeHierarchy.size() - 1; i >= 0; i--) {
Type curT = typeHierarchy.get(i);
// parameterized type
if (curT instanceof ParameterizedType) {
Class<?> rawType = ((Class<?>) ((ParameterizedType) curT).getRawType());
for (int paramIndex = 0; paramIndex < rawType.getTypeParameters().length; paramIndex++) {
TypeVariable<?> curVarOfCurT = rawType.getTypeParameters()[paramIndex];
// check if variable names match
if (sameTypeVars(curVarOfCurT, inTypeTypeVar)) {
Type curVarType = ((ParameterizedType) curT).getActualTypeArguments()[paramIndex];
// another type variable level
if (curVarType instanceof TypeVariable<?>) {
inTypeTypeVar = (TypeVariable<?>) curVarType;
}
// class
else {
return curVarType;
}
}
}
}
}
// can not be materialized, most likely due to type erasure
// return the type variable of the deepest level
return inTypeTypeVar;
} | java | private static Type materializeTypeVariable(ArrayList<Type> typeHierarchy, TypeVariable<?> typeVar) {
TypeVariable<?> inTypeTypeVar = typeVar;
// iterate thru hierarchy from top to bottom until type variable gets a class assigned
for (int i = typeHierarchy.size() - 1; i >= 0; i--) {
Type curT = typeHierarchy.get(i);
// parameterized type
if (curT instanceof ParameterizedType) {
Class<?> rawType = ((Class<?>) ((ParameterizedType) curT).getRawType());
for (int paramIndex = 0; paramIndex < rawType.getTypeParameters().length; paramIndex++) {
TypeVariable<?> curVarOfCurT = rawType.getTypeParameters()[paramIndex];
// check if variable names match
if (sameTypeVars(curVarOfCurT, inTypeTypeVar)) {
Type curVarType = ((ParameterizedType) curT).getActualTypeArguments()[paramIndex];
// another type variable level
if (curVarType instanceof TypeVariable<?>) {
inTypeTypeVar = (TypeVariable<?>) curVarType;
}
// class
else {
return curVarType;
}
}
}
}
}
// can not be materialized, most likely due to type erasure
// return the type variable of the deepest level
return inTypeTypeVar;
} | [
"private",
"static",
"Type",
"materializeTypeVariable",
"(",
"ArrayList",
"<",
"Type",
">",
"typeHierarchy",
",",
"TypeVariable",
"<",
"?",
">",
"typeVar",
")",
"{",
"TypeVariable",
"<",
"?",
">",
"inTypeTypeVar",
"=",
"typeVar",
";",
"// iterate thru hierarchy fr... | Tries to find a concrete value (Class, ParameterizedType etc. ) for a TypeVariable by traversing the type hierarchy downwards.
If a value could not be found it will return the most bottom type variable in the hierarchy. | [
"Tries",
"to",
"find",
"a",
"concrete",
"value",
"(",
"Class",
"ParameterizedType",
"etc",
".",
")",
"for",
"a",
"TypeVariable",
"by",
"traversing",
"the",
"type",
"hierarchy",
"downwards",
".",
"If",
"a",
"value",
"could",
"not",
"be",
"found",
"it",
"wil... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L1591-L1624 | train | materializes a type variable. | [
30522,
2797,
10763,
2828,
3430,
4697,
13874,
10755,
19210,
1006,
9140,
9863,
1026,
2828,
1028,
2828,
4048,
6906,
29389,
1010,
2828,
10755,
19210,
1026,
1029,
1028,
2828,
10755,
1007,
1063,
2828,
10755,
19210,
1026,
1029,
1028,
20014,
18863,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/IoUtil.java | IoUtil.read | public static String read(InputStream in, Charset charset) throws IORuntimeException {
FastByteArrayOutputStream out = read(in);
return null == charset ? out.toString() : out.toString(charset);
} | java | public static String read(InputStream in, Charset charset) throws IORuntimeException {
FastByteArrayOutputStream out = read(in);
return null == charset ? out.toString() : out.toString(charset);
} | [
"public",
"static",
"String",
"read",
"(",
"InputStream",
"in",
",",
"Charset",
"charset",
")",
"throws",
"IORuntimeException",
"{",
"FastByteArrayOutputStream",
"out",
"=",
"read",
"(",
"in",
")",
";",
"return",
"null",
"==",
"charset",
"?",
"out",
".",
"to... | 从流中读取内容,读取完毕后并不关闭流
@param in 输入流,读取完毕后并不关闭流
@param charset 字符集
@return 内容
@throws IORuntimeException IO异常 | [
"从流中读取内容,读取完毕后并不关闭流"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java#L409-L412 | train | Reads a sequence of bytes from the specified input stream and returns the resulting string. | [
30522,
2270,
10763,
5164,
3191,
1006,
20407,
25379,
1999,
1010,
25869,
13462,
25869,
13462,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
3435,
3762,
27058,
11335,
29337,
25856,
16446,
25379,
2041,
1027,
3191,
1006,
1999,
1007,
1025,
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... |
netty/netty | transport/src/main/java/io/netty/channel/PendingWriteQueue.java | PendingWriteQueue.removeAndWrite | public ChannelFuture removeAndWrite() {
assert ctx.executor().inEventLoop();
PendingWrite write = head;
if (write == null) {
return null;
}
Object msg = write.msg;
ChannelPromise promise = write.promise;
recycle(write, true);
return ctx.write(msg, promise);
} | java | public ChannelFuture removeAndWrite() {
assert ctx.executor().inEventLoop();
PendingWrite write = head;
if (write == null) {
return null;
}
Object msg = write.msg;
ChannelPromise promise = write.promise;
recycle(write, true);
return ctx.write(msg, promise);
} | [
"public",
"ChannelFuture",
"removeAndWrite",
"(",
")",
"{",
"assert",
"ctx",
".",
"executor",
"(",
")",
".",
"inEventLoop",
"(",
")",
";",
"PendingWrite",
"write",
"=",
"head",
";",
"if",
"(",
"write",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}"... | Removes a pending write operation and performs it via
{@link ChannelHandlerContext#write(Object, ChannelPromise)}.
@return {@link ChannelFuture} if something was written and {@code null}
if the {@link PendingWriteQueue} is empty. | [
"Removes",
"a",
"pending",
"write",
"operation",
"and",
"performs",
"it",
"via",
"{",
"@link",
"ChannelHandlerContext#write",
"(",
"Object",
"ChannelPromise",
")",
"}",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/channel/PendingWriteQueue.java#L220-L230 | train | Remove and write the current entry. | [
30522,
2270,
3149,
11263,
11244,
6366,
5685,
26373,
1006,
1007,
1063,
20865,
14931,
2595,
1012,
4654,
8586,
16161,
2099,
1006,
1007,
1012,
1999,
18697,
3372,
4135,
7361,
1006,
1007,
1025,
14223,
26373,
4339,
1027,
2132,
1025,
2065,
1006,
43... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | buffer/src/main/java/io/netty/buffer/PoolChunk.java | PoolChunk.updateParentsAlloc | private void updateParentsAlloc(int id) {
while (id > 1) {
int parentId = id >>> 1;
byte val1 = value(id);
byte val2 = value(id ^ 1);
byte val = val1 < val2 ? val1 : val2;
setValue(parentId, val);
id = parentId;
}
} | java | private void updateParentsAlloc(int id) {
while (id > 1) {
int parentId = id >>> 1;
byte val1 = value(id);
byte val2 = value(id ^ 1);
byte val = val1 < val2 ? val1 : val2;
setValue(parentId, val);
id = parentId;
}
} | [
"private",
"void",
"updateParentsAlloc",
"(",
"int",
"id",
")",
"{",
"while",
"(",
"id",
">",
"1",
")",
"{",
"int",
"parentId",
"=",
"id",
">>>",
"1",
";",
"byte",
"val1",
"=",
"value",
"(",
"id",
")",
";",
"byte",
"val2",
"=",
"value",
"(",
"id"... | Update method used by allocate
This is triggered only when a successor is allocated and all its predecessors
need to update their state
The minimal depth at which subtree rooted at id has some free space
@param id id | [
"Update",
"method",
"used",
"by",
"allocate",
"This",
"is",
"triggered",
"only",
"when",
"a",
"successor",
"is",
"allocated",
"and",
"all",
"its",
"predecessors",
"need",
"to",
"update",
"their",
"state",
"The",
"minimal",
"depth",
"at",
"which",
"subtree",
... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/PoolChunk.java#L249-L258 | train | Update the parents allocation. | [
30522,
2797,
11675,
10651,
19362,
11187,
8095,
10085,
1006,
20014,
8909,
1007,
1063,
2096,
1006,
8909,
1028,
1015,
1007,
1063,
20014,
6687,
3593,
1027,
8909,
1028,
1028,
1028,
1015,
1025,
24880,
11748,
2487,
1027,
3643,
1006,
8909,
1007,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.