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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java | SqlFunctionUtils.lpad | public static String lpad(String base, int len, String pad) {
if (len < 0 || "".equals(pad)) {
return null;
} else if (len == 0) {
return "";
}
char[] data = new char[len];
char[] baseChars = base.toCharArray();
char[] padChars = pad.toCharArray();
// the length of the padding needed
int pos = Math.max(len - base.length(), 0);
// copy the padding
for (int i = 0; i < pos; i += pad.length()) {
for (int j = 0; j < pad.length() && j < pos - i; j++) {
data[i + j] = padChars[j];
}
}
// copy the base
int i = 0;
while (pos + i < len && i < base.length()) {
data[pos + i] = baseChars[i];
i += 1;
}
return new String(data);
} | java | public static String lpad(String base, int len, String pad) {
if (len < 0 || "".equals(pad)) {
return null;
} else if (len == 0) {
return "";
}
char[] data = new char[len];
char[] baseChars = base.toCharArray();
char[] padChars = pad.toCharArray();
// the length of the padding needed
int pos = Math.max(len - base.length(), 0);
// copy the padding
for (int i = 0; i < pos; i += pad.length()) {
for (int j = 0; j < pad.length() && j < pos - i; j++) {
data[i + j] = padChars[j];
}
}
// copy the base
int i = 0;
while (pos + i < len && i < base.length()) {
data[pos + i] = baseChars[i];
i += 1;
}
return new String(data);
} | [
"public",
"static",
"String",
"lpad",
"(",
"String",
"base",
",",
"int",
"len",
",",
"String",
"pad",
")",
"{",
"if",
"(",
"len",
"<",
"0",
"||",
"\"\"",
".",
"equals",
"(",
"pad",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"... | Returns the string str left-padded with the string pad to a length of len characters.
If str is longer than len, the return value is shortened to len characters. | [
"Returns",
"the",
"string",
"str",
"left",
"-",
"padded",
"with",
"the",
"string",
"pad",
"to",
"a",
"length",
"of",
"len",
"characters",
".",
"If",
"str",
"is",
"longer",
"than",
"len",
"the",
"return",
"value",
"is",
"shortened",
"to",
"len",
"characte... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java#L221-L250 | train | Returns a string of length len with the specified padding string. | [
30522,
2270,
10763,
5164,
6948,
4215,
1006,
5164,
2918,
1010,
20014,
18798,
1010,
5164,
11687,
1007,
1063,
2065,
1006,
18798,
1026,
1014,
1064,
1064,
1000,
1000,
1012,
19635,
1006,
11687,
1007,
1007,
1063,
2709,
19701,
1025,
1065,
2842,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/web/reactive/error/DefaultErrorWebExceptionHandler.java | DefaultErrorWebExceptionHandler.acceptsTextHtml | protected RequestPredicate acceptsTextHtml() {
return (serverRequest) -> {
try {
List<MediaType> acceptedMediaTypes = serverRequest.headers().accept();
acceptedMediaTypes.remove(MediaType.ALL);
MediaType.sortBySpecificityAndQuality(acceptedMediaTypes);
return acceptedMediaTypes.stream()
.anyMatch(MediaType.TEXT_HTML::isCompatibleWith);
} | java | protected RequestPredicate acceptsTextHtml() {
return (serverRequest) -> {
try {
List<MediaType> acceptedMediaTypes = serverRequest.headers().accept();
acceptedMediaTypes.remove(MediaType.ALL);
MediaType.sortBySpecificityAndQuality(acceptedMediaTypes);
return acceptedMediaTypes.stream()
.anyMatch(MediaType.TEXT_HTML::isCompatibleWith);
} | [
"protected",
"RequestPredicate",
"acceptsTextHtml",
"(",
")",
"{",
"return",
"(",
"serverRequest",
")",
"-",
">",
"{",
"try",
"{",
"List",
"<",
"MediaType",
">",
"acceptedMediaTypes",
"=",
"serverRequest",
".",
"headers",
"(",
")",
".",
"accept",
"(",
")",
... | Predicate that checks whether the current request explicitly support
{@code "text/html"} media type.
<p>
The "match-all" media type is not considered here.
@return the request predicate | [
"Predicate",
"that",
"checks",
"whether",
"the",
"current",
"request",
"explicitly",
"support",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java#L177-L185 | train | Checks if the request accepts text html. | [
30522,
5123,
5227,
28139,
16467,
13385,
18209,
11039,
19968,
1006,
1007,
1063,
2709,
1006,
8241,
2890,
15500,
1007,
1011,
1028,
1063,
3046,
1063,
2862,
1026,
2865,
13874,
1028,
3970,
16969,
13874,
2015,
1027,
8241,
2890,
15500,
1012,
20346,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java | AbstractRunMojo.resolveJvmArguments | protected RunArguments resolveJvmArguments() {
StringBuilder stringBuilder = new StringBuilder();
if (this.systemPropertyVariables != null) {
stringBuilder.append(this.systemPropertyVariables.entrySet().stream()
.map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue()))
.collect(Collectors.joining(" ")));
}
if (this.jvmArguments != null) {
stringBuilder.append(" ").append(this.jvmArguments);
}
return new RunArguments(stringBuilder.toString());
} | java | protected RunArguments resolveJvmArguments() {
StringBuilder stringBuilder = new StringBuilder();
if (this.systemPropertyVariables != null) {
stringBuilder.append(this.systemPropertyVariables.entrySet().stream()
.map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue()))
.collect(Collectors.joining(" ")));
}
if (this.jvmArguments != null) {
stringBuilder.append(" ").append(this.jvmArguments);
}
return new RunArguments(stringBuilder.toString());
} | [
"protected",
"RunArguments",
"resolveJvmArguments",
"(",
")",
"{",
"StringBuilder",
"stringBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"this",
".",
"systemPropertyVariables",
"!=",
"null",
")",
"{",
"stringBuilder",
".",
"append",
"(",
"this... | Resolve the JVM arguments to use.
@return a {@link RunArguments} defining the JVM arguments | [
"Resolve",
"the",
"JVM",
"arguments",
"to",
"use",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java#L354-L365 | train | Resolve the JVM arguments. | [
30522,
5123,
2448,
2906,
22850,
11187,
10663,
3501,
2615,
7849,
22850,
11187,
1006,
1007,
1063,
5164,
8569,
23891,
2099,
5164,
8569,
23891,
2099,
1027,
2047,
5164,
8569,
23891,
2099,
1006,
1007,
1025,
2065,
1006,
2023,
1012,
2291,
21572,
48... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/livereload/LiveReloadServer.java | LiveReloadServer.createConnection | protected Connection createConnection(Socket socket, InputStream inputStream,
OutputStream outputStream) throws IOException {
return new Connection(socket, inputStream, outputStream);
} | java | protected Connection createConnection(Socket socket, InputStream inputStream,
OutputStream outputStream) throws IOException {
return new Connection(socket, inputStream, outputStream);
} | [
"protected",
"Connection",
"createConnection",
"(",
"Socket",
"socket",
",",
"InputStream",
"inputStream",
",",
"OutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"return",
"new",
"Connection",
"(",
"socket",
",",
"inputStream",
",",
"outputStream",
... | Factory method used to create the {@link Connection}.
@param socket the source socket
@param inputStream the socket input stream
@param outputStream the socket output stream
@return a connection
@throws IOException in case of I/O errors | [
"Factory",
"method",
"used",
"to",
"create",
"the",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java#L236-L239 | train | Creates a new connection to the server. | [
30522,
5123,
4434,
3443,
8663,
2638,
7542,
1006,
22278,
22278,
1010,
20407,
25379,
20407,
25379,
1010,
27852,
25379,
27852,
25379,
1007,
11618,
22834,
10288,
24422,
1063,
2709,
2047,
4434,
1006,
22278,
1010,
20407,
25379,
1010,
27852,
25379,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java | EmbeddedCLIServiceClient.getFunctions | @Override
public OperationHandle getFunctions(SessionHandle sessionHandle,
String catalogName, String schemaName, String functionName)
throws HiveSQLException {
return cliService.getFunctions(sessionHandle, catalogName, schemaName, functionName);
} | java | @Override
public OperationHandle getFunctions(SessionHandle sessionHandle,
String catalogName, String schemaName, String functionName)
throws HiveSQLException {
return cliService.getFunctions(sessionHandle, catalogName, schemaName, functionName);
} | [
"@",
"Override",
"public",
"OperationHandle",
"getFunctions",
"(",
"SessionHandle",
"sessionHandle",
",",
"String",
"catalogName",
",",
"String",
"schemaName",
",",
"String",
"functionName",
")",
"throws",
"HiveSQLException",
"{",
"return",
"cliService",
".",
"getFunc... | /* (non-Javadoc)
@see org.apache.hive.service.cli.CLIServiceClient#getFunctions(org.apache.hive.service.cli.SessionHandle, java.lang.String) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java#L145-L150 | train | Get the function handle for a sequence of Hive functions. | [
30522,
1030,
2058,
15637,
2270,
3169,
11774,
2571,
2131,
11263,
27989,
2015,
1006,
5219,
11774,
2571,
5219,
11774,
2571,
1010,
5164,
12105,
18442,
1010,
5164,
8040,
28433,
18442,
1010,
5164,
3853,
18442,
1007,
11618,
26736,
2015,
4160,
2571,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AllWindowedStream.java | AllWindowedStream.min | public SingleOutputStreamOperator<T> min(int positionToMin) {
return aggregate(new ComparableAggregator<>(positionToMin, input.getType(), AggregationFunction.AggregationType.MIN, input.getExecutionConfig()));
} | java | public SingleOutputStreamOperator<T> min(int positionToMin) {
return aggregate(new ComparableAggregator<>(positionToMin, input.getType(), AggregationFunction.AggregationType.MIN, input.getExecutionConfig()));
} | [
"public",
"SingleOutputStreamOperator",
"<",
"T",
">",
"min",
"(",
"int",
"positionToMin",
")",
"{",
"return",
"aggregate",
"(",
"new",
"ComparableAggregator",
"<>",
"(",
"positionToMin",
",",
"input",
".",
"getType",
"(",
")",
",",
"AggregationFunction",
".",
... | Applies an aggregation that that gives the minimum value of every window
of the data stream at the given position.
@param positionToMin The position to minimize
@return The transformed DataStream. | [
"Applies",
"an",
"aggregation",
"that",
"that",
"gives",
"the",
"minimum",
"value",
"of",
"every",
"window",
"of",
"the",
"data",
"stream",
"at",
"the",
"given",
"position",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/AllWindowedStream.java#L1404-L1406 | train | Applies an aggregation that reduces the minimum value of the data stream at the given position. | [
30522,
2270,
2309,
5833,
18780,
21422,
25918,
8844,
1026,
1056,
1028,
8117,
1006,
20014,
2597,
20389,
2378,
1007,
1063,
2709,
9572,
1006,
2047,
12435,
8490,
17603,
20697,
2953,
1026,
1028,
1006,
2597,
20389,
2378,
1010,
7953,
1012,
2131,
13... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/summary/TextRankKeyword.java | TextRankKeyword.getTermAndRank | public Map<String, Float> getTermAndRank(String content, int size)
{
Map<String, Float> map = getTermAndRank(content);
Map<String, Float> result = top(size, map);
return result;
} | java | public Map<String, Float> getTermAndRank(String content, int size)
{
Map<String, Float> map = getTermAndRank(content);
Map<String, Float> result = top(size, map);
return result;
} | [
"public",
"Map",
"<",
"String",
",",
"Float",
">",
"getTermAndRank",
"(",
"String",
"content",
",",
"int",
"size",
")",
"{",
"Map",
"<",
"String",
",",
"Float",
">",
"map",
"=",
"getTermAndRank",
"(",
"content",
")",
";",
"Map",
"<",
"String",
",",
"... | 返回分数最高的前size个分词结果和对应的rank
@param content
@param size
@return | [
"返回分数最高的前size个分词结果和对应的rank"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/summary/TextRankKeyword.java#L82-L88 | train | Get getTermAndRank map. | [
30522,
2270,
4949,
1026,
5164,
1010,
14257,
1028,
2131,
3334,
2386,
24914,
2243,
1006,
5164,
4180,
1010,
20014,
2946,
1007,
1063,
4949,
1026,
5164,
1010,
14257,
1028,
4949,
1027,
2131,
3334,
2386,
24914,
2243,
30524,
1007,
1025,
2709,
2765,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/multipart/HttpPostRequestEncoder.java | HttpPostRequestEncoder.addBodyFileUpload | public void addBodyFileUpload(String name, File file, String contentType, boolean isText)
throws ErrorDataEncoderException {
addBodyFileUpload(name, file.getName(), file, contentType, isText);
} | java | public void addBodyFileUpload(String name, File file, String contentType, boolean isText)
throws ErrorDataEncoderException {
addBodyFileUpload(name, file.getName(), file, contentType, isText);
} | [
"public",
"void",
"addBodyFileUpload",
"(",
"String",
"name",
",",
"File",
"file",
",",
"String",
"contentType",
",",
"boolean",
"isText",
")",
"throws",
"ErrorDataEncoderException",
"{",
"addBodyFileUpload",
"(",
"name",
",",
"file",
".",
"getName",
"(",
")",
... | Add a file as a FileUpload
@param name
the name of the parameter
@param file
the file to be uploaded (if not Multipart mode, only the filename will be included)
@param contentType
the associated contentType for the File
@param isText
True if this file should be transmitted in Text format (else binary)
@throws NullPointerException
for name and file
@throws ErrorDataEncoderException
if the encoding is in error or if the finalize were already done | [
"Add",
"a",
"file",
"as",
"a",
"FileUpload"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java#L360-L363 | train | addBodyFileUpload This method is used to add a file to the application body. | [
30522,
2270,
11675,
5587,
23684,
8873,
2571,
6279,
11066,
1006,
5164,
2171,
1010,
5371,
5371,
1010,
5164,
4180,
13874,
1010,
22017,
20898,
21541,
10288,
2102,
1007,
11618,
7561,
2850,
2696,
2368,
16044,
2890,
2595,
24422,
1063,
5587,
23684,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.transformSelect | private <T> Collection<Integer> transformSelect(SelectTransformation<T> select) {
StreamTransformation<T> input = select.getInput();
Collection<Integer> resultIds = transform(input);
// the recursive transform might have already transformed this
if (alreadyTransformed.containsKey(select)) {
return alreadyTransformed.get(select);
}
List<Integer> virtualResultIds = new ArrayList<>();
for (int inputId : resultIds) {
int virtualId = StreamTransformation.getNewNodeId();
streamGraph.addVirtualSelectNode(inputId, virtualId, select.getSelectedNames());
virtualResultIds.add(virtualId);
}
return virtualResultIds;
} | java | private <T> Collection<Integer> transformSelect(SelectTransformation<T> select) {
StreamTransformation<T> input = select.getInput();
Collection<Integer> resultIds = transform(input);
// the recursive transform might have already transformed this
if (alreadyTransformed.containsKey(select)) {
return alreadyTransformed.get(select);
}
List<Integer> virtualResultIds = new ArrayList<>();
for (int inputId : resultIds) {
int virtualId = StreamTransformation.getNewNodeId();
streamGraph.addVirtualSelectNode(inputId, virtualId, select.getSelectedNames());
virtualResultIds.add(virtualId);
}
return virtualResultIds;
} | [
"private",
"<",
"T",
">",
"Collection",
"<",
"Integer",
">",
"transformSelect",
"(",
"SelectTransformation",
"<",
"T",
">",
"select",
")",
"{",
"StreamTransformation",
"<",
"T",
">",
"input",
"=",
"select",
".",
"getInput",
"(",
")",
";",
"Collection",
"<"... | Transforms a {@code SelectTransformation}.
<p>For this we create a virtual node in the {@code StreamGraph} holds the selected names.
@see org.apache.flink.streaming.api.graph.StreamGraphGenerator | [
"Transforms",
"a",
"{",
"@code",
"SelectTransformation",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraphGenerator.java#L289-L306 | train | This method is called by the recursive transform method. | [
30522,
2797,
1026,
1056,
1028,
3074,
1026,
16109,
1028,
21743,
12260,
6593,
1006,
7276,
6494,
3619,
14192,
3370,
1026,
1056,
1028,
7276,
1007,
1063,
5460,
6494,
3619,
14192,
3370,
1026,
1056,
1028,
7953,
1027,
7276,
1012,
2131,
2378,
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... |
alibaba/canal | parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java | MysqlConnection.loadBinlogFormat | private void loadBinlogFormat() {
ResultSetPacket rs = null;
try {
rs = query("show variables like 'binlog_format'");
} catch (IOException e) {
throw new CanalParseException(e);
}
List<String> columnValues = rs.getFieldValues();
if (columnValues == null || columnValues.size() != 2) {
logger.warn("unexpected binlog format query result, this may cause unexpected result, so throw exception to request network to io shutdown.");
throw new IllegalStateException("unexpected binlog format query result:" + rs.getFieldValues());
}
binlogFormat = BinlogFormat.valuesOf(columnValues.get(1));
if (binlogFormat == null) {
throw new IllegalStateException("unexpected binlog format query result:" + rs.getFieldValues());
}
} | java | private void loadBinlogFormat() {
ResultSetPacket rs = null;
try {
rs = query("show variables like 'binlog_format'");
} catch (IOException e) {
throw new CanalParseException(e);
}
List<String> columnValues = rs.getFieldValues();
if (columnValues == null || columnValues.size() != 2) {
logger.warn("unexpected binlog format query result, this may cause unexpected result, so throw exception to request network to io shutdown.");
throw new IllegalStateException("unexpected binlog format query result:" + rs.getFieldValues());
}
binlogFormat = BinlogFormat.valuesOf(columnValues.get(1));
if (binlogFormat == null) {
throw new IllegalStateException("unexpected binlog format query result:" + rs.getFieldValues());
}
} | [
"private",
"void",
"loadBinlogFormat",
"(",
")",
"{",
"ResultSetPacket",
"rs",
"=",
"null",
";",
"try",
"{",
"rs",
"=",
"query",
"(",
"\"show variables like 'binlog_format'\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"Canal... | 获取一下binlog format格式 | [
"获取一下binlog",
"format格式"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java#L466-L484 | train | Load binlog format from database. | [
30522,
2797,
11675,
7170,
8428,
21197,
14192,
4017,
1006,
1007,
1063,
3463,
3388,
23947,
3388,
12667,
1027,
19701,
1025,
3046,
1063,
12667,
1027,
23032,
1006,
1000,
2265,
10857,
2066,
1005,
8026,
21197,
1035,
4289,
1005,
1000,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/KeyedStream.java | KeyedStream.validateKeyTypeIsHashable | private boolean validateKeyTypeIsHashable(TypeInformation<?> type) {
try {
return (type instanceof PojoTypeInfo)
? !type.getTypeClass().getMethod("hashCode").getDeclaringClass().equals(Object.class)
: !(type instanceof PrimitiveArrayTypeInfo || type instanceof BasicArrayTypeInfo || type instanceof ObjectArrayTypeInfo);
} catch (NoSuchMethodException ignored) {
// this should never happen as we are just searching for the hashCode() method.
}
return false;
} | java | private boolean validateKeyTypeIsHashable(TypeInformation<?> type) {
try {
return (type instanceof PojoTypeInfo)
? !type.getTypeClass().getMethod("hashCode").getDeclaringClass().equals(Object.class)
: !(type instanceof PrimitiveArrayTypeInfo || type instanceof BasicArrayTypeInfo || type instanceof ObjectArrayTypeInfo);
} catch (NoSuchMethodException ignored) {
// this should never happen as we are just searching for the hashCode() method.
}
return false;
} | [
"private",
"boolean",
"validateKeyTypeIsHashable",
"(",
"TypeInformation",
"<",
"?",
">",
"type",
")",
"{",
"try",
"{",
"return",
"(",
"type",
"instanceof",
"PojoTypeInfo",
")",
"?",
"!",
"type",
".",
"getTypeClass",
"(",
")",
".",
"getMethod",
"(",
"\"hashC... | Validates that a given type of element (as encoded by the provided {@link TypeInformation}) can be
used as a key in the {@code DataStream.keyBy()} operation.
@param type The {@link TypeInformation} of the type to check.
@return {@code false} if:
<ol>
<li>it is a POJO type but does not override the {@link #hashCode()} method and relies on
the {@link Object#hashCode()} implementation.</li>
<li>it is an array of any type (see {@link PrimitiveArrayTypeInfo}, {@link BasicArrayTypeInfo},
{@link ObjectArrayTypeInfo}).</li>
</ol>,
{@code true} otherwise. | [
"Validates",
"that",
"a",
"given",
"type",
"of",
"element",
"(",
"as",
"encoded",
"by",
"the",
"provided",
"{",
"@link",
"TypeInformation",
"}",
")",
"can",
"be",
"used",
"as",
"a",
"key",
"in",
"the",
"{",
"@code",
"DataStream",
".",
"keyBy",
"()",
"}... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/KeyedStream.java#L216-L225 | train | Validate that the key type is hashable. | [
30522,
2797,
22017,
20898,
9398,
3686,
14839,
13874,
24032,
7377,
3468,
1006,
2828,
2378,
14192,
3370,
1026,
1029,
1028,
2828,
30524,
2828,
1012,
2131,
13874,
26266,
1006,
1007,
1012,
2131,
11368,
6806,
2094,
1006,
1000,
23325,
16044,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java | EnvironmentInformation.getVersion | public static String getVersion() {
String version = EnvironmentInformation.class.getPackage().getImplementationVersion();
return version != null ? version : UNKNOWN;
} | java | public static String getVersion() {
String version = EnvironmentInformation.class.getPackage().getImplementationVersion();
return version != null ? version : UNKNOWN;
} | [
"public",
"static",
"String",
"getVersion",
"(",
")",
"{",
"String",
"version",
"=",
"EnvironmentInformation",
".",
"class",
".",
"getPackage",
"(",
")",
".",
"getImplementationVersion",
"(",
")",
";",
"return",
"version",
"!=",
"null",
"?",
"version",
":",
... | Returns the version of the code as String. If version == null, then the JobManager does not run from a
Maven build. An example is a source code checkout, compile, and run from inside an IDE.
@return The version string. | [
"Returns",
"the",
"version",
"of",
"the",
"code",
"as",
"String",
".",
"If",
"version",
"==",
"null",
"then",
"the",
"JobManager",
"does",
"not",
"run",
"from",
"a",
"Maven",
"build",
".",
"An",
"example",
"is",
"a",
"source",
"code",
"checkout",
"compil... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java#L49-L52 | train | Get the version of the application. | [
30522,
2270,
10763,
5164,
2131,
27774,
1006,
1007,
1063,
5164,
2544,
1027,
4044,
2378,
14192,
3370,
1012,
2465,
1012,
2131,
23947,
4270,
1006,
1007,
1012,
2131,
5714,
10814,
3672,
3370,
27774,
1006,
1007,
1025,
2709,
2544,
999,
1027,
19701,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/state/KeyGroupPartitioner.java | KeyGroupPartitioner.reportKeyGroupOfElementAtIndex | protected void reportKeyGroupOfElementAtIndex(int index, int keyGroup) {
final int keyGroupIndex = keyGroup - firstKeyGroup;
elementKeyGroups[index] = keyGroupIndex;
++counterHistogram[keyGroupIndex];
} | java | protected void reportKeyGroupOfElementAtIndex(int index, int keyGroup) {
final int keyGroupIndex = keyGroup - firstKeyGroup;
elementKeyGroups[index] = keyGroupIndex;
++counterHistogram[keyGroupIndex];
} | [
"protected",
"void",
"reportKeyGroupOfElementAtIndex",
"(",
"int",
"index",
",",
"int",
"keyGroup",
")",
"{",
"final",
"int",
"keyGroupIndex",
"=",
"keyGroup",
"-",
"firstKeyGroup",
";",
"elementKeyGroups",
"[",
"index",
"]",
"=",
"keyGroupIndex",
";",
"++",
"co... | This method reports in the bookkeeping data that the element at the given index belongs to the given key-group. | [
"This",
"method",
"reports",
"in",
"the",
"bookkeeping",
"data",
"that",
"the",
"element",
"at",
"the",
"given",
"index",
"belongs",
"to",
"the",
"given",
"key",
"-",
"group",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/state/KeyGroupPartitioner.java#L161-L165 | train | Report the key group of the element at the given index. | [
30522,
5123,
11675,
3189,
14839,
17058,
11253,
12260,
3672,
20363,
3207,
2595,
1006,
20014,
5950,
1010,
20014,
3145,
17058,
1007,
1063,
2345,
20014,
3145,
17058,
22254,
10288,
1027,
3145,
17058,
1011,
2034,
14839,
17058,
1025,
5783,
14839,
17... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/AbstractDb.java | AbstractDb.executeBatch | public int[] executeBatch(String... sqls) throws SQLException {
Connection conn = null;
try {
conn = this.getConnection();
return SqlExecutor.executeBatch(conn, sqls);
} catch (SQLException e) {
throw e;
} finally {
this.closeConnection(conn);
}
} | java | public int[] executeBatch(String... sqls) throws SQLException {
Connection conn = null;
try {
conn = this.getConnection();
return SqlExecutor.executeBatch(conn, sqls);
} catch (SQLException e) {
throw e;
} finally {
this.closeConnection(conn);
}
} | [
"public",
"int",
"[",
"]",
"executeBatch",
"(",
"String",
"...",
"sqls",
")",
"throws",
"SQLException",
"{",
"Connection",
"conn",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"this",
".",
"getConnection",
"(",
")",
";",
"return",
"SqlExecutor",
".",
"exec... | 批量执行非查询语句
@param sqls SQL列表
@return 每个SQL执行影响的行数
@throws SQLException SQL执行异常
@since 4.5.6 | [
"批量执行非查询语句"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java#L226-L236 | train | Executes a batch of SQL statements. | [
30522,
2270,
20014,
1031,
1033,
15389,
14479,
2818,
1006,
5164,
1012,
1012,
1012,
29296,
2015,
1007,
11618,
29296,
10288,
24422,
1063,
4434,
9530,
2078,
1027,
19701,
1025,
3046,
1063,
9530,
2078,
1027,
2023,
1012,
2131,
8663,
2638,
7542,
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/zookeeper/ZooKeeperStateHandleStore.java | ZooKeeperStateHandleStore.deleteChildren | public void deleteChildren() throws Exception {
final String path = "/" + client.getNamespace();
LOG.info("Removing {} from ZooKeeper", path);
ZKPaths.deleteChildren(client.getZookeeperClient().getZooKeeper(), path, true);
} | java | public void deleteChildren() throws Exception {
final String path = "/" + client.getNamespace();
LOG.info("Removing {} from ZooKeeper", path);
ZKPaths.deleteChildren(client.getZookeeperClient().getZooKeeper(), path, true);
} | [
"public",
"void",
"deleteChildren",
"(",
")",
"throws",
"Exception",
"{",
"final",
"String",
"path",
"=",
"\"/\"",
"+",
"client",
".",
"getNamespace",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Removing {} from ZooKeeper\"",
",",
"path",
")",
";",
"ZKPaths",... | Recursively deletes all children.
@throws Exception ZK errors | [
"Recursively",
"deletes",
"all",
"children",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/ZooKeeperStateHandleStore.java#L433-L437 | train | Delete all the children of the namespace. | [
30522,
2270,
11675,
3972,
12870,
19339,
7389,
1006,
1007,
11618,
6453,
1063,
2345,
5164,
4130,
1027,
1000,
1013,
1000,
1009,
7396,
1012,
2131,
18442,
23058,
1006,
1007,
1025,
8833,
1012,
18558,
1006,
1000,
9268,
1063,
1065,
2013,
9201,
1310... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/annotation/AnnotationUtil.java | AnnotationUtil.toCombination | public static CombinationAnnotationElement toCombination(AnnotatedElement annotationEle) {
if(annotationEle instanceof CombinationAnnotationElement) {
return (CombinationAnnotationElement)annotationEle;
}
return new CombinationAnnotationElement(annotationEle);
} | java | public static CombinationAnnotationElement toCombination(AnnotatedElement annotationEle) {
if(annotationEle instanceof CombinationAnnotationElement) {
return (CombinationAnnotationElement)annotationEle;
}
return new CombinationAnnotationElement(annotationEle);
} | [
"public",
"static",
"CombinationAnnotationElement",
"toCombination",
"(",
"AnnotatedElement",
"annotationEle",
")",
"{",
"if",
"(",
"annotationEle",
"instanceof",
"CombinationAnnotationElement",
")",
"{",
"return",
"(",
"CombinationAnnotationElement",
")",
"annotationEle",
... | 将指定的被注解的元素转换为组合注解元素
@param annotationEle 注解元素
@return 组合注解元素 | [
"将指定的被注解的元素转换为组合注解元素"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/annotation/AnnotationUtil.java#L36-L41 | train | Converts an annotated element to a combination annotation element. | [
30522,
2270,
10763,
5257,
11639,
17287,
3508,
12260,
3672,
2000,
18274,
12758,
1006,
5754,
17287,
3064,
12260,
3672,
5754,
17287,
3508,
12260,
1007,
1063,
2065,
30524,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/MasterSlaveSchema.java | MasterSlaveSchema.renew | @Subscribe
public synchronized void renew(final MasterSlaveRuleChangedEvent masterSlaveRuleChangedEvent) {
if (getName().equals(masterSlaveRuleChangedEvent.getShardingSchemaName())) {
masterSlaveRule = new OrchestrationMasterSlaveRule(masterSlaveRuleChangedEvent.getMasterSlaveRuleConfiguration());
}
} | java | @Subscribe
public synchronized void renew(final MasterSlaveRuleChangedEvent masterSlaveRuleChangedEvent) {
if (getName().equals(masterSlaveRuleChangedEvent.getShardingSchemaName())) {
masterSlaveRule = new OrchestrationMasterSlaveRule(masterSlaveRuleChangedEvent.getMasterSlaveRuleConfiguration());
}
} | [
"@",
"Subscribe",
"public",
"synchronized",
"void",
"renew",
"(",
"final",
"MasterSlaveRuleChangedEvent",
"masterSlaveRuleChangedEvent",
")",
"{",
"if",
"(",
"getName",
"(",
")",
".",
"equals",
"(",
"masterSlaveRuleChangedEvent",
".",
"getShardingSchemaName",
"(",
")"... | Renew master-slave rule.
@param masterSlaveRuleChangedEvent master-slave rule changed event. | [
"Renew",
"master",
"-",
"slave",
"rule",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/MasterSlaveSchema.java#L74-L79 | train | Renew master slave rule. | [
30522,
1030,
4942,
29234,
2270,
25549,
11675,
20687,
1006,
2345,
5972,
14973,
2121,
9307,
22305,
14728,
15338,
5972,
14973,
2121,
9307,
22305,
14728,
15338,
1007,
1063,
2065,
1006,
2131,
18442,
1006,
1007,
1012,
19635,
1006,
5972,
14973,
2121... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/history/FsJobArchivist.java | FsJobArchivist.getArchivedJsons | public static Collection<ArchivedJson> getArchivedJsons(Path file) throws IOException {
try (FSDataInputStream input = file.getFileSystem().open(file);
ByteArrayOutputStream output = new ByteArrayOutputStream()) {
IOUtils.copyBytes(input, output);
JsonNode archive = mapper.readTree(output.toByteArray());
Collection<ArchivedJson> archives = new ArrayList<>();
for (JsonNode archivePart : archive.get(ARCHIVE)) {
String path = archivePart.get(PATH).asText();
String json = archivePart.get(JSON).asText();
archives.add(new ArchivedJson(path, json));
}
return archives;
}
} | java | public static Collection<ArchivedJson> getArchivedJsons(Path file) throws IOException {
try (FSDataInputStream input = file.getFileSystem().open(file);
ByteArrayOutputStream output = new ByteArrayOutputStream()) {
IOUtils.copyBytes(input, output);
JsonNode archive = mapper.readTree(output.toByteArray());
Collection<ArchivedJson> archives = new ArrayList<>();
for (JsonNode archivePart : archive.get(ARCHIVE)) {
String path = archivePart.get(PATH).asText();
String json = archivePart.get(JSON).asText();
archives.add(new ArchivedJson(path, json));
}
return archives;
}
} | [
"public",
"static",
"Collection",
"<",
"ArchivedJson",
">",
"getArchivedJsons",
"(",
"Path",
"file",
")",
"throws",
"IOException",
"{",
"try",
"(",
"FSDataInputStream",
"input",
"=",
"file",
".",
"getFileSystem",
"(",
")",
".",
"open",
"(",
"file",
")",
";",... | Reads the given archive file and returns a {@link Collection} of contained {@link ArchivedJson}.
@param file archive to extract
@return collection of archived jsons
@throws IOException if the file can't be opened, read or doesn't contain valid json | [
"Reads",
"the",
"given",
"archive",
"file",
"and",
"returns",
"a",
"{",
"@link",
"Collection",
"}",
"of",
"contained",
"{",
"@link",
"ArchivedJson",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/history/FsJobArchivist.java#L107-L122 | train | Get all archived jsons from a file. | [
30522,
2270,
10763,
3074,
1026,
9749,
22578,
2239,
1028,
2131,
2906,
5428,
7178,
22578,
5644,
1006,
4130,
5371,
1007,
11618,
22834,
10288,
24422,
1063,
3046,
1006,
1042,
16150,
6790,
2378,
18780,
21422,
7953,
1027,
5371,
1012,
2131,
8873,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Execution.java | Execution.releaseAssignedResource | private void releaseAssignedResource(@Nullable Throwable cause) {
assertRunningInJobMasterMainThread();
final LogicalSlot slot = assignedResource;
if (slot != null) {
ComponentMainThreadExecutor jobMasterMainThreadExecutor =
getVertex().getExecutionGraph().getJobMasterMainThreadExecutor();
slot.releaseSlot(cause)
.whenComplete((Object ignored, Throwable throwable) -> {
jobMasterMainThreadExecutor.assertRunningInMainThread();
if (throwable != null) {
releaseFuture.completeExceptionally(throwable);
} else {
releaseFuture.complete(null);
}
});
} else {
// no assigned resource --> we can directly complete the release future
releaseFuture.complete(null);
}
} | java | private void releaseAssignedResource(@Nullable Throwable cause) {
assertRunningInJobMasterMainThread();
final LogicalSlot slot = assignedResource;
if (slot != null) {
ComponentMainThreadExecutor jobMasterMainThreadExecutor =
getVertex().getExecutionGraph().getJobMasterMainThreadExecutor();
slot.releaseSlot(cause)
.whenComplete((Object ignored, Throwable throwable) -> {
jobMasterMainThreadExecutor.assertRunningInMainThread();
if (throwable != null) {
releaseFuture.completeExceptionally(throwable);
} else {
releaseFuture.complete(null);
}
});
} else {
// no assigned resource --> we can directly complete the release future
releaseFuture.complete(null);
}
} | [
"private",
"void",
"releaseAssignedResource",
"(",
"@",
"Nullable",
"Throwable",
"cause",
")",
"{",
"assertRunningInJobMasterMainThread",
"(",
")",
";",
"final",
"LogicalSlot",
"slot",
"=",
"assignedResource",
";",
"if",
"(",
"slot",
"!=",
"null",
")",
"{",
"Com... | Releases the assigned resource and completes the release future
once the assigned resource has been successfully released.
@param cause for the resource release, null if none | [
"Releases",
"the",
"assigned",
"resource",
"and",
"completes",
"the",
"release",
"future",
"once",
"the",
"assigned",
"resource",
"has",
"been",
"successfully",
"released",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java#L1259-L1282 | train | Releases the assigned resource. | [
30522,
2797,
11675,
2713,
12054,
23773,
2098,
6072,
8162,
3401,
1006,
1030,
19701,
3085,
5466,
3085,
3426,
1007,
1063,
20865,
15532,
5582,
2378,
5558,
25526,
24268,
24238,
2705,
16416,
2094,
1006,
1007,
1025,
2345,
11177,
14540,
4140,
10453,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java | ServerBootstrap.childAttr | public <T> ServerBootstrap childAttr(AttributeKey<T> childKey, T value) {
if (childKey == null) {
throw new NullPointerException("childKey");
}
if (value == null) {
childAttrs.remove(childKey);
} else {
childAttrs.put(childKey, value);
}
return this;
} | java | public <T> ServerBootstrap childAttr(AttributeKey<T> childKey, T value) {
if (childKey == null) {
throw new NullPointerException("childKey");
}
if (value == null) {
childAttrs.remove(childKey);
} else {
childAttrs.put(childKey, value);
}
return this;
} | [
"public",
"<",
"T",
">",
"ServerBootstrap",
"childAttr",
"(",
"AttributeKey",
"<",
"T",
">",
"childKey",
",",
"T",
"value",
")",
"{",
"if",
"(",
"childKey",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"childKey\"",
")",
";",
"}... | Set the specific {@link AttributeKey} with the given value on every child {@link Channel}. If the value is
{@code null} the {@link AttributeKey} is removed | [
"Set",
"the",
"specific",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java#L117-L127 | train | Add a child attribute. | [
30522,
2270,
1026,
1056,
1028,
8241,
27927,
20528,
2361,
2775,
19321,
2099,
1006,
17961,
14839,
1026,
1056,
1028,
2775,
14839,
1010,
1056,
3643,
1007,
1063,
2065,
1006,
2775,
14839,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
19701,
8400,
78... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-proxy/sharding-proxy-transport/sharding-proxy-transport-postgresql/src/main/java/org/apache/shardingsphere/shardingproxy/transport/postgresql/packet/command/PostgreSQLCommandPacketFactory.java | PostgreSQLCommandPacketFactory.newInstance | public static PostgreSQLCommandPacket newInstance(
final PostgreSQLCommandPacketType commandPacketType, final PostgreSQLPacketPayload payload, final int connectionId) throws SQLException {
switch (commandPacketType) {
case QUERY:
return new PostgreSQLComQueryPacket(payload);
case PARSE:
return new PostgreSQLComParsePacket(payload);
case BIND:
return new PostgreSQLComBindPacket(payload, connectionId);
case DESCRIBE:
return new PostgreSQLComDescribePacket(payload);
case EXECUTE:
return new PostgreSQLComExecutePacket(payload);
case SYNC:
return new PostgreSQLComSyncPacket(payload);
case TERMINATE:
return new PostgreSQLComTerminationPacket(payload);
default:
return new PostgreSQLUnsupportedCommandPacket(commandPacketType.getValue());
}
} | java | public static PostgreSQLCommandPacket newInstance(
final PostgreSQLCommandPacketType commandPacketType, final PostgreSQLPacketPayload payload, final int connectionId) throws SQLException {
switch (commandPacketType) {
case QUERY:
return new PostgreSQLComQueryPacket(payload);
case PARSE:
return new PostgreSQLComParsePacket(payload);
case BIND:
return new PostgreSQLComBindPacket(payload, connectionId);
case DESCRIBE:
return new PostgreSQLComDescribePacket(payload);
case EXECUTE:
return new PostgreSQLComExecutePacket(payload);
case SYNC:
return new PostgreSQLComSyncPacket(payload);
case TERMINATE:
return new PostgreSQLComTerminationPacket(payload);
default:
return new PostgreSQLUnsupportedCommandPacket(commandPacketType.getValue());
}
} | [
"public",
"static",
"PostgreSQLCommandPacket",
"newInstance",
"(",
"final",
"PostgreSQLCommandPacketType",
"commandPacketType",
",",
"final",
"PostgreSQLPacketPayload",
"payload",
",",
"final",
"int",
"connectionId",
")",
"throws",
"SQLException",
"{",
"switch",
"(",
"com... | Create new instance of command packet.
@param commandPacketType command packet type for PostgreSQL
@param payload packet payload for PostgreSQL
@param connectionId connection id
@return command packet for PostgreSQL
@throws SQLException SQL exception | [
"Create",
"new",
"instance",
"of",
"command",
"packet",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-proxy/sharding-proxy-transport/sharding-proxy-transport-postgresql/src/main/java/org/apache/shardingsphere/shardingproxy/transport/postgresql/packet/command/PostgreSQLCommandPacketFactory.java#L51-L71 | train | Create a new instance of a PostgreSQLCommandPacket. | [
30522,
2270,
10763,
2695,
17603,
2015,
4160,
22499,
14760,
4859,
23947,
3388,
2047,
7076,
26897,
1006,
2345,
2695,
17603,
2015,
4160,
22499,
14760,
4859,
23947,
6582,
18863,
3094,
23947,
6582,
18863,
1010,
2345,
2695,
17603,
2015,
4160,
14277... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.elementToBeClickable | public static ExpectedCondition<WebElement> elementToBeClickable(final By locator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
WebElement element = visibilityOfElementLocated(locator).apply(driver);
try {
if (element != null && element.isEnabled()) {
return element;
}
return null;
} catch (StaleElementReferenceException e) {
return null;
}
}
@Override
public String toString() {
return "element to be clickable: " + locator;
}
};
} | java | public static ExpectedCondition<WebElement> elementToBeClickable(final By locator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
WebElement element = visibilityOfElementLocated(locator).apply(driver);
try {
if (element != null && element.isEnabled()) {
return element;
}
return null;
} catch (StaleElementReferenceException e) {
return null;
}
}
@Override
public String toString() {
return "element to be clickable: " + locator;
}
};
} | [
"public",
"static",
"ExpectedCondition",
"<",
"WebElement",
">",
"elementToBeClickable",
"(",
"final",
"By",
"locator",
")",
"{",
"return",
"new",
"ExpectedCondition",
"<",
"WebElement",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WebElement",
"apply",
"(",
... | An expectation for checking an element is visible and enabled such that you can click it.
@param locator used to find the element
@return the WebElement once it is located and clickable (visible and enabled) | [
"An",
"expectation",
"for",
"checking",
"an",
"element",
"is",
"visible",
"and",
"enabled",
"such",
"that",
"you",
"can",
"click",
"it",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java#L637-L657 | train | An expectation for checking that an element is clickable. | [
30522,
2270,
10763,
3517,
8663,
20562,
1026,
4773,
12260,
3672,
1028,
5783,
3406,
4783,
20464,
6799,
3085,
1006,
2345,
2011,
8840,
11266,
2953,
1007,
1063,
2709,
2047,
3517,
8663,
20562,
1026,
4773,
12260,
3672,
1028,
1006,
1007,
1063,
1030... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-setting/src/main/java/cn/hutool/setting/Setting.java | Setting.load | synchronized public boolean load() {
if (null == this.settingLoader) {
settingLoader = new SettingLoader(this.groupedMap, this.charset, this.isUseVariable);
}
return settingLoader.load(new UrlResource(this.settingUrl));
} | java | synchronized public boolean load() {
if (null == this.settingLoader) {
settingLoader = new SettingLoader(this.groupedMap, this.charset, this.isUseVariable);
}
return settingLoader.load(new UrlResource(this.settingUrl));
} | [
"synchronized",
"public",
"boolean",
"load",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"this",
".",
"settingLoader",
")",
"{",
"settingLoader",
"=",
"new",
"SettingLoader",
"(",
"this",
".",
"groupedMap",
",",
"this",
".",
"charset",
",",
"this",
".",
"isU... | 重新加载配置文件
@return 是否加载成功 | [
"重新加载配置文件"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/Setting.java#L168-L173 | train | Load the setting. | [
30522,
25549,
2270,
22017,
20898,
7170,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
2023,
1012,
4292,
11066,
2121,
1007,
1063,
4292,
11066,
2121,
1027,
2047,
4292,
11066,
2121,
1006,
2023,
1012,
15131,
2863,
2361,
1010,
2023,
1012,
258... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/resettable/NonReusingBlockResettableIterator.java | NonReusingBlockResettableIterator.reopen | public void reopen(Iterator<T> input) throws IOException {
this.input = input;
this.noMoreBlocks = false;
this.closed = false;
nextBlock();
} | java | public void reopen(Iterator<T> input) throws IOException {
this.input = input;
this.noMoreBlocks = false;
this.closed = false;
nextBlock();
} | [
"public",
"void",
"reopen",
"(",
"Iterator",
"<",
"T",
">",
"input",
")",
"throws",
"IOException",
"{",
"this",
".",
"input",
"=",
"input",
";",
"this",
".",
"noMoreBlocks",
"=",
"false",
";",
"this",
".",
"closed",
"=",
"false",
";",
"nextBlock",
"(",... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/resettable/NonReusingBlockResettableIterator.java#L74-L81 | train | Reopen the iterator. | [
30522,
2270,
11675,
2128,
26915,
1006,
2009,
6906,
4263,
1026,
1056,
1028,
7953,
1007,
11618,
22834,
10288,
24422,
1063,
2023,
1012,
7953,
1027,
7953,
1025,
2023,
1012,
2053,
5974,
23467,
2015,
1027,
6270,
1025,
2023,
1012,
2701,
1027,
6270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-connectors/flink-connector-kafka-0.11/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer011.java | FlinkKafkaProducer011.open | @Override
public void open(Configuration configuration) throws Exception {
if (logFailuresOnly) {
callback = new Callback() {
@Override
public void onCompletion(RecordMetadata metadata, Exception e) {
if (e != null) {
LOG.error("Error while sending record to Kafka: " + e.getMessage(), e);
}
acknowledgeMessage();
}
};
}
else {
callback = new Callback() {
@Override
public void onCompletion(RecordMetadata metadata, Exception exception) {
if (exception != null && asyncException == null) {
asyncException = exception;
}
acknowledgeMessage();
}
};
}
super.open(configuration);
} | java | @Override
public void open(Configuration configuration) throws Exception {
if (logFailuresOnly) {
callback = new Callback() {
@Override
public void onCompletion(RecordMetadata metadata, Exception e) {
if (e != null) {
LOG.error("Error while sending record to Kafka: " + e.getMessage(), e);
}
acknowledgeMessage();
}
};
}
else {
callback = new Callback() {
@Override
public void onCompletion(RecordMetadata metadata, Exception exception) {
if (exception != null && asyncException == null) {
asyncException = exception;
}
acknowledgeMessage();
}
};
}
super.open(configuration);
} | [
"@",
"Override",
"public",
"void",
"open",
"(",
"Configuration",
"configuration",
")",
"throws",
"Exception",
"{",
"if",
"(",
"logFailuresOnly",
")",
"{",
"callback",
"=",
"new",
"Callback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onCompletion",
"... | Initializes the connection to Kafka. | [
"Initializes",
"the",
"connection",
"to",
"Kafka",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kafka-0.11/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer011.java#L587-L613 | train | Override open to perform the actual work | [
30522,
1030,
2058,
15637,
2270,
11675,
2330,
1006,
9563,
9563,
1007,
11618,
6453,
1063,
2065,
1006,
8833,
7011,
4014,
14900,
2239,
2135,
1007,
1063,
2655,
5963,
1027,
2047,
2655,
5963,
30524,
7561,
2096,
6016,
2501,
2000,
10556,
24316,
2050... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/MetadataOperation.java | MetadataOperation.convertIdentifierPattern | protected String convertIdentifierPattern(final String pattern, boolean datanucleusFormat) {
if (pattern == null) {
return convertPattern("%", true);
} else {
return convertPattern(pattern, datanucleusFormat);
}
} | java | protected String convertIdentifierPattern(final String pattern, boolean datanucleusFormat) {
if (pattern == null) {
return convertPattern("%", true);
} else {
return convertPattern(pattern, datanucleusFormat);
}
} | [
"protected",
"String",
"convertIdentifierPattern",
"(",
"final",
"String",
"pattern",
",",
"boolean",
"datanucleusFormat",
")",
"{",
"if",
"(",
"pattern",
"==",
"null",
")",
"{",
"return",
"convertPattern",
"(",
"\"%\"",
",",
"true",
")",
";",
"}",
"else",
"... | Convert wildchars and escape sequence from JDBC format to datanucleous/regex | [
"Convert",
"wildchars",
"and",
"escape",
"sequence",
"from",
"JDBC",
"format",
"to",
"datanucleous",
"/",
"regex"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/MetadataOperation.java#L64-L70 | train | Convert a string to a CBE identifier pattern. | [
30522,
5123,
5164,
10463,
5178,
16778,
8873,
2121,
4502,
12079,
2078,
1006,
2345,
5164,
5418,
1010,
22017,
20898,
2951,
11231,
14321,
2271,
14192,
4017,
1007,
1063,
2065,
1006,
5418,
1027,
1027,
19701,
1007,
1063,
2709,
10463,
4502,
12079,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/seg/Segment.java | Segment.combineByCustomDictionary | protected static List<Vertex> combineByCustomDictionary(List<Vertex> vertexList, DoubleArrayTrie<CoreDictionary.Attribute> dat, final WordNet wordNetAll)
{
List<Vertex> outputList = combineByCustomDictionary(vertexList, dat);
int line = 0;
for (final Vertex vertex : outputList)
{
final int parentLength = vertex.realWord.length();
final int currentLine = line;
if (parentLength >= 3)
{
CustomDictionary.parseText(vertex.realWord, new AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute>()
{
@Override
public void hit(int begin, int end, CoreDictionary.Attribute value)
{
if (end - begin == parentLength) return;
wordNetAll.add(currentLine + begin, new Vertex(vertex.realWord.substring(begin, end), value));
}
});
}
line += parentLength;
}
return outputList;
} | java | protected static List<Vertex> combineByCustomDictionary(List<Vertex> vertexList, DoubleArrayTrie<CoreDictionary.Attribute> dat, final WordNet wordNetAll)
{
List<Vertex> outputList = combineByCustomDictionary(vertexList, dat);
int line = 0;
for (final Vertex vertex : outputList)
{
final int parentLength = vertex.realWord.length();
final int currentLine = line;
if (parentLength >= 3)
{
CustomDictionary.parseText(vertex.realWord, new AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute>()
{
@Override
public void hit(int begin, int end, CoreDictionary.Attribute value)
{
if (end - begin == parentLength) return;
wordNetAll.add(currentLine + begin, new Vertex(vertex.realWord.substring(begin, end), value));
}
});
}
line += parentLength;
}
return outputList;
} | [
"protected",
"static",
"List",
"<",
"Vertex",
">",
"combineByCustomDictionary",
"(",
"List",
"<",
"Vertex",
">",
"vertexList",
",",
"DoubleArrayTrie",
"<",
"CoreDictionary",
".",
"Attribute",
">",
"dat",
",",
"final",
"WordNet",
"wordNetAll",
")",
"{",
"List",
... | 使用用户词典合并粗分结果,并将用户词语收集到全词图中
@param vertexList 粗分结果
@param dat 用户自定义词典
@param wordNetAll 收集用户词语到全词图中
@return 合并后的结果 | [
"使用用户词典合并粗分结果,并将用户词语收集到全词图中"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/seg/Segment.java#L299-L322 | train | Combine by custom dictionary. | [
30522,
5123,
10763,
2862,
1026,
19449,
1028,
11506,
3762,
7874,
20389,
29201,
3258,
5649,
1006,
2862,
1026,
19449,
1028,
30524,
17961,
1028,
23755,
1010,
2345,
2773,
7159,
2773,
7159,
8095,
1007,
1063,
2862,
1026,
19449,
1028,
6434,
9863,
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-api-java/src/main/java/org/apache/flink/table/factories/TableFactoryUtil.java | TableFactoryUtil.findAndCreateTableSource | public static <T> TableSource<T> findAndCreateTableSource(Descriptor descriptor) {
Map<String, String> properties = descriptor.toProperties();
TableSource tableSource;
try {
tableSource = TableFactoryService
.find(TableSourceFactory.class, properties)
.createTableSource(properties);
} catch (Throwable t) {
throw new TableException("findAndCreateTableSource failed.", t);
}
return tableSource;
} | java | public static <T> TableSource<T> findAndCreateTableSource(Descriptor descriptor) {
Map<String, String> properties = descriptor.toProperties();
TableSource tableSource;
try {
tableSource = TableFactoryService
.find(TableSourceFactory.class, properties)
.createTableSource(properties);
} catch (Throwable t) {
throw new TableException("findAndCreateTableSource failed.", t);
}
return tableSource;
} | [
"public",
"static",
"<",
"T",
">",
"TableSource",
"<",
"T",
">",
"findAndCreateTableSource",
"(",
"Descriptor",
"descriptor",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"descriptor",
".",
"toProperties",
"(",
")",
";",
"TableSourc... | Returns a table source matching the descriptor. | [
"Returns",
"a",
"table",
"source",
"matching",
"the",
"descriptor",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/factories/TableFactoryUtil.java#L47-L60 | train | Find and create table source. | [
30522,
2270,
10763,
1026,
1056,
1028,
7251,
8162,
3401,
1026,
1056,
1028,
2424,
5685,
16748,
3686,
10880,
6499,
3126,
3401,
1006,
4078,
23235,
2953,
4078,
23235,
2953,
1007,
1063,
4949,
1026,
5164,
1010,
5164,
1028,
5144,
1027,
4078,
23235,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueStreamChannel.java | AbstractKQueueStreamChannel.writeBytes | private int writeBytes(ChannelOutboundBuffer in, ByteBuf buf) throws Exception {
int readableBytes = buf.readableBytes();
if (readableBytes == 0) {
in.remove();
return 0;
}
if (buf.hasMemoryAddress() || buf.nioBufferCount() == 1) {
return doWriteBytes(in, buf);
} else {
ByteBuffer[] nioBuffers = buf.nioBuffers();
return writeBytesMultiple(in, nioBuffers, nioBuffers.length, readableBytes,
config().getMaxBytesPerGatheringWrite());
}
} | java | private int writeBytes(ChannelOutboundBuffer in, ByteBuf buf) throws Exception {
int readableBytes = buf.readableBytes();
if (readableBytes == 0) {
in.remove();
return 0;
}
if (buf.hasMemoryAddress() || buf.nioBufferCount() == 1) {
return doWriteBytes(in, buf);
} else {
ByteBuffer[] nioBuffers = buf.nioBuffers();
return writeBytesMultiple(in, nioBuffers, nioBuffers.length, readableBytes,
config().getMaxBytesPerGatheringWrite());
}
} | [
"private",
"int",
"writeBytes",
"(",
"ChannelOutboundBuffer",
"in",
",",
"ByteBuf",
"buf",
")",
"throws",
"Exception",
"{",
"int",
"readableBytes",
"=",
"buf",
".",
"readableBytes",
"(",
")",
";",
"if",
"(",
"readableBytes",
"==",
"0",
")",
"{",
"in",
".",... | Write bytes form the given {@link ByteBuf} to the underlying {@link java.nio.channels.Channel}.
@param in the collection which contains objects to write.
@param buf the {@link ByteBuf} from which the bytes should be written
@return The value that should be decremented from the write quantum which starts at
{@link ChannelConfig#getWriteSpinCount()}. The typical use cases are as follows:
<ul>
<li>0 - if no write was attempted. This is appropriate if an empty {@link ByteBuf} (or other empty content)
is encountered</li>
<li>1 - if a single call to write data was made to the OS</li>
<li>{@link ChannelUtils#WRITE_STATUS_SNDBUF_FULL} - if an attempt to write data was made to the OS, but no
data was accepted</li>
</ul> | [
"Write",
"bytes",
"form",
"the",
"given",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueStreamChannel.java#L103-L117 | train | Write bytes. | [
30522,
2797,
20014,
4339,
3762,
4570,
1006,
3149,
5833,
15494,
8569,
12494,
1999,
1010,
24880,
8569,
2546,
20934,
2546,
1007,
11618,
6453,
1063,
20014,
3191,
3085,
3762,
4570,
1027,
20934,
2546,
1012,
3191,
3085,
3762,
4570,
1006,
1007,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/seg/common/Vertex.java | Vertex.newPunctuationInstance | public static Vertex newPunctuationInstance(String realWord)
{
return new Vertex(realWord, new CoreDictionary.Attribute(Nature.w, 1000));
} | java | public static Vertex newPunctuationInstance(String realWord)
{
return new Vertex(realWord, new CoreDictionary.Attribute(Nature.w, 1000));
} | [
"public",
"static",
"Vertex",
"newPunctuationInstance",
"(",
"String",
"realWord",
")",
"{",
"return",
"new",
"Vertex",
"(",
"realWord",
",",
"new",
"CoreDictionary",
".",
"Attribute",
"(",
"Nature",
".",
"w",
",",
"1000",
")",
")",
";",
"}"
] | 创建一个标点符号实例
@param realWord 标点符号对应的真实字串
@return 标点符号顶点 | [
"创建一个标点符号实例"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/seg/common/Vertex.java#L364-L367 | train | Create a new punctuation Vertex. | [
30522,
2270,
10763,
19449,
2047,
14289,
12273,
26302,
3508,
7076,
26897,
1006,
5164,
2613,
18351,
1007,
1063,
2709,
2047,
19449,
1006,
2613,
18351,
1010,
2047,
4563,
29201,
3258,
5649,
1012,
17961,
1006,
3267,
1012,
1059,
1010,
6694,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/bipartite/BipartiteGraph.java | BipartiteGraph.projectionBottomFull | public Graph<KB, VVB, Projection<KT, VVT, VVB, EV>> projectionBottomFull() {
DataSet<Tuple5<KT, KB, EV, VVT, VVB>> edgesWithVertices = joinEdgeWithVertices();
DataSet<Edge<KB, Projection<KT, VVT, VVB, EV>>> newEdges = edgesWithVertices.join(edgesWithVertices)
.where(0)
.equalTo(0)
.with(new ProjectionBottomFull<>())
.name("Full bottom projection");
return Graph.fromDataSet(bottomVertices, newEdges, context);
} | java | public Graph<KB, VVB, Projection<KT, VVT, VVB, EV>> projectionBottomFull() {
DataSet<Tuple5<KT, KB, EV, VVT, VVB>> edgesWithVertices = joinEdgeWithVertices();
DataSet<Edge<KB, Projection<KT, VVT, VVB, EV>>> newEdges = edgesWithVertices.join(edgesWithVertices)
.where(0)
.equalTo(0)
.with(new ProjectionBottomFull<>())
.name("Full bottom projection");
return Graph.fromDataSet(bottomVertices, newEdges, context);
} | [
"public",
"Graph",
"<",
"KB",
",",
"VVB",
",",
"Projection",
"<",
"KT",
",",
"VVT",
",",
"VVB",
",",
"EV",
">",
">",
"projectionBottomFull",
"(",
")",
"{",
"DataSet",
"<",
"Tuple5",
"<",
"KT",
",",
"KB",
",",
"EV",
",",
"VVT",
",",
"VVB",
">",
... | Convert a bipartite graph into a graph that contains only bottom vertices. An edge between two vertices in the
new graph will exist only if the original bipartite graph contains at least one top vertex they both connect to.
<p>The full projection performs three joins and returns edges containing the connecting vertex ID and value,
both bottom vertex values, and both bipartite edge values.
<p>Note: KB must override .equals(). This requirement may be removed in a future release.
@return full bottom projection of the bipartite graph | [
"Convert",
"a",
"bipartite",
"graph",
"into",
"a",
"graph",
"that",
"contains",
"only",
"bottom",
"vertices",
".",
"An",
"edge",
"between",
"two",
"vertices",
"in",
"the",
"new",
"graph",
"will",
"exist",
"only",
"if",
"the",
"original",
"bipartite",
"graph"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/bipartite/BipartiteGraph.java#L281-L291 | train | Create a graph that is a full bottom projection of this DataSet. | [
30522,
2270,
10629,
1026,
21677,
1010,
1058,
26493,
1010,
13996,
1026,
1047,
2102,
1010,
1058,
2615,
2102,
1010,
1058,
26493,
1010,
23408,
1028,
1028,
13996,
18384,
20389,
3993,
2140,
1006,
1007,
1063,
2951,
13462,
1026,
10722,
10814,
2629,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DefaultRestartInitializer.java | DefaultRestartInitializer.isMain | protected boolean isMain(Thread thread) {
return thread.getName().equals("main") && thread.getContextClassLoader()
.getClass().getName().contains("AppClassLoader");
} | java | protected boolean isMain(Thread thread) {
return thread.getName().equals("main") && thread.getContextClassLoader()
.getClass().getName().contains("AppClassLoader");
} | [
"protected",
"boolean",
"isMain",
"(",
"Thread",
"thread",
")",
"{",
"return",
"thread",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"main\"",
")",
"&&",
"thread",
".",
"getContextClassLoader",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getName",
"("... | Returns if the thread is for a main invocation. By default checks the name of the
thread and the context classloader.
@param thread the thread to check
@return {@code true} if the thread is a main invocation | [
"Returns",
"if",
"the",
"thread",
"is",
"for",
"a",
"main",
"invocation",
".",
"By",
"default",
"checks",
"the",
"name",
"of",
"the",
"thread",
"and",
"the",
"context",
"classloader",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/DefaultRestartInitializer.java#L51-L54 | train | Checks if the thread is the main thread. | [
30522,
5123,
22017,
20898,
2003,
24238,
1006,
11689,
11689,
1007,
1063,
2709,
11689,
1012,
2131,
18442,
1006,
1007,
1012,
19635,
1006,
1000,
2364,
1000,
1007,
1004,
1004,
11689,
1012,
2131,
8663,
18209,
26266,
11066,
2121,
1006,
1007,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/template/engine/velocity/VelocityUtil.java | VelocityUtil.merge | public static void merge(Template template, VelocityContext context, Writer writer) {
if (template == null) {
throw new UtilException("Template is null");
}
if (context == null) {
context = new VelocityContext(globalContext);
} else {
// 加入全局上下文
for (Entry<String, Object> entry : globalContext.entrySet()) {
context.put(entry.getKey(), entry.getValue());
}
}
template.merge(context, writer);
} | java | public static void merge(Template template, VelocityContext context, Writer writer) {
if (template == null) {
throw new UtilException("Template is null");
}
if (context == null) {
context = new VelocityContext(globalContext);
} else {
// 加入全局上下文
for (Entry<String, Object> entry : globalContext.entrySet()) {
context.put(entry.getKey(), entry.getValue());
}
}
template.merge(context, writer);
} | [
"public",
"static",
"void",
"merge",
"(",
"Template",
"template",
",",
"VelocityContext",
"context",
",",
"Writer",
"writer",
")",
"{",
"if",
"(",
"template",
"==",
"null",
")",
"{",
"throw",
"new",
"UtilException",
"(",
"\"Template is null\"",
")",
";",
"}"... | 融合模板和内容并写入到Writer
@param template 模板
@param context 内容
@param writer Writer | [
"融合模板和内容并写入到Writer"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/velocity/VelocityUtil.java#L254-L268 | train | Merge the given VelocityContext with the given Template. | [
30522,
2270,
10763,
11675,
13590,
1006,
23561,
23561,
1010,
10146,
8663,
18209,
6123,
1010,
3213,
3213,
1007,
1063,
2065,
1006,
23561,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
21183,
9463,
2595,
24422,
1006,
1000,
23561,
2003,
19701,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java | SqlExecutor.executeForGeneratedKey | public static Long executeForGeneratedKey(Connection conn, String sql, Map<String, Object> paramMap) throws SQLException {
final NamedSql namedSql = new NamedSql(sql, paramMap);
return executeForGeneratedKey(conn, namedSql.getSql(), namedSql.getParams());
} | java | public static Long executeForGeneratedKey(Connection conn, String sql, Map<String, Object> paramMap) throws SQLException {
final NamedSql namedSql = new NamedSql(sql, paramMap);
return executeForGeneratedKey(conn, namedSql.getSql(), namedSql.getParams());
} | [
"public",
"static",
"Long",
"executeForGeneratedKey",
"(",
"Connection",
"conn",
",",
"String",
"sql",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"paramMap",
")",
"throws",
"SQLException",
"{",
"final",
"NamedSql",
"namedSql",
"=",
"new",
"NamedSql",
"(",
... | 执行非查询语句,返回主键<br>
发查询语句包括 插入、更新、删除<br>
此方法不会关闭Connection
@param conn 数据库连接对象
@param sql SQL
@param paramMap 参数Map
@return 主键
@throws SQLException SQL执行异常
@since 4.0.10 | [
"执行非查询语句,返回主键<br",
">",
"发查询语句包括",
"插入、更新、删除<br",
">",
"此方法不会关闭Connection"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java#L116-L119 | train | Execute SQL for generated key. | [
30522,
2270,
10763,
2146,
15389,
29278,
6914,
16848,
14839,
1006,
4434,
9530,
2078,
1010,
5164,
29296,
1010,
4949,
1026,
5164,
1010,
4874,
1028,
11498,
14760,
2361,
1007,
11618,
29296,
10288,
24422,
1063,
2345,
2315,
2015,
4160,
2140,
2315,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryString.java | BinaryString.blankString | public static BinaryString blankString(int length) {
byte[] spaces = new byte[length];
Arrays.fill(spaces, (byte) ' ');
return fromBytes(spaces);
} | java | public static BinaryString blankString(int length) {
byte[] spaces = new byte[length];
Arrays.fill(spaces, (byte) ' ');
return fromBytes(spaces);
} | [
"public",
"static",
"BinaryString",
"blankString",
"(",
"int",
"length",
")",
"{",
"byte",
"[",
"]",
"spaces",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"Arrays",
".",
"fill",
"(",
"spaces",
",",
"(",
"byte",
")",
"'",
"'",
")",
";",
"return",
"... | Creates an BinaryString that contains `length` spaces. | [
"Creates",
"an",
"BinaryString",
"that",
"contains",
"length",
"spaces",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryString.java#L94-L98 | train | Creates a blank string of the specified length. | [
30522,
2270,
10763,
12441,
3367,
4892,
8744,
3367,
4892,
1006,
20014,
3091,
1007,
1063,
24880,
1031,
1033,
7258,
1027,
2047,
24880,
1031,
3091,
1033,
1025,
27448,
1012,
6039,
1006,
7258,
1010,
1006,
24880,
1007,
1005,
1005,
1007,
1025,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | core/src/main/java/org/apache/spark/util/collection/unsafe/sort/RadixSort.java | RadixSort.sort | public static int sort(
LongArray array, long numRecords, int startByteIndex, int endByteIndex,
boolean desc, boolean signed) {
assert startByteIndex >= 0 : "startByteIndex (" + startByteIndex + ") should >= 0";
assert endByteIndex <= 7 : "endByteIndex (" + endByteIndex + ") should <= 7";
assert endByteIndex > startByteIndex;
assert numRecords * 2 <= array.size();
long inIndex = 0;
long outIndex = numRecords;
if (numRecords > 0) {
long[][] counts = getCounts(array, numRecords, startByteIndex, endByteIndex);
for (int i = startByteIndex; i <= endByteIndex; i++) {
if (counts[i] != null) {
sortAtByte(
array, numRecords, counts[i], i, inIndex, outIndex,
desc, signed && i == endByteIndex);
long tmp = inIndex;
inIndex = outIndex;
outIndex = tmp;
}
}
}
return Ints.checkedCast(inIndex);
} | java | public static int sort(
LongArray array, long numRecords, int startByteIndex, int endByteIndex,
boolean desc, boolean signed) {
assert startByteIndex >= 0 : "startByteIndex (" + startByteIndex + ") should >= 0";
assert endByteIndex <= 7 : "endByteIndex (" + endByteIndex + ") should <= 7";
assert endByteIndex > startByteIndex;
assert numRecords * 2 <= array.size();
long inIndex = 0;
long outIndex = numRecords;
if (numRecords > 0) {
long[][] counts = getCounts(array, numRecords, startByteIndex, endByteIndex);
for (int i = startByteIndex; i <= endByteIndex; i++) {
if (counts[i] != null) {
sortAtByte(
array, numRecords, counts[i], i, inIndex, outIndex,
desc, signed && i == endByteIndex);
long tmp = inIndex;
inIndex = outIndex;
outIndex = tmp;
}
}
}
return Ints.checkedCast(inIndex);
} | [
"public",
"static",
"int",
"sort",
"(",
"LongArray",
"array",
",",
"long",
"numRecords",
",",
"int",
"startByteIndex",
",",
"int",
"endByteIndex",
",",
"boolean",
"desc",
",",
"boolean",
"signed",
")",
"{",
"assert",
"startByteIndex",
">=",
"0",
":",
"\"star... | Sorts a given array of longs using least-significant-digit radix sort. This routine assumes
you have extra space at the end of the array at least equal to the number of records. The
sort is destructive and may relocate the data positioned within the array.
@param array array of long elements followed by at least that many empty slots.
@param numRecords number of data records in the array.
@param startByteIndex the first byte (in range [0, 7]) to sort each long by, counting from the
least significant byte.
@param endByteIndex the last byte (in range [0, 7]) to sort each long by, counting from the
least significant byte. Must be greater than startByteIndex.
@param desc whether this is a descending (binary-order) sort.
@param signed whether this is a signed (two's complement) sort.
@return The starting index of the sorted data within the given array. We return this instead
of always copying the data back to position zero for efficiency. | [
"Sorts",
"a",
"given",
"array",
"of",
"longs",
"using",
"least",
"-",
"significant",
"-",
"digit",
"radix",
"sort",
".",
"This",
"routine",
"assumes",
"you",
"have",
"extra",
"space",
"at",
"the",
"end",
"of",
"the",
"array",
"at",
"least",
"equal",
"to"... | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/RadixSort.java#L44-L67 | train | Sort the given LongArray using the byte - based algorithm. | [
30522,
2270,
10763,
20014,
4066,
1006,
2146,
2906,
9447,
9140,
1010,
2146,
16371,
2213,
2890,
27108,
5104,
1010,
20014,
2707,
3762,
9589,
3207,
2595,
1010,
20014,
2203,
3762,
9589,
3207,
2595,
1010,
22017,
20898,
4078,
2278,
1010,
22017,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/CharsetConversion.java | CharsetConversion.getJavaCharset | public static String getJavaCharset(final int id) {
Entry entry = getEntry(id);
if (entry != null) {
if (entry.javaCharset != null) {
return entry.javaCharset;
} else {
logger.warn("Unknown java charset for: id = " + id + ", name = " + entry.mysqlCharset + ", coll = "
+ entry.mysqlCollation);
return null;
}
} else {
logger.warn("Unexpect mysql charset: " + id);
return null;
}
} | java | public static String getJavaCharset(final int id) {
Entry entry = getEntry(id);
if (entry != null) {
if (entry.javaCharset != null) {
return entry.javaCharset;
} else {
logger.warn("Unknown java charset for: id = " + id + ", name = " + entry.mysqlCharset + ", coll = "
+ entry.mysqlCollation);
return null;
}
} else {
logger.warn("Unexpect mysql charset: " + id);
return null;
}
} | [
"public",
"static",
"String",
"getJavaCharset",
"(",
"final",
"int",
"id",
")",
"{",
"Entry",
"entry",
"=",
"getEntry",
"(",
"id",
")",
";",
"if",
"(",
"entry",
"!=",
"null",
")",
"{",
"if",
"(",
"entry",
".",
"javaCharset",
"!=",
"null",
")",
"{",
... | Return converted charset name for java. | [
"Return",
"converted",
"charset",
"name",
"for",
"java",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/CharsetConversion.java#L376-L391 | train | Gets the java charset name. | [
30522,
2270,
10763,
5164,
2131,
3900,
24887,
8167,
13462,
1006,
2345,
20014,
8909,
1007,
1063,
4443,
4443,
1027,
2131,
4765,
2854,
1006,
8909,
1007,
1025,
2065,
1006,
4443,
999,
1027,
19701,
1007,
1063,
2065,
1006,
4443,
1012,
9262,
7507,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/executor/BatchPreparedStatementExecutor.java | BatchPreparedStatementExecutor.executeBatch | public int[] executeBatch() throws SQLException {
final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecuteCallback<int[]> callback = new SQLExecuteCallback<int[]>(getDatabaseType(), isExceptionThrown) {
@Override
protected int[] executeSQL(final RouteUnit routeUnit, final Statement statement, final ConnectionMode connectionMode) throws SQLException {
return statement.executeBatch();
}
};
List<int[]> results = executeCallback(callback);
if (isAccumulate()) {
return accumulate(results);
} else {
return results.get(0);
}
} | java | public int[] executeBatch() throws SQLException {
final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecuteCallback<int[]> callback = new SQLExecuteCallback<int[]>(getDatabaseType(), isExceptionThrown) {
@Override
protected int[] executeSQL(final RouteUnit routeUnit, final Statement statement, final ConnectionMode connectionMode) throws SQLException {
return statement.executeBatch();
}
};
List<int[]> results = executeCallback(callback);
if (isAccumulate()) {
return accumulate(results);
} else {
return results.get(0);
}
} | [
"public",
"int",
"[",
"]",
"executeBatch",
"(",
")",
"throws",
"SQLException",
"{",
"final",
"boolean",
"isExceptionThrown",
"=",
"ExecutorExceptionHandler",
".",
"isExceptionThrown",
"(",
")",
";",
"SQLExecuteCallback",
"<",
"int",
"[",
"]",
">",
"callback",
"=... | Execute batch.
@return execute results
@throws SQLException SQL exception | [
"Execute",
"batch",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/executor/BatchPreparedStatementExecutor.java#L162-L177 | train | Execute batch. | [
30522,
2270,
20014,
1031,
30524,
1006,
1007,
1025,
29296,
10288,
8586,
10421,
9289,
20850,
8684,
1026,
20014,
1031,
1033,
1028,
2655,
5963,
1027,
2047,
29296,
10288,
8586,
10421,
9289,
20850,
8684,
1026,
20014,
1031,
1033,
1028,
1006,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPool.java | NetworkBufferPool.redistributeBuffers | private void redistributeBuffers() throws IOException {
assert Thread.holdsLock(factoryLock);
// All buffers, which are not among the required ones
final int numAvailableMemorySegment = totalNumberOfMemorySegments - numTotalRequiredBuffers;
if (numAvailableMemorySegment == 0) {
// in this case, we need to redistribute buffers so that every pool gets its minimum
for (LocalBufferPool bufferPool : allBufferPools) {
bufferPool.setNumBuffers(bufferPool.getNumberOfRequiredMemorySegments());
}
return;
}
/*
* With buffer pools being potentially limited, let's distribute the available memory
* segments based on the capacity of each buffer pool, i.e. the maximum number of segments
* an unlimited buffer pool can take is numAvailableMemorySegment, for limited buffer pools
* it may be less. Based on this and the sum of all these values (totalCapacity), we build
* a ratio that we use to distribute the buffers.
*/
long totalCapacity = 0; // long to avoid int overflow
for (LocalBufferPool bufferPool : allBufferPools) {
int excessMax = bufferPool.getMaxNumberOfMemorySegments() -
bufferPool.getNumberOfRequiredMemorySegments();
totalCapacity += Math.min(numAvailableMemorySegment, excessMax);
}
// no capacity to receive additional buffers?
if (totalCapacity == 0) {
return; // necessary to avoid div by zero when nothing to re-distribute
}
// since one of the arguments of 'min(a,b)' is a positive int, this is actually
// guaranteed to be within the 'int' domain
// (we use a checked downCast to handle possible bugs more gracefully).
final int memorySegmentsToDistribute = MathUtils.checkedDownCast(
Math.min(numAvailableMemorySegment, totalCapacity));
long totalPartsUsed = 0; // of totalCapacity
int numDistributedMemorySegment = 0;
for (LocalBufferPool bufferPool : allBufferPools) {
int excessMax = bufferPool.getMaxNumberOfMemorySegments() -
bufferPool.getNumberOfRequiredMemorySegments();
// shortcut
if (excessMax == 0) {
continue;
}
totalPartsUsed += Math.min(numAvailableMemorySegment, excessMax);
// avoid remaining buffers by looking at the total capacity that should have been
// re-distributed up until here
// the downcast will always succeed, because both arguments of the subtraction are in the 'int' domain
final int mySize = MathUtils.checkedDownCast(
memorySegmentsToDistribute * totalPartsUsed / totalCapacity - numDistributedMemorySegment);
numDistributedMemorySegment += mySize;
bufferPool.setNumBuffers(bufferPool.getNumberOfRequiredMemorySegments() + mySize);
}
assert (totalPartsUsed == totalCapacity);
assert (numDistributedMemorySegment == memorySegmentsToDistribute);
} | java | private void redistributeBuffers() throws IOException {
assert Thread.holdsLock(factoryLock);
// All buffers, which are not among the required ones
final int numAvailableMemorySegment = totalNumberOfMemorySegments - numTotalRequiredBuffers;
if (numAvailableMemorySegment == 0) {
// in this case, we need to redistribute buffers so that every pool gets its minimum
for (LocalBufferPool bufferPool : allBufferPools) {
bufferPool.setNumBuffers(bufferPool.getNumberOfRequiredMemorySegments());
}
return;
}
/*
* With buffer pools being potentially limited, let's distribute the available memory
* segments based on the capacity of each buffer pool, i.e. the maximum number of segments
* an unlimited buffer pool can take is numAvailableMemorySegment, for limited buffer pools
* it may be less. Based on this and the sum of all these values (totalCapacity), we build
* a ratio that we use to distribute the buffers.
*/
long totalCapacity = 0; // long to avoid int overflow
for (LocalBufferPool bufferPool : allBufferPools) {
int excessMax = bufferPool.getMaxNumberOfMemorySegments() -
bufferPool.getNumberOfRequiredMemorySegments();
totalCapacity += Math.min(numAvailableMemorySegment, excessMax);
}
// no capacity to receive additional buffers?
if (totalCapacity == 0) {
return; // necessary to avoid div by zero when nothing to re-distribute
}
// since one of the arguments of 'min(a,b)' is a positive int, this is actually
// guaranteed to be within the 'int' domain
// (we use a checked downCast to handle possible bugs more gracefully).
final int memorySegmentsToDistribute = MathUtils.checkedDownCast(
Math.min(numAvailableMemorySegment, totalCapacity));
long totalPartsUsed = 0; // of totalCapacity
int numDistributedMemorySegment = 0;
for (LocalBufferPool bufferPool : allBufferPools) {
int excessMax = bufferPool.getMaxNumberOfMemorySegments() -
bufferPool.getNumberOfRequiredMemorySegments();
// shortcut
if (excessMax == 0) {
continue;
}
totalPartsUsed += Math.min(numAvailableMemorySegment, excessMax);
// avoid remaining buffers by looking at the total capacity that should have been
// re-distributed up until here
// the downcast will always succeed, because both arguments of the subtraction are in the 'int' domain
final int mySize = MathUtils.checkedDownCast(
memorySegmentsToDistribute * totalPartsUsed / totalCapacity - numDistributedMemorySegment);
numDistributedMemorySegment += mySize;
bufferPool.setNumBuffers(bufferPool.getNumberOfRequiredMemorySegments() + mySize);
}
assert (totalPartsUsed == totalCapacity);
assert (numDistributedMemorySegment == memorySegmentsToDistribute);
} | [
"private",
"void",
"redistributeBuffers",
"(",
")",
"throws",
"IOException",
"{",
"assert",
"Thread",
".",
"holdsLock",
"(",
"factoryLock",
")",
";",
"// All buffers, which are not among the required ones",
"final",
"int",
"numAvailableMemorySegment",
"=",
"totalNumberOfMem... | Must be called from synchronized block | [
"Must",
"be",
"called",
"from",
"synchronized",
"block"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPool.java#L345-L411 | train | Redistributes all the buffers to the local buffers. | [
30522,
2797,
11675,
2417,
2923,
3089,
8569,
2618,
8569,
12494,
2015,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
20865,
11689,
1012,
30524,
3468,
4168,
5302,
24769,
13910,
3672,
1027,
2561,
19172,
5677,
11253,
4168,
5302,
24769,
13910,
8163... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | http-url/src/main/java/com/networknt/url/URLNormalizer.java | URLNormalizer.removeTrailingSlash | public URLNormalizer removeTrailingSlash() {
String urlRoot = HttpURL.getRoot(url);
String path = toURL().getPath();
String urlRootAndPath = urlRoot + path;
if (path.endsWith("/")) {
String newPath = StringUtils.removeEnd(path, "/");
String newUrlRootAndPath = urlRoot + newPath;
url = StringUtils.replaceOnce(
url, urlRootAndPath, newUrlRootAndPath);
}
return this;
} | java | public URLNormalizer removeTrailingSlash() {
String urlRoot = HttpURL.getRoot(url);
String path = toURL().getPath();
String urlRootAndPath = urlRoot + path;
if (path.endsWith("/")) {
String newPath = StringUtils.removeEnd(path, "/");
String newUrlRootAndPath = urlRoot + newPath;
url = StringUtils.replaceOnce(
url, urlRootAndPath, newUrlRootAndPath);
}
return this;
} | [
"public",
"URLNormalizer",
"removeTrailingSlash",
"(",
")",
"{",
"String",
"urlRoot",
"=",
"HttpURL",
".",
"getRoot",
"(",
"url",
")",
";",
"String",
"path",
"=",
"toURL",
"(",
")",
".",
"getPath",
"(",
")",
";",
"String",
"urlRootAndPath",
"=",
"urlRoot",... | <p>Removes any trailing slash (/) from a URL, before fragment
(#) or query string (?).</p>
<p><b>Please Note:</b> Removing trailing slashes form URLs
could potentially break their semantic equivalence.</p>
<code>http://www.example.com/alice/ →
http://www.example.com/alice</code>
@return this instance
@since 1.11.0 | [
"<p",
">",
"Removes",
"any",
"trailing",
"slash",
"(",
"/",
")",
"from",
"a",
"URL",
"before",
"fragment",
"(",
"#",
")",
"or",
"query",
"string",
"(",
"?",
")",
".",
"<",
"/",
"p",
">"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/http-url/src/main/java/com/networknt/url/URLNormalizer.java#L391-L403 | train | Remove trailing slash from URL. | [
30522,
2270,
24471,
19666,
2953,
9067,
17629,
6366,
6494,
16281,
14540,
11823,
1006,
1007,
1063,
5164,
24471,
20974,
17206,
1027,
8299,
3126,
2140,
1012,
2131,
3217,
4140,
1006,
24471,
2140,
1007,
1025,
30524,
5685,
15069,
1027,
24471,
20974,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ReUtil.java | ReUtil.findAll | public static List<String> findAll(Pattern pattern, CharSequence content, int group) {
return findAll(pattern, content, group, new ArrayList<String>());
} | java | public static List<String> findAll(Pattern pattern, CharSequence content, int group) {
return findAll(pattern, content, group, new ArrayList<String>());
} | [
"public",
"static",
"List",
"<",
"String",
">",
"findAll",
"(",
"Pattern",
"pattern",
",",
"CharSequence",
"content",
",",
"int",
"group",
")",
"{",
"return",
"findAll",
"(",
"pattern",
",",
"content",
",",
"group",
",",
"new",
"ArrayList",
"<",
"String",
... | 取得内容中匹配的所有结果
@param pattern 编译后的正则模式
@param content 被查找的内容
@param group 正则的分组
@return 结果列表
@since 3.0.6 | [
"取得内容中匹配的所有结果"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReUtil.java#L443-L445 | train | Finds all matches of the given pattern in the given content and group. | [
30522,
2270,
10763,
2862,
1026,
5164,
1028,
2424,
8095,
1006,
5418,
5418,
1010,
25869,
3366,
4226,
5897,
4180,
1010,
20014,
2177,
1007,
1063,
2709,
2424,
8095,
1006,
5418,
1010,
4180,
1010,
2177,
1010,
2047,
9140,
9863,
1026,
5164,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/InstrumentedScheduledExecutorService.java | InstrumentedScheduledExecutorService.submit | @Nonnull
@Override
public <T> Future<T> submit(@Nonnull Runnable task, T result) {
submitted.mark();
return delegate.submit(new InstrumentedRunnable(task), result);
} | java | @Nonnull
@Override
public <T> Future<T> submit(@Nonnull Runnable task, T result) {
submitted.mark();
return delegate.submit(new InstrumentedRunnable(task), result);
} | [
"@",
"Nonnull",
"@",
"Override",
"public",
"<",
"T",
">",
"Future",
"<",
"T",
">",
"submit",
"(",
"@",
"Nonnull",
"Runnable",
"task",
",",
"T",
"result",
")",
"{",
"submitted",
".",
"mark",
"(",
")",
";",
"return",
"delegate",
".",
"submit",
"(",
"... | {@inheritDoc} | [
"{"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/InstrumentedScheduledExecutorService.java#L174-L179 | train | Submits a Runnable to the delegate thread pool. | [
30522,
1030,
2512,
11231,
3363,
1030,
2058,
15637,
2270,
1026,
1056,
1028,
2925,
1026,
1056,
1028,
12040,
30524,
1010,
2765,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/kafka/KafkaProperties.java | KafkaProperties.buildAdminProperties | public Map<String, Object> buildAdminProperties() {
Map<String, Object> properties = buildCommonProperties();
properties.putAll(this.admin.buildProperties());
return properties;
} | java | public Map<String, Object> buildAdminProperties() {
Map<String, Object> properties = buildCommonProperties();
properties.putAll(this.admin.buildProperties());
return properties;
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"buildAdminProperties",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"buildCommonProperties",
"(",
")",
";",
"properties",
".",
"putAll",
"(",
"this",
".",
"admin",
".",
"... | Create an initial map of admin properties from the state of this instance.
<p>
This allows you to add additional properties, if necessary, and override the
default kafkaAdmin bean.
@return the admin properties initialized with the customizations defined on this
instance | [
"Create",
"an",
"initial",
"map",
"of",
"admin",
"properties",
"from",
"the",
"state",
"of",
"this",
"instance",
".",
"<p",
">",
"This",
"allows",
"you",
"to",
"add",
"additional",
"properties",
"if",
"necessary",
"and",
"override",
"the",
"default",
"kafkaA... | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java#L197-L201 | train | Build the properties for the admin. | [
30522,
2270,
4949,
1026,
5164,
1010,
4874,
1028,
3857,
4215,
10020,
21572,
4842,
7368,
1006,
1007,
1063,
4949,
1026,
5164,
1010,
4874,
1028,
5144,
1027,
3857,
9006,
8202,
21572,
4842,
7368,
1006,
1007,
1025,
5144,
1012,
2404,
8095,
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... |
netty/netty | codec/src/main/java/io/netty/handler/codec/DateFormatter.java | DateFormatter.append | public static StringBuilder append(Date date, StringBuilder sb) {
return formatter().append0(checkNotNull(date, "date"), checkNotNull(sb, "sb"));
} | java | public static StringBuilder append(Date date, StringBuilder sb) {
return formatter().append0(checkNotNull(date, "date"), checkNotNull(sb, "sb"));
} | [
"public",
"static",
"StringBuilder",
"append",
"(",
"Date",
"date",
",",
"StringBuilder",
"sb",
")",
"{",
"return",
"formatter",
"(",
")",
".",
"append0",
"(",
"checkNotNull",
"(",
"date",
",",
"\"date\"",
")",
",",
"checkNotNull",
"(",
"sb",
",",
"\"sb\""... | Append a {@link Date} to a {@link StringBuilder} into RFC1123 format
@param date the date to format
@param sb the StringBuilder
@return the same StringBuilder | [
"Append",
"a",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/DateFormatter.java#L123-L125 | train | Append a date to a StringBuilder. | [
30522,
2270,
10763,
5164,
8569,
23891,
2099,
10439,
10497,
1006,
3058,
3058,
1010,
5164,
8569,
23891,
2099,
24829,
1007,
1063,
2709,
4289,
3334,
1006,
1007,
1012,
10439,
10497,
2692,
1006,
4638,
17048,
11231,
3363,
1006,
3058,
1010,
1000,
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... |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/InternalTimerServiceImpl.java | InternalTimerServiceImpl.snapshotTimersForKeyGroup | public InternalTimersSnapshot<K, N> snapshotTimersForKeyGroup(int keyGroupIdx) {
return new InternalTimersSnapshot<>(
keySerializer,
namespaceSerializer,
eventTimeTimersQueue.getSubsetForKeyGroup(keyGroupIdx),
processingTimeTimersQueue.getSubsetForKeyGroup(keyGroupIdx));
} | java | public InternalTimersSnapshot<K, N> snapshotTimersForKeyGroup(int keyGroupIdx) {
return new InternalTimersSnapshot<>(
keySerializer,
namespaceSerializer,
eventTimeTimersQueue.getSubsetForKeyGroup(keyGroupIdx),
processingTimeTimersQueue.getSubsetForKeyGroup(keyGroupIdx));
} | [
"public",
"InternalTimersSnapshot",
"<",
"K",
",",
"N",
">",
"snapshotTimersForKeyGroup",
"(",
"int",
"keyGroupIdx",
")",
"{",
"return",
"new",
"InternalTimersSnapshot",
"<>",
"(",
"keySerializer",
",",
"namespaceSerializer",
",",
"eventTimeTimersQueue",
".",
"getSubs... | Snapshots the timers (both processing and event time ones) for a given {@code keyGroupIdx}.
@param keyGroupIdx the id of the key-group to be put in the snapshot.
@return a snapshot containing the timers for the given key-group, and the serializers for them | [
"Snapshots",
"the",
"timers",
"(",
"both",
"processing",
"and",
"event",
"time",
"ones",
")",
"for",
"a",
"given",
"{",
"@code",
"keyGroupIdx",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/InternalTimerServiceImpl.java#L265-L271 | train | Creates a snapshot of the timers for the given key - group index. | [
30522,
2270,
4722,
7292,
2869,
2015,
2532,
4523,
12326,
1026,
1047,
1010,
1050,
1028,
20057,
12326,
7292,
2869,
29278,
14839,
17058,
1006,
20014,
3145,
17058,
3593,
2595,
1007,
1063,
2709,
2047,
4722,
7292,
2869,
2015,
2532,
4523,
12326,
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... |
netty/netty | common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java | NativeLibraryLoader.tryToLoadClass | private static Class<?> tryToLoadClass(final ClassLoader loader, final Class<?> helper)
throws ClassNotFoundException {
try {
return Class.forName(helper.getName(), false, loader);
} catch (ClassNotFoundException e1) {
if (loader == null) {
// cannot defineClass inside bootstrap class loader
throw e1;
}
try {
// The helper class is NOT found in target ClassLoader, we have to define the helper class.
final byte[] classBinary = classToByteArray(helper);
return AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
@Override
public Class<?> run() {
try {
// Define the helper class in the target ClassLoader,
// then we can call the helper to load the native library.
Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class,
byte[].class, int.class, int.class);
defineClass.setAccessible(true);
return (Class<?>) defineClass.invoke(loader, helper.getName(), classBinary, 0,
classBinary.length);
} catch (Exception e) {
throw new IllegalStateException("Define class failed!", e);
}
}
});
} catch (ClassNotFoundException e2) {
ThrowableUtil.addSuppressed(e2, e1);
throw e2;
} catch (RuntimeException e2) {
ThrowableUtil.addSuppressed(e2, e1);
throw e2;
} catch (Error e2) {
ThrowableUtil.addSuppressed(e2, e1);
throw e2;
}
}
} | java | private static Class<?> tryToLoadClass(final ClassLoader loader, final Class<?> helper)
throws ClassNotFoundException {
try {
return Class.forName(helper.getName(), false, loader);
} catch (ClassNotFoundException e1) {
if (loader == null) {
// cannot defineClass inside bootstrap class loader
throw e1;
}
try {
// The helper class is NOT found in target ClassLoader, we have to define the helper class.
final byte[] classBinary = classToByteArray(helper);
return AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
@Override
public Class<?> run() {
try {
// Define the helper class in the target ClassLoader,
// then we can call the helper to load the native library.
Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class,
byte[].class, int.class, int.class);
defineClass.setAccessible(true);
return (Class<?>) defineClass.invoke(loader, helper.getName(), classBinary, 0,
classBinary.length);
} catch (Exception e) {
throw new IllegalStateException("Define class failed!", e);
}
}
});
} catch (ClassNotFoundException e2) {
ThrowableUtil.addSuppressed(e2, e1);
throw e2;
} catch (RuntimeException e2) {
ThrowableUtil.addSuppressed(e2, e1);
throw e2;
} catch (Error e2) {
ThrowableUtil.addSuppressed(e2, e1);
throw e2;
}
}
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"tryToLoadClass",
"(",
"final",
"ClassLoader",
"loader",
",",
"final",
"Class",
"<",
"?",
">",
"helper",
")",
"throws",
"ClassNotFoundException",
"{",
"try",
"{",
"return",
"Class",
".",
"forName",
"(",
"helper",
... | Try to load the helper {@link Class} into specified {@link ClassLoader}.
@param loader - The {@link ClassLoader} where to load the helper {@link Class}
@param helper - The helper {@link Class}
@return A new helper Class defined in the specified ClassLoader.
@throws ClassNotFoundException Helper class not found or loading failed | [
"Try",
"to",
"load",
"the",
"helper",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java#L395-L434 | train | Try to load the class from the given ClassLoader. | [
30522,
2797,
10763,
2465,
1026,
1029,
1028,
3046,
3406,
11066,
26266,
1006,
2345,
2465,
11066,
2121,
7170,
2121,
1010,
2345,
2465,
1026,
1029,
1028,
2393,
2121,
1007,
11618,
2465,
17048,
14876,
8630,
10288,
24422,
1063,
3046,
1063,
2709,
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... |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java | ExecutionEnvironment.registerCachedFile | public void registerCachedFile(String filePath, String name, boolean executable){
this.cacheFile.add(new Tuple2<>(name, new DistributedCacheEntry(filePath, executable)));
} | java | public void registerCachedFile(String filePath, String name, boolean executable){
this.cacheFile.add(new Tuple2<>(name, new DistributedCacheEntry(filePath, executable)));
} | [
"public",
"void",
"registerCachedFile",
"(",
"String",
"filePath",
",",
"String",
"name",
",",
"boolean",
"executable",
")",
"{",
"this",
".",
"cacheFile",
".",
"add",
"(",
"new",
"Tuple2",
"<>",
"(",
"name",
",",
"new",
"DistributedCacheEntry",
"(",
"filePa... | Registers a file at the distributed cache under the given name. The file will be accessible
from any user-defined function in the (distributed) runtime under a local path. Files
may be local files (which will be distributed via BlobServer), or files in a distributed file system.
The runtime will copy the files temporarily to a local cache, if needed.
<p>The {@link org.apache.flink.api.common.functions.RuntimeContext} can be obtained inside UDFs via
{@link org.apache.flink.api.common.functions.RichFunction#getRuntimeContext()} and provides access
{@link org.apache.flink.api.common.cache.DistributedCache} via
{@link org.apache.flink.api.common.functions.RuntimeContext#getDistributedCache()}.
@param filePath The path of the file, as a URI (e.g. "file:///some/path" or "hdfs://host:port/and/path")
@param name The name under which the file is registered.
@param executable flag indicating whether the file should be executable | [
"Registers",
"a",
"file",
"at",
"the",
"distributed",
"cache",
"under",
"the",
"given",
"name",
".",
"The",
"file",
"will",
"be",
"accessible",
"from",
"any",
"user",
"-",
"defined",
"function",
"in",
"the",
"(",
"distributed",
")",
"runtime",
"under",
"a"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java#L878-L880 | train | Register a cached file. | [
30522,
2270,
11675,
4236,
3540,
7690,
8873,
2571,
1006,
5164,
5371,
15069,
1010,
5164,
2171,
1010,
22017,
20898,
4654,
8586,
23056,
1007,
1063,
2023,
1012,
17053,
8873,
2571,
1012,
5587,
1006,
2047,
10722,
10814,
2475,
1026,
1028,
1006,
217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
redisson/redisson | redisson/src/main/java/org/redisson/config/Config.java | Config.fromJSON | public static Config fromJSON(File file, ClassLoader classLoader) throws IOException {
ConfigSupport support = new ConfigSupport();
return support.fromJSON(file, Config.class, classLoader);
} | java | public static Config fromJSON(File file, ClassLoader classLoader) throws IOException {
ConfigSupport support = new ConfigSupport();
return support.fromJSON(file, Config.class, classLoader);
} | [
"public",
"static",
"Config",
"fromJSON",
"(",
"File",
"file",
",",
"ClassLoader",
"classLoader",
")",
"throws",
"IOException",
"{",
"ConfigSupport",
"support",
"=",
"new",
"ConfigSupport",
"(",
")",
";",
"return",
"support",
".",
"fromJSON",
"(",
"file",
",",... | Read config object stored in JSON format from <code>File</code>
@param file object
@param classLoader class loader
@return config
@throws IOException error | [
"Read",
"config",
"object",
"stored",
"in",
"JSON",
"format",
"from",
"<code",
">",
"File<",
"/",
"code",
">"
] | d3acc0249b2d5d658d36d99e2c808ce49332ea44 | https://github.com/redisson/redisson/blob/d3acc0249b2d5d658d36d99e2c808ce49332ea44/redisson/src/main/java/org/redisson/config/Config.java#L581-L584 | train | Creates a Config object from a JSON file. | [
30522,
2270,
10763,
9530,
8873,
2290,
2013,
22578,
2239,
1006,
5371,
5371,
1010,
2465,
11066,
2121,
2465,
11066,
2121,
1007,
11618,
22834,
10288,
24422,
1063,
9530,
8873,
5620,
6279,
6442,
2490,
1027,
2047,
9530,
8873,
5620,
6279,
6442,
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-clients/src/main/java/org/apache/flink/client/LocalExecutor.java | LocalExecutor.start | @Override
public void start() throws Exception {
synchronized (lock) {
if (jobExecutorService == null) {
// create the embedded runtime
jobExecutorServiceConfiguration = createConfiguration();
// start it up
jobExecutorService = createJobExecutorService(jobExecutorServiceConfiguration);
} else {
throw new IllegalStateException("The local executor was already started.");
}
}
} | java | @Override
public void start() throws Exception {
synchronized (lock) {
if (jobExecutorService == null) {
// create the embedded runtime
jobExecutorServiceConfiguration = createConfiguration();
// start it up
jobExecutorService = createJobExecutorService(jobExecutorServiceConfiguration);
} else {
throw new IllegalStateException("The local executor was already started.");
}
}
} | [
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"throws",
"Exception",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"jobExecutorService",
"==",
"null",
")",
"{",
"// create the embedded runtime",
"jobExecutorServiceConfiguration",
"=",
"createConfigu... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-clients/src/main/java/org/apache/flink/client/LocalExecutor.java#L110-L123 | train | Start the local executor. | [
30522,
1030,
30524,
1063,
25549,
1006,
5843,
1007,
1063,
2065,
1006,
3105,
10288,
8586,
16161,
22573,
2099,
7903,
2063,
1027,
1027,
19701,
1007,
1063,
1013,
1013,
3443,
1996,
11157,
2448,
7292,
3105,
10288,
8586,
16161,
22573,
2099,
7903,
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java | ZipUtil.getZipOutputStream | private static ZipOutputStream getZipOutputStream(OutputStream out, Charset charset) {
charset = (null == charset) ? DEFAULT_CHARSET : charset;
return new ZipOutputStream(out, charset);
} | java | private static ZipOutputStream getZipOutputStream(OutputStream out, Charset charset) {
charset = (null == charset) ? DEFAULT_CHARSET : charset;
return new ZipOutputStream(out, charset);
} | [
"private",
"static",
"ZipOutputStream",
"getZipOutputStream",
"(",
"OutputStream",
"out",
",",
"Charset",
"charset",
")",
"{",
"charset",
"=",
"(",
"null",
"==",
"charset",
")",
"?",
"DEFAULT_CHARSET",
":",
"charset",
";",
"return",
"new",
"ZipOutputStream",
"("... | 获得 {@link ZipOutputStream}
@param zipFile 压缩文件
@param charset 编码
@return {@link ZipOutputStream} | [
"获得",
"{",
"@link",
"ZipOutputStream",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java#L757-L760 | train | Returns a ZipOutputStream for writing to the given output stream using the given charset. | [
30522,
2797,
10763,
14101,
5833,
18780,
21422,
2131,
5831,
6873,
4904,
18780,
21422,
1006,
27852,
25379,
2041,
1010,
25869,
13462,
25869,
13462,
1007,
1063,
25869,
13462,
1027,
1006,
19701,
1027,
1027,
25869,
13462,
1007,
1029,
12398,
1035,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java | ExpectedConditions.elementSelectionStateToBe | public static ExpectedCondition<Boolean> elementSelectionStateToBe(final WebElement element,
final boolean selected) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return element.isSelected() == selected;
}
@Override
public String toString() {
return String.format("element (%s) to %sbe selected", element, (selected ? "" : "not "));
}
};
} | java | public static ExpectedCondition<Boolean> elementSelectionStateToBe(final WebElement element,
final boolean selected) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return element.isSelected() == selected;
}
@Override
public String toString() {
return String.format("element (%s) to %sbe selected", element, (selected ? "" : "not "));
}
};
} | [
"public",
"static",
"ExpectedCondition",
"<",
"Boolean",
">",
"elementSelectionStateToBe",
"(",
"final",
"WebElement",
"element",
",",
"final",
"boolean",
"selected",
")",
"{",
"return",
"new",
"ExpectedCondition",
"<",
"Boolean",
">",
"(",
")",
"{",
"@",
"Overr... | An expectation for checking if the given element is selected.
@param element WebElement to be selected
@param selected boolean state of the selection state of the element
@return true once the element's selection stated is that of selected | [
"An",
"expectation",
"for",
"checking",
"if",
"the",
"given",
"element",
"is",
"selected",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java#L761-L774 | train | An expectation for checking WebElement to have selected state. | [
30522,
2270,
10763,
3517,
8663,
20562,
1026,
22017,
20898,
1028,
3787,
12260,
22014,
12259,
3406,
4783,
1006,
2345,
4773,
12260,
3672,
5783,
1010,
2345,
22017,
20898,
3479,
1007,
1063,
2709,
2047,
3517,
8663,
20562,
1026,
22017,
20898,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpRequest.java | HttpRequest.sendMultipart | private void sendMultipart() throws IOException {
setMultipart();// 设置表单类型为Multipart
final OutputStream out = this.httpConnection.getOutputStream();
try {
writeFileForm(out);
writeForm(out);
formEnd(out);
} catch (IOException e) {
throw e;
} finally {
IoUtil.close(out);
}
} | java | private void sendMultipart() throws IOException {
setMultipart();// 设置表单类型为Multipart
final OutputStream out = this.httpConnection.getOutputStream();
try {
writeFileForm(out);
writeForm(out);
formEnd(out);
} catch (IOException e) {
throw e;
} finally {
IoUtil.close(out);
}
} | [
"private",
"void",
"sendMultipart",
"(",
")",
"throws",
"IOException",
"{",
"setMultipart",
"(",
")",
";",
"// 设置表单类型为Multipart\r",
"final",
"OutputStream",
"out",
"=",
"this",
".",
"httpConnection",
".",
"getOutputStream",
"(",
")",
";",
"try",
"{",
"writeFileF... | 发送多组件请求(例如包含文件的表单)
@throws IOException | [
"发送多组件请求(例如包含文件的表单)"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java#L1021-L1034 | train | Send a multipart request. | [
30522,
2797,
11675,
4604,
12274,
7096,
11514,
8445,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
2275,
12274,
7096,
11514,
8445,
1006,
1007,
1025,
1013,
1013,
100,
100,
100,
100,
100,
100,
100,
4800,
19362,
2102,
2345,
27852,
25379,
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-libraries/flink-gelly/src/main/java/org/apache/flink/graph/Graph.java | Graph.addEdges | public Graph<K, VV, EV> addEdges(List<Edge<K, EV>> newEdges) {
DataSet<Edge<K, EV>> newEdgesDataSet = this.context.fromCollection(newEdges);
DataSet<Edge<K, EV>> validNewEdges = this.getVertices().join(newEdgesDataSet)
.where(0).equalTo(0)
.with(new JoinVerticesWithEdgesOnSrc<>()).name("Join with source")
.join(this.getVertices()).where(1).equalTo(0)
.with(new JoinWithVerticesOnTrg<>()).name("Join with target");
return Graph.fromDataSet(this.vertices, this.edges.union(validNewEdges), this.context);
} | java | public Graph<K, VV, EV> addEdges(List<Edge<K, EV>> newEdges) {
DataSet<Edge<K, EV>> newEdgesDataSet = this.context.fromCollection(newEdges);
DataSet<Edge<K, EV>> validNewEdges = this.getVertices().join(newEdgesDataSet)
.where(0).equalTo(0)
.with(new JoinVerticesWithEdgesOnSrc<>()).name("Join with source")
.join(this.getVertices()).where(1).equalTo(0)
.with(new JoinWithVerticesOnTrg<>()).name("Join with target");
return Graph.fromDataSet(this.vertices, this.edges.union(validNewEdges), this.context);
} | [
"public",
"Graph",
"<",
"K",
",",
"VV",
",",
"EV",
">",
"addEdges",
"(",
"List",
"<",
"Edge",
"<",
"K",
",",
"EV",
">",
">",
"newEdges",
")",
"{",
"DataSet",
"<",
"Edge",
"<",
"K",
",",
"EV",
">",
">",
"newEdgesDataSet",
"=",
"this",
".",
"cont... | Adds the given list edges to the graph.
<p>When adding an edge for a non-existing set of vertices, the edge is considered invalid and ignored.
@param newEdges the data set of edges to be added
@return a new graph containing the existing edges plus the newly added edges. | [
"Adds",
"the",
"given",
"list",
"edges",
"to",
"the",
"graph",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/Graph.java#L1430-L1441 | train | Add edges to the graph. | [
30522,
2270,
10629,
1026,
1047,
1010,
1058,
2615,
1010,
23408,
1028,
2794,
8449,
1006,
2862,
1026,
3341,
1026,
1047,
1010,
23408,
1028,
1028,
2047,
24225,
2015,
1007,
1063,
2951,
13462,
1026,
3341,
1026,
1047,
1010,
23408,
1028,
1028,
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... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/HashPartition.java | HashPartition.setReadPosition | public void setReadPosition(long pointer) {
final int bufferNum = (int) (pointer >>> this.segmentSizeBits);
final int offset = (int) (pointer & (this.memorySegmentSize - 1));
this.currentBufferNum = bufferNum;
seekInput(this.partitionBuffers[bufferNum], offset,
bufferNum < this.partitionBuffers.length-1 ? this.memorySegmentSize : this.finalBufferLimit);
} | java | public void setReadPosition(long pointer) {
final int bufferNum = (int) (pointer >>> this.segmentSizeBits);
final int offset = (int) (pointer & (this.memorySegmentSize - 1));
this.currentBufferNum = bufferNum;
seekInput(this.partitionBuffers[bufferNum], offset,
bufferNum < this.partitionBuffers.length-1 ? this.memorySegmentSize : this.finalBufferLimit);
} | [
"public",
"void",
"setReadPosition",
"(",
"long",
"pointer",
")",
"{",
"final",
"int",
"bufferNum",
"=",
"(",
"int",
")",
"(",
"pointer",
">>>",
"this",
".",
"segmentSizeBits",
")",
";",
"final",
"int",
"offset",
"=",
"(",
"int",
")",
"(",
"pointer",
"... | -------------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/HashPartition.java#L470-L478 | train | Sets the current read position of the input buffer. | [
30522,
2270,
11675,
2275,
16416,
18927,
19234,
1006,
2146,
20884,
1007,
1063,
2345,
20014,
17698,
19172,
1027,
1006,
20014,
1007,
1006,
20884,
1028,
1028,
1028,
2023,
1012,
9214,
4697,
16313,
2015,
1007,
1025,
2345,
20014,
16396,
1027,
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... |
alibaba/canal | sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineBarrier.java | TimelineBarrier.await | public void await(Event event, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
long timestamp = getTimestamp(event);
try {
lock.lockInterruptibly();
single(timestamp);
while (isPermit(event, timestamp) == false) {
condition.await(timeout, unit);
}
} finally {
lock.unlock();
}
} | java | public void await(Event event, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
long timestamp = getTimestamp(event);
try {
lock.lockInterruptibly();
single(timestamp);
while (isPermit(event, timestamp) == false) {
condition.await(timeout, unit);
}
} finally {
lock.unlock();
}
} | [
"public",
"void",
"await",
"(",
"Event",
"event",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"TimeoutException",
"{",
"long",
"timestamp",
"=",
"getTimestamp",
"(",
"event",
")",
";",
"try",
"{",
"lock",
".",... | 判断自己的timestamp是否可以通过,带超时控制
@throws InterruptedException
@throws TimeoutException | [
"判断自己的timestamp是否可以通过",
"带超时控制"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineBarrier.java#L66-L77 | train | Await for an event. | [
30522,
2270,
11675,
26751,
1006,
2724,
2724,
1010,
2146,
2051,
5833,
1010,
2051,
19496,
2102,
3131,
1007,
11618,
7153,
10288,
24422,
1010,
2051,
5833,
10288,
24422,
1063,
2146,
2335,
15464,
2361,
1027,
2131,
7292,
9153,
8737,
1006,
2724,
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/cli/CliFrontend.java | CliFrontend.cancel | protected void cancel(String[] args) throws Exception {
LOG.info("Running 'cancel' command.");
final Options commandOptions = CliFrontendParser.getCancelCommandOptions();
final Options commandLineOptions = CliFrontendParser.mergeOptions(commandOptions, customCommandLineOptions);
final CommandLine commandLine = CliFrontendParser.parse(commandLineOptions, args, false);
CancelOptions cancelOptions = new CancelOptions(commandLine);
// evaluate help flag
if (cancelOptions.isPrintHelp()) {
CliFrontendParser.printHelpForCancel(customCommandLines);
return;
}
final CustomCommandLine<?> activeCommandLine = getActiveCustomCommandLine(commandLine);
final String[] cleanedArgs = cancelOptions.getArgs();
if (cancelOptions.isWithSavepoint()) {
final JobID jobId;
final String targetDirectory;
if (cleanedArgs.length > 0) {
jobId = parseJobId(cleanedArgs[0]);
targetDirectory = cancelOptions.getSavepointTargetDirectory();
} else {
jobId = parseJobId(cancelOptions.getSavepointTargetDirectory());
targetDirectory = null;
}
if (targetDirectory == null) {
logAndSysout("Cancelling job " + jobId + " with savepoint to default savepoint directory.");
} else {
logAndSysout("Cancelling job " + jobId + " with savepoint to " + targetDirectory + '.');
}
runClusterAction(
activeCommandLine,
commandLine,
clusterClient -> {
final String savepointPath;
try {
savepointPath = clusterClient.cancelWithSavepoint(jobId, targetDirectory);
} catch (Exception e) {
throw new FlinkException("Could not cancel job " + jobId + '.', e);
}
logAndSysout("Cancelled job " + jobId + ". Savepoint stored in " + savepointPath + '.');
});
} else {
final JobID jobId;
if (cleanedArgs.length > 0) {
jobId = parseJobId(cleanedArgs[0]);
} else {
throw new CliArgsException("Missing JobID. Specify a JobID to cancel a job.");
}
logAndSysout("Cancelling job " + jobId + '.');
runClusterAction(
activeCommandLine,
commandLine,
clusterClient -> {
try {
clusterClient.cancel(jobId);
} catch (Exception e) {
throw new FlinkException("Could not cancel job " + jobId + '.', e);
}
});
logAndSysout("Cancelled job " + jobId + '.');
}
} | java | protected void cancel(String[] args) throws Exception {
LOG.info("Running 'cancel' command.");
final Options commandOptions = CliFrontendParser.getCancelCommandOptions();
final Options commandLineOptions = CliFrontendParser.mergeOptions(commandOptions, customCommandLineOptions);
final CommandLine commandLine = CliFrontendParser.parse(commandLineOptions, args, false);
CancelOptions cancelOptions = new CancelOptions(commandLine);
// evaluate help flag
if (cancelOptions.isPrintHelp()) {
CliFrontendParser.printHelpForCancel(customCommandLines);
return;
}
final CustomCommandLine<?> activeCommandLine = getActiveCustomCommandLine(commandLine);
final String[] cleanedArgs = cancelOptions.getArgs();
if (cancelOptions.isWithSavepoint()) {
final JobID jobId;
final String targetDirectory;
if (cleanedArgs.length > 0) {
jobId = parseJobId(cleanedArgs[0]);
targetDirectory = cancelOptions.getSavepointTargetDirectory();
} else {
jobId = parseJobId(cancelOptions.getSavepointTargetDirectory());
targetDirectory = null;
}
if (targetDirectory == null) {
logAndSysout("Cancelling job " + jobId + " with savepoint to default savepoint directory.");
} else {
logAndSysout("Cancelling job " + jobId + " with savepoint to " + targetDirectory + '.');
}
runClusterAction(
activeCommandLine,
commandLine,
clusterClient -> {
final String savepointPath;
try {
savepointPath = clusterClient.cancelWithSavepoint(jobId, targetDirectory);
} catch (Exception e) {
throw new FlinkException("Could not cancel job " + jobId + '.', e);
}
logAndSysout("Cancelled job " + jobId + ". Savepoint stored in " + savepointPath + '.');
});
} else {
final JobID jobId;
if (cleanedArgs.length > 0) {
jobId = parseJobId(cleanedArgs[0]);
} else {
throw new CliArgsException("Missing JobID. Specify a JobID to cancel a job.");
}
logAndSysout("Cancelling job " + jobId + '.');
runClusterAction(
activeCommandLine,
commandLine,
clusterClient -> {
try {
clusterClient.cancel(jobId);
} catch (Exception e) {
throw new FlinkException("Could not cancel job " + jobId + '.', e);
}
});
logAndSysout("Cancelled job " + jobId + '.');
}
} | [
"protected",
"void",
"cancel",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"LOG",
".",
"info",
"(",
"\"Running 'cancel' command.\"",
")",
";",
"final",
"Options",
"commandOptions",
"=",
"CliFrontendParser",
".",
"getCancelCommandOptions",
"("... | Executes the CANCEL action.
@param args Command line arguments for the cancel action. | [
"Executes",
"the",
"CANCEL",
"action",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java#L548-L623 | train | Cancel the job with the given arguments. | [
30522,
5123,
11675,
17542,
1006,
5164,
1031,
1033,
12098,
5620,
1007,
11618,
6453,
1063,
8833,
1012,
18558,
1006,
1000,
2770,
1005,
17542,
1005,
3094,
1012,
1000,
1007,
1025,
2345,
7047,
15054,
16790,
2015,
1027,
18856,
10128,
4948,
6528,
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-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java | ConfigurationUtils.createConfiguration | @Nonnull
public static Configuration createConfiguration(Properties properties) {
final Configuration configuration = new Configuration();
final Set<String> propertyNames = properties.stringPropertyNames();
for (String propertyName : propertyNames) {
configuration.setString(propertyName, properties.getProperty(propertyName));
}
return configuration;
} | java | @Nonnull
public static Configuration createConfiguration(Properties properties) {
final Configuration configuration = new Configuration();
final Set<String> propertyNames = properties.stringPropertyNames();
for (String propertyName : propertyNames) {
configuration.setString(propertyName, properties.getProperty(propertyName));
}
return configuration;
} | [
"@",
"Nonnull",
"public",
"static",
"Configuration",
"createConfiguration",
"(",
"Properties",
"properties",
")",
"{",
"final",
"Configuration",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"final",
"Set",
"<",
"String",
">",
"propertyNames",
"=",
... | Creates a new {@link Configuration} from the given {@link Properties}.
@param properties to convert into a {@link Configuration}
@return {@link Configuration} which has been populated by the values of the given {@link Properties} | [
"Creates",
"a",
"new",
"{",
"@link",
"Configuration",
"}",
"from",
"the",
"given",
"{",
"@link",
"Properties",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java#L122-L133 | train | Creates a configuration object from the given properties. | [
30522,
1030,
2512,
11231,
3363,
2270,
10763,
9563,
3443,
8663,
8873,
27390,
3370,
1006,
5144,
5144,
1007,
1063,
2345,
9563,
9563,
1027,
2047,
9563,
1006,
1007,
1025,
2345,
2275,
1026,
5164,
1028,
3200,
18442,
2015,
1027,
5144,
1012,
5164,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-cron/src/main/java/cn/hutool/cron/Scheduler.java | Scheduler.stop | public Scheduler stop(boolean clearTasks) {
synchronized (lock) {
if (false == started) {
throw new IllegalStateException("Scheduler not started !");
}
// 停止CronTimer
this.timer.stopTimer();
this.timer = null;
//停止线程池
this.threadExecutor.shutdown();
this.threadExecutor = null;
//可选是否清空任务表
if(clearTasks) {
clear();
}
// 修改标志
started = false;
}
return this;
} | java | public Scheduler stop(boolean clearTasks) {
synchronized (lock) {
if (false == started) {
throw new IllegalStateException("Scheduler not started !");
}
// 停止CronTimer
this.timer.stopTimer();
this.timer = null;
//停止线程池
this.threadExecutor.shutdown();
this.threadExecutor = null;
//可选是否清空任务表
if(clearTasks) {
clear();
}
// 修改标志
started = false;
}
return this;
} | [
"public",
"Scheduler",
"stop",
"(",
"boolean",
"clearTasks",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"false",
"==",
"started",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Scheduler not started !\"",
")",
";",
"}",
"// 停止CronT... | 停止定时任务<br>
此方法调用后会将定时器进程立即结束,如果为守护线程模式,则正在执行的作业也会自动结束,否则作业线程将在执行完成后结束。
@return this
@since 4.1.17 | [
"停止定时任务<br",
">",
"此方法调用后会将定时器进程立即结束,如果为守护线程模式,则正在执行的作业也会自动结束,否则作业线程将在执行完成后结束。"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cron/src/main/java/cn/hutool/cron/Scheduler.java#L400-L423 | train | Stop the scheduler. | [
30522,
2270,
6134,
2099,
2644,
1006,
22017,
20898,
3154,
10230,
5705,
1007,
1063,
25549,
1006,
5843,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
2318,
1007,
1063,
5466,
2047,
6206,
9153,
17389,
2595,
24422,
1006,
1000,
6134,
2099,
2025,
2318,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/operators/base/InnerJoinOperatorBase.java | InnerJoinOperatorBase.executeOnCollections | @SuppressWarnings("unchecked")
@Override
protected List<OUT> executeOnCollections(List<IN1> inputData1, List<IN2> inputData2, RuntimeContext runtimeContext,
ExecutionConfig executionConfig) throws Exception {
FlatJoinFunction<IN1, IN2, OUT> function = userFunction.getUserCodeObject();
FunctionUtils.setFunctionRuntimeContext(function, runtimeContext);
FunctionUtils.openFunction(function, this.parameters);
TypeInformation<IN1> leftInformation = getOperatorInfo().getFirstInputType();
TypeInformation<IN2> rightInformation = getOperatorInfo().getSecondInputType();
TypeInformation<OUT> outInformation = getOperatorInfo().getOutputType();
TypeSerializer<IN1> leftSerializer = leftInformation.createSerializer(executionConfig);
TypeSerializer<IN2> rightSerializer = rightInformation.createSerializer(executionConfig);
TypeComparator<IN1> leftComparator;
TypeComparator<IN2> rightComparator;
if (leftInformation instanceof AtomicType) {
leftComparator = ((AtomicType<IN1>) leftInformation).createComparator(true, executionConfig);
} else if (leftInformation instanceof CompositeType) {
int[] keyPositions = getKeyColumns(0);
boolean[] orders = new boolean[keyPositions.length];
Arrays.fill(orders, true);
leftComparator = ((CompositeType<IN1>) leftInformation).createComparator(keyPositions, orders, 0, executionConfig);
} else {
throw new RuntimeException("Type information for left input of type " + leftInformation.getClass()
.getCanonicalName() + " is not supported. Could not generate a comparator.");
}
if (rightInformation instanceof AtomicType) {
rightComparator = ((AtomicType<IN2>) rightInformation).createComparator(true, executionConfig);
} else if (rightInformation instanceof CompositeType) {
int[] keyPositions = getKeyColumns(1);
boolean[] orders = new boolean[keyPositions.length];
Arrays.fill(orders, true);
rightComparator = ((CompositeType<IN2>) rightInformation).createComparator(keyPositions, orders, 0, executionConfig);
} else {
throw new RuntimeException("Type information for right input of type " + rightInformation.getClass()
.getCanonicalName() + " is not supported. Could not generate a comparator.");
}
TypePairComparator<IN1, IN2> pairComparator = new GenericPairComparator<IN1, IN2>(leftComparator, rightComparator);
List<OUT> result = new ArrayList<OUT>();
Collector<OUT> collector = new CopyingListCollector<OUT>(result, outInformation.createSerializer(executionConfig));
Map<Integer, List<IN2>> probeTable = new HashMap<Integer, List<IN2>>();
//Build hash table
for (IN2 element : inputData2) {
List<IN2> list = probeTable.get(rightComparator.hash(element));
if (list == null) {
list = new ArrayList<IN2>();
probeTable.put(rightComparator.hash(element), list);
}
list.add(element);
}
//Probing
for (IN1 left : inputData1) {
List<IN2> matchingHashes = probeTable.get(leftComparator.hash(left));
if (matchingHashes != null) {
pairComparator.setReference(left);
for (IN2 right : matchingHashes) {
if (pairComparator.equalToReference(right)) {
function.join(leftSerializer.copy(left), rightSerializer.copy(right), collector);
}
}
}
}
FunctionUtils.closeFunction(function);
return result;
} | java | @SuppressWarnings("unchecked")
@Override
protected List<OUT> executeOnCollections(List<IN1> inputData1, List<IN2> inputData2, RuntimeContext runtimeContext,
ExecutionConfig executionConfig) throws Exception {
FlatJoinFunction<IN1, IN2, OUT> function = userFunction.getUserCodeObject();
FunctionUtils.setFunctionRuntimeContext(function, runtimeContext);
FunctionUtils.openFunction(function, this.parameters);
TypeInformation<IN1> leftInformation = getOperatorInfo().getFirstInputType();
TypeInformation<IN2> rightInformation = getOperatorInfo().getSecondInputType();
TypeInformation<OUT> outInformation = getOperatorInfo().getOutputType();
TypeSerializer<IN1> leftSerializer = leftInformation.createSerializer(executionConfig);
TypeSerializer<IN2> rightSerializer = rightInformation.createSerializer(executionConfig);
TypeComparator<IN1> leftComparator;
TypeComparator<IN2> rightComparator;
if (leftInformation instanceof AtomicType) {
leftComparator = ((AtomicType<IN1>) leftInformation).createComparator(true, executionConfig);
} else if (leftInformation instanceof CompositeType) {
int[] keyPositions = getKeyColumns(0);
boolean[] orders = new boolean[keyPositions.length];
Arrays.fill(orders, true);
leftComparator = ((CompositeType<IN1>) leftInformation).createComparator(keyPositions, orders, 0, executionConfig);
} else {
throw new RuntimeException("Type information for left input of type " + leftInformation.getClass()
.getCanonicalName() + " is not supported. Could not generate a comparator.");
}
if (rightInformation instanceof AtomicType) {
rightComparator = ((AtomicType<IN2>) rightInformation).createComparator(true, executionConfig);
} else if (rightInformation instanceof CompositeType) {
int[] keyPositions = getKeyColumns(1);
boolean[] orders = new boolean[keyPositions.length];
Arrays.fill(orders, true);
rightComparator = ((CompositeType<IN2>) rightInformation).createComparator(keyPositions, orders, 0, executionConfig);
} else {
throw new RuntimeException("Type information for right input of type " + rightInformation.getClass()
.getCanonicalName() + " is not supported. Could not generate a comparator.");
}
TypePairComparator<IN1, IN2> pairComparator = new GenericPairComparator<IN1, IN2>(leftComparator, rightComparator);
List<OUT> result = new ArrayList<OUT>();
Collector<OUT> collector = new CopyingListCollector<OUT>(result, outInformation.createSerializer(executionConfig));
Map<Integer, List<IN2>> probeTable = new HashMap<Integer, List<IN2>>();
//Build hash table
for (IN2 element : inputData2) {
List<IN2> list = probeTable.get(rightComparator.hash(element));
if (list == null) {
list = new ArrayList<IN2>();
probeTable.put(rightComparator.hash(element), list);
}
list.add(element);
}
//Probing
for (IN1 left : inputData1) {
List<IN2> matchingHashes = probeTable.get(leftComparator.hash(left));
if (matchingHashes != null) {
pairComparator.setReference(left);
for (IN2 right : matchingHashes) {
if (pairComparator.equalToReference(right)) {
function.join(leftSerializer.copy(left), rightSerializer.copy(right), collector);
}
}
}
}
FunctionUtils.closeFunction(function);
return result;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"protected",
"List",
"<",
"OUT",
">",
"executeOnCollections",
"(",
"List",
"<",
"IN1",
">",
"inputData1",
",",
"List",
"<",
"IN2",
">",
"inputData2",
",",
"RuntimeContext",
"runtimeContext",
... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/operators/base/InnerJoinOperatorBase.java#L69-L149 | train | Execute on collections. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
1030,
2058,
15637,
5123,
2862,
1026,
2041,
1028,
15389,
2239,
26895,
18491,
2015,
1006,
2862,
1026,
1999,
2487,
1028,
7953,
2850,
2696,
2487,
1010,
2862,
1026,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java | Pattern.followedBy | public Pattern<T, T> followedBy(final String name) {
return new Pattern<>(name, this, ConsumingStrategy.SKIP_TILL_NEXT, afterMatchSkipStrategy);
} | java | public Pattern<T, T> followedBy(final String name) {
return new Pattern<>(name, this, ConsumingStrategy.SKIP_TILL_NEXT, afterMatchSkipStrategy);
} | [
"public",
"Pattern",
"<",
"T",
",",
"T",
">",
"followedBy",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"Pattern",
"<>",
"(",
"name",
",",
"this",
",",
"ConsumingStrategy",
".",
"SKIP_TILL_NEXT",
",",
"afterMatchSkipStrategy",
")",
";",
"}"
... | Appends a new pattern to the existing one. The new pattern enforces non-strict
temporal contiguity. This means that a matching event of this pattern and the
preceding matching event might be interleaved with other events which are ignored.
@param name Name of the new pattern
@return A new pattern which is appended to this one | [
"Appends",
"a",
"new",
"pattern",
"to",
"the",
"existing",
"one",
".",
"The",
"new",
"pattern",
"enforces",
"non",
"-",
"strict",
"temporal",
"contiguity",
".",
"This",
"means",
"that",
"a",
"matching",
"event",
"of",
"this",
"pattern",
"and",
"the",
"prec... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java#L290-L292 | train | Creates a pattern that matches characters followed by the given string. | [
30522,
2270,
5418,
1026,
1056,
1010,
1056,
1028,
2628,
3762,
1006,
2345,
5164,
2171,
30524,
1012,
13558,
1035,
6229,
1035,
2279,
1010,
2044,
18900,
18069,
3211,
4523,
6494,
2618,
6292,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/JSONUtil.java | JSONUtil.toBean | public static <T> T toBean(JSONObject json, Type beanType, boolean ignoreError) {
if (null == json) {
return null;
}
return json.toBean(beanType, ignoreError);
} | java | public static <T> T toBean(JSONObject json, Type beanType, boolean ignoreError) {
if (null == json) {
return null;
}
return json.toBean(beanType, ignoreError);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"toBean",
"(",
"JSONObject",
"json",
",",
"Type",
"beanType",
",",
"boolean",
"ignoreError",
")",
"{",
"if",
"(",
"null",
"==",
"json",
")",
"{",
"return",
"null",
";",
"}",
"return",
"json",
".",
"toBean",
"("... | 转为实体类对象
@param <T> Bean类型
@param json JSONObject
@param beanType 实体类对象类型
@param ignoreError 是否忽略转换错误
@return 实体类对象
@since 4.3.2 | [
"转为实体类对象"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-json/src/main/java/cn/hutool/json/JSONUtil.java#L369-L374 | train | Converts a JSON object to a bean. | [
30522,
2270,
10763,
1026,
1056,
1028,
1056,
2000,
4783,
2319,
1006,
1046,
3385,
16429,
20614,
1046,
3385,
1010,
2828,
14068,
13874,
1010,
22017,
20898,
8568,
2121,
29165,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1046,
3385,
1007,
1063,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.swap | public static Object swap(Object array, int index1, int index2) {
if (isEmpty(array)) {
throw new IllegalArgumentException("Array must not empty !");
}
Object tmp = get(array, index1);
Array.set(array, index1, Array.get(array, index2));
Array.set(array, index2, tmp);
return array;
} | java | public static Object swap(Object array, int index1, int index2) {
if (isEmpty(array)) {
throw new IllegalArgumentException("Array must not empty !");
}
Object tmp = get(array, index1);
Array.set(array, index1, Array.get(array, index2));
Array.set(array, index2, tmp);
return array;
} | [
"public",
"static",
"Object",
"swap",
"(",
"Object",
"array",
",",
"int",
"index1",
",",
"int",
"index2",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Array must not empty !\"",
")",
";",
... | 交换数组中两个位置的值
@param array 数组对象
@param index1 位置1
@param index2 位置2
@return 交换后的数组,与传入数组为同一对象
@since 4.0.7 | [
"交换数组中两个位置的值"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java#L3762-L3770 | train | Swaps the elements of the specified array at the specified positions. | [
30522,
2270,
10763,
4874,
19948,
1006,
4874,
9140,
1010,
20014,
5950,
2487,
1010,
20014,
5950,
2475,
1007,
1063,
2065,
1006,
2003,
6633,
13876,
2100,
1006,
30524,
9140,
2442,
2025,
4064,
999,
1000,
1007,
1025,
1065,
4874,
1056,
8737,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java | CommandBuilderUtils.checkNotNull | static void checkNotNull(Object o, String arg) {
if (o == null) {
throw new IllegalArgumentException(String.format("'%s' must not be null.", arg));
}
} | java | static void checkNotNull(Object o, String arg) {
if (o == null) {
throw new IllegalArgumentException(String.format("'%s' must not be null.", arg));
}
} | [
"static",
"void",
"checkNotNull",
"(",
"Object",
"o",
",",
"String",
"arg",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"'%s' must not be null.\"",
",",
"arg",
")",
")",... | Throws IllegalArgumentException if the given object is null. | [
"Throws",
"IllegalArgumentException",
"if",
"the",
"given",
"object",
"is",
"null",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java#L212-L216 | train | Check that the object is not null. | [
30522,
10763,
11675,
4638,
17048,
11231,
3363,
1006,
4874,
1051,
1010,
5164,
12098,
2290,
1007,
1063,
2065,
1006,
1051,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24422,
1006,
5164,
1012,
4289,
1006,
1000,
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... |
netty/netty | transport/src/main/java/io/netty/channel/socket/nio/ProtocolFamilyConverter.java | ProtocolFamilyConverter.convert | public static ProtocolFamily convert(InternetProtocolFamily family) {
switch (family) {
case IPv4:
return StandardProtocolFamily.INET;
case IPv6:
return StandardProtocolFamily.INET6;
default:
throw new IllegalArgumentException();
}
} | java | public static ProtocolFamily convert(InternetProtocolFamily family) {
switch (family) {
case IPv4:
return StandardProtocolFamily.INET;
case IPv6:
return StandardProtocolFamily.INET6;
default:
throw new IllegalArgumentException();
}
} | [
"public",
"static",
"ProtocolFamily",
"convert",
"(",
"InternetProtocolFamily",
"family",
")",
"{",
"switch",
"(",
"family",
")",
"{",
"case",
"IPv4",
":",
"return",
"StandardProtocolFamily",
".",
"INET",
";",
"case",
"IPv6",
":",
"return",
"StandardProtocolFamily... | Convert the {@link InternetProtocolFamily}. This MUST only be called on jdk version >= 7. | [
"Convert",
"the",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/channel/socket/nio/ProtocolFamilyConverter.java#L35-L44 | train | Convert the InternetProtocolFamily to the standard protocol family. | [
30522,
2270,
10763,
8778,
7011,
4328,
2135,
10463,
1006,
4274,
21572,
3406,
25778,
7011,
4328,
2135,
2155,
1007,
1063,
6942,
1006,
2155,
1007,
1063,
2553,
12997,
2615,
2549,
1024,
2709,
3115,
21572,
3406,
25778,
7011,
4328,
2135,
1012,
1999... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/mining/word2vec/WordVectorModel.java | WordVectorModel.analogy | public List<Map.Entry<String, Float>> analogy(String A, String B, String C, int size)
{
Vector a = storage.get(A);
Vector b = storage.get(B);
Vector c = storage.get(C);
if (a == null || b == null || c == null)
{
return Collections.emptyList();
}
List<Map.Entry<String, Float>> resultList = nearest(a.minus(b).add(c), size + 3);
ListIterator<Map.Entry<String, Float>> listIterator = resultList.listIterator();
while (listIterator.hasNext())
{
String key = listIterator.next().getKey();
if (key.equals(A) || key.equals(B) || key.equals(C))
{
listIterator.remove();
}
}
if (resultList.size() > size)
{
resultList = resultList.subList(0, size);
}
return resultList;
} | java | public List<Map.Entry<String, Float>> analogy(String A, String B, String C, int size)
{
Vector a = storage.get(A);
Vector b = storage.get(B);
Vector c = storage.get(C);
if (a == null || b == null || c == null)
{
return Collections.emptyList();
}
List<Map.Entry<String, Float>> resultList = nearest(a.minus(b).add(c), size + 3);
ListIterator<Map.Entry<String, Float>> listIterator = resultList.listIterator();
while (listIterator.hasNext())
{
String key = listIterator.next().getKey();
if (key.equals(A) || key.equals(B) || key.equals(C))
{
listIterator.remove();
}
}
if (resultList.size() > size)
{
resultList = resultList.subList(0, size);
}
return resultList;
} | [
"public",
"List",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"Float",
">",
">",
"analogy",
"(",
"String",
"A",
",",
"String",
"B",
",",
"String",
"C",
",",
"int",
"size",
")",
"{",
"Vector",
"a",
"=",
"storage",
".",
"get",
"(",
"A",
")",
";... | 返回跟 A - B + C 最相似的词语,比如 中国 - 北京 + 东京 = 日本。输入顺序按照 中国 北京 东京
@param A 做加法的词语
@param B 做减法的词语
@param C 做加法的词语
@param size topN个
@return 与(A - B + C)语义距离最近的词语及其相似度列表 | [
"返回跟",
"A",
"-",
"B",
"+",
"C",
"最相似的词语",
"比如",
"中国",
"-",
"北京",
"+",
"东京",
"=",
"日本。输入顺序按照",
"中国",
"北京",
"东京"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/mining/word2vec/WordVectorModel.java#L69-L96 | train | Analogy method for a list of tc_lang files. | [
30522,
2270,
2862,
1026,
4949,
1012,
4443,
1026,
5164,
1010,
14257,
1028,
1028,
23323,
1006,
5164,
1037,
1010,
5164,
1038,
1010,
5164,
1039,
1010,
20014,
2946,
1007,
1063,
9207,
1037,
1027,
5527,
1012,
2131,
1006,
1037,
1007,
1025,
9207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
alibaba/canal | store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java | MemoryEventStoreWithBuffer.checkFreeSlotAt | private boolean checkFreeSlotAt(final long sequence) {
final long wrapPoint = sequence - bufferSize;
final long minPoint = getMinimumGetOrAck();
if (wrapPoint > minPoint) { // 刚好追上一轮
return false;
} else {
// 在bufferSize模式上,再增加memSize控制
if (batchMode.isMemSize()) {
final long memsize = putMemSize.get() - ackMemSize.get();
if (memsize < bufferSize * bufferMemUnit) {
return true;
} else {
return false;
}
} else {
return true;
}
}
} | java | private boolean checkFreeSlotAt(final long sequence) {
final long wrapPoint = sequence - bufferSize;
final long minPoint = getMinimumGetOrAck();
if (wrapPoint > minPoint) { // 刚好追上一轮
return false;
} else {
// 在bufferSize模式上,再增加memSize控制
if (batchMode.isMemSize()) {
final long memsize = putMemSize.get() - ackMemSize.get();
if (memsize < bufferSize * bufferMemUnit) {
return true;
} else {
return false;
}
} else {
return true;
}
}
} | [
"private",
"boolean",
"checkFreeSlotAt",
"(",
"final",
"long",
"sequence",
")",
"{",
"final",
"long",
"wrapPoint",
"=",
"sequence",
"-",
"bufferSize",
";",
"final",
"long",
"minPoint",
"=",
"getMinimumGetOrAck",
"(",
")",
";",
"if",
"(",
"wrapPoint",
">",
"m... | 查询是否有空位 | [
"查询是否有空位"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java#L507-L525 | train | check free slot at. | [
30522,
2797,
22017,
20898,
4638,
23301,
14540,
17287,
2102,
1006,
2345,
2146,
5537,
1007,
1063,
2345,
2146,
10236,
8400,
1027,
5537,
1011,
17698,
5332,
4371,
1025,
2345,
2146,
8117,
8400,
1027,
2131,
25300,
27147,
18150,
6525,
3600,
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-core/src/main/java/cn/hutool/core/io/BufferUtil.java | BufferUtil.readBytes | public static byte[] readBytes(ByteBuffer buffer, int start, int end) {
byte[] bs = new byte[end - start];
System.arraycopy(buffer.array(), start, bs, 0, bs.length);
return bs;
} | java | public static byte[] readBytes(ByteBuffer buffer, int start, int end) {
byte[] bs = new byte[end - start];
System.arraycopy(buffer.array(), start, bs, 0, bs.length);
return bs;
} | [
"public",
"static",
"byte",
"[",
"]",
"readBytes",
"(",
"ByteBuffer",
"buffer",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"byte",
"[",
"]",
"bs",
"=",
"new",
"byte",
"[",
"end",
"-",
"start",
"]",
";",
"System",
".",
"arraycopy",
"(",
"buff... | 读取指定区间的数据
@param buffer {@link ByteBuffer}
@param start 开始位置
@param end 结束位置
@return bytes | [
"读取指定区间的数据"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/BufferUtil.java#L132-L136 | train | Reads a range of bytes from a ByteBuffer. | [
30522,
2270,
10763,
24880,
1031,
1033,
3191,
3762,
4570,
1006,
24880,
8569,
12494,
17698,
1010,
20014,
2707,
1010,
20014,
2203,
1007,
1063,
24880,
1031,
1033,
18667,
1027,
2047,
24880,
1031,
2203,
1011,
2707,
1033,
1025,
2291,
1012,
9140,
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/swing/RobotUtil.java | RobotUtil.captureScreen | public static File captureScreen(Rectangle screenRect, File outFile) {
ImgUtil.write(captureScreen(screenRect), outFile);
return outFile;
} | java | public static File captureScreen(Rectangle screenRect, File outFile) {
ImgUtil.write(captureScreen(screenRect), outFile);
return outFile;
} | [
"public",
"static",
"File",
"captureScreen",
"(",
"Rectangle",
"screenRect",
",",
"File",
"outFile",
")",
"{",
"ImgUtil",
".",
"write",
"(",
"captureScreen",
"(",
"screenRect",
")",
",",
"outFile",
")",
";",
"return",
"outFile",
";",
"}"
] | 截屏
@param screenRect 截屏的矩形区域
@param outFile 写出到的文件
@return 写出到的文件 | [
"截屏"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/swing/RobotUtil.java#L193-L196 | train | Capture the screen in a file. | [
30522,
2270,
10763,
5371,
19566,
24410,
1006,
28667,
23395,
3898,
2890,
6593,
1010,
5371,
2041,
8873,
2571,
1007,
1063,
10047,
27920,
4014,
1012,
4339,
1006,
19566,
24410,
1006,
3898,
2890,
6593,
1007,
1010,
2041,
8873,
2571,
1007,
1025,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-cron/src/main/java/cn/hutool/cron/TaskTable.java | TaskTable.remove | public void remove(String id) {
final Lock writeLock = lock.writeLock();
try {
writeLock.lock();
final int index = ids.indexOf(id);
if (index > -1) {
tasks.remove(index);
patterns.remove(index);
ids.remove(index);
size--;
}
} finally {
writeLock.unlock();
}
} | java | public void remove(String id) {
final Lock writeLock = lock.writeLock();
try {
writeLock.lock();
final int index = ids.indexOf(id);
if (index > -1) {
tasks.remove(index);
patterns.remove(index);
ids.remove(index);
size--;
}
} finally {
writeLock.unlock();
}
} | [
"public",
"void",
"remove",
"(",
"String",
"id",
")",
"{",
"final",
"Lock",
"writeLock",
"=",
"lock",
".",
"writeLock",
"(",
")",
";",
"try",
"{",
"writeLock",
".",
"lock",
"(",
")",
";",
"final",
"int",
"index",
"=",
"ids",
".",
"indexOf",
"(",
"i... | 移除Task
@param id Task的ID | [
"移除Task"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cron/src/main/java/cn/hutool/cron/TaskTable.java#L72-L86 | train | Removes the given entity from the list of managed entities. | [
30522,
2270,
11675,
6366,
1006,
5164,
8909,
1007,
1063,
2345,
5843,
4339,
7878,
1027,
5843,
1012,
4339,
7878,
1006,
1007,
1025,
3046,
1063,
4339,
7878,
1012,
5843,
1006,
1007,
1025,
2345,
20014,
5950,
1027,
8909,
2015,
1012,
5950,
11253,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/EscapeUtil.java | EscapeUtil.escape | public static String escape(String content) {
if (StrUtil.isBlank(content)) {
return content;
}
int i;
char j;
StringBuilder tmp = new StringBuilder();
tmp.ensureCapacity(content.length() * 6);
for (i = 0; i < content.length(); i++) {
j = content.charAt(i);
if (Character.isDigit(j) || Character.isLowerCase(j) || Character.isUpperCase(j)) {
tmp.append(j);
} else if (j < 256) {
tmp.append("%");
if (j < 16) {
tmp.append("0");
}
tmp.append(Integer.toString(j, 16));
} else {
tmp.append("%u");
tmp.append(Integer.toString(j, 16));
}
}
return tmp.toString();
} | java | public static String escape(String content) {
if (StrUtil.isBlank(content)) {
return content;
}
int i;
char j;
StringBuilder tmp = new StringBuilder();
tmp.ensureCapacity(content.length() * 6);
for (i = 0; i < content.length(); i++) {
j = content.charAt(i);
if (Character.isDigit(j) || Character.isLowerCase(j) || Character.isUpperCase(j)) {
tmp.append(j);
} else if (j < 256) {
tmp.append("%");
if (j < 16) {
tmp.append("0");
}
tmp.append(Integer.toString(j, 16));
} else {
tmp.append("%u");
tmp.append(Integer.toString(j, 16));
}
}
return tmp.toString();
} | [
"public",
"static",
"String",
"escape",
"(",
"String",
"content",
")",
"{",
"if",
"(",
"StrUtil",
".",
"isBlank",
"(",
"content",
")",
")",
"{",
"return",
"content",
";",
"}",
"int",
"i",
";",
"char",
"j",
";",
"StringBuilder",
"tmp",
"=",
"new",
"St... | Escape编码(Unicode)<br>
该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: * @ - _ + . / 。其他所有的字符都会被转义序列替换。
@param content 被转义的内容
@return 编码后的字符串 | [
"Escape编码(Unicode)<br",
">",
"该方法不会对",
"ASCII",
"字母和数字进行编码,也不会对下面这些",
"ASCII",
"标点符号进行编码:",
"*",
"@",
"-",
"_",
"+",
".",
"/",
"。其他所有的字符都会被转义序列替换。"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/EscapeUtil.java#L46-L74 | train | Escape the content of a UTF - 8 string. | [
30522,
2270,
10763,
5164,
4019,
1006,
5164,
4180,
1007,
1063,
2065,
1006,
2358,
22134,
4014,
1012,
2003,
28522,
8950,
1006,
4180,
1007,
1007,
1063,
2709,
4180,
1025,
1065,
20014,
1045,
1025,
25869,
1046,
1025,
5164,
8569,
23891,
2099,
1056,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java | CharArrayBuffer.append | public void append(final CharArrayBuffer b, final int off, final int len) {
if (b == null) {
return;
}
append(b.array, off, len);
} | java | public void append(final CharArrayBuffer b, final int off, final int len) {
if (b == null) {
return;
}
append(b.array, off, len);
} | [
"public",
"void",
"append",
"(",
"final",
"CharArrayBuffer",
"b",
",",
"final",
"int",
"off",
",",
"final",
"int",
"len",
")",
"{",
"if",
"(",
"b",
"==",
"null",
")",
"{",
"return",
";",
"}",
"append",
"(",
"b",
".",
"array",
",",
"off",
",",
"le... | Appends {@code len} chars to this buffer from the given source
buffer starting at index {@code off}. The capacity of the
destination buffer is increased, if necessary, to accommodate all
{@code len} chars.
@param b the source buffer to be appended.
@param off the index of the first char to append.
@param len the number of chars to append.
@throws IndexOutOfBoundsException if {@code off} is out of
range, {@code len} is negative, or
{@code off} + {@code len} is out of range. | [
"Appends",
"{",
"@code",
"len",
"}",
"chars",
"to",
"this",
"buffer",
"from",
"the",
"given",
"source",
"buffer",
"starting",
"at",
"index",
"{",
"@code",
"off",
"}",
".",
"The",
"capacity",
"of",
"the",
"destination",
"buffer",
"is",
"increased",
"if",
... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java#L126-L131 | train | Append a char array buffer to the end of the log. | [
30522,
2270,
11675,
10439,
10497,
1006,
2345,
25869,
2906,
9447,
8569,
12494,
1038,
1010,
2345,
20014,
2125,
1010,
2345,
20014,
18798,
1007,
1063,
2065,
1006,
1038,
1027,
1027,
19701,
1007,
1063,
2709,
1025,
1065,
10439,
10497,
1006,
1038,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/KinesisDataFetcher.java | KinesisDataFetcher.snapshotState | public HashMap<StreamShardMetadata, SequenceNumber> snapshotState() {
// this method assumes that the checkpoint lock is held
assert Thread.holdsLock(checkpointLock);
HashMap<StreamShardMetadata, SequenceNumber> stateSnapshot = new HashMap<>();
for (KinesisStreamShardState shardWithState : subscribedShardsState) {
stateSnapshot.put(shardWithState.getStreamShardMetadata(), shardWithState.getLastProcessedSequenceNum());
}
return stateSnapshot;
} | java | public HashMap<StreamShardMetadata, SequenceNumber> snapshotState() {
// this method assumes that the checkpoint lock is held
assert Thread.holdsLock(checkpointLock);
HashMap<StreamShardMetadata, SequenceNumber> stateSnapshot = new HashMap<>();
for (KinesisStreamShardState shardWithState : subscribedShardsState) {
stateSnapshot.put(shardWithState.getStreamShardMetadata(), shardWithState.getLastProcessedSequenceNum());
}
return stateSnapshot;
} | [
"public",
"HashMap",
"<",
"StreamShardMetadata",
",",
"SequenceNumber",
">",
"snapshotState",
"(",
")",
"{",
"// this method assumes that the checkpoint lock is held",
"assert",
"Thread",
".",
"holdsLock",
"(",
"checkpointLock",
")",
";",
"HashMap",
"<",
"StreamShardMetad... | Creates a snapshot of the current last processed sequence numbers of each subscribed shard.
@return state snapshot | [
"Creates",
"a",
"snapshot",
"of",
"the",
"current",
"last",
"processed",
"sequence",
"numbers",
"of",
"each",
"subscribed",
"shard",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/KinesisDataFetcher.java#L471-L480 | train | This method returns a snapshot of the state of the Kinesis stream. | [
30522,
2270,
23325,
2863,
2361,
1026,
9199,
11783,
11368,
8447,
2696,
1010,
5537,
19172,
5677,
1028,
20057,
12326,
9153,
2618,
1006,
1007,
1063,
1013,
1013,
2023,
4118,
15980,
2008,
1996,
26520,
5843,
2003,
2218,
20865,
11689,
1012,
4324,
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... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/corpus/dictionary/TFDictionary.java | TFDictionary.combine | public int combine(TFDictionary dictionary, int limit, boolean add)
{
int preSize = trie.size();
for (Map.Entry<String, TermFrequency> entry : dictionary.trie.entrySet())
{
TermFrequency termFrequency = trie.get(entry.getKey());
if (termFrequency == null)
{
trie.put(entry.getKey(), new TermFrequency(entry.getKey(), Math.min(limit, entry.getValue().getValue())));
}
else
{
if (add)
{
termFrequency.setValue(termFrequency.getValue() + Math.min(limit, entry.getValue().getValue()));
}
}
}
return trie.size() - preSize;
} | java | public int combine(TFDictionary dictionary, int limit, boolean add)
{
int preSize = trie.size();
for (Map.Entry<String, TermFrequency> entry : dictionary.trie.entrySet())
{
TermFrequency termFrequency = trie.get(entry.getKey());
if (termFrequency == null)
{
trie.put(entry.getKey(), new TermFrequency(entry.getKey(), Math.min(limit, entry.getValue().getValue())));
}
else
{
if (add)
{
termFrequency.setValue(termFrequency.getValue() + Math.min(limit, entry.getValue().getValue()));
}
}
}
return trie.size() - preSize;
} | [
"public",
"int",
"combine",
"(",
"TFDictionary",
"dictionary",
",",
"int",
"limit",
",",
"boolean",
"add",
")",
"{",
"int",
"preSize",
"=",
"trie",
".",
"size",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"TermFrequency",
">",
... | 合并自己(主词典)和某个词频词典
@param dictionary 某个词频词典
@param limit 如果该词频词典试图引入一个词语,其词频不得超过此limit(如果不需要使用limit功能,可以传入Integer.MAX_VALUE)
@param add 设为true则是词频叠加模式,否则是词频覆盖模式
@return 词条的增量 | [
"合并自己(主词典)和某个词频词典"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/corpus/dictionary/TFDictionary.java#L55-L74 | train | Combine the terms of a TFDictionary with another TFDictionary. | [
30522,
2270,
20014,
11506,
1006,
1056,
2546,
29201,
3258,
5649,
9206,
1010,
20014,
5787,
1010,
22017,
20898,
5587,
1007,
1063,
20014,
3653,
5332,
4371,
1027,
13012,
2063,
1012,
2946,
1006,
1007,
1025,
2005,
1006,
4949,
1012,
4443,
1026,
516... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/generator/GraphGeneratorUtils.java | GraphGeneratorUtils.vertexSet | public static <K, EV> DataSet<Vertex<K, NullValue>> vertexSet(DataSet<Edge<K, EV>> edges, int parallelism) {
DataSet<Vertex<K, NullValue>> vertexSet = edges
.flatMap(new EmitSrcAndTarget<>())
.setParallelism(parallelism)
.name("Emit source and target labels");
return vertexSet
.distinct()
.setCombineHint(CombineHint.HASH)
.setParallelism(parallelism)
.name("Emit vertex labels");
} | java | public static <K, EV> DataSet<Vertex<K, NullValue>> vertexSet(DataSet<Edge<K, EV>> edges, int parallelism) {
DataSet<Vertex<K, NullValue>> vertexSet = edges
.flatMap(new EmitSrcAndTarget<>())
.setParallelism(parallelism)
.name("Emit source and target labels");
return vertexSet
.distinct()
.setCombineHint(CombineHint.HASH)
.setParallelism(parallelism)
.name("Emit vertex labels");
} | [
"public",
"static",
"<",
"K",
",",
"EV",
">",
"DataSet",
"<",
"Vertex",
"<",
"K",
",",
"NullValue",
">",
">",
"vertexSet",
"(",
"DataSet",
"<",
"Edge",
"<",
"K",
",",
"EV",
">",
">",
"edges",
",",
"int",
"parallelism",
")",
"{",
"DataSet",
"<",
"... | Generates {@link Vertex vertices} present in the given set of {@link Edge}s.
@param edges source {@link DataSet} of {@link Edge}s
@param parallelism operator parallelism
@param <K> label type
@param <EV> edge value type
@return {@link DataSet} of discovered {@link Vertex vertices}
@see Graph#fromDataSet(DataSet, DataSet, ExecutionEnvironment) | [
"Generates",
"{",
"@link",
"Vertex",
"vertices",
"}",
"present",
"in",
"the",
"given",
"set",
"of",
"{",
"@link",
"Edge",
"}",
"s",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/generator/GraphGeneratorUtils.java#L106-L117 | train | Create a vertex set from a DataSet of edges. | [
30522,
2270,
10763,
1026,
1047,
1010,
23408,
1028,
2951,
13462,
1026,
19449,
1026,
1047,
1010,
19701,
10175,
5657,
1028,
1028,
19449,
13462,
1006,
2951,
13462,
1026,
3341,
1026,
1047,
1010,
23408,
1028,
1028,
7926,
1010,
20014,
5903,
2964,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/web/servlet/error/BasicErrorController.java | BasicErrorController.isIncludeStackTrace | protected boolean isIncludeStackTrace(HttpServletRequest request,
MediaType produces) {
IncludeStacktrace include = getErrorProperties().getIncludeStacktrace();
if (include == IncludeStacktrace.ALWAYS) {
return true;
}
if (include == IncludeStacktrace.ON_TRACE_PARAM) {
return getTraceParameter(request);
}
return false;
} | java | protected boolean isIncludeStackTrace(HttpServletRequest request,
MediaType produces) {
IncludeStacktrace include = getErrorProperties().getIncludeStacktrace();
if (include == IncludeStacktrace.ALWAYS) {
return true;
}
if (include == IncludeStacktrace.ON_TRACE_PARAM) {
return getTraceParameter(request);
}
return false;
} | [
"protected",
"boolean",
"isIncludeStackTrace",
"(",
"HttpServletRequest",
"request",
",",
"MediaType",
"produces",
")",
"{",
"IncludeStacktrace",
"include",
"=",
"getErrorProperties",
"(",
")",
".",
"getIncludeStacktrace",
"(",
")",
";",
"if",
"(",
"include",
"==",
... | Determine if the stacktrace attribute should be included.
@param request the source request
@param produces the media type produced (or {@code MediaType.ALL})
@return if the stacktrace attribute should be included | [
"Determine",
"if",
"the",
"stacktrace",
"attribute",
"should",
"be",
"included",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java#L110-L120 | train | Returns true if the stacktrace should be included in the error message. | [
30522,
5123,
22017,
20898,
2003,
2378,
20464,
22087,
2696,
3600,
6494,
3401,
1006,
16770,
2121,
2615,
7485,
2890,
15500,
5227,
1010,
2865,
13874,
7137,
1007,
1063,
2950,
2696,
3600,
6494,
3401,
2421,
1027,
2131,
2121,
29165,
21572,
4842,
73... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/IdcardUtil.java | IdcardUtil.isValidCard10 | public static String[] isValidCard10(String idCard) {
if(StrUtil.isBlank(idCard)) {
return null;
}
String[] info = new String[3];
String card = idCard.replaceAll("[\\(|\\)]", "");
if (card.length() != 8 && card.length() != 9 && idCard.length() != 10) {
return null;
}
if (idCard.matches("^[a-zA-Z][0-9]{9}$")) { // 台湾
info[0] = "台湾";
String char2 = idCard.substring(1, 2);
if (char2.equals("1")) {
info[1] = "M";
} else if (char2.equals("2")) {
info[1] = "F";
} else {
info[1] = "N";
info[2] = "false";
return info;
}
info[2] = isValidTWCard(idCard) ? "true" : "false";
} else if (idCard.matches("^[1|5|7][0-9]{6}\\(?[0-9A-Z]\\)?$")) { // 澳门
info[0] = "澳门";
info[1] = "N";
} else if (idCard.matches("^[A-Z]{1,2}[0-9]{6}\\(?[0-9A]\\)?$")) { // 香港
info[0] = "香港";
info[1] = "N";
info[2] = isValidHKCard(idCard) ? "true" : "false";
} else {
return null;
}
return info;
} | java | public static String[] isValidCard10(String idCard) {
if(StrUtil.isBlank(idCard)) {
return null;
}
String[] info = new String[3];
String card = idCard.replaceAll("[\\(|\\)]", "");
if (card.length() != 8 && card.length() != 9 && idCard.length() != 10) {
return null;
}
if (idCard.matches("^[a-zA-Z][0-9]{9}$")) { // 台湾
info[0] = "台湾";
String char2 = idCard.substring(1, 2);
if (char2.equals("1")) {
info[1] = "M";
} else if (char2.equals("2")) {
info[1] = "F";
} else {
info[1] = "N";
info[2] = "false";
return info;
}
info[2] = isValidTWCard(idCard) ? "true" : "false";
} else if (idCard.matches("^[1|5|7][0-9]{6}\\(?[0-9A-Z]\\)?$")) { // 澳门
info[0] = "澳门";
info[1] = "N";
} else if (idCard.matches("^[A-Z]{1,2}[0-9]{6}\\(?[0-9A]\\)?$")) { // 香港
info[0] = "香港";
info[1] = "N";
info[2] = isValidHKCard(idCard) ? "true" : "false";
} else {
return null;
}
return info;
} | [
"public",
"static",
"String",
"[",
"]",
"isValidCard10",
"(",
"String",
"idCard",
")",
"{",
"if",
"(",
"StrUtil",
".",
"isBlank",
"(",
"idCard",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"[",
"]",
"info",
"=",
"new",
"String",
"[",
"3",
... | 验证10位身份编码是否合法
@param idCard 身份编码
@return 身份证信息数组
<p>
[0] - 台湾、澳门、香港 [1] - 性别(男M,女F,未知N) [2] - 是否合法(合法true,不合法false) 若不是身份证件号码则返回null
</p> | [
"验证10位身份编码是否合法"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/IdcardUtil.java#L267-L300 | train | Returns an array of strings if the given ID card is a valid ID card 10. | [
30522,
2270,
10763,
5164,
1031,
1033,
2003,
10175,
3593,
11522,
10790,
1006,
5164,
8909,
11522,
1007,
1063,
2065,
1006,
2358,
22134,
4014,
1012,
2003,
28522,
8950,
1006,
8909,
11522,
1007,
1007,
1063,
2709,
19701,
1025,
1065,
5164,
1031,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java | DateUtil.formatDate | public static String formatDate(Date date) {
if (null == date) {
return null;
}
return DatePattern.NORM_DATE_FORMAT.format(date);
} | java | public static String formatDate(Date date) {
if (null == date) {
return null;
}
return DatePattern.NORM_DATE_FORMAT.format(date);
} | [
"public",
"static",
"String",
"formatDate",
"(",
"Date",
"date",
")",
"{",
"if",
"(",
"null",
"==",
"date",
")",
"{",
"return",
"null",
";",
"}",
"return",
"DatePattern",
".",
"NORM_DATE_FORMAT",
".",
"format",
"(",
"date",
")",
";",
"}"
] | 格式化日期部分(不包括时间)<br>
格式 yyyy-MM-dd
@param date 被格式化的日期
@return 格式化后的字符串 | [
"格式化日期部分(不包括时间)<br",
">",
"格式",
"yyyy",
"-",
"MM",
"-",
"dd"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L521-L526 | train | Format a date object to be used in a SQL statement. | [
30522,
2270,
10763,
5164,
4289,
13701,
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,
1035,
4289,
1012,
4289,
1006,
3058,
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... |
networknt/light-4j | client/src/main/java/com/networknt/client/oauth/OauthHelper.java | OauthHelper.getSignResult | public static Result<TokenResponse> getSignResult(SignRequest signRequest, String envTag) {
final AtomicReference<Result<TokenResponse>> reference = new AtomicReference<>();
final Http2Client client = Http2Client.getInstance();
final CountDownLatch latch = new CountDownLatch(1);
final ClientConnection connection;
try {
if(signRequest.getServerUrl() != null) {
connection = client.connect(new URI(signRequest.getServerUrl()), Http2Client.WORKER, Http2Client.SSL, Http2Client.BUFFER_POOL, signRequest.enableHttp2 ? OptionMap.create(UndertowOptions.ENABLE_HTTP2, true): OptionMap.EMPTY).get();
} else if(signRequest.getServiceId() != null) {
Cluster cluster = SingletonServiceFactory.getBean(Cluster.class);
String url = cluster.serviceToUrl("https", signRequest.getServiceId(), envTag, null);
connection = client.connect(new URI(url), Http2Client.WORKER, Http2Client.SSL, Http2Client.BUFFER_POOL, signRequest.enableHttp2 ? OptionMap.create(UndertowOptions.ENABLE_HTTP2, true): OptionMap.EMPTY).get();
} else {
// both server_url and serviceId are empty in the config.
logger.error("Error: both server_url and serviceId are not configured in client.yml for " + signRequest.getClass());
throw new ClientException("both server_url and serviceId are not configured in client.yml for " + signRequest.getClass());
}
} catch (Exception e) {
logger.error("cannot establish connection:", e);
return Failure.of(new Status(ESTABLISH_CONNECTION_ERROR, signRequest.getServerUrl() != null ? signRequest.getServerUrl() : signRequest.getServiceId()));
}
try {
Map<String, Object> map = new HashMap<>();
map.put("expires", signRequest.getExpires());
map.put("payload", signRequest.getPayload());
String requestBody = Config.getInstance().getMapper().writeValueAsString(map);
connection.getIoThread().execute(() -> {
final ClientRequest request = new ClientRequest().setMethod(Methods.POST).setPath(signRequest.getUri());
request.getRequestHeaders().put(Headers.HOST, "localhost");
request.getRequestHeaders().put(Headers.TRANSFER_ENCODING, "chunked");
request.getRequestHeaders().put(Headers.CONTENT_TYPE, "application/x-www-form-urlencoded");
request.getRequestHeaders().put(Headers.AUTHORIZATION, getBasicAuthHeader(signRequest.getClientId(), signRequest.getClientSecret()));
connection.sendRequest(request, new ClientCallback<ClientExchange>() {
@Override
public void completed(ClientExchange result) {
new StringWriteChannelListener(requestBody).setup(result.getRequestChannel());
result.setResponseListener(new ClientCallback<ClientExchange>() {
@Override
public void completed(ClientExchange result) {
new StringReadChannelListener(Http2Client.BUFFER_POOL) {
@Override
protected void stringDone(String string) {
logger.debug("getToken response = " + string);
reference.set(handleResponse(getContentTypeFromExchange(result), string));
latch.countDown();
}
@Override
protected void error(IOException e) {
logger.error("IOException:", e);
reference.set(Failure.of(new Status(FAIL_TO_SEND_REQUEST)));
latch.countDown();
}
}.setup(result.getResponseChannel());
}
@Override
public void failed(IOException e) {
logger.error("IOException:", e);
reference.set(Failure.of(new Status(FAIL_TO_SEND_REQUEST)));
latch.countDown();
}
});
}
@Override
public void failed(IOException e) {
logger.error("IOException:", e);
reference.set(Failure.of(new Status(FAIL_TO_SEND_REQUEST)));
latch.countDown();
}
});
});
latch.await(signRequest.getTimeout(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
logger.error("IOException: ", e);
return Failure.of(new Status(FAIL_TO_SEND_REQUEST));
} finally {
IoUtils.safeClose(connection);
}
//if reference.get() is null at this point, mostly likely couldn't get token within latch.await() timeout.
return reference.get() == null ? Failure.of(new Status(GET_TOKEN_TIMEOUT)) : reference.get();
} | java | public static Result<TokenResponse> getSignResult(SignRequest signRequest, String envTag) {
final AtomicReference<Result<TokenResponse>> reference = new AtomicReference<>();
final Http2Client client = Http2Client.getInstance();
final CountDownLatch latch = new CountDownLatch(1);
final ClientConnection connection;
try {
if(signRequest.getServerUrl() != null) {
connection = client.connect(new URI(signRequest.getServerUrl()), Http2Client.WORKER, Http2Client.SSL, Http2Client.BUFFER_POOL, signRequest.enableHttp2 ? OptionMap.create(UndertowOptions.ENABLE_HTTP2, true): OptionMap.EMPTY).get();
} else if(signRequest.getServiceId() != null) {
Cluster cluster = SingletonServiceFactory.getBean(Cluster.class);
String url = cluster.serviceToUrl("https", signRequest.getServiceId(), envTag, null);
connection = client.connect(new URI(url), Http2Client.WORKER, Http2Client.SSL, Http2Client.BUFFER_POOL, signRequest.enableHttp2 ? OptionMap.create(UndertowOptions.ENABLE_HTTP2, true): OptionMap.EMPTY).get();
} else {
// both server_url and serviceId are empty in the config.
logger.error("Error: both server_url and serviceId are not configured in client.yml for " + signRequest.getClass());
throw new ClientException("both server_url and serviceId are not configured in client.yml for " + signRequest.getClass());
}
} catch (Exception e) {
logger.error("cannot establish connection:", e);
return Failure.of(new Status(ESTABLISH_CONNECTION_ERROR, signRequest.getServerUrl() != null ? signRequest.getServerUrl() : signRequest.getServiceId()));
}
try {
Map<String, Object> map = new HashMap<>();
map.put("expires", signRequest.getExpires());
map.put("payload", signRequest.getPayload());
String requestBody = Config.getInstance().getMapper().writeValueAsString(map);
connection.getIoThread().execute(() -> {
final ClientRequest request = new ClientRequest().setMethod(Methods.POST).setPath(signRequest.getUri());
request.getRequestHeaders().put(Headers.HOST, "localhost");
request.getRequestHeaders().put(Headers.TRANSFER_ENCODING, "chunked");
request.getRequestHeaders().put(Headers.CONTENT_TYPE, "application/x-www-form-urlencoded");
request.getRequestHeaders().put(Headers.AUTHORIZATION, getBasicAuthHeader(signRequest.getClientId(), signRequest.getClientSecret()));
connection.sendRequest(request, new ClientCallback<ClientExchange>() {
@Override
public void completed(ClientExchange result) {
new StringWriteChannelListener(requestBody).setup(result.getRequestChannel());
result.setResponseListener(new ClientCallback<ClientExchange>() {
@Override
public void completed(ClientExchange result) {
new StringReadChannelListener(Http2Client.BUFFER_POOL) {
@Override
protected void stringDone(String string) {
logger.debug("getToken response = " + string);
reference.set(handleResponse(getContentTypeFromExchange(result), string));
latch.countDown();
}
@Override
protected void error(IOException e) {
logger.error("IOException:", e);
reference.set(Failure.of(new Status(FAIL_TO_SEND_REQUEST)));
latch.countDown();
}
}.setup(result.getResponseChannel());
}
@Override
public void failed(IOException e) {
logger.error("IOException:", e);
reference.set(Failure.of(new Status(FAIL_TO_SEND_REQUEST)));
latch.countDown();
}
});
}
@Override
public void failed(IOException e) {
logger.error("IOException:", e);
reference.set(Failure.of(new Status(FAIL_TO_SEND_REQUEST)));
latch.countDown();
}
});
});
latch.await(signRequest.getTimeout(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
logger.error("IOException: ", e);
return Failure.of(new Status(FAIL_TO_SEND_REQUEST));
} finally {
IoUtils.safeClose(connection);
}
//if reference.get() is null at this point, mostly likely couldn't get token within latch.await() timeout.
return reference.get() == null ? Failure.of(new Status(GET_TOKEN_TIMEOUT)) : reference.get();
} | [
"public",
"static",
"Result",
"<",
"TokenResponse",
">",
"getSignResult",
"(",
"SignRequest",
"signRequest",
",",
"String",
"envTag",
")",
"{",
"final",
"AtomicReference",
"<",
"Result",
"<",
"TokenResponse",
">",
">",
"reference",
"=",
"new",
"AtomicReference",
... | Get a signed JWT token from token service to ensure that nobody can modify the payload when the token
is passed from service to service. Unlike the access JWT token, this token is ensure the data integrity
with signature.
@param signRequest SignRequest that is constructed from the client.yml sign section
@param envTag environment tag that is used for service lookup if serviceId is used.
@return Result that contains TokenResponse or error status when failed. | [
"Get",
"a",
"signed",
"JWT",
"token",
"from",
"token",
"service",
"to",
"ensure",
"that",
"nobody",
"can",
"modify",
"the",
"payload",
"when",
"the",
"token",
"is",
"passed",
"from",
"service",
"to",
"service",
".",
"Unlike",
"the",
"access",
"JWT",
"token... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/oauth/OauthHelper.java#L165-L252 | train | Get the result of the authentication process. | [
30522,
2270,
10763,
2765,
1026,
19204,
6072,
26029,
3366,
1028,
4152,
23773,
6072,
11314,
1006,
3696,
2890,
15500,
3696,
2890,
15500,
1010,
5164,
4372,
2615,
15900,
1007,
1063,
2345,
9593,
2890,
25523,
1026,
2765,
1026,
19204,
6072,
26029,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java | URLUtil.toURI | public static URI toURI(String location) throws UtilException {
try {
return new URI(location.replace(" ", "%20"));
} catch (URISyntaxException e) {
throw new UtilException(e);
}
} | java | public static URI toURI(String location) throws UtilException {
try {
return new URI(location.replace(" ", "%20"));
} catch (URISyntaxException e) {
throw new UtilException(e);
}
} | [
"public",
"static",
"URI",
"toURI",
"(",
"String",
"location",
")",
"throws",
"UtilException",
"{",
"try",
"{",
"return",
"new",
"URI",
"(",
"location",
".",
"replace",
"(",
"\" \"",
",",
"\"%20\"",
")",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
... | 转字符串为URI
@param location 字符串路径
@return URI
@exception UtilException 包装URISyntaxException | [
"转字符串为URI"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java#L450-L456 | train | Create a URI from a string. | [
30522,
2270,
10763,
24471,
2072,
2778,
2072,
1006,
5164,
3295,
1007,
11618,
21183,
9463,
2595,
24422,
1063,
3046,
1063,
2709,
2047,
24471,
2072,
1006,
3295,
1012,
5672,
1006,
1000,
1000,
1010,
1000,
1003,
2322,
1000,
1007,
1007,
1025,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | buffer/src/main/java/io/netty/buffer/ByteBufUtil.java | ByteBufUtil.writeAscii | public static int writeAscii(ByteBuf buf, CharSequence seq) {
// ASCII uses 1 byte per char
final int len = seq.length();
if (seq instanceof AsciiString) {
AsciiString asciiString = (AsciiString) seq;
buf.writeBytes(asciiString.array(), asciiString.arrayOffset(), len);
} else {
for (;;) {
if (buf instanceof WrappedCompositeByteBuf) {
// WrappedCompositeByteBuf is a sub-class of AbstractByteBuf so it needs special handling.
buf = buf.unwrap();
} else if (buf instanceof AbstractByteBuf) {
AbstractByteBuf byteBuf = (AbstractByteBuf) buf;
byteBuf.ensureWritable0(len);
int written = writeAscii(byteBuf, byteBuf.writerIndex, seq, len);
byteBuf.writerIndex += written;
return written;
} else if (buf instanceof WrappedByteBuf) {
// Unwrap as the wrapped buffer may be an AbstractByteBuf and so we can use fast-path.
buf = buf.unwrap();
} else {
byte[] bytes = seq.toString().getBytes(CharsetUtil.US_ASCII);
buf.writeBytes(bytes);
return bytes.length;
}
}
}
return len;
} | java | public static int writeAscii(ByteBuf buf, CharSequence seq) {
// ASCII uses 1 byte per char
final int len = seq.length();
if (seq instanceof AsciiString) {
AsciiString asciiString = (AsciiString) seq;
buf.writeBytes(asciiString.array(), asciiString.arrayOffset(), len);
} else {
for (;;) {
if (buf instanceof WrappedCompositeByteBuf) {
// WrappedCompositeByteBuf is a sub-class of AbstractByteBuf so it needs special handling.
buf = buf.unwrap();
} else if (buf instanceof AbstractByteBuf) {
AbstractByteBuf byteBuf = (AbstractByteBuf) buf;
byteBuf.ensureWritable0(len);
int written = writeAscii(byteBuf, byteBuf.writerIndex, seq, len);
byteBuf.writerIndex += written;
return written;
} else if (buf instanceof WrappedByteBuf) {
// Unwrap as the wrapped buffer may be an AbstractByteBuf and so we can use fast-path.
buf = buf.unwrap();
} else {
byte[] bytes = seq.toString().getBytes(CharsetUtil.US_ASCII);
buf.writeBytes(bytes);
return bytes.length;
}
}
}
return len;
} | [
"public",
"static",
"int",
"writeAscii",
"(",
"ByteBuf",
"buf",
",",
"CharSequence",
"seq",
")",
"{",
"// ASCII uses 1 byte per char",
"final",
"int",
"len",
"=",
"seq",
".",
"length",
"(",
")",
";",
"if",
"(",
"seq",
"instanceof",
"AsciiString",
")",
"{",
... | Encode a {@link CharSequence} in <a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> and write it
to a {@link ByteBuf}.
This method returns the actual number of bytes written. | [
"Encode",
"a",
"{",
"@link",
"CharSequence",
"}",
"in",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"ASCII",
">",
"ASCII<",
"/",
"a",
">",
"and",
"write",
"it",
"to",
"a",
"{",
"@link",
"ByteBuf",
"... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java#L681-L709 | train | Write ASCII to a buffer. | [
30522,
2270,
10763,
20014,
4339,
3022,
6895,
2072,
1006,
24880,
8569,
2546,
20934,
2546,
1010,
25869,
3366,
4226,
5897,
7367,
4160,
1007,
1063,
1013,
1013,
2004,
6895,
2072,
3594,
1015,
24880,
2566,
25869,
2345,
20014,
18798,
1027,
7367,
41... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java | AbstractTrafficShapingHandler.checkWriteSuspend | void checkWriteSuspend(ChannelHandlerContext ctx, long delay, long queueSize) {
if (queueSize > maxWriteSize || delay > maxWriteDelay) {
setUserDefinedWritability(ctx, false);
}
} | java | void checkWriteSuspend(ChannelHandlerContext ctx, long delay, long queueSize) {
if (queueSize > maxWriteSize || delay > maxWriteDelay) {
setUserDefinedWritability(ctx, false);
}
} | [
"void",
"checkWriteSuspend",
"(",
"ChannelHandlerContext",
"ctx",
",",
"long",
"delay",
",",
"long",
"queueSize",
")",
"{",
"if",
"(",
"queueSize",
">",
"maxWriteSize",
"||",
"delay",
">",
"maxWriteDelay",
")",
"{",
"setUserDefinedWritability",
"(",
"ctx",
",",
... | Check the writability according to delay and size for the channel.
Set if necessary setUserDefinedWritability status.
@param delay the computed delay
@param queueSize the current queueSize | [
"Check",
"the",
"writability",
"according",
"to",
"delay",
"and",
"size",
"for",
"the",
"channel",
".",
"Set",
"if",
"necessary",
"setUserDefinedWritability",
"status",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java#L597-L601 | train | Check if write suspend is allowed. | [
30522,
11675,
4638,
26373,
13203,
11837,
2094,
1006,
3149,
11774,
3917,
8663,
18209,
14931,
2595,
1010,
2146,
8536,
1010,
2146,
24240,
5332,
4371,
1007,
1063,
2065,
1006,
24240,
5332,
4371,
1028,
4098,
26373,
5332,
4371,
1064,
1064,
8536,
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-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/SingleOutputStreamOperator.java | SingleOutputStreamOperator.returns | public SingleOutputStreamOperator<T> returns(TypeInformation<T> typeInfo) {
requireNonNull(typeInfo, "TypeInformation must not be null");
transformation.setOutputType(typeInfo);
return this;
} | java | public SingleOutputStreamOperator<T> returns(TypeInformation<T> typeInfo) {
requireNonNull(typeInfo, "TypeInformation must not be null");
transformation.setOutputType(typeInfo);
return this;
} | [
"public",
"SingleOutputStreamOperator",
"<",
"T",
">",
"returns",
"(",
"TypeInformation",
"<",
"T",
">",
"typeInfo",
")",
"{",
"requireNonNull",
"(",
"typeInfo",
",",
"\"TypeInformation must not be null\"",
")",
";",
"transformation",
".",
"setOutputType",
"(",
"typ... | Adds a type information hint about the return type of this operator. This method
can be used in cases where Flink cannot determine automatically what the produced
type of a function is. That can be the case if the function uses generic type variables
in the return type that cannot be inferred from the input type.
<p>In most cases, the methods {@link #returns(Class)} and {@link #returns(TypeHint)}
are preferable.
@param typeInfo type information as a return type hint
@return This operator with a given return type hint. | [
"Adds",
"a",
"type",
"information",
"hint",
"about",
"the",
"return",
"type",
"of",
"this",
"operator",
".",
"This",
"method",
"can",
"be",
"used",
"in",
"cases",
"where",
"Flink",
"cannot",
"determine",
"automatically",
"what",
"the",
"produced",
"type",
"o... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/SingleOutputStreamOperator.java#L362-L367 | train | Sets the output type of the operator. | [
30522,
2270,
2309,
5833,
18780,
21422,
25918,
8844,
1026,
1056,
1028,
5651,
1006,
2828,
2378,
14192,
3370,
1026,
1056,
1028,
2828,
2378,
14876,
1007,
1063,
5478,
8540,
11231,
3363,
1006,
2828,
2378,
14876,
1010,
1000,
2828,
2378,
14192,
337... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.setCharset | public SoapClient setCharset(Charset charset) {
this.charset = charset;
try {
this.message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, this.charset.toString());
this.message.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
} catch (SOAPException e) {
// ignore
}
return this;
} | java | public SoapClient setCharset(Charset charset) {
this.charset = charset;
try {
this.message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, this.charset.toString());
this.message.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
} catch (SOAPException e) {
// ignore
}
return this;
} | [
"public",
"SoapClient",
"setCharset",
"(",
"Charset",
"charset",
")",
"{",
"this",
".",
"charset",
"=",
"charset",
";",
"try",
"{",
"this",
".",
"message",
".",
"setProperty",
"(",
"SOAPMessage",
".",
"CHARACTER_SET_ENCODING",
",",
"this",
".",
"charset",
".... | 设置编码
@param charset 编码
@return this | [
"设置编码"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/webservice/SoapClient.java#L147-L157 | train | Sets the character set encoding for the SOAP message. | [
30522,
2270,
7815,
20464,
11638,
2275,
7507,
22573,
2102,
1006,
25869,
13462,
25869,
13462,
1007,
1063,
30524,
1006,
7815,
7834,
3736,
3351,
1012,
2839,
1035,
2275,
1035,
17181,
1010,
2023,
1012,
25869,
13462,
1012,
2000,
3367,
4892,
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-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/AbstractBinaryWriter.java | AbstractBinaryWriter.writeString | @Override
public void writeString(int pos, BinaryString input) {
if (input.getSegments() == null) {
String javaObject = input.getJavaObject();
writeBytes(pos, javaObject.getBytes());
} else {
int len = input.getSizeInBytes();
if (len <= 7) {
byte[] bytes = SegmentsUtil.allocateReuseBytes(len);
SegmentsUtil.copyToBytes(input.getSegments(), input.getOffset(), bytes, 0, len);
writeBytesToFixLenPart(segment, getFieldOffset(pos), bytes, len);
} else {
writeSegmentsToVarLenPart(pos, input.getSegments(), input.getOffset(), len);
}
}
} | java | @Override
public void writeString(int pos, BinaryString input) {
if (input.getSegments() == null) {
String javaObject = input.getJavaObject();
writeBytes(pos, javaObject.getBytes());
} else {
int len = input.getSizeInBytes();
if (len <= 7) {
byte[] bytes = SegmentsUtil.allocateReuseBytes(len);
SegmentsUtil.copyToBytes(input.getSegments(), input.getOffset(), bytes, 0, len);
writeBytesToFixLenPart(segment, getFieldOffset(pos), bytes, len);
} else {
writeSegmentsToVarLenPart(pos, input.getSegments(), input.getOffset(), len);
}
}
} | [
"@",
"Override",
"public",
"void",
"writeString",
"(",
"int",
"pos",
",",
"BinaryString",
"input",
")",
"{",
"if",
"(",
"input",
".",
"getSegments",
"(",
")",
"==",
"null",
")",
"{",
"String",
"javaObject",
"=",
"input",
".",
"getJavaObject",
"(",
")",
... | See {@link BinaryString#readBinaryStringFieldFromSegments}. | [
"See",
"{"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/AbstractBinaryWriter.java#L72-L87 | train | Write a string to the stream. | [
30522,
1030,
2058,
15637,
2270,
11675,
7009,
18886,
3070,
1006,
20014,
13433,
2015,
1010,
12441,
3367,
4892,
7953,
1007,
1063,
2065,
1006,
7953,
1012,
4152,
13910,
8163,
1006,
1007,
1027,
1027,
19701,
1007,
1063,
5164,
9262,
16429,
20614,
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/runtime/clusterframework/store/ZooKeeperMesosWorkerStore.java | ZooKeeperMesosWorkerStore.setFrameworkID | @Override
public void setFrameworkID(Option<Protos.FrameworkID> frameworkID) throws Exception {
synchronized (startStopLock) {
verifyIsRunning();
byte[] value = frameworkID.isDefined() ? frameworkID.get().getValue().getBytes(ConfigConstants.DEFAULT_CHARSET) :
new byte[0];
frameworkIdInZooKeeper.setValue(value);
}
} | java | @Override
public void setFrameworkID(Option<Protos.FrameworkID> frameworkID) throws Exception {
synchronized (startStopLock) {
verifyIsRunning();
byte[] value = frameworkID.isDefined() ? frameworkID.get().getValue().getBytes(ConfigConstants.DEFAULT_CHARSET) :
new byte[0];
frameworkIdInZooKeeper.setValue(value);
}
} | [
"@",
"Override",
"public",
"void",
"setFrameworkID",
"(",
"Option",
"<",
"Protos",
".",
"FrameworkID",
">",
"frameworkID",
")",
"throws",
"Exception",
"{",
"synchronized",
"(",
"startStopLock",
")",
"{",
"verifyIsRunning",
"(",
")",
";",
"byte",
"[",
"]",
"v... | Update the persisted framework ID.
@param frameworkID the new ID or empty to remove the persisted ID.
@throws Exception on ZK failures, interruptions. | [
"Update",
"the",
"persisted",
"framework",
"ID",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/store/ZooKeeperMesosWorkerStore.java#L136-L145 | train | Set the framework ID in ZooKeeper. | [
30522,
1030,
2058,
15637,
2270,
11675,
2275,
15643,
6198,
3593,
1006,
5724,
1026,
15053,
2015,
1012,
30524,
1012,
2003,
3207,
23460,
2094,
1006,
1007,
1029,
7705,
3593,
1012,
2131,
1006,
1007,
1012,
2131,
10175,
5657,
1006,
1007,
1012,
2131... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannelConfig.java | EpollDatagramChannelConfig.setFreeBind | public EpollDatagramChannelConfig setFreeBind(boolean freeBind) {
try {
((EpollDatagramChannel) channel).socket.setIpFreeBind(freeBind);
return this;
} catch (IOException e) {
throw new ChannelException(e);
}
} | java | public EpollDatagramChannelConfig setFreeBind(boolean freeBind) {
try {
((EpollDatagramChannel) channel).socket.setIpFreeBind(freeBind);
return this;
} catch (IOException e) {
throw new ChannelException(e);
}
} | [
"public",
"EpollDatagramChannelConfig",
"setFreeBind",
"(",
"boolean",
"freeBind",
")",
"{",
"try",
"{",
"(",
"(",
"EpollDatagramChannel",
")",
"channel",
")",
".",
"socket",
".",
"setIpFreeBind",
"(",
"freeBind",
")",
";",
"return",
"this",
";",
"}",
"catch",... | If {@code true} is used <a href="http://man7.org/linux/man-pages/man7/ip.7.html">IP_FREEBIND</a> is enabled,
{@code false} for disable it. Default is disabled. | [
"If",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannelConfig.java#L431-L438 | train | Sets the freeBind flag. | [
30522,
2270,
4958,
14511,
2850,
23091,
26058,
8663,
8873,
2290,
2275,
23301,
8428,
2094,
1006,
22017,
20898,
2489,
8428,
2094,
1007,
1063,
3046,
1063,
1006,
1006,
4958,
14511,
2850,
23091,
26058,
1007,
3149,
1007,
1012,
22278,
1012,
2275,
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/utility/TextUtility.java | TextUtility.count | public static int count(String keyword, String srcText)
{
int count = 0;
int leng = srcText.length();
int j = 0;
for (int i = 0; i < leng; i++)
{
if (srcText.charAt(i) == keyword.charAt(j))
{
j++;
if (j == keyword.length())
{
count++;
j = 0;
}
}
else
{
i = i - j;// should rollback when not match
j = 0;
}
}
return count;
} | java | public static int count(String keyword, String srcText)
{
int count = 0;
int leng = srcText.length();
int j = 0;
for (int i = 0; i < leng; i++)
{
if (srcText.charAt(i) == keyword.charAt(j))
{
j++;
if (j == keyword.length())
{
count++;
j = 0;
}
}
else
{
i = i - j;// should rollback when not match
j = 0;
}
}
return count;
} | [
"public",
"static",
"int",
"count",
"(",
"String",
"keyword",
",",
"String",
"srcText",
")",
"{",
"int",
"count",
"=",
"0",
";",
"int",
"leng",
"=",
"srcText",
".",
"length",
"(",
")",
";",
"int",
"j",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
... | 统计 keyword 在 srcText 中的出现次数
@param keyword
@param srcText
@return | [
"统计",
"keyword",
"在",
"srcText",
"中的出现次数"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/utility/TextUtility.java#L599-L623 | train | Count the number of matches in a source text. | [
30522,
2270,
10763,
20014,
4175,
1006,
5164,
3145,
18351,
1010,
5164,
5034,
6593,
10288,
2102,
1007,
1063,
20014,
4175,
1027,
1014,
1025,
20014,
18798,
2290,
1027,
5034,
6593,
10288,
2102,
1012,
3091,
1006,
1007,
1025,
20014,
1046,
1027,
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-db/src/main/java/cn/hutool/db/dialect/impl/AnsiSqlDialect.java | AnsiSqlDialect.wrapPageSql | protected SqlBuilder wrapPageSql(SqlBuilder find, Page page) {
// limit A offset B 表示:A就是你需要多少行,B就是查询的起点位置。
return find.append(" limit ").append(page.getPageSize()).append(" offset ").append(page.getStartPosition());
} | java | protected SqlBuilder wrapPageSql(SqlBuilder find, Page page) {
// limit A offset B 表示:A就是你需要多少行,B就是查询的起点位置。
return find.append(" limit ").append(page.getPageSize()).append(" offset ").append(page.getStartPosition());
} | [
"protected",
"SqlBuilder",
"wrapPageSql",
"(",
"SqlBuilder",
"find",
",",
"Page",
"page",
")",
"{",
"// limit A offset B 表示:A就是你需要多少行,B就是查询的起点位置。",
"return",
"find",
".",
"append",
"(",
"\" limit \"",
")",
".",
"append",
"(",
"page",
".",
"getPageSize",
"(",
")",
... | 根据不同数据库在查询SQL语句基础上包装其分页的语句<br>
各自数据库通过重写此方法实现最小改动情况下修改分页语句
@param find 标准查询语句
@param page 分页对象
@return 分页语句
@since 3.2.3 | [
"根据不同数据库在查询SQL语句基础上包装其分页的语句<br",
">",
"各自数据库通过重写此方法实现最小改动情况下修改分页语句"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/dialect/impl/AnsiSqlDialect.java#L134-L137 | train | Wrap the given page in a limit and offset sql. | [
30522,
5123,
29296,
8569,
23891,
2099,
10236,
13704,
2015,
4160,
2140,
1006,
29296,
8569,
23891,
2099,
2424,
1010,
3931,
3931,
1007,
1063,
1013,
1013,
5787,
1037,
16396,
1038,
100,
1923,
1993,
1037,
100,
100,
100,
100,
100,
100,
100,
1945... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulUtils.java | ConsulUtils.convertConsulSerivceId | public static String convertConsulSerivceId(URL url) {
if (url == null) {
return null;
}
return convertServiceId(url.getHost(), url.getPort(), url.getPath());
} | java | public static String convertConsulSerivceId(URL url) {
if (url == null) {
return null;
}
return convertServiceId(url.getHost(), url.getPort(), url.getPath());
} | [
"public",
"static",
"String",
"convertConsulSerivceId",
"(",
"URL",
"url",
")",
"{",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"convertServiceId",
"(",
"url",
".",
"getHost",
"(",
")",
",",
"url",
".",
"getPort",
"... | convert url to consul service id. serviceid includes ip+port+service
@param url a URL object
@return service id | [
"convert",
"url",
"to",
"consul",
"service",
"id",
".",
"serviceid",
"includes",
"ip+port+service"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulUtils.java#L126-L131 | train | Convert a URL to a Consul Serivce ID. | [
30522,
30524,
1025,
1065,
2709,
19884,
2121,
7903,
7416,
2094,
1006,
24471,
2140,
1012,
2131,
15006,
2102,
1006,
1007,
1010,
24471,
2140,
1012,
2131,
6442,
1006,
1007,
1010,
24471,
2140,
1012,
2131,
15069,
1006,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.fetch | private int fetch(State parent, List<Map.Entry<Integer, State>> siblings)
{
if (parent.isAcceptable())
{
State fakeNode = new State(-(parent.getDepth() + 1)); // 此节点是parent的子节点,同时具备parent的输出
fakeNode.addEmit(parent.getLargestValueId());
siblings.add(new AbstractMap.SimpleEntry<Integer, State>(0, fakeNode));
}
for (Map.Entry<Character, State> entry : parent.getSuccess().entrySet())
{
siblings.add(new AbstractMap.SimpleEntry<Integer, State>(entry.getKey() + 1, entry.getValue()));
}
return siblings.size();
} | java | private int fetch(State parent, List<Map.Entry<Integer, State>> siblings)
{
if (parent.isAcceptable())
{
State fakeNode = new State(-(parent.getDepth() + 1)); // 此节点是parent的子节点,同时具备parent的输出
fakeNode.addEmit(parent.getLargestValueId());
siblings.add(new AbstractMap.SimpleEntry<Integer, State>(0, fakeNode));
}
for (Map.Entry<Character, State> entry : parent.getSuccess().entrySet())
{
siblings.add(new AbstractMap.SimpleEntry<Integer, State>(entry.getKey() + 1, entry.getValue()));
}
return siblings.size();
} | [
"private",
"int",
"fetch",
"(",
"State",
"parent",
",",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"State",
">",
">",
"siblings",
")",
"{",
"if",
"(",
"parent",
".",
"isAcceptable",
"(",
")",
")",
"{",
"State",
"fakeNode",
"=",
"new",
"... | 获取直接相连的子节点
@param parent 父节点
@param siblings (子)兄弟节点
@return 兄弟节点个数 | [
"获取直接相连的子节点"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/AhoCorasick/AhoCorasickDoubleArrayTrie.java#L486-L499 | train | Fetch the number of siblings from the parent. | [
30522,
2797,
20014,
18584,
1006,
2110,
6687,
1010,
2862,
1026,
4949,
1012,
4443,
1026,
16109,
1010,
2110,
1028,
1028,
9504,
1007,
1063,
2065,
1006,
6687,
1012,
18061,
9468,
23606,
3085,
1006,
1007,
1007,
1063,
2110,
8275,
3630,
3207,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/Validator.java | Validator.validateEmpty | public static <T> T validateEmpty(T value, String errorMsg) throws ValidateException {
if (isNotEmpty(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | java | public static <T> T validateEmpty(T value, String errorMsg) throws ValidateException {
if (isNotEmpty(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"validateEmpty",
"(",
"T",
"value",
",",
"String",
"errorMsg",
")",
"throws",
"ValidateException",
"{",
"if",
"(",
"isNotEmpty",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"ValidateException",
"(",
"errorMsg",
")",... | 验证是否为空,非空时抛出异常<br>
对于String类型判定是否为empty(null 或 "")<br>
@param value 值
@param errorMsg 验证错误的信息
@return 验证后的值,验证通过返回此值,空值
@throws ValidateException 验证异常 | [
"验证是否为空,非空时抛出异常<br",
">",
"对于String类型判定是否为empty",
"(",
"null",
"或",
")",
"<br",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java#L204-L209 | train | Validate empty. | [
30522,
2270,
10763,
1026,
1056,
1028,
1056,
9398,
3686,
6633,
13876,
2100,
1006,
1056,
3643,
1010,
5164,
7561,
5244,
2290,
1007,
11618,
9398,
3686,
10288,
24422,
1063,
2065,
1006,
3475,
12184,
27718,
2100,
1006,
3643,
1007,
1007,
1063,
5466... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java | SpringApplication.setSources | public void setSources(Set<String> sources) {
Assert.notNull(sources, "Sources must not be null");
this.sources = new LinkedHashSet<>(sources);
} | java | public void setSources(Set<String> sources) {
Assert.notNull(sources, "Sources must not be null");
this.sources = new LinkedHashSet<>(sources);
} | [
"public",
"void",
"setSources",
"(",
"Set",
"<",
"String",
">",
"sources",
")",
"{",
"Assert",
".",
"notNull",
"(",
"sources",
",",
"\"Sources must not be null\"",
")",
";",
"this",
".",
"sources",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
"sources",
")",
";... | Set additional sources that will be used to create an ApplicationContext. A source
can be: a class name, package name, or an XML resource location.
<p>
Sources set here will be used in addition to any primary sources set in the
constructor.
@param sources the application sources to set
@see #SpringApplication(Class...)
@see #getAllSources() | [
"Set",
"additional",
"sources",
"that",
"will",
"be",
"used",
"to",
"create",
"an",
"ApplicationContext",
".",
"A",
"source",
"can",
"be",
":",
"a",
"class",
"name",
"package",
"name",
"or",
"an",
"XML",
"resource",
"location",
".",
"<p",
">",
"Sources",
... | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java#L1152-L1155 | train | Sets the sources to be used for the test. | [
30522,
2270,
11675,
4520,
8162,
9623,
1006,
2275,
1026,
5164,
1028,
4216,
1007,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
4216,
1010,
1000,
4216,
2442,
2025,
2022,
19701,
1000,
1007,
1025,
2023,
1012,
4216,
1027,
2047,
5799,
14949,
7898,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/logging/LoggingPreferences.java | LoggingPreferences.addPreferences | public LoggingPreferences addPreferences(LoggingPreferences prefs) {
if (prefs == null) {
return this;
}
for (String logType : prefs.getEnabledLogTypes()) {
enable(logType, prefs.getLevel(logType));
}
return this;
} | java | public LoggingPreferences addPreferences(LoggingPreferences prefs) {
if (prefs == null) {
return this;
}
for (String logType : prefs.getEnabledLogTypes()) {
enable(logType, prefs.getLevel(logType));
}
return this;
} | [
"public",
"LoggingPreferences",
"addPreferences",
"(",
"LoggingPreferences",
"prefs",
")",
"{",
"if",
"(",
"prefs",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"for",
"(",
"String",
"logType",
":",
"prefs",
".",
"getEnabledLogTypes",
"(",
")",
")",
... | Adds the given logging preferences giving them precedence over existing
preferences.
@param prefs The logging preferences to add.
@return A references to this object. | [
"Adds",
"the",
"given",
"logging",
"preferences",
"giving",
"them",
"precedence",
"over",
"existing",
"preferences",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/logging/LoggingPreferences.java#L80-L88 | train | Add the logging preferences to this object. | [
30522,
2270,
15899,
28139,
25523,
2015,
5587,
28139,
25523,
2015,
1006,
15899,
28139,
25523,
2015,
3653,
10343,
1007,
1063,
2065,
1006,
3653,
10343,
1027,
1027,
19701,
1007,
1063,
2709,
2023,
1025,
1065,
2005,
1006,
5164,
8833,
13874,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Row.java | Row.copy | public static Row copy(Row row) {
final Row newRow = new Row(row.fields.length);
System.arraycopy(row.fields, 0, newRow.fields, 0, row.fields.length);
return newRow;
} | java | public static Row copy(Row row) {
final Row newRow = new Row(row.fields.length);
System.arraycopy(row.fields, 0, newRow.fields, 0, row.fields.length);
return newRow;
} | [
"public",
"static",
"Row",
"copy",
"(",
"Row",
"row",
")",
"{",
"final",
"Row",
"newRow",
"=",
"new",
"Row",
"(",
"row",
".",
"fields",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"row",
".",
"fields",
",",
"0",
",",
"newRow",
".",
... | Creates a new Row which copied from another row.
This method does not perform a deep copy.
@param row The row being copied.
@return The cloned new Row | [
"Creates",
"a",
"new",
"Row",
"which",
"copied",
"from",
"another",
"row",
".",
"This",
"method",
"does",
"not",
"perform",
"a",
"deep",
"copy",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/Row.java#L150-L154 | train | Creates a copy of the given row. | [
30522,
2270,
10763,
5216,
6100,
1006,
5216,
5216,
1007,
1063,
2345,
5216,
2047,
10524,
1027,
2047,
5216,
1006,
5216,
1012,
4249,
1012,
3091,
1007,
1025,
2291,
1012,
9140,
3597,
7685,
1006,
5216,
1012,
4249,
1010,
1014,
1010,
2047,
10524,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getMatrix | public Matrix getMatrix(int i0, int i1, int j0, int j1)
{
Matrix X = new Matrix(i1 - i0 + 1, j1 - j0 + 1);
double[][] B = X.getArray();
try
{
for (int i = i0; i <= i1; i++)
{
for (int j = j0; j <= j1; j++)
{
B[i - i0][j - j0] = A[i][j];
}
}
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new ArrayIndexOutOfBoundsException("Submatrix indices");
}
return X;
} | java | public Matrix getMatrix(int i0, int i1, int j0, int j1)
{
Matrix X = new Matrix(i1 - i0 + 1, j1 - j0 + 1);
double[][] B = X.getArray();
try
{
for (int i = i0; i <= i1; i++)
{
for (int j = j0; j <= j1; j++)
{
B[i - i0][j - j0] = A[i][j];
}
}
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new ArrayIndexOutOfBoundsException("Submatrix indices");
}
return X;
} | [
"public",
"Matrix",
"getMatrix",
"(",
"int",
"i0",
",",
"int",
"i1",
",",
"int",
"j0",
",",
"int",
"j1",
")",
"{",
"Matrix",
"X",
"=",
"new",
"Matrix",
"(",
"i1",
"-",
"i0",
"+",
"1",
",",
"j1",
"-",
"j0",
"+",
"1",
")",
";",
"double",
"[",
... | Get a submatrix.
@param i0 Initial row index
@param i1 Final row index
@param j0 Initial column index
@param j1 Final column index
@return A(i0:i1, j0:j1)
@throws ArrayIndexOutOfBoundsException Submatrix indices | [
"Get",
"a",
"submatrix",
"."
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dependency/nnparser/Matrix.java#L362-L381 | train | Gets the matrix of the matrix of the submatrix. | [
30522,
2270,
8185,
2131,
18900,
17682,
1006,
20014,
1045,
2692,
1010,
20014,
1045,
2487,
1010,
20014,
1046,
2692,
1010,
20014,
1046,
2487,
1007,
1063,
8185,
1060,
1027,
2047,
8185,
1006,
1045,
2487,
1011,
1045,
2692,
1009,
1015,
1010,
1046,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/CLIService.java | CLIService.getSchemas | @Override
public OperationHandle getSchemas(SessionHandle sessionHandle,
String catalogName, String schemaName)
throws HiveSQLException {
OperationHandle opHandle = sessionManager.getSession(sessionHandle)
.getSchemas(catalogName, schemaName);
LOG.debug(sessionHandle + ": getSchemas()");
return opHandle;
} | java | @Override
public OperationHandle getSchemas(SessionHandle sessionHandle,
String catalogName, String schemaName)
throws HiveSQLException {
OperationHandle opHandle = sessionManager.getSession(sessionHandle)
.getSchemas(catalogName, schemaName);
LOG.debug(sessionHandle + ": getSchemas()");
return opHandle;
} | [
"@",
"Override",
"public",
"OperationHandle",
"getSchemas",
"(",
"SessionHandle",
"sessionHandle",
",",
"String",
"catalogName",
",",
"String",
"schemaName",
")",
"throws",
"HiveSQLException",
"{",
"OperationHandle",
"opHandle",
"=",
"sessionManager",
".",
"getSession",... | /* (non-Javadoc)
@see org.apache.hive.service.cli.ICLIService#getSchemas(org.apache.hive.service.cli.SessionHandle, java.lang.String, java.lang.String) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/CLIService.java#L308-L316 | train | Get the schema list for a given catalog and schema name. | [
30522,
1030,
2058,
15637,
2270,
3169,
11774,
2571,
4152,
5403,
9335,
1006,
5219,
11774,
2571,
5219,
11774,
2571,
1010,
5164,
12105,
18442,
1010,
5164,
8040,
28433,
18442,
1007,
11618,
26736,
2015,
4160,
2571,
2595,
24422,
1063,
3169,
11774,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Execution.java | Execution.sendCancelRpcCall | private void sendCancelRpcCall(int numberRetries) {
final LogicalSlot slot = assignedResource;
if (slot != null) {
final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
final ComponentMainThreadExecutor jobMasterMainThreadExecutor =
getVertex().getExecutionGraph().getJobMasterMainThreadExecutor();
CompletableFuture<Acknowledge> cancelResultFuture = FutureUtils.retry(
() -> taskManagerGateway.cancelTask(attemptId, rpcTimeout),
numberRetries,
jobMasterMainThreadExecutor);
cancelResultFuture.whenComplete(
(ack, failure) -> {
if (failure != null) {
fail(new Exception("Task could not be canceled.", failure));
}
});
}
} | java | private void sendCancelRpcCall(int numberRetries) {
final LogicalSlot slot = assignedResource;
if (slot != null) {
final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
final ComponentMainThreadExecutor jobMasterMainThreadExecutor =
getVertex().getExecutionGraph().getJobMasterMainThreadExecutor();
CompletableFuture<Acknowledge> cancelResultFuture = FutureUtils.retry(
() -> taskManagerGateway.cancelTask(attemptId, rpcTimeout),
numberRetries,
jobMasterMainThreadExecutor);
cancelResultFuture.whenComplete(
(ack, failure) -> {
if (failure != null) {
fail(new Exception("Task could not be canceled.", failure));
}
});
}
} | [
"private",
"void",
"sendCancelRpcCall",
"(",
"int",
"numberRetries",
")",
"{",
"final",
"LogicalSlot",
"slot",
"=",
"assignedResource",
";",
"if",
"(",
"slot",
"!=",
"null",
")",
"{",
"final",
"TaskManagerGateway",
"taskManagerGateway",
"=",
"slot",
".",
"getTas... | This method sends a CancelTask message to the instance of the assigned slot.
<p>The sending is tried up to NUM_CANCEL_CALL_TRIES times. | [
"This",
"method",
"sends",
"a",
"CancelTask",
"message",
"to",
"the",
"instance",
"of",
"the",
"assigned",
"slot",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java#L1184-L1204 | train | Cancel the task. | [
30522,
2797,
11675,
4604,
9336,
29109,
14536,
16665,
3363,
1006,
20014,
2193,
13465,
5134,
1007,
1063,
2345,
11177,
14540,
4140,
10453,
1027,
4137,
6072,
8162,
3401,
1025,
2065,
1006,
10453,
999,
1027,
19701,
1007,
1063,
2345,
4708,
24805,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | http-url/src/main/java/com/networknt/url/URLNormalizer.java | URLNormalizer.unsecureScheme | public URLNormalizer unsecureScheme() {
Matcher m = PATTERN_SCHEMA.matcher(url);
if (m.find()) {
String schema = m.group(1);
if ("https".equalsIgnoreCase(schema)) {
url = m.replaceFirst(StringUtils.stripEnd(schema, "Ss") + "$2");
}
}
return this;
} | java | public URLNormalizer unsecureScheme() {
Matcher m = PATTERN_SCHEMA.matcher(url);
if (m.find()) {
String schema = m.group(1);
if ("https".equalsIgnoreCase(schema)) {
url = m.replaceFirst(StringUtils.stripEnd(schema, "Ss") + "$2");
}
}
return this;
} | [
"public",
"URLNormalizer",
"unsecureScheme",
"(",
")",
"{",
"Matcher",
"m",
"=",
"PATTERN_SCHEMA",
".",
"matcher",
"(",
"url",
")",
";",
"if",
"(",
"m",
".",
"find",
"(",
")",
")",
"{",
"String",
"schema",
"=",
"m",
".",
"group",
"(",
"1",
")",
";"... | <p>Converts <code>https</code> scheme to <code>http</code>.</p>
<code>https://www.example.com/ → http://www.example.com/</code>
@return this instance | [
"<p",
">",
"Converts",
"<code",
">",
"https<",
"/",
"code",
">",
"scheme",
"to",
"<code",
">",
"http<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">",
"<code",
">",
"https",
":",
"//",
"www",
".",
"example",
".",
"com",
"/",
"&rarr",
";",
"http",
"... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/http-url/src/main/java/com/networknt/url/URLNormalizer.java#L589-L598 | train | Unsecure scheme. | [
30522,
2270,
24471,
19666,
2953,
9067,
17629,
4895,
3366,
23887,
22842,
4168,
1006,
1007,
1063,
2674,
2121,
1049,
1027,
5418,
1035,
8040,
28433,
1012,
2674,
2121,
1006,
24471,
2140,
1007,
1025,
2065,
1006,
1049,
1012,
2424,
1006,
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-core/src/main/java/cn/hutool/core/util/ClassUtil.java | ClassUtil.getClassName | public static String getClassName(Class<?> clazz, boolean isSimple) {
if (null == clazz) {
return null;
}
return isSimple ? clazz.getSimpleName() : clazz.getName();
} | java | public static String getClassName(Class<?> clazz, boolean isSimple) {
if (null == clazz) {
return null;
}
return isSimple ? clazz.getSimpleName() : clazz.getName();
} | [
"public",
"static",
"String",
"getClassName",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"boolean",
"isSimple",
")",
"{",
"if",
"(",
"null",
"==",
"clazz",
")",
"{",
"return",
"null",
";",
"}",
"return",
"isSimple",
"?",
"clazz",
".",
"getSimpleName",
... | 获取类名<br>
类名并不包含“.class”这个扩展名<br>
例如:ClassUtil这个类<br>
<pre>
isSimple为false: "com.xiaoleilu.hutool.util.ClassUtil"
isSimple为true: "ClassUtil"
</pre>
@param clazz 类
@param isSimple 是否简单类名,如果为true,返回不带包名的类名
@return 类名
@since 3.0.7 | [
"获取类名<br",
">",
"类名并不包含“",
".",
"class”这个扩展名<br",
">",
"例如:ClassUtil这个类<br",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ClassUtil.java#L104-L109 | train | Returns the name of the class. | [
30522,
2270,
10763,
5164,
2131,
26266,
18442,
1006,
2465,
1026,
1029,
1028,
18856,
10936,
2480,
1010,
22017,
20898,
26354,
5714,
10814,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
18856,
10936,
2480,
1007,
1063,
2709,
19701,
1025,
1065,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/state/OperatorStateCheckpointOutputStream.java | OperatorStateCheckpointOutputStream.closeAndGetHandle | @Override
OperatorStateHandle closeAndGetHandle() throws IOException {
StreamStateHandle streamStateHandle = delegate.closeAndGetHandle();
if (null == streamStateHandle) {
return null;
}
if (partitionOffsets.isEmpty() && delegate.getPos() > initialPosition) {
startNewPartition();
}
Map<String, OperatorStateHandle.StateMetaInfo> offsetsMap = new HashMap<>(1);
OperatorStateHandle.StateMetaInfo metaInfo =
new OperatorStateHandle.StateMetaInfo(
partitionOffsets.toArray(),
OperatorStateHandle.Mode.SPLIT_DISTRIBUTE);
offsetsMap.put(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME, metaInfo);
return new OperatorStreamStateHandle(offsetsMap, streamStateHandle);
} | java | @Override
OperatorStateHandle closeAndGetHandle() throws IOException {
StreamStateHandle streamStateHandle = delegate.closeAndGetHandle();
if (null == streamStateHandle) {
return null;
}
if (partitionOffsets.isEmpty() && delegate.getPos() > initialPosition) {
startNewPartition();
}
Map<String, OperatorStateHandle.StateMetaInfo> offsetsMap = new HashMap<>(1);
OperatorStateHandle.StateMetaInfo metaInfo =
new OperatorStateHandle.StateMetaInfo(
partitionOffsets.toArray(),
OperatorStateHandle.Mode.SPLIT_DISTRIBUTE);
offsetsMap.put(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME, metaInfo);
return new OperatorStreamStateHandle(offsetsMap, streamStateHandle);
} | [
"@",
"Override",
"OperatorStateHandle",
"closeAndGetHandle",
"(",
")",
"throws",
"IOException",
"{",
"StreamStateHandle",
"streamStateHandle",
"=",
"delegate",
".",
"closeAndGetHandle",
"(",
")",
";",
"if",
"(",
"null",
"==",
"streamStateHandle",
")",
"{",
"return",... | This method should not be public so as to not expose internals to user code. | [
"This",
"method",
"should",
"not",
"be",
"public",
"so",
"as",
"to",
"not",
"expose",
"internals",
"to",
"user",
"code",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/state/OperatorStateCheckpointOutputStream.java#L57-L79 | train | Close the underlying stream and return the handle. | [
30522,
1030,
2058,
15637,
9224,
12259,
11774,
2571,
2485,
5685,
18150,
11774,
2571,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
9199,
12259,
11774,
2571,
9199,
12259,
11774,
2571,
1027,
11849,
1012,
2485,
5685,
18150,
11774,
2571,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.