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/util/ClassUtil.java | ClassUtil.getClassPaths | public static Set<String> getClassPaths(String packageName, boolean isDecode) {
String packagePath = packageName.replace(StrUtil.DOT, StrUtil.SLASH);
Enumeration<URL> resources;
try {
resources = getClassLoader().getResources(packagePath);
} catch (IOException e) {
throw new UtilException(e, "Loading classPath [{}] error!", packagePath);
}
final Set<String> paths = new HashSet<String>();
String path;
while (resources.hasMoreElements()) {
path = resources.nextElement().getPath();
paths.add(isDecode ? URLUtil.decode(path, CharsetUtil.systemCharsetName()) : path);
}
return paths;
} | java | public static Set<String> getClassPaths(String packageName, boolean isDecode) {
String packagePath = packageName.replace(StrUtil.DOT, StrUtil.SLASH);
Enumeration<URL> resources;
try {
resources = getClassLoader().getResources(packagePath);
} catch (IOException e) {
throw new UtilException(e, "Loading classPath [{}] error!", packagePath);
}
final Set<String> paths = new HashSet<String>();
String path;
while (resources.hasMoreElements()) {
path = resources.nextElement().getPath();
paths.add(isDecode ? URLUtil.decode(path, CharsetUtil.systemCharsetName()) : path);
}
return paths;
} | [
"public",
"static",
"Set",
"<",
"String",
">",
"getClassPaths",
"(",
"String",
"packageName",
",",
"boolean",
"isDecode",
")",
"{",
"String",
"packagePath",
"=",
"packageName",
".",
"replace",
"(",
"StrUtil",
".",
"DOT",
",",
"StrUtil",
".",
"SLASH",
")",
... | 获得ClassPath
@param packageName 包名称
@param isDecode 是否解码路径中的特殊字符(例如空格和中文)
@return ClassPath路径字符串集合
@since 4.0.11 | [
"获得ClassPath"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ClassUtil.java#L419-L434 | train | Gets the paths of all the classes in the given package. | [
30522,
2270,
10763,
2275,
1026,
5164,
1028,
2131,
26266,
15069,
2015,
1006,
5164,
7427,
18442,
1010,
22017,
20898,
2003,
3207,
16044,
1007,
1063,
5164,
7427,
15069,
1027,
7427,
18442,
1012,
5672,
1006,
2358,
22134,
4014,
1012,
11089,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/BooleanUtil.java | BooleanUtil.xor | public static boolean xor(boolean... array) {
if (ArrayUtil.isEmpty(array)) {
throw new IllegalArgumentException("The Array must not be empty");
}
boolean result = false;
for (final boolean element : array) {
result ^= element;
}
return result;
} | java | public static boolean xor(boolean... array) {
if (ArrayUtil.isEmpty(array)) {
throw new IllegalArgumentException("The Array must not be empty");
}
boolean result = false;
for (final boolean element : array) {
result ^= element;
}
return result;
} | [
"public",
"static",
"boolean",
"xor",
"(",
"boolean",
"...",
"array",
")",
"{",
"if",
"(",
"ArrayUtil",
".",
"isEmpty",
"(",
"array",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The Array must not be empty\"",
")",
";",
"}",
"boolean",
... | 对Boolean数组取异或
<pre>
BooleanUtil.xor(true, true) = false
BooleanUtil.xor(false, false) = false
BooleanUtil.xor(true, false) = true
BooleanUtil.xor(true, true) = false
BooleanUtil.xor(false, false) = false
BooleanUtil.xor(true, false) = true
</pre>
@param array {@code boolean}数组
@return 如果异或计算为true返回 {@code true} | [
"对Boolean数组取异或"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/BooleanUtil.java#L404-L415 | train | Xor an array of booleans. | [
30522,
2270,
10763,
22017,
20898,
1060,
2953,
1006,
22017,
20898,
1012,
1012,
1012,
9140,
1007,
1063,
2065,
1006,
9140,
21823,
2140,
1012,
2003,
6633,
13876,
2100,
1006,
9140,
1007,
1007,
1063,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/recognition/nt/OrganizationRecognition.java | OrganizationRecognition.viterbiCompute | public static List<NT> viterbiCompute(List<EnumItem<NT>> roleTagList)
{
return Viterbi.computeEnum(roleTagList, OrganizationDictionary.transformMatrixDictionary);
} | java | public static List<NT> viterbiCompute(List<EnumItem<NT>> roleTagList)
{
return Viterbi.computeEnum(roleTagList, OrganizationDictionary.transformMatrixDictionary);
} | [
"public",
"static",
"List",
"<",
"NT",
">",
"viterbiCompute",
"(",
"List",
"<",
"EnumItem",
"<",
"NT",
">",
">",
"roleTagList",
")",
"{",
"return",
"Viterbi",
".",
"computeEnum",
"(",
"roleTagList",
",",
"OrganizationDictionary",
".",
"transformMatrixDictionary"... | 维特比算法求解最优标签
@param roleTagList
@return | [
"维特比算法求解最优标签"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/recognition/nt/OrganizationRecognition.java#L122-L125 | train | Compute the Viterbi formula. | [
30522,
2270,
10763,
2862,
1026,
23961,
1028,
6819,
3334,
13592,
25377,
10421,
1006,
2862,
1026,
4372,
12717,
18532,
1026,
23961,
1028,
1028,
2535,
15900,
9863,
1007,
1063,
2709,
6819,
3334,
5638,
1012,
24134,
2368,
2819,
1006,
2535,
15900,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-poi/src/main/java/cn/hutool/poi/excel/sax/Excel07SaxReader.java | Excel07SaxReader.endElement | @Override
public void endElement(String uri, String localName, String qName) throws SAXException {
final String contentStr = StrUtil.trim(lastContent);
if (T_ELEMENT.equals(qName)) {
// type标签
rowCellList.add(curCell++, contentStr);
} else if (C_ELEMENT.equals(qName)) {
// cell标签
Object value = ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStringsTable, this.numFmtString);
// 补全单元格之间的空格
fillBlankCell(preCoordinate, curCoordinate, false);
rowCellList.add(curCell++, value);
} else if (ROW_ELEMENT.equals(qName)) {
// 如果是row标签,说明已经到了一行的结尾
// 最大列坐标以第一行的为准
if (curRow == 0) {
maxCellCoordinate = curCoordinate;
}
// 补全一行尾部可能缺失的单元格
if (maxCellCoordinate != null) {
fillBlankCell(curCoordinate, maxCellCoordinate, true);
}
rowHandler.handle(sheetIndex, curRow, rowCellList);
// 一行结束
// 清空rowCellList,
rowCellList.clear();
// 行数增加
curRow++;
// 当前列置0
curCell = 0;
// 置空当前列坐标和前一列坐标
curCoordinate = null;
preCoordinate = null;
}
} | java | @Override
public void endElement(String uri, String localName, String qName) throws SAXException {
final String contentStr = StrUtil.trim(lastContent);
if (T_ELEMENT.equals(qName)) {
// type标签
rowCellList.add(curCell++, contentStr);
} else if (C_ELEMENT.equals(qName)) {
// cell标签
Object value = ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStringsTable, this.numFmtString);
// 补全单元格之间的空格
fillBlankCell(preCoordinate, curCoordinate, false);
rowCellList.add(curCell++, value);
} else if (ROW_ELEMENT.equals(qName)) {
// 如果是row标签,说明已经到了一行的结尾
// 最大列坐标以第一行的为准
if (curRow == 0) {
maxCellCoordinate = curCoordinate;
}
// 补全一行尾部可能缺失的单元格
if (maxCellCoordinate != null) {
fillBlankCell(curCoordinate, maxCellCoordinate, true);
}
rowHandler.handle(sheetIndex, curRow, rowCellList);
// 一行结束
// 清空rowCellList,
rowCellList.clear();
// 行数增加
curRow++;
// 当前列置0
curCell = 0;
// 置空当前列坐标和前一列坐标
curCoordinate = null;
preCoordinate = null;
}
} | [
"@",
"Override",
"public",
"void",
"endElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"final",
"String",
"contentStr",
"=",
"StrUtil",
".",
"trim",
"(",
"lastContent",
")",
";",
"if",
... | 标签结束的回调处理方法 | [
"标签结束的回调处理方法"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/sax/Excel07SaxReader.java#L234-L272 | train | Override the end of an XML element. | [
30522,
1030,
2058,
15637,
2270,
11675,
2203,
12260,
3672,
1006,
5164,
24471,
2072,
1010,
5164,
2334,
18442,
1010,
5164,
1053,
18442,
1007,
11618,
24937,
2595,
24422,
1063,
2345,
5164,
8417,
16344,
1027,
2358,
22134,
4014,
1012,
12241,
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-http/src/main/java/cn/hutool/http/webservice/SoapClient.java | SoapClient.init | public SoapClient init(SoapProtocol protocol) {
// 创建消息工厂
try {
this.factory = MessageFactory.newInstance(protocol.getValue());
// 根据消息工厂创建SoapMessage
this.message = factory.createMessage();
} catch (SOAPException e) {
throw new SoapRuntimeException(e);
}
return this;
} | java | public SoapClient init(SoapProtocol protocol) {
// 创建消息工厂
try {
this.factory = MessageFactory.newInstance(protocol.getValue());
// 根据消息工厂创建SoapMessage
this.message = factory.createMessage();
} catch (SOAPException e) {
throw new SoapRuntimeException(e);
}
return this;
} | [
"public",
"SoapClient",
"init",
"(",
"SoapProtocol",
"protocol",
")",
"{",
"// 创建消息工厂\r",
"try",
"{",
"this",
".",
"factory",
"=",
"MessageFactory",
".",
"newInstance",
"(",
"protocol",
".",
"getValue",
"(",
")",
")",
";",
"// 根据消息工厂创建SoapMessage\r",
"this",
"... | 初始化
@param protocol 协议版本枚举,见{@link SoapProtocol}
@return this | [
"初始化"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/webservice/SoapClient.java#L128-L139 | train | Initializes the soap client. | [
30522,
2270,
7815,
20464,
11638,
1999,
4183,
1006,
7815,
21572,
3406,
25778,
8778,
1007,
1063,
1013,
1013,
100,
100,
100,
100,
100,
100,
3046,
1063,
2023,
1012,
4713,
1027,
4471,
21450,
1012,
2047,
7076,
26897,
1006,
8778,
1012,
2131,
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-core/src/main/java/org/apache/flink/util/AbstractCloseableRegistry.java | AbstractCloseableRegistry.addCloseableInternal | protected final void addCloseableInternal(Closeable closeable, T metaData) {
synchronized (getSynchronizationLock()) {
closeableToRef.put(closeable, metaData);
}
} | java | protected final void addCloseableInternal(Closeable closeable, T metaData) {
synchronized (getSynchronizationLock()) {
closeableToRef.put(closeable, metaData);
}
} | [
"protected",
"final",
"void",
"addCloseableInternal",
"(",
"Closeable",
"closeable",
",",
"T",
"metaData",
")",
"{",
"synchronized",
"(",
"getSynchronizationLock",
"(",
")",
")",
"{",
"closeableToRef",
".",
"put",
"(",
"closeable",
",",
"metaData",
")",
";",
"... | Adds a mapping to the registry map, respecting locking. | [
"Adds",
"a",
"mapping",
"to",
"the",
"registry",
"map",
"respecting",
"locking",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/AbstractCloseableRegistry.java#L153-L157 | train | Add a closeable to the cache. | [
30522,
5123,
2345,
11675,
5587,
20464,
9232,
3085,
18447,
11795,
2389,
1006,
2485,
3085,
2485,
3085,
1010,
1056,
27425,
1007,
1063,
25549,
1006,
4152,
6038,
2818,
4948,
3989,
7878,
1006,
1007,
1007,
1063,
2485,
3085,
19277,
2546,
1012,
2404... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/context/table/Tables.java | Tables.isSingleTable | public boolean isSingleTable() {
Collection<String> tableNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (Table each : tables) {
tableNames.add(each.getName());
}
return 1 == tableNames.size();
} | java | public boolean isSingleTable() {
Collection<String> tableNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (Table each : tables) {
tableNames.add(each.getName());
}
return 1 == tableNames.size();
} | [
"public",
"boolean",
"isSingleTable",
"(",
")",
"{",
"Collection",
"<",
"String",
">",
"tableNames",
"=",
"new",
"TreeSet",
"<>",
"(",
"String",
".",
"CASE_INSENSITIVE_ORDER",
")",
";",
"for",
"(",
"Table",
"each",
":",
"tables",
")",
"{",
"tableNames",
".... | Judge is single table or not.
@return is single table or not | [
"Judge",
"is",
"single",
"table",
"or",
"not",
"."
] | 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/context/table/Tables.java#L63-L69 | train | Checks if this is a single table. | [
30522,
2270,
22017,
20898,
26354,
2075,
7485,
3085,
1006,
1007,
1063,
3074,
1026,
5164,
1028,
2795,
18442,
2015,
1027,
2047,
3628,
3388,
1026,
1028,
1006,
5164,
1012,
2553,
1035,
16021,
6132,
13043,
1035,
2344,
1007,
1025,
2005,
1006,
2795,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.sysctlGetInt | private static Integer sysctlGetInt(String sysctlKey) throws IOException {
Process process = new ProcessBuilder("sysctl", sysctlKey).start();
try {
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
try {
String line = br.readLine();
if (line.startsWith(sysctlKey)) {
for (int i = line.length() - 1; i > sysctlKey.length(); --i) {
if (!Character.isDigit(line.charAt(i))) {
return Integer.valueOf(line.substring(i + 1, line.length()));
}
}
}
return null;
} finally {
br.close();
}
} finally {
if (process != null) {
process.destroy();
}
}
} | java | private static Integer sysctlGetInt(String sysctlKey) throws IOException {
Process process = new ProcessBuilder("sysctl", sysctlKey).start();
try {
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
try {
String line = br.readLine();
if (line.startsWith(sysctlKey)) {
for (int i = line.length() - 1; i > sysctlKey.length(); --i) {
if (!Character.isDigit(line.charAt(i))) {
return Integer.valueOf(line.substring(i + 1, line.length()));
}
}
}
return null;
} finally {
br.close();
}
} finally {
if (process != null) {
process.destroy();
}
}
} | [
"private",
"static",
"Integer",
"sysctlGetInt",
"(",
"String",
"sysctlKey",
")",
"throws",
"IOException",
"{",
"Process",
"process",
"=",
"new",
"ProcessBuilder",
"(",
"\"sysctl\"",
",",
"sysctlKey",
")",
".",
"start",
"(",
")",
";",
"try",
"{",
"InputStream",... | This will execute <a href ="https://www.freebsd.org/cgi/man.cgi?sysctl(8)">sysctl</a> with the {@code sysctlKey}
which is expected to return the numeric value for for {@code sysctlKey}.
@param sysctlKey The key which the return value corresponds to.
@return The <a href ="https://www.freebsd.org/cgi/man.cgi?sysctl(8)">sysctl</a> value for {@code sysctlKey}. | [
"This",
"will",
"execute",
"<a",
"href",
"=",
"https",
":",
"//",
"www",
".",
"freebsd",
".",
"org",
"/",
"cgi",
"/",
"man",
".",
"cgi?sysctl",
"(",
"8",
")",
">",
"sysctl<",
"/",
"a",
">",
"with",
"the",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/NetUtil.java#L315-L339 | train | Get Integer from sysctl | [
30522,
2797,
10763,
16109,
25353,
11020,
19646,
18150,
18447,
1006,
5164,
25353,
11020,
19646,
14839,
1007,
11618,
22834,
10288,
24422,
1063,
2832,
2832,
1027,
2047,
2832,
8569,
23891,
2099,
1006,
1000,
25353,
11020,
19646,
1000,
1010,
25353,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getBeInt32 | public final int getBeInt32(final int pos) {
final int position = origin + pos;
if (pos + 3 >= limit || pos < 0) throw new IllegalArgumentException("limit excceed: "
+ (pos < 0 ? pos : (pos + 3)));
byte[] buf = buffer;
return (0xff & buf[position + 3]) | ((0xff & buf[position + 2]) << 8) | ((0xff & buf[position + 1]) << 16)
| ((buf[position]) << 24);
} | java | public final int getBeInt32(final int pos) {
final int position = origin + pos;
if (pos + 3 >= limit || pos < 0) throw new IllegalArgumentException("limit excceed: "
+ (pos < 0 ? pos : (pos + 3)));
byte[] buf = buffer;
return (0xff & buf[position + 3]) | ((0xff & buf[position + 2]) << 8) | ((0xff & buf[position + 1]) << 16)
| ((buf[position]) << 24);
} | [
"public",
"final",
"int",
"getBeInt32",
"(",
"final",
"int",
"pos",
")",
"{",
"final",
"int",
"position",
"=",
"origin",
"+",
"pos",
";",
"if",
"(",
"pos",
"+",
"3",
">=",
"limit",
"||",
"pos",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",... | Return 32-bit signed int from buffer. (big-endian)
@see mysql-5.6.10/include/myisampack.h - mi_sint4korr | [
"Return",
"32",
"-",
"bit",
"signed",
"int",
"from",
"buffer",
".",
"(",
"big",
"-",
"endian",
")"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L485-L494 | train | Gets a int from the buffer starting at the given position in the buffer as an int. | [
30522,
2270,
2345,
20014,
2131,
19205,
3372,
16703,
1006,
2345,
20014,
13433,
2015,
1007,
1063,
2345,
20014,
2597,
1027,
4761,
1009,
13433,
2015,
1025,
2065,
1006,
13433,
2015,
1009,
1017,
1028,
1027,
5787,
1064,
1064,
13433,
2015,
1026,
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... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/support/pagefactory/AjaxElementLocator.java | AjaxElementLocator.findElements | @Override
public List<WebElement> findElements() {
SlowLoadingElementList list = new SlowLoadingElementList(clock, timeOutInSeconds);
try {
return list.get().getElements();
} catch (NoSuchElementError e) {
return new ArrayList<>();
}
} | java | @Override
public List<WebElement> findElements() {
SlowLoadingElementList list = new SlowLoadingElementList(clock, timeOutInSeconds);
try {
return list.get().getElements();
} catch (NoSuchElementError e) {
return new ArrayList<>();
}
} | [
"@",
"Override",
"public",
"List",
"<",
"WebElement",
">",
"findElements",
"(",
")",
"{",
"SlowLoadingElementList",
"list",
"=",
"new",
"SlowLoadingElementList",
"(",
"clock",
",",
"timeOutInSeconds",
")",
";",
"try",
"{",
"return",
"list",
".",
"get",
"(",
... | {@inheritDoc}
Will poll the interface on a regular basis until at least one element is present. | [
"{",
"@inheritDoc",
"}"
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/pagefactory/AjaxElementLocator.java#L108-L116 | train | Override this method to return a list of elements. | [
30522,
1030,
2058,
15637,
2270,
2862,
1026,
4773,
12260,
3672,
1028,
2424,
12260,
8163,
1006,
1007,
1063,
4030,
18570,
12260,
3672,
9863,
2862,
1027,
2047,
4030,
18570,
12260,
3672,
9863,
1006,
5119,
1010,
2051,
5833,
7076,
8586,
15422,
201... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/datastream/DataStream.java | DataStream.print | @PublicEvolving
public DataStreamSink<T> print() {
PrintSinkFunction<T> printFunction = new PrintSinkFunction<>();
return addSink(printFunction).name("Print to Std. Out");
} | java | @PublicEvolving
public DataStreamSink<T> print() {
PrintSinkFunction<T> printFunction = new PrintSinkFunction<>();
return addSink(printFunction).name("Print to Std. Out");
} | [
"@",
"PublicEvolving",
"public",
"DataStreamSink",
"<",
"T",
">",
"print",
"(",
")",
"{",
"PrintSinkFunction",
"<",
"T",
">",
"printFunction",
"=",
"new",
"PrintSinkFunction",
"<>",
"(",
")",
";",
"return",
"addSink",
"(",
"printFunction",
")",
".",
"name",
... | Writes a DataStream to the standard output stream (stdout).
<p>For each element of the DataStream the result of {@link Object#toString()} is written.
<p>NOTE: This will print to stdout on the machine where the code is executed, i.e. the Flink
worker.
@return The closed DataStream. | [
"Writes",
"a",
"DataStream",
"to",
"the",
"standard",
"output",
"stream",
"(",
"stdout",
")",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java#L956-L960 | train | Print to Std. Out | [
30522,
1030,
2270,
6777,
4747,
6455,
2270,
2951,
21422,
11493,
2243,
1026,
1056,
1028,
6140,
1006,
1007,
1063,
11204,
19839,
11263,
27989,
1026,
1056,
1028,
6140,
11263,
27989,
1027,
2047,
11204,
19839,
11263,
27989,
1026,
1028,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java | JSONObject.getBoolean | public boolean getBoolean(String name) throws JSONException {
Object object = get(name);
Boolean result = JSON.toBoolean(object);
if (result == null) {
throw JSON.typeMismatch(name, object, "boolean");
}
return result;
} | java | public boolean getBoolean(String name) throws JSONException {
Object object = get(name);
Boolean result = JSON.toBoolean(object);
if (result == null) {
throw JSON.typeMismatch(name, object, "boolean");
}
return result;
} | [
"public",
"boolean",
"getBoolean",
"(",
"String",
"name",
")",
"throws",
"JSONException",
"{",
"Object",
"object",
"=",
"get",
"(",
"name",
")",
";",
"Boolean",
"result",
"=",
"JSON",
".",
"toBoolean",
"(",
"object",
")",
";",
"if",
"(",
"result",
"==",
... | Returns the value mapped by {@code name} if it exists and is a boolean or can be
coerced to a boolean.
@param name the name of the property
@return the value
@throws JSONException if the mapping doesn't exist or cannot be coerced to a
boolean. | [
"Returns",
"the",
"value",
"mapped",
"by",
"{"
] | 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/JSONObject.java#L398-L405 | train | Get the boolean value associated with a name. | [
30522,
2270,
22017,
20898,
2131,
5092,
9890,
2319,
1006,
5164,
2171,
1007,
11618,
1046,
3385,
10288,
24422,
1063,
4874,
4874,
1027,
2131,
1006,
2171,
1007,
1025,
22017,
20898,
2765,
1027,
1046,
3385,
1012,
2000,
5092,
9890,
2319,
1006,
4874... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java | HttpUtil.getCharsetAsSequence | public static CharSequence getCharsetAsSequence(CharSequence contentTypeValue) {
if (contentTypeValue == null) {
throw new NullPointerException("contentTypeValue");
}
int indexOfCharset = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, CHARSET_EQUALS, 0);
if (indexOfCharset == AsciiString.INDEX_NOT_FOUND) {
return null;
}
int indexOfEncoding = indexOfCharset + CHARSET_EQUALS.length();
if (indexOfEncoding < contentTypeValue.length()) {
CharSequence charsetCandidate = contentTypeValue.subSequence(indexOfEncoding, contentTypeValue.length());
int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(charsetCandidate, SEMICOLON, 0);
if (indexOfSemicolon == AsciiString.INDEX_NOT_FOUND) {
return charsetCandidate;
}
return charsetCandidate.subSequence(0, indexOfSemicolon);
}
return null;
} | java | public static CharSequence getCharsetAsSequence(CharSequence contentTypeValue) {
if (contentTypeValue == null) {
throw new NullPointerException("contentTypeValue");
}
int indexOfCharset = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, CHARSET_EQUALS, 0);
if (indexOfCharset == AsciiString.INDEX_NOT_FOUND) {
return null;
}
int indexOfEncoding = indexOfCharset + CHARSET_EQUALS.length();
if (indexOfEncoding < contentTypeValue.length()) {
CharSequence charsetCandidate = contentTypeValue.subSequence(indexOfEncoding, contentTypeValue.length());
int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(charsetCandidate, SEMICOLON, 0);
if (indexOfSemicolon == AsciiString.INDEX_NOT_FOUND) {
return charsetCandidate;
}
return charsetCandidate.subSequence(0, indexOfSemicolon);
}
return null;
} | [
"public",
"static",
"CharSequence",
"getCharsetAsSequence",
"(",
"CharSequence",
"contentTypeValue",
")",
"{",
"if",
"(",
"contentTypeValue",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"contentTypeValue\"",
")",
";",
"}",
"int",
"indexOfC... | Fetch charset from Content-Type header value as a char sequence.
A lot of sites/possibly clients have charset="CHARSET", for example charset="utf-8". Or "utf8" instead of "utf-8"
This is not according to standard, but this method provide an ability to catch desired mistakes manually in code
@param contentTypeValue Content-Type header value to parse
@return the {@code CharSequence} with charset from message's Content-Type header
or {@code null} if charset is not presented
@throws NullPointerException in case if {@code contentTypeValue == null} | [
"Fetch",
"charset",
"from",
"Content",
"-",
"Type",
"header",
"value",
"as",
"a",
"char",
"sequence",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java#L450-L472 | train | Get charset as sequence. | [
30522,
2270,
10763,
25869,
3366,
4226,
5897,
2131,
7507,
22573,
10230,
3366,
4226,
5897,
1006,
25869,
3366,
4226,
5897,
4180,
13874,
10175,
5657,
1007,
1063,
2065,
1006,
4180,
13874,
10175,
5657,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/query/KvStateInfo.java | KvStateInfo.duplicate | public KvStateInfo<K, N, V> duplicate() {
final TypeSerializer<K> dupKeySerializer = keySerializer.duplicate();
final TypeSerializer<N> dupNamespaceSerializer = namespaceSerializer.duplicate();
final TypeSerializer<V> dupSVSerializer = stateValueSerializer.duplicate();
if (
dupKeySerializer == keySerializer &&
dupNamespaceSerializer == namespaceSerializer &&
dupSVSerializer == stateValueSerializer
) {
return this;
}
return new KvStateInfo<>(dupKeySerializer, dupNamespaceSerializer, dupSVSerializer);
} | java | public KvStateInfo<K, N, V> duplicate() {
final TypeSerializer<K> dupKeySerializer = keySerializer.duplicate();
final TypeSerializer<N> dupNamespaceSerializer = namespaceSerializer.duplicate();
final TypeSerializer<V> dupSVSerializer = stateValueSerializer.duplicate();
if (
dupKeySerializer == keySerializer &&
dupNamespaceSerializer == namespaceSerializer &&
dupSVSerializer == stateValueSerializer
) {
return this;
}
return new KvStateInfo<>(dupKeySerializer, dupNamespaceSerializer, dupSVSerializer);
} | [
"public",
"KvStateInfo",
"<",
"K",
",",
"N",
",",
"V",
">",
"duplicate",
"(",
")",
"{",
"final",
"TypeSerializer",
"<",
"K",
">",
"dupKeySerializer",
"=",
"keySerializer",
".",
"duplicate",
"(",
")",
";",
"final",
"TypeSerializer",
"<",
"N",
">",
"dupNam... | Creates a deep copy of the current {@link KvStateInfo} by duplicating
all the included serializers.
<p>This method assumes correct implementation of the {@link TypeSerializer#duplicate()}
method of the included serializers. | [
"Creates",
"a",
"deep",
"copy",
"of",
"the",
"current",
"{",
"@link",
"KvStateInfo",
"}",
"by",
"duplicating",
"all",
"the",
"included",
"serializers",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/query/KvStateInfo.java#L79-L94 | train | Returns a duplicate of this state info. | [
30522,
2270,
24888,
9153,
9589,
14876,
1026,
1047,
1010,
1050,
1010,
1058,
1028,
24473,
1006,
1007,
1063,
2345,
4127,
11610,
28863,
1026,
1047,
1028,
4241,
2361,
14839,
8043,
4818,
17629,
1027,
6309,
11610,
28863,
1012,
24473,
1006,
1007,
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-extra/src/main/java/cn/hutool/extra/servlet/ServletUtil.java | ServletUtil.getCookie | public final static Cookie getCookie(HttpServletRequest httpServletRequest, String name) {
final Map<String, Cookie> cookieMap = readCookieMap(httpServletRequest);
return cookieMap == null ? null : cookieMap.get(name);
} | java | public final static Cookie getCookie(HttpServletRequest httpServletRequest, String name) {
final Map<String, Cookie> cookieMap = readCookieMap(httpServletRequest);
return cookieMap == null ? null : cookieMap.get(name);
} | [
"public",
"final",
"static",
"Cookie",
"getCookie",
"(",
"HttpServletRequest",
"httpServletRequest",
",",
"String",
"name",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Cookie",
">",
"cookieMap",
"=",
"readCookieMap",
"(",
"httpServletRequest",
")",
";",
"retu... | 获得指定的Cookie
@param httpServletRequest {@link HttpServletRequest}
@param name cookie名
@return Cookie对象 | [
"获得指定的Cookie"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/servlet/ServletUtil.java#L378-L381 | train | Gets the cookie with the given name from the request. | [
30522,
2270,
2345,
10763,
17387,
2131,
3597,
23212,
2063,
1006,
16770,
2121,
2615,
7485,
2890,
15500,
16770,
2121,
2615,
7485,
2890,
15500,
1010,
5164,
2171,
1007,
1063,
2345,
4949,
1026,
5164,
1010,
17387,
1028,
17387,
2863,
2361,
1027,
31... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-setting/src/main/java/cn/hutool/setting/Setting.java | Setting.putAll | @Override
public void putAll(Map<? extends String, ? extends String> m) {
this.groupedMap.putAll(DEFAULT_GROUP, m);
} | java | @Override
public void putAll(Map<? extends String, ? extends String> m) {
this.groupedMap.putAll(DEFAULT_GROUP, m);
} | [
"@",
"Override",
"public",
"void",
"putAll",
"(",
"Map",
"<",
"?",
"extends",
"String",
",",
"?",
"extends",
"String",
">",
"m",
")",
"{",
"this",
".",
"groupedMap",
".",
"putAll",
"(",
"DEFAULT_GROUP",
",",
"m",
")",
";",
"}"
] | 将键值对Map加入默认分组(空分组)中
@param m Map | [
"将键值对Map加入默认分组(空分组)中"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/Setting.java#L582-L585 | train | Override this method to add all entries from the given map to the default group. | [
30522,
1030,
2058,
15637,
2270,
11675,
2404,
30524,
5164,
1028,
1049,
1007,
1063,
2023,
1012,
15131,
2863,
2361,
1012,
2404,
8095,
1006,
12398,
1035,
2177,
1010,
1049,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java | Sftp.lsDirs | public List<String> lsDirs(String path) {
return ls(path, new Filter<LsEntry>() {
@Override
public boolean accept(LsEntry t) {
return t.getAttrs().isDir();
}
});
} | java | public List<String> lsDirs(String path) {
return ls(path, new Filter<LsEntry>() {
@Override
public boolean accept(LsEntry t) {
return t.getAttrs().isDir();
}
});
} | [
"public",
"List",
"<",
"String",
">",
"lsDirs",
"(",
"String",
"path",
")",
"{",
"return",
"ls",
"(",
"path",
",",
"new",
"Filter",
"<",
"LsEntry",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"LsEntry",
"t",
")",
"{",
"... | 遍历某个目录下所有目录,不会递归遍历
@param path 遍历某个目录下所有目录
@return 目录名列表
@since 4.0.5 | [
"遍历某个目录下所有目录,不会递归遍历"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java#L206-L213 | train | Returns a list of directories under the given path. | [
30522,
2270,
2862,
1026,
5164,
1028,
1048,
16150,
18894,
1006,
5164,
4130,
1007,
1063,
2709,
1048,
2015,
1006,
4130,
1010,
2047,
11307,
1026,
1048,
5054,
11129,
1028,
1006,
1007,
1063,
1030,
2058,
15637,
2270,
22017,
20898,
5138,
1006,
1048... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.transformTwoInputTransform | private <IN1, IN2, OUT> Collection<Integer> transformTwoInputTransform(TwoInputTransformation<IN1, IN2, OUT> transform) {
Collection<Integer> inputIds1 = transform(transform.getInput1());
Collection<Integer> inputIds2 = transform(transform.getInput2());
// the recursive call might have already transformed this
if (alreadyTransformed.containsKey(transform)) {
return alreadyTransformed.get(transform);
}
List<Integer> allInputIds = new ArrayList<>();
allInputIds.addAll(inputIds1);
allInputIds.addAll(inputIds2);
String slotSharingGroup = determineSlotSharingGroup(transform.getSlotSharingGroup(), allInputIds);
streamGraph.addCoOperator(
transform.getId(),
slotSharingGroup,
transform.getCoLocationGroupKey(),
transform.getOperator(),
transform.getInputType1(),
transform.getInputType2(),
transform.getOutputType(),
transform.getName());
if (transform.getStateKeySelector1() != null || transform.getStateKeySelector2() != null) {
TypeSerializer<?> keySerializer = transform.getStateKeyType().createSerializer(env.getConfig());
streamGraph.setTwoInputStateKey(transform.getId(), transform.getStateKeySelector1(), transform.getStateKeySelector2(), keySerializer);
}
streamGraph.setParallelism(transform.getId(), transform.getParallelism());
streamGraph.setMaxParallelism(transform.getId(), transform.getMaxParallelism());
for (Integer inputId: inputIds1) {
streamGraph.addEdge(inputId,
transform.getId(),
1
);
}
for (Integer inputId: inputIds2) {
streamGraph.addEdge(inputId,
transform.getId(),
2
);
}
return Collections.singleton(transform.getId());
} | java | private <IN1, IN2, OUT> Collection<Integer> transformTwoInputTransform(TwoInputTransformation<IN1, IN2, OUT> transform) {
Collection<Integer> inputIds1 = transform(transform.getInput1());
Collection<Integer> inputIds2 = transform(transform.getInput2());
// the recursive call might have already transformed this
if (alreadyTransformed.containsKey(transform)) {
return alreadyTransformed.get(transform);
}
List<Integer> allInputIds = new ArrayList<>();
allInputIds.addAll(inputIds1);
allInputIds.addAll(inputIds2);
String slotSharingGroup = determineSlotSharingGroup(transform.getSlotSharingGroup(), allInputIds);
streamGraph.addCoOperator(
transform.getId(),
slotSharingGroup,
transform.getCoLocationGroupKey(),
transform.getOperator(),
transform.getInputType1(),
transform.getInputType2(),
transform.getOutputType(),
transform.getName());
if (transform.getStateKeySelector1() != null || transform.getStateKeySelector2() != null) {
TypeSerializer<?> keySerializer = transform.getStateKeyType().createSerializer(env.getConfig());
streamGraph.setTwoInputStateKey(transform.getId(), transform.getStateKeySelector1(), transform.getStateKeySelector2(), keySerializer);
}
streamGraph.setParallelism(transform.getId(), transform.getParallelism());
streamGraph.setMaxParallelism(transform.getId(), transform.getMaxParallelism());
for (Integer inputId: inputIds1) {
streamGraph.addEdge(inputId,
transform.getId(),
1
);
}
for (Integer inputId: inputIds2) {
streamGraph.addEdge(inputId,
transform.getId(),
2
);
}
return Collections.singleton(transform.getId());
} | [
"private",
"<",
"IN1",
",",
"IN2",
",",
"OUT",
">",
"Collection",
"<",
"Integer",
">",
"transformTwoInputTransform",
"(",
"TwoInputTransformation",
"<",
"IN1",
",",
"IN2",
",",
"OUT",
">",
"transform",
")",
"{",
"Collection",
"<",
"Integer",
">",
"inputIds1"... | Transforms a {@code TwoInputTransformation}.
<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",
"TwoInputTransformation",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraphGenerator.java#L577-L626 | train | Transform two input transforms. | [
30522,
2797,
1026,
1999,
2487,
1010,
1999,
2475,
1010,
2041,
1028,
3074,
1026,
16109,
1028,
10938,
2102,
12155,
2378,
18780,
6494,
3619,
14192,
1006,
2048,
2378,
18780,
6494,
3619,
14192,
3370,
1026,
1999,
2487,
1010,
1999,
2475,
1010,
2041... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Record.java | Record.getFieldsIntoCheckingNull | public void getFieldsIntoCheckingNull(int[] positions, Value[] targets) {
for (int i = 0; i < positions.length; i++) {
if (!getFieldInto(positions[i], targets[i])) {
throw new NullKeyFieldException(i);
}
}
} | java | public void getFieldsIntoCheckingNull(int[] positions, Value[] targets) {
for (int i = 0; i < positions.length; i++) {
if (!getFieldInto(positions[i], targets[i])) {
throw new NullKeyFieldException(i);
}
}
} | [
"public",
"void",
"getFieldsIntoCheckingNull",
"(",
"int",
"[",
"]",
"positions",
",",
"Value",
"[",
"]",
"targets",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"positions",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
... | Gets the fields at the given positions into an array.
If at any position a field is null, then this method throws a @link NullKeyFieldException.
All fields that have been successfully read until the failing read are correctly contained in the record.
All other fields are not set.
@param positions The positions of the fields to get.
@param targets The values into which the content of the fields is put.
@throws NullKeyFieldException in case of a failing field read. | [
"Gets",
"the",
"fields",
"at",
"the",
"given",
"positions",
"into",
"an",
"array",
".",
"If",
"at",
"any",
"position",
"a",
"field",
"is",
"null",
"then",
"this",
"method",
"throws",
"a",
"@link",
"NullKeyFieldException",
".",
"All",
"fields",
"that",
"hav... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/Record.java#L357-L363 | train | Gets the fields into checking that they are null. | [
30522,
2270,
11675,
2131,
15155,
18447,
23555,
23177,
11231,
3363,
1006,
20014,
1031,
1033,
4460,
1010,
3643,
1031,
1033,
7889,
1007,
1063,
2005,
1006,
20014,
1045,
1027,
1014,
1025,
1045,
1026,
4460,
1012,
3091,
1025,
1045,
1009,
1009,
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... |
apache/flink | flink-optimizer/src/main/java/org/apache/flink/optimizer/dataproperties/RequestedGlobalProperties.java | RequestedGlobalProperties.isMetBy | public boolean isMetBy(GlobalProperties props) {
if (this.partitioning == PartitioningProperty.ANY_DISTRIBUTION) {
return true;
} else if (this.partitioning == PartitioningProperty.FULL_REPLICATION) {
return props.isFullyReplicated();
}
else if (props.isFullyReplicated()) {
return false;
}
else if (this.partitioning == PartitioningProperty.RANDOM_PARTITIONED) {
return true;
}
else if (this.partitioning == PartitioningProperty.ANY_PARTITIONING) {
return checkCompatiblePartitioningFields(props);
}
else if (this.partitioning == PartitioningProperty.HASH_PARTITIONED) {
return props.getPartitioning() == PartitioningProperty.HASH_PARTITIONED &&
checkCompatiblePartitioningFields(props);
}
else if (this.partitioning == PartitioningProperty.RANGE_PARTITIONED) {
return props.getPartitioning() == PartitioningProperty.RANGE_PARTITIONED &&
props.matchesOrderedPartitioning(this.ordering);
}
else if (this.partitioning == PartitioningProperty.FORCED_REBALANCED) {
return props.getPartitioning() == PartitioningProperty.FORCED_REBALANCED;
}
else if (this.partitioning == PartitioningProperty.CUSTOM_PARTITIONING) {
return props.getPartitioning() == PartitioningProperty.CUSTOM_PARTITIONING &&
checkCompatiblePartitioningFields(props) &&
props.getCustomPartitioner().equals(this.customPartitioner);
}
else {
throw new CompilerException("Properties matching logic leaves open cases.");
}
} | java | public boolean isMetBy(GlobalProperties props) {
if (this.partitioning == PartitioningProperty.ANY_DISTRIBUTION) {
return true;
} else if (this.partitioning == PartitioningProperty.FULL_REPLICATION) {
return props.isFullyReplicated();
}
else if (props.isFullyReplicated()) {
return false;
}
else if (this.partitioning == PartitioningProperty.RANDOM_PARTITIONED) {
return true;
}
else if (this.partitioning == PartitioningProperty.ANY_PARTITIONING) {
return checkCompatiblePartitioningFields(props);
}
else if (this.partitioning == PartitioningProperty.HASH_PARTITIONED) {
return props.getPartitioning() == PartitioningProperty.HASH_PARTITIONED &&
checkCompatiblePartitioningFields(props);
}
else if (this.partitioning == PartitioningProperty.RANGE_PARTITIONED) {
return props.getPartitioning() == PartitioningProperty.RANGE_PARTITIONED &&
props.matchesOrderedPartitioning(this.ordering);
}
else if (this.partitioning == PartitioningProperty.FORCED_REBALANCED) {
return props.getPartitioning() == PartitioningProperty.FORCED_REBALANCED;
}
else if (this.partitioning == PartitioningProperty.CUSTOM_PARTITIONING) {
return props.getPartitioning() == PartitioningProperty.CUSTOM_PARTITIONING &&
checkCompatiblePartitioningFields(props) &&
props.getCustomPartitioner().equals(this.customPartitioner);
}
else {
throw new CompilerException("Properties matching logic leaves open cases.");
}
} | [
"public",
"boolean",
"isMetBy",
"(",
"GlobalProperties",
"props",
")",
"{",
"if",
"(",
"this",
".",
"partitioning",
"==",
"PartitioningProperty",
".",
"ANY_DISTRIBUTION",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"this",
".",
"partitioning",
"... | Checks, if this set of interesting properties, is met by the given
produced properties.
@param props The properties for which to check whether they meet these properties.
@return True, if the properties are met, false otherwise. | [
"Checks",
"if",
"this",
"set",
"of",
"interesting",
"properties",
"is",
"met",
"by",
"the",
"given",
"produced",
"properties",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/dataproperties/RequestedGlobalProperties.java#L301-L336 | train | Checks if the properties are met by this node. | [
30522,
2270,
22017,
20898,
2003,
11368,
3762,
1006,
3795,
21572,
4842,
7368,
24387,
1007,
1063,
2065,
1006,
2023,
1012,
13571,
2075,
1027,
1027,
13571,
2075,
21572,
4842,
3723,
1012,
2151,
1035,
4353,
1007,
1063,
2709,
2995,
1025,
1065,
284... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/LengthFieldBasedFrameDecoder.java | LengthFieldBasedFrameDecoder.decode | protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
if (discardingTooLongFrame) {
discardingTooLongFrame(in);
}
if (in.readableBytes() < lengthFieldEndOffset) {
return null;
}
int actualLengthFieldOffset = in.readerIndex() + lengthFieldOffset;
long frameLength = getUnadjustedFrameLength(in, actualLengthFieldOffset, lengthFieldLength, byteOrder);
if (frameLength < 0) {
failOnNegativeLengthField(in, frameLength, lengthFieldEndOffset);
}
frameLength += lengthAdjustment + lengthFieldEndOffset;
if (frameLength < lengthFieldEndOffset) {
failOnFrameLengthLessThanLengthFieldEndOffset(in, frameLength, lengthFieldEndOffset);
}
if (frameLength > maxFrameLength) {
exceededFrameLength(in, frameLength);
return null;
}
// never overflows because it's less than maxFrameLength
int frameLengthInt = (int) frameLength;
if (in.readableBytes() < frameLengthInt) {
return null;
}
if (initialBytesToStrip > frameLengthInt) {
failOnFrameLengthLessThanInitialBytesToStrip(in, frameLength, initialBytesToStrip);
}
in.skipBytes(initialBytesToStrip);
// extract frame
int readerIndex = in.readerIndex();
int actualFrameLength = frameLengthInt - initialBytesToStrip;
ByteBuf frame = extractFrame(ctx, in, readerIndex, actualFrameLength);
in.readerIndex(readerIndex + actualFrameLength);
return frame;
} | java | protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
if (discardingTooLongFrame) {
discardingTooLongFrame(in);
}
if (in.readableBytes() < lengthFieldEndOffset) {
return null;
}
int actualLengthFieldOffset = in.readerIndex() + lengthFieldOffset;
long frameLength = getUnadjustedFrameLength(in, actualLengthFieldOffset, lengthFieldLength, byteOrder);
if (frameLength < 0) {
failOnNegativeLengthField(in, frameLength, lengthFieldEndOffset);
}
frameLength += lengthAdjustment + lengthFieldEndOffset;
if (frameLength < lengthFieldEndOffset) {
failOnFrameLengthLessThanLengthFieldEndOffset(in, frameLength, lengthFieldEndOffset);
}
if (frameLength > maxFrameLength) {
exceededFrameLength(in, frameLength);
return null;
}
// never overflows because it's less than maxFrameLength
int frameLengthInt = (int) frameLength;
if (in.readableBytes() < frameLengthInt) {
return null;
}
if (initialBytesToStrip > frameLengthInt) {
failOnFrameLengthLessThanInitialBytesToStrip(in, frameLength, initialBytesToStrip);
}
in.skipBytes(initialBytesToStrip);
// extract frame
int readerIndex = in.readerIndex();
int actualFrameLength = frameLengthInt - initialBytesToStrip;
ByteBuf frame = extractFrame(ctx, in, readerIndex, actualFrameLength);
in.readerIndex(readerIndex + actualFrameLength);
return frame;
} | [
"protected",
"Object",
"decode",
"(",
"ChannelHandlerContext",
"ctx",
",",
"ByteBuf",
"in",
")",
"throws",
"Exception",
"{",
"if",
"(",
"discardingTooLongFrame",
")",
"{",
"discardingTooLongFrame",
"(",
"in",
")",
";",
"}",
"if",
"(",
"in",
".",
"readableBytes... | Create a frame out of the {@link ByteBuf} and return it.
@param ctx the {@link ChannelHandlerContext} which this {@link ByteToMessageDecoder} belongs to
@param in the {@link ByteBuf} from which to read data
@return frame the {@link ByteBuf} which represent the frame or {@code null} if no frame could
be created. | [
"Create",
"a",
"frame",
"out",
"of",
"the",
"{",
"@link",
"ByteBuf",
"}",
"and",
"return",
"it",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java#L398-L442 | train | Decode a single frame from the input buffer. | [
30522,
5123,
4874,
21933,
3207,
1006,
3149,
11774,
3917,
8663,
18209,
14931,
2595,
1010,
24880,
8569,
2546,
1999,
1007,
11618,
6453,
1063,
2065,
1006,
5860,
29154,
3406,
12898,
3070,
15643,
1007,
1063,
5860,
29154,
3406,
12898,
3070,
15643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/map/MapUtil.java | MapUtil.join | public static <K, V> String join(Map<K, V> map, String separator, String keyValueSeparator, boolean isIgnoreNull) {
final StringBuilder strBuilder = StrUtil.builder();
boolean isFirst = true;
for (Entry<K, V> entry : map.entrySet()) {
if (false == isIgnoreNull || entry.getKey() != null && entry.getValue() != null) {
if (isFirst) {
isFirst = false;
} else {
strBuilder.append(separator);
}
strBuilder.append(Convert.toStr(entry.getKey())).append(keyValueSeparator).append(Convert.toStr(entry.getValue()));
}
}
return strBuilder.toString();
} | java | public static <K, V> String join(Map<K, V> map, String separator, String keyValueSeparator, boolean isIgnoreNull) {
final StringBuilder strBuilder = StrUtil.builder();
boolean isFirst = true;
for (Entry<K, V> entry : map.entrySet()) {
if (false == isIgnoreNull || entry.getKey() != null && entry.getValue() != null) {
if (isFirst) {
isFirst = false;
} else {
strBuilder.append(separator);
}
strBuilder.append(Convert.toStr(entry.getKey())).append(keyValueSeparator).append(Convert.toStr(entry.getValue()));
}
}
return strBuilder.toString();
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"String",
"join",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"String",
"separator",
",",
"String",
"keyValueSeparator",
",",
"boolean",
"isIgnoreNull",
")",
"{",
"final",
"StringBuilder",
"strBuilder",
"... | 将map转成字符串
@param <K> 键类型
@param <V> 值类型
@param map Map
@param separator entry之间的连接符
@param keyValueSeparator kv之间的连接符
@param isIgnoreNull 是否忽略null的键和值
@return 连接后的字符串
@since 3.1.1 | [
"将map转成字符串"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L458-L472 | train | Joins the specified map with the specified separator and keyValue separators. | [
30522,
2270,
10763,
1026,
1047,
1010,
1058,
1028,
5164,
3693,
1006,
4949,
1026,
1047,
1010,
1058,
1028,
4949,
1010,
5164,
19802,
25879,
2953,
1010,
5164,
3145,
10175,
15808,
13699,
25879,
2953,
1010,
22017,
20898,
2003,
23773,
5686,
11231,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/AutoConfigurationImportSelector.java | AutoConfigurationImportSelector.getCandidateConfigurations | protected List<String> getCandidateConfigurations(AnnotationMetadata metadata,
AnnotationAttributes attributes) {
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(
getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader());
Assert.notEmpty(configurations,
"No auto configuration classes found in META-INF/spring.factories. If you "
+ "are using a custom packaging, make sure that file is correct.");
return configurations;
} | java | protected List<String> getCandidateConfigurations(AnnotationMetadata metadata,
AnnotationAttributes attributes) {
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(
getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader());
Assert.notEmpty(configurations,
"No auto configuration classes found in META-INF/spring.factories. If you "
+ "are using a custom packaging, make sure that file is correct.");
return configurations;
} | [
"protected",
"List",
"<",
"String",
">",
"getCandidateConfigurations",
"(",
"AnnotationMetadata",
"metadata",
",",
"AnnotationAttributes",
"attributes",
")",
"{",
"List",
"<",
"String",
">",
"configurations",
"=",
"SpringFactoriesLoader",
".",
"loadFactoryNames",
"(",
... | Return the auto-configuration class names that should be considered. By default
this method will load candidates using {@link SpringFactoriesLoader} with
{@link #getSpringFactoriesLoaderFactoryClass()}.
@param metadata the source metadata
@param attributes the {@link #getAttributes(AnnotationMetadata) annotation
attributes}
@return a list of candidate configurations | [
"Return",
"the",
"auto",
"-",
"configuration",
"class",
"names",
"that",
"should",
"be",
"considered",
".",
"By",
"default",
"this",
"method",
"will",
"load",
"candidates",
"using",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java#L179-L187 | train | Get the list of configuration classes that are found in META - INF. spring. factories. | [
30522,
5123,
2862,
1026,
5164,
1028,
2131,
9336,
4305,
13701,
8663,
8873,
27390,
10708,
1006,
5754,
17287,
3508,
11368,
8447,
2696,
27425,
1010,
5754,
17287,
3508,
19321,
3089,
8569,
4570,
12332,
1007,
1063,
2862,
1026,
5164,
1028,
22354,
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/collection/AhoCorasick/AhoCorasickDoubleArrayTrie.java | AhoCorasickDoubleArrayTrie.parseText | public void parseText(char[] text, IHit<V> processor)
{
int position = 1;
int currentState = 0;
for (char c : text)
{
currentState = getState(currentState, c);
int[] hitArray = output[currentState];
if (hitArray != null)
{
for (int hit : hitArray)
{
processor.hit(position - l[hit], position, v[hit]);
}
}
++position;
}
} | java | public void parseText(char[] text, IHit<V> processor)
{
int position = 1;
int currentState = 0;
for (char c : text)
{
currentState = getState(currentState, c);
int[] hitArray = output[currentState];
if (hitArray != null)
{
for (int hit : hitArray)
{
processor.hit(position - l[hit], position, v[hit]);
}
}
++position;
}
} | [
"public",
"void",
"parseText",
"(",
"char",
"[",
"]",
"text",
",",
"IHit",
"<",
"V",
">",
"processor",
")",
"{",
"int",
"position",
"=",
"1",
";",
"int",
"currentState",
"=",
"0",
";",
"for",
"(",
"char",
"c",
":",
"text",
")",
"{",
"currentState",... | 处理文本
@param text
@param processor | [
"处理文本"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/AhoCorasick/AhoCorasickDoubleArrayTrie.java#L128-L145 | train | Parse text. | [
30522,
2270,
11675,
11968,
13462,
10288,
2102,
1006,
25869,
1031,
1033,
3793,
1010,
1045,
16584,
1026,
1058,
1028,
13151,
1007,
1063,
20014,
2597,
1027,
1015,
1025,
20014,
14731,
12259,
1027,
1014,
1025,
2005,
1006,
25869,
1039,
1024,
3793,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/ObjectId.java | ObjectId.getProcessPiece | private static int getProcessPiece() {
// 进程码
// 因为静态变量类加载可能相同,所以要获取进程ID + 加载对象的ID值
final int processPiece;
// 进程ID初始化
int processId;
try {
// 获取进程ID
final String processName =ManagementFactory.getRuntimeMXBean().getName();
final int atIndex = processName.indexOf('@');
if (atIndex > 0) {
processId = Integer.parseInt(processName.substring(0, atIndex));
} else {
processId = processName.hashCode();
}
} catch (Throwable t) {
processId = RandomUtil.randomInt();
}
final ClassLoader loader = ClassLoaderUtil.getClassLoader();
// 返回对象哈希码,无论是否重写hashCode方法
int loaderId = (loader != null) ? System.identityHashCode(loader) : 0;
// 进程ID + 对象加载ID
StringBuilder processSb = new StringBuilder();
processSb.append(Integer.toHexString(processId));
processSb.append(Integer.toHexString(loaderId));
// 保留前2位
processPiece = processSb.toString().hashCode() & 0xFFFF;
return processPiece;
} | java | private static int getProcessPiece() {
// 进程码
// 因为静态变量类加载可能相同,所以要获取进程ID + 加载对象的ID值
final int processPiece;
// 进程ID初始化
int processId;
try {
// 获取进程ID
final String processName =ManagementFactory.getRuntimeMXBean().getName();
final int atIndex = processName.indexOf('@');
if (atIndex > 0) {
processId = Integer.parseInt(processName.substring(0, atIndex));
} else {
processId = processName.hashCode();
}
} catch (Throwable t) {
processId = RandomUtil.randomInt();
}
final ClassLoader loader = ClassLoaderUtil.getClassLoader();
// 返回对象哈希码,无论是否重写hashCode方法
int loaderId = (loader != null) ? System.identityHashCode(loader) : 0;
// 进程ID + 对象加载ID
StringBuilder processSb = new StringBuilder();
processSb.append(Integer.toHexString(processId));
processSb.append(Integer.toHexString(loaderId));
// 保留前2位
processPiece = processSb.toString().hashCode() & 0xFFFF;
return processPiece;
} | [
"private",
"static",
"int",
"getProcessPiece",
"(",
")",
"{",
"// 进程码\r",
"// 因为静态变量类加载可能相同,所以要获取进程ID + 加载对象的ID值\r",
"final",
"int",
"processPiece",
";",
"// 进程ID初始化\r",
"int",
"processId",
";",
"try",
"{",
"// 获取进程ID\r",
"final",
"String",
"processName",
"=",
"Manage... | 获取进程码片段
@return 进程码片段 | [
"获取进程码片段"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/ObjectId.java#L152-L183 | train | Gets the processPiece. | [
30522,
2797,
10763,
20014,
2131,
21572,
9623,
13102,
23783,
2063,
1006,
1007,
1063,
1013,
1013,
100,
100,
100,
1013,
1013,
100,
100,
100,
100,
100,
100,
100,
1779,
100,
100,
100,
1919,
1794,
1010,
100,
100,
100,
100,
100,
100,
100,
89... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.convertLineSeparator | public static File convertLineSeparator(File file, Charset charset, LineSeparator lineSeparator) {
final List<String> lines = readLines(file, charset);
return FileWriter.create(file, charset).writeLines(lines, lineSeparator, false);
} | java | public static File convertLineSeparator(File file, Charset charset, LineSeparator lineSeparator) {
final List<String> lines = readLines(file, charset);
return FileWriter.create(file, charset).writeLines(lines, lineSeparator, false);
} | [
"public",
"static",
"File",
"convertLineSeparator",
"(",
"File",
"file",
",",
"Charset",
"charset",
",",
"LineSeparator",
"lineSeparator",
")",
"{",
"final",
"List",
"<",
"String",
">",
"lines",
"=",
"readLines",
"(",
"file",
",",
"charset",
")",
";",
"retur... | 转换换行符<br>
将给定文件的换行符转换为指定换行符
@param file 文件
@param charset 编码
@param lineSeparator 换行符枚举{@link LineSeparator}
@return 被修改的文件
@since 3.1.0 | [
"转换换行符<br",
">",
"将给定文件的换行符转换为指定换行符"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L3243-L3246 | train | Converts the line separator from UTF - 8 to UTF - 8. | [
30522,
2270,
10763,
5371,
10463,
12735,
13699,
25879,
2953,
1006,
5371,
5371,
1010,
25869,
13462,
25869,
13462,
1010,
3210,
13699,
25879,
2953,
3210,
13699,
25879,
2953,
1007,
1063,
2345,
2862,
1026,
5164,
1028,
3210,
1027,
3191,
12735,
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-swift-fs-hadoop/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.handleDeprecation | private String[] handleDeprecation(DeprecationContext deprecations,
String name) {
if (null != name) {
name = name.trim();
}
ArrayList<String > names = new ArrayList<String>();
if (isDeprecated(name)) {
DeprecatedKeyInfo keyInfo = deprecations.getDeprecatedKeyMap().get(name);
warnOnceIfDeprecated(deprecations, name);
for (String newKey : keyInfo.newKeys) {
if(newKey != null) {
names.add(newKey);
}
}
}
if(names.size() == 0) {
names.add(name);
}
for(String n : names) {
String deprecatedKey = deprecations.getReverseDeprecatedKeyMap().get(n);
if (deprecatedKey != null && !getOverlay().containsKey(n) &&
getOverlay().containsKey(deprecatedKey)) {
getProps().setProperty(n, getOverlay().getProperty(deprecatedKey));
getOverlay().setProperty(n, getOverlay().getProperty(deprecatedKey));
}
}
return names.toArray(new String[names.size()]);
} | java | private String[] handleDeprecation(DeprecationContext deprecations,
String name) {
if (null != name) {
name = name.trim();
}
ArrayList<String > names = new ArrayList<String>();
if (isDeprecated(name)) {
DeprecatedKeyInfo keyInfo = deprecations.getDeprecatedKeyMap().get(name);
warnOnceIfDeprecated(deprecations, name);
for (String newKey : keyInfo.newKeys) {
if(newKey != null) {
names.add(newKey);
}
}
}
if(names.size() == 0) {
names.add(name);
}
for(String n : names) {
String deprecatedKey = deprecations.getReverseDeprecatedKeyMap().get(n);
if (deprecatedKey != null && !getOverlay().containsKey(n) &&
getOverlay().containsKey(deprecatedKey)) {
getProps().setProperty(n, getOverlay().getProperty(deprecatedKey));
getOverlay().setProperty(n, getOverlay().getProperty(deprecatedKey));
}
}
return names.toArray(new String[names.size()]);
} | [
"private",
"String",
"[",
"]",
"handleDeprecation",
"(",
"DeprecationContext",
"deprecations",
",",
"String",
"name",
")",
"{",
"if",
"(",
"null",
"!=",
"name",
")",
"{",
"name",
"=",
"name",
".",
"trim",
"(",
")",
";",
"}",
"ArrayList",
"<",
"String",
... | Checks for the presence of the property <code>name</code> in the
deprecation map. Returns the first of the list of new keys if present
in the deprecation map or the <code>name</code> itself. If the property
is not presently set but the property map contains an entry for the
deprecated key, the value of the deprecated key is set as the value for
the provided property name.
@param name the property name
@return the first property in the list of properties mapping
the <code>name</code> or the <code>name</code> itself. | [
"Checks",
"for",
"the",
"presence",
"of",
"the",
"property",
"<code",
">",
"name<",
"/",
"code",
">",
"in",
"the",
"deprecation",
"map",
".",
"Returns",
"the",
"first",
"of",
"the",
"list",
"of",
"new",
"keys",
"if",
"present",
"in",
"the",
"deprecation"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-swift-fs-hadoop/src/main/java/org/apache/hadoop/conf/Configuration.java#L583-L610 | train | Handle deprecated key. | [
30522,
2797,
5164,
1031,
1033,
8971,
13699,
2890,
10719,
1006,
2139,
28139,
10719,
8663,
18209,
2139,
28139,
10719,
2015,
1010,
5164,
2171,
1007,
1063,
2065,
1006,
19701,
999,
1027,
2171,
1007,
1063,
2171,
1027,
2171,
1012,
12241,
1006,
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... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java | CheckpointCoordinator.discardCheckpoint | private void discardCheckpoint(PendingCheckpoint pendingCheckpoint, @Nullable Throwable cause) {
assert(Thread.holdsLock(lock));
Preconditions.checkNotNull(pendingCheckpoint);
final long checkpointId = pendingCheckpoint.getCheckpointId();
LOG.info("Discarding checkpoint {} of job {}.", checkpointId, job, cause);
if (cause == null || cause instanceof CheckpointDeclineException) {
pendingCheckpoint.abort(CheckpointFailureReason.CHECKPOINT_DECLINED, cause);
} else {
pendingCheckpoint.abort(CheckpointFailureReason.JOB_FAILURE, cause);
}
rememberRecentCheckpointId(checkpointId);
// we don't have to schedule another "dissolving" checkpoint any more because the
// cancellation barriers take care of breaking downstream alignments
// we only need to make sure that suspended queued requests are resumed
boolean haveMoreRecentPending = false;
for (PendingCheckpoint p : pendingCheckpoints.values()) {
if (!p.isDiscarded() && p.getCheckpointId() >= pendingCheckpoint.getCheckpointId()) {
haveMoreRecentPending = true;
break;
}
}
if (!haveMoreRecentPending) {
triggerQueuedRequests();
}
} | java | private void discardCheckpoint(PendingCheckpoint pendingCheckpoint, @Nullable Throwable cause) {
assert(Thread.holdsLock(lock));
Preconditions.checkNotNull(pendingCheckpoint);
final long checkpointId = pendingCheckpoint.getCheckpointId();
LOG.info("Discarding checkpoint {} of job {}.", checkpointId, job, cause);
if (cause == null || cause instanceof CheckpointDeclineException) {
pendingCheckpoint.abort(CheckpointFailureReason.CHECKPOINT_DECLINED, cause);
} else {
pendingCheckpoint.abort(CheckpointFailureReason.JOB_FAILURE, cause);
}
rememberRecentCheckpointId(checkpointId);
// we don't have to schedule another "dissolving" checkpoint any more because the
// cancellation barriers take care of breaking downstream alignments
// we only need to make sure that suspended queued requests are resumed
boolean haveMoreRecentPending = false;
for (PendingCheckpoint p : pendingCheckpoints.values()) {
if (!p.isDiscarded() && p.getCheckpointId() >= pendingCheckpoint.getCheckpointId()) {
haveMoreRecentPending = true;
break;
}
}
if (!haveMoreRecentPending) {
triggerQueuedRequests();
}
} | [
"private",
"void",
"discardCheckpoint",
"(",
"PendingCheckpoint",
"pendingCheckpoint",
",",
"@",
"Nullable",
"Throwable",
"cause",
")",
"{",
"assert",
"(",
"Thread",
".",
"holdsLock",
"(",
"lock",
")",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"pendin... | Discards the given pending checkpoint because of the given cause.
@param pendingCheckpoint to discard
@param cause for discarding the checkpoint | [
"Discards",
"the",
"given",
"pending",
"checkpoint",
"because",
"of",
"the",
"given",
"cause",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java#L1313-L1344 | train | Discards a checkpoint. | [
30522,
2797,
11675,
5860,
4232,
5403,
3600,
8400,
1006,
14223,
5403,
3600,
8400,
14223,
5403,
3600,
8400,
1010,
1030,
19701,
3085,
5466,
3085,
3426,
1007,
1063,
20865,
1006,
11689,
1012,
4324,
7878,
1006,
5843,
1007,
1007,
1025,
3653,
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/format/FastDatePrinter.java | FastDatePrinter.format | String format(final Object obj) {
if (obj instanceof Date) {
return format((Date) obj);
} else if (obj instanceof Calendar) {
return format((Calendar) obj);
} else if (obj instanceof Long) {
return format(((Long) obj).longValue());
} else {
throw new IllegalArgumentException("Unknown class: " + (obj == null ? "<null>" : obj.getClass().getName()));
}
} | java | String format(final Object obj) {
if (obj instanceof Date) {
return format((Date) obj);
} else if (obj instanceof Calendar) {
return format((Calendar) obj);
} else if (obj instanceof Long) {
return format(((Long) obj).longValue());
} else {
throw new IllegalArgumentException("Unknown class: " + (obj == null ? "<null>" : obj.getClass().getName()));
}
} | [
"String",
"format",
"(",
"final",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"Date",
")",
"{",
"return",
"format",
"(",
"(",
"Date",
")",
"obj",
")",
";",
"}",
"else",
"if",
"(",
"obj",
"instanceof",
"Calendar",
")",
"{",
"return",
... | <p>
Formats a {@code Date}, {@code Calendar} or {@code Long} (milliseconds) object.
</p>
@param obj the object to format
@return The formatted value. | [
"<p",
">",
"Formats",
"a",
"{",
"@code",
"Date",
"}",
"{",
"@code",
"Calendar",
"}",
"or",
"{",
"@code",
"Long",
"}",
"(",
"milliseconds",
")",
"object",
".",
"<",
"/",
"p",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/format/FastDatePrinter.java#L297-L307 | train | Format the given object to a string. | [
30522,
5164,
4289,
1006,
2345,
4874,
27885,
3501,
1007,
1063,
2065,
1006,
27885,
3501,
6013,
11253,
3058,
1007,
1063,
2709,
4289,
1006,
1006,
3058,
1007,
27885,
3501,
1007,
1025,
1065,
2842,
2065,
1006,
27885,
3501,
6013,
11253,
8094,
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... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/mining/word2vec/Corpus.java | Corpus.createBinaryTree | void createBinaryTree()
{
int[] point = new int[VocabWord.MAX_CODE_LENGTH];
char[] code = new char[VocabWord.MAX_CODE_LENGTH];
int[] count = new int[vocabSize * 2 + 1];
char[] binary = new char[vocabSize * 2 + 1];
int[] parentNode = new int[vocabSize * 2 + 1];
for (int i = 0; i < vocabSize; i++)
count[i] = vocab[i].cn;
for (int i = vocabSize; i < vocabSize * 2; i++)
count[i] = Integer.MAX_VALUE;
int pos1 = vocabSize - 1;
int pos2 = vocabSize;
// Following algorithm constructs the Huffman tree by adding one node at a time
int min1i, min2i;
for (int i = 0; i < vocabSize - 1; i++)
{
// First, find two smallest nodes 'min1, min2'
if (pos1 >= 0)
{
if (count[pos1] < count[pos2])
{
min1i = pos1;
pos1--;
}
else
{
min1i = pos2;
pos2++;
}
}
else
{
min1i = pos2;
pos2++;
}
if (pos1 >= 0)
{
if (count[pos1] < count[pos2])
{
min2i = pos1;
pos1--;
}
else
{
min2i = pos2;
pos2++;
}
}
else
{
min2i = pos2;
pos2++;
}
count[vocabSize + i] = count[min1i] + count[min2i];
parentNode[min1i] = vocabSize + i;
parentNode[min2i] = vocabSize + i;
binary[min2i] = 1;
}
// Now assign binary code to each vocabulary word
for (int j = 0; j < vocabSize; j++)
{
int k = j;
int i = 0;
while (true)
{
code[i] = binary[k];
point[i] = k;
i++;
k = parentNode[k];
if (k == vocabSize * 2 - 2) break;
}
vocab[j].codelen = i;
vocab[j].point[0] = vocabSize - 2;
for (k = 0; k < i; k++)
{
vocab[j].code[i - k - 1] = code[k];
vocab[j].point[i - k] = point[k] - vocabSize;
}
}
} | java | void createBinaryTree()
{
int[] point = new int[VocabWord.MAX_CODE_LENGTH];
char[] code = new char[VocabWord.MAX_CODE_LENGTH];
int[] count = new int[vocabSize * 2 + 1];
char[] binary = new char[vocabSize * 2 + 1];
int[] parentNode = new int[vocabSize * 2 + 1];
for (int i = 0; i < vocabSize; i++)
count[i] = vocab[i].cn;
for (int i = vocabSize; i < vocabSize * 2; i++)
count[i] = Integer.MAX_VALUE;
int pos1 = vocabSize - 1;
int pos2 = vocabSize;
// Following algorithm constructs the Huffman tree by adding one node at a time
int min1i, min2i;
for (int i = 0; i < vocabSize - 1; i++)
{
// First, find two smallest nodes 'min1, min2'
if (pos1 >= 0)
{
if (count[pos1] < count[pos2])
{
min1i = pos1;
pos1--;
}
else
{
min1i = pos2;
pos2++;
}
}
else
{
min1i = pos2;
pos2++;
}
if (pos1 >= 0)
{
if (count[pos1] < count[pos2])
{
min2i = pos1;
pos1--;
}
else
{
min2i = pos2;
pos2++;
}
}
else
{
min2i = pos2;
pos2++;
}
count[vocabSize + i] = count[min1i] + count[min2i];
parentNode[min1i] = vocabSize + i;
parentNode[min2i] = vocabSize + i;
binary[min2i] = 1;
}
// Now assign binary code to each vocabulary word
for (int j = 0; j < vocabSize; j++)
{
int k = j;
int i = 0;
while (true)
{
code[i] = binary[k];
point[i] = k;
i++;
k = parentNode[k];
if (k == vocabSize * 2 - 2) break;
}
vocab[j].codelen = i;
vocab[j].point[0] = vocabSize - 2;
for (k = 0; k < i; k++)
{
vocab[j].code[i - k - 1] = code[k];
vocab[j].point[i - k] = point[k] - vocabSize;
}
}
} | [
"void",
"createBinaryTree",
"(",
")",
"{",
"int",
"[",
"]",
"point",
"=",
"new",
"int",
"[",
"VocabWord",
".",
"MAX_CODE_LENGTH",
"]",
";",
"char",
"[",
"]",
"code",
"=",
"new",
"char",
"[",
"VocabWord",
".",
"MAX_CODE_LENGTH",
"]",
";",
"int",
"[",
... | Create binary Huffman tree using the word counts.
Frequent words will have short uniqe binary codes | [
"Create",
"binary",
"Huffman",
"tree",
"using",
"the",
"word",
"counts",
".",
"Frequent",
"words",
"will",
"have",
"short",
"uniqe",
"binary",
"codes"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/mining/word2vec/Corpus.java#L189-L270 | train | Create binary tree. | [
30522,
11675,
3443,
21114,
2854,
13334,
1006,
1007,
1063,
20014,
1031,
1033,
2391,
1027,
2047,
20014,
1031,
29536,
3540,
2497,
18351,
1012,
4098,
1035,
3642,
1035,
3091,
1033,
1025,
25869,
1031,
1033,
3642,
1027,
2047,
25869,
1031,
29536,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java | MysqlEventParser.findAsPerTimestampInSpecificLogFile | private EntryPosition findAsPerTimestampInSpecificLogFile(MysqlConnection mysqlConnection,
final Long startTimestamp,
final EntryPosition endPosition,
final String searchBinlogFile,
final Boolean justForPositionTimestamp) {
final LogPosition logPosition = new LogPosition();
try {
mysqlConnection.reconnect();
// 开始遍历文件
mysqlConnection.seek(searchBinlogFile, 4L, endPosition.getGtid(), new SinkFunction<LogEvent>() {
private LogPosition lastPosition;
public boolean sink(LogEvent event) {
EntryPosition entryPosition = null;
try {
CanalEntry.Entry entry = parseAndProfilingIfNecessary(event, true);
if (justForPositionTimestamp && logPosition.getPostion() == null && event.getWhen() > 0) {
// 初始位点
entryPosition = new EntryPosition(searchBinlogFile,
event.getLogPos() - event.getEventLen(),
event.getWhen() * 1000,
event.getServerId());
entryPosition.setGtid(event.getHeader().getGtidSetStr());
logPosition.setPostion(entryPosition);
}
// 直接用event的位点来处理,解决一个binlog文件里没有任何事件导致死循环无法退出的问题
String logfilename = event.getHeader().getLogFileName();
// 记录的是binlog end offest,
// 因为与其对比的offest是show master status里的end offest
Long logfileoffset = event.getHeader().getLogPos();
Long logposTimestamp = event.getHeader().getWhen() * 1000;
Long serverId = event.getHeader().getServerId();
// 如果最小的一条记录都不满足条件,可直接退出
if (logposTimestamp >= startTimestamp) {
return false;
}
if (StringUtils.equals(endPosition.getJournalName(), logfilename)
&& endPosition.getPosition() <= logfileoffset) {
return false;
}
if (entry == null) {
return true;
}
// 记录一下上一个事务结束的位置,即下一个事务的position
// position = current +
// data.length,代表该事务的下一条offest,避免多余的事务重复
if (CanalEntry.EntryType.TRANSACTIONEND.equals(entry.getEntryType())) {
entryPosition = new EntryPosition(logfilename, logfileoffset, logposTimestamp, serverId);
if (logger.isDebugEnabled()) {
logger.debug("set {} to be pending start position before finding another proper one...",
entryPosition);
}
logPosition.setPostion(entryPosition);
entryPosition.setGtid(entry.getHeader().getGtid());
} else if (CanalEntry.EntryType.TRANSACTIONBEGIN.equals(entry.getEntryType())) {
// 当前事务开始位点
entryPosition = new EntryPosition(logfilename, logfileoffset, logposTimestamp, serverId);
if (logger.isDebugEnabled()) {
logger.debug("set {} to be pending start position before finding another proper one...",
entryPosition);
}
entryPosition.setGtid(entry.getHeader().getGtid());
logPosition.setPostion(entryPosition);
}
lastPosition = buildLastPosition(entry);
} catch (Throwable e) {
processSinkError(e, lastPosition, searchBinlogFile, 4L);
}
return running;
}
});
} catch (IOException e) {
logger.error("ERROR ## findAsPerTimestampInSpecificLogFile has an error", e);
}
if (logPosition.getPostion() != null) {
return logPosition.getPostion();
} else {
return null;
}
} | java | private EntryPosition findAsPerTimestampInSpecificLogFile(MysqlConnection mysqlConnection,
final Long startTimestamp,
final EntryPosition endPosition,
final String searchBinlogFile,
final Boolean justForPositionTimestamp) {
final LogPosition logPosition = new LogPosition();
try {
mysqlConnection.reconnect();
// 开始遍历文件
mysqlConnection.seek(searchBinlogFile, 4L, endPosition.getGtid(), new SinkFunction<LogEvent>() {
private LogPosition lastPosition;
public boolean sink(LogEvent event) {
EntryPosition entryPosition = null;
try {
CanalEntry.Entry entry = parseAndProfilingIfNecessary(event, true);
if (justForPositionTimestamp && logPosition.getPostion() == null && event.getWhen() > 0) {
// 初始位点
entryPosition = new EntryPosition(searchBinlogFile,
event.getLogPos() - event.getEventLen(),
event.getWhen() * 1000,
event.getServerId());
entryPosition.setGtid(event.getHeader().getGtidSetStr());
logPosition.setPostion(entryPosition);
}
// 直接用event的位点来处理,解决一个binlog文件里没有任何事件导致死循环无法退出的问题
String logfilename = event.getHeader().getLogFileName();
// 记录的是binlog end offest,
// 因为与其对比的offest是show master status里的end offest
Long logfileoffset = event.getHeader().getLogPos();
Long logposTimestamp = event.getHeader().getWhen() * 1000;
Long serverId = event.getHeader().getServerId();
// 如果最小的一条记录都不满足条件,可直接退出
if (logposTimestamp >= startTimestamp) {
return false;
}
if (StringUtils.equals(endPosition.getJournalName(), logfilename)
&& endPosition.getPosition() <= logfileoffset) {
return false;
}
if (entry == null) {
return true;
}
// 记录一下上一个事务结束的位置,即下一个事务的position
// position = current +
// data.length,代表该事务的下一条offest,避免多余的事务重复
if (CanalEntry.EntryType.TRANSACTIONEND.equals(entry.getEntryType())) {
entryPosition = new EntryPosition(logfilename, logfileoffset, logposTimestamp, serverId);
if (logger.isDebugEnabled()) {
logger.debug("set {} to be pending start position before finding another proper one...",
entryPosition);
}
logPosition.setPostion(entryPosition);
entryPosition.setGtid(entry.getHeader().getGtid());
} else if (CanalEntry.EntryType.TRANSACTIONBEGIN.equals(entry.getEntryType())) {
// 当前事务开始位点
entryPosition = new EntryPosition(logfilename, logfileoffset, logposTimestamp, serverId);
if (logger.isDebugEnabled()) {
logger.debug("set {} to be pending start position before finding another proper one...",
entryPosition);
}
entryPosition.setGtid(entry.getHeader().getGtid());
logPosition.setPostion(entryPosition);
}
lastPosition = buildLastPosition(entry);
} catch (Throwable e) {
processSinkError(e, lastPosition, searchBinlogFile, 4L);
}
return running;
}
});
} catch (IOException e) {
logger.error("ERROR ## findAsPerTimestampInSpecificLogFile has an error", e);
}
if (logPosition.getPostion() != null) {
return logPosition.getPostion();
} else {
return null;
}
} | [
"private",
"EntryPosition",
"findAsPerTimestampInSpecificLogFile",
"(",
"MysqlConnection",
"mysqlConnection",
",",
"final",
"Long",
"startTimestamp",
",",
"final",
"EntryPosition",
"endPosition",
",",
"final",
"String",
"searchBinlogFile",
",",
"final",
"Boolean",
"justForP... | 根据给定的时间戳,在指定的binlog中找到最接近于该时间戳(必须是小于时间戳)的一个事务起始位置。
针对最后一个binlog会给定endPosition,避免无尽的查询 | [
"根据给定的时间戳,在指定的binlog中找到最接近于该时间戳",
"(",
"必须是小于时间戳",
")",
"的一个事务起始位置。",
"针对最后一个binlog会给定endPosition,避免无尽的查询"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java#L733-L823 | train | Find as per timestamp in specific log file. | [
30522,
2797,
4443,
26994,
2424,
3022,
4842,
7292,
9153,
8737,
7076,
5051,
6895,
8873,
20464,
8649,
8873,
2571,
1006,
2026,
2015,
4160,
22499,
10087,
7542,
2026,
2015,
4160,
22499,
10087,
7542,
1010,
2345,
2146,
2707,
7292,
9153,
8737,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/DateBetween.java | DateBetween.between | public long between(DateUnit unit) {
long diff = end.getTime() - begin.getTime();
return diff / unit.getMillis();
} | java | public long between(DateUnit unit) {
long diff = end.getTime() - begin.getTime();
return diff / unit.getMillis();
} | [
"public",
"long",
"between",
"(",
"DateUnit",
"unit",
")",
"{",
"long",
"diff",
"=",
"end",
".",
"getTime",
"(",
")",
"-",
"begin",
".",
"getTime",
"(",
")",
";",
"return",
"diff",
"/",
"unit",
".",
"getMillis",
"(",
")",
";",
"}"
] | 判断两个日期相差的时长<br>
返回 给定单位的时长差
@param unit 相差的单位:相差 天{@link DateUnit#DAY}、小时{@link DateUnit#HOUR} 等
@return 时长差 | [
"判断两个日期相差的时长<br",
">",
"返回",
"给定单位的时长差"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateBetween.java#L89-L92 | train | Returns the number of milliseconds between this date and the given unit. | [
30522,
2270,
2146,
2090,
1006,
3058,
19496,
2102,
3131,
1007,
1063,
2146,
4487,
4246,
1027,
2203,
1012,
2131,
7292,
1006,
1007,
1011,
4088,
1012,
2131,
7292,
1006,
1007,
1025,
2709,
4487,
4246,
1013,
3131,
1012,
2131,
19912,
2483,
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... |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/template/engine/beetl/BeetlUtil.java | BeetlUtil.createFileGroupTemplate | public static GroupTemplate createFileGroupTemplate(String dir, Charset charset) {
return createGroupTemplate(new FileResourceLoader(dir, charset.name()));
} | java | public static GroupTemplate createFileGroupTemplate(String dir, Charset charset) {
return createGroupTemplate(new FileResourceLoader(dir, charset.name()));
} | [
"public",
"static",
"GroupTemplate",
"createFileGroupTemplate",
"(",
"String",
"dir",
",",
"Charset",
"charset",
")",
"{",
"return",
"createGroupTemplate",
"(",
"new",
"FileResourceLoader",
"(",
"dir",
",",
"charset",
".",
"name",
"(",
")",
")",
")",
";",
"}"
... | 创建文件目录的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
此时自定义的配置文件可在ClassPath中放入beetl.properties配置
@param dir 目录路径(绝对路径)
@param charset 读取模板文件的编码
@return {@link GroupTemplate}
@since 3.2.0 | [
"创建文件目录的模板组",
"{",
"@link",
"GroupTemplate",
"}",
",配置文件使用全局默认<br",
">",
"此时自定义的配置文件可在ClassPath中放入beetl",
".",
"properties配置"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/beetl/BeetlUtil.java#L96-L98 | train | Creates a new group template using the specified resource loader. | [
30522,
2270,
10763,
2177,
18532,
15725,
3443,
8873,
23115,
22107,
18532,
15725,
1006,
5164,
16101,
1010,
25869,
13462,
25869,
13462,
1007,
1063,
2709,
3443,
17058,
18532,
15725,
1006,
2047,
5371,
6072,
8162,
29109,
10441,
4063,
1006,
16101,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-mesos/src/main/java/org/apache/flink/mesos/Utils.java | Utils.ranges | public static Protos.Resource ranges(String name, String role, Protos.Value.Range... ranges) {
checkNotNull(name);
checkNotNull(role);
checkNotNull(ranges);
return Protos.Resource.newBuilder()
.setName(name)
.setType(Protos.Value.Type.RANGES)
.setRanges(Protos.Value.Ranges.newBuilder().addAllRange(Arrays.asList(ranges)).build())
.setRole(role)
.build();
} | java | public static Protos.Resource ranges(String name, String role, Protos.Value.Range... ranges) {
checkNotNull(name);
checkNotNull(role);
checkNotNull(ranges);
return Protos.Resource.newBuilder()
.setName(name)
.setType(Protos.Value.Type.RANGES)
.setRanges(Protos.Value.Ranges.newBuilder().addAllRange(Arrays.asList(ranges)).build())
.setRole(role)
.build();
} | [
"public",
"static",
"Protos",
".",
"Resource",
"ranges",
"(",
"String",
"name",
",",
"String",
"role",
",",
"Protos",
".",
"Value",
".",
"Range",
"...",
"ranges",
")",
"{",
"checkNotNull",
"(",
"name",
")",
";",
"checkNotNull",
"(",
"role",
")",
";",
"... | Construct a range resource. | [
"Construct",
"a",
"range",
"resource",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-mesos/src/main/java/org/apache/flink/mesos/Utils.java#L207-L217 | train | Create a new resource with ranges. | [
30522,
2270,
10763,
15053,
2015,
1012,
7692,
8483,
1006,
5164,
2171,
1010,
5164,
2535,
1010,
15053,
2015,
1012,
3643,
1012,
2846,
1012,
1012,
1012,
8483,
1007,
1063,
4638,
17048,
11231,
3363,
1006,
2171,
1007,
1025,
4638,
17048,
11231,
3363... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/catalog/ExternalCatalogTable.java | ExternalCatalogTable.getTableStats | @Deprecated
public Optional<TableStats> getTableStats() {
DescriptorProperties normalizedProps = new DescriptorProperties();
normalizedProps.putProperties(normalizedProps);
Optional<Long> rowCount = normalizedProps.getOptionalLong(STATISTICS_ROW_COUNT);
if (rowCount.isPresent()) {
Map<String, ColumnStats> columnStats = readColumnStats(normalizedProps, STATISTICS_COLUMNS);
return Optional.of(new TableStats(rowCount.get(), columnStats));
} else {
return Optional.empty();
}
} | java | @Deprecated
public Optional<TableStats> getTableStats() {
DescriptorProperties normalizedProps = new DescriptorProperties();
normalizedProps.putProperties(normalizedProps);
Optional<Long> rowCount = normalizedProps.getOptionalLong(STATISTICS_ROW_COUNT);
if (rowCount.isPresent()) {
Map<String, ColumnStats> columnStats = readColumnStats(normalizedProps, STATISTICS_COLUMNS);
return Optional.of(new TableStats(rowCount.get(), columnStats));
} else {
return Optional.empty();
}
} | [
"@",
"Deprecated",
"public",
"Optional",
"<",
"TableStats",
">",
"getTableStats",
"(",
")",
"{",
"DescriptorProperties",
"normalizedProps",
"=",
"new",
"DescriptorProperties",
"(",
")",
";",
"normalizedProps",
".",
"putProperties",
"(",
"normalizedProps",
")",
";",
... | Reads table statistics from the descriptors properties.
@deprecated This method exists for backwards-compatibility only. | [
"Reads",
"table",
"statistics",
"from",
"the",
"descriptors",
"properties",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/ExternalCatalogTable.java#L93-L104 | train | Get the table stats. | [
30522,
1030,
2139,
28139,
12921,
2270,
11887,
1026,
7251,
29336,
2015,
1028,
2131,
10880,
9153,
3215,
1006,
1007,
1063,
4078,
23235,
2953,
21572,
4842,
7368,
3671,
3550,
21572,
4523,
1027,
2047,
4078,
23235,
2953,
21572,
4842,
7368,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/BinaryInMemorySortBuffer.java | BinaryInMemorySortBuffer.createBuffer | public static BinaryInMemorySortBuffer createBuffer(
NormalizedKeyComputer normalizedKeyComputer,
AbstractRowSerializer<BaseRow> inputSerializer,
BinaryRowSerializer serializer,
RecordComparator comparator,
List<MemorySegment> memory) throws IOException {
checkArgument(memory.size() >= MIN_REQUIRED_BUFFERS);
int totalNumBuffers = memory.size();
ListMemorySegmentPool pool = new ListMemorySegmentPool(memory);
ArrayList<MemorySegment> recordBufferSegments = new ArrayList<>(16);
return new BinaryInMemorySortBuffer(
normalizedKeyComputer, inputSerializer, serializer, comparator, recordBufferSegments,
new SimpleCollectingOutputView(recordBufferSegments, pool, pool.pageSize()),
pool, totalNumBuffers);
} | java | public static BinaryInMemorySortBuffer createBuffer(
NormalizedKeyComputer normalizedKeyComputer,
AbstractRowSerializer<BaseRow> inputSerializer,
BinaryRowSerializer serializer,
RecordComparator comparator,
List<MemorySegment> memory) throws IOException {
checkArgument(memory.size() >= MIN_REQUIRED_BUFFERS);
int totalNumBuffers = memory.size();
ListMemorySegmentPool pool = new ListMemorySegmentPool(memory);
ArrayList<MemorySegment> recordBufferSegments = new ArrayList<>(16);
return new BinaryInMemorySortBuffer(
normalizedKeyComputer, inputSerializer, serializer, comparator, recordBufferSegments,
new SimpleCollectingOutputView(recordBufferSegments, pool, pool.pageSize()),
pool, totalNumBuffers);
} | [
"public",
"static",
"BinaryInMemorySortBuffer",
"createBuffer",
"(",
"NormalizedKeyComputer",
"normalizedKeyComputer",
",",
"AbstractRowSerializer",
"<",
"BaseRow",
">",
"inputSerializer",
",",
"BinaryRowSerializer",
"serializer",
",",
"RecordComparator",
"comparator",
",",
"... | Create a memory sorter in `insert` way. | [
"Create",
"a",
"memory",
"sorter",
"in",
"insert",
"way",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/BinaryInMemorySortBuffer.java#L57-L71 | train | Create a binary sort buffer. | [
30522,
2270,
10763,
12441,
2378,
4168,
5302,
24769,
11589,
8569,
12494,
3443,
8569,
12494,
1006,
3671,
3550,
14839,
9006,
18780,
2121,
3671,
3550,
14839,
9006,
18780,
2121,
1010,
10061,
10524,
8043,
4818,
17629,
1026,
2918,
10524,
1028,
20407... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/HashUtil.java | HashUtil.intHash | public static int intHash(int key) {
key += ~(key << 15);
key ^= (key >>> 10);
key += (key << 3);
key ^= (key >>> 6);
key += ~(key << 11);
key ^= (key >>> 16);
return key;
} | java | public static int intHash(int key) {
key += ~(key << 15);
key ^= (key >>> 10);
key += (key << 3);
key ^= (key >>> 6);
key += ~(key << 11);
key ^= (key >>> 16);
return key;
} | [
"public",
"static",
"int",
"intHash",
"(",
"int",
"key",
")",
"{",
"key",
"+=",
"~",
"(",
"key",
"<<",
"15",
")",
";",
"key",
"^=",
"(",
"key",
">>>",
"10",
")",
";",
"key",
"+=",
"(",
"key",
"<<",
"3",
")",
";",
"key",
"^=",
"(",
"key",
">... | Thomas Wang的算法,整数hash
@param key 整数
@return hash值 | [
"Thomas",
"Wang的算法,整数hash"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/HashUtil.java#L184-L192 | train | Returns the hash value of a given key. | [
30522,
2270,
10763,
20014,
20014,
14949,
2232,
1006,
20014,
3145,
1007,
1063,
3145,
1009,
1027,
1066,
1006,
3145,
1026,
1026,
2321,
1007,
1025,
3145,
1034,
1027,
1006,
3145,
1028,
1028,
1028,
2184,
1007,
1025,
3145,
1009,
1027,
1006,
3145,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/metrics/groups/TaskManagerMetricGroup.java | TaskManagerMetricGroup.putVariables | @Override
protected void putVariables(Map<String, String> variables) {
variables.put(ScopeFormat.SCOPE_HOST, hostname);
variables.put(ScopeFormat.SCOPE_TASKMANAGER_ID, taskManagerId);
} | java | @Override
protected void putVariables(Map<String, String> variables) {
variables.put(ScopeFormat.SCOPE_HOST, hostname);
variables.put(ScopeFormat.SCOPE_TASKMANAGER_ID, taskManagerId);
} | [
"@",
"Override",
"protected",
"void",
"putVariables",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"variables",
")",
"{",
"variables",
".",
"put",
"(",
"ScopeFormat",
".",
"SCOPE_HOST",
",",
"hostname",
")",
";",
"variables",
".",
"put",
"(",
"ScopeForma... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/TaskManagerMetricGroup.java#L142-L146 | train | Override this method to add the variables to the scope map. | [
30522,
1030,
2058,
15637,
5123,
11675,
2404,
10755,
19210,
2015,
1006,
4949,
1026,
5164,
1010,
5164,
1028,
10857,
1007,
1063,
10857,
1012,
2404,
1006,
9531,
14192,
4017,
1012,
9531,
1035,
3677,
1010,
3677,
18442,
1007,
1025,
10857,
1012,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java | ArrayUtil.min | public static <T extends Comparable<? super T>> T min(T[] numberArray) {
if (isEmpty(numberArray)) {
throw new IllegalArgumentException("Number array must not empty !");
}
T min = numberArray[0];
for (int i = 0; i < numberArray.length; i++) {
if (ObjectUtil.compare(min, numberArray[i]) > 0) {
min = numberArray[i];
}
}
return min;
} | java | public static <T extends Comparable<? super T>> T min(T[] numberArray) {
if (isEmpty(numberArray)) {
throw new IllegalArgumentException("Number array must not empty !");
}
T min = numberArray[0];
for (int i = 0; i < numberArray.length; i++) {
if (ObjectUtil.compare(min, numberArray[i]) > 0) {
min = numberArray[i];
}
}
return min;
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"T",
"min",
"(",
"T",
"[",
"]",
"numberArray",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"numberArray",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
... | 取最小值
@param <T> 元素类型
@param numberArray 数字数组
@return 最小值
@since 3.0.9 | [
"取最小值"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java#L3267-L3278 | train | Returns the minimum value of the specified number array. | [
30522,
2270,
10763,
1026,
1056,
8908,
12435,
1026,
1029,
3565,
1056,
1028,
1028,
1056,
8117,
1006,
1056,
1031,
1033,
2193,
2906,
9447,
1007,
1063,
2065,
1006,
2003,
6633,
13876,
2100,
1006,
2193,
2906,
9447,
1007,
1007,
1063,
5466,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/perceptron/accessories/CoNLLReader.java | CoNLLReader.readData | public ArrayList<Instance> readData(int limit, boolean keepNonProjective, boolean labeled, boolean rootFirst, boolean lowerCased, IndexMaps maps) throws IOException
{
HashMap<String, Integer> wordMap = maps.getWordId();
ArrayList<Instance> instanceList = new ArrayList<Instance>();
String line;
ArrayList<Integer> tokens = new ArrayList<Integer>();
ArrayList<Integer> tags = new ArrayList<Integer>();
ArrayList<Integer> cluster4Ids = new ArrayList<Integer>();
ArrayList<Integer> cluster6Ids = new ArrayList<Integer>();
ArrayList<Integer> clusterIds = new ArrayList<Integer>();
HashMap<Integer, Edge> goldDependencies = new HashMap<Integer, Edge>();
int sentenceCounter = 0;
while ((line = fileReader.readLine()) != null)
{
line = line.trim();
if (line.length() == 0) // 句子分隔空白行
{
if (tokens.size() > 0)
{
sentenceCounter++;
if (!rootFirst)
{
for (Edge edge : goldDependencies.values())
{
if (edge.headIndex == 0)
edge.headIndex = tokens.size() + 1;
}
tokens.add(0);
tags.add(0);
cluster4Ids.add(0);
cluster6Ids.add(0);
clusterIds.add(0);
}
Sentence currentSentence = new Sentence(tokens, tags, cluster4Ids, cluster6Ids, clusterIds);
Instance instance = new Instance(currentSentence, goldDependencies);
if (keepNonProjective || !instance.isNonprojective())
instanceList.add(instance);
goldDependencies = new HashMap<Integer, Edge>();
tokens = new ArrayList<Integer>();
tags = new ArrayList<Integer>();
cluster4Ids = new ArrayList<Integer>();
cluster6Ids = new ArrayList<Integer>();
clusterIds = new ArrayList<Integer>();
}
else
{
goldDependencies = new HashMap<Integer, Edge>();
tokens = new ArrayList<Integer>();
tags = new ArrayList<Integer>();
cluster4Ids = new ArrayList<Integer>();
cluster6Ids = new ArrayList<Integer>();
clusterIds = new ArrayList<Integer>();
}
if (sentenceCounter >= limit)
{
System.out.println("buffer full..." + instanceList.size());
break;
}
}
else
{
String[] cells = line.split("\t");
if (cells.length < 8)
throw new IllegalArgumentException("invalid conll format");
int wordIndex = Integer.parseInt(cells[0]);
String word = cells[1].trim();
if (lowerCased)
word = word.toLowerCase();
String pos = cells[3].trim();
int wi = getId(word, wordMap);
int pi = getId(pos, wordMap);
tags.add(pi);
tokens.add(wi);
int headIndex = Integer.parseInt(cells[6]);
String relation = cells[7];
if (!labeled)
relation = "~";
else if (relation.equals("_"))
relation = "-";
if (headIndex == 0)
relation = "ROOT";
int ri = getId(relation, wordMap);
if (headIndex == -1)
ri = -1;
int[] ids = maps.clusterId(word);
clusterIds.add(ids[0]);
cluster4Ids.add(ids[1]);
cluster6Ids.add(ids[2]);
if (headIndex >= 0)
goldDependencies.put(wordIndex, new Edge(headIndex, ri));
}
}
if (tokens.size() > 0)
{
if (!rootFirst)
{
for (int gold : goldDependencies.keySet())
{
if (goldDependencies.get(gold).headIndex == 0)
goldDependencies.get(gold).headIndex = goldDependencies.size() + 1;
}
tokens.add(0);
tags.add(0);
cluster4Ids.add(0);
cluster6Ids.add(0);
clusterIds.add(0);
}
sentenceCounter++;
Sentence currentSentence = new Sentence(tokens, tags, cluster4Ids, cluster6Ids, clusterIds);
instanceList.add(new Instance(currentSentence, goldDependencies));
}
return instanceList;
} | java | public ArrayList<Instance> readData(int limit, boolean keepNonProjective, boolean labeled, boolean rootFirst, boolean lowerCased, IndexMaps maps) throws IOException
{
HashMap<String, Integer> wordMap = maps.getWordId();
ArrayList<Instance> instanceList = new ArrayList<Instance>();
String line;
ArrayList<Integer> tokens = new ArrayList<Integer>();
ArrayList<Integer> tags = new ArrayList<Integer>();
ArrayList<Integer> cluster4Ids = new ArrayList<Integer>();
ArrayList<Integer> cluster6Ids = new ArrayList<Integer>();
ArrayList<Integer> clusterIds = new ArrayList<Integer>();
HashMap<Integer, Edge> goldDependencies = new HashMap<Integer, Edge>();
int sentenceCounter = 0;
while ((line = fileReader.readLine()) != null)
{
line = line.trim();
if (line.length() == 0) // 句子分隔空白行
{
if (tokens.size() > 0)
{
sentenceCounter++;
if (!rootFirst)
{
for (Edge edge : goldDependencies.values())
{
if (edge.headIndex == 0)
edge.headIndex = tokens.size() + 1;
}
tokens.add(0);
tags.add(0);
cluster4Ids.add(0);
cluster6Ids.add(0);
clusterIds.add(0);
}
Sentence currentSentence = new Sentence(tokens, tags, cluster4Ids, cluster6Ids, clusterIds);
Instance instance = new Instance(currentSentence, goldDependencies);
if (keepNonProjective || !instance.isNonprojective())
instanceList.add(instance);
goldDependencies = new HashMap<Integer, Edge>();
tokens = new ArrayList<Integer>();
tags = new ArrayList<Integer>();
cluster4Ids = new ArrayList<Integer>();
cluster6Ids = new ArrayList<Integer>();
clusterIds = new ArrayList<Integer>();
}
else
{
goldDependencies = new HashMap<Integer, Edge>();
tokens = new ArrayList<Integer>();
tags = new ArrayList<Integer>();
cluster4Ids = new ArrayList<Integer>();
cluster6Ids = new ArrayList<Integer>();
clusterIds = new ArrayList<Integer>();
}
if (sentenceCounter >= limit)
{
System.out.println("buffer full..." + instanceList.size());
break;
}
}
else
{
String[] cells = line.split("\t");
if (cells.length < 8)
throw new IllegalArgumentException("invalid conll format");
int wordIndex = Integer.parseInt(cells[0]);
String word = cells[1].trim();
if (lowerCased)
word = word.toLowerCase();
String pos = cells[3].trim();
int wi = getId(word, wordMap);
int pi = getId(pos, wordMap);
tags.add(pi);
tokens.add(wi);
int headIndex = Integer.parseInt(cells[6]);
String relation = cells[7];
if (!labeled)
relation = "~";
else if (relation.equals("_"))
relation = "-";
if (headIndex == 0)
relation = "ROOT";
int ri = getId(relation, wordMap);
if (headIndex == -1)
ri = -1;
int[] ids = maps.clusterId(word);
clusterIds.add(ids[0]);
cluster4Ids.add(ids[1]);
cluster6Ids.add(ids[2]);
if (headIndex >= 0)
goldDependencies.put(wordIndex, new Edge(headIndex, ri));
}
}
if (tokens.size() > 0)
{
if (!rootFirst)
{
for (int gold : goldDependencies.keySet())
{
if (goldDependencies.get(gold).headIndex == 0)
goldDependencies.get(gold).headIndex = goldDependencies.size() + 1;
}
tokens.add(0);
tags.add(0);
cluster4Ids.add(0);
cluster6Ids.add(0);
clusterIds.add(0);
}
sentenceCounter++;
Sentence currentSentence = new Sentence(tokens, tags, cluster4Ids, cluster6Ids, clusterIds);
instanceList.add(new Instance(currentSentence, goldDependencies));
}
return instanceList;
} | [
"public",
"ArrayList",
"<",
"Instance",
">",
"readData",
"(",
"int",
"limit",
",",
"boolean",
"keepNonProjective",
",",
"boolean",
"labeled",
",",
"boolean",
"rootFirst",
",",
"boolean",
"lowerCased",
",",
"IndexMaps",
"maps",
")",
"throws",
"IOException",
"{",
... | 读取句子
@param limit 最大多少句
@param keepNonProjective 保留非投影
@param labeled
@param rootFirst 是否把root放到最前面
@param lowerCased
@param maps feature id map
@return
@throws Exception | [
"读取句子"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dependency/perceptron/accessories/CoNLLReader.java#L183-L305 | train | Read data from the file. | [
30522,
2270,
9140,
9863,
1026,
6013,
1028,
3191,
2850,
2696,
1006,
20014,
5787,
1010,
22017,
20898,
2562,
8540,
21572,
20614,
3512,
1010,
22017,
20898,
12599,
1010,
22017,
20898,
7117,
8873,
12096,
1010,
22017,
20898,
2896,
28969,
1010,
5950,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.formatDateTime | public static String formatDateTime(Date date) {
if (null == date) {
return null;
}
return DatePattern.NORM_DATETIME_FORMAT.format(date);
} | java | public static String formatDateTime(Date date) {
if (null == date) {
return null;
}
return DatePattern.NORM_DATETIME_FORMAT.format(date);
} | [
"public",
"static",
"String",
"formatDateTime",
"(",
"Date",
"date",
")",
"{",
"if",
"(",
"null",
"==",
"date",
")",
"{",
"return",
"null",
";",
"}",
"return",
"DatePattern",
".",
"NORM_DATETIME_FORMAT",
".",
"format",
"(",
"date",
")",
";",
"}"
] | 格式化日期时间<br>
格式 yyyy-MM-dd HH:mm:ss
@param date 被格式化的日期
@return 格式化后的日期 | [
"格式化日期时间<br",
">",
"格式",
"yyyy",
"-",
"MM",
"-",
"dd",
"HH",
":",
"mm",
":",
"ss"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L507-L512 | train | Format a date in the format required by the Java date time format. | [
30522,
2270,
10763,
5164,
4289,
13701,
7292,
1006,
3058,
3058,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
3058,
1007,
1063,
2709,
19701,
1025,
1065,
2709,
3058,
4502,
12079,
2078,
1012,
13373,
1035,
3058,
7292,
1035,
4289,
1012,
4289,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/util/FileUtils.java | FileUtils.deletePathIfEmpty | public static boolean deletePathIfEmpty(FileSystem fileSystem, Path path) throws IOException {
final FileStatus[] fileStatuses;
try {
fileStatuses = fileSystem.listStatus(path);
}
catch (FileNotFoundException e) {
// path already deleted
return true;
}
catch (Exception e) {
// could not access directory, cannot delete
return false;
}
// if there are no more files or if we couldn't list the file status try to delete the path
if (fileStatuses == null) {
// another indicator of "file not found"
return true;
}
else if (fileStatuses.length == 0) {
// attempt to delete the path (will fail and be ignored if the path now contains
// some files (possibly added concurrently))
return fileSystem.delete(path, false);
}
else {
return false;
}
} | java | public static boolean deletePathIfEmpty(FileSystem fileSystem, Path path) throws IOException {
final FileStatus[] fileStatuses;
try {
fileStatuses = fileSystem.listStatus(path);
}
catch (FileNotFoundException e) {
// path already deleted
return true;
}
catch (Exception e) {
// could not access directory, cannot delete
return false;
}
// if there are no more files or if we couldn't list the file status try to delete the path
if (fileStatuses == null) {
// another indicator of "file not found"
return true;
}
else if (fileStatuses.length == 0) {
// attempt to delete the path (will fail and be ignored if the path now contains
// some files (possibly added concurrently))
return fileSystem.delete(path, false);
}
else {
return false;
}
} | [
"public",
"static",
"boolean",
"deletePathIfEmpty",
"(",
"FileSystem",
"fileSystem",
",",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"final",
"FileStatus",
"[",
"]",
"fileStatuses",
";",
"try",
"{",
"fileStatuses",
"=",
"fileSystem",
".",
"listStatus",
"... | Deletes the path if it is empty. A path can only be empty if it is a directory which does
not contain any other directories/files.
@param fileSystem to use
@param path to be deleted if empty
@return true if the path could be deleted; otherwise false
@throws IOException if the delete operation fails | [
"Deletes",
"the",
"path",
"if",
"it",
"is",
"empty",
".",
"A",
"path",
"can",
"only",
"be",
"empty",
"if",
"it",
"is",
"a",
"directory",
"which",
"does",
"not",
"contain",
"any",
"other",
"directories",
"/",
"files",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/FileUtils.java#L399-L427 | train | Delete the path if it does not contain any files. | [
30522,
2270,
10763,
22017,
20898,
3972,
12870,
15069,
29323,
27718,
2100,
1006,
6764,
27268,
6633,
6764,
27268,
6633,
1010,
4130,
4130,
1007,
11618,
22834,
10288,
24422,
1063,
2345,
6764,
29336,
2271,
1031,
1033,
6764,
29336,
25581,
1025,
304... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/typeutils/CompositeType.java | CompositeType.getFlatFields | @PublicEvolving
public List<FlatFieldDescriptor> getFlatFields(String fieldExpression) {
List<FlatFieldDescriptor> result = new ArrayList<FlatFieldDescriptor>();
this.getFlatFields(fieldExpression, 0, result);
return result;
} | java | @PublicEvolving
public List<FlatFieldDescriptor> getFlatFields(String fieldExpression) {
List<FlatFieldDescriptor> result = new ArrayList<FlatFieldDescriptor>();
this.getFlatFields(fieldExpression, 0, result);
return result;
} | [
"@",
"PublicEvolving",
"public",
"List",
"<",
"FlatFieldDescriptor",
">",
"getFlatFields",
"(",
"String",
"fieldExpression",
")",
"{",
"List",
"<",
"FlatFieldDescriptor",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"FlatFieldDescriptor",
">",
"(",
")",
";",
"th... | Returns the flat field descriptors for the given field expression.
@param fieldExpression The field expression for which the flat field descriptors are computed.
@return The list of descriptors for the flat fields which are specified by the field expression. | [
"Returns",
"the",
"flat",
"field",
"descriptors",
"for",
"the",
"given",
"field",
"expression",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/typeutils/CompositeType.java#L66-L71 | train | Gets the flat fields of the given field expression. | [
30522,
1030,
2270,
6777,
4747,
6455,
2270,
2862,
1026,
4257,
3790,
6155,
23235,
2953,
1028,
2131,
10258,
4017,
15155,
1006,
5164,
2492,
10288,
20110,
3258,
1007,
1063,
2862,
1026,
4257,
3790,
6155,
23235,
2953,
1028,
2765,
1027,
2047,
9140,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/minicluster/MiniCluster.java | MiniCluster.createMetricRegistry | protected MetricRegistryImpl createMetricRegistry(Configuration config) {
return new MetricRegistryImpl(
MetricRegistryConfiguration.fromConfiguration(config),
ReporterSetup.fromConfiguration(config));
} | java | protected MetricRegistryImpl createMetricRegistry(Configuration config) {
return new MetricRegistryImpl(
MetricRegistryConfiguration.fromConfiguration(config),
ReporterSetup.fromConfiguration(config));
} | [
"protected",
"MetricRegistryImpl",
"createMetricRegistry",
"(",
"Configuration",
"config",
")",
"{",
"return",
"new",
"MetricRegistryImpl",
"(",
"MetricRegistryConfiguration",
".",
"fromConfiguration",
"(",
"config",
")",
",",
"ReporterSetup",
".",
"fromConfiguration",
"(... | Factory method to create the metric registry for the mini cluster.
@param config The configuration of the mini cluster | [
"Factory",
"method",
"to",
"create",
"the",
"metric",
"registry",
"for",
"the",
"mini",
"cluster",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java#L697-L701 | train | Create a metric registry based on the configuration. | [
30522,
5123,
12046,
2890,
24063,
2854,
5714,
24759,
3443,
12589,
2890,
24063,
2854,
1006,
9563,
9530,
8873,
2290,
1007,
1063,
2709,
2047,
12046,
2890,
24063,
2854,
5714,
24759,
1006,
12046,
2890,
24063,
2854,
8663,
8873,
27390,
3370,
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... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/model/perceptron/model/LinearModel.java | LinearModel.decode | public int decode(Collection<Integer> x)
{
float y = 0;
for (Integer f : x)
y += parameter[f];
return y < 0 ? -1 : 1;
} | java | public int decode(Collection<Integer> x)
{
float y = 0;
for (Integer f : x)
y += parameter[f];
return y < 0 ? -1 : 1;
} | [
"public",
"int",
"decode",
"(",
"Collection",
"<",
"Integer",
">",
"x",
")",
"{",
"float",
"y",
"=",
"0",
";",
"for",
"(",
"Integer",
"f",
":",
"x",
")",
"y",
"+=",
"parameter",
"[",
"]",
";",
"return",
"y",
"<",
"0",
"?",
"-",
"1",
":",
"1",... | 分离超平面解码
@param x 特征向量
@return sign(wx) | [
"分离超平面解码"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/model/perceptron/model/LinearModel.java#L247-L253 | train | Decodes a Collection of Integer objects into a single integer value. | [
30522,
2270,
20014,
21933,
3207,
1006,
3074,
1026,
16109,
1028,
1060,
1007,
1063,
14257,
1061,
1027,
1014,
1025,
2005,
1006,
16109,
1042,
1024,
1060,
1007,
1061,
1009,
1027,
16381,
1031,
1042,
1033,
1025,
2709,
1061,
1026,
1014,
1029,
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... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java | MDAG.getStringsStartingWith | public HashSet<String> getStringsStartingWith(String prefixStr)
{
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
{
MDAGNode originNode = sourceNode.transition(prefixStr); //attempt to _transition down the path denoted by prefixStr
if (originNode != null) //if there a _transition path corresponding to prefixString (one or more stored Strings begin with prefixString)
{
if (originNode.isAcceptNode()) strHashSet.add(prefixStr);
getStrings(strHashSet, SearchCondition.PREFIX_SEARCH_CONDITION, prefixStr, prefixStr, originNode.getOutgoingTransitions()); //retrieve all Strings that extend the _transition path denoted by prefixStr
}
}
else
{
SimpleMDAGNode originNode = SimpleMDAGNode.traverseMDAG(mdagDataArray, simplifiedSourceNode, prefixStr); //attempt to _transition down the path denoted by prefixStr
if (originNode != null) //if there a _transition path corresponding to prefixString (one or more stored Strings begin with prefixStr)
{
if (originNode.isAcceptNode()) strHashSet.add(prefixStr);
getStrings(strHashSet, SearchCondition.PREFIX_SEARCH_CONDITION, prefixStr, prefixStr, originNode); //retrieve all Strings that extend the _transition path denoted by prefixString
}
}
return strHashSet;
} | java | public HashSet<String> getStringsStartingWith(String prefixStr)
{
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
{
MDAGNode originNode = sourceNode.transition(prefixStr); //attempt to _transition down the path denoted by prefixStr
if (originNode != null) //if there a _transition path corresponding to prefixString (one or more stored Strings begin with prefixString)
{
if (originNode.isAcceptNode()) strHashSet.add(prefixStr);
getStrings(strHashSet, SearchCondition.PREFIX_SEARCH_CONDITION, prefixStr, prefixStr, originNode.getOutgoingTransitions()); //retrieve all Strings that extend the _transition path denoted by prefixStr
}
}
else
{
SimpleMDAGNode originNode = SimpleMDAGNode.traverseMDAG(mdagDataArray, simplifiedSourceNode, prefixStr); //attempt to _transition down the path denoted by prefixStr
if (originNode != null) //if there a _transition path corresponding to prefixString (one or more stored Strings begin with prefixStr)
{
if (originNode.isAcceptNode()) strHashSet.add(prefixStr);
getStrings(strHashSet, SearchCondition.PREFIX_SEARCH_CONDITION, prefixStr, prefixStr, originNode); //retrieve all Strings that extend the _transition path denoted by prefixString
}
}
return strHashSet;
} | [
"public",
"HashSet",
"<",
"String",
">",
"getStringsStartingWith",
"(",
"String",
"prefixStr",
")",
"{",
"HashSet",
"<",
"String",
">",
"strHashSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"sourceNode",
"!=",
"null",
")",
"/... | 前缀查询<br>
Retrieves all the Strings in the MDAG that begin with a given String.
@param prefixStr a String that is the prefix for all the desired Strings
@return a HashSet containing all the Strings present in the MDAG that begin with {@code prefixString} | [
"前缀查询<br",
">",
"Retrieves",
"all",
"the",
"Strings",
"in",
"the",
"MDAG",
"that",
"begin",
"with",
"a",
"given",
"String",
"."
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java#L940-L966 | train | Get the set of Strings starting with the given prefix string. | [
30522,
2270,
23325,
13462,
1026,
5164,
1028,
4152,
18886,
3070,
4757,
7559,
3436,
24415,
1006,
5164,
17576,
3367,
2099,
1007,
1063,
23325,
13462,
1026,
5164,
1028,
2358,
25032,
11823,
13462,
1027,
2047,
23325,
13462,
1026,
5164,
1028,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/typeutils/base/EnumSerializer.java | EnumSerializer.readObject | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
// may be null if this serializer was deserialized from an older version
if (this.values == null) {
this.values = enumClass.getEnumConstants();
this.valueToOrdinal = new EnumMap<>(this.enumClass);
int i = 0;
for (T value : values) {
this.valueToOrdinal.put(value, i++);
}
}
} | java | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
// may be null if this serializer was deserialized from an older version
if (this.values == null) {
this.values = enumClass.getEnumConstants();
this.valueToOrdinal = new EnumMap<>(this.enumClass);
int i = 0;
for (T value : values) {
this.valueToOrdinal.put(value, i++);
}
}
} | [
"private",
"void",
"readObject",
"(",
"ObjectInputStream",
"in",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"in",
".",
"defaultReadObject",
"(",
")",
";",
"// may be null if this serializer was deserialized from an older version",
"if",
"(",
"this",
... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/typeutils/base/EnumSerializer.java#L162-L175 | train | Deserializes the object from an ObjectInputStream. | [
30522,
2797,
11675,
3191,
16429,
20614,
1006,
4874,
2378,
18780,
21422,
1999,
1007,
11618,
22834,
10288,
24422,
1010,
2465,
17048,
14876,
8630,
10288,
24422,
1063,
1999,
1012,
12398,
16416,
3527,
2497,
20614,
1006,
1007,
1025,
1013,
1013,
208... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.titleIs | public static ExpectedCondition<Boolean> titleIs(final String title) {
return new ExpectedCondition<Boolean>() {
private String currentTitle = "";
@Override
public Boolean apply(WebDriver driver) {
currentTitle = driver.getTitle();
return title.equals(currentTitle);
}
@Override
public String toString() {
return String.format("title to be \"%s\". Current title: \"%s\"", title, currentTitle);
}
};
} | java | public static ExpectedCondition<Boolean> titleIs(final String title) {
return new ExpectedCondition<Boolean>() {
private String currentTitle = "";
@Override
public Boolean apply(WebDriver driver) {
currentTitle = driver.getTitle();
return title.equals(currentTitle);
}
@Override
public String toString() {
return String.format("title to be \"%s\". Current title: \"%s\"", title, currentTitle);
}
};
} | [
"public",
"static",
"ExpectedCondition",
"<",
"Boolean",
">",
"titleIs",
"(",
"final",
"String",
"title",
")",
"{",
"return",
"new",
"ExpectedCondition",
"<",
"Boolean",
">",
"(",
")",
"{",
"private",
"String",
"currentTitle",
"=",
"\"\"",
";",
"@",
"Overrid... | An expectation for checking the title of a page.
@param title the expected title, which must be an exact match
@return true when the title matches, false otherwise | [
"An",
"expectation",
"for",
"checking",
"the",
"title",
"of",
"a",
"page",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java#L57-L72 | train | An expectation for checking the title of a page. | [
30522,
2270,
10763,
3517,
8663,
20562,
1026,
22017,
20898,
1028,
2516,
2483,
1006,
2345,
5164,
2516,
1007,
1063,
2709,
2047,
3517,
8663,
20562,
1026,
22017,
20898,
1028,
1006,
1007,
1063,
2797,
5164,
2783,
3775,
9286,
1027,
1000,
1000,
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... |
netty/netty | buffer/src/main/java/io/netty/buffer/Unpooled.java | Unpooled.copyBoolean | public static ByteBuf copyBoolean(boolean value) {
ByteBuf buf = buffer(1);
buf.writeBoolean(value);
return buf;
} | java | public static ByteBuf copyBoolean(boolean value) {
ByteBuf buf = buffer(1);
buf.writeBoolean(value);
return buf;
} | [
"public",
"static",
"ByteBuf",
"copyBoolean",
"(",
"boolean",
"value",
")",
"{",
"ByteBuf",
"buf",
"=",
"buffer",
"(",
"1",
")",
";",
"buf",
".",
"writeBoolean",
"(",
"value",
")",
";",
"return",
"buf",
";",
"}"
] | Creates a new single-byte big-endian buffer that holds the specified boolean value. | [
"Creates",
"a",
"new",
"single",
"-",
"byte",
"big",
"-",
"endian",
"buffer",
"that",
"holds",
"the",
"specified",
"boolean",
"value",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/Unpooled.java#L782-L786 | train | Create a new big - endian buffer that holds a single boolean value. | [
30522,
2270,
10763,
24880,
8569,
2546,
6100,
5092,
9890,
2319,
1006,
22017,
20898,
3643,
1007,
1063,
24880,
8569,
2546,
20934,
2546,
1027,
17698,
1006,
1015,
1007,
1025,
20934,
2546,
1012,
4339,
5092,
9890,
2319,
1006,
3643,
1007,
1025,
270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java | SecureUtil.signParams | public static String signParams(SymmetricCrypto crypto, Map<?, ?> params, String separator, String keyValueSeparator, boolean isIgnoreNull) {
if (MapUtil.isEmpty(params)) {
return null;
}
String paramsStr = MapUtil.join(MapUtil.sort(params), separator, keyValueSeparator, isIgnoreNull);
return crypto.encryptHex(paramsStr);
} | java | public static String signParams(SymmetricCrypto crypto, Map<?, ?> params, String separator, String keyValueSeparator, boolean isIgnoreNull) {
if (MapUtil.isEmpty(params)) {
return null;
}
String paramsStr = MapUtil.join(MapUtil.sort(params), separator, keyValueSeparator, isIgnoreNull);
return crypto.encryptHex(paramsStr);
} | [
"public",
"static",
"String",
"signParams",
"(",
"SymmetricCrypto",
"crypto",
",",
"Map",
"<",
"?",
",",
"?",
">",
"params",
",",
"String",
"separator",
",",
"String",
"keyValueSeparator",
",",
"boolean",
"isIgnoreNull",
")",
"{",
"if",
"(",
"MapUtil",
".",
... | 对参数做签名<br>
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串
@param crypto 对称加密算法
@param params 参数
@param separator entry之间的连接符
@param keyValueSeparator kv之间的连接符
@param isIgnoreNull 是否忽略null的键和值
@return 签名
@since 4.0.1 | [
"对参数做签名<br",
">",
"参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java#L847-L853 | train | Sign params. | [
30522,
2270,
10763,
5164,
3696,
28689,
5244,
1006,
19490,
26775,
22571,
3406,
19888,
2080,
1010,
4949,
1026,
1029,
1010,
1029,
1028,
11498,
5244,
1010,
5164,
19802,
25879,
2953,
1010,
5164,
3145,
10175,
15808,
13699,
25879,
2953,
1010,
22017,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | sink/src/main/java/com/alibaba/otter/canal/sink/entry/EntryEventSink.java | EntryEventSink.applyWait | private void applyWait(int fullTimes) {
int newFullTimes = fullTimes > maxFullTimes ? maxFullTimes : fullTimes;
if (fullTimes <= 3) { // 3次以内
Thread.yield();
} else { // 超过3次,最多只sleep 10ms
LockSupport.parkNanos(1000 * 1000L * newFullTimes);
}
} | java | private void applyWait(int fullTimes) {
int newFullTimes = fullTimes > maxFullTimes ? maxFullTimes : fullTimes;
if (fullTimes <= 3) { // 3次以内
Thread.yield();
} else { // 超过3次,最多只sleep 10ms
LockSupport.parkNanos(1000 * 1000L * newFullTimes);
}
} | [
"private",
"void",
"applyWait",
"(",
"int",
"fullTimes",
")",
"{",
"int",
"newFullTimes",
"=",
"fullTimes",
">",
"maxFullTimes",
"?",
"maxFullTimes",
":",
"fullTimes",
";",
"if",
"(",
"fullTimes",
"<=",
"3",
")",
"{",
"// 3次以内",
"Thread",
".",
"yield",
"("... | 处理无数据的情况,避免空循环挂死 | [
"处理无数据的情况,避免空循环挂死"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/sink/src/main/java/com/alibaba/otter/canal/sink/entry/EntryEventSink.java#L192-L200 | train | Apply wait. | [
30522,
2797,
11675,
6611,
21547,
2102,
1006,
20014,
2440,
7292,
2015,
1007,
1063,
20014,
2047,
3993,
7096,
14428,
2015,
1027,
2440,
7292,
2015,
1028,
4098,
3993,
7096,
14428,
2015,
1029,
4098,
3993,
7096,
14428,
2015,
1024,
2440,
7292,
2015... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/file/FileWriter.java | FileWriter.write | public File write(byte[] data, int off, int len, boolean isAppend) throws IORuntimeException {
FileOutputStream out = null;
try {
out = new FileOutputStream(FileUtil.touch(file), isAppend);
out.write(data, off, len);
out.flush();
}catch(IOException e){
throw new IORuntimeException(e);
} finally {
IoUtil.close(out);
}
return file;
} | java | public File write(byte[] data, int off, int len, boolean isAppend) throws IORuntimeException {
FileOutputStream out = null;
try {
out = new FileOutputStream(FileUtil.touch(file), isAppend);
out.write(data, off, len);
out.flush();
}catch(IOException e){
throw new IORuntimeException(e);
} finally {
IoUtil.close(out);
}
return file;
} | [
"public",
"File",
"write",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"off",
",",
"int",
"len",
",",
"boolean",
"isAppend",
")",
"throws",
"IORuntimeException",
"{",
"FileOutputStream",
"out",
"=",
"null",
";",
"try",
"{",
"out",
"=",
"new",
"FileOutputS... | 写入数据到文件
@param data 数据
@param off 数据开始位置
@param len 数据长度
@param isAppend 是否追加模式
@return 目标文件
@throws IORuntimeException IO异常 | [
"写入数据到文件"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/file/FileWriter.java#L287-L299 | train | Write the specified bytes to the file. | [
30522,
2270,
5371,
4339,
1006,
24880,
1031,
1033,
2951,
1010,
20014,
2125,
1010,
20014,
18798,
1010,
22017,
20898,
18061,
21512,
4859,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
5371,
5833,
18780,
21422,
2041,
1027,
19701,
1025,
304... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/functions/SqlDateTimeUtils.java | SqlDateTimeUtils.dateSub | public static String dateSub(String dateStr, int days, TimeZone tz) {
long ts = parseToTimeMillis(dateStr, tz);
if (ts == Long.MIN_VALUE) {
return null;
}
return dateSub(ts, days, tz);
} | java | public static String dateSub(String dateStr, int days, TimeZone tz) {
long ts = parseToTimeMillis(dateStr, tz);
if (ts == Long.MIN_VALUE) {
return null;
}
return dateSub(ts, days, tz);
} | [
"public",
"static",
"String",
"dateSub",
"(",
"String",
"dateStr",
",",
"int",
"days",
",",
"TimeZone",
"tz",
")",
"{",
"long",
"ts",
"=",
"parseToTimeMillis",
"(",
"dateStr",
",",
"tz",
")",
";",
"if",
"(",
"ts",
"==",
"Long",
".",
"MIN_VALUE",
")",
... | Do subtraction on date string.
@param dateStr formatted date string.
@param days days count you want to subtract.
@param tz time zone of the date time string
@return datetime string. | [
"Do",
"subtraction",
"on",
"date",
"string",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java#L755-L761 | train | Returns the date string of the specified number of days from the specified date string. | [
30522,
2270,
10763,
5164,
5246,
12083,
1006,
5164,
5246,
16344,
1010,
20014,
2420,
1010,
2051,
15975,
1056,
2480,
1007,
1063,
2146,
24529,
1027,
11968,
13462,
4140,
14428,
19912,
2483,
1006,
5246,
16344,
1010,
1056,
2480,
1007,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpRequest.java | HttpRequest.sendFormUrlEncoded | private void sendFormUrlEncoded() throws IOException {
if (StrUtil.isBlank(this.header(Header.CONTENT_TYPE))) {
// 如果未自定义Content-Type,使用默认的application/x-www-form-urlencoded
this.httpConnection.header(Header.CONTENT_TYPE, ContentType.FORM_URLENCODED.toString(this.charset), true);
}
// Write的时候会优先使用body中的内容,write时自动关闭OutputStream
if (ArrayUtil.isNotEmpty(this.bodyBytes)) {
IoUtil.write(this.httpConnection.getOutputStream(), true, this.bodyBytes);
} else {
final String content = HttpUtil.toParams(this.form, this.charset);
IoUtil.write(this.httpConnection.getOutputStream(), this.charset, true, content);
}
} | java | private void sendFormUrlEncoded() throws IOException {
if (StrUtil.isBlank(this.header(Header.CONTENT_TYPE))) {
// 如果未自定义Content-Type,使用默认的application/x-www-form-urlencoded
this.httpConnection.header(Header.CONTENT_TYPE, ContentType.FORM_URLENCODED.toString(this.charset), true);
}
// Write的时候会优先使用body中的内容,write时自动关闭OutputStream
if (ArrayUtil.isNotEmpty(this.bodyBytes)) {
IoUtil.write(this.httpConnection.getOutputStream(), true, this.bodyBytes);
} else {
final String content = HttpUtil.toParams(this.form, this.charset);
IoUtil.write(this.httpConnection.getOutputStream(), this.charset, true, content);
}
} | [
"private",
"void",
"sendFormUrlEncoded",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"StrUtil",
".",
"isBlank",
"(",
"this",
".",
"header",
"(",
"Header",
".",
"CONTENT_TYPE",
")",
")",
")",
"{",
"// 如果未自定义Content-Type,使用默认的application/x-www-form-urlencoded\r... | 发送普通表单
@throws IOException | [
"发送普通表单"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java#L1001-L1014 | train | Send the form url encoded response. | [
30522,
2797,
11675,
4604,
14192,
3126,
7770,
16044,
2094,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
2065,
1006,
2358,
22134,
4014,
1012,
2003,
28522,
8950,
1006,
2023,
1012,
20346,
1006,
20346,
1012,
4180,
1035,
2828,
1007,
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... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/SM2Engine.java | SM2Engine.addFieldElement | private void addFieldElement(ECFieldElement v) {
final byte[] p = BigIntegers.asUnsignedByteArray(this.curveLength, v.toBigInteger());
this.digest.update(p, 0, p.length);
} | java | private void addFieldElement(ECFieldElement v) {
final byte[] p = BigIntegers.asUnsignedByteArray(this.curveLength, v.toBigInteger());
this.digest.update(p, 0, p.length);
} | [
"private",
"void",
"addFieldElement",
"(",
"ECFieldElement",
"v",
")",
"{",
"final",
"byte",
"[",
"]",
"p",
"=",
"BigIntegers",
".",
"asUnsignedByteArray",
"(",
"this",
".",
"curveLength",
",",
"v",
".",
"toBigInteger",
"(",
")",
")",
";",
"this",
".",
"... | 增加字段节点
@param digest
@param v | [
"增加字段节点"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/SM2Engine.java#L354-L357 | train | Adds the field element to the digest. | [
30522,
2797,
11675,
5587,
3790,
12260,
3672,
1006,
14925,
3790,
12260,
3672,
1058,
1007,
1063,
2345,
24880,
1031,
1033,
1052,
1027,
2502,
18447,
26320,
2015,
1012,
2004,
4609,
5332,
19225,
3762,
27058,
11335,
2100,
1006,
2023,
1012,
7774,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/HashUtil.java | HashUtil.djbHash | public static int djbHash(String str) {
int hash = 5381;
for (int i = 0; i < str.length(); i++) {
hash = ((hash << 5) + hash) + str.charAt(i);
}
return hash & 0x7FFFFFFF;
} | java | public static int djbHash(String str) {
int hash = 5381;
for (int i = 0; i < str.length(); i++) {
hash = ((hash << 5) + hash) + str.charAt(i);
}
return hash & 0x7FFFFFFF;
} | [
"public",
"static",
"int",
"djbHash",
"(",
"String",
"str",
")",
"{",
"int",
"hash",
"=",
"5381",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"hash",
"=",
"(",
"(",
"hash",
... | DJB算法
@param str 字符串
@return hash值 | [
"DJB算法"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/HashUtil.java#L314-L322 | train | Returns the hash code of the specified string. | [
30522,
2270,
10763,
20014,
6520,
22655,
4095,
1006,
5164,
2358,
2099,
1007,
1063,
20014,
23325,
1027,
5187,
2620,
2487,
1025,
2005,
1006,
20014,
1045,
1027,
1014,
1025,
1045,
1026,
2358,
2099,
1012,
3091,
1006,
1007,
1025,
1045,
1009,
1009,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/text/StrBuilder.java | StrBuilder.append | public StrBuilder append(char[] src) {
if (ArrayUtil.isEmpty(src)) {
return this;
}
return append(src, 0, src.length);
} | java | public StrBuilder append(char[] src) {
if (ArrayUtil.isEmpty(src)) {
return this;
}
return append(src, 0, src.length);
} | [
"public",
"StrBuilder",
"append",
"(",
"char",
"[",
"]",
"src",
")",
"{",
"if",
"(",
"ArrayUtil",
".",
"isEmpty",
"(",
"src",
")",
")",
"{",
"return",
"this",
";",
"}",
"return",
"append",
"(",
"src",
",",
"0",
",",
"src",
".",
"length",
")",
";"... | 追加一个字符数组
@param src 字符数组
@return this | [
"追加一个字符数组"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/text/StrBuilder.java#L113-L118 | train | Appends the specified chars to this builder. | [
30522,
2270,
2358,
15185,
19231,
4063,
10439,
10497,
1006,
25869,
1031,
1033,
5034,
2278,
1007,
1063,
2065,
1006,
9140,
21823,
2140,
1012,
2003,
6633,
13876,
2100,
1006,
5034,
2278,
1007,
1007,
1063,
2709,
2023,
1025,
1065,
2709,
10439,
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-http/src/main/java/cn/hutool/http/HttpBase.java | HttpBase.removeHeader | public T removeHeader(String name) {
if(name != null) {
headers.remove(name.trim());
}
return (T)this;
} | java | public T removeHeader(String name) {
if(name != null) {
headers.remove(name.trim());
}
return (T)this;
} | [
"public",
"T",
"removeHeader",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"headers",
".",
"remove",
"(",
"name",
".",
"trim",
"(",
")",
")",
";",
"}",
"return",
"(",
"T",
")",
"this",
";",
"}"
] | 移除一个头信息
@param name Header名
@return this | [
"移除一个头信息"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpBase.java#L196-L201 | train | Removes a header from the response. | [
30522,
2270,
1056,
6366,
4974,
2121,
1006,
5164,
2171,
1007,
1063,
2065,
1006,
2171,
999,
1027,
19701,
1007,
1063,
20346,
2015,
1012,
6366,
1006,
2171,
1012,
12241,
1006,
1007,
1007,
1025,
1065,
2709,
1006,
1056,
1007,
2023,
1025,
1065,
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/dependency/nnparser/Matrix.java | Matrix.plus | public Matrix plus(Matrix B)
{
checkMatrixDimensions(B);
Matrix X = new Matrix(m, n);
double[][] C = X.getArray();
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
C[i][j] = A[i][j] + B.A[i][j];
}
}
return X;
} | java | public Matrix plus(Matrix B)
{
checkMatrixDimensions(B);
Matrix X = new Matrix(m, n);
double[][] C = X.getArray();
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
C[i][j] = A[i][j] + B.A[i][j];
}
}
return X;
} | [
"public",
"Matrix",
"plus",
"(",
"Matrix",
"B",
")",
"{",
"checkMatrixDimensions",
"(",
"B",
")",
";",
"Matrix",
"X",
"=",
"new",
"Matrix",
"(",
"m",
",",
"n",
")",
";",
"double",
"[",
"]",
"[",
"]",
"C",
"=",
"X",
".",
"getArray",
"(",
")",
";... | C = A + B
@param B another matrix
@return A + B | [
"C",
"=",
"A",
"+",
"B"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dependency/nnparser/Matrix.java#L690-L703 | train | A = A + B | [
30522,
2270,
8185,
4606,
1006,
8185,
1038,
1007,
1063,
4638,
18900,
17682,
22172,
6132,
8496,
1006,
1038,
1007,
1025,
8185,
1060,
1027,
2047,
8185,
1006,
1049,
1010,
1050,
1007,
1025,
3313,
1031,
1033,
1031,
1033,
1039,
1027,
1060,
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/util/LeaderRetrievalUtils.java | LeaderRetrievalUtils.retrieveLeaderConnectionInfo | public static LeaderConnectionInfo retrieveLeaderConnectionInfo(
LeaderRetrievalService leaderRetrievalService,
Time timeout) throws LeaderRetrievalException {
return retrieveLeaderConnectionInfo(leaderRetrievalService, FutureUtils.toFiniteDuration(timeout));
} | java | public static LeaderConnectionInfo retrieveLeaderConnectionInfo(
LeaderRetrievalService leaderRetrievalService,
Time timeout) throws LeaderRetrievalException {
return retrieveLeaderConnectionInfo(leaderRetrievalService, FutureUtils.toFiniteDuration(timeout));
} | [
"public",
"static",
"LeaderConnectionInfo",
"retrieveLeaderConnectionInfo",
"(",
"LeaderRetrievalService",
"leaderRetrievalService",
",",
"Time",
"timeout",
")",
"throws",
"LeaderRetrievalException",
"{",
"return",
"retrieveLeaderConnectionInfo",
"(",
"leaderRetrievalService",
",... | Retrieves the leader akka url and the current leader session ID. The values are stored in a
{@link LeaderConnectionInfo} instance.
@param leaderRetrievalService Leader retrieval service to retrieve the leader connection
information
@param timeout Timeout when to give up looking for the leader
@return LeaderConnectionInfo containing the leader's akka URL and the current leader session
ID
@throws LeaderRetrievalException | [
"Retrieves",
"the",
"leader",
"akka",
"url",
"and",
"the",
"current",
"leader",
"session",
"ID",
".",
"The",
"values",
"are",
"stored",
"in",
"a",
"{",
"@link",
"LeaderConnectionInfo",
"}",
"instance",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/util/LeaderRetrievalUtils.java#L58-L62 | train | Retrieve the leader connection info. | [
30522,
2270,
10763,
3003,
8663,
2638,
7542,
2378,
14876,
12850,
19000,
8663,
2638,
7542,
2378,
14876,
1006,
3003,
13465,
7373,
10175,
8043,
7903,
2063,
3003,
13465,
7373,
10175,
8043,
7903,
2063,
1010,
2051,
2051,
5833,
1007,
11618,
3003,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-socket/src/main/java/cn/hutool/socket/nio/NioServer.java | NioServer.init | public NioServer init(InetSocketAddress address) {
try {
// 打开服务器套接字通道
this.serverSocketChannel = ServerSocketChannel.open();
// 设置为非阻塞状态
serverSocketChannel.configureBlocking(false);
// 获取通道相关联的套接字
final ServerSocket serverSocket = serverSocketChannel.socket();
// 绑定端口号
serverSocket.bind(address);
// 打开一个选择器
selector = Selector.open();
// 服务器套接字注册到Selector中 并指定Selector监控连接事件
serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
} catch (IOException e) {
throw new IORuntimeException(e);
}
return this;
} | java | public NioServer init(InetSocketAddress address) {
try {
// 打开服务器套接字通道
this.serverSocketChannel = ServerSocketChannel.open();
// 设置为非阻塞状态
serverSocketChannel.configureBlocking(false);
// 获取通道相关联的套接字
final ServerSocket serverSocket = serverSocketChannel.socket();
// 绑定端口号
serverSocket.bind(address);
// 打开一个选择器
selector = Selector.open();
// 服务器套接字注册到Selector中 并指定Selector监控连接事件
serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
} catch (IOException e) {
throw new IORuntimeException(e);
}
return this;
} | [
"public",
"NioServer",
"init",
"(",
"InetSocketAddress",
"address",
")",
"{",
"try",
"{",
"// 打开服务器套接字通道\r",
"this",
".",
"serverSocketChannel",
"=",
"ServerSocketChannel",
".",
"open",
"(",
")",
";",
"// 设置为非阻塞状态\r",
"serverSocketChannel",
".",
"configureBlocking",
... | 初始化
@param address 地址和端口
@return this | [
"初始化"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-socket/src/main/java/cn/hutool/socket/nio/NioServer.java#L43-L63 | train | Initializes the NioServer. | [
30522,
2270,
9152,
9232,
2099,
6299,
1999,
4183,
1006,
1999,
8454,
7432,
12928,
14141,
8303,
4769,
1007,
1063,
3046,
1063,
1013,
1013,
100,
100,
100,
100,
100,
100,
100,
100,
100,
1957,
2023,
1012,
14903,
7432,
3388,
26058,
1027,
14903,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java | MysqlEventParser.findServerId | private Long findServerId(MysqlConnection mysqlConnection) {
try {
ResultSetPacket packet = mysqlConnection.query("show variables like 'server_id'");
List<String> fields = packet.getFieldValues();
if (CollectionUtils.isEmpty(fields)) {
throw new CanalParseException("command : show variables like 'server_id' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation");
}
return Long.valueOf(fields.get(1));
} catch (IOException e) {
throw new CanalParseException("command : show variables like 'server_id' has an error!", e);
}
} | java | private Long findServerId(MysqlConnection mysqlConnection) {
try {
ResultSetPacket packet = mysqlConnection.query("show variables like 'server_id'");
List<String> fields = packet.getFieldValues();
if (CollectionUtils.isEmpty(fields)) {
throw new CanalParseException("command : show variables like 'server_id' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation");
}
return Long.valueOf(fields.get(1));
} catch (IOException e) {
throw new CanalParseException("command : show variables like 'server_id' has an error!", e);
}
} | [
"private",
"Long",
"findServerId",
"(",
"MysqlConnection",
"mysqlConnection",
")",
"{",
"try",
"{",
"ResultSetPacket",
"packet",
"=",
"mysqlConnection",
".",
"query",
"(",
"\"show variables like 'server_id'\"",
")",
";",
"List",
"<",
"String",
">",
"fields",
"=",
... | 查询当前db的serverId信息 | [
"查询当前db的serverId信息"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java#L635-L646 | train | Find server id. | [
30522,
2797,
2146,
4858,
2121,
6299,
3593,
1006,
2026,
2015,
4160,
22499,
10087,
7542,
2026,
2015,
4160,
22499,
10087,
7542,
1007,
1063,
3046,
1063,
3463,
3388,
23947,
3388,
14771,
1027,
2026,
2015,
4160,
22499,
10087,
7542,
1012,
23032,
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-setting/src/main/java/cn/hutool/setting/dialect/Props.java | Props.store | public void store(String path, Class<?> clazz) {
this.store(FileUtil.getAbsolutePath(path, clazz));
} | java | public void store(String path, Class<?> clazz) {
this.store(FileUtil.getAbsolutePath(path, clazz));
} | [
"public",
"void",
"store",
"(",
"String",
"path",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"this",
".",
"store",
"(",
"FileUtil",
".",
"getAbsolutePath",
"(",
"path",
",",
"clazz",
")",
")",
";",
"}"
] | 存储当前设置,会覆盖掉以前的设置
@param path 相对路径
@param clazz 相对的类 | [
"存储当前设置,会覆盖掉以前的设置"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/dialect/Props.java#L510-L512 | train | Store a class in the database. | [
30522,
2270,
11675,
3573,
1006,
5164,
4130,
1010,
2465,
1026,
1029,
1028,
18856,
10936,
2480,
1007,
1063,
2023,
1012,
3573,
1006,
5371,
21823,
2140,
1012,
2131,
7875,
19454,
10421,
15069,
1006,
4130,
1010,
18856,
10936,
2480,
1007,
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... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java | TaskExecutor.onStart | @Override
public void onStart() throws Exception {
try {
startTaskExecutorServices();
} catch (Exception e) {
final TaskManagerException exception = new TaskManagerException(String.format("Could not start the TaskExecutor %s", getAddress()), e);
onFatalError(exception);
throw exception;
}
startRegistrationTimeout();
} | java | @Override
public void onStart() throws Exception {
try {
startTaskExecutorServices();
} catch (Exception e) {
final TaskManagerException exception = new TaskManagerException(String.format("Could not start the TaskExecutor %s", getAddress()), e);
onFatalError(exception);
throw exception;
}
startRegistrationTimeout();
} | [
"@",
"Override",
"public",
"void",
"onStart",
"(",
")",
"throws",
"Exception",
"{",
"try",
"{",
"startTaskExecutorServices",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"final",
"TaskManagerException",
"exception",
"=",
"new",
"TaskManagerExc... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java#L285-L296 | train | Start the TaskExecutor. | [
30522,
1030,
2058,
15637,
2270,
11675,
2006,
14117,
2102,
1006,
1007,
11618,
6453,
1063,
3046,
1063,
2707,
10230,
3489,
2595,
8586,
16161,
22573,
2099,
7903,
2229,
1006,
1007,
1025,
1065,
4608,
1006,
6453,
1041,
1007,
1063,
2345,
4708,
2480... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java | KeyUtil.getSecretKeyFactory | public static SecretKeyFactory getSecretKeyFactory(String algorithm) {
final Provider provider = GlobalBouncyCastleProvider.INSTANCE.getProvider();
SecretKeyFactory keyFactory;
try {
keyFactory = (null == provider) //
? SecretKeyFactory.getInstance(getMainAlgorithm(algorithm)) //
: SecretKeyFactory.getInstance(getMainAlgorithm(algorithm), provider);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
return keyFactory;
} | java | public static SecretKeyFactory getSecretKeyFactory(String algorithm) {
final Provider provider = GlobalBouncyCastleProvider.INSTANCE.getProvider();
SecretKeyFactory keyFactory;
try {
keyFactory = (null == provider) //
? SecretKeyFactory.getInstance(getMainAlgorithm(algorithm)) //
: SecretKeyFactory.getInstance(getMainAlgorithm(algorithm), provider);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
return keyFactory;
} | [
"public",
"static",
"SecretKeyFactory",
"getSecretKeyFactory",
"(",
"String",
"algorithm",
")",
"{",
"final",
"Provider",
"provider",
"=",
"GlobalBouncyCastleProvider",
".",
"INSTANCE",
".",
"getProvider",
"(",
")",
";",
"SecretKeyFactory",
"keyFactory",
";",
"try",
... | 获取{@link SecretKeyFactory}
@param algorithm 对称加密算法
@return {@link KeyFactory}
@since 4.5.2 | [
"获取",
"{",
"@link",
"SecretKeyFactory",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java#L480-L492 | train | Gets the SecretKeyFactory for the given algorithm. | [
30522,
2270,
10763,
3595,
14839,
21450,
4152,
8586,
13465,
14839,
21450,
1006,
5164,
9896,
1007,
1063,
2345,
10802,
10802,
1027,
3795,
5092,
4609,
5666,
23662,
21572,
17258,
2121,
1012,
6013,
1012,
2131,
21572,
17258,
2121,
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... |
SeleniumHQ/selenium | java/server/src/org/openqa/grid/selenium/GridLauncherV3.java | GridLauncherV3.buildLauncher | private GridItemLauncher buildLauncher(String[] args) {
if (Arrays.asList(args).contains("-htmlSuite")) {
out.println(Joiner.on("\n").join(
"Download the Selenium HTML Runner from http://www.seleniumhq.org/download/ and",
"use that to run your HTML suite."));
return null;
}
String role = "standalone";
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("-role=")) {
role = args[i].substring("-role=".length());
} else if (args[i].equals("-role")) {
i++; // Increment, because we're going to need this.
if (i < args.length) {
role = args[i];
} else {
role = null; // Will cause us to print the usage information.
}
}
}
GridRole gridRole = GridRole.get(role);
if (gridRole == null || LAUNCHERS.get(gridRole) == null) {
printInfoAboutRoles(role);
return null;
}
return LAUNCHERS.get(gridRole);
} | java | private GridItemLauncher buildLauncher(String[] args) {
if (Arrays.asList(args).contains("-htmlSuite")) {
out.println(Joiner.on("\n").join(
"Download the Selenium HTML Runner from http://www.seleniumhq.org/download/ and",
"use that to run your HTML suite."));
return null;
}
String role = "standalone";
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("-role=")) {
role = args[i].substring("-role=".length());
} else if (args[i].equals("-role")) {
i++; // Increment, because we're going to need this.
if (i < args.length) {
role = args[i];
} else {
role = null; // Will cause us to print the usage information.
}
}
}
GridRole gridRole = GridRole.get(role);
if (gridRole == null || LAUNCHERS.get(gridRole) == null) {
printInfoAboutRoles(role);
return null;
}
return LAUNCHERS.get(gridRole);
} | [
"private",
"GridItemLauncher",
"buildLauncher",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"Arrays",
".",
"asList",
"(",
"args",
")",
".",
"contains",
"(",
"\"-htmlSuite\"",
")",
")",
"{",
"out",
".",
"println",
"(",
"Joiner",
".",
"on",
"("... | From the {@code args}, builds a new {@link GridItemLauncher} and populates it properly.
@return null if no role is found, or a properly populated {@link GridItemLauncher}. | [
"From",
"the",
"{",
"@code",
"args",
"}",
"builds",
"a",
"new",
"{",
"@link",
"GridItemLauncher",
"}",
"and",
"populates",
"it",
"properly",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/grid/selenium/GridLauncherV3.java#L95-L125 | train | Build the launcher. | [
30522,
2797,
8370,
4221,
19968,
4887,
26091,
2099,
3857,
17298,
26091,
2099,
1006,
5164,
1031,
1033,
12098,
5620,
1007,
1063,
2065,
1006,
27448,
1012,
2004,
9863,
1006,
12098,
5620,
1007,
1012,
3397,
1006,
1000,
1011,
16129,
28880,
2063,
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-clients/src/main/java/org/apache/flink/client/program/rest/RestClusterClient.java | RestClusterClient.submitJob | @Override
public CompletableFuture<JobSubmissionResult> submitJob(@Nonnull JobGraph jobGraph) {
// we have to enable queued scheduling because slot will be allocated lazily
jobGraph.setAllowQueuedScheduling(true);
CompletableFuture<java.nio.file.Path> jobGraphFileFuture = CompletableFuture.supplyAsync(() -> {
try {
final java.nio.file.Path jobGraphFile = Files.createTempFile("flink-jobgraph", ".bin");
try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) {
objectOut.writeObject(jobGraph);
}
return jobGraphFile;
} catch (IOException e) {
throw new CompletionException(new FlinkException("Failed to serialize JobGraph.", e));
}
}, executorService);
CompletableFuture<Tuple2<JobSubmitRequestBody, Collection<FileUpload>>> requestFuture = jobGraphFileFuture.thenApply(jobGraphFile -> {
List<String> jarFileNames = new ArrayList<>(8);
List<JobSubmitRequestBody.DistributedCacheFile> artifactFileNames = new ArrayList<>(8);
Collection<FileUpload> filesToUpload = new ArrayList<>(8);
filesToUpload.add(new FileUpload(jobGraphFile, RestConstants.CONTENT_TYPE_BINARY));
for (Path jar : jobGraph.getUserJars()) {
jarFileNames.add(jar.getName());
filesToUpload.add(new FileUpload(Paths.get(jar.toUri()), RestConstants.CONTENT_TYPE_JAR));
}
for (Map.Entry<String, DistributedCache.DistributedCacheEntry> artifacts : jobGraph.getUserArtifacts().entrySet()) {
artifactFileNames.add(new JobSubmitRequestBody.DistributedCacheFile(artifacts.getKey(), new Path(artifacts.getValue().filePath).getName()));
filesToUpload.add(new FileUpload(Paths.get(artifacts.getValue().filePath), RestConstants.CONTENT_TYPE_BINARY));
}
final JobSubmitRequestBody requestBody = new JobSubmitRequestBody(
jobGraphFile.getFileName().toString(),
jarFileNames,
artifactFileNames);
return Tuple2.of(requestBody, Collections.unmodifiableCollection(filesToUpload));
});
final CompletableFuture<JobSubmitResponseBody> submissionFuture = requestFuture.thenCompose(
requestAndFileUploads -> sendRetriableRequest(
JobSubmitHeaders.getInstance(),
EmptyMessageParameters.getInstance(),
requestAndFileUploads.f0,
requestAndFileUploads.f1,
isConnectionProblemOrServiceUnavailable())
);
submissionFuture
.thenCombine(jobGraphFileFuture, (ignored, jobGraphFile) -> jobGraphFile)
.thenAccept(jobGraphFile -> {
try {
Files.delete(jobGraphFile);
} catch (IOException e) {
log.warn("Could not delete temporary file {}.", jobGraphFile, e);
}
});
return submissionFuture
.thenApply(
(JobSubmitResponseBody jobSubmitResponseBody) -> new JobSubmissionResult(jobGraph.getJobID()))
.exceptionally(
(Throwable throwable) -> {
throw new CompletionException(new JobSubmissionException(jobGraph.getJobID(), "Failed to submit JobGraph.", ExceptionUtils.stripCompletionException(throwable)));
});
} | java | @Override
public CompletableFuture<JobSubmissionResult> submitJob(@Nonnull JobGraph jobGraph) {
// we have to enable queued scheduling because slot will be allocated lazily
jobGraph.setAllowQueuedScheduling(true);
CompletableFuture<java.nio.file.Path> jobGraphFileFuture = CompletableFuture.supplyAsync(() -> {
try {
final java.nio.file.Path jobGraphFile = Files.createTempFile("flink-jobgraph", ".bin");
try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) {
objectOut.writeObject(jobGraph);
}
return jobGraphFile;
} catch (IOException e) {
throw new CompletionException(new FlinkException("Failed to serialize JobGraph.", e));
}
}, executorService);
CompletableFuture<Tuple2<JobSubmitRequestBody, Collection<FileUpload>>> requestFuture = jobGraphFileFuture.thenApply(jobGraphFile -> {
List<String> jarFileNames = new ArrayList<>(8);
List<JobSubmitRequestBody.DistributedCacheFile> artifactFileNames = new ArrayList<>(8);
Collection<FileUpload> filesToUpload = new ArrayList<>(8);
filesToUpload.add(new FileUpload(jobGraphFile, RestConstants.CONTENT_TYPE_BINARY));
for (Path jar : jobGraph.getUserJars()) {
jarFileNames.add(jar.getName());
filesToUpload.add(new FileUpload(Paths.get(jar.toUri()), RestConstants.CONTENT_TYPE_JAR));
}
for (Map.Entry<String, DistributedCache.DistributedCacheEntry> artifacts : jobGraph.getUserArtifacts().entrySet()) {
artifactFileNames.add(new JobSubmitRequestBody.DistributedCacheFile(artifacts.getKey(), new Path(artifacts.getValue().filePath).getName()));
filesToUpload.add(new FileUpload(Paths.get(artifacts.getValue().filePath), RestConstants.CONTENT_TYPE_BINARY));
}
final JobSubmitRequestBody requestBody = new JobSubmitRequestBody(
jobGraphFile.getFileName().toString(),
jarFileNames,
artifactFileNames);
return Tuple2.of(requestBody, Collections.unmodifiableCollection(filesToUpload));
});
final CompletableFuture<JobSubmitResponseBody> submissionFuture = requestFuture.thenCompose(
requestAndFileUploads -> sendRetriableRequest(
JobSubmitHeaders.getInstance(),
EmptyMessageParameters.getInstance(),
requestAndFileUploads.f0,
requestAndFileUploads.f1,
isConnectionProblemOrServiceUnavailable())
);
submissionFuture
.thenCombine(jobGraphFileFuture, (ignored, jobGraphFile) -> jobGraphFile)
.thenAccept(jobGraphFile -> {
try {
Files.delete(jobGraphFile);
} catch (IOException e) {
log.warn("Could not delete temporary file {}.", jobGraphFile, e);
}
});
return submissionFuture
.thenApply(
(JobSubmitResponseBody jobSubmitResponseBody) -> new JobSubmissionResult(jobGraph.getJobID()))
.exceptionally(
(Throwable throwable) -> {
throw new CompletionException(new JobSubmissionException(jobGraph.getJobID(), "Failed to submit JobGraph.", ExceptionUtils.stripCompletionException(throwable)));
});
} | [
"@",
"Override",
"public",
"CompletableFuture",
"<",
"JobSubmissionResult",
">",
"submitJob",
"(",
"@",
"Nonnull",
"JobGraph",
"jobGraph",
")",
"{",
"// we have to enable queued scheduling because slot will be allocated lazily",
"jobGraph",
".",
"setAllowQueuedScheduling",
"(",... | Submits the given {@link JobGraph} to the dispatcher.
@param jobGraph to submit
@return Future which is completed with the submission response | [
"Submits",
"the",
"given",
"{",
"@link",
"JobGraph",
"}",
"to",
"the",
"dispatcher",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-clients/src/main/java/org/apache/flink/client/program/rest/RestClusterClient.java#L316-L384 | train | Submit a job to Flink. | [
30522,
1030,
2058,
15637,
2270,
4012,
10814,
10880,
11263,
11244,
1026,
5841,
12083,
25481,
6072,
11314,
1028,
12040,
5558,
2497,
1006,
1030,
2512,
11231,
3363,
3105,
14413,
3105,
14413,
1007,
1063,
1013,
1013,
2057,
2031,
2000,
9585,
24240,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/executiongraph/failover/FailoverStrategyLoader.java | FailoverStrategyLoader.loadFailoverStrategy | public static FailoverStrategy.Factory loadFailoverStrategy(Configuration config, @Nullable Logger logger) {
final String strategyParam = config.getString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY);
if (StringUtils.isNullOrWhitespaceOnly(strategyParam)) {
if (logger != null) {
logger.warn("Null config value for {} ; using default failover strategy (full restarts).",
JobManagerOptions.EXECUTION_FAILOVER_STRATEGY.key());
}
return new RestartAllStrategy.Factory();
}
else {
switch (strategyParam.toLowerCase()) {
case FULL_RESTART_STRATEGY_NAME:
return new RestartAllStrategy.Factory();
case PIPELINED_REGION_RESTART_STRATEGY_NAME:
return new RestartPipelinedRegionStrategy.Factory();
case INDIVIDUAL_RESTART_STRATEGY_NAME:
return new RestartIndividualStrategy.Factory();
default:
// we could interpret the parameter as a factory class name and instantiate that
// for now we simply do not support this
throw new IllegalConfigurationException("Unknown failover strategy: " + strategyParam);
}
}
} | java | public static FailoverStrategy.Factory loadFailoverStrategy(Configuration config, @Nullable Logger logger) {
final String strategyParam = config.getString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY);
if (StringUtils.isNullOrWhitespaceOnly(strategyParam)) {
if (logger != null) {
logger.warn("Null config value for {} ; using default failover strategy (full restarts).",
JobManagerOptions.EXECUTION_FAILOVER_STRATEGY.key());
}
return new RestartAllStrategy.Factory();
}
else {
switch (strategyParam.toLowerCase()) {
case FULL_RESTART_STRATEGY_NAME:
return new RestartAllStrategy.Factory();
case PIPELINED_REGION_RESTART_STRATEGY_NAME:
return new RestartPipelinedRegionStrategy.Factory();
case INDIVIDUAL_RESTART_STRATEGY_NAME:
return new RestartIndividualStrategy.Factory();
default:
// we could interpret the parameter as a factory class name and instantiate that
// for now we simply do not support this
throw new IllegalConfigurationException("Unknown failover strategy: " + strategyParam);
}
}
} | [
"public",
"static",
"FailoverStrategy",
".",
"Factory",
"loadFailoverStrategy",
"(",
"Configuration",
"config",
",",
"@",
"Nullable",
"Logger",
"logger",
")",
"{",
"final",
"String",
"strategyParam",
"=",
"config",
".",
"getString",
"(",
"JobManagerOptions",
".",
... | Loads a FailoverStrategy Factory from the given configuration. | [
"Loads",
"a",
"FailoverStrategy",
"Factory",
"from",
"the",
"given",
"configuration",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/FailoverStrategyLoader.java#L49-L77 | train | Load failover strategy. | [
30522,
2270,
10763,
8246,
30524,
2213,
1027,
9530,
8873,
2290,
1012,
4152,
18886,
3070,
1006,
3105,
24805,
4590,
7361,
9285,
1012,
7781,
1035,
8246,
7840,
1035,
5656,
1007,
1025,
2065,
1006,
5164,
21823,
4877,
1012,
3475,
18083,
2953,
2860,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java | CliFrontend.parseJobId | private JobID parseJobId(String jobIdString) throws CliArgsException {
if (jobIdString == null) {
throw new CliArgsException("Missing JobId");
}
final JobID jobId;
try {
jobId = JobID.fromHexString(jobIdString);
} catch (IllegalArgumentException e) {
throw new CliArgsException(e.getMessage());
}
return jobId;
} | java | private JobID parseJobId(String jobIdString) throws CliArgsException {
if (jobIdString == null) {
throw new CliArgsException("Missing JobId");
}
final JobID jobId;
try {
jobId = JobID.fromHexString(jobIdString);
} catch (IllegalArgumentException e) {
throw new CliArgsException(e.getMessage());
}
return jobId;
} | [
"private",
"JobID",
"parseJobId",
"(",
"String",
"jobIdString",
")",
"throws",
"CliArgsException",
"{",
"if",
"(",
"jobIdString",
"==",
"null",
")",
"{",
"throw",
"new",
"CliArgsException",
"(",
"\"Missing JobId\"",
")",
";",
"}",
"final",
"JobID",
"jobId",
";... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java#L881-L893 | train | Parses a string containing a JobID. | [
30522,
2797,
3105,
3593,
11968,
3366,
5558,
17062,
1006,
5164,
3105,
9821,
18886,
3070,
1007,
11618,
18856,
2401,
10623,
3366,
2595,
24422,
1063,
2065,
1006,
3105,
9821,
18886,
3070,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
18856,
2401,
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-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java | SecureUtil.generateKey | public static SecretKey generateKey(String algorithm, KeySpec keySpec) {
return KeyUtil.generateKey(algorithm, keySpec);
} | java | public static SecretKey generateKey(String algorithm, KeySpec keySpec) {
return KeyUtil.generateKey(algorithm, keySpec);
} | [
"public",
"static",
"SecretKey",
"generateKey",
"(",
"String",
"algorithm",
",",
"KeySpec",
"keySpec",
")",
"{",
"return",
"KeyUtil",
".",
"generateKey",
"(",
"algorithm",
",",
"keySpec",
")",
";",
"}"
] | 生成 {@link SecretKey},仅用于对称加密和摘要算法
@param algorithm 算法
@param keySpec {@link KeySpec}
@return {@link SecretKey} | [
"生成",
"{",
"@link",
"SecretKey",
"}",
",仅用于对称加密和摘要算法"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java#L129-L131 | train | Generates a secret key using the specified algorithm and key spec. | [
30522,
2270,
10763,
3595,
14839,
9699,
14839,
1006,
5164,
9896,
1010,
6309,
5051,
2278,
6309,
5051,
2278,
1007,
1063,
2709,
3145,
21823,
2140,
1012,
9699,
14839,
1006,
9896,
1010,
6309,
5051,
2278,
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... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManager.java | SlotManager.handleFailedSlotRequest | private void handleFailedSlotRequest(SlotID slotId, AllocationID allocationId, Throwable cause) {
PendingSlotRequest pendingSlotRequest = pendingSlotRequests.get(allocationId);
LOG.debug("Slot request with allocation id {} failed for slot {}.", allocationId, slotId, cause);
if (null != pendingSlotRequest) {
pendingSlotRequest.setRequestFuture(null);
try {
internalRequestSlot(pendingSlotRequest);
} catch (ResourceManagerException e) {
pendingSlotRequests.remove(allocationId);
resourceActions.notifyAllocationFailure(
pendingSlotRequest.getJobId(),
allocationId,
e);
}
} else {
LOG.debug("There was not pending slot request with allocation id {}. Probably the request has been fulfilled or cancelled.", allocationId);
}
} | java | private void handleFailedSlotRequest(SlotID slotId, AllocationID allocationId, Throwable cause) {
PendingSlotRequest pendingSlotRequest = pendingSlotRequests.get(allocationId);
LOG.debug("Slot request with allocation id {} failed for slot {}.", allocationId, slotId, cause);
if (null != pendingSlotRequest) {
pendingSlotRequest.setRequestFuture(null);
try {
internalRequestSlot(pendingSlotRequest);
} catch (ResourceManagerException e) {
pendingSlotRequests.remove(allocationId);
resourceActions.notifyAllocationFailure(
pendingSlotRequest.getJobId(),
allocationId,
e);
}
} else {
LOG.debug("There was not pending slot request with allocation id {}. Probably the request has been fulfilled or cancelled.", allocationId);
}
} | [
"private",
"void",
"handleFailedSlotRequest",
"(",
"SlotID",
"slotId",
",",
"AllocationID",
"allocationId",
",",
"Throwable",
"cause",
")",
"{",
"PendingSlotRequest",
"pendingSlotRequest",
"=",
"pendingSlotRequests",
".",
"get",
"(",
"allocationId",
")",
";",
"LOG",
... | Handles a failed slot request. The slot manager tries to find a new slot fulfilling
the resource requirements for the failed slot request.
@param slotId identifying the slot which was assigned to the slot request before
@param allocationId identifying the failed slot request
@param cause of the failure | [
"Handles",
"a",
"failed",
"slot",
"request",
".",
"The",
"slot",
"manager",
"tries",
"to",
"find",
"a",
"new",
"slot",
"fulfilling",
"the",
"resource",
"requirements",
"for",
"the",
"failed",
"slot",
"request",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManager.java#L949-L970 | train | Handle a failed slot request. | [
30522,
2797,
11675,
5047,
7011,
18450,
14540,
4140,
2890,
15500,
1006,
10453,
3593,
10453,
3593,
1010,
16169,
3593,
16169,
3593,
1010,
5466,
3085,
3426,
1007,
1063,
14223,
14540,
4140,
2890,
15500,
14223,
14540,
4140,
2890,
15500,
1027,
14223... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TaskSlotTable.java | TaskSlotTable.getTaskSlot | @Nullable
private TaskSlot getTaskSlot(AllocationID allocationId) {
Preconditions.checkNotNull(allocationId);
return allocationIDTaskSlotMap.get(allocationId);
} | java | @Nullable
private TaskSlot getTaskSlot(AllocationID allocationId) {
Preconditions.checkNotNull(allocationId);
return allocationIDTaskSlotMap.get(allocationId);
} | [
"@",
"Nullable",
"private",
"TaskSlot",
"getTaskSlot",
"(",
"AllocationID",
"allocationId",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"allocationId",
")",
";",
"return",
"allocationIDTaskSlotMap",
".",
"get",
"(",
"allocationId",
")",
";",
"}"
] | --------------------------------------------------------------------- | [
"---------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TaskSlotTable.java#L575-L580 | train | Gets the task slot for the given allocation id. | [
30522,
1030,
19701,
3085,
2797,
8518,
10994,
2131,
10230,
5705,
10994,
1006,
16169,
3593,
16169,
3593,
1007,
1063,
3653,
8663,
20562,
2015,
1012,
4638,
17048,
11231,
3363,
1006,
16169,
3593,
1007,
1025,
2709,
16169,
3593,
10230,
5705,
10994,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/unsafe/src/main/java/org/apache/spark/unsafe/types/ByteArray.java | ByteArray.writeToMemory | public static void writeToMemory(byte[] src, Object target, long targetOffset) {
Platform.copyMemory(src, Platform.BYTE_ARRAY_OFFSET, target, targetOffset, src.length);
} | java | public static void writeToMemory(byte[] src, Object target, long targetOffset) {
Platform.copyMemory(src, Platform.BYTE_ARRAY_OFFSET, target, targetOffset, src.length);
} | [
"public",
"static",
"void",
"writeToMemory",
"(",
"byte",
"[",
"]",
"src",
",",
"Object",
"target",
",",
"long",
"targetOffset",
")",
"{",
"Platform",
".",
"copyMemory",
"(",
"src",
",",
"Platform",
".",
"BYTE_ARRAY_OFFSET",
",",
"target",
",",
"targetOffset... | Writes the content of a byte array into a memory address, identified by an object and an
offset. The target memory address must already been allocated, and have enough space to
hold all the bytes in this string. | [
"Writes",
"the",
"content",
"of",
"a",
"byte",
"array",
"into",
"a",
"memory",
"address",
"identified",
"by",
"an",
"object",
"and",
"an",
"offset",
".",
"The",
"target",
"memory",
"address",
"must",
"already",
"been",
"allocated",
"and",
"have",
"enough",
... | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/unsafe/src/main/java/org/apache/spark/unsafe/types/ByteArray.java#L35-L37 | train | Write to memory. | [
30522,
2270,
10763,
11675,
4339,
20389,
6633,
10253,
1006,
24880,
1031,
1033,
5034,
2278,
1010,
4874,
4539,
1010,
2146,
4539,
27475,
3388,
1007,
1063,
4132,
1012,
6100,
4168,
5302,
2854,
1006,
5034,
2278,
1010,
4132,
1012,
24880,
1035,
9140... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.deserializeResponse | public RESP deserializeResponse(final ByteBuf buf) {
Preconditions.checkNotNull(buf);
return responseDeserializer.deserializeMessage(buf);
} | java | public RESP deserializeResponse(final ByteBuf buf) {
Preconditions.checkNotNull(buf);
return responseDeserializer.deserializeMessage(buf);
} | [
"public",
"RESP",
"deserializeResponse",
"(",
"final",
"ByteBuf",
"buf",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"buf",
")",
";",
"return",
"responseDeserializer",
".",
"deserializeMessage",
"(",
"buf",
")",
";",
"}"
] | De-serializes the response sent to the
{@link org.apache.flink.queryablestate.network.Client}.
<pre>
<b>The buffer is expected to be at the response position.</b>
</pre>
@param buf The {@link ByteBuf} containing the serialized response.
@return The response. | [
"De",
"-",
"serializes",
"the",
"response",
"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#L278-L281 | train | Deserialize a RESP message from the given ByteBuf. | [
30522,
2270,
24501,
2361,
4078,
11610,
28863,
2229,
26029,
3366,
1006,
2345,
24880,
8569,
2546,
20934,
2546,
1007,
1063,
3653,
8663,
20562,
2015,
1012,
4638,
17048,
11231,
3363,
1006,
20934,
2546,
1007,
1025,
2709,
3433,
6155,
11610,
28863,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.writeBytes | public static File writeBytes(byte[] data, String path) throws IORuntimeException {
return writeBytes(data, touch(path));
} | java | public static File writeBytes(byte[] data, String path) throws IORuntimeException {
return writeBytes(data, touch(path));
} | [
"public",
"static",
"File",
"writeBytes",
"(",
"byte",
"[",
"]",
"data",
",",
"String",
"path",
")",
"throws",
"IORuntimeException",
"{",
"return",
"writeBytes",
"(",
"data",
",",
"touch",
"(",
"path",
")",
")",
";",
"}"
] | 写数据到文件中
@param data 数据
@param path 目标文件
@return 目标文件
@throws IORuntimeException IO异常 | [
"写数据到文件中"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L3114-L3116 | train | Write the byte array to a file. | [
30522,
2270,
10763,
5371,
4339,
3762,
4570,
1006,
24880,
1031,
1033,
2951,
1010,
5164,
4130,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
2709,
4339,
3762,
4570,
1006,
2951,
1010,
3543,
1006,
4130,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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/ByteBufUtil.java | ByteBufUtil.readBytes | public static ByteBuf readBytes(ByteBufAllocator alloc, ByteBuf buffer, int length) {
boolean release = true;
ByteBuf dst = alloc.buffer(length);
try {
buffer.readBytes(dst);
release = false;
return dst;
} finally {
if (release) {
dst.release();
}
}
} | java | public static ByteBuf readBytes(ByteBufAllocator alloc, ByteBuf buffer, int length) {
boolean release = true;
ByteBuf dst = alloc.buffer(length);
try {
buffer.readBytes(dst);
release = false;
return dst;
} finally {
if (release) {
dst.release();
}
}
} | [
"public",
"static",
"ByteBuf",
"readBytes",
"(",
"ByteBufAllocator",
"alloc",
",",
"ByteBuf",
"buffer",
",",
"int",
"length",
")",
"{",
"boolean",
"release",
"=",
"true",
";",
"ByteBuf",
"dst",
"=",
"alloc",
".",
"buffer",
"(",
"length",
")",
";",
"try",
... | Read the given amount of bytes into a new {@link ByteBuf} that is allocated from the {@link ByteBufAllocator}. | [
"Read",
"the",
"given",
"amount",
"of",
"bytes",
"into",
"a",
"new",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java#L442-L454 | train | readBytes This method is used to read a byte array of bytes from a byte buffer. | [
30522,
2270,
10763,
24880,
8569,
2546,
3191,
3762,
4570,
1006,
24880,
8569,
13976,
24755,
4263,
2035,
10085,
1010,
24880,
8569,
2546,
17698,
1010,
20014,
3091,
1007,
1063,
22017,
20898,
2713,
1027,
2995,
1025,
24880,
8569,
2546,
16233,
2102,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/recognition/nr/PersonRecognition.java | PersonRecognition.viterbiCompute | public static List<NR> viterbiCompute(List<EnumItem<NR>> roleTagList)
{
return Viterbi.computeEnum(roleTagList, PersonDictionary.transformMatrixDictionary);
} | java | public static List<NR> viterbiCompute(List<EnumItem<NR>> roleTagList)
{
return Viterbi.computeEnum(roleTagList, PersonDictionary.transformMatrixDictionary);
} | [
"public",
"static",
"List",
"<",
"NR",
">",
"viterbiCompute",
"(",
"List",
"<",
"EnumItem",
"<",
"NR",
">",
">",
"roleTagList",
")",
"{",
"return",
"Viterbi",
".",
"computeEnum",
"(",
"roleTagList",
",",
"PersonDictionary",
".",
"transformMatrixDictionary",
")... | 维特比算法求解最优标签
@param roleTagList
@return | [
"维特比算法求解最优标签"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/recognition/nr/PersonRecognition.java#L125-L128 | train | Compute the Viterbi formula. | [
30522,
2270,
10763,
2862,
1026,
17212,
1028,
6819,
3334,
13592,
25377,
10421,
1006,
2862,
1026,
4372,
12717,
18532,
1026,
17212,
1028,
1028,
2535,
15900,
9863,
1007,
1063,
2709,
6819,
3334,
5638,
1012,
24134,
2368,
2819,
1006,
2535,
15900,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.limit | public final LogBuffer limit(int newLimit) {
if (origin + newLimit > buffer.length || newLimit < 0) throw new IllegalArgumentException("capacity excceed: "
+ (origin + newLimit));
limit = newLimit;
return this;
} | java | public final LogBuffer limit(int newLimit) {
if (origin + newLimit > buffer.length || newLimit < 0) throw new IllegalArgumentException("capacity excceed: "
+ (origin + newLimit));
limit = newLimit;
return this;
} | [
"public",
"final",
"LogBuffer",
"limit",
"(",
"int",
"newLimit",
")",
"{",
"if",
"(",
"origin",
"+",
"newLimit",
">",
"buffer",
".",
"length",
"||",
"newLimit",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"capacity excceed: \"",
"+",
"(... | Sets this buffer's limit. If the position is larger than the new limit
then it is set to the new limit. If the mark is defined and larger than
the new limit then it is discarded. </p>
@param newLimit The new limit value; must be non-negative and no larger
than this buffer's capacity
@return This buffer
@throws IllegalArgumentException If the preconditions on
<tt>newLimit</tt> do not hold | [
"Sets",
"this",
"buffer",
"s",
"limit",
".",
"If",
"the",
"position",
"is",
"larger",
"than",
"the",
"new",
"limit",
"then",
"it",
"is",
"set",
"to",
"the",
"new",
"limit",
".",
"If",
"the",
"mark",
"is",
"defined",
"and",
"larger",
"than",
"the",
"n... | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L175-L181 | train | Sets the limit of the buffer. | [
30522,
30524,
1007,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24422,
1006,
1000,
3977,
4654,
9468,
13089,
1024,
1000,
1009,
1006,
4761,
1009,
2047,
17960,
4183,
1007,
1007,
1025,
5787,
1027,
2047,
17960,
4183,
1025,
2709,
2023,
1025,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/BinaryExternalSorter.java | BinaryExternalSorter.setResultIterator | private void setResultIterator(MutableObjectIterator<BinaryRow> iterator) {
synchronized (this.iteratorLock) {
// set the result iterator only, if no exception has occurred
if (this.iteratorException == null) {
this.iterator = iterator;
this.iteratorLock.notifyAll();
}
}
} | java | private void setResultIterator(MutableObjectIterator<BinaryRow> iterator) {
synchronized (this.iteratorLock) {
// set the result iterator only, if no exception has occurred
if (this.iteratorException == null) {
this.iterator = iterator;
this.iteratorLock.notifyAll();
}
}
} | [
"private",
"void",
"setResultIterator",
"(",
"MutableObjectIterator",
"<",
"BinaryRow",
">",
"iterator",
")",
"{",
"synchronized",
"(",
"this",
".",
"iteratorLock",
")",
"{",
"// set the result iterator only, if no exception has occurred",
"if",
"(",
"this",
".",
"itera... | Sets the result iterator. By setting the result iterator, all threads that are waiting for
the result
iterator are notified and will obtain it.
@param iterator The result iterator to set. | [
"Sets",
"the",
"result",
"iterator",
".",
"By",
"setting",
"the",
"result",
"iterator",
"all",
"threads",
"that",
"are",
"waiting",
"for",
"the",
"result",
"iterator",
"are",
"notified",
"and",
"will",
"obtain",
"it",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/BinaryExternalSorter.java#L626-L634 | train | Sets the result iterator. | [
30522,
2797,
11675,
2275,
6072,
11314,
21646,
8844,
1006,
14163,
10880,
16429,
20614,
21646,
8844,
1026,
12441,
10524,
1028,
2009,
6906,
4263,
1007,
1063,
25549,
1006,
2023,
1012,
2009,
6906,
4263,
7878,
1007,
1063,
1013,
1013,
2275,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraph.java | StreamGraph.clear | public void clear() {
streamNodes = new HashMap<>();
virtualSelectNodes = new HashMap<>();
virtualSideOutputNodes = new HashMap<>();
virtualPartitionNodes = new HashMap<>();
vertexIDtoBrokerID = new HashMap<>();
vertexIDtoLoopTimeout = new HashMap<>();
iterationSourceSinkPairs = new HashSet<>();
sources = new HashSet<>();
sinks = new HashSet<>();
} | java | public void clear() {
streamNodes = new HashMap<>();
virtualSelectNodes = new HashMap<>();
virtualSideOutputNodes = new HashMap<>();
virtualPartitionNodes = new HashMap<>();
vertexIDtoBrokerID = new HashMap<>();
vertexIDtoLoopTimeout = new HashMap<>();
iterationSourceSinkPairs = new HashSet<>();
sources = new HashSet<>();
sinks = new HashSet<>();
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"streamNodes",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"virtualSelectNodes",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"virtualSideOutputNodes",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"virtualPartitionNo... | Remove all registered nodes etc. | [
"Remove",
"all",
"registered",
"nodes",
"etc",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraph.java#L111-L121 | train | Clear all the nodes. | [
30522,
2270,
11675,
3154,
1006,
1007,
1063,
5460,
3630,
6155,
1027,
2047,
23325,
2863,
2361,
1026,
1028,
1006,
1007,
1025,
7484,
11246,
22471,
3630,
6155,
1027,
2047,
23325,
2863,
2361,
1026,
1028,
1006,
1007,
1025,
7484,
7363,
5833,
18780,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/factories/TableFactoryService.java | TableFactoryService.filterByFactoryClass | private static <T> List<TableFactory> filterByFactoryClass(
Class<T> factoryClass,
Map<String, String> properties,
List<TableFactory> foundFactories) {
List<TableFactory> classFactories = foundFactories.stream()
.filter(p -> factoryClass.isAssignableFrom(p.getClass()))
.collect(Collectors.toList());
if (classFactories.isEmpty()) {
throw new NoMatchingTableFactoryException(
String.format("No factory implements '%s'.", factoryClass.getCanonicalName()),
factoryClass,
foundFactories,
properties);
}
return classFactories;
} | java | private static <T> List<TableFactory> filterByFactoryClass(
Class<T> factoryClass,
Map<String, String> properties,
List<TableFactory> foundFactories) {
List<TableFactory> classFactories = foundFactories.stream()
.filter(p -> factoryClass.isAssignableFrom(p.getClass()))
.collect(Collectors.toList());
if (classFactories.isEmpty()) {
throw new NoMatchingTableFactoryException(
String.format("No factory implements '%s'.", factoryClass.getCanonicalName()),
factoryClass,
foundFactories,
properties);
}
return classFactories;
} | [
"private",
"static",
"<",
"T",
">",
"List",
"<",
"TableFactory",
">",
"filterByFactoryClass",
"(",
"Class",
"<",
"T",
">",
"factoryClass",
",",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
",",
"List",
"<",
"TableFactory",
">",
"foundFactories",
... | Filters factories with matching context by factory class. | [
"Filters",
"factories",
"with",
"matching",
"context",
"by",
"factory",
"class",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFactoryService.java#L172-L190 | train | Filter by factory class | [
30522,
2797,
10763,
1026,
1056,
1028,
2862,
1026,
2795,
21450,
1028,
11307,
3762,
21450,
26266,
1006,
2465,
1026,
1056,
1028,
4713,
26266,
1010,
4949,
1026,
5164,
1010,
5164,
1028,
5144,
1010,
2862,
1026,
2795,
21450,
1028,
2179,
7011,
1676... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.setFieldValue | public static void setFieldValue(Object obj, Field field, Object value) throws UtilException {
Assert.notNull(obj);
Assert.notNull(field);
field.setAccessible(true);
if(null != value) {
Class<?> fieldType = field.getType();
if(false == fieldType.isAssignableFrom(value.getClass())) {
//对于类型不同的字段,尝试转换,转换失败则使用原对象类型
final Object targetValue = Convert.convert(fieldType, value);
if(null != targetValue) {
value = targetValue;
}
}
}
try {
field.set(obj, value);
} catch (IllegalAccessException e) {
throw new UtilException(e, "IllegalAccess for {}.{}", obj.getClass(), field.getName());
}
} | java | public static void setFieldValue(Object obj, Field field, Object value) throws UtilException {
Assert.notNull(obj);
Assert.notNull(field);
field.setAccessible(true);
if(null != value) {
Class<?> fieldType = field.getType();
if(false == fieldType.isAssignableFrom(value.getClass())) {
//对于类型不同的字段,尝试转换,转换失败则使用原对象类型
final Object targetValue = Convert.convert(fieldType, value);
if(null != targetValue) {
value = targetValue;
}
}
}
try {
field.set(obj, value);
} catch (IllegalAccessException e) {
throw new UtilException(e, "IllegalAccess for {}.{}", obj.getClass(), field.getName());
}
} | [
"public",
"static",
"void",
"setFieldValue",
"(",
"Object",
"obj",
",",
"Field",
"field",
",",
"Object",
"value",
")",
"throws",
"UtilException",
"{",
"Assert",
".",
"notNull",
"(",
"obj",
")",
";",
"Assert",
".",
"notNull",
"(",
"field",
")",
";",
"fiel... | 设置字段值
@param obj 对象
@param field 字段
@param value 值,值类型必须与字段类型匹配,不会自动转换对象类型
@throws UtilException UtilException 包装IllegalAccessException异常 | [
"设置字段值"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java#L250-L271 | train | Sets the value of the specified field from the specified object. | [
30522,
2270,
10763,
11675,
2275,
3790,
10175,
5657,
1006,
4874,
27885,
3501,
1010,
2492,
2492,
1010,
4874,
3643,
1007,
11618,
21183,
9463,
2595,
24422,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
27885,
3501,
1007,
1025,
20865,
1012,
2025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java | Restarter.preInitializeLeakyClasses | private void preInitializeLeakyClasses() {
try {
Class<?> readerClass = ClassNameReader.class;
Field field = readerClass.getDeclaredField("EARLY_EXIT");
field.setAccessible(true);
((Throwable) field.get(null)).fillInStackTrace();
}
catch (Exception ex) {
this.logger.warn("Unable to pre-initialize classes", ex);
}
} | java | private void preInitializeLeakyClasses() {
try {
Class<?> readerClass = ClassNameReader.class;
Field field = readerClass.getDeclaredField("EARLY_EXIT");
field.setAccessible(true);
((Throwable) field.get(null)).fillInStackTrace();
}
catch (Exception ex) {
this.logger.warn("Unable to pre-initialize classes", ex);
}
} | [
"private",
"void",
"preInitializeLeakyClasses",
"(",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"readerClass",
"=",
"ClassNameReader",
".",
"class",
";",
"Field",
"field",
"=",
"readerClass",
".",
"getDeclaredField",
"(",
"\"EARLY_EXIT\"",
")",
";",
"field"... | CGLIB has a private exception field which needs to initialized early to ensure that
the stacktrace doesn't retain a reference to the RestartClassLoader. | [
"CGLIB",
"has",
"a",
"private",
"exception",
"field",
"which",
"needs",
"to",
"initialized",
"early",
"to",
"ensure",
"that",
"the",
"stacktrace",
"doesn",
"t",
"retain",
"a",
"reference",
"to",
"the",
"RestartClassLoader",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java#L188-L198 | train | Pre - initialize leaky classes. | [
30522,
2797,
11675,
3653,
5498,
20925,
4697,
19738,
4801,
26266,
2229,
1006,
1007,
1063,
3046,
1063,
2465,
1026,
1029,
1028,
8068,
26266,
1027,
2465,
18442,
16416,
4063,
1012,
2465,
1025,
2492,
2492,
1027,
8068,
26266,
1012,
2131,
3207,
204... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DelegatingDecompressorFrameListener.java | DelegatingDecompressorFrameListener.initDecompressor | private void initDecompressor(ChannelHandlerContext ctx, int streamId, Http2Headers headers, boolean endOfStream)
throws Http2Exception {
final Http2Stream stream = connection.stream(streamId);
if (stream == null) {
return;
}
Http2Decompressor decompressor = decompressor(stream);
if (decompressor == null && !endOfStream) {
// Determine the content encoding.
CharSequence contentEncoding = headers.get(CONTENT_ENCODING);
if (contentEncoding == null) {
contentEncoding = IDENTITY;
}
final EmbeddedChannel channel = newContentDecompressor(ctx, contentEncoding);
if (channel != null) {
decompressor = new Http2Decompressor(channel);
stream.setProperty(propertyKey, decompressor);
// Decode the content and remove or replace the existing headers
// so that the message looks like a decoded message.
CharSequence targetContentEncoding = getTargetContentEncoding(contentEncoding);
if (IDENTITY.contentEqualsIgnoreCase(targetContentEncoding)) {
headers.remove(CONTENT_ENCODING);
} else {
headers.set(CONTENT_ENCODING, targetContentEncoding);
}
}
}
if (decompressor != null) {
// The content length will be for the compressed data. Since we will decompress the data
// this content-length will not be correct. Instead of queuing messages or delaying sending
// header frames...just remove the content-length header
headers.remove(CONTENT_LENGTH);
// The first time that we initialize a decompressor, decorate the local flow controller to
// properly convert consumed bytes.
if (!flowControllerInitialized) {
flowControllerInitialized = true;
connection.local().flowController(new ConsumedBytesConverter(connection.local().flowController()));
}
}
} | java | private void initDecompressor(ChannelHandlerContext ctx, int streamId, Http2Headers headers, boolean endOfStream)
throws Http2Exception {
final Http2Stream stream = connection.stream(streamId);
if (stream == null) {
return;
}
Http2Decompressor decompressor = decompressor(stream);
if (decompressor == null && !endOfStream) {
// Determine the content encoding.
CharSequence contentEncoding = headers.get(CONTENT_ENCODING);
if (contentEncoding == null) {
contentEncoding = IDENTITY;
}
final EmbeddedChannel channel = newContentDecompressor(ctx, contentEncoding);
if (channel != null) {
decompressor = new Http2Decompressor(channel);
stream.setProperty(propertyKey, decompressor);
// Decode the content and remove or replace the existing headers
// so that the message looks like a decoded message.
CharSequence targetContentEncoding = getTargetContentEncoding(contentEncoding);
if (IDENTITY.contentEqualsIgnoreCase(targetContentEncoding)) {
headers.remove(CONTENT_ENCODING);
} else {
headers.set(CONTENT_ENCODING, targetContentEncoding);
}
}
}
if (decompressor != null) {
// The content length will be for the compressed data. Since we will decompress the data
// this content-length will not be correct. Instead of queuing messages or delaying sending
// header frames...just remove the content-length header
headers.remove(CONTENT_LENGTH);
// The first time that we initialize a decompressor, decorate the local flow controller to
// properly convert consumed bytes.
if (!flowControllerInitialized) {
flowControllerInitialized = true;
connection.local().flowController(new ConsumedBytesConverter(connection.local().flowController()));
}
}
} | [
"private",
"void",
"initDecompressor",
"(",
"ChannelHandlerContext",
"ctx",
",",
"int",
"streamId",
",",
"Http2Headers",
"headers",
",",
"boolean",
"endOfStream",
")",
"throws",
"Http2Exception",
"{",
"final",
"Http2Stream",
"stream",
"=",
"connection",
".",
"stream... | Checks if a new decompressor object is needed for the stream identified by {@code streamId}.
This method will modify the {@code content-encoding} header contained in {@code headers}.
@param ctx The context
@param streamId The identifier for the headers inside {@code headers}
@param headers Object representing headers which have been read
@param endOfStream Indicates if the stream has ended
@throws Http2Exception If the {@code content-encoding} is not supported | [
"Checks",
"if",
"a",
"new",
"decompressor",
"object",
"is",
"needed",
"for",
"the",
"stream",
"identified",
"by",
"{",
"@code",
"streamId",
"}",
".",
"This",
"method",
"will",
"modify",
"the",
"{",
"@code",
"content",
"-",
"encoding",
"}",
"header",
"conta... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java#L205-L247 | train | Initialize the decompressor. | [
30522,
2797,
11675,
1999,
4183,
3207,
9006,
20110,
2953,
1006,
3149,
11774,
3917,
8663,
18209,
14931,
2595,
1010,
20014,
5460,
3593,
1010,
8299,
2475,
4974,
2545,
20346,
2015,
1010,
22017,
20898,
2203,
11253,
21422,
1007,
11618,
8299,
2475,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/files/StaticFileServerHandler.java | StaticFileServerHandler.respondAsLeader | @Override
protected void respondAsLeader(ChannelHandlerContext channelHandlerContext, RoutedRequest routedRequest, T gateway) throws Exception {
final HttpRequest request = routedRequest.getRequest();
final String requestPath;
// make sure we request the "index.html" in case there is a directory request
if (routedRequest.getPath().endsWith("/")) {
requestPath = routedRequest.getPath() + "index.html";
}
// in case the files being accessed are logs or stdout files, find appropriate paths.
else if (routedRequest.getPath().equals("/jobmanager/log") || routedRequest.getPath().equals("/jobmanager/stdout")) {
requestPath = "";
} else {
requestPath = routedRequest.getPath();
}
respondToRequest(channelHandlerContext, request, requestPath);
} | java | @Override
protected void respondAsLeader(ChannelHandlerContext channelHandlerContext, RoutedRequest routedRequest, T gateway) throws Exception {
final HttpRequest request = routedRequest.getRequest();
final String requestPath;
// make sure we request the "index.html" in case there is a directory request
if (routedRequest.getPath().endsWith("/")) {
requestPath = routedRequest.getPath() + "index.html";
}
// in case the files being accessed are logs or stdout files, find appropriate paths.
else if (routedRequest.getPath().equals("/jobmanager/log") || routedRequest.getPath().equals("/jobmanager/stdout")) {
requestPath = "";
} else {
requestPath = routedRequest.getPath();
}
respondToRequest(channelHandlerContext, request, requestPath);
} | [
"@",
"Override",
"protected",
"void",
"respondAsLeader",
"(",
"ChannelHandlerContext",
"channelHandlerContext",
",",
"RoutedRequest",
"routedRequest",
",",
"T",
"gateway",
")",
"throws",
"Exception",
"{",
"final",
"HttpRequest",
"request",
"=",
"routedRequest",
".",
"... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/files/StaticFileServerHandler.java#L125-L142 | train | respond as leader. | [
30522,
1030,
2058,
15637,
5123,
11675,
6869,
3022,
19000,
1006,
3149,
11774,
3917,
8663,
18209,
3149,
11774,
3917,
8663,
18209,
1010,
19578,
2890,
15500,
19578,
2890,
15500,
1010,
1056,
11909,
1007,
11618,
6453,
1063,
2345,
8299,
2890,
15500,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-json/src/main/java/cn/hutool/json/JSONGetter.java | JSONGetter.getStrEscaped | public String getStrEscaped(K key, String defaultValue) {
return JSONUtil.escape(getStr(key, defaultValue));
} | java | public String getStrEscaped(K key, String defaultValue) {
return JSONUtil.escape(getStr(key, defaultValue));
} | [
"public",
"String",
"getStrEscaped",
"(",
"K",
"key",
",",
"String",
"defaultValue",
")",
"{",
"return",
"JSONUtil",
".",
"escape",
"(",
"getStr",
"(",
"key",
",",
"defaultValue",
")",
")",
";",
"}"
] | 获取字符串类型值,并转义不可见字符,如'\n'换行符会被转义为字符串"\n"
@param key 键
@param defaultValue 默认值
@return 字符串类型值
@since 4.2.2 | [
"获取字符串类型值,并转义不可见字符,如",
"\\",
"n",
"换行符会被转义为字符串",
"\\",
"n"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-json/src/main/java/cn/hutool/json/JSONGetter.java#L43-L45 | train | Returns the string value for the given key as escaped. | [
30522,
2270,
5164,
4152,
19168,
19464,
2094,
1006,
1047,
3145,
1010,
5164,
12398,
10175,
5657,
1007,
1063,
2709,
1046,
3385,
21823,
2140,
1012,
4019,
1006,
4152,
16344,
1006,
3145,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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/qrcode/QrConfig.java | QrConfig.toHints | public HashMap<EncodeHintType, Object> toHints() {
// 配置
final HashMap<EncodeHintType, Object> hints = new HashMap<>();
if (null != this.charset) {
hints.put(EncodeHintType.CHARACTER_SET, charset.toString());
}
if (null != this.errorCorrection) {
hints.put(EncodeHintType.ERROR_CORRECTION, this.errorCorrection);
}
if (null != this.margin) {
hints.put(EncodeHintType.MARGIN, this.margin);
}
return hints;
} | java | public HashMap<EncodeHintType, Object> toHints() {
// 配置
final HashMap<EncodeHintType, Object> hints = new HashMap<>();
if (null != this.charset) {
hints.put(EncodeHintType.CHARACTER_SET, charset.toString());
}
if (null != this.errorCorrection) {
hints.put(EncodeHintType.ERROR_CORRECTION, this.errorCorrection);
}
if (null != this.margin) {
hints.put(EncodeHintType.MARGIN, this.margin);
}
return hints;
} | [
"public",
"HashMap",
"<",
"EncodeHintType",
",",
"Object",
">",
"toHints",
"(",
")",
"{",
"// 配置\r",
"final",
"HashMap",
"<",
"EncodeHintType",
",",
"Object",
">",
"hints",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"this",
".... | 转换为Zxing的二维码配置
@return 配置 | [
"转换为Zxing的二维码配置"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/qrcode/QrConfig.java#L277-L290 | train | Converts this object to a HashMap of hints. | [
30522,
2270,
23325,
2863,
2361,
1026,
4372,
16044,
10606,
15353,
5051,
1010,
4874,
1028,
2000,
10606,
3215,
1006,
1007,
1063,
1013,
1013,
100,
100,
2345,
23325,
2863,
2361,
1026,
4372,
16044,
10606,
15353,
5051,
1010,
4874,
1028,
20385,
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-mesos/src/main/java/org/apache/flink/mesos/util/MesosConfiguration.java | MesosConfiguration.logMesosConfig | public static void logMesosConfig(Logger log, MesosConfiguration config) {
Map<String, String> env = System.getenv();
Protos.FrameworkInfo.Builder info = config.frameworkInfo();
log.info("--------------------------------------------------------------------------------");
log.info(" Mesos Info:");
log.info(" Master URL: {}", config.masterUrl());
log.info(" Framework Info:");
log.info(" ID: {}", info.hasId() ? info.getId().getValue() : "(none)");
log.info(" Name: {}", info.hasName() ? info.getName() : "(none)");
log.info(" Failover Timeout (secs): {}", info.getFailoverTimeout());
log.info(" Role: {}", info.hasRole() ? info.getRole() : "(none)");
log.info(" Capabilities: {}",
info.getCapabilitiesList().size() > 0 ? info.getCapabilitiesList() : "(none)");
log.info(" Principal: {}", info.hasPrincipal() ? info.getPrincipal() : "(none)");
log.info(" Host: {}", info.hasHostname() ? info.getHostname() : "(none)");
if (env.containsKey("LIBPROCESS_IP")) {
log.info(" LIBPROCESS_IP: {}", env.get("LIBPROCESS_IP"));
}
if (env.containsKey("LIBPROCESS_PORT")) {
log.info(" LIBPROCESS_PORT: {}", env.get("LIBPROCESS_PORT"));
}
log.info(" Web UI: {}", info.hasWebuiUrl() ? info.getWebuiUrl() : "(none)");
log.info("--------------------------------------------------------------------------------");
} | java | public static void logMesosConfig(Logger log, MesosConfiguration config) {
Map<String, String> env = System.getenv();
Protos.FrameworkInfo.Builder info = config.frameworkInfo();
log.info("--------------------------------------------------------------------------------");
log.info(" Mesos Info:");
log.info(" Master URL: {}", config.masterUrl());
log.info(" Framework Info:");
log.info(" ID: {}", info.hasId() ? info.getId().getValue() : "(none)");
log.info(" Name: {}", info.hasName() ? info.getName() : "(none)");
log.info(" Failover Timeout (secs): {}", info.getFailoverTimeout());
log.info(" Role: {}", info.hasRole() ? info.getRole() : "(none)");
log.info(" Capabilities: {}",
info.getCapabilitiesList().size() > 0 ? info.getCapabilitiesList() : "(none)");
log.info(" Principal: {}", info.hasPrincipal() ? info.getPrincipal() : "(none)");
log.info(" Host: {}", info.hasHostname() ? info.getHostname() : "(none)");
if (env.containsKey("LIBPROCESS_IP")) {
log.info(" LIBPROCESS_IP: {}", env.get("LIBPROCESS_IP"));
}
if (env.containsKey("LIBPROCESS_PORT")) {
log.info(" LIBPROCESS_PORT: {}", env.get("LIBPROCESS_PORT"));
}
log.info(" Web UI: {}", info.hasWebuiUrl() ? info.getWebuiUrl() : "(none)");
log.info("--------------------------------------------------------------------------------");
} | [
"public",
"static",
"void",
"logMesosConfig",
"(",
"Logger",
"log",
",",
"MesosConfiguration",
"config",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"env",
"=",
"System",
".",
"getenv",
"(",
")",
";",
"Protos",
".",
"FrameworkInfo",
".",
"Builder",... | A utility method to log relevant Mesos connection info. | [
"A",
"utility",
"method",
"to",
"log",
"relevant",
"Mesos",
"connection",
"info",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-mesos/src/main/java/org/apache/flink/mesos/util/MesosConfiguration.java#L135-L163 | train | Log the Mesos configuration | [
30522,
2270,
10763,
11675,
8833,
7834,
2891,
8663,
8873,
2290,
1006,
8833,
4590,
8833,
1010,
2033,
17063,
8663,
8873,
27390,
3370,
9530,
8873,
2290,
1007,
1063,
4949,
1026,
5164,
1010,
5164,
1028,
4372,
2615,
1027,
2291,
1012,
2131,
2368,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/factories/TableFactoryService.java | TableFactoryService.normalizeContext | private static Map<String, String> normalizeContext(TableFactory factory) {
Map<String, String> requiredContext = factory.requiredContext();
if (requiredContext == null) {
throw new TableException(
String.format("Required context of factory '%s' must not be null.", factory.getClass().getName()));
}
return requiredContext.keySet().stream()
.collect(Collectors.toMap(key -> key.toLowerCase(), key -> requiredContext.get(key)));
} | java | private static Map<String, String> normalizeContext(TableFactory factory) {
Map<String, String> requiredContext = factory.requiredContext();
if (requiredContext == null) {
throw new TableException(
String.format("Required context of factory '%s' must not be null.", factory.getClass().getName()));
}
return requiredContext.keySet().stream()
.collect(Collectors.toMap(key -> key.toLowerCase(), key -> requiredContext.get(key)));
} | [
"private",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"normalizeContext",
"(",
"TableFactory",
"factory",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"requiredContext",
"=",
"factory",
".",
"requiredContext",
"(",
")",
";",
"if",
"(",
"req... | Prepares the properties of a context to be used for match operations. | [
"Prepares",
"the",
"properties",
"of",
"a",
"context",
"to",
"be",
"used",
"for",
"match",
"operations",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/TableFactoryService.java#L233-L241 | train | Normalizes the context of the given table factory. | [
30522,
2797,
10763,
4949,
1026,
5164,
1010,
5164,
1028,
3671,
4697,
8663,
18209,
1006,
2795,
21450,
4713,
1007,
1063,
4949,
1026,
5164,
1010,
5164,
1028,
3223,
8663,
18209,
1027,
4713,
1012,
3223,
8663,
18209,
1006,
1007,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java | ResourceUtils.getUrls | public static List<String> getUrls(String path, ClassLoader classLoader) {
if (classLoader == null) {
classLoader = ClassUtils.getDefaultClassLoader();
}
path = StringUtils.cleanPath(path);
try {
return getUrlsFromWildcardPath(path, classLoader);
}
catch (Exception ex) {
throw new IllegalArgumentException(
"Cannot create URL from path [" + path + "]", ex);
}
} | java | public static List<String> getUrls(String path, ClassLoader classLoader) {
if (classLoader == null) {
classLoader = ClassUtils.getDefaultClassLoader();
}
path = StringUtils.cleanPath(path);
try {
return getUrlsFromWildcardPath(path, classLoader);
}
catch (Exception ex) {
throw new IllegalArgumentException(
"Cannot create URL from path [" + path + "]", ex);
}
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getUrls",
"(",
"String",
"path",
",",
"ClassLoader",
"classLoader",
")",
"{",
"if",
"(",
"classLoader",
"==",
"null",
")",
"{",
"classLoader",
"=",
"ClassUtils",
".",
"getDefaultClassLoader",
"(",
")",
";",
... | Return URLs from a given source path. Source paths can be simple file locations
(/some/file.java) or wildcard patterns (/some/**). Additionally the prefixes
"file:", "classpath:" and "classpath*:" can be used for specific path types.
@param path the source path
@param classLoader the class loader or {@code null} to use the default
@return a list of URLs | [
"Return",
"URLs",
"from",
"a",
"given",
"source",
"path",
".",
"Source",
"paths",
"can",
"be",
"simple",
"file",
"locations",
"(",
"/",
"some",
"/",
"file",
".",
"java",
")",
"or",
"wildcard",
"patterns",
"(",
"/",
"some",
"/",
"**",
")",
".",
"Addit... | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java#L68-L80 | train | Gets the URLs from a path. | [
30522,
2270,
10763,
2862,
1026,
5164,
1028,
2131,
3126,
4877,
1006,
5164,
4130,
1010,
2465,
11066,
2121,
2465,
11066,
2121,
1007,
1063,
2065,
1006,
2465,
11066,
2121,
1027,
1027,
19701,
1007,
1063,
2465,
11066,
2121,
1027,
2465,
21823,
4877... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/io/PostVersionedIOReadableWritable.java | PostVersionedIOReadableWritable.read | public final void read(InputStream inputStream) throws IOException {
byte[] tmp = new byte[VERSIONED_IDENTIFIER.length];
inputStream.read(tmp);
if (Arrays.equals(tmp, VERSIONED_IDENTIFIER)) {
DataInputView inputView = new DataInputViewStreamWrapper(inputStream);
super.read(inputView);
read(inputView, true);
} else {
PushbackInputStream resetStream = new PushbackInputStream(inputStream, VERSIONED_IDENTIFIER.length);
resetStream.unread(tmp);
read(new DataInputViewStreamWrapper(resetStream), false);
}
} | java | public final void read(InputStream inputStream) throws IOException {
byte[] tmp = new byte[VERSIONED_IDENTIFIER.length];
inputStream.read(tmp);
if (Arrays.equals(tmp, VERSIONED_IDENTIFIER)) {
DataInputView inputView = new DataInputViewStreamWrapper(inputStream);
super.read(inputView);
read(inputView, true);
} else {
PushbackInputStream resetStream = new PushbackInputStream(inputStream, VERSIONED_IDENTIFIER.length);
resetStream.unread(tmp);
read(new DataInputViewStreamWrapper(resetStream), false);
}
} | [
"public",
"final",
"void",
"read",
"(",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"tmp",
"=",
"new",
"byte",
"[",
"VERSIONED_IDENTIFIER",
".",
"length",
"]",
";",
"inputStream",
".",
"read",
"(",
"tmp",
")",
";",
... | This read attempts to first identify if the input view contains the special
{@link #VERSIONED_IDENTIFIER} by reading and buffering the first few bytes.
If identified to be versioned, the usual version resolution read path
in {@link VersionedIOReadableWritable#read(DataInputView)} is invoked.
Otherwise, we "reset" the input stream by pushing back the read buffered bytes
into the stream. | [
"This",
"read",
"attempts",
"to",
"first",
"identify",
"if",
"the",
"input",
"view",
"contains",
"the",
"special",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/io/PostVersionedIOReadableWritable.java#L63-L78 | train | Reads the contents of the given input stream. | [
30522,
2270,
2345,
11675,
3191,
1006,
20407,
25379,
20407,
25379,
1007,
11618,
22834,
10288,
24422,
1063,
24880,
1031,
1033,
1056,
8737,
1027,
2047,
24880,
1031,
2544,
2098,
1035,
8909,
4765,
18095,
1012,
3091,
1033,
1025,
20407,
25379,
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/metrics/MetricRegistryImpl.java | MetricRegistryImpl.getMetricQueryServiceGatewayRpcAddress | @Override
@Nullable
public String getMetricQueryServiceGatewayRpcAddress() {
if (queryService != null) {
return queryService.getSelfGateway(MetricQueryServiceGateway.class).getAddress();
} else {
return null;
}
} | java | @Override
@Nullable
public String getMetricQueryServiceGatewayRpcAddress() {
if (queryService != null) {
return queryService.getSelfGateway(MetricQueryServiceGateway.class).getAddress();
} else {
return null;
}
} | [
"@",
"Override",
"@",
"Nullable",
"public",
"String",
"getMetricQueryServiceGatewayRpcAddress",
"(",
")",
"{",
"if",
"(",
"queryService",
"!=",
"null",
")",
"{",
"return",
"queryService",
".",
"getSelfGateway",
"(",
"MetricQueryServiceGateway",
".",
"class",
")",
... | Returns the address under which the {@link MetricQueryService} is reachable.
@return address of the metric query service | [
"Returns",
"the",
"address",
"under",
"which",
"the",
"{",
"@link",
"MetricQueryService",
"}",
"is",
"reachable",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/MetricRegistryImpl.java#L199-L207 | train | Get the address of the metric query service gateway. | [
30522,
1030,
2058,
15637,
1030,
19701,
3085,
2270,
5164,
2131,
12589,
4226,
24769,
2121,
7903,
29107,
2618,
4576,
14536,
3540,
14141,
8303,
1006,
1007,
1063,
2065,
1006,
23032,
8043,
7903,
2063,
999,
1027,
19701,
1007,
1063,
2709,
23032,
80... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-optimizer/src/main/java/org/apache/flink/optimizer/plan/PlanNode.java | PlanNode.setBroadcastInputs | public void setBroadcastInputs(List<NamedChannel> broadcastInputs) {
if (broadcastInputs != null) {
this.broadcastInputs = broadcastInputs;
// update the branch map
for (NamedChannel nc : broadcastInputs) {
PlanNode source = nc.getSource();
mergeBranchPlanMaps(branchPlan, source.branchPlan);
}
}
// do a sanity check that if we are branching, we have now candidates for each branch point
if (this.template.hasUnclosedBranches()) {
if (this.branchPlan == null) {
throw new CompilerException("Branching and rejoining logic did not find a candidate for the branching point.");
}
for (UnclosedBranchDescriptor uc : this.template.getOpenBranches()) {
OptimizerNode brancher = uc.getBranchingNode();
if (this.branchPlan.get(brancher) == null) {
throw new CompilerException("Branching and rejoining logic did not find a candidate for the branching point.");
}
}
}
} | java | public void setBroadcastInputs(List<NamedChannel> broadcastInputs) {
if (broadcastInputs != null) {
this.broadcastInputs = broadcastInputs;
// update the branch map
for (NamedChannel nc : broadcastInputs) {
PlanNode source = nc.getSource();
mergeBranchPlanMaps(branchPlan, source.branchPlan);
}
}
// do a sanity check that if we are branching, we have now candidates for each branch point
if (this.template.hasUnclosedBranches()) {
if (this.branchPlan == null) {
throw new CompilerException("Branching and rejoining logic did not find a candidate for the branching point.");
}
for (UnclosedBranchDescriptor uc : this.template.getOpenBranches()) {
OptimizerNode brancher = uc.getBranchingNode();
if (this.branchPlan.get(brancher) == null) {
throw new CompilerException("Branching and rejoining logic did not find a candidate for the branching point.");
}
}
}
} | [
"public",
"void",
"setBroadcastInputs",
"(",
"List",
"<",
"NamedChannel",
">",
"broadcastInputs",
")",
"{",
"if",
"(",
"broadcastInputs",
"!=",
"null",
")",
"{",
"this",
".",
"broadcastInputs",
"=",
"broadcastInputs",
";",
"// update the branch map",
"for",
"(",
... | Sets a list of all broadcast inputs attached to this node. | [
"Sets",
"a",
"list",
"of",
"all",
"broadcast",
"inputs",
"attached",
"to",
"this",
"node",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/plan/PlanNode.java#L341-L366 | train | Sets the broadcast inputs for this rejoining. | [
30522,
2270,
11675,
2275,
12618,
4215,
10526,
2378,
18780,
2015,
1006,
2862,
1026,
2315,
26058,
1028,
3743,
2378,
18780,
2015,
1007,
1063,
2065,
1006,
3743,
2378,
18780,
2015,
999,
1027,
19701,
1007,
1063,
2023,
1012,
3743,
2378,
18780,
201... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/exceptions/ExceptionUtil.java | ExceptionUtil.isFromOrSuppressedThrowable | public static boolean isFromOrSuppressedThrowable(Throwable throwable, Class<? extends Throwable> exceptionClass, boolean checkCause) {
return convertFromOrSuppressedThrowable(throwable, exceptionClass, checkCause) != null;
} | java | public static boolean isFromOrSuppressedThrowable(Throwable throwable, Class<? extends Throwable> exceptionClass, boolean checkCause) {
return convertFromOrSuppressedThrowable(throwable, exceptionClass, checkCause) != null;
} | [
"public",
"static",
"boolean",
"isFromOrSuppressedThrowable",
"(",
"Throwable",
"throwable",
",",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
"exceptionClass",
",",
"boolean",
"checkCause",
")",
"{",
"return",
"convertFromOrSuppressedThrowable",
"(",
"throwable",
... | 判断指定异常是否来自或者包含指定异常
@param throwable 异常
@param exceptionClass 定义的引起异常的类
@param checkCause 判断cause
@return true 来自或者包含
@since 4.4.1 | [
"判断指定异常是否来自或者包含指定异常"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/exceptions/ExceptionUtil.java#L269-L271 | train | Checks if throwable is from or suppressed exception. | [
30522,
2270,
10763,
22017,
20898,
2003,
19699,
19506,
2869,
6279,
19811,
30524,
1006,
5466,
3085,
1010,
6453,
26266,
1010,
4638,
3540,
8557,
1007,
999,
1027,
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,
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/utils/EncodingUtils.java | EncodingUtils.repeat | public static String repeat(final String str, final int repeat) {
// Performance tuned for 2.0 (JDK1.4)
if (str == null) {
return null;
}
if (repeat <= 0) {
return EMPTY;
}
final int inputLength = str.length();
if (repeat == 1 || inputLength == 0) {
return str;
}
if (inputLength == 1 && repeat <= PAD_LIMIT) {
return repeat(str.charAt(0), repeat);
}
final int outputLength = inputLength * repeat;
switch (inputLength) {
case 1:
return repeat(str.charAt(0), repeat);
case 2:
final char ch0 = str.charAt(0);
final char ch1 = str.charAt(1);
final char[] output2 = new char[outputLength];
for (int i = repeat * 2 - 2; i >= 0; i--, i--) {
output2[i] = ch0;
output2[i + 1] = ch1;
}
return new String(output2);
default:
final StringBuilder buf = new StringBuilder(outputLength);
for (int i = 0; i < repeat; i++) {
buf.append(str);
}
return buf.toString();
}
} | java | public static String repeat(final String str, final int repeat) {
// Performance tuned for 2.0 (JDK1.4)
if (str == null) {
return null;
}
if (repeat <= 0) {
return EMPTY;
}
final int inputLength = str.length();
if (repeat == 1 || inputLength == 0) {
return str;
}
if (inputLength == 1 && repeat <= PAD_LIMIT) {
return repeat(str.charAt(0), repeat);
}
final int outputLength = inputLength * repeat;
switch (inputLength) {
case 1:
return repeat(str.charAt(0), repeat);
case 2:
final char ch0 = str.charAt(0);
final char ch1 = str.charAt(1);
final char[] output2 = new char[outputLength];
for (int i = repeat * 2 - 2; i >= 0; i--, i--) {
output2[i] = ch0;
output2[i + 1] = ch1;
}
return new String(output2);
default:
final StringBuilder buf = new StringBuilder(outputLength);
for (int i = 0; i < repeat; i++) {
buf.append(str);
}
return buf.toString();
}
} | [
"public",
"static",
"String",
"repeat",
"(",
"final",
"String",
"str",
",",
"final",
"int",
"repeat",
")",
"{",
"// Performance tuned for 2.0 (JDK1.4)",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"repeat",
"<=",
"0",
... | Repeat a String {@code repeat} times to form a new String.
<pre>
StringUtils.repeat(null, 2) = null
StringUtils.repeat("", 0) = ""
StringUtils.repeat("", 2) = ""
StringUtils.repeat("a", 3) = "aaa"
StringUtils.repeat("ab", 2) = "abab"
StringUtils.repeat("a", -2) = ""
</pre>
@param str the String to repeat, may be null
@param repeat number of times to repeat str, negative treated as zero
@return a new String consisting of the original String repeated, {@code null} if null String input | [
"Repeat",
"a",
"String",
"{",
"@code",
"repeat",
"}",
"times",
"to",
"form",
"a",
"new",
"String",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/utils/EncodingUtils.java#L156-L193 | train | Returns a string that is repeated. | [
30522,
2270,
10763,
5164,
9377,
1006,
2345,
5164,
2358,
2099,
1010,
2345,
20014,
9377,
1007,
1063,
1013,
1013,
2836,
15757,
2005,
1016,
1012,
1014,
1006,
26219,
2243,
2487,
1012,
1018,
1007,
2065,
1006,
2358,
2099,
1027,
1027,
19701,
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-core/src/main/java/org/apache/flink/util/ReflectionUtil.java | ReflectionUtil.getFullTemplateType | public static FullTypeInfo getFullTemplateType(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
FullTypeInfo[] templateTypeInfos = new FullTypeInfo[parameterizedType.getActualTypeArguments().length];
for (int i = 0; i < parameterizedType.getActualTypeArguments().length; i++) {
templateTypeInfos[i] = getFullTemplateType(parameterizedType.getActualTypeArguments()[i]);
}
return new FullTypeInfo((Class<?>) parameterizedType.getRawType(), templateTypeInfos);
} else {
return new FullTypeInfo((Class<?>) type, null);
}
} | java | public static FullTypeInfo getFullTemplateType(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
FullTypeInfo[] templateTypeInfos = new FullTypeInfo[parameterizedType.getActualTypeArguments().length];
for (int i = 0; i < parameterizedType.getActualTypeArguments().length; i++) {
templateTypeInfos[i] = getFullTemplateType(parameterizedType.getActualTypeArguments()[i]);
}
return new FullTypeInfo((Class<?>) parameterizedType.getRawType(), templateTypeInfos);
} else {
return new FullTypeInfo((Class<?>) type, null);
}
} | [
"public",
"static",
"FullTypeInfo",
"getFullTemplateType",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"ParameterizedType",
")",
"{",
"ParameterizedType",
"parameterizedType",
"=",
"(",
"ParameterizedType",
")",
"type",
";",
"FullTypeInfo",
"[",
... | Extract the full type information from the given type.
@param type to be analyzed
@return Full type information describing the given type | [
"Extract",
"the",
"full",
"type",
"information",
"from",
"the",
"given",
"type",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/ReflectionUtil.java#L183-L197 | train | Get the full type information for a type. | [
30522,
2270,
10763,
2440,
13874,
2378,
14876,
2131,
3993,
7096,
6633,
15725,
13874,
1006,
2828,
2828,
1007,
1063,
2065,
1006,
2828,
6013,
11253,
16381,
3550,
13874,
1007,
1063,
16381,
3550,
13874,
16381,
3550,
13874,
1027,
1006,
16381,
3550,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Utils.java | Utils.getEnvironmentVariables | public static Map<String, String> getEnvironmentVariables(String envPrefix, org.apache.flink.configuration.Configuration flinkConfiguration) {
Map<String, String> result = new HashMap<>();
for (Map.Entry<String, String> entry: flinkConfiguration.toMap().entrySet()) {
if (entry.getKey().startsWith(envPrefix) && entry.getKey().length() > envPrefix.length()) {
// remove prefix
String key = entry.getKey().substring(envPrefix.length());
result.put(key, entry.getValue());
}
}
return result;
} | java | public static Map<String, String> getEnvironmentVariables(String envPrefix, org.apache.flink.configuration.Configuration flinkConfiguration) {
Map<String, String> result = new HashMap<>();
for (Map.Entry<String, String> entry: flinkConfiguration.toMap().entrySet()) {
if (entry.getKey().startsWith(envPrefix) && entry.getKey().length() > envPrefix.length()) {
// remove prefix
String key = entry.getKey().substring(envPrefix.length());
result.put(key, entry.getValue());
}
}
return result;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"getEnvironmentVariables",
"(",
"String",
"envPrefix",
",",
"org",
".",
"apache",
".",
"flink",
".",
"configuration",
".",
"Configuration",
"flinkConfiguration",
")",
"{",
"Map",
"<",
"String",
",",... | Method to extract environment variables from the flinkConfiguration based on the given prefix String.
@param envPrefix Prefix for the environment variables key
@param flinkConfiguration The Flink config to get the environment variable defintion from | [
"Method",
"to",
"extract",
"environment",
"variables",
"from",
"the",
"flinkConfiguration",
"based",
"on",
"the",
"given",
"prefix",
"String",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-yarn/src/main/java/org/apache/flink/yarn/Utils.java#L337-L347 | train | Gets the environment variables from the given configuration. | [
30522,
2270,
10763,
4949,
1026,
5164,
1010,
5164,
1028,
2131,
2368,
21663,
2239,
3672,
10755,
19210,
2015,
1006,
5164,
4372,
2615,
28139,
8873,
2595,
1010,
8917,
1012,
15895,
1012,
13109,
19839,
1012,
9563,
1012,
9563,
13109,
19839,
8663,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/query/KvStateRegistry.java | KvStateRegistry.getKvStateRegistryListener | private KvStateRegistryListener getKvStateRegistryListener(JobID jobId) {
// first check whether we are running the legacy code which registers
// a single listener under HighAvailabilityServices.DEFAULT_JOB_ID
KvStateRegistryListener listener = listeners.get(HighAvailabilityServices.DEFAULT_JOB_ID);
if (listener == null) {
listener = listeners.get(jobId);
}
return listener;
} | java | private KvStateRegistryListener getKvStateRegistryListener(JobID jobId) {
// first check whether we are running the legacy code which registers
// a single listener under HighAvailabilityServices.DEFAULT_JOB_ID
KvStateRegistryListener listener = listeners.get(HighAvailabilityServices.DEFAULT_JOB_ID);
if (listener == null) {
listener = listeners.get(jobId);
}
return listener;
} | [
"private",
"KvStateRegistryListener",
"getKvStateRegistryListener",
"(",
"JobID",
"jobId",
")",
"{",
"// first check whether we are running the legacy code which registers",
"// a single listener under HighAvailabilityServices.DEFAULT_JOB_ID",
"KvStateRegistryListener",
"listener",
"=",
"l... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/query/KvStateRegistry.java#L169-L178 | train | Get the KvStateRegistryListener for the given job id. | [
30522,
2797,
24888,
9153,
3334,
13910,
2923,
23320,
27870,
3678,
2131,
2243,
15088,
12259,
2890,
24063,
23320,
27870,
3678,
1006,
3105,
3593,
3105,
3593,
1007,
1063,
1013,
1013,
2034,
4638,
3251,
2057,
2024,
2770,
1996,
8027,
3642,
2029,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/functions/aggfunctions/DeclarativeAggregateFunction.java | DeclarativeAggregateFunction.operand | public final UnresolvedReferenceExpression operand(int i) {
String name = String.valueOf(i);
if (getAggBufferNames().contains(name)) {
throw new IllegalStateException(
String.format("Agg buffer name(%s) should not same to operands.", name));
}
return new UnresolvedReferenceExpression(name);
} | java | public final UnresolvedReferenceExpression operand(int i) {
String name = String.valueOf(i);
if (getAggBufferNames().contains(name)) {
throw new IllegalStateException(
String.format("Agg buffer name(%s) should not same to operands.", name));
}
return new UnresolvedReferenceExpression(name);
} | [
"public",
"final",
"UnresolvedReferenceExpression",
"operand",
"(",
"int",
"i",
")",
"{",
"String",
"name",
"=",
"String",
".",
"valueOf",
"(",
"i",
")",
";",
"if",
"(",
"getAggBufferNames",
"(",
")",
".",
"contains",
"(",
"name",
")",
")",
"{",
"throw",... | Arg of accumulate and retract, the input value (usually obtained from a new arrived data). | [
"Arg",
"of",
"accumulate",
"and",
"retract",
"the",
"input",
"value",
"(",
"usually",
"obtained",
"from",
"a",
"new",
"arrived",
"data",
")",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/functions/aggfunctions/DeclarativeAggregateFunction.java#L134-L141 | train | Returns an unresolved reference expression that has the given operand. | [
30522,
2270,
2345,
4895,
6072,
16116,
2890,
25523,
10288,
20110,
3258,
3850,
4859,
1006,
20014,
1045,
1007,
1063,
5164,
2171,
1027,
5164,
1012,
3643,
11253,
1006,
1045,
1007,
1025,
2065,
1006,
2131,
8490,
18259,
16093,
7512,
18442,
2015,
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/NioServer.java | NioServer.handle | private void handle(SelectionKey key) {
// 有客户端接入此服务端
if (key.isAcceptable()) {
// 获取通道 转化为要处理的类型
final ServerSocketChannel server = (ServerSocketChannel) key.channel();
SocketChannel socketChannel;
try {
// 获取连接到此服务器的客户端通道
socketChannel = server.accept();
} catch (IOException e) {
throw new IORuntimeException(e);
}
// SocketChannel通道的可读事件注册到Selector中
registerChannel(selector, socketChannel, Operation.READ);
}
// 读事件就绪
if (key.isReadable()) {
final SocketChannel socketChannel = (SocketChannel) key.channel();
read(socketChannel);
// SocketChannel通道的可写事件注册到Selector中
registerChannel(selector, socketChannel, Operation.WRITE);
}
// 写事件就绪
if (key.isWritable()) {
final SocketChannel socketChannel = (SocketChannel) key.channel();
write(socketChannel);
// SocketChannel通道的可读事件注册到Selector中
registerChannel(selector, socketChannel, Operation.READ);
}
} | java | private void handle(SelectionKey key) {
// 有客户端接入此服务端
if (key.isAcceptable()) {
// 获取通道 转化为要处理的类型
final ServerSocketChannel server = (ServerSocketChannel) key.channel();
SocketChannel socketChannel;
try {
// 获取连接到此服务器的客户端通道
socketChannel = server.accept();
} catch (IOException e) {
throw new IORuntimeException(e);
}
// SocketChannel通道的可读事件注册到Selector中
registerChannel(selector, socketChannel, Operation.READ);
}
// 读事件就绪
if (key.isReadable()) {
final SocketChannel socketChannel = (SocketChannel) key.channel();
read(socketChannel);
// SocketChannel通道的可写事件注册到Selector中
registerChannel(selector, socketChannel, Operation.WRITE);
}
// 写事件就绪
if (key.isWritable()) {
final SocketChannel socketChannel = (SocketChannel) key.channel();
write(socketChannel);
// SocketChannel通道的可读事件注册到Selector中
registerChannel(selector, socketChannel, Operation.READ);
}
} | [
"private",
"void",
"handle",
"(",
"SelectionKey",
"key",
")",
"{",
"// 有客户端接入此服务端\r",
"if",
"(",
"key",
".",
"isAcceptable",
"(",
")",
")",
"{",
"// 获取通道 转化为要处理的类型\r",
"final",
"ServerSocketChannel",
"server",
"=",
"(",
"ServerSocketChannel",
")",
"key",
".",
... | 处理SelectionKey
@param key SelectionKey | [
"处理SelectionKey"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-socket/src/main/java/cn/hutool/socket/nio/NioServer.java#L97-L130 | train | Handles a select key. | [
30522,
2797,
11675,
5047,
1006,
4989,
14839,
3145,
1007,
1063,
1013,
1013,
1873,
100,
100,
100,
100,
100,
100,
100,
100,
100,
2065,
1006,
3145,
1012,
18061,
9468,
23606,
3085,
1006,
1007,
1007,
1063,
1013,
1013,
100,
100,
100,
1957,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.