repo stringclasses 11 values | path stringlengths 41 234 | func_name stringlengths 5 78 | original_string stringlengths 71 14.1k | language stringclasses 1 value | code stringlengths 71 14.1k | code_tokens listlengths 22 2.65k | docstring stringlengths 2 5.35k | docstring_tokens listlengths 1 369 | sha stringclasses 11 values | url stringlengths 129 339 | partition stringclasses 1 value | summary stringlengths 7 175 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
apache/spark | common/network-common/src/main/java/org/apache/spark/network/client/TransportClientFactory.java | TransportClientFactory.close | @Override
public void close() {
// Go through all clients and close them if they are active.
for (ClientPool clientPool : connectionPool.values()) {
for (int i = 0; i < clientPool.clients.length; i++) {
TransportClient client = clientPool.clients[i];
if (client != null) {
clientPool.clients[i] = null;
JavaUtils.closeQuietly(client);
}
}
}
connectionPool.clear();
if (workerGroup != null) {
workerGroup.shutdownGracefully();
workerGroup = null;
}
} | java | @Override
public void close() {
// Go through all clients and close them if they are active.
for (ClientPool clientPool : connectionPool.values()) {
for (int i = 0; i < clientPool.clients.length; i++) {
TransportClient client = clientPool.clients[i];
if (client != null) {
clientPool.clients[i] = null;
JavaUtils.closeQuietly(client);
}
}
}
connectionPool.clear();
if (workerGroup != null) {
workerGroup.shutdownGracefully();
workerGroup = null;
}
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"// Go through all clients and close them if they are active.",
"for",
"(",
"ClientPool",
"clientPool",
":",
"connectionPool",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
... | Close all connections in the connection pool, and shutdown the worker thread pool. | [
"Close",
"all",
"connections",
"in",
"the",
"connection",
"pool",
"and",
"shutdown",
"the",
"worker",
"thread",
"pool",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/network-common/src/main/java/org/apache/spark/network/client/TransportClientFactory.java#L279-L297 | train | Close all resources. | [
30522,
1030,
2058,
15637,
2270,
11675,
2485,
1006,
1007,
1063,
1013,
1013,
2175,
2083,
2035,
7846,
1998,
2485,
2068,
2065,
2027,
2024,
3161,
1012,
2005,
1006,
7396,
16869,
7396,
16869,
1024,
4434,
16869,
1012,
5300,
1006,
1007,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/net/NetUtil.java | NetUtil.hideIpPart | public static String hideIpPart(String ip) {
return new StringBuffer(ip.length()).append(ip.substring(0, ip.lastIndexOf(".") + 1)).append("*").toString();
} | java | public static String hideIpPart(String ip) {
return new StringBuffer(ip.length()).append(ip.substring(0, ip.lastIndexOf(".") + 1)).append("*").toString();
} | [
"public",
"static",
"String",
"hideIpPart",
"(",
"String",
"ip",
")",
"{",
"return",
"new",
"StringBuffer",
"(",
"ip",
".",
"length",
"(",
")",
")",
".",
"append",
"(",
"ip",
".",
"substring",
"(",
"0",
",",
"ip",
".",
"lastIndexOf",
"(",
"\".\"",
")... | 隐藏掉IP地址的最后一部分为 * 代替
@param ip IP地址
@return 隐藏部分后的IP | [
"隐藏掉IP地址的最后一部分为",
"*",
"代替"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/net/NetUtil.java#L236-L238 | train | hide the ip part of the ip | [
30522,
2270,
10763,
5164,
5342,
11514,
19362,
2102,
1006,
5164,
12997,
1007,
1063,
2709,
2047,
5164,
8569,
12494,
1006,
12997,
1012,
3091,
1006,
1007,
1007,
1012,
10439,
10497,
1006,
12997,
1012,
4942,
3367,
4892,
1006,
1014,
1010,
12997,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java | ExpectedConditions.presenceOfNestedElementLocatedBy | public static ExpectedCondition<WebElement> presenceOfNestedElementLocatedBy(
final By locator,
final By childLocator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver webDriver) {
return webDriver.findElement(locator).findElement(childLocator);
}
@Override
public String toString() {
return String.format("visibility of element located by %s -> %s", locator, childLocator);
}
};
} | java | public static ExpectedCondition<WebElement> presenceOfNestedElementLocatedBy(
final By locator,
final By childLocator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver webDriver) {
return webDriver.findElement(locator).findElement(childLocator);
}
@Override
public String toString() {
return String.format("visibility of element located by %s -> %s", locator, childLocator);
}
};
} | [
"public",
"static",
"ExpectedCondition",
"<",
"WebElement",
">",
"presenceOfNestedElementLocatedBy",
"(",
"final",
"By",
"locator",
",",
"final",
"By",
"childLocator",
")",
"{",
"return",
"new",
"ExpectedCondition",
"<",
"WebElement",
">",
"(",
")",
"{",
"@",
"O... | An expectation for checking child WebElement as a part of parent element to present
@param locator used to check parent element. For example table with locator
By.xpath("//table")
@param childLocator used to find child element. For example td By.xpath("./tr/td")
@return subelement | [
"An",
"expectation",
"for",
"checking",
"child",
"WebElement",
"as",
"a",
"part",
"of",
"parent",
"element",
"to",
"present"
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java#L1223-L1238 | train | An expectation for checking that a nested element is present on a page. | [
30522,
2270,
10763,
3517,
8663,
20562,
1026,
4773,
12260,
3672,
1028,
3739,
11253,
5267,
3064,
12260,
3672,
4135,
12921,
3762,
1006,
2345,
2011,
8840,
11266,
2953,
1010,
2345,
2011,
2775,
4135,
11266,
2953,
1007,
1063,
2709,
2047,
3517,
305... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/environment/StreamExecutionEnvironment.java | StreamExecutionEnvironment.socketTextStream | @PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port, String delimiter, long maxRetry) {
return addSource(new SocketTextStreamFunction(hostname, port, delimiter, maxRetry),
"Socket Stream");
} | java | @PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port, String delimiter, long maxRetry) {
return addSource(new SocketTextStreamFunction(hostname, port, delimiter, maxRetry),
"Socket Stream");
} | [
"@",
"PublicEvolving",
"public",
"DataStreamSource",
"<",
"String",
">",
"socketTextStream",
"(",
"String",
"hostname",
",",
"int",
"port",
",",
"String",
"delimiter",
",",
"long",
"maxRetry",
")",
"{",
"return",
"addSource",
"(",
"new",
"SocketTextStreamFunction"... | Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
decoded by the system's default character set. On the termination of the socket server connection retries can be
initiated.
<p>Let us note that the socket itself does not report on abort and as a consequence retries are only initiated when
the socket was gracefully terminated.
@param hostname
The host name which a server socket binds
@param port
The port number which a server socket binds. A port number of 0 means that the port number is automatically
allocated.
@param delimiter
A string which splits received strings into records
@param maxRetry
The maximal retry interval in seconds while the program waits for a socket that is temporarily down.
Reconnection is initiated every second. A number of 0 means that the reader is immediately terminated,
while
a negative value ensures retrying forever.
@return A data stream containing the strings received from the socket | [
"Creates",
"a",
"new",
"data",
"stream",
"that",
"contains",
"the",
"strings",
"received",
"infinitely",
"from",
"a",
"socket",
".",
"Received",
"strings",
"are",
"decoded",
"by",
"the",
"system",
"s",
"default",
"character",
"set",
".",
"On",
"the",
"termin... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java#L1214-L1218 | train | Add a DataStreamSource that reads from a socket socket. | [
30522,
1030,
2270,
6777,
4747,
6455,
2270,
2951,
21422,
6499,
3126,
3401,
1026,
5164,
1028,
22278,
18209,
21422,
1006,
5164,
3677,
18442,
1010,
20014,
3417,
1010,
5164,
3972,
27605,
3334,
1010,
2146,
4098,
13465,
2854,
1007,
1063,
2709,
990... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-yarn/src/main/java/org/apache/flink/yarn/Utils.java | Utils.setupLocalResource | static Tuple2<Path, LocalResource> setupLocalResource(
FileSystem fs,
String appId,
Path localSrcPath,
Path homedir,
String relativeTargetPath) throws IOException {
File localFile = new File(localSrcPath.toUri().getPath());
if (localFile.isDirectory()) {
throw new IllegalArgumentException("File to copy must not be a directory: " +
localSrcPath);
}
// copy resource to HDFS
String suffix =
".flink/"
+ appId
+ (relativeTargetPath.isEmpty() ? "" : "/" + relativeTargetPath)
+ "/" + localSrcPath.getName();
Path dst = new Path(homedir, suffix);
LOG.debug("Copying from {} to {}", localSrcPath, dst);
fs.copyFromLocalFile(false, true, localSrcPath, dst);
// Note: If we used registerLocalResource(FileSystem, Path) here, we would access the remote
// file once again which has problems with eventually consistent read-after-write file
// systems. Instead, we decide to preserve the modification time at the remote
// location because this and the size of the resource will be checked by YARN based on
// the values we provide to #registerLocalResource() below.
fs.setTimes(dst, localFile.lastModified(), -1);
// now create the resource instance
LocalResource resource = registerLocalResource(dst, localFile.length(), localFile.lastModified());
return Tuple2.of(dst, resource);
} | java | static Tuple2<Path, LocalResource> setupLocalResource(
FileSystem fs,
String appId,
Path localSrcPath,
Path homedir,
String relativeTargetPath) throws IOException {
File localFile = new File(localSrcPath.toUri().getPath());
if (localFile.isDirectory()) {
throw new IllegalArgumentException("File to copy must not be a directory: " +
localSrcPath);
}
// copy resource to HDFS
String suffix =
".flink/"
+ appId
+ (relativeTargetPath.isEmpty() ? "" : "/" + relativeTargetPath)
+ "/" + localSrcPath.getName();
Path dst = new Path(homedir, suffix);
LOG.debug("Copying from {} to {}", localSrcPath, dst);
fs.copyFromLocalFile(false, true, localSrcPath, dst);
// Note: If we used registerLocalResource(FileSystem, Path) here, we would access the remote
// file once again which has problems with eventually consistent read-after-write file
// systems. Instead, we decide to preserve the modification time at the remote
// location because this and the size of the resource will be checked by YARN based on
// the values we provide to #registerLocalResource() below.
fs.setTimes(dst, localFile.lastModified(), -1);
// now create the resource instance
LocalResource resource = registerLocalResource(dst, localFile.length(), localFile.lastModified());
return Tuple2.of(dst, resource);
} | [
"static",
"Tuple2",
"<",
"Path",
",",
"LocalResource",
">",
"setupLocalResource",
"(",
"FileSystem",
"fs",
",",
"String",
"appId",
",",
"Path",
"localSrcPath",
",",
"Path",
"homedir",
",",
"String",
"relativeTargetPath",
")",
"throws",
"IOException",
"{",
"File"... | Copy a local file to a remote file system.
@param fs
remote filesystem
@param appId
application ID
@param localSrcPath
path to the local file
@param homedir
remote home directory base (will be extended)
@param relativeTargetPath
relative target path of the file (will be prefixed be the full home directory we set up)
@return Path to remote file (usually hdfs) | [
"Copy",
"a",
"local",
"file",
"to",
"a",
"remote",
"file",
"system",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-yarn/src/main/java/org/apache/flink/yarn/Utils.java#L138-L174 | train | Setup the local resource. | [
30522,
10763,
10722,
10814,
2475,
1026,
4130,
1010,
2334,
6072,
8162,
3401,
1028,
16437,
4135,
9289,
6072,
8162,
3401,
1006,
6764,
27268,
6633,
1042,
2015,
1010,
5164,
10439,
3593,
1010,
4130,
10575,
11890,
15069,
1010,
4130,
2188,
4305,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java | ExecutionEnvironment.readTextFile | public DataSource<String> readTextFile(String filePath, String charsetName) {
Preconditions.checkNotNull(filePath, "The file path may not be null.");
TextInputFormat format = new TextInputFormat(new Path(filePath));
format.setCharsetName(charsetName);
return new DataSource<>(this, format, BasicTypeInfo.STRING_TYPE_INFO, Utils.getCallLocationName());
} | java | public DataSource<String> readTextFile(String filePath, String charsetName) {
Preconditions.checkNotNull(filePath, "The file path may not be null.");
TextInputFormat format = new TextInputFormat(new Path(filePath));
format.setCharsetName(charsetName);
return new DataSource<>(this, format, BasicTypeInfo.STRING_TYPE_INFO, Utils.getCallLocationName());
} | [
"public",
"DataSource",
"<",
"String",
">",
"readTextFile",
"(",
"String",
"filePath",
",",
"String",
"charsetName",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"filePath",
",",
"\"The file path may not be null.\"",
")",
";",
"TextInputFormat",
"format",
"=... | Creates a {@link DataSet} that represents the Strings produced by reading the given file line wise.
The {@link java.nio.charset.Charset} with the given name will be used to read the files.
@param filePath The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path").
@param charsetName The name of the character set used to read the file.
@return A {@link DataSet} that represents the data read from the given file as text lines. | [
"Creates",
"a",
"{",
"@link",
"DataSet",
"}",
"that",
"represents",
"the",
"Strings",
"produced",
"by",
"reading",
"the",
"given",
"file",
"line",
"wise",
".",
"The",
"{",
"@link",
"java",
".",
"nio",
".",
"charset",
".",
"Charset",
"}",
"with",
"the",
... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java#L407-L413 | train | Reads a text file from the specified path. | [
30522,
2270,
2951,
6499,
3126,
3401,
1026,
5164,
1028,
3191,
18209,
8873,
2571,
1006,
5164,
5371,
15069,
1010,
5164,
25869,
13462,
18442,
1007,
1063,
3653,
8663,
20562,
2015,
1012,
4638,
17048,
11231,
3363,
1006,
5371,
15069,
1010,
1000,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/text/StrBuilder.java | StrBuilder.insert | public StrBuilder insert(int index, char c) {
moveDataAfterIndex(index, 1);
value[index] = c;
this.position = Math.max(this.position, index) + 1;
return this;
} | java | public StrBuilder insert(int index, char c) {
moveDataAfterIndex(index, 1);
value[index] = c;
this.position = Math.max(this.position, index) + 1;
return this;
} | [
"public",
"StrBuilder",
"insert",
"(",
"int",
"index",
",",
"char",
"c",
")",
"{",
"moveDataAfterIndex",
"(",
"index",
",",
"1",
")",
";",
"value",
"[",
"index",
"]",
"=",
"c",
";",
"this",
".",
"position",
"=",
"Math",
".",
"max",
"(",
"this",
"."... | 插入指定字符
@param index 位置
@param c 字符
@return this | [
"插入指定字符"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/text/StrBuilder.java#L163-L168 | train | Inserts a character at the specified position. | [
30522,
2270,
2358,
15185,
19231,
4063,
19274,
1006,
20014,
5950,
1010,
25869,
1039,
1007,
1063,
2333,
6790,
10354,
3334,
22254,
10288,
1006,
5950,
1010,
1015,
1007,
1025,
30524,
2597,
1010,
5950,
1007,
1009,
1015,
1025,
2709,
2023,
1025,
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-extra/src/main/java/cn/hutool/extra/servlet/ServletUtil.java | ServletUtil.write | public static void write(HttpServletResponse response, InputStream in, String contentType) {
response.setContentType(contentType);
write(response, in);
} | java | public static void write(HttpServletResponse response, InputStream in, String contentType) {
response.setContentType(contentType);
write(response, in);
} | [
"public",
"static",
"void",
"write",
"(",
"HttpServletResponse",
"response",
",",
"InputStream",
"in",
",",
"String",
"contentType",
")",
"{",
"response",
".",
"setContentType",
"(",
"contentType",
")",
";",
"write",
"(",
"response",
",",
"in",
")",
";",
"}"... | 返回数据给客户端
@param response 响应对象{@link HttpServletResponse}
@param in 需要返回客户端的内容
@param contentType 返回的类型 | [
"返回数据给客户端"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/servlet/ServletUtil.java#L536-L539 | train | Write the content of the InputStream to the HttpServletResponse. | [
30522,
2270,
10763,
11675,
4339,
1006,
16770,
2121,
2615,
7485,
6072,
26029,
3366,
3433,
1010,
20407,
25379,
1999,
1010,
5164,
4180,
13874,
1007,
1063,
3433,
1012,
2275,
8663,
6528,
15353,
5051,
1006,
4180,
13874,
1007,
1025,
4339,
1006,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java | SqlExecutor.call | public static boolean call(Connection conn, String sql, Object... params) throws SQLException {
CallableStatement call = null;
try {
call = StatementUtil.prepareCall(conn, sql, params);
return call.execute();
} finally {
DbUtil.close(call);
}
} | java | public static boolean call(Connection conn, String sql, Object... params) throws SQLException {
CallableStatement call = null;
try {
call = StatementUtil.prepareCall(conn, sql, params);
return call.execute();
} finally {
DbUtil.close(call);
}
} | [
"public",
"static",
"boolean",
"call",
"(",
"Connection",
"conn",
",",
"String",
"sql",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"CallableStatement",
"call",
"=",
"null",
";",
"try",
"{",
"call",
"=",
"StatementUtil",
".",
"prepare... | 执行调用存储过程<br>
此方法不会关闭Connection
@param conn 数据库连接对象
@param sql SQL
@param params 参数
@return 如果执行后第一个结果是ResultSet,则返回true,否则返回false。
@throws SQLException SQL执行异常 | [
"执行调用存储过程<br",
">",
"此方法不会关闭Connection"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java#L73-L81 | train | Execute a SQL call. | [
30522,
2270,
10763,
22017,
20898,
2655,
1006,
4434,
9530,
2078,
1010,
5164,
29296,
1010,
4874,
1012,
1012,
1012,
11498,
5244,
1007,
11618,
29296,
10288,
24422,
1063,
2655,
3085,
9153,
18532,
4765,
2655,
1027,
19701,
1025,
3046,
1063,
2655,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-hadoop-compatibility/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java | WritableTypeInfo.getWritableTypeInfo | @PublicEvolving
static <T extends Writable> TypeInformation<T> getWritableTypeInfo(Class<T> typeClass) {
if (Writable.class.isAssignableFrom(typeClass) && !typeClass.equals(Writable.class)) {
return new WritableTypeInfo<T>(typeClass);
}
else {
throw new InvalidTypesException("The given class is no subclass of " + Writable.class.getName());
}
} | java | @PublicEvolving
static <T extends Writable> TypeInformation<T> getWritableTypeInfo(Class<T> typeClass) {
if (Writable.class.isAssignableFrom(typeClass) && !typeClass.equals(Writable.class)) {
return new WritableTypeInfo<T>(typeClass);
}
else {
throw new InvalidTypesException("The given class is no subclass of " + Writable.class.getName());
}
} | [
"@",
"PublicEvolving",
"static",
"<",
"T",
"extends",
"Writable",
">",
"TypeInformation",
"<",
"T",
">",
"getWritableTypeInfo",
"(",
"Class",
"<",
"T",
">",
"typeClass",
")",
"{",
"if",
"(",
"Writable",
".",
"class",
".",
"isAssignableFrom",
"(",
"typeClass"... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java#L145-L153 | train | Gets the Writable TypeInformation. | [
30522,
1030,
2270,
6777,
4747,
6455,
10763,
1026,
1056,
8908,
25697,
3085,
1028,
2828,
2378,
14192,
3370,
1026,
1056,
1028,
2131,
13088,
6590,
3468,
13874,
2378,
14876,
1006,
2465,
1026,
1056,
1028,
2828,
26266,
1007,
1063,
2065,
1006,
2569... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java | Sftp.delFile | @Override
public boolean delFile(String filePath) {
try {
channel.rm(filePath);
} catch (SftpException e) {
throw new JschRuntimeException(e);
}
return true;
} | java | @Override
public boolean delFile(String filePath) {
try {
channel.rm(filePath);
} catch (SftpException e) {
throw new JschRuntimeException(e);
}
return true;
} | [
"@",
"Override",
"public",
"boolean",
"delFile",
"(",
"String",
"filePath",
")",
"{",
"try",
"{",
"channel",
".",
"rm",
"(",
"filePath",
")",
";",
"}",
"catch",
"(",
"SftpException",
"e",
")",
"{",
"throw",
"new",
"JschRuntimeException",
"(",
"e",
")",
... | 删除文件
@param filePath 要删除的文件绝对路径 | [
"删除文件"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java#L295-L303 | train | This method is used to delete a file from the remote host. | [
30522,
1030,
2058,
15637,
2270,
22017,
20898,
3972,
8873,
2571,
1006,
5164,
5371,
15069,
1007,
1063,
3046,
1063,
3149,
1012,
28549,
1006,
5371,
15069,
30524,
11624,
15532,
7292,
10288,
24422,
1006,
1041,
1007,
1025,
1065,
2709,
2995,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | codec/src/main/java/io/netty/handler/codec/compression/Bzip2BlockCompressor.java | Bzip2BlockCompressor.write | boolean write(final int value) {
if (blockLength > blockLengthLimit) {
return false;
}
final int rleCurrentValue = this.rleCurrentValue;
final int rleLength = this.rleLength;
if (rleLength == 0) {
this.rleCurrentValue = value;
this.rleLength = 1;
} else if (rleCurrentValue != value) {
// This path commits us to write 6 bytes - one RLE run (5 bytes) plus one extra
writeRun(rleCurrentValue & 0xff, rleLength);
this.rleCurrentValue = value;
this.rleLength = 1;
} else {
if (rleLength == 254) {
writeRun(rleCurrentValue & 0xff, 255);
this.rleLength = 0;
} else {
this.rleLength = rleLength + 1;
}
}
return true;
} | java | boolean write(final int value) {
if (blockLength > blockLengthLimit) {
return false;
}
final int rleCurrentValue = this.rleCurrentValue;
final int rleLength = this.rleLength;
if (rleLength == 0) {
this.rleCurrentValue = value;
this.rleLength = 1;
} else if (rleCurrentValue != value) {
// This path commits us to write 6 bytes - one RLE run (5 bytes) plus one extra
writeRun(rleCurrentValue & 0xff, rleLength);
this.rleCurrentValue = value;
this.rleLength = 1;
} else {
if (rleLength == 254) {
writeRun(rleCurrentValue & 0xff, 255);
this.rleLength = 0;
} else {
this.rleLength = rleLength + 1;
}
}
return true;
} | [
"boolean",
"write",
"(",
"final",
"int",
"value",
")",
"{",
"if",
"(",
"blockLength",
">",
"blockLengthLimit",
")",
"{",
"return",
"false",
";",
"}",
"final",
"int",
"rleCurrentValue",
"=",
"this",
".",
"rleCurrentValue",
";",
"final",
"int",
"rleLength",
... | Writes a byte to the block, accumulating to an RLE run where possible.
@param value The byte to write
@return {@code true} if the byte was written, or {@code false} if the block is already full | [
"Writes",
"a",
"byte",
"to",
"the",
"block",
"accumulating",
"to",
"an",
"RLE",
"run",
"where",
"possible",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/compression/Bzip2BlockCompressor.java#L180-L204 | train | Write a single value to the log file. | [
30522,
22017,
20898,
4339,
1006,
2345,
20014,
3643,
1007,
1063,
2065,
1006,
3796,
7770,
13512,
2232,
1028,
3796,
7770,
13512,
27766,
22930,
1007,
1063,
2709,
6270,
1025,
1065,
2345,
20014,
1054,
2571,
10841,
14343,
3372,
10175,
5657,
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/io/file/FileReader.java | FileReader.readBytes | public byte[] readBytes() throws IORuntimeException {
long len = file.length();
if (len >= Integer.MAX_VALUE) {
throw new IORuntimeException("File is larger then max array size");
}
byte[] bytes = new byte[(int) len];
FileInputStream in = null;
int readLength;
try {
in = new FileInputStream(file);
readLength = in.read(bytes);
if(readLength < len){
throw new IOException(StrUtil.format("File length is [{}] but read [{}]!", len, readLength));
}
} catch (Exception e) {
throw new IORuntimeException(e);
} finally {
IoUtil.close(in);
}
return bytes;
} | java | public byte[] readBytes() throws IORuntimeException {
long len = file.length();
if (len >= Integer.MAX_VALUE) {
throw new IORuntimeException("File is larger then max array size");
}
byte[] bytes = new byte[(int) len];
FileInputStream in = null;
int readLength;
try {
in = new FileInputStream(file);
readLength = in.read(bytes);
if(readLength < len){
throw new IOException(StrUtil.format("File length is [{}] but read [{}]!", len, readLength));
}
} catch (Exception e) {
throw new IORuntimeException(e);
} finally {
IoUtil.close(in);
}
return bytes;
} | [
"public",
"byte",
"[",
"]",
"readBytes",
"(",
")",
"throws",
"IORuntimeException",
"{",
"long",
"len",
"=",
"file",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
">=",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IORuntimeException",
"(",
... | 读取文件所有数据<br>
文件的长度不能超过 {@link Integer#MAX_VALUE}
@return 字节码
@throws IORuntimeException IO异常 | [
"读取文件所有数据<br",
">",
"文件的长度不能超过",
"{",
"@link",
"Integer#MAX_VALUE",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/file/FileReader.java#L112-L134 | train | Reads the contents of the file into a byte array. | [
30522,
2270,
24880,
1031,
1033,
3191,
3762,
4570,
1006,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
2146,
18798,
1027,
5371,
1012,
3091,
1006,
1007,
1025,
2065,
1006,
18798,
1028,
1027,
16109,
1012,
4098,
1035,
3643,
1007,
1063,
54... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java | TypeExtractionUtils.extractTypeArgument | public static Type extractTypeArgument(Type t, int index) throws InvalidTypesException {
if (t instanceof ParameterizedType) {
Type[] actualTypeArguments = ((ParameterizedType) t).getActualTypeArguments();
if (index < 0 || index >= actualTypeArguments.length) {
throw new InvalidTypesException("Cannot extract the type argument with index " +
index + " because the type has only " + actualTypeArguments.length +
" type arguments.");
} else {
return actualTypeArguments[index];
}
} else {
throw new InvalidTypesException("The given type " + t + " is not a parameterized type.");
}
} | java | public static Type extractTypeArgument(Type t, int index) throws InvalidTypesException {
if (t instanceof ParameterizedType) {
Type[] actualTypeArguments = ((ParameterizedType) t).getActualTypeArguments();
if (index < 0 || index >= actualTypeArguments.length) {
throw new InvalidTypesException("Cannot extract the type argument with index " +
index + " because the type has only " + actualTypeArguments.length +
" type arguments.");
} else {
return actualTypeArguments[index];
}
} else {
throw new InvalidTypesException("The given type " + t + " is not a parameterized type.");
}
} | [
"public",
"static",
"Type",
"extractTypeArgument",
"(",
"Type",
"t",
",",
"int",
"index",
")",
"throws",
"InvalidTypesException",
"{",
"if",
"(",
"t",
"instanceof",
"ParameterizedType",
")",
"{",
"Type",
"[",
"]",
"actualTypeArguments",
"=",
"(",
"(",
"Paramet... | This method extracts the n-th type argument from the given type. An InvalidTypesException
is thrown if the type does not have any type arguments or if the index exceeds the number
of type arguments.
@param t Type to extract the type arguments from
@param index Index of the type argument to extract
@return The extracted type argument
@throws InvalidTypesException if the given type does not have any type arguments or if the
index exceeds the number of type arguments. | [
"This",
"method",
"extracts",
"the",
"n",
"-",
"th",
"type",
"argument",
"from",
"the",
"given",
"type",
".",
"An",
"InvalidTypesException",
"is",
"thrown",
"if",
"the",
"type",
"does",
"not",
"have",
"any",
"type",
"arguments",
"or",
"if",
"the",
"index",... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java#L194-L208 | train | Extract the type argument at the given index from the given type. | [
30522,
2270,
10763,
2828,
14817,
13874,
2906,
22850,
4765,
1006,
2828,
1056,
1010,
20014,
5950,
1007,
11618,
19528,
13874,
3366,
2595,
24422,
1063,
2065,
1006,
1056,
6013,
11253,
16381,
3550,
13874,
1007,
1063,
2828,
1031,
1033,
5025,
13874,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/ReOpenableMutableHashTable.java | ReOpenableMutableHashTable.storeInitialHashTable | void storeInitialHashTable() throws IOException {
if (spilled) {
return; // we create the initialHashTable only once. Later calls are caused by deeper recursion lvls
}
spilled = true;
for (int partIdx = 0; partIdx < initialPartitions.size(); partIdx++) {
final ReOpenableHashPartition<BT, PT> p = (ReOpenableHashPartition<BT, PT>) initialPartitions.get(partIdx);
if (p.isInMemory()) { // write memory resident partitions to disk
this.writeBehindBuffersAvailable += p.spillInMemoryPartition(spilledInMemoryPartitions.next(), ioManager, writeBehindBuffers);
}
}
} | java | void storeInitialHashTable() throws IOException {
if (spilled) {
return; // we create the initialHashTable only once. Later calls are caused by deeper recursion lvls
}
spilled = true;
for (int partIdx = 0; partIdx < initialPartitions.size(); partIdx++) {
final ReOpenableHashPartition<BT, PT> p = (ReOpenableHashPartition<BT, PT>) initialPartitions.get(partIdx);
if (p.isInMemory()) { // write memory resident partitions to disk
this.writeBehindBuffersAvailable += p.spillInMemoryPartition(spilledInMemoryPartitions.next(), ioManager, writeBehindBuffers);
}
}
} | [
"void",
"storeInitialHashTable",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"spilled",
")",
"{",
"return",
";",
"// we create the initialHashTable only once. Later calls are caused by deeper recursion lvls",
"}",
"spilled",
"=",
"true",
";",
"for",
"(",
"int",
"... | This method stores the initial hash table's contents on disk if hash join needs the memory
for further partition processing.
The initial hash table is rebuild before a new secondary input is opened.
For the sake of simplicity we iterate over all in-memory elements and store them in one file.
The file is hashed into memory upon opening a new probe input.
@throws IOException | [
"This",
"method",
"stores",
"the",
"initial",
"hash",
"table",
"s",
"contents",
"on",
"disk",
"if",
"hash",
"join",
"needs",
"the",
"memory",
"for",
"further",
"partition",
"processing",
".",
"The",
"initial",
"hash",
"table",
"is",
"rebuild",
"before",
"a",... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/ReOpenableMutableHashTable.java#L135-L147 | train | Stores the initial hash table. | [
30522,
11675,
3573,
5498,
20925,
14949,
22893,
3468,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
2065,
1006,
13439,
1007,
1063,
2709,
1025,
1013,
1013,
2057,
3443,
30524,
1014,
1025,
2112,
3593,
2595,
1026,
3988,
19362,
3775,
9285,
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... |
alibaba/canal | deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalStater.java | CanalStater.start | synchronized void start(Properties properties) throws Throwable {
String serverMode = CanalController.getProperty(properties, CanalConstants.CANAL_SERVER_MODE);
if (serverMode.equalsIgnoreCase("kafka")) {
canalMQProducer = new CanalKafkaProducer();
} else if (serverMode.equalsIgnoreCase("rocketmq")) {
canalMQProducer = new CanalRocketMQProducer();
}
if (canalMQProducer != null) {
// disable netty
System.setProperty(CanalConstants.CANAL_WITHOUT_NETTY, "true");
String autoScan = CanalController.getProperty(properties, CanalConstants.CANAL_AUTO_SCAN);
// 设置为raw避免ByteString->Entry的二次解析
System.setProperty("canal.instance.memory.rawEntry", "false");
if ("true".equals(autoScan)) {
String rootDir = CanalController.getProperty(properties, CanalConstants.CANAL_CONF_DIR);
if (StringUtils.isEmpty(rootDir)) {
rootDir = "../conf";
}
File rootdir = new File(rootDir);
if (rootdir.exists()) {
File[] instanceDirs = rootdir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String filename = pathname.getName();
return pathname.isDirectory() && !"spring".equalsIgnoreCase(filename) &&
!"metrics".equalsIgnoreCase(filename);
}
});
if (instanceDirs != null && instanceDirs.length > 0) {
List<String> instances = Lists.transform(Arrays.asList(instanceDirs),
new Function<File, String>() {
@Override
public String apply(File instanceDir) {
return instanceDir.getName();
}
});
System.setProperty(CanalConstants.CANAL_DESTINATIONS, Joiner.on(",").join(instances));
}
}
} else {
String destinations = CanalController.getProperty(properties, CanalConstants.CANAL_DESTINATIONS);
System.setProperty(CanalConstants.CANAL_DESTINATIONS, destinations);
}
}
logger.info("## start the canal server.");
controller = new CanalController(properties);
controller.start();
logger.info("## the canal server is running now ......");
shutdownThread = new Thread() {
public void run() {
try {
logger.info("## stop the canal server");
controller.stop();
CanalLauncher.running = false;
} catch (Throwable e) {
logger.warn("##something goes wrong when stopping canal Server:", e);
} finally {
logger.info("## canal server is down.");
}
}
};
Runtime.getRuntime().addShutdownHook(shutdownThread);
if (canalMQProducer != null) {
canalMQStarter = new CanalMQStarter(canalMQProducer);
MQProperties mqProperties = buildMQProperties(properties);
canalMQStarter.start(mqProperties);
controller.setCanalMQStarter(canalMQStarter);
}
} | java | synchronized void start(Properties properties) throws Throwable {
String serverMode = CanalController.getProperty(properties, CanalConstants.CANAL_SERVER_MODE);
if (serverMode.equalsIgnoreCase("kafka")) {
canalMQProducer = new CanalKafkaProducer();
} else if (serverMode.equalsIgnoreCase("rocketmq")) {
canalMQProducer = new CanalRocketMQProducer();
}
if (canalMQProducer != null) {
// disable netty
System.setProperty(CanalConstants.CANAL_WITHOUT_NETTY, "true");
String autoScan = CanalController.getProperty(properties, CanalConstants.CANAL_AUTO_SCAN);
// 设置为raw避免ByteString->Entry的二次解析
System.setProperty("canal.instance.memory.rawEntry", "false");
if ("true".equals(autoScan)) {
String rootDir = CanalController.getProperty(properties, CanalConstants.CANAL_CONF_DIR);
if (StringUtils.isEmpty(rootDir)) {
rootDir = "../conf";
}
File rootdir = new File(rootDir);
if (rootdir.exists()) {
File[] instanceDirs = rootdir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String filename = pathname.getName();
return pathname.isDirectory() && !"spring".equalsIgnoreCase(filename) &&
!"metrics".equalsIgnoreCase(filename);
}
});
if (instanceDirs != null && instanceDirs.length > 0) {
List<String> instances = Lists.transform(Arrays.asList(instanceDirs),
new Function<File, String>() {
@Override
public String apply(File instanceDir) {
return instanceDir.getName();
}
});
System.setProperty(CanalConstants.CANAL_DESTINATIONS, Joiner.on(",").join(instances));
}
}
} else {
String destinations = CanalController.getProperty(properties, CanalConstants.CANAL_DESTINATIONS);
System.setProperty(CanalConstants.CANAL_DESTINATIONS, destinations);
}
}
logger.info("## start the canal server.");
controller = new CanalController(properties);
controller.start();
logger.info("## the canal server is running now ......");
shutdownThread = new Thread() {
public void run() {
try {
logger.info("## stop the canal server");
controller.stop();
CanalLauncher.running = false;
} catch (Throwable e) {
logger.warn("##something goes wrong when stopping canal Server:", e);
} finally {
logger.info("## canal server is down.");
}
}
};
Runtime.getRuntime().addShutdownHook(shutdownThread);
if (canalMQProducer != null) {
canalMQStarter = new CanalMQStarter(canalMQProducer);
MQProperties mqProperties = buildMQProperties(properties);
canalMQStarter.start(mqProperties);
controller.setCanalMQStarter(canalMQStarter);
}
} | [
"synchronized",
"void",
"start",
"(",
"Properties",
"properties",
")",
"throws",
"Throwable",
"{",
"String",
"serverMode",
"=",
"CanalController",
".",
"getProperty",
"(",
"properties",
",",
"CanalConstants",
".",
"CANAL_SERVER_MODE",
")",
";",
"if",
"(",
"serverM... | 启动方法
@param properties canal.properties 配置
@throws Throwable | [
"启动方法"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalStater.java#L43-L117 | train | Start the application. | [
30522,
25549,
11675,
2707,
1006,
5144,
5144,
1007,
11618,
5466,
3085,
1063,
5164,
8241,
5302,
3207,
1027,
5033,
8663,
13181,
10820,
1012,
2131,
21572,
4842,
3723,
1006,
5144,
1010,
5033,
8663,
12693,
3215,
1012,
5033,
1035,
8241,
1035,
5549... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/InstrumentedExecutors.java | InstrumentedExecutors.newSingleThreadExecutor | public static InstrumentedExecutorService newSingleThreadExecutor(MetricRegistry registry, String name) {
return new InstrumentedExecutorService(Executors.newSingleThreadExecutor(), registry, name);
} | java | public static InstrumentedExecutorService newSingleThreadExecutor(MetricRegistry registry, String name) {
return new InstrumentedExecutorService(Executors.newSingleThreadExecutor(), registry, name);
} | [
"public",
"static",
"InstrumentedExecutorService",
"newSingleThreadExecutor",
"(",
"MetricRegistry",
"registry",
",",
"String",
"name",
")",
"{",
"return",
"new",
"InstrumentedExecutorService",
"(",
"Executors",
".",
"newSingleThreadExecutor",
"(",
")",
",",
"registry",
... | Creates an InstrumentedExecutor that uses a single worker thread operating
off an unbounded queue. (Note however that if this single
thread terminates due to a failure during execution prior to
shutdown, a new one will take its place if needed to execute
subsequent tasks.) Tasks are guaranteed to execute
sequentially, and no more than one task will be active at any
given time. Unlike the otherwise equivalent
{@code newFixedThreadPool(1)} the returned executor is
guaranteed not to be reconfigurable to use additional threads.
@param registry the {@link MetricRegistry} that will contain the metrics.
@param name the (metrics) name for this executor service, see {@link MetricRegistry#name(String, String...)}.
@return the newly created single-threaded Executor
@see Executors#newSingleThreadExecutor() | [
"Creates",
"an",
"InstrumentedExecutor",
"that",
"uses",
"a",
"single",
"worker",
"thread",
"operating",
"off",
"an",
"unbounded",
"queue",
".",
"(",
"Note",
"however",
"that",
"if",
"this",
"single",
"thread",
"terminates",
"due",
"to",
"a",
"failure",
"durin... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/InstrumentedExecutors.java#L154-L156 | train | Create a new single thread executor. | [
30522,
2270,
10763,
6602,
14728,
2595,
8586,
16161,
22573,
2099,
7903,
2063,
2739,
2075,
7485,
28362,
9648,
2595,
8586,
16161,
2099,
1006,
12046,
2890,
24063,
2854,
15584,
1010,
5164,
2171,
1007,
1063,
2709,
2047,
6602,
14728,
2595,
8586,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.checkForOverride | private void checkForOverride(Properties properties, String name, String attr, String value) {
String propertyValue = properties.getProperty(attr);
if (propertyValue != null && !propertyValue.equals(value)) {
LOG.warn(name + ":an attempt to override final parameter: " + attr
+ "; Ignoring.");
}
} | java | private void checkForOverride(Properties properties, String name, String attr, String value) {
String propertyValue = properties.getProperty(attr);
if (propertyValue != null && !propertyValue.equals(value)) {
LOG.warn(name + ":an attempt to override final parameter: " + attr
+ "; Ignoring.");
}
} | [
"private",
"void",
"checkForOverride",
"(",
"Properties",
"properties",
",",
"String",
"name",
",",
"String",
"attr",
",",
"String",
"value",
")",
"{",
"String",
"propertyValue",
"=",
"properties",
".",
"getProperty",
"(",
"attr",
")",
";",
"if",
"(",
"prope... | Print a warning if a property with a given name already exists with a
different value | [
"Print",
"a",
"warning",
"if",
"a",
"property",
"with",
"a",
"given",
"name",
"already",
"exists",
"with",
"a",
"different",
"value"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L3078-L3084 | train | Check if override is allowed. | [
30522,
2797,
11675,
4638,
29278,
7840,
15637,
1006,
5144,
5144,
1010,
5164,
2171,
1010,
5164,
2012,
16344,
1010,
5164,
3643,
1007,
1063,
5164,
3200,
10175,
5657,
1027,
5144,
1012,
2131,
21572,
4842,
3723,
1006,
2012,
16344,
1007,
1025,
2065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java | ThriftCLIServiceClient.executeStatementAsync | @Override
public OperationHandle executeStatementAsync(SessionHandle sessionHandle, String statement,
Map<String, String> confOverlay)
throws HiveSQLException {
return executeStatementInternal(sessionHandle, statement, confOverlay, true);
} | java | @Override
public OperationHandle executeStatementAsync(SessionHandle sessionHandle, String statement,
Map<String, String> confOverlay)
throws HiveSQLException {
return executeStatementInternal(sessionHandle, statement, confOverlay, true);
} | [
"@",
"Override",
"public",
"OperationHandle",
"executeStatementAsync",
"(",
"SessionHandle",
"sessionHandle",
",",
"String",
"statement",
",",
"Map",
"<",
"String",
",",
"String",
">",
"confOverlay",
")",
"throws",
"HiveSQLException",
"{",
"return",
"executeStatementI... | /* (non-Javadoc)
@see org.apache.hive.service.cli.ICLIService#executeStatementAsync(org.apache.hive.service.cli.SessionHandle, java.lang.String, java.util.Map) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java#L124-L129 | train | Execute a statement asynchronously. | [
30522,
1030,
2058,
15637,
30524,
2571,
1010,
5164,
4861,
1010,
4949,
1026,
5164,
1010,
5164,
1028,
9530,
14876,
6299,
8485,
1007,
11618,
26736,
2015,
4160,
2571,
2595,
24422,
1063,
2709,
15389,
9153,
18532,
4765,
18447,
11795,
2389,
1006,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ConfigurationParserUtils.java | ConfigurationParserUtils.getManagedMemoryFraction | public static float getManagedMemoryFraction(Configuration configuration) {
float managedMemoryFraction = configuration.getFloat(TaskManagerOptions.MANAGED_MEMORY_FRACTION);
checkConfigParameter(managedMemoryFraction > 0.0f && managedMemoryFraction < 1.0f, managedMemoryFraction,
TaskManagerOptions.MANAGED_MEMORY_FRACTION.key(),
"MemoryManager fraction of the free memory must be between 0.0 and 1.0");
return managedMemoryFraction;
} | java | public static float getManagedMemoryFraction(Configuration configuration) {
float managedMemoryFraction = configuration.getFloat(TaskManagerOptions.MANAGED_MEMORY_FRACTION);
checkConfigParameter(managedMemoryFraction > 0.0f && managedMemoryFraction < 1.0f, managedMemoryFraction,
TaskManagerOptions.MANAGED_MEMORY_FRACTION.key(),
"MemoryManager fraction of the free memory must be between 0.0 and 1.0");
return managedMemoryFraction;
} | [
"public",
"static",
"float",
"getManagedMemoryFraction",
"(",
"Configuration",
"configuration",
")",
"{",
"float",
"managedMemoryFraction",
"=",
"configuration",
".",
"getFloat",
"(",
"TaskManagerOptions",
".",
"MANAGED_MEMORY_FRACTION",
")",
";",
"checkConfigParameter",
... | Parses the configuration to get the fraction of managed memory and validates the value.
@param configuration configuration object
@return fraction of managed memory | [
"Parses",
"the",
"configuration",
"to",
"get",
"the",
"fraction",
"of",
"managed",
"memory",
"and",
"validates",
"the",
"value",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/util/ConfigurationParserUtils.java#L70-L78 | train | Get the managed memory fraction from the configuration. | [
30522,
2270,
10763,
14257,
2131,
24805,
5999,
4168,
5302,
2854,
27843,
7542,
1006,
9563,
9563,
1007,
1063,
14257,
3266,
4168,
5302,
2854,
27843,
7542,
1027,
9563,
1012,
2131,
10258,
16503,
1006,
4708,
24805,
4590,
30524,
1015,
1012,
1014,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java | BootstrapTools.writeConfiguration | public static void writeConfiguration(Configuration cfg, File file) throws IOException {
try (FileWriter fwrt = new FileWriter(file);
PrintWriter out = new PrintWriter(fwrt)) {
for (String key : cfg.keySet()) {
String value = cfg.getString(key, null);
out.print(key);
out.print(": ");
out.println(value);
}
}
} | java | public static void writeConfiguration(Configuration cfg, File file) throws IOException {
try (FileWriter fwrt = new FileWriter(file);
PrintWriter out = new PrintWriter(fwrt)) {
for (String key : cfg.keySet()) {
String value = cfg.getString(key, null);
out.print(key);
out.print(": ");
out.println(value);
}
}
} | [
"public",
"static",
"void",
"writeConfiguration",
"(",
"Configuration",
"cfg",
",",
"File",
"file",
")",
"throws",
"IOException",
"{",
"try",
"(",
"FileWriter",
"fwrt",
"=",
"new",
"FileWriter",
"(",
"file",
")",
";",
"PrintWriter",
"out",
"=",
"new",
"Print... | Writes a Flink YAML config file from a Flink Configuration object.
@param cfg The Flink config
@param file The File to write to
@throws IOException | [
"Writes",
"a",
"Flink",
"YAML",
"config",
"file",
"from",
"a",
"Flink",
"Configuration",
"object",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java#L311-L321 | train | Write configuration to a file. | [
30522,
2270,
10763,
11675,
4339,
8663,
8873,
27390,
3370,
1006,
9563,
12935,
2290,
1010,
5371,
5371,
1007,
11618,
22834,
10288,
24422,
1063,
3046,
1006,
5371,
15994,
1042,
13088,
2102,
1027,
2047,
5371,
15994,
1006,
5371,
1007,
1025,
6140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/JarClassLoader.java | JarClassLoader.loadJar | public static void loadJar(URLClassLoader loader, File jarFile) throws UtilException {
try {
final Method method = ClassUtil.getDeclaredMethod(URLClassLoader.class, "addURL", URL.class);
if (null != method) {
method.setAccessible(true);
final List<File> jars = loopJar(jarFile);
for (File jar : jars) {
ReflectUtil.invoke(loader, method, new Object[] { jar.toURI().toURL() });
}
}
} catch (IOException e) {
throw new UtilException(e);
}
} | java | public static void loadJar(URLClassLoader loader, File jarFile) throws UtilException {
try {
final Method method = ClassUtil.getDeclaredMethod(URLClassLoader.class, "addURL", URL.class);
if (null != method) {
method.setAccessible(true);
final List<File> jars = loopJar(jarFile);
for (File jar : jars) {
ReflectUtil.invoke(loader, method, new Object[] { jar.toURI().toURL() });
}
}
} catch (IOException e) {
throw new UtilException(e);
}
} | [
"public",
"static",
"void",
"loadJar",
"(",
"URLClassLoader",
"loader",
",",
"File",
"jarFile",
")",
"throws",
"UtilException",
"{",
"try",
"{",
"final",
"Method",
"method",
"=",
"ClassUtil",
".",
"getDeclaredMethod",
"(",
"URLClassLoader",
".",
"class",
",",
... | 加载Jar文件到指定loader中
@param loader {@link URLClassLoader}
@param jarFile 被加载的jar
@throws UtilException IO异常包装和执行异常 | [
"加载Jar文件到指定loader中"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/JarClassLoader.java#L57-L70 | train | Load a jar file. | [
30522,
2270,
10763,
11675,
7170,
16084,
1006,
24471,
15472,
27102,
11066,
2121,
7170,
2121,
1010,
5371,
15723,
8873,
2571,
1007,
11618,
21183,
9463,
2595,
24422,
1063,
3046,
1063,
2345,
4118,
4118,
1027,
2465,
21823,
2140,
1012,
2131,
3207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ssl/OpenSslSessionStats.java | OpenSslSessionStats.ticketKeyFail | public long ticketKeyFail() {
Lock readerLock = context.ctxLock.readLock();
readerLock.lock();
try {
return SSLContext.sessionTicketKeyFail(context.ctx);
} finally {
readerLock.unlock();
}
} | java | public long ticketKeyFail() {
Lock readerLock = context.ctxLock.readLock();
readerLock.lock();
try {
return SSLContext.sessionTicketKeyFail(context.ctx);
} finally {
readerLock.unlock();
}
} | [
"public",
"long",
"ticketKeyFail",
"(",
")",
"{",
"Lock",
"readerLock",
"=",
"context",
".",
"ctxLock",
".",
"readLock",
"(",
")",
";",
"readerLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"SSLContext",
".",
"sessionTicketKeyFail",
"(",
"context... | Returns the number of times a client presented a ticket that did not match any key in the list. | [
"Returns",
"the",
"number",
"of",
"times",
"a",
"client",
"presented",
"a",
"ticket",
"that",
"did",
"not",
"match",
"any",
"key",
"in",
"the",
"list",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/OpenSslSessionStats.java#L204-L212 | train | Gets the ticketKeyFail value. | [
30522,
2270,
2146,
7281,
14839,
7011,
4014,
1006,
1007,
1063,
5843,
8068,
7878,
1027,
6123,
1012,
14931,
2595,
7878,
1012,
3191,
7878,
1006,
1007,
1025,
8068,
7878,
1012,
5843,
1006,
1007,
1025,
3046,
1063,
2709,
7020,
22499,
10111,
18413,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AbstractLauncher.java | AbstractLauncher.addSparkArg | public T addSparkArg(String name, String value) {
SparkSubmitOptionParser validator = new ArgumentValidator(true);
if (validator.MASTER.equals(name)) {
setMaster(value);
} else if (validator.PROPERTIES_FILE.equals(name)) {
setPropertiesFile(value);
} else if (validator.CONF.equals(name)) {
String[] vals = value.split("=", 2);
setConf(vals[0], vals[1]);
} else if (validator.CLASS.equals(name)) {
setMainClass(value);
} else if (validator.JARS.equals(name)) {
builder.jars.clear();
for (String jar : value.split(",")) {
addJar(jar);
}
} else if (validator.FILES.equals(name)) {
builder.files.clear();
for (String file : value.split(",")) {
addFile(file);
}
} else if (validator.PY_FILES.equals(name)) {
builder.pyFiles.clear();
for (String file : value.split(",")) {
addPyFile(file);
}
} else {
validator.parse(Arrays.asList(name, value));
builder.userArgs.add(name);
builder.userArgs.add(value);
}
return self();
} | java | public T addSparkArg(String name, String value) {
SparkSubmitOptionParser validator = new ArgumentValidator(true);
if (validator.MASTER.equals(name)) {
setMaster(value);
} else if (validator.PROPERTIES_FILE.equals(name)) {
setPropertiesFile(value);
} else if (validator.CONF.equals(name)) {
String[] vals = value.split("=", 2);
setConf(vals[0], vals[1]);
} else if (validator.CLASS.equals(name)) {
setMainClass(value);
} else if (validator.JARS.equals(name)) {
builder.jars.clear();
for (String jar : value.split(",")) {
addJar(jar);
}
} else if (validator.FILES.equals(name)) {
builder.files.clear();
for (String file : value.split(",")) {
addFile(file);
}
} else if (validator.PY_FILES.equals(name)) {
builder.pyFiles.clear();
for (String file : value.split(",")) {
addPyFile(file);
}
} else {
validator.parse(Arrays.asList(name, value));
builder.userArgs.add(name);
builder.userArgs.add(value);
}
return self();
} | [
"public",
"T",
"addSparkArg",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"SparkSubmitOptionParser",
"validator",
"=",
"new",
"ArgumentValidator",
"(",
"true",
")",
";",
"if",
"(",
"validator",
".",
"MASTER",
".",
"equals",
"(",
"name",
")",
"... | Adds an argument with a value to the Spark invocation. If the argument name corresponds to
a known argument, the code validates that the argument actually expects a value, and throws
an exception otherwise.
<p>
It is safe to add arguments modified by other methods in this class (such as
{@link #setMaster(String)} - the last invocation will be the one to take effect.
<p>
Use this method with caution. It is possible to create an invalid Spark command by passing
unknown arguments to this method, since those are allowed for forward compatibility.
@since 1.5.0
@param name Name of argument to add.
@param value Value of the argument.
@return This launcher. | [
"Adds",
"an",
"argument",
"with",
"a",
"value",
"to",
"the",
"Spark",
"invocation",
".",
"If",
"the",
"argument",
"name",
"corresponds",
"to",
"a",
"known",
"argument",
"the",
"code",
"validates",
"that",
"the",
"argument",
"actually",
"expects",
"a",
"value... | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/launcher/src/main/java/org/apache/spark/launcher/AbstractLauncher.java#L162-L194 | train | Adds a SparkSubmitOption to the SparkSubmitOptions object. | [
30522,
2270,
1056,
9909,
14432,
2906,
2290,
1006,
5164,
2171,
1010,
5164,
3643,
1007,
1063,
12300,
12083,
22930,
7361,
3508,
19362,
8043,
9398,
8844,
1027,
2047,
6685,
10175,
8524,
4263,
1006,
2995,
1007,
1025,
2065,
1006,
9398,
8844,
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-db/src/main/java/cn/hutool/db/Entity.java | Entity.parseWithUnderlineCase | public static <T> Entity parseWithUnderlineCase(T bean) {
return create(null).parseBean(bean, true, true);
} | java | public static <T> Entity parseWithUnderlineCase(T bean) {
return create(null).parseBean(bean, true, true);
} | [
"public",
"static",
"<",
"T",
">",
"Entity",
"parseWithUnderlineCase",
"(",
"T",
"bean",
")",
"{",
"return",
"create",
"(",
"null",
")",
".",
"parseBean",
"(",
"bean",
",",
"true",
",",
"true",
")",
";",
"}"
] | 将PO对象转为Entity,并采用下划线法转换字段
@param <T> Bean对象类型
@param bean Bean对象
@return Entity | [
"将PO对象转为Entity",
"并采用下划线法转换字段"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/Entity.java#L85-L87 | train | Parses the given bean with underline case. | [
30522,
2270,
10763,
1026,
1056,
1028,
9178,
11968,
3366,
24415,
20824,
4179,
18382,
1006,
1056,
14068,
1007,
1063,
2709,
3443,
1006,
19701,
1007,
1012,
11968,
3366,
4783,
2319,
1006,
14068,
1010,
2995,
1010,
2995,
1007,
1025,
1065,
102,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java | AbstractTemplateViewResolverProperties.applyToMvcViewResolver | public void applyToMvcViewResolver(Object viewResolver) {
Assert.isInstanceOf(AbstractTemplateViewResolver.class, viewResolver,
"ViewResolver is not an instance of AbstractTemplateViewResolver :"
+ viewResolver);
AbstractTemplateViewResolver resolver = (AbstractTemplateViewResolver) viewResolver;
resolver.setPrefix(getPrefix());
resolver.setSuffix(getSuffix());
resolver.setCache(isCache());
if (getContentType() != null) {
resolver.setContentType(getContentType().toString());
}
resolver.setViewNames(getViewNames());
resolver.setExposeRequestAttributes(isExposeRequestAttributes());
resolver.setAllowRequestOverride(isAllowRequestOverride());
resolver.setAllowSessionOverride(isAllowSessionOverride());
resolver.setExposeSessionAttributes(isExposeSessionAttributes());
resolver.setExposeSpringMacroHelpers(isExposeSpringMacroHelpers());
resolver.setRequestContextAttribute(getRequestContextAttribute());
// The resolver usually acts as a fallback resolver (e.g. like a
// InternalResourceViewResolver) so it needs to have low precedence
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
} | java | public void applyToMvcViewResolver(Object viewResolver) {
Assert.isInstanceOf(AbstractTemplateViewResolver.class, viewResolver,
"ViewResolver is not an instance of AbstractTemplateViewResolver :"
+ viewResolver);
AbstractTemplateViewResolver resolver = (AbstractTemplateViewResolver) viewResolver;
resolver.setPrefix(getPrefix());
resolver.setSuffix(getSuffix());
resolver.setCache(isCache());
if (getContentType() != null) {
resolver.setContentType(getContentType().toString());
}
resolver.setViewNames(getViewNames());
resolver.setExposeRequestAttributes(isExposeRequestAttributes());
resolver.setAllowRequestOverride(isAllowRequestOverride());
resolver.setAllowSessionOverride(isAllowSessionOverride());
resolver.setExposeSessionAttributes(isExposeSessionAttributes());
resolver.setExposeSpringMacroHelpers(isExposeSpringMacroHelpers());
resolver.setRequestContextAttribute(getRequestContextAttribute());
// The resolver usually acts as a fallback resolver (e.g. like a
// InternalResourceViewResolver) so it needs to have low precedence
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
} | [
"public",
"void",
"applyToMvcViewResolver",
"(",
"Object",
"viewResolver",
")",
"{",
"Assert",
".",
"isInstanceOf",
"(",
"AbstractTemplateViewResolver",
".",
"class",
",",
"viewResolver",
",",
"\"ViewResolver is not an instance of AbstractTemplateViewResolver :\"",
"+",
"view... | Apply the given properties to a {@link AbstractTemplateViewResolver}. Use Object in
signature to avoid runtime dependency on MVC, which means that the template engine
can be used in a non-web application.
@param viewResolver the resolver to apply the properties to. | [
"Apply",
"the",
"given",
"properties",
"to",
"a",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java#L155-L176 | train | Apply this view resolver to the given view resolver. | [
30522,
2270,
11675,
6611,
20389,
25465,
8584,
6072,
4747,
6299,
1006,
4874,
3193,
6072,
4747,
6299,
1007,
1063,
20865,
1012,
2003,
7076,
26897,
11253,
1006,
10061,
18532,
15725,
8584,
6072,
4747,
6299,
1012,
2465,
1010,
3193,
6072,
4747,
62... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ConstantPool.java | ConstantPool.getOrCreate | private T getOrCreate(String name) {
T constant = constants.get(name);
if (constant == null) {
final T tempConstant = newConstant(nextId(), name);
constant = constants.putIfAbsent(name, tempConstant);
if (constant == null) {
return tempConstant;
}
}
return constant;
} | java | private T getOrCreate(String name) {
T constant = constants.get(name);
if (constant == null) {
final T tempConstant = newConstant(nextId(), name);
constant = constants.putIfAbsent(name, tempConstant);
if (constant == null) {
return tempConstant;
}
}
return constant;
} | [
"private",
"T",
"getOrCreate",
"(",
"String",
"name",
")",
"{",
"T",
"constant",
"=",
"constants",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"constant",
"==",
"null",
")",
"{",
"final",
"T",
"tempConstant",
"=",
"newConstant",
"(",
"nextId",
"(",
... | Get existing constant by name or creates new one if not exists. Threadsafe
@param name the name of the {@link Constant} | [
"Get",
"existing",
"constant",
"by",
"name",
"or",
"creates",
"new",
"one",
"if",
"not",
"exists",
".",
"Threadsafe"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/ConstantPool.java#L68-L79 | train | Gets or creates a new instance of the class with the given name. | [
30522,
2797,
1056,
2131,
2953,
16748,
3686,
1006,
5164,
2171,
1007,
1063,
1056,
5377,
1027,
5377,
2015,
1012,
2131,
1006,
2171,
1007,
1025,
2065,
1006,
5377,
1027,
1027,
19701,
1007,
1063,
2345,
1056,
8915,
8737,
8663,
12693,
2102,
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... |
netty/netty | handler/src/main/java/io/netty/handler/ssl/SslContextBuilder.java | SslContextBuilder.keyManager | public SslContextBuilder keyManager(File keyCertChainFile, File keyFile, String keyPassword) {
X509Certificate[] keyCertChain;
PrivateKey key;
try {
keyCertChain = SslContext.toX509Certificates(keyCertChainFile);
} catch (Exception e) {
throw new IllegalArgumentException("File does not contain valid certificates: " + keyCertChainFile, e);
}
try {
key = SslContext.toPrivateKey(keyFile, keyPassword);
} catch (Exception e) {
throw new IllegalArgumentException("File does not contain valid private key: " + keyFile, e);
}
return keyManager(key, keyPassword, keyCertChain);
} | java | public SslContextBuilder keyManager(File keyCertChainFile, File keyFile, String keyPassword) {
X509Certificate[] keyCertChain;
PrivateKey key;
try {
keyCertChain = SslContext.toX509Certificates(keyCertChainFile);
} catch (Exception e) {
throw new IllegalArgumentException("File does not contain valid certificates: " + keyCertChainFile, e);
}
try {
key = SslContext.toPrivateKey(keyFile, keyPassword);
} catch (Exception e) {
throw new IllegalArgumentException("File does not contain valid private key: " + keyFile, e);
}
return keyManager(key, keyPassword, keyCertChain);
} | [
"public",
"SslContextBuilder",
"keyManager",
"(",
"File",
"keyCertChainFile",
",",
"File",
"keyFile",
",",
"String",
"keyPassword",
")",
"{",
"X509Certificate",
"[",
"]",
"keyCertChain",
";",
"PrivateKey",
"key",
";",
"try",
"{",
"keyCertChain",
"=",
"SslContext",... | Identifying certificate for this host. {@code keyCertChainFile} and {@code keyFile} may
be {@code null} for client contexts, which disables mutual authentication.
@param keyCertChainFile an X.509 certificate chain file in PEM format
@param keyFile a PKCS#8 private key file in PEM format
@param keyPassword the password of the {@code keyFile}, or {@code null} if it's not
password-protected | [
"Identifying",
"certificate",
"for",
"this",
"host",
".",
"{",
"@code",
"keyCertChainFile",
"}",
"and",
"{",
"@code",
"keyFile",
"}",
"may",
"be",
"{",
"@code",
"null",
"}",
"for",
"client",
"contexts",
"which",
"disables",
"mutual",
"authentication",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/SslContextBuilder.java#L259-L273 | train | Key manager method. | [
30522,
2270,
7020,
22499,
10111,
18413,
8569,
23891,
2099,
3145,
24805,
4590,
1006,
5371,
3145,
17119,
10649,
8113,
8873,
2571,
1010,
5371,
3145,
8873,
2571,
1010,
5164,
3145,
15194,
18351,
1007,
1063,
1060,
12376,
2683,
17119,
3775,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | header/src/main/java/com/networknt/header/HeaderHandler.java | HeaderHandler.handleRequest | @Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
// handle request header
Map<String, Object> requestHeaderMap = (Map<String, Object>)config.get(REQUEST);
if(requestHeaderMap != null) {
List<String> requestHeaderRemove = (List<String>)requestHeaderMap.get(REMOVE);
if(requestHeaderRemove != null) {
requestHeaderRemove.forEach(s -> exchange.getRequestHeaders().remove(s));
}
Map<String, String> requestHeaderUpdate = (Map<String, String>)requestHeaderMap.get(UPDATE);
if(requestHeaderUpdate != null) {
requestHeaderUpdate.forEach((k, v) -> exchange.getRequestHeaders().put(new HttpString(k), v));
}
}
// handle response header
Map<String, Object> responseHeaderMap = (Map<String, Object>)config.get(RESPONSE);
if(responseHeaderMap != null) {
List<String> responseHeaderRemove = (List<String>)responseHeaderMap.get(REMOVE);
if(responseHeaderRemove != null) {
responseHeaderRemove.forEach(s -> exchange.getResponseHeaders().remove(s));
}
Map<String, String> responseHeaderUpdate = (Map<String, String>)responseHeaderMap.get(UPDATE);
if(responseHeaderUpdate != null) {
responseHeaderUpdate.forEach((k, v) -> exchange.getResponseHeaders().put(new HttpString(k), v));
}
}
Handler.next(exchange, next);
} | java | @Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
// handle request header
Map<String, Object> requestHeaderMap = (Map<String, Object>)config.get(REQUEST);
if(requestHeaderMap != null) {
List<String> requestHeaderRemove = (List<String>)requestHeaderMap.get(REMOVE);
if(requestHeaderRemove != null) {
requestHeaderRemove.forEach(s -> exchange.getRequestHeaders().remove(s));
}
Map<String, String> requestHeaderUpdate = (Map<String, String>)requestHeaderMap.get(UPDATE);
if(requestHeaderUpdate != null) {
requestHeaderUpdate.forEach((k, v) -> exchange.getRequestHeaders().put(new HttpString(k), v));
}
}
// handle response header
Map<String, Object> responseHeaderMap = (Map<String, Object>)config.get(RESPONSE);
if(responseHeaderMap != null) {
List<String> responseHeaderRemove = (List<String>)responseHeaderMap.get(REMOVE);
if(responseHeaderRemove != null) {
responseHeaderRemove.forEach(s -> exchange.getResponseHeaders().remove(s));
}
Map<String, String> responseHeaderUpdate = (Map<String, String>)responseHeaderMap.get(UPDATE);
if(responseHeaderUpdate != null) {
responseHeaderUpdate.forEach((k, v) -> exchange.getResponseHeaders().put(new HttpString(k), v));
}
}
Handler.next(exchange, next);
} | [
"@",
"Override",
"public",
"void",
"handleRequest",
"(",
"final",
"HttpServerExchange",
"exchange",
")",
"throws",
"Exception",
"{",
"// handle request header",
"Map",
"<",
"String",
",",
"Object",
">",
"requestHeaderMap",
"=",
"(",
"Map",
"<",
"String",
",",
"O... | Check iterate the configuration on both request and response section and update
headers accordingly.
@param exchange HttpServerExchange
@throws Exception Exception | [
"Check",
"iterate",
"the",
"configuration",
"on",
"both",
"request",
"and",
"response",
"section",
"and",
"update",
"headers",
"accordingly",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/header/src/main/java/com/networknt/header/HeaderHandler.java#L67-L96 | train | Handle request and response headers. | [
30522,
1030,
2058,
15637,
2270,
11675,
28213,
2063,
15500,
1006,
2345,
16770,
2121,
28943,
2595,
22305,
2063,
3863,
1007,
11618,
6453,
1063,
1013,
1013,
5047,
5227,
20346,
4949,
1026,
5164,
1010,
4874,
1028,
5227,
4974,
2121,
2863,
2361,
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... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java | Bindable.getAnnotation | @SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<A> type) {
for (Annotation annotation : this.annotations) {
if (type.isInstance(annotation)) {
return (A) annotation;
}
}
return null;
} | java | @SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<A> type) {
for (Annotation annotation : this.annotations) {
if (type.isInstance(annotation)) {
return (A) annotation;
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"A",
"extends",
"Annotation",
">",
"A",
"getAnnotation",
"(",
"Class",
"<",
"A",
">",
"type",
")",
"{",
"for",
"(",
"Annotation",
"annotation",
":",
"this",
".",
"annotations",
")",
"{",
... | Return a single associated annotations that could affect binding.
@param <A> the annotation type
@param type annotation type
@return the associated annotation or {@code null} | [
"Return",
"a",
"single",
"associated",
"annotations",
"that",
"could",
"affect",
"binding",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java#L99-L107 | train | Gets the annotation of the given type. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2270,
1026,
1037,
8908,
5754,
17287,
3508,
1028,
1037,
2131,
11639,
17287,
3508,
1006,
2465,
1026,
1037,
1028,
2828,
1007,
30524,
2828,
1012,
2003,
7076,
26897... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java | TypeExtractor.privateCreateTypeInfo | @SuppressWarnings("unchecked")
private <IN1, IN2, OUT> TypeInformation<OUT> privateCreateTypeInfo(Type returnType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
ArrayList<Type> typeHierarchy = new ArrayList<Type>();
// get info from hierarchy
return (TypeInformation<OUT>) createTypeInfoWithTypeHierarchy(typeHierarchy, returnType, in1Type, in2Type);
} | java | @SuppressWarnings("unchecked")
private <IN1, IN2, OUT> TypeInformation<OUT> privateCreateTypeInfo(Type returnType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
ArrayList<Type> typeHierarchy = new ArrayList<Type>();
// get info from hierarchy
return (TypeInformation<OUT>) createTypeInfoWithTypeHierarchy(typeHierarchy, returnType, in1Type, in2Type);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"IN1",
",",
"IN2",
",",
"OUT",
">",
"TypeInformation",
"<",
"OUT",
">",
"privateCreateTypeInfo",
"(",
"Type",
"returnType",
",",
"TypeInformation",
"<",
"IN1",
">",
"in1Type",
",",
"TypeInform... | for LambdaFunctions | [
"for",
"LambdaFunctions"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L807-L813 | train | private static final int MAX_TYPE_COUNT = 2 ; | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2797,
1026,
1999,
2487,
1010,
1999,
2475,
1010,
2041,
1028,
2828,
2378,
14192,
3370,
1026,
2041,
1028,
2797,
16748,
3686,
13874,
2378,
14876,
1006,
2828,
2709,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/img/Img.java | Img.fixRectangle | private Rectangle fixRectangle(Rectangle rectangle, int baseWidth, int baseHeight) {
if (this.positionBaseCentre) {
// 修正图片位置从背景的中心计算
rectangle.setLocation(//
rectangle.x + (int) (Math.abs(baseWidth - rectangle.width) / 2), //
rectangle.y + (int) (Math.abs(baseHeight - rectangle.height) / 2)//
);
}
return rectangle;
} | java | private Rectangle fixRectangle(Rectangle rectangle, int baseWidth, int baseHeight) {
if (this.positionBaseCentre) {
// 修正图片位置从背景的中心计算
rectangle.setLocation(//
rectangle.x + (int) (Math.abs(baseWidth - rectangle.width) / 2), //
rectangle.y + (int) (Math.abs(baseHeight - rectangle.height) / 2)//
);
}
return rectangle;
} | [
"private",
"Rectangle",
"fixRectangle",
"(",
"Rectangle",
"rectangle",
",",
"int",
"baseWidth",
",",
"int",
"baseHeight",
")",
"{",
"if",
"(",
"this",
".",
"positionBaseCentre",
")",
"{",
"// 修正图片位置从背景的中心计算\r",
"rectangle",
".",
"setLocation",
"(",
"//\r",
"rect... | 修正矩形框位置,如果{@link Img#setPositionFromCentre(boolean)} 设为{@code true},则坐标修正为基于图形中心,否则基于左上角
@param rectangle 矩形
@param baseWidth 参考宽
@param baseHeight 参考高
@return 修正后的{@link Rectangle}
@since 4.1.15 | [
"修正矩形框位置,如果",
"{",
"@link",
"Img#setPositionFromCentre",
"(",
"boolean",
")",
"}",
"设为",
"{",
"@code",
"true",
"}",
",则坐标修正为基于图形中心,否则基于左上角"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/Img.java#L616-L625 | train | Fix the rectangle. | [
30522,
2797,
28667,
23395,
8081,
2890,
25572,
3070,
2571,
1006,
28667,
23395,
28667,
23395,
1010,
20014,
2918,
9148,
11927,
2232,
1010,
20014,
2918,
26036,
13900,
1007,
1063,
2065,
1006,
2023,
1012,
2597,
15058,
13013,
2890,
1007,
1063,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/SocketClientSink.java | SocketClientSink.createConnection | private void createConnection() throws IOException {
client = new Socket(hostName, port);
client.setKeepAlive(true);
client.setTcpNoDelay(true);
outputStream = client.getOutputStream();
} | java | private void createConnection() throws IOException {
client = new Socket(hostName, port);
client.setKeepAlive(true);
client.setTcpNoDelay(true);
outputStream = client.getOutputStream();
} | [
"private",
"void",
"createConnection",
"(",
")",
"throws",
"IOException",
"{",
"client",
"=",
"new",
"Socket",
"(",
"hostName",
",",
"port",
")",
";",
"client",
".",
"setKeepAlive",
"(",
"true",
")",
";",
"client",
".",
"setTcpNoDelay",
"(",
"true",
")",
... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/SocketClientSink.java#L252-L258 | train | Create a connection to the server. | [
30522,
2797,
11675,
3443,
8663,
2638,
7542,
1006,
1007,
11618,
22834,
10288,
24422,
1063,
7396,
1027,
2047,
22278,
1006,
3677,
18442,
1010,
3417,
1007,
1025,
7396,
1012,
2275,
20553,
12952,
3512,
1006,
2995,
1007,
1025,
7396,
1012,
2275,
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... |
netty/netty | codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java | DefaultHttp2LocalFlowController.windowUpdateRatio | public void windowUpdateRatio(float ratio) {
assert ctx == null || ctx.executor().inEventLoop();
checkValidRatio(ratio);
windowUpdateRatio = ratio;
} | java | public void windowUpdateRatio(float ratio) {
assert ctx == null || ctx.executor().inEventLoop();
checkValidRatio(ratio);
windowUpdateRatio = ratio;
} | [
"public",
"void",
"windowUpdateRatio",
"(",
"float",
"ratio",
")",
"{",
"assert",
"ctx",
"==",
"null",
"||",
"ctx",
".",
"executor",
"(",
")",
".",
"inEventLoop",
"(",
")",
";",
"checkValidRatio",
"(",
"ratio",
")",
";",
"windowUpdateRatio",
"=",
"ratio",
... | The window update ratio is used to determine when a window update must be sent. If the ratio
of bytes processed since the last update has meet or exceeded this ratio then a window update will
be sent. This is the global window update ratio that will be used for new streams.
@param ratio the ratio to use when checking if a {@code WINDOW_UPDATE} is determined necessary for new streams.
@throws IllegalArgumentException If the ratio is out of bounds (0, 1). | [
"The",
"window",
"update",
"ratio",
"is",
"used",
"to",
"determine",
"when",
"a",
"window",
"update",
"must",
"be",
"sent",
".",
"If",
"the",
"ratio",
"of",
"bytes",
"processed",
"since",
"the",
"last",
"update",
"has",
"meet",
"or",
"exceeded",
"this",
... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java#L214-L218 | train | Sets the window update ratio. | [
30522,
2270,
11675,
3332,
6279,
13701,
8609,
3695,
1006,
14257,
6463,
1007,
1063,
20865,
14931,
2595,
1027,
1027,
19701,
1064,
1064,
14931,
2595,
1012,
4654,
8586,
16161,
2099,
1006,
1007,
1012,
1999,
18697,
3372,
4135,
7361,
1006,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/DataSet.java | DataSet.join | public <R> JoinOperatorSets<T, R> join(DataSet<R> other, JoinHint strategy) {
return new JoinOperatorSets<>(this, other, strategy);
} | java | public <R> JoinOperatorSets<T, R> join(DataSet<R> other, JoinHint strategy) {
return new JoinOperatorSets<>(this, other, strategy);
} | [
"public",
"<",
"R",
">",
"JoinOperatorSets",
"<",
"T",
",",
"R",
">",
"join",
"(",
"DataSet",
"<",
"R",
">",
"other",
",",
"JoinHint",
"strategy",
")",
"{",
"return",
"new",
"JoinOperatorSets",
"<>",
"(",
"this",
",",
"other",
",",
"strategy",
")",
"... | Initiates a Join transformation.
<p>A Join transformation joins the elements of two
{@link DataSet DataSets} on key equality and provides multiple ways to combine
joining elements into one DataSet.
<p>This method returns a {@link JoinOperatorSets} on which one of the {@code where} methods
can be called to define the join key of the first joining (i.e., this) DataSet.
@param other The other DataSet with which this DataSet is joined.
@param strategy The strategy that should be used execute the join. If {@code null} is given, then the
optimizer will pick the join strategy.
@return A JoinOperatorSets to continue the definition of the Join transformation.
@see JoinOperatorSets
@see DataSet | [
"Initiates",
"a",
"Join",
"transformation",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/DataSet.java#L773-L775 | train | Create a new JoinOperatorSets object that joins the data set with the given data set. | [
30522,
2270,
1026,
1054,
1028,
3693,
25918,
18926,
8454,
1026,
1056,
1010,
1054,
1028,
3693,
1006,
2951,
13462,
1026,
1054,
1028,
2060,
1010,
3693,
10606,
2102,
5656,
1007,
1063,
2709,
2047,
3693,
25918,
18926,
8454,
1026,
1028,
1006,
2023,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceUnwrapper.java | DataSourceUnwrapper.unwrap | public static <T> T unwrap(DataSource dataSource, Class<T> target) {
if (target.isInstance(dataSource)) {
return target.cast(dataSource);
}
T unwrapped = safeUnwrap(dataSource, target);
if (unwrapped != null) {
return unwrapped;
}
if (DELEGATING_DATA_SOURCE_PRESENT) {
DataSource targetDataSource = DelegatingDataSourceUnwrapper
.getTargetDataSource(dataSource);
if (targetDataSource != null) {
return unwrap(targetDataSource, target);
}
}
if (AopUtils.isAopProxy(dataSource)) {
Object proxyTarget = AopProxyUtils.getSingletonTarget(dataSource);
if (proxyTarget instanceof DataSource) {
return unwrap((DataSource) proxyTarget, target);
}
}
return null;
} | java | public static <T> T unwrap(DataSource dataSource, Class<T> target) {
if (target.isInstance(dataSource)) {
return target.cast(dataSource);
}
T unwrapped = safeUnwrap(dataSource, target);
if (unwrapped != null) {
return unwrapped;
}
if (DELEGATING_DATA_SOURCE_PRESENT) {
DataSource targetDataSource = DelegatingDataSourceUnwrapper
.getTargetDataSource(dataSource);
if (targetDataSource != null) {
return unwrap(targetDataSource, target);
}
}
if (AopUtils.isAopProxy(dataSource)) {
Object proxyTarget = AopProxyUtils.getSingletonTarget(dataSource);
if (proxyTarget instanceof DataSource) {
return unwrap((DataSource) proxyTarget, target);
}
}
return null;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"unwrap",
"(",
"DataSource",
"dataSource",
",",
"Class",
"<",
"T",
">",
"target",
")",
"{",
"if",
"(",
"target",
".",
"isInstance",
"(",
"dataSource",
")",
")",
"{",
"return",
"target",
".",
"cast",
"(",
"dataS... | Return an object that implements the given {@code target} type, unwrapping delegate
or proxy if necessary.
@param dataSource the datasource to handle
@param target the type that the result must implement
@param <T> the target type
@return an object that implements the target type or {@code null} | [
"Return",
"an",
"object",
"that",
"implements",
"the",
"given",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceUnwrapper.java#L53-L75 | train | Unwrap the given DataSource and target class. | [
30522,
2270,
10763,
1026,
1056,
1028,
1056,
4895,
13088,
9331,
1006,
2951,
6499,
3126,
3401,
2951,
6499,
3126,
3401,
1010,
2465,
1026,
1056,
1028,
4539,
1007,
1063,
2065,
1006,
4539,
1012,
2003,
7076,
26897,
1006,
2951,
6499,
3126,
3401,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-filesystems/flink-swift-fs-hadoop/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.getPropsWithPrefix | public Map<String, String> getPropsWithPrefix(String confPrefix) {
Map<String, String> configMap = new HashMap<>();
for (Entry<String, String> entry : this) {
String name = entry.getKey();
if (name.startsWith(confPrefix)) {
String value = this.get(name);
name = name.substring(confPrefix.length());
configMap.put(name, value);
}
}
return configMap;
} | java | public Map<String, String> getPropsWithPrefix(String confPrefix) {
Map<String, String> configMap = new HashMap<>();
for (Entry<String, String> entry : this) {
String name = entry.getKey();
if (name.startsWith(confPrefix)) {
String value = this.get(name);
name = name.substring(confPrefix.length());
configMap.put(name, value);
}
}
return configMap;
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getPropsWithPrefix",
"(",
"String",
"confPrefix",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"configMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",... | Constructs a mapping of configuration and includes all properties that
start with the specified configuration prefix. Property names in the
mapping are trimmed to remove the configuration prefix.
@param confPrefix configuration prefix
@return mapping of configuration properties with prefix stripped | [
"Constructs",
"a",
"mapping",
"of",
"configuration",
"and",
"includes",
"all",
"properties",
"that",
"start",
"with",
"the",
"specified",
"configuration",
"prefix",
".",
"Property",
"names",
"in",
"the",
"mapping",
"are",
"trimmed",
"to",
"remove",
"the",
"confi... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-swift-fs-hadoop/src/main/java/org/apache/hadoop/conf/Configuration.java#L2455-L2466 | train | Get the props with the specified prefix. | [
30522,
2270,
4949,
1026,
5164,
1010,
5164,
1028,
2131,
21572,
4523,
24415,
28139,
8873,
2595,
30524,
1027,
4443,
1012,
2131,
14839,
1006,
1007,
1025,
2065,
1006,
2171,
1012,
4627,
24415,
1006,
9530,
22540,
2890,
8873,
2595,
1007,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java | Binder.bind | public <T> BindResult<T> bind(String name, Bindable<T> target, BindHandler handler) {
return bind(ConfigurationPropertyName.of(name), target, handler);
} | java | public <T> BindResult<T> bind(String name, Bindable<T> target, BindHandler handler) {
return bind(ConfigurationPropertyName.of(name), target, handler);
} | [
"public",
"<",
"T",
">",
"BindResult",
"<",
"T",
">",
"bind",
"(",
"String",
"name",
",",
"Bindable",
"<",
"T",
">",
"target",
",",
"BindHandler",
"handler",
")",
"{",
"return",
"bind",
"(",
"ConfigurationPropertyName",
".",
"of",
"(",
"name",
")",
","... | Bind the specified target {@link Bindable} using this binder's
{@link ConfigurationPropertySource property sources}.
@param name the configuration property name to bind
@param target the target bindable
@param handler the bind handler (may be {@code null})
@param <T> the bound type
@return the binding result (never {@code null}) | [
"Bind",
"the",
"specified",
"target",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java#L190-L192 | train | Binds the given target object to the given handler. | [
30522,
2270,
1026,
1056,
1028,
14187,
6072,
11314,
1026,
1056,
1028,
14187,
1006,
5164,
2171,
1010,
14187,
3085,
1026,
1056,
1028,
4539,
1010,
14187,
11774,
3917,
28213,
1007,
1063,
2709,
14187,
1006,
9563,
21572,
30524,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/util/Precompiler.java | Precompiler.compileWithoutNS | public static void compileWithoutNS(List<IWord> wordList)
{
for (IWord word : wordList)
{
if (word.getLabel().startsWith("ns")) continue;
word.setValue(PosTagCompiler.compile(word.getLabel(), word.getValue()));
// switch (word.getLabel())
// {
// case "nx":
// {
// word.setValue(Predefine.TAG_PROPER);
// }
// break;
// case "nt":
// case "ntc":
// case "ntcf":
// case "ntcb":
// case "ntch":
// case "nto":
// case "ntu":
// case "nts":
// case "nth":
// {
// word.setValue(Predefine.TAG_GROUP);
// }
// break;
// case "m":
// case "mq":
// {
// word.setValue(Predefine.TAG_NUMBER);
// }
// break;
// case "x":
// {
// word.setValue(Predefine.TAG_CLUSTER);
// }
// break;
// case "xx":
// {
// word.setValue(Predefine.TAG_OTHER);
// }
// break;
// case "t":
// {
// word.setValue(Predefine.TAG_TIME);
// }
// break;
// case "nr":
// {
// word.setValue(Predefine.TAG_PEOPLE);
// }
// break;
// }
}
} | java | public static void compileWithoutNS(List<IWord> wordList)
{
for (IWord word : wordList)
{
if (word.getLabel().startsWith("ns")) continue;
word.setValue(PosTagCompiler.compile(word.getLabel(), word.getValue()));
// switch (word.getLabel())
// {
// case "nx":
// {
// word.setValue(Predefine.TAG_PROPER);
// }
// break;
// case "nt":
// case "ntc":
// case "ntcf":
// case "ntcb":
// case "ntch":
// case "nto":
// case "ntu":
// case "nts":
// case "nth":
// {
// word.setValue(Predefine.TAG_GROUP);
// }
// break;
// case "m":
// case "mq":
// {
// word.setValue(Predefine.TAG_NUMBER);
// }
// break;
// case "x":
// {
// word.setValue(Predefine.TAG_CLUSTER);
// }
// break;
// case "xx":
// {
// word.setValue(Predefine.TAG_OTHER);
// }
// break;
// case "t":
// {
// word.setValue(Predefine.TAG_TIME);
// }
// break;
// case "nr":
// {
// word.setValue(Predefine.TAG_PEOPLE);
// }
// break;
// }
}
} | [
"public",
"static",
"void",
"compileWithoutNS",
"(",
"List",
"<",
"IWord",
">",
"wordList",
")",
"{",
"for",
"(",
"IWord",
"word",
":",
"wordList",
")",
"{",
"if",
"(",
"word",
".",
"getLabel",
"(",
")",
".",
"startsWith",
"(",
"\"ns\"",
")",
")",
"c... | 在忽略ns的前提下预编译
@param wordList | [
"在忽略ns的前提下预编译"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/corpus/util/Precompiler.java#L104-L158 | train | Compile the list of words without the NSSP prefix. | [
30522,
2270,
10763,
11675,
4012,
22090,
24415,
5833,
3619,
1006,
2862,
1026,
1045,
18351,
1028,
2773,
9863,
1007,
1063,
2005,
1006,
1045,
18351,
2773,
1024,
2773,
9863,
1007,
1063,
2065,
1006,
2773,
1012,
2131,
20470,
2884,
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... |
apache/incubator-shardingsphere | sharding-orchestration/sharding-orchestration-core/src/main/java/org/apache/shardingsphere/orchestration/internal/registry/RegistryCenterServiceLoader.java | RegistryCenterServiceLoader.load | public RegistryCenter load(final RegistryCenterConfiguration regCenterConfig) {
Preconditions.checkNotNull(regCenterConfig, "Registry center configuration cannot be null.");
RegistryCenter result = newService(regCenterConfig.getType(), regCenterConfig.getProperties());
result.init(regCenterConfig);
return result;
} | java | public RegistryCenter load(final RegistryCenterConfiguration regCenterConfig) {
Preconditions.checkNotNull(regCenterConfig, "Registry center configuration cannot be null.");
RegistryCenter result = newService(regCenterConfig.getType(), regCenterConfig.getProperties());
result.init(regCenterConfig);
return result;
} | [
"public",
"RegistryCenter",
"load",
"(",
"final",
"RegistryCenterConfiguration",
"regCenterConfig",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"regCenterConfig",
",",
"\"Registry center configuration cannot be null.\"",
")",
";",
"RegistryCenter",
"result",
"=",
"... | Load registry center from SPI.
@param regCenterConfig registry center configuration
@return registry center | [
"Load",
"registry",
"center",
"from",
"SPI",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-orchestration/sharding-orchestration-core/src/main/java/org/apache/shardingsphere/orchestration/internal/registry/RegistryCenterServiceLoader.java#L50-L55 | train | Load a Registry Center from the configuration. | [
30522,
2270,
15584,
13013,
2121,
7170,
1006,
2345,
15584,
13013,
2121,
8663,
8873,
27390,
3370,
19723,
13013,
2121,
8663,
8873,
2290,
1007,
1063,
3653,
8663,
20562,
2015,
1012,
4638,
17048,
11231,
3363,
1006,
19723,
13013,
2121,
8663,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/text/csv/CsvRow.java | CsvRow.getByName | public String getByName(final String name) {
if (headerMap == null) {
throw new IllegalStateException("No header available");
}
final Integer col = headerMap.get(name);
if (col != null) {
return get(col);
}
return null;
} | java | public String getByName(final String name) {
if (headerMap == null) {
throw new IllegalStateException("No header available");
}
final Integer col = headerMap.get(name);
if (col != null) {
return get(col);
}
return null;
} | [
"public",
"String",
"getByName",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"headerMap",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No header available\"",
")",
";",
"}",
"final",
"Integer",
"col",
"=",
"headerMap",
".... | 获取标题对应的字段内容
@param name 标题名
@return 字段值,null表示无此字段值
@throws IllegalStateException CSV文件无标题行抛出此异常 | [
"获取标题对应的字段内容"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/text/csv/CsvRow.java#L53-L63 | train | Gets the value of the header with the given name. | [
30522,
2270,
5164,
2131,
3762,
18442,
1006,
2345,
5164,
2171,
1007,
1063,
2065,
1006,
20346,
2863,
2361,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
6206,
9153,
17389,
2595,
24422,
1006,
1000,
2053,
20346,
2800,
1000,
1007,
1025,
1065,
2345,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/serialization/ClassResolvers.java | ClassResolvers.softCachingConcurrentResolver | public static ClassResolver softCachingConcurrentResolver(ClassLoader classLoader) {
return new CachingClassResolver(
new ClassLoaderClassResolver(defaultClassLoader(classLoader)),
new SoftReferenceMap<String, Class<?>>(
PlatformDependent.<String, Reference<Class<?>>>newConcurrentHashMap()));
} | java | public static ClassResolver softCachingConcurrentResolver(ClassLoader classLoader) {
return new CachingClassResolver(
new ClassLoaderClassResolver(defaultClassLoader(classLoader)),
new SoftReferenceMap<String, Class<?>>(
PlatformDependent.<String, Reference<Class<?>>>newConcurrentHashMap()));
} | [
"public",
"static",
"ClassResolver",
"softCachingConcurrentResolver",
"(",
"ClassLoader",
"classLoader",
")",
"{",
"return",
"new",
"CachingClassResolver",
"(",
"new",
"ClassLoaderClassResolver",
"(",
"defaultClassLoader",
"(",
"classLoader",
")",
")",
",",
"new",
"Soft... | aggressive concurrent cache
good for shared cache, when we're not worried about class unloading
@param classLoader - specific classLoader to use, or null if you want to revert to default
@return new instance of class resolver | [
"aggressive",
"concurrent",
"cache",
"good",
"for",
"shared",
"cache",
"when",
"we",
"re",
"not",
"worried",
"about",
"class",
"unloading"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java#L81-L86 | train | Creates a new Concurrent ClassResolver that uses the default classloader. | [
30522,
2270,
10763,
2465,
6072,
4747,
6299,
3730,
3540,
8450,
8663,
10841,
14343,
3372,
6072,
4747,
6299,
1006,
2465,
11066,
2121,
2465,
11066,
2121,
1007,
1063,
2709,
2047,
6187,
8450,
26266,
6072,
4747,
6299,
1006,
2047,
2465,
11066,
2121... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionJobVertex.java | ExecutionJobVertex.getAggregateJobVertexState | public static ExecutionState getAggregateJobVertexState(int[] verticesPerState, int parallelism) {
if (verticesPerState == null || verticesPerState.length != ExecutionState.values().length) {
throw new IllegalArgumentException("Must provide an array as large as there are execution states.");
}
if (verticesPerState[ExecutionState.FAILED.ordinal()] > 0) {
return ExecutionState.FAILED;
}
if (verticesPerState[ExecutionState.CANCELING.ordinal()] > 0) {
return ExecutionState.CANCELING;
}
else if (verticesPerState[ExecutionState.CANCELED.ordinal()] > 0) {
return ExecutionState.CANCELED;
}
else if (verticesPerState[ExecutionState.RUNNING.ordinal()] > 0) {
return ExecutionState.RUNNING;
}
else if (verticesPerState[ExecutionState.FINISHED.ordinal()] > 0) {
return verticesPerState[ExecutionState.FINISHED.ordinal()] == parallelism ?
ExecutionState.FINISHED : ExecutionState.RUNNING;
}
else {
// all else collapses under created
return ExecutionState.CREATED;
}
} | java | public static ExecutionState getAggregateJobVertexState(int[] verticesPerState, int parallelism) {
if (verticesPerState == null || verticesPerState.length != ExecutionState.values().length) {
throw new IllegalArgumentException("Must provide an array as large as there are execution states.");
}
if (verticesPerState[ExecutionState.FAILED.ordinal()] > 0) {
return ExecutionState.FAILED;
}
if (verticesPerState[ExecutionState.CANCELING.ordinal()] > 0) {
return ExecutionState.CANCELING;
}
else if (verticesPerState[ExecutionState.CANCELED.ordinal()] > 0) {
return ExecutionState.CANCELED;
}
else if (verticesPerState[ExecutionState.RUNNING.ordinal()] > 0) {
return ExecutionState.RUNNING;
}
else if (verticesPerState[ExecutionState.FINISHED.ordinal()] > 0) {
return verticesPerState[ExecutionState.FINISHED.ordinal()] == parallelism ?
ExecutionState.FINISHED : ExecutionState.RUNNING;
}
else {
// all else collapses under created
return ExecutionState.CREATED;
}
} | [
"public",
"static",
"ExecutionState",
"getAggregateJobVertexState",
"(",
"int",
"[",
"]",
"verticesPerState",
",",
"int",
"parallelism",
")",
"{",
"if",
"(",
"verticesPerState",
"==",
"null",
"||",
"verticesPerState",
".",
"length",
"!=",
"ExecutionState",
".",
"v... | A utility function that computes an "aggregated" state for the vertex.
<p>This state is not used anywhere in the coordination, but can be used for display
in dashboards to as a summary for how the particular parallel operation represented by
this ExecutionJobVertex is currently behaving.
<p>For example, if at least one parallel task is failed, the aggregate state is failed.
If not, and at least one parallel task is cancelling (or cancelled), the aggregate state
is cancelling (or cancelled). If all tasks are finished, the aggregate state is finished,
and so on.
@param verticesPerState The number of vertices in each state (indexed by the ordinal of
the ExecutionState values).
@param parallelism The parallelism of the ExecutionJobVertex
@return The aggregate state of this ExecutionJobVertex. | [
"A",
"utility",
"function",
"that",
"computes",
"an",
"aggregated",
"state",
"for",
"the",
"vertex",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionJobVertex.java#L654-L679 | train | Returns the state of the given vertex array in the given parallelism. | [
30522,
2270,
10763,
22679,
12259,
2131,
8490,
17603,
5867,
5558,
2497,
16874,
10288,
9153,
2618,
1006,
20014,
1031,
1033,
18984,
7347,
12259,
1010,
20014,
5903,
2964,
1007,
1063,
2065,
1006,
18984,
7347,
12259,
1027,
1027,
19701,
1064,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | transport/src/main/java/io/netty/channel/PendingWriteQueue.java | PendingWriteQueue.current | public Object current() {
assert ctx.executor().inEventLoop();
PendingWrite write = head;
if (write == null) {
return null;
}
return write.msg;
} | java | public Object current() {
assert ctx.executor().inEventLoop();
PendingWrite write = head;
if (write == null) {
return null;
}
return write.msg;
} | [
"public",
"Object",
"current",
"(",
")",
"{",
"assert",
"ctx",
".",
"executor",
"(",
")",
".",
"inEventLoop",
"(",
")",
";",
"PendingWrite",
"write",
"=",
"head",
";",
"if",
"(",
"write",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
... | Return the current message or {@code null} if empty. | [
"Return",
"the",
"current",
"message",
"or",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/channel/PendingWriteQueue.java#L253-L260 | train | Gets the current message. | [
30522,
2270,
4874,
2783,
1006,
1007,
1063,
20865,
14931,
2595,
1012,
4654,
8586,
16161,
2099,
1006,
1007,
1012,
1999,
18697,
3372,
4135,
7361,
1006,
1007,
1025,
14223,
26373,
4339,
1027,
2132,
1025,
2065,
1006,
4339,
1027,
1027,
19701,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCompletedCheckpointStore.java | ZooKeeperCompletedCheckpointStore.recover | @Override
public void recover() throws Exception {
LOG.info("Recovering checkpoints from ZooKeeper.");
// Get all there is first
List<Tuple2<RetrievableStateHandle<CompletedCheckpoint>, String>> initialCheckpoints;
while (true) {
try {
initialCheckpoints = checkpointsInZooKeeper.getAllAndLock();
break;
}
catch (ConcurrentModificationException e) {
LOG.warn("Concurrent modification while reading from ZooKeeper. Retrying.");
}
}
Collections.sort(initialCheckpoints, STRING_COMPARATOR);
int numberOfInitialCheckpoints = initialCheckpoints.size();
LOG.info("Found {} checkpoints in ZooKeeper.", numberOfInitialCheckpoints);
// Try and read the state handles from storage. We try until we either successfully read
// all of them or when we reach a stable state, i.e. when we successfully read the same set
// of checkpoints in two tries. We do it like this to protect against transient outages
// of the checkpoint store (for example a DFS): if the DFS comes online midway through
// reading a set of checkpoints we would run the risk of reading only a partial set
// of checkpoints while we could in fact read the other checkpoints as well if we retried.
// Waiting until a stable state protects against this while also being resilient against
// checkpoints being actually unreadable.
//
// These considerations are also important in the scope of incremental checkpoints, where
// we use ref-counting for shared state handles and might accidentally delete shared state
// of checkpoints that we don't read due to transient storage outages.
List<CompletedCheckpoint> lastTryRetrievedCheckpoints = new ArrayList<>(numberOfInitialCheckpoints);
List<CompletedCheckpoint> retrievedCheckpoints = new ArrayList<>(numberOfInitialCheckpoints);
do {
LOG.info("Trying to fetch {} checkpoints from storage.", numberOfInitialCheckpoints);
lastTryRetrievedCheckpoints.clear();
lastTryRetrievedCheckpoints.addAll(retrievedCheckpoints);
retrievedCheckpoints.clear();
for (Tuple2<RetrievableStateHandle<CompletedCheckpoint>, String> checkpointStateHandle : initialCheckpoints) {
CompletedCheckpoint completedCheckpoint = null;
try {
completedCheckpoint = retrieveCompletedCheckpoint(checkpointStateHandle);
if (completedCheckpoint != null) {
retrievedCheckpoints.add(completedCheckpoint);
}
} catch (Exception e) {
LOG.warn("Could not retrieve checkpoint, not adding to list of recovered checkpoints.", e);
}
}
} while (retrievedCheckpoints.size() != numberOfInitialCheckpoints &&
!CompletedCheckpoint.checkpointsMatch(lastTryRetrievedCheckpoints, retrievedCheckpoints));
// Clear local handles in order to prevent duplicates on
// recovery. The local handles should reflect the state
// of ZooKeeper.
completedCheckpoints.clear();
completedCheckpoints.addAll(retrievedCheckpoints);
if (completedCheckpoints.isEmpty() && numberOfInitialCheckpoints > 0) {
throw new FlinkException(
"Could not read any of the " + numberOfInitialCheckpoints + " checkpoints from storage.");
} else if (completedCheckpoints.size() != numberOfInitialCheckpoints) {
LOG.warn(
"Could only fetch {} of {} checkpoints from storage.",
completedCheckpoints.size(),
numberOfInitialCheckpoints);
}
} | java | @Override
public void recover() throws Exception {
LOG.info("Recovering checkpoints from ZooKeeper.");
// Get all there is first
List<Tuple2<RetrievableStateHandle<CompletedCheckpoint>, String>> initialCheckpoints;
while (true) {
try {
initialCheckpoints = checkpointsInZooKeeper.getAllAndLock();
break;
}
catch (ConcurrentModificationException e) {
LOG.warn("Concurrent modification while reading from ZooKeeper. Retrying.");
}
}
Collections.sort(initialCheckpoints, STRING_COMPARATOR);
int numberOfInitialCheckpoints = initialCheckpoints.size();
LOG.info("Found {} checkpoints in ZooKeeper.", numberOfInitialCheckpoints);
// Try and read the state handles from storage. We try until we either successfully read
// all of them or when we reach a stable state, i.e. when we successfully read the same set
// of checkpoints in two tries. We do it like this to protect against transient outages
// of the checkpoint store (for example a DFS): if the DFS comes online midway through
// reading a set of checkpoints we would run the risk of reading only a partial set
// of checkpoints while we could in fact read the other checkpoints as well if we retried.
// Waiting until a stable state protects against this while also being resilient against
// checkpoints being actually unreadable.
//
// These considerations are also important in the scope of incremental checkpoints, where
// we use ref-counting for shared state handles and might accidentally delete shared state
// of checkpoints that we don't read due to transient storage outages.
List<CompletedCheckpoint> lastTryRetrievedCheckpoints = new ArrayList<>(numberOfInitialCheckpoints);
List<CompletedCheckpoint> retrievedCheckpoints = new ArrayList<>(numberOfInitialCheckpoints);
do {
LOG.info("Trying to fetch {} checkpoints from storage.", numberOfInitialCheckpoints);
lastTryRetrievedCheckpoints.clear();
lastTryRetrievedCheckpoints.addAll(retrievedCheckpoints);
retrievedCheckpoints.clear();
for (Tuple2<RetrievableStateHandle<CompletedCheckpoint>, String> checkpointStateHandle : initialCheckpoints) {
CompletedCheckpoint completedCheckpoint = null;
try {
completedCheckpoint = retrieveCompletedCheckpoint(checkpointStateHandle);
if (completedCheckpoint != null) {
retrievedCheckpoints.add(completedCheckpoint);
}
} catch (Exception e) {
LOG.warn("Could not retrieve checkpoint, not adding to list of recovered checkpoints.", e);
}
}
} while (retrievedCheckpoints.size() != numberOfInitialCheckpoints &&
!CompletedCheckpoint.checkpointsMatch(lastTryRetrievedCheckpoints, retrievedCheckpoints));
// Clear local handles in order to prevent duplicates on
// recovery. The local handles should reflect the state
// of ZooKeeper.
completedCheckpoints.clear();
completedCheckpoints.addAll(retrievedCheckpoints);
if (completedCheckpoints.isEmpty() && numberOfInitialCheckpoints > 0) {
throw new FlinkException(
"Could not read any of the " + numberOfInitialCheckpoints + " checkpoints from storage.");
} else if (completedCheckpoints.size() != numberOfInitialCheckpoints) {
LOG.warn(
"Could only fetch {} of {} checkpoints from storage.",
completedCheckpoints.size(),
numberOfInitialCheckpoints);
}
} | [
"@",
"Override",
"public",
"void",
"recover",
"(",
")",
"throws",
"Exception",
"{",
"LOG",
".",
"info",
"(",
"\"Recovering checkpoints from ZooKeeper.\"",
")",
";",
"// Get all there is first",
"List",
"<",
"Tuple2",
"<",
"RetrievableStateHandle",
"<",
"CompletedCheck... | Gets the latest checkpoint from ZooKeeper and removes all others.
<p><strong>Important</strong>: Even if there are more than one checkpoint in ZooKeeper,
this will only recover the latest and discard the others. Otherwise, there is no guarantee
that the history of checkpoints is consistent. | [
"Gets",
"the",
"latest",
"checkpoint",
"from",
"ZooKeeper",
"and",
"removes",
"all",
"others",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCompletedCheckpointStore.java#L126-L202 | train | Recover the checkpoints from ZooKeeper. | [
30522,
1030,
2058,
15637,
2270,
11675,
8980,
1006,
1007,
11618,
6453,
1063,
8833,
1012,
18558,
1006,
1000,
13400,
26520,
2015,
2013,
9201,
13106,
1012,
1000,
1007,
1025,
1013,
1013,
2131,
2035,
2045,
2003,
2034,
2862,
1026,
10722,
10814,
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... |
networknt/light-4j | utility/src/main/java/com/networknt/utility/RegExUtils.java | RegExUtils.replaceFirst | public static String replaceFirst(final String text, final Pattern regex, final String replacement) {
if (text == null || regex == null|| replacement == null ) {
return text;
}
return regex.matcher(text).replaceFirst(replacement);
} | java | public static String replaceFirst(final String text, final Pattern regex, final String replacement) {
if (text == null || regex == null|| replacement == null ) {
return text;
}
return regex.matcher(text).replaceFirst(replacement);
} | [
"public",
"static",
"String",
"replaceFirst",
"(",
"final",
"String",
"text",
",",
"final",
"Pattern",
"regex",
",",
"final",
"String",
"replacement",
")",
"{",
"if",
"(",
"text",
"==",
"null",
"||",
"regex",
"==",
"null",
"||",
"replacement",
"==",
"null"... | <p>Replaces the first substring of the text string that matches the given regular expression pattern
with the given replacement.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code pattern.matcher(text).replaceFirst(replacement)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<pre>
StringUtils.replaceFirst(null, *, *) = null
StringUtils.replaceFirst("any", (Pattern) null, *) = "any"
StringUtils.replaceFirst("any", *, null) = "any"
StringUtils.replaceFirst("", Pattern.compile(""), "zzz") = "zzz"
StringUtils.replaceFirst("", Pattern.compile(".*"), "zzz") = "zzz"
StringUtils.replaceFirst("", Pattern.compile(".+"), "zzz") = ""
StringUtils.replaceFirst("abc", Pattern.compile(""), "ZZ") = "ZZabc"
StringUtils.replaceFirst("<__>\n<__>", Pattern.compile("<.*>"), "z") = "z\n<__>"
StringUtils.replaceFirst("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z") = "z"
StringUtils.replaceFirst("ABCabc123", Pattern.compile("[a-z]"), "_") = "ABC_bc123"
StringUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "_") = "ABC_123abc"
StringUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "") = "ABC123abc"
StringUtils.replaceFirst("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2") = "Lorem_ipsum dolor sit"
</pre>
@param text text to search and replace in, may be null
@param regex the regular expression pattern to which this string is to be matched
@param replacement the string to be substituted for the first match
@return the text with the first replacement processed,
{@code null} if null String input
@see java.util.regex.Matcher#replaceFirst(String)
@see java.util.regex.Pattern | [
"<p",
">",
"Replaces",
"the",
"first",
"substring",
"of",
"the",
"text",
"string",
"that",
"matches",
"the",
"given",
"regular",
"expression",
"pattern",
"with",
"the",
"given",
"replacement",
".",
"<",
"/",
"p",
">"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/RegExUtils.java#L355-L360 | train | Replace the first occurence of the given regular expression with the given replacement. | [
30522,
2270,
10763,
5164,
5672,
8873,
12096,
1006,
2345,
5164,
3793,
1010,
2345,
5418,
19723,
10288,
1010,
2345,
5164,
6110,
1007,
1063,
2065,
1006,
3793,
1027,
1027,
19701,
1064,
1064,
19723,
10288,
1027,
1027,
19701,
1064,
1064,
6110,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | buffer/src/main/java/io/netty/buffer/ByteBufUtil.java | ByteBufUtil.hexDump | public static String hexDump(ByteBuf buffer) {
return hexDump(buffer, buffer.readerIndex(), buffer.readableBytes());
} | java | public static String hexDump(ByteBuf buffer) {
return hexDump(buffer, buffer.readerIndex(), buffer.readableBytes());
} | [
"public",
"static",
"String",
"hexDump",
"(",
"ByteBuf",
"buffer",
")",
"{",
"return",
"hexDump",
"(",
"buffer",
",",
"buffer",
".",
"readerIndex",
"(",
")",
",",
"buffer",
".",
"readableBytes",
"(",
")",
")",
";",
"}"
] | Returns a <a href="http://en.wikipedia.org/wiki/Hex_dump">hex dump</a>
of the specified buffer's readable bytes. | [
"Returns",
"a",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Hex_dump",
">",
"hex",
"dump<",
"/",
"a",
">",
"of",
"the",
"specified",
"buffer",
"s",
"readable",
"bytes",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java#L113-L115 | train | Returns a hex dump of the given buffer. | [
30522,
2270,
10763,
5164,
2002,
2595,
8566,
8737,
1006,
24880,
8569,
2546,
17698,
1007,
1063,
2709,
2002,
2595,
8566,
8737,
1006,
17698,
1010,
17698,
1012,
8068,
22254,
10288,
1006,
1007,
1010,
17698,
1012,
3191,
3085,
3762,
4570,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-optimizer/src/main/java/org/apache/flink/optimizer/plantranslate/JobGraphGenerator.java | JobGraphGenerator.createSingleInputVertex | private JobVertex createSingleInputVertex(SingleInputPlanNode node) throws CompilerException {
final String taskName = node.getNodeName();
final DriverStrategy ds = node.getDriverStrategy();
// check, whether chaining is possible
boolean chaining;
{
Channel inConn = node.getInput();
PlanNode pred = inConn.getSource();
chaining = ds.getPushChainDriverClass() != null &&
!(pred instanceof NAryUnionPlanNode) && // first op after union is stand-alone, because union is merged
!(pred instanceof BulkPartialSolutionPlanNode) && // partial solution merges anyways
!(pred instanceof WorksetPlanNode) && // workset merges anyways
!(pred instanceof IterationPlanNode) && // cannot chain with iteration heads currently
inConn.getShipStrategy() == ShipStrategyType.FORWARD &&
inConn.getLocalStrategy() == LocalStrategy.NONE &&
pred.getOutgoingChannels().size() == 1 &&
node.getParallelism() == pred.getParallelism() &&
node.getBroadcastInputs().isEmpty();
// cannot chain the nodes that produce the next workset or the next solution set, if they are not the
// in a tail
if (this.currentIteration instanceof WorksetIterationPlanNode && node.getOutgoingChannels().size() > 0)
{
WorksetIterationPlanNode wspn = (WorksetIterationPlanNode) this.currentIteration;
if (wspn.getSolutionSetDeltaPlanNode() == pred || wspn.getNextWorkSetPlanNode() == pred) {
chaining = false;
}
}
// cannot chain the nodes that produce the next workset in a bulk iteration if a termination criterion follows
if (this.currentIteration instanceof BulkIterationPlanNode)
{
BulkIterationPlanNode wspn = (BulkIterationPlanNode) this.currentIteration;
if (node == wspn.getRootOfTerminationCriterion() && wspn.getRootOfStepFunction() == pred){
chaining = false;
}else if(node.getOutgoingChannels().size() > 0 &&(wspn.getRootOfStepFunction() == pred ||
wspn.getRootOfTerminationCriterion() == pred)) {
chaining = false;
}
}
}
final JobVertex vertex;
final TaskConfig config;
if (chaining) {
vertex = null;
config = new TaskConfig(new Configuration());
this.chainedTasks.put(node, new TaskInChain(node, ds.getPushChainDriverClass(), config, taskName));
} else {
// create task vertex
vertex = new JobVertex(taskName);
vertex.setResources(node.getMinResources(), node.getPreferredResources());
vertex.setInvokableClass((this.currentIteration != null && node.isOnDynamicPath()) ? IterationIntermediateTask.class : BatchTask.class);
config = new TaskConfig(vertex.getConfiguration());
config.setDriver(ds.getDriverClass());
}
// set user code
config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper());
config.setStubParameters(node.getProgramOperator().getParameters());
// set the driver strategy
config.setDriverStrategy(ds);
for (int i = 0; i < ds.getNumRequiredComparators(); i++) {
config.setDriverComparator(node.getComparator(i), i);
}
// assign memory, file-handles, etc.
assignDriverResources(node, config);
return vertex;
} | java | private JobVertex createSingleInputVertex(SingleInputPlanNode node) throws CompilerException {
final String taskName = node.getNodeName();
final DriverStrategy ds = node.getDriverStrategy();
// check, whether chaining is possible
boolean chaining;
{
Channel inConn = node.getInput();
PlanNode pred = inConn.getSource();
chaining = ds.getPushChainDriverClass() != null &&
!(pred instanceof NAryUnionPlanNode) && // first op after union is stand-alone, because union is merged
!(pred instanceof BulkPartialSolutionPlanNode) && // partial solution merges anyways
!(pred instanceof WorksetPlanNode) && // workset merges anyways
!(pred instanceof IterationPlanNode) && // cannot chain with iteration heads currently
inConn.getShipStrategy() == ShipStrategyType.FORWARD &&
inConn.getLocalStrategy() == LocalStrategy.NONE &&
pred.getOutgoingChannels().size() == 1 &&
node.getParallelism() == pred.getParallelism() &&
node.getBroadcastInputs().isEmpty();
// cannot chain the nodes that produce the next workset or the next solution set, if they are not the
// in a tail
if (this.currentIteration instanceof WorksetIterationPlanNode && node.getOutgoingChannels().size() > 0)
{
WorksetIterationPlanNode wspn = (WorksetIterationPlanNode) this.currentIteration;
if (wspn.getSolutionSetDeltaPlanNode() == pred || wspn.getNextWorkSetPlanNode() == pred) {
chaining = false;
}
}
// cannot chain the nodes that produce the next workset in a bulk iteration if a termination criterion follows
if (this.currentIteration instanceof BulkIterationPlanNode)
{
BulkIterationPlanNode wspn = (BulkIterationPlanNode) this.currentIteration;
if (node == wspn.getRootOfTerminationCriterion() && wspn.getRootOfStepFunction() == pred){
chaining = false;
}else if(node.getOutgoingChannels().size() > 0 &&(wspn.getRootOfStepFunction() == pred ||
wspn.getRootOfTerminationCriterion() == pred)) {
chaining = false;
}
}
}
final JobVertex vertex;
final TaskConfig config;
if (chaining) {
vertex = null;
config = new TaskConfig(new Configuration());
this.chainedTasks.put(node, new TaskInChain(node, ds.getPushChainDriverClass(), config, taskName));
} else {
// create task vertex
vertex = new JobVertex(taskName);
vertex.setResources(node.getMinResources(), node.getPreferredResources());
vertex.setInvokableClass((this.currentIteration != null && node.isOnDynamicPath()) ? IterationIntermediateTask.class : BatchTask.class);
config = new TaskConfig(vertex.getConfiguration());
config.setDriver(ds.getDriverClass());
}
// set user code
config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper());
config.setStubParameters(node.getProgramOperator().getParameters());
// set the driver strategy
config.setDriverStrategy(ds);
for (int i = 0; i < ds.getNumRequiredComparators(); i++) {
config.setDriverComparator(node.getComparator(i), i);
}
// assign memory, file-handles, etc.
assignDriverResources(node, config);
return vertex;
} | [
"private",
"JobVertex",
"createSingleInputVertex",
"(",
"SingleInputPlanNode",
"node",
")",
"throws",
"CompilerException",
"{",
"final",
"String",
"taskName",
"=",
"node",
".",
"getNodeName",
"(",
")",
";",
"final",
"DriverStrategy",
"ds",
"=",
"node",
".",
"getDr... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/plantranslate/JobGraphGenerator.java#L838-L909 | train | Create a single input vertex. | [
30522,
2797,
3105,
16874,
10288,
9005,
2075,
19856,
18780,
16874,
10288,
1006,
2309,
2378,
18780,
24759,
11639,
10244,
13045,
1007,
11618,
21624,
10288,
24422,
1063,
2345,
5164,
4708,
18442,
1027,
13045,
1012,
2131,
3630,
4181,
14074,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/core/fs/EntropyInjector.java | EntropyInjector.createEntropyAware | public static OutputStreamAndPath createEntropyAware(
FileSystem fs,
Path path,
WriteMode writeMode) throws IOException {
// check and possibly inject entropy into the path
final EntropyInjectingFileSystem efs = getEntropyFs(fs);
final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true);
// create the stream on the original file system to let the safety net
// take its effect
final FSDataOutputStream out = fs.create(processedPath, writeMode);
return new OutputStreamAndPath(out, processedPath);
} | java | public static OutputStreamAndPath createEntropyAware(
FileSystem fs,
Path path,
WriteMode writeMode) throws IOException {
// check and possibly inject entropy into the path
final EntropyInjectingFileSystem efs = getEntropyFs(fs);
final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true);
// create the stream on the original file system to let the safety net
// take its effect
final FSDataOutputStream out = fs.create(processedPath, writeMode);
return new OutputStreamAndPath(out, processedPath);
} | [
"public",
"static",
"OutputStreamAndPath",
"createEntropyAware",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
",",
"WriteMode",
"writeMode",
")",
"throws",
"IOException",
"{",
"// check and possibly inject entropy into the path",
"final",
"EntropyInjectingFileSystem",
"efs",... | Handles entropy injection across regular and entropy-aware file systems.
<p>If the given file system is entropy-aware (a implements {@link EntropyInjectingFileSystem}),
then this method replaces the entropy marker in the path with random characters.
The entropy marker is defined by {@link EntropyInjectingFileSystem#getEntropyInjectionKey()}.
<p>If the given file system does not implement {@code EntropyInjectingFileSystem},
then this method delegates to {@link FileSystem#create(Path, WriteMode)} and
returns the same path in the resulting {@code OutputStreamAndPath}. | [
"Handles",
"entropy",
"injection",
"across",
"regular",
"and",
"entropy",
"-",
"aware",
"file",
"systems",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/fs/EntropyInjector.java#L50-L63 | train | Create a stream on the original file system that is entropy aware. | [
30522,
2270,
10763,
27852,
25379,
5685,
15069,
3443,
4765,
18981,
3148,
8059,
1006,
6764,
27268,
6633,
1042,
2015,
1010,
4130,
4130,
1010,
4339,
5302,
3207,
4339,
5302,
3207,
1007,
11618,
22834,
10288,
24422,
1063,
1013,
1013,
4638,
30524,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/model/maxent/MaxEntModel.java | MaxEntModel.predict | public final List<Pair<String, Double>> predict(String[] context)
{
List<Pair<String, Double>> result = new ArrayList<Pair<String, Double>>(outcomeNames.length);
double[] p = eval(context);
for (int i = 0; i < p.length; ++i)
{
result.add(new Pair<String, Double>(outcomeNames[i], p[i]));
}
return result;
} | java | public final List<Pair<String, Double>> predict(String[] context)
{
List<Pair<String, Double>> result = new ArrayList<Pair<String, Double>>(outcomeNames.length);
double[] p = eval(context);
for (int i = 0; i < p.length; ++i)
{
result.add(new Pair<String, Double>(outcomeNames[i], p[i]));
}
return result;
} | [
"public",
"final",
"List",
"<",
"Pair",
"<",
"String",
",",
"Double",
">",
">",
"predict",
"(",
"String",
"[",
"]",
"context",
")",
"{",
"List",
"<",
"Pair",
"<",
"String",
",",
"Double",
">",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"Pair",
"<... | 预测分布
@param context
@return | [
"预测分布"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/model/maxent/MaxEntModel.java#L76-L85 | train | Predict a sequence of attributes of a Sequence. | [
30522,
2270,
2345,
2862,
1026,
3940,
1026,
5164,
1010,
3313,
1028,
1028,
16014,
1006,
5164,
1031,
1033,
6123,
1007,
1063,
2862,
1026,
3940,
1026,
5164,
1010,
3313,
1028,
1028,
2765,
1027,
2047,
9140,
9863,
1026,
3940,
1026,
5164,
1010,
33... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelUtil.java | ExcelUtil.readBySax | public static void readBySax(InputStream in, int sheetIndex, RowHandler rowHandler) {
in = IoUtil.toMarkSupportStream(in);
if (ExcelFileUtil.isXlsx(in)) {
read07BySax(in, sheetIndex, rowHandler);
} else {
read03BySax(in, sheetIndex, rowHandler);
}
} | java | public static void readBySax(InputStream in, int sheetIndex, RowHandler rowHandler) {
in = IoUtil.toMarkSupportStream(in);
if (ExcelFileUtil.isXlsx(in)) {
read07BySax(in, sheetIndex, rowHandler);
} else {
read03BySax(in, sheetIndex, rowHandler);
}
} | [
"public",
"static",
"void",
"readBySax",
"(",
"InputStream",
"in",
",",
"int",
"sheetIndex",
",",
"RowHandler",
"rowHandler",
")",
"{",
"in",
"=",
"IoUtil",
".",
"toMarkSupportStream",
"(",
"in",
")",
";",
"if",
"(",
"ExcelFileUtil",
".",
"isXlsx",
"(",
"i... | 通过Sax方式读取Excel,同时支持03和07格式
@param in Excel流
@param sheetIndex sheet序号
@param rowHandler 行处理器
@since 3.2.0 | [
"通过Sax方式读取Excel,同时支持03和07格式"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelUtil.java#L71-L78 | train | Read a row from an input stream using the Excel file format. | [
30522,
2270,
10763,
11675,
3191,
3762,
3736,
2595,
1006,
20407,
25379,
1999,
1010,
20014,
7123,
22254,
10288,
1010,
5216,
11774,
3917,
5216,
11774,
3917,
1007,
30524,
1999,
1007,
1025,
2065,
1006,
24970,
8873,
2571,
21823,
2140,
1012,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/SingleOutputStreamOperator.java | SingleOutputStreamOperator.returns | public SingleOutputStreamOperator<T> returns(TypeHint<T> typeHint) {
requireNonNull(typeHint, "TypeHint must not be null");
try {
return returns(TypeInformation.of(typeHint));
}
catch (InvalidTypesException e) {
throw new InvalidTypesException("Cannot infer the type information from the type hint. " +
"Make sure that the TypeHint does not use any generic type variables.");
}
} | java | public SingleOutputStreamOperator<T> returns(TypeHint<T> typeHint) {
requireNonNull(typeHint, "TypeHint must not be null");
try {
return returns(TypeInformation.of(typeHint));
}
catch (InvalidTypesException e) {
throw new InvalidTypesException("Cannot infer the type information from the type hint. " +
"Make sure that the TypeHint does not use any generic type variables.");
}
} | [
"public",
"SingleOutputStreamOperator",
"<",
"T",
">",
"returns",
"(",
"TypeHint",
"<",
"T",
">",
"typeHint",
")",
"{",
"requireNonNull",
"(",
"typeHint",
",",
"\"TypeHint must not be null\"",
")",
";",
"try",
"{",
"return",
"returns",
"(",
"TypeInformation",
".... | 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>Use this method the following way:
<pre>{@code
DataStream<Tuple2<String, Double>> result =
stream.flatMap(new FunctionWithNonInferrableReturnType())
.returns(new TypeHint<Tuple2<String, Double>>(){});
}</pre>
@param typeHint The type hint for the returned data type.
@return This operator with the type information corresponding to the given 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#L338-L348 | train | Returns an operator that accepts the given type hint. | [
30522,
2270,
2309,
5833,
18780,
21422,
25918,
8844,
1026,
1056,
1028,
5651,
1006,
2828,
10606,
2102,
1026,
1056,
1028,
2828,
10606,
2102,
1007,
1063,
5478,
8540,
11231,
3363,
1006,
2828,
10606,
2102,
1010,
1000,
2828,
10606,
2102,
2442,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/catalog/GenericInMemoryCatalog.java | GenericInMemoryCatalog.dropTable | @Override
public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists) throws TableNotExistException {
checkNotNull(tablePath);
if (tableExists(tablePath)) {
tables.remove(tablePath);
partitions.remove(tablePath);
} else if (!ignoreIfNotExists) {
throw new TableNotExistException(catalogName, tablePath);
}
} | java | @Override
public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists) throws TableNotExistException {
checkNotNull(tablePath);
if (tableExists(tablePath)) {
tables.remove(tablePath);
partitions.remove(tablePath);
} else if (!ignoreIfNotExists) {
throw new TableNotExistException(catalogName, tablePath);
}
} | [
"@",
"Override",
"public",
"void",
"dropTable",
"(",
"ObjectPath",
"tablePath",
",",
"boolean",
"ignoreIfNotExists",
")",
"throws",
"TableNotExistException",
"{",
"checkNotNull",
"(",
"tablePath",
")",
";",
"if",
"(",
"tableExists",
"(",
"tablePath",
")",
")",
"... | ------ tables and views ------ | [
"------",
"tables",
"and",
"views",
"------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericInMemoryCatalog.java#L219-L230 | train | Drops a table. | [
30522,
1030,
2058,
15637,
2270,
11675,
4530,
10880,
1006,
4874,
15069,
2795,
15069,
1010,
22017,
20898,
8568,
10128,
22074,
9048,
12837,
1007,
11618,
2795,
22074,
9048,
13473,
2595,
24422,
1063,
4638,
17048,
11231,
3363,
1006,
2795,
15069,
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 | codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java | CorsConfigBuilder.build | public CorsConfig build() {
if (preflightHeaders.isEmpty() && !noPreflightHeaders) {
preflightHeaders.put(HttpHeaderNames.DATE, DateValueGenerator.INSTANCE);
preflightHeaders.put(HttpHeaderNames.CONTENT_LENGTH, new ConstantValueGenerator("0"));
}
return new CorsConfig(this);
} | java | public CorsConfig build() {
if (preflightHeaders.isEmpty() && !noPreflightHeaders) {
preflightHeaders.put(HttpHeaderNames.DATE, DateValueGenerator.INSTANCE);
preflightHeaders.put(HttpHeaderNames.CONTENT_LENGTH, new ConstantValueGenerator("0"));
}
return new CorsConfig(this);
} | [
"public",
"CorsConfig",
"build",
"(",
")",
"{",
"if",
"(",
"preflightHeaders",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"noPreflightHeaders",
")",
"{",
"preflightHeaders",
".",
"put",
"(",
"HttpHeaderNames",
".",
"DATE",
",",
"DateValueGenerator",
".",
"INSTANCE",... | Builds a {@link CorsConfig} with settings specified by previous method calls.
@return {@link CorsConfig} the configured CorsConfig instance. | [
"Builds",
"a",
"{",
"@link",
"CorsConfig",
"}",
"with",
"settings",
"specified",
"by",
"previous",
"method",
"calls",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java#L358-L364 | train | Build the CorsConfig object. | [
30522,
2270,
2522,
2869,
8663,
8873,
2290,
3857,
1006,
1007,
1063,
2065,
1006,
3653,
28968,
4974,
2545,
1012,
2003,
6633,
13876,
2100,
1006,
1007,
1004,
1004,
999,
2053,
28139,
28968,
4974,
2545,
1007,
1063,
3653,
28968,
4974,
2545,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/old/lexer/analyzer/Tokenizer.java | Tokenizer.skipComment | public int skipComment() {
char current = charAt(offset);
char next = charAt(offset + 1);
if (isSingleLineCommentBegin(current, next)) {
return skipSingleLineComment(COMMENT_BEGIN_SYMBOL_LENGTH);
} else if ('#' == current) {
return skipSingleLineComment(MYSQL_SPECIAL_COMMENT_BEGIN_SYMBOL_LENGTH);
} else if (isMultipleLineCommentBegin(current, next)) {
return skipMultiLineComment();
}
return offset;
} | java | public int skipComment() {
char current = charAt(offset);
char next = charAt(offset + 1);
if (isSingleLineCommentBegin(current, next)) {
return skipSingleLineComment(COMMENT_BEGIN_SYMBOL_LENGTH);
} else if ('#' == current) {
return skipSingleLineComment(MYSQL_SPECIAL_COMMENT_BEGIN_SYMBOL_LENGTH);
} else if (isMultipleLineCommentBegin(current, next)) {
return skipMultiLineComment();
}
return offset;
} | [
"public",
"int",
"skipComment",
"(",
")",
"{",
"char",
"current",
"=",
"charAt",
"(",
"offset",
")",
";",
"char",
"next",
"=",
"charAt",
"(",
"offset",
"+",
"1",
")",
";",
"if",
"(",
"isSingleLineCommentBegin",
"(",
"current",
",",
"next",
")",
")",
... | skip comment.
@return offset after comment skipped | [
"skip",
"comment",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/old/lexer/analyzer/Tokenizer.java#L69-L80 | train | Skip comment. | [
30522,
2270,
20014,
13558,
9006,
3672,
1006,
1007,
1063,
25869,
2783,
1027,
25869,
4017,
1006,
16396,
1007,
1025,
25869,
2279,
1027,
25869,
4017,
1006,
16396,
1009,
1015,
1007,
1025,
2065,
1006,
26354,
2075,
2571,
4179,
9006,
3672,
4783,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java | CharArrayBuffer.toCharArray | public char[] toCharArray() {
final char[] b = new char[this.len];
if (this.len > 0) {
System.arraycopy(this.array, 0, b, 0, this.len);
}
return b;
} | java | public char[] toCharArray() {
final char[] b = new char[this.len];
if (this.len > 0) {
System.arraycopy(this.array, 0, b, 0, this.len);
}
return b;
} | [
"public",
"char",
"[",
"]",
"toCharArray",
"(",
")",
"{",
"final",
"char",
"[",
"]",
"b",
"=",
"new",
"char",
"[",
"this",
".",
"len",
"]",
";",
"if",
"(",
"this",
".",
"len",
">",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
... | Converts the content of this buffer to an array of chars.
@return char array | [
"Converts",
"the",
"content",
"of",
"this",
"buffer",
"to",
"an",
"array",
"of",
"chars",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java#L242-L248 | train | Get a copy of the array as a char array. | [
30522,
2270,
25869,
1031,
1033,
2000,
7507,
19848,
9447,
1006,
1007,
1063,
2345,
25869,
1031,
1033,
1038,
1027,
2047,
25869,
1031,
2023,
1012,
18798,
1033,
1025,
2065,
1006,
2023,
1012,
18798,
1028,
1014,
1007,
1063,
2291,
1012,
9140,
3597,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java | IoUtil.getReader | public static BufferedReader getReader(Reader reader) {
if (null == reader) {
return null;
}
return (reader instanceof BufferedReader) ? (BufferedReader) reader : new BufferedReader(reader);
} | java | public static BufferedReader getReader(Reader reader) {
if (null == reader) {
return null;
}
return (reader instanceof BufferedReader) ? (BufferedReader) reader : new BufferedReader(reader);
} | [
"public",
"static",
"BufferedReader",
"getReader",
"(",
"Reader",
"reader",
")",
"{",
"if",
"(",
"null",
"==",
"reader",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"reader",
"instanceof",
"BufferedReader",
")",
"?",
"(",
"BufferedReader",
")",
"r... | 获得{@link BufferedReader}<br>
如果是{@link BufferedReader}强转返回,否则新建。如果提供的Reader为null返回null
@param reader 普通Reader,如果为null返回null
@return {@link BufferedReader} or null
@since 3.0.9 | [
"获得",
"{",
"@link",
"BufferedReader",
"}",
"<br",
">",
"如果是",
"{",
"@link",
"BufferedReader",
"}",
"强转返回,否则新建。如果提供的Reader为null返回null"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java#L335-L341 | train | Returns a new BufferedReader instance that wraps the specified reader. | [
30522,
2270,
10763,
17698,
2098,
16416,
4063,
2131,
16416,
4063,
1006,
8068,
8068,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
8068,
1007,
1063,
2709,
19701,
1025,
1065,
2709,
1006,
8068,
6013,
11253,
17698,
2098,
16416,
4063,
1007,
1029,
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-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java | KeyUtil.generatePrivateKey | public static PrivateKey generatePrivateKey(String algorithm, byte[] key) {
if (null == key) {
return null;
}
return generatePrivateKey(algorithm, new PKCS8EncodedKeySpec(key));
} | java | public static PrivateKey generatePrivateKey(String algorithm, byte[] key) {
if (null == key) {
return null;
}
return generatePrivateKey(algorithm, new PKCS8EncodedKeySpec(key));
} | [
"public",
"static",
"PrivateKey",
"generatePrivateKey",
"(",
"String",
"algorithm",
",",
"byte",
"[",
"]",
"key",
")",
"{",
"if",
"(",
"null",
"==",
"key",
")",
"{",
"return",
"null",
";",
"}",
"return",
"generatePrivateKey",
"(",
"algorithm",
",",
"new",
... | 生成私钥,仅用于非对称加密<br>
采用PKCS#8规范,此规范定义了私钥信息语法和加密私钥语法<br>
算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyFactory
@param algorithm 算法
@param key 密钥,必须为DER编码存储
@return 私钥 {@link PrivateKey} | [
"生成私钥,仅用于非对称加密<br",
">",
"采用PKCS#8规范,此规范定义了私钥信息语法和加密私钥语法<br",
">",
"算法见:https",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javase",
"/",
"7",
"/",
"docs",
"/",
"technotes",
"/",
"guides",
"/",
"security",
"/",
"StandardNames",
".",
"html#KeyFactory"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java#L219-L224 | train | Generates a private key from a byte array of bytes. | [
30522,
2270,
10763,
2797,
14839,
9699,
18098,
21466,
14839,
1006,
5164,
9896,
1010,
24880,
1031,
1033,
3145,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
3145,
1007,
1063,
2709,
19701,
1025,
1065,
2709,
9699,
18098,
21466,
14839,
1006,
9896,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getColumns | @Override
public OperationHandle getColumns(SessionHandle sessionHandle, String catalogName,
String schemaName, String tableName, String columnName) throws HiveSQLException {
return cliService.getColumns(sessionHandle, catalogName, schemaName, tableName, columnName);
} | java | @Override
public OperationHandle getColumns(SessionHandle sessionHandle, String catalogName,
String schemaName, String tableName, String columnName) throws HiveSQLException {
return cliService.getColumns(sessionHandle, catalogName, schemaName, tableName, columnName);
} | [
"@",
"Override",
"public",
"OperationHandle",
"getColumns",
"(",
"SessionHandle",
"sessionHandle",
",",
"String",
"catalogName",
",",
"String",
"schemaName",
",",
"String",
"tableName",
",",
"String",
"columnName",
")",
"throws",
"HiveSQLException",
"{",
"return",
"... | /* (non-Javadoc)
@see org.apache.hive.service.cli.CLIServiceClient#getColumns(org.apache.hive.service.cli.SessionHandle, java.lang.String, java.lang.String, 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/EmbeddedCLIServiceClient.java#L136-L140 | train | Get columns. | [
30522,
1030,
2058,
15637,
2270,
3169,
11774,
2571,
2131,
25778,
2819,
3619,
1006,
5219,
11774,
2571,
5219,
11774,
2571,
1010,
5164,
12105,
18442,
1010,
5164,
8040,
28433,
18442,
1010,
5164,
2795,
18442,
1010,
5164,
5930,
18442,
1007,
11618,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpConnection.java | HttpConnection.header | public HttpConnection header(Map<String, List<String>> headerMap, boolean isOverride) {
if (MapUtil.isNotEmpty(headerMap)) {
String name;
for (Entry<String, List<String>> entry : headerMap.entrySet()) {
name = entry.getKey();
for (String value : entry.getValue()) {
this.header(name, StrUtil.nullToEmpty(value), isOverride);
}
}
}
return this;
} | java | public HttpConnection header(Map<String, List<String>> headerMap, boolean isOverride) {
if (MapUtil.isNotEmpty(headerMap)) {
String name;
for (Entry<String, List<String>> entry : headerMap.entrySet()) {
name = entry.getKey();
for (String value : entry.getValue()) {
this.header(name, StrUtil.nullToEmpty(value), isOverride);
}
}
}
return this;
} | [
"public",
"HttpConnection",
"header",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headerMap",
",",
"boolean",
"isOverride",
")",
"{",
"if",
"(",
"MapUtil",
".",
"isNotEmpty",
"(",
"headerMap",
")",
")",
"{",
"String",
"name",
";",
... | 设置请求头<br>
不覆盖原有请求头
@param headerMap 请求头
@param isOverride 是否覆盖
@return this | [
"设置请求头<br",
">",
"不覆盖原有请求头"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpConnection.java#L208-L219 | train | Adds the header to the connection. | [
30522,
2270,
8299,
8663,
2638,
7542,
20346,
1006,
4949,
1026,
5164,
1010,
2862,
1026,
5164,
1028,
1028,
20346,
2863,
2361,
1010,
22017,
20898,
11163,
6299,
15637,
1007,
1063,
2065,
1006,
4949,
21823,
2140,
1012,
3475,
12184,
27718,
2100,
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-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java | Pattern.where | public Pattern<T, F> where(IterativeCondition<F> condition) {
Preconditions.checkNotNull(condition, "The condition cannot be null.");
ClosureCleaner.clean(condition, true);
if (this.condition == null) {
this.condition = condition;
} else {
this.condition = new RichAndCondition<>(this.condition, condition);
}
return this;
} | java | public Pattern<T, F> where(IterativeCondition<F> condition) {
Preconditions.checkNotNull(condition, "The condition cannot be null.");
ClosureCleaner.clean(condition, true);
if (this.condition == null) {
this.condition = condition;
} else {
this.condition = new RichAndCondition<>(this.condition, condition);
}
return this;
} | [
"public",
"Pattern",
"<",
"T",
",",
"F",
">",
"where",
"(",
"IterativeCondition",
"<",
"F",
">",
"condition",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"condition",
",",
"\"The condition cannot be null.\"",
")",
";",
"ClosureCleaner",
".",
"clean",
... | Adds a condition that has to be satisfied by an event
in order to be considered a match. If another condition has already been
set, the new one is going to be combined with the previous with a
logical {@code AND}. In other case, this is going to be the only
condition.
@param condition The condition as an {@link IterativeCondition}.
@return The pattern with the new condition is set. | [
"Adds",
"a",
"condition",
"that",
"has",
"to",
"be",
"satisfied",
"by",
"an",
"event",
"in",
"order",
"to",
"be",
"considered",
"a",
"match",
".",
"If",
"another",
"condition",
"has",
"already",
"been",
"set",
"the",
"new",
"one",
"is",
"going",
"to",
... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java#L155-L165 | train | Sets the condition to be satisfied. | [
30522,
2270,
5418,
1026,
1056,
1010,
1042,
1028,
2073,
1006,
2009,
25284,
8663,
20562,
1026,
1042,
1028,
4650,
1007,
1063,
3653,
8663,
20562,
2015,
1012,
4638,
17048,
11231,
3363,
1006,
4650,
1010,
1000,
1996,
4650,
3685,
2022,
19701,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java | MDAG.getStringsWithSubstring | public HashSet<String> getStringsWithSubstring(String str)
{
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", sourceNode.getOutgoingTransitions());
else
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", simplifiedSourceNode);
return strHashSet;
} | java | public HashSet<String> getStringsWithSubstring(String str)
{
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", sourceNode.getOutgoingTransitions());
else
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", simplifiedSourceNode);
return strHashSet;
} | [
"public",
"HashSet",
"<",
"String",
">",
"getStringsWithSubstring",
"(",
"String",
"str",
")",
"{",
"HashSet",
"<",
"String",
">",
"strHashSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"sourceNode",
"!=",
"null",
")",
"//if t... | 返回包含字串的key<br>
Retrieves all the Strings in the MDAG that contain a given String.
@param str a String that is contained in all the desired Strings
@return a HashSet containing all the Strings present in the MDAG that begin with {@code prefixString} | [
"返回包含字串的key<br",
">",
"Retrieves",
"all",
"the",
"Strings",
"in",
"the",
"MDAG",
"that",
"contain",
"a",
"given",
"String",
"."
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java#L976-L986 | train | getStringsWithSubstring This method is used to get a set of strings from the source and target nodes. | [
30522,
2270,
23325,
13462,
1026,
5164,
1028,
4152,
18886,
3070,
26760,
8939,
6342,
5910,
18886,
3070,
1006,
5164,
2358,
2099,
1007,
1063,
23325,
13462,
1026,
5164,
1028,
2358,
25032,
11823,
13462,
1027,
2047,
23325,
13462,
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... |
apache/flink | flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/Graph.java | Graph.mapEdges | public <NV> Graph<K, VV, NV> mapEdges(final MapFunction<Edge<K, EV>, NV> mapper, TypeInformation<Edge<K, NV>> returnType) {
DataSet<Edge<K, NV>> mappedEdges = edges.map(
new MapFunction<Edge<K, EV>, Edge<K, NV>>() {
private Edge<K, NV> output = new Edge<>();
public Edge<K, NV> map(Edge<K, EV> value) throws Exception {
output.f0 = value.f0;
output.f1 = value.f1;
output.f2 = mapper.map(value);
return output;
}
})
.returns(returnType)
.withForwardedFields("f0; f1")
.name("Map edges");
return new Graph<>(this.vertices, mappedEdges, this.context);
} | java | public <NV> Graph<K, VV, NV> mapEdges(final MapFunction<Edge<K, EV>, NV> mapper, TypeInformation<Edge<K, NV>> returnType) {
DataSet<Edge<K, NV>> mappedEdges = edges.map(
new MapFunction<Edge<K, EV>, Edge<K, NV>>() {
private Edge<K, NV> output = new Edge<>();
public Edge<K, NV> map(Edge<K, EV> value) throws Exception {
output.f0 = value.f0;
output.f1 = value.f1;
output.f2 = mapper.map(value);
return output;
}
})
.returns(returnType)
.withForwardedFields("f0; f1")
.name("Map edges");
return new Graph<>(this.vertices, mappedEdges, this.context);
} | [
"public",
"<",
"NV",
">",
"Graph",
"<",
"K",
",",
"VV",
",",
"NV",
">",
"mapEdges",
"(",
"final",
"MapFunction",
"<",
"Edge",
"<",
"K",
",",
"EV",
">",
",",
"NV",
">",
"mapper",
",",
"TypeInformation",
"<",
"Edge",
"<",
"K",
",",
"NV",
">",
">"... | Apply a function to the attribute of each edge in the graph.
@param mapper the map function to apply.
@param returnType the explicit return type.
@return a new graph | [
"Apply",
"a",
"function",
"to",
"the",
"attribute",
"of",
"each",
"edge",
"in",
"the",
"graph",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/Graph.java#L603-L620 | train | Maps edges of this graph to the vertices of the given mapping function. | [
30522,
2270,
1026,
1050,
2615,
1028,
10629,
1026,
1047,
1010,
1058,
2615,
1010,
1050,
2615,
1028,
4949,
24225,
2015,
1006,
2345,
4949,
11263,
27989,
1026,
3341,
1026,
1047,
1010,
23408,
1028,
1010,
1050,
2615,
1028,
4949,
4842,
1010,
2828,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/digest/Digester.java | Digester.init | public Digester init(String algorithm, Provider provider) {
if(null == provider) {
this.digest = SecureUtil.createMessageDigest(algorithm);
}else {
try {
this.digest = MessageDigest.getInstance(algorithm, provider);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
}
return this;
} | java | public Digester init(String algorithm, Provider provider) {
if(null == provider) {
this.digest = SecureUtil.createMessageDigest(algorithm);
}else {
try {
this.digest = MessageDigest.getInstance(algorithm, provider);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
}
return this;
} | [
"public",
"Digester",
"init",
"(",
"String",
"algorithm",
",",
"Provider",
"provider",
")",
"{",
"if",
"(",
"null",
"==",
"provider",
")",
"{",
"this",
".",
"digest",
"=",
"SecureUtil",
".",
"createMessageDigest",
"(",
"algorithm",
")",
";",
"}",
"else",
... | 初始化
@param algorithm 算法
@param provider 算法提供者,null表示JDK默认,可以引入Bouncy Castle等来提供更多算法支持
@return {@link Digester}
@throws CryptoException Cause by IOException | [
"初始化"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/digest/Digester.java#L87-L98 | train | Initializes the digest. | [
30522,
2270,
17886,
2121,
1999,
4183,
1006,
5164,
9896,
1010,
10802,
10802,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
10802,
1007,
1063,
2023,
1012,
17886,
1027,
5851,
21823,
2140,
1012,
3443,
7834,
3736,
5999,
25538,
3367,
1006,
9896,
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... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/utility/MathUtility.java | MathUtility.calculateWeight | public static double calculateWeight(Vertex from, Vertex to)
{
int frequency = from.getAttribute().totalFrequency;
if (frequency == 0)
{
frequency = 1; // 防止发生除零错误
}
// int nTwoWordsFreq = BiGramDictionary.getBiFrequency(from.word, to.word);
int nTwoWordsFreq = CoreBiGramTableDictionary.getBiFrequency(from.wordID, to.wordID);
double value = -Math.log(dSmoothingPara * frequency / (MAX_FREQUENCY) + (1 - dSmoothingPara) * ((1 - dTemp) * nTwoWordsFreq / frequency + dTemp));
if (value < 0.0)
{
value = -value;
}
// logger.info(String.format("%5s frequency:%6d, %s nTwoWordsFreq:%3d, weight:%.2f", from.word, frequency, from.word + "@" + to.word, nTwoWordsFreq, value));
return value;
} | java | public static double calculateWeight(Vertex from, Vertex to)
{
int frequency = from.getAttribute().totalFrequency;
if (frequency == 0)
{
frequency = 1; // 防止发生除零错误
}
// int nTwoWordsFreq = BiGramDictionary.getBiFrequency(from.word, to.word);
int nTwoWordsFreq = CoreBiGramTableDictionary.getBiFrequency(from.wordID, to.wordID);
double value = -Math.log(dSmoothingPara * frequency / (MAX_FREQUENCY) + (1 - dSmoothingPara) * ((1 - dTemp) * nTwoWordsFreq / frequency + dTemp));
if (value < 0.0)
{
value = -value;
}
// logger.info(String.format("%5s frequency:%6d, %s nTwoWordsFreq:%3d, weight:%.2f", from.word, frequency, from.word + "@" + to.word, nTwoWordsFreq, value));
return value;
} | [
"public",
"static",
"double",
"calculateWeight",
"(",
"Vertex",
"from",
",",
"Vertex",
"to",
")",
"{",
"int",
"frequency",
"=",
"from",
".",
"getAttribute",
"(",
")",
".",
"totalFrequency",
";",
"if",
"(",
"frequency",
"==",
"0",
")",
"{",
"frequency",
"... | 从一个词到另一个词的词的花费
@param from 前面的词
@param to 后面的词
@return 分数 | [
"从一个词到另一个词的词的花费"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/utility/MathUtility.java#L130-L146 | train | Calculate weight of two terms. | [
30522,
2270,
10763,
3313,
18422,
11179,
1006,
19449,
2013,
1010,
19449,
2000,
1007,
1063,
20014,
6075,
1027,
2013,
1012,
2131,
19321,
3089,
8569,
2618,
1006,
1007,
1012,
2561,
19699,
2063,
4226,
9407,
1025,
2065,
1006,
6075,
1027,
1027,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
redisson/redisson | redisson/src/main/java/org/redisson/RedissonBlockingDeque.java | RedissonBlockingDeque.pollFromAny | @Override
public V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws InterruptedException {
return blockingQueue.pollFromAny(timeout, unit);
} | java | @Override
public V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws InterruptedException {
return blockingQueue.pollFromAny(timeout, unit);
} | [
"@",
"Override",
"public",
"V",
"pollFromAny",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
",",
"String",
"...",
"queueNames",
")",
"throws",
"InterruptedException",
"{",
"return",
"blockingQueue",
".",
"pollFromAny",
"(",
"timeout",
",",
"unit",
")",
";"... | /*
(non-Javadoc)
@see org.redisson.core.RBlockingQueue#pollFromAny(long, java.util.concurrent.TimeUnit, java.lang.String[]) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | d3acc0249b2d5d658d36d99e2c808ce49332ea44 | https://github.com/redisson/redisson/blob/d3acc0249b2d5d658d36d99e2c808ce49332ea44/redisson/src/main/java/org/redisson/RedissonBlockingDeque.java#L101-L104 | train | Polls from any of the managed resources. | [
30522,
1030,
2058,
15637,
2270,
1058,
8554,
19699,
20778,
2100,
1006,
2146,
2051,
5833,
1010,
2051,
19496,
2102,
3131,
1010,
5164,
1012,
1012,
1012,
24240,
18442,
2015,
1007,
11618,
7153,
10288,
24422,
1063,
2709,
10851,
4226,
5657,
1012,
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... |
networknt/light-4j | utility/src/main/java/com/networknt/utility/StringUtils.java | StringUtils.substringBeforeLast | public static String substringBeforeLast(final String str, final String separator) {
if (isEmpty(str) || isEmpty(separator)) {
return str;
}
final int pos = str.lastIndexOf(separator);
if (pos == INDEX_NOT_FOUND) {
return str;
}
return str.substring(0, pos);
} | java | public static String substringBeforeLast(final String str, final String separator) {
if (isEmpty(str) || isEmpty(separator)) {
return str;
}
final int pos = str.lastIndexOf(separator);
if (pos == INDEX_NOT_FOUND) {
return str;
}
return str.substring(0, pos);
} | [
"public",
"static",
"String",
"substringBeforeLast",
"(",
"final",
"String",
"str",
",",
"final",
"String",
"separator",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"str",
")",
"||",
"isEmpty",
"(",
"separator",
")",
")",
"{",
"return",
"str",
";",
"}",
"final"... | <p>Gets the substring before the last occurrence of a separator.
The separator is not returned.</p>
<p>A {@code null} string input will return {@code null}.
An empty ("") string input will return the empty string.
An empty or {@code null} separator will return the input string.</p>
<p>If nothing is found, the string input is returned.</p>
<pre>
StringUtils.substringBeforeLast(null, *) = null
StringUtils.substringBeforeLast("", *) = ""
StringUtils.substringBeforeLast("abcba", "b") = "abc"
StringUtils.substringBeforeLast("abc", "c") = "ab"
StringUtils.substringBeforeLast("a", "a") = ""
StringUtils.substringBeforeLast("a", "z") = "a"
StringUtils.substringBeforeLast("a", null) = "a"
StringUtils.substringBeforeLast("a", "") = "a"
</pre>
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring before the last occurrence of the separator,
{@code null} if null String input
@since 2.0 | [
"<p",
">",
"Gets",
"the",
"substring",
"before",
"the",
"last",
"occurrence",
"of",
"a",
"separator",
".",
"The",
"separator",
"is",
"not",
"returned",
".",
"<",
"/",
"p",
">"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/StringUtils.java#L572-L581 | train | Get substring before last. | [
30522,
2270,
10763,
5164,
4942,
3367,
4892,
4783,
29278,
10581,
3367,
1006,
2345,
5164,
2358,
2099,
1010,
2345,
5164,
19802,
25879,
2953,
1007,
1063,
2065,
1006,
2003,
6633,
13876,
2100,
1006,
2358,
2099,
1007,
1064,
1064,
2003,
6633,
13876... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ReUtil.java | ReUtil.findAllGroup1 | public static List<String> findAllGroup1(Pattern pattern, CharSequence content) {
return findAll(pattern, content, 1);
} | java | public static List<String> findAllGroup1(Pattern pattern, CharSequence content) {
return findAll(pattern, content, 1);
} | [
"public",
"static",
"List",
"<",
"String",
">",
"findAllGroup1",
"(",
"Pattern",
"pattern",
",",
"CharSequence",
"content",
")",
"{",
"return",
"findAll",
"(",
"pattern",
",",
"content",
",",
"1",
")",
";",
"}"
] | 取得内容中匹配的所有结果,获得匹配的所有结果中正则对应分组1的内容
@param pattern 编译后的正则模式
@param content 被查找的内容
@return 结果列表
@since 3.1.2 | [
"取得内容中匹配的所有结果,获得匹配的所有结果中正则对应分组1的内容"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReUtil.java#L430-L432 | train | Finds all groups of the given content that match the given pattern and returns the first group. | [
30522,
2270,
10763,
2862,
1026,
5164,
1028,
2424,
8095,
17058,
2487,
1006,
5418,
5418,
1010,
25869,
3366,
4226,
5897,
4180,
1007,
1063,
2709,
2424,
8095,
1006,
5418,
1010,
4180,
1010,
1015,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/io/CollectionInputFormat.java | CollectionInputFormat.writeObject | private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
final int size = dataSet.size();
out.writeInt(size);
if (size > 0) {
DataOutputViewStreamWrapper wrapper = new DataOutputViewStreamWrapper(out);
for (T element : dataSet){
serializer.serialize(element, wrapper);
}
}
} | java | private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
final int size = dataSet.size();
out.writeInt(size);
if (size > 0) {
DataOutputViewStreamWrapper wrapper = new DataOutputViewStreamWrapper(out);
for (T element : dataSet){
serializer.serialize(element, wrapper);
}
}
} | [
"private",
"void",
"writeObject",
"(",
"ObjectOutputStream",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"defaultWriteObject",
"(",
")",
";",
"final",
"int",
"size",
"=",
"dataSet",
".",
"size",
"(",
")",
";",
"out",
".",
"writeInt",
"(",
"size",... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/io/CollectionInputFormat.java#L81-L93 | train | Serialize the data set to the specified output stream. | [
30522,
2797,
11675,
4339,
16429,
20614,
1006,
4874,
5833,
18780,
21422,
2041,
1007,
11618,
22834,
10288,
24422,
1063,
2041,
1012,
12398,
26373,
16429,
20614,
1006,
1007,
1025,
2345,
20014,
2946,
1027,
2951,
13462,
1012,
2946,
1006,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java | SqlValidatorImpl.deriveTypeImpl | RelDataType deriveTypeImpl(
SqlValidatorScope scope,
SqlNode operand) {
DeriveTypeVisitor v = new DeriveTypeVisitor(scope);
final RelDataType type = operand.accept(v);
return Objects.requireNonNull(scope.nullifyType(operand, type));
} | java | RelDataType deriveTypeImpl(
SqlValidatorScope scope,
SqlNode operand) {
DeriveTypeVisitor v = new DeriveTypeVisitor(scope);
final RelDataType type = operand.accept(v);
return Objects.requireNonNull(scope.nullifyType(operand, type));
} | [
"RelDataType",
"deriveTypeImpl",
"(",
"SqlValidatorScope",
"scope",
",",
"SqlNode",
"operand",
")",
"{",
"DeriveTypeVisitor",
"v",
"=",
"new",
"DeriveTypeVisitor",
"(",
"scope",
")",
";",
"final",
"RelDataType",
"type",
"=",
"operand",
".",
"accept",
"(",
"v",
... | Derives the type of a node, never null. | [
"Derives",
"the",
"type",
"of",
"a",
"node",
"never",
"null",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L1640-L1646 | train | Derive type from a type. | [
30522,
2128,
15150,
29336,
18863,
18547,
13874,
5714,
24759,
1006,
29296,
10175,
8524,
6591,
16186,
9531,
1010,
29296,
3630,
3207,
3850,
4859,
1007,
1063,
18547,
13874,
11365,
15660,
1058,
1027,
2047,
18547,
13874,
11365,
15660,
1006,
9531,
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/util/NumberUtil.java | NumberUtil.div | public static BigDecimal div(Number v1, Number v2, int scale, RoundingMode roundingMode) {
return div(v1.toString(), v2.toString(), scale, roundingMode);
} | java | public static BigDecimal div(Number v1, Number v2, int scale, RoundingMode roundingMode) {
return div(v1.toString(), v2.toString(), scale, roundingMode);
} | [
"public",
"static",
"BigDecimal",
"div",
"(",
"Number",
"v1",
",",
"Number",
"v2",
",",
"int",
"scale",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"return",
"div",
"(",
"v1",
".",
"toString",
"(",
")",
",",
"v2",
".",
"toString",
"(",
")",
",",
"... | 提供(相对)精确的除法运算,当发生除不尽的情况时,由scale指定精确度
@param v1 被除数
@param v2 除数
@param scale 精确度,如果为负值,取绝对值
@param roundingMode 保留小数的模式 {@link RoundingMode}
@return 两个参数的商
@since 3.1.0 | [
"提供",
"(",
"相对",
")",
"精确的除法运算",
"当发生除不尽的情况时",
"由scale指定精确度"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java#L714-L716 | train | Divide two numbers. | [
30522,
2270,
10763,
2502,
3207,
6895,
9067,
4487,
2615,
1006,
2193,
1058,
2487,
1010,
2193,
1058,
2475,
1010,
20014,
4094,
1010,
26939,
5302,
3207,
26939,
5302,
3207,
1007,
1063,
2709,
4487,
2615,
1006,
1058,
2487,
1012,
2000,
3367,
4892,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | java/client/src/org/openqa/selenium/interactions/Actions.java | Actions.moveByOffset | public Actions moveByOffset(int xOffset, int yOffset) {
if (isBuildingActions()) {
action.addAction(new MoveToOffsetAction(jsonMouse, null, xOffset, yOffset));
}
return tick(
defaultMouse.createPointerMove(Duration.ofMillis(200), Origin.pointer(), xOffset, yOffset));
} | java | public Actions moveByOffset(int xOffset, int yOffset) {
if (isBuildingActions()) {
action.addAction(new MoveToOffsetAction(jsonMouse, null, xOffset, yOffset));
}
return tick(
defaultMouse.createPointerMove(Duration.ofMillis(200), Origin.pointer(), xOffset, yOffset));
} | [
"public",
"Actions",
"moveByOffset",
"(",
"int",
"xOffset",
",",
"int",
"yOffset",
")",
"{",
"if",
"(",
"isBuildingActions",
"(",
")",
")",
"{",
"action",
".",
"addAction",
"(",
"new",
"MoveToOffsetAction",
"(",
"jsonMouse",
",",
"null",
",",
"xOffset",
",... | Moves the mouse from its current position (or 0,0) by the given offset. If the coordinates
provided are outside the viewport (the mouse will end up outside the browser window) then
the viewport is scrolled to match.
@param xOffset horizontal offset. A negative value means moving the mouse left.
@param yOffset vertical offset. A negative value means moving the mouse up.
@return A self reference.
@throws MoveTargetOutOfBoundsException if the provided offset is outside the document's
boundaries. | [
"Moves",
"the",
"mouse",
"from",
"its",
"current",
"position",
"(",
"or",
"0",
"0",
")",
"by",
"the",
"given",
"offset",
".",
"If",
"the",
"coordinates",
"provided",
"are",
"outside",
"the",
"viewport",
"(",
"the",
"mouse",
"will",
"end",
"up",
"outside"... | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/interactions/Actions.java#L405-L412 | train | Move the mouse to the specified location. | [
30522,
2270,
4506,
2693,
3762,
27475,
3388,
1006,
20014,
1060,
27475,
3388,
1010,
20014,
10930,
21807,
3388,
1007,
1063,
2065,
1006,
2003,
25820,
18908,
8496,
1006,
1007,
1007,
1063,
2895,
1012,
5587,
18908,
3258,
1006,
2047,
2693,
3406,
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... |
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... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/UUID.java | UUID.fromString | public static UUID fromString(String name) {
String[] components = name.split("-");
if (components.length != 5) {
throw new IllegalArgumentException("Invalid UUID string: " + name);
}
for (int i = 0; i < 5; i++) {
components[i] = "0x" + components[i];
}
long mostSigBits = Long.decode(components[0]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
long leastSigBits = Long.decode(components[3]).longValue();
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
return new UUID(mostSigBits, leastSigBits);
} | java | public static UUID fromString(String name) {
String[] components = name.split("-");
if (components.length != 5) {
throw new IllegalArgumentException("Invalid UUID string: " + name);
}
for (int i = 0; i < 5; i++) {
components[i] = "0x" + components[i];
}
long mostSigBits = Long.decode(components[0]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
long leastSigBits = Long.decode(components[3]).longValue();
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
return new UUID(mostSigBits, leastSigBits);
} | [
"public",
"static",
"UUID",
"fromString",
"(",
"String",
"name",
")",
"{",
"String",
"[",
"]",
"components",
"=",
"name",
".",
"split",
"(",
"\"-\"",
")",
";",
"if",
"(",
"components",
".",
"length",
"!=",
"5",
")",
"{",
"throw",
"new",
"IllegalArgumen... | 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。
@param name 指定 {@code UUID} 字符串
@return 具有指定值的 {@code UUID}
@throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常 | [
"根据",
"{",
"@link",
"#toString",
"()",
"}",
"方法中描述的字符串标准表示形式创建",
"{",
"@code",
"UUID",
"}",
"。"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/UUID.java#L159-L179 | train | Creates a UUID from a string of UUIDs. | [
30522,
2270,
10763,
1057,
21272,
2013,
3367,
4892,
1006,
5164,
2171,
1007,
1063,
5164,
1031,
1033,
6177,
1027,
2171,
1012,
3975,
1006,
1000,
1011,
1000,
1007,
1025,
2065,
1006,
6177,
1012,
3091,
999,
1027,
1019,
1007,
1063,
5466,
2047,
62... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.validateUpperCase | public static <T extends CharSequence> T validateUpperCase(T value, String errorMsg) throws ValidateException {
if (false == isUpperCase(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | java | public static <T extends CharSequence> T validateUpperCase(T value, String errorMsg) throws ValidateException {
if (false == isUpperCase(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | [
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"validateUpperCase",
"(",
"T",
"value",
",",
"String",
"errorMsg",
")",
"throws",
"ValidateException",
"{",
"if",
"(",
"false",
"==",
"isUpperCase",
"(",
"value",
")",
")",
"{",
"throw",
"n... | 验证字符串是否全部为大写字母
@param <T> 字符串类型
@param value 表单值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常
@since 3.3.0 | [
"验证字符串是否全部为大写字母"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java#L486-L491 | train | Validate uppercase. | [
30522,
2270,
10763,
1026,
1056,
8908,
25869,
3366,
4226,
5897,
1028,
1056,
9398,
3686,
29547,
18992,
3366,
1006,
1056,
3643,
1010,
5164,
7561,
5244,
2290,
1007,
11618,
9398,
3686,
10288,
24422,
1063,
2065,
1006,
6270,
1027,
1027,
2003,
2954... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-common/src/main/java/org/apache/flink/table/descriptors/DescriptorProperties.java | DescriptorProperties.putIndexedFixedProperties | public void putIndexedFixedProperties(String key, List<String> subKeys, List<List<String>> subKeyValues) {
checkNotNull(key);
checkNotNull(subKeys);
checkNotNull(subKeyValues);
for (int idx = 0; idx < subKeyValues.size(); idx++) {
final List<String> values = subKeyValues.get(idx);
if (values == null || values.size() != subKeys.size()) {
throw new ValidationException("Values must have same arity as keys.");
}
for (int keyIdx = 0; keyIdx < values.size(); keyIdx++) {
put(key + '.' + idx + '.' + subKeys.get(keyIdx), values.get(keyIdx));
}
}
} | java | public void putIndexedFixedProperties(String key, List<String> subKeys, List<List<String>> subKeyValues) {
checkNotNull(key);
checkNotNull(subKeys);
checkNotNull(subKeyValues);
for (int idx = 0; idx < subKeyValues.size(); idx++) {
final List<String> values = subKeyValues.get(idx);
if (values == null || values.size() != subKeys.size()) {
throw new ValidationException("Values must have same arity as keys.");
}
for (int keyIdx = 0; keyIdx < values.size(); keyIdx++) {
put(key + '.' + idx + '.' + subKeys.get(keyIdx), values.get(keyIdx));
}
}
} | [
"public",
"void",
"putIndexedFixedProperties",
"(",
"String",
"key",
",",
"List",
"<",
"String",
">",
"subKeys",
",",
"List",
"<",
"List",
"<",
"String",
">",
">",
"subKeyValues",
")",
"{",
"checkNotNull",
"(",
"key",
")",
";",
"checkNotNull",
"(",
"subKey... | Adds an indexed sequence of properties (with sub-properties) under a common key.
<p>For example:
<pre>
schema.fields.0.type = INT, schema.fields.0.name = test
schema.fields.1.type = LONG, schema.fields.1.name = test2
</pre>
<p>The arity of each subKeyValues must match the arity of propertyKeys. | [
"Adds",
"an",
"indexed",
"sequence",
"of",
"properties",
"(",
"with",
"sub",
"-",
"properties",
")",
"under",
"a",
"common",
"key",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/descriptors/DescriptorProperties.java#L202-L215 | train | Put an indexed property. | [
30522,
2270,
11675,
22072,
3207,
19068,
23901,
21572,
4842,
7368,
1006,
5164,
3145,
1010,
2862,
1026,
5164,
1028,
4942,
14839,
2015,
1010,
2862,
1026,
2862,
1026,
5164,
1028,
1028,
4942,
14839,
10175,
15808,
1007,
1063,
4638,
17048,
11231,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/bean/BeanUtil.java | BeanUtil.hasSetter | public static boolean hasSetter(Class<?> clazz) {
if (ClassUtil.isNormalClass(clazz)) {
final Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getParameterTypes().length == 1 && method.getName().startsWith("set")) {
// 检测包含标准的setXXX方法即视为标准的JavaBean
return true;
}
}
}
return false;
} | java | public static boolean hasSetter(Class<?> clazz) {
if (ClassUtil.isNormalClass(clazz)) {
final Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getParameterTypes().length == 1 && method.getName().startsWith("set")) {
// 检测包含标准的setXXX方法即视为标准的JavaBean
return true;
}
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasSetter",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"ClassUtil",
".",
"isNormalClass",
"(",
"clazz",
")",
")",
"{",
"final",
"Method",
"[",
"]",
"methods",
"=",
"clazz",
".",
"getMethods",
"(",
")",
... | 判断是否有Setter方法<br>
判定方法是是否存在只有一个参数的setXXX方法
@param clazz 待测试类
@return 是否为Bean对象
@since 4.2.2 | [
"判断是否有Setter方法<br",
">",
"判定方法是是否存在只有一个参数的setXXX方法"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/bean/BeanUtil.java#L64-L75 | train | Checks if the given class has a setter method. | [
30522,
2270,
10763,
22017,
20898,
2038,
21678,
2121,
1006,
2465,
1026,
1029,
1028,
18856,
10936,
2480,
1007,
1063,
2065,
1006,
2465,
21823,
2140,
1012,
3475,
2953,
9067,
26266,
1006,
18856,
10936,
2480,
1007,
1007,
1063,
2345,
4118,
1031,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | handler/src/main/java/io/netty/handler/ssl/SslHandler.java | SslHandler.runDelegatedTasks | private boolean runDelegatedTasks(boolean inUnwrap) {
if (delegatedTaskExecutor == ImmediateExecutor.INSTANCE || inEventLoop(delegatedTaskExecutor)) {
// We should run the task directly in the EventExecutor thread and not offload at all.
runAllDelegatedTasks(engine);
return true;
} else {
executeDelegatedTasks(inUnwrap);
return false;
}
} | java | private boolean runDelegatedTasks(boolean inUnwrap) {
if (delegatedTaskExecutor == ImmediateExecutor.INSTANCE || inEventLoop(delegatedTaskExecutor)) {
// We should run the task directly in the EventExecutor thread and not offload at all.
runAllDelegatedTasks(engine);
return true;
} else {
executeDelegatedTasks(inUnwrap);
return false;
}
} | [
"private",
"boolean",
"runDelegatedTasks",
"(",
"boolean",
"inUnwrap",
")",
"{",
"if",
"(",
"delegatedTaskExecutor",
"==",
"ImmediateExecutor",
".",
"INSTANCE",
"||",
"inEventLoop",
"(",
"delegatedTaskExecutor",
")",
")",
"{",
"// We should run the task directly in the Ev... | Will either run the delegated task directly calling {@link Runnable#run()} and return {@code true} or will
offload the delegated task using {@link Executor#execute(Runnable)} and return {@code false}.
If the task is offloaded it will take care to resume its work on the {@link EventExecutor} once there are no
more tasks to process. | [
"Will",
"either",
"run",
"the",
"delegated",
"task",
"directly",
"calling",
"{",
"@link",
"Runnable#run",
"()",
"}",
"and",
"return",
"{",
"@code",
"true",
"}",
"or",
"will",
"offload",
"the",
"delegated",
"task",
"using",
"{",
"@link",
"Executor#execute",
"... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/SslHandler.java#L1513-L1522 | train | Run all delegates. | [
30522,
2797,
22017,
20898,
2448,
9247,
29107,
3064,
10230,
5705,
1006,
22017,
20898,
1999,
4609,
13088,
9331,
1007,
1063,
2065,
1006,
11849,
11927,
19895,
10288,
8586,
16161,
2099,
1027,
1027,
6234,
10288,
8586,
16161,
2099,
1012,
6013,
1064,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/entrypoint/ClusterEntrypoint.java | ClusterEntrypoint.generateClusterConfiguration | private Configuration generateClusterConfiguration(Configuration configuration) {
final Configuration resultConfiguration = new Configuration(Preconditions.checkNotNull(configuration));
final String webTmpDir = configuration.getString(WebOptions.TMP_DIR);
final File uniqueWebTmpDir = new File(webTmpDir, "flink-web-" + UUID.randomUUID());
resultConfiguration.setString(WebOptions.TMP_DIR, uniqueWebTmpDir.getAbsolutePath());
return resultConfiguration;
} | java | private Configuration generateClusterConfiguration(Configuration configuration) {
final Configuration resultConfiguration = new Configuration(Preconditions.checkNotNull(configuration));
final String webTmpDir = configuration.getString(WebOptions.TMP_DIR);
final File uniqueWebTmpDir = new File(webTmpDir, "flink-web-" + UUID.randomUUID());
resultConfiguration.setString(WebOptions.TMP_DIR, uniqueWebTmpDir.getAbsolutePath());
return resultConfiguration;
} | [
"private",
"Configuration",
"generateClusterConfiguration",
"(",
"Configuration",
"configuration",
")",
"{",
"final",
"Configuration",
"resultConfiguration",
"=",
"new",
"Configuration",
"(",
"Preconditions",
".",
"checkNotNull",
"(",
"configuration",
")",
")",
";",
"fi... | -------------------------------------------------- | [
"--------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterEntrypoint.java#L385-L394 | train | Generates a cluster configuration. | [
30522,
2797,
9563,
9699,
20464,
19966,
2121,
8663,
8873,
27390,
3370,
1006,
9563,
9563,
1007,
1063,
2345,
9563,
2765,
8663,
8873,
27390,
3370,
1027,
2047,
9563,
1006,
3653,
8663,
20562,
2015,
1012,
4638,
17048,
11231,
3363,
1006,
9563,
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/math/MathUtil.java | MathUtil.combinationSelect | public static List<String[]> combinationSelect(String[] datas, int m) {
return new Combination(datas).select(m);
} | java | public static List<String[]> combinationSelect(String[] datas, int m) {
return new Combination(datas).select(m);
} | [
"public",
"static",
"List",
"<",
"String",
"[",
"]",
">",
"combinationSelect",
"(",
"String",
"[",
"]",
"datas",
",",
"int",
"m",
")",
"{",
"return",
"new",
"Combination",
"(",
"datas",
")",
".",
"select",
"(",
"m",
")",
";",
"}"
] | 组合选择(从列表中选择n个组合)
@param datas 待选列表
@param m 选择个数
@return 所有组合列表 | [
"组合选择(从列表中选择n个组合)"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/math/MathUtil.java#L76-L78 | train | Select a list of strings from a list of strings. | [
30522,
2270,
10763,
2862,
1026,
5164,
1031,
1033,
1028,
14930,
12260,
6593,
1006,
5164,
1031,
1033,
2951,
2015,
1010,
20014,
1049,
1007,
1063,
2709,
2047,
5257,
1006,
2951,
2015,
1007,
1012,
7276,
1006,
1049,
1007,
1025,
1065,
102,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TaskLauncherManager.java | TaskLauncherManager.spawnLauncher | protected TaskLauncher spawnLauncher(long millis) {
final TaskLauncher launcher = new TaskLauncher(this.scheduler, millis);
synchronized (this.launchers) {
this.launchers.add(launcher);
}
//子线程是否为deamon线程取决于父线程,因此此处无需显示调用
//launcher.setDaemon(this.scheduler.daemon);
// launcher.start();
this.scheduler.threadExecutor.execute(launcher);
return launcher;
} | java | protected TaskLauncher spawnLauncher(long millis) {
final TaskLauncher launcher = new TaskLauncher(this.scheduler, millis);
synchronized (this.launchers) {
this.launchers.add(launcher);
}
//子线程是否为deamon线程取决于父线程,因此此处无需显示调用
//launcher.setDaemon(this.scheduler.daemon);
// launcher.start();
this.scheduler.threadExecutor.execute(launcher);
return launcher;
} | [
"protected",
"TaskLauncher",
"spawnLauncher",
"(",
"long",
"millis",
")",
"{",
"final",
"TaskLauncher",
"launcher",
"=",
"new",
"TaskLauncher",
"(",
"this",
".",
"scheduler",
",",
"millis",
")",
";",
"synchronized",
"(",
"this",
".",
"launchers",
")",
"{",
"... | 启动 TaskLauncher
@param millis 触发事件的毫秒数
@return {@link TaskLauncher} | [
"启动",
"TaskLauncher"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cron/src/main/java/cn/hutool/cron/TaskLauncherManager.java#L27-L37 | train | Spawn a new launcher. | [
30522,
5123,
4708,
17298,
26091,
2099,
25645,
17298,
26091,
2099,
1006,
2146,
4971,
2483,
1007,
1063,
2345,
4708,
17298,
26091,
2099,
22742,
1027,
2047,
4708,
17298,
26091,
2099,
1006,
2023,
1012,
6134,
2099,
1010,
4971,
2483,
1007,
1025,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/types/parser/BigDecParser.java | BigDecParser.parseField | public static final BigDecimal parseField(byte[] bytes, int startPos, int length, char delimiter) {
if (length <= 0) {
throw new NumberFormatException("Invalid input: Empty string");
}
int i = 0;
final byte delByte = (byte) delimiter;
while (i < length && bytes[startPos + i] != delByte) {
i++;
}
if (i > 0 &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[startPos + i - 1]))) {
throw new NumberFormatException("There is leading or trailing whitespace in the numeric field.");
}
final char[] chars = new char[i];
for (int j = 0; j < i; j++) {
final byte b = bytes[startPos + j];
if ((b < '0' || b > '9') && b != '-' && b != '+' && b != '.' && b != 'E' && b != 'e') {
throw new NumberFormatException();
}
chars[j] = (char) bytes[startPos + j];
}
return new BigDecimal(chars);
} | java | public static final BigDecimal parseField(byte[] bytes, int startPos, int length, char delimiter) {
if (length <= 0) {
throw new NumberFormatException("Invalid input: Empty string");
}
int i = 0;
final byte delByte = (byte) delimiter;
while (i < length && bytes[startPos + i] != delByte) {
i++;
}
if (i > 0 &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[startPos + i - 1]))) {
throw new NumberFormatException("There is leading or trailing whitespace in the numeric field.");
}
final char[] chars = new char[i];
for (int j = 0; j < i; j++) {
final byte b = bytes[startPos + j];
if ((b < '0' || b > '9') && b != '-' && b != '+' && b != '.' && b != 'E' && b != 'e') {
throw new NumberFormatException();
}
chars[j] = (char) bytes[startPos + j];
}
return new BigDecimal(chars);
} | [
"public",
"static",
"final",
"BigDecimal",
"parseField",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"startPos",
",",
"int",
"length",
",",
"char",
"delimiter",
")",
"{",
"if",
"(",
"length",
"<=",
"0",
")",
"{",
"throw",
"new",
"NumberFormatException",
... | Static utility to parse a field of type BigDecimal from a byte sequence that represents text
characters
(such as when read from a file stream).
@param bytes The bytes containing the text data that should be parsed.
@param startPos The offset to start the parsing.
@param length The length of the byte sequence (counting from the offset).
@param delimiter The delimiter that terminates the field.
@return The parsed value.
@throws IllegalArgumentException Thrown when the value cannot be parsed because the text
represents not a correct number. | [
"Static",
"utility",
"to",
"parse",
"a",
"field",
"of",
"type",
"BigDecimal",
"from",
"a",
"byte",
"sequence",
"that",
"represents",
"text",
"characters",
"(",
"such",
"as",
"when",
"read",
"from",
"a",
"file",
"stream",
")",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/parser/BigDecParser.java#L104-L129 | train | Parses a field of a byte array. | [
30522,
2270,
10763,
2345,
2502,
3207,
6895,
9067,
11968,
20106,
12891,
1006,
24880,
1031,
1033,
27507,
1010,
20014,
2707,
6873,
2015,
1010,
20014,
3091,
1010,
25869,
3972,
27605,
3334,
1007,
1063,
2065,
1006,
3091,
1026,
1027,
1014,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/thread/ThreadUtil.java | ThreadUtil.getThreads | public static Thread[] getThreads(ThreadGroup group) {
final Thread[] slackList = new Thread[group.activeCount() * 2];
final int actualSize = group.enumerate(slackList);
final Thread[] result = new Thread[actualSize];
System.arraycopy(slackList, 0, result, 0, actualSize);
return result;
} | java | public static Thread[] getThreads(ThreadGroup group) {
final Thread[] slackList = new Thread[group.activeCount() * 2];
final int actualSize = group.enumerate(slackList);
final Thread[] result = new Thread[actualSize];
System.arraycopy(slackList, 0, result, 0, actualSize);
return result;
} | [
"public",
"static",
"Thread",
"[",
"]",
"getThreads",
"(",
"ThreadGroup",
"group",
")",
"{",
"final",
"Thread",
"[",
"]",
"slackList",
"=",
"new",
"Thread",
"[",
"group",
".",
"activeCount",
"(",
")",
"*",
"2",
"]",
";",
"final",
"int",
"actualSize",
"... | 获取JVM中与当前线程同组的所有线程<br>
使用数组二次拷贝方式,防止在线程列表获取过程中线程终止<br>
from Voovan
@param group 线程组
@return 线程对象数组 | [
"获取JVM中与当前线程同组的所有线程<br",
">",
"使用数组二次拷贝方式,防止在线程列表获取过程中线程终止<br",
">",
"from",
"Voovan"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/thread/ThreadUtil.java#L354-L360 | train | Get threads from a thread group. | [
30522,
2270,
10763,
11689,
1031,
1033,
2131,
2705,
16416,
5104,
1006,
11689,
17058,
2177,
1007,
1063,
2345,
11689,
1031,
1033,
19840,
9863,
1027,
2047,
11689,
1031,
2177,
1012,
3161,
3597,
16671,
1006,
1007,
1008,
1016,
1033,
1025,
2345,
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... |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java | Sftp.get | public Sftp get(String src, String dest) {
try {
channel.get(src, dest);
} catch (SftpException e) {
throw new JschRuntimeException(e);
}
return this;
} | java | public Sftp get(String src, String dest) {
try {
channel.get(src, dest);
} catch (SftpException e) {
throw new JschRuntimeException(e);
}
return this;
} | [
"public",
"Sftp",
"get",
"(",
"String",
"src",
",",
"String",
"dest",
")",
"{",
"try",
"{",
"channel",
".",
"get",
"(",
"src",
",",
"dest",
")",
";",
"}",
"catch",
"(",
"SftpException",
"e",
")",
"{",
"throw",
"new",
"JschRuntimeException",
"(",
"e",... | 获取远程文件
@param src 远程文件路径
@param dest 目标文件路径
@return this | [
"获取远程文件"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java#L396-L403 | train | Open a single file or directory. | [
30522,
2270,
16420,
25856,
2131,
1006,
5164,
5034,
2278,
1010,
5164,
4078,
2102,
1007,
1063,
3046,
1063,
3149,
1012,
2131,
1006,
5034,
30524,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/websocketx/WebSocketClientHandshaker.java | WebSocketClientHandshaker.finishHandshake | public final void finishHandshake(Channel channel, FullHttpResponse response) {
verify(response);
// Verify the subprotocol that we received from the server.
// This must be one of our expected subprotocols - or null/empty if we didn't want to speak a subprotocol
String receivedProtocol = response.headers().get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL);
receivedProtocol = receivedProtocol != null ? receivedProtocol.trim() : null;
String expectedProtocol = expectedSubprotocol != null ? expectedSubprotocol : "";
boolean protocolValid = false;
if (expectedProtocol.isEmpty() && receivedProtocol == null) {
// No subprotocol required and none received
protocolValid = true;
setActualSubprotocol(expectedSubprotocol); // null or "" - we echo what the user requested
} else if (!expectedProtocol.isEmpty() && receivedProtocol != null && !receivedProtocol.isEmpty()) {
// We require a subprotocol and received one -> verify it
for (String protocol : expectedProtocol.split(",")) {
if (protocol.trim().equals(receivedProtocol)) {
protocolValid = true;
setActualSubprotocol(receivedProtocol);
break;
}
}
} // else mixed cases - which are all errors
if (!protocolValid) {
throw new WebSocketHandshakeException(String.format(
"Invalid subprotocol. Actual: %s. Expected one of: %s",
receivedProtocol, expectedSubprotocol));
}
setHandshakeComplete();
final ChannelPipeline p = channel.pipeline();
// Remove decompressor from pipeline if its in use
HttpContentDecompressor decompressor = p.get(HttpContentDecompressor.class);
if (decompressor != null) {
p.remove(decompressor);
}
// Remove aggregator if present before
HttpObjectAggregator aggregator = p.get(HttpObjectAggregator.class);
if (aggregator != null) {
p.remove(aggregator);
}
ChannelHandlerContext ctx = p.context(HttpResponseDecoder.class);
if (ctx == null) {
ctx = p.context(HttpClientCodec.class);
if (ctx == null) {
throw new IllegalStateException("ChannelPipeline does not contain " +
"a HttpRequestEncoder or HttpClientCodec");
}
final HttpClientCodec codec = (HttpClientCodec) ctx.handler();
// Remove the encoder part of the codec as the user may start writing frames after this method returns.
codec.removeOutboundHandler();
p.addAfter(ctx.name(), "ws-decoder", newWebsocketDecoder());
// Delay the removal of the decoder so the user can setup the pipeline if needed to handle
// WebSocketFrame messages.
// See https://github.com/netty/netty/issues/4533
channel.eventLoop().execute(new Runnable() {
@Override
public void run() {
p.remove(codec);
}
});
} else {
if (p.get(HttpRequestEncoder.class) != null) {
// Remove the encoder part of the codec as the user may start writing frames after this method returns.
p.remove(HttpRequestEncoder.class);
}
final ChannelHandlerContext context = ctx;
p.addAfter(context.name(), "ws-decoder", newWebsocketDecoder());
// Delay the removal of the decoder so the user can setup the pipeline if needed to handle
// WebSocketFrame messages.
// See https://github.com/netty/netty/issues/4533
channel.eventLoop().execute(new Runnable() {
@Override
public void run() {
p.remove(context.handler());
}
});
}
} | java | public final void finishHandshake(Channel channel, FullHttpResponse response) {
verify(response);
// Verify the subprotocol that we received from the server.
// This must be one of our expected subprotocols - or null/empty if we didn't want to speak a subprotocol
String receivedProtocol = response.headers().get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL);
receivedProtocol = receivedProtocol != null ? receivedProtocol.trim() : null;
String expectedProtocol = expectedSubprotocol != null ? expectedSubprotocol : "";
boolean protocolValid = false;
if (expectedProtocol.isEmpty() && receivedProtocol == null) {
// No subprotocol required and none received
protocolValid = true;
setActualSubprotocol(expectedSubprotocol); // null or "" - we echo what the user requested
} else if (!expectedProtocol.isEmpty() && receivedProtocol != null && !receivedProtocol.isEmpty()) {
// We require a subprotocol and received one -> verify it
for (String protocol : expectedProtocol.split(",")) {
if (protocol.trim().equals(receivedProtocol)) {
protocolValid = true;
setActualSubprotocol(receivedProtocol);
break;
}
}
} // else mixed cases - which are all errors
if (!protocolValid) {
throw new WebSocketHandshakeException(String.format(
"Invalid subprotocol. Actual: %s. Expected one of: %s",
receivedProtocol, expectedSubprotocol));
}
setHandshakeComplete();
final ChannelPipeline p = channel.pipeline();
// Remove decompressor from pipeline if its in use
HttpContentDecompressor decompressor = p.get(HttpContentDecompressor.class);
if (decompressor != null) {
p.remove(decompressor);
}
// Remove aggregator if present before
HttpObjectAggregator aggregator = p.get(HttpObjectAggregator.class);
if (aggregator != null) {
p.remove(aggregator);
}
ChannelHandlerContext ctx = p.context(HttpResponseDecoder.class);
if (ctx == null) {
ctx = p.context(HttpClientCodec.class);
if (ctx == null) {
throw new IllegalStateException("ChannelPipeline does not contain " +
"a HttpRequestEncoder or HttpClientCodec");
}
final HttpClientCodec codec = (HttpClientCodec) ctx.handler();
// Remove the encoder part of the codec as the user may start writing frames after this method returns.
codec.removeOutboundHandler();
p.addAfter(ctx.name(), "ws-decoder", newWebsocketDecoder());
// Delay the removal of the decoder so the user can setup the pipeline if needed to handle
// WebSocketFrame messages.
// See https://github.com/netty/netty/issues/4533
channel.eventLoop().execute(new Runnable() {
@Override
public void run() {
p.remove(codec);
}
});
} else {
if (p.get(HttpRequestEncoder.class) != null) {
// Remove the encoder part of the codec as the user may start writing frames after this method returns.
p.remove(HttpRequestEncoder.class);
}
final ChannelHandlerContext context = ctx;
p.addAfter(context.name(), "ws-decoder", newWebsocketDecoder());
// Delay the removal of the decoder so the user can setup the pipeline if needed to handle
// WebSocketFrame messages.
// See https://github.com/netty/netty/issues/4533
channel.eventLoop().execute(new Runnable() {
@Override
public void run() {
p.remove(context.handler());
}
});
}
} | [
"public",
"final",
"void",
"finishHandshake",
"(",
"Channel",
"channel",
",",
"FullHttpResponse",
"response",
")",
"{",
"verify",
"(",
"response",
")",
";",
"// Verify the subprotocol that we received from the server.",
"// This must be one of our expected subprotocols - or null/... | Validates and finishes the opening handshake initiated by {@link #handshake}}.
@param channel
Channel
@param response
HTTP response containing the closing handshake details | [
"Validates",
"and",
"finishes",
"the",
"opening",
"handshake",
"initiated",
"by",
"{",
"@link",
"#handshake",
"}}",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java#L275-L361 | train | Finishes the handshake. | [
30522,
2270,
2345,
11675,
3926,
11774,
7377,
3489,
1006,
3149,
3149,
1010,
2440,
11039,
25856,
6072,
26029,
3366,
3433,
1007,
1063,
20410,
1006,
3433,
1007,
1025,
1013,
1013,
20410,
1996,
4942,
21572,
3406,
25778,
2008,
2057,
2363,
2013,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/iterative/task/AbstractIterativeTask.java | AbstractIterativeTask.createSolutionSetUpdateOutputCollector | protected Collector<OT> createSolutionSetUpdateOutputCollector(Collector<OT> delegate) {
Broker<Object> solutionSetBroker = SolutionSetBroker.instance();
Object ss = solutionSetBroker.get(brokerKey());
if (ss instanceof CompactingHashTable) {
@SuppressWarnings("unchecked")
CompactingHashTable<OT> solutionSet = (CompactingHashTable<OT>) ss;
return new SolutionSetUpdateOutputCollector<OT>(solutionSet, delegate);
}
else if (ss instanceof JoinHashMap) {
@SuppressWarnings("unchecked")
JoinHashMap<OT> map = (JoinHashMap<OT>) ss;
return new SolutionSetObjectsUpdateOutputCollector<OT>(map, delegate);
} else {
throw new RuntimeException("Unrecognized solution set handle: " + ss);
}
} | java | protected Collector<OT> createSolutionSetUpdateOutputCollector(Collector<OT> delegate) {
Broker<Object> solutionSetBroker = SolutionSetBroker.instance();
Object ss = solutionSetBroker.get(brokerKey());
if (ss instanceof CompactingHashTable) {
@SuppressWarnings("unchecked")
CompactingHashTable<OT> solutionSet = (CompactingHashTable<OT>) ss;
return new SolutionSetUpdateOutputCollector<OT>(solutionSet, delegate);
}
else if (ss instanceof JoinHashMap) {
@SuppressWarnings("unchecked")
JoinHashMap<OT> map = (JoinHashMap<OT>) ss;
return new SolutionSetObjectsUpdateOutputCollector<OT>(map, delegate);
} else {
throw new RuntimeException("Unrecognized solution set handle: " + ss);
}
} | [
"protected",
"Collector",
"<",
"OT",
">",
"createSolutionSetUpdateOutputCollector",
"(",
"Collector",
"<",
"OT",
">",
"delegate",
")",
"{",
"Broker",
"<",
"Object",
">",
"solutionSetBroker",
"=",
"SolutionSetBroker",
".",
"instance",
"(",
")",
";",
"Object",
"ss... | Creates a new solution set update output collector.
<p>This collector is used by {@link IterationIntermediateTask} or {@link IterationTailTask} to update the
solution set of workset iterations. Depending on the task configuration, either a fast (non-probing)
{@link org.apache.flink.runtime.iterative.io.SolutionSetFastUpdateOutputCollector} or normal (re-probing)
{@link SolutionSetUpdateOutputCollector} is created.
<p>If a non-null delegate is given, the new {@link Collector} will write back to the solution set and also call
collect(T) of the delegate.
@param delegate null -OR- a delegate collector to be called by the newly created collector
@return a new {@link org.apache.flink.runtime.iterative.io.SolutionSetFastUpdateOutputCollector} or
{@link SolutionSetUpdateOutputCollector} | [
"Creates",
"a",
"new",
"solution",
"set",
"update",
"output",
"collector",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/iterative/task/AbstractIterativeTask.java#L341-L357 | train | Creates a new instance of the SolutionSetUpdateOutputCollector interface. | [
30522,
5123,
10018,
1026,
27178,
1028,
9005,
4747,
13700,
13462,
6279,
13701,
5833,
18780,
26895,
22471,
2953,
1006,
10018,
1026,
27178,
1028,
11849,
1007,
1063,
20138,
1026,
4874,
1028,
7300,
3388,
12618,
5484,
1027,
7300,
3388,
12618,
5484,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/util/MathUtils.java | MathUtils.roundUpToPowerOfTwo | public static int roundUpToPowerOfTwo(int x) {
x = x - 1;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
return x + 1;
} | java | public static int roundUpToPowerOfTwo(int x) {
x = x - 1;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
return x + 1;
} | [
"public",
"static",
"int",
"roundUpToPowerOfTwo",
"(",
"int",
"x",
")",
"{",
"x",
"=",
"x",
"-",
"1",
";",
"x",
"|=",
"x",
">>",
"1",
";",
"x",
"|=",
"x",
">>",
"2",
";",
"x",
"|=",
"x",
">>",
"4",
";",
"x",
"|=",
"x",
">>",
"8",
";",
"x"... | Round the given number to the next power of two.
@param x number to round
@return x rounded up to the next power of two | [
"Round",
"the",
"given",
"number",
"to",
"the",
"next",
"power",
"of",
"two",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/MathUtils.java#L161-L169 | train | Round up to power of two. | [
30522,
2270,
10763,
20014,
2461,
29441,
7361,
25114,
15794,
12155,
1006,
20014,
1060,
1007,
1063,
1060,
1027,
1060,
1011,
1015,
1025,
1060,
1064,
1027,
1060,
1028,
1028,
1015,
1025,
1060,
1064,
1027,
1060,
1028,
1028,
1016,
1025,
1060,
1064... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/resource/ClassPathResource.java | ClassPathResource.getAbsolutePath | public final String getAbsolutePath() {
if (FileUtil.isAbsolutePath(this.path)) {
return this.path;
}
// url在初始化的时候已经断言,此处始终不为null
return FileUtil.normalize(URLUtil.getDecodedPath(this.url));
} | java | public final String getAbsolutePath() {
if (FileUtil.isAbsolutePath(this.path)) {
return this.path;
}
// url在初始化的时候已经断言,此处始终不为null
return FileUtil.normalize(URLUtil.getDecodedPath(this.url));
} | [
"public",
"final",
"String",
"getAbsolutePath",
"(",
")",
"{",
"if",
"(",
"FileUtil",
".",
"isAbsolutePath",
"(",
"this",
".",
"path",
")",
")",
"{",
"return",
"this",
".",
"path",
";",
"}",
"// url在初始化的时候已经断言,此处始终不为null\r",
"return",
"FileUtil",
".",
"norma... | 获得绝对路径Path<br>
对于不存在的资源,返回拼接后的绝对路径
@return 绝对路径path | [
"获得绝对路径Path<br",
">",
"对于不存在的资源,返回拼接后的绝对路径"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/resource/ClassPathResource.java#L92-L98 | train | Gets the absolute path of the file. | [
30522,
2270,
2345,
5164,
2131,
7875,
19454,
10421,
15069,
1006,
1007,
1063,
2065,
1006,
5371,
21823,
2140,
1012,
18061,
5910,
4747,
10421,
15069,
1006,
2023,
1012,
4130,
1007,
1007,
1063,
2709,
2023,
1012,
4130,
1025,
1065,
1013,
1013,
2447... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.zip | public static File zip(File zipFile, String[] paths, InputStream[] ins) throws UtilException {
return zip(zipFile, paths, ins, DEFAULT_CHARSET);
} | java | public static File zip(File zipFile, String[] paths, InputStream[] ins) throws UtilException {
return zip(zipFile, paths, ins, DEFAULT_CHARSET);
} | [
"public",
"static",
"File",
"zip",
"(",
"File",
"zipFile",
",",
"String",
"[",
"]",
"paths",
",",
"InputStream",
"[",
"]",
"ins",
")",
"throws",
"UtilException",
"{",
"return",
"zip",
"(",
"zipFile",
",",
"paths",
",",
"ins",
",",
"DEFAULT_CHARSET",
")",... | 对流中的数据加入到压缩文件<br>
路径列表和流列表长度必须一致
@param zipFile 生成的Zip文件,包括文件名。注意:zipPath不能是srcPath路径下的子文件夹
@param paths 流数据在压缩文件中的路径或文件名
@param ins 要压缩的源
@return 压缩文件
@throws UtilException IO异常
@since 3.0.9 | [
"对流中的数据加入到压缩文件<br",
">",
"路径列表和流列表长度必须一致"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java#L251-L253 | train | Creates a zip file from the given input stream. | [
30522,
2270,
10763,
5371,
14101,
1006,
5371,
14101,
8873,
2571,
1010,
5164,
1031,
1033,
10425,
1010,
20407,
25379,
1031,
1033,
16021,
1007,
11618,
21183,
9463,
2595,
24422,
1063,
2709,
14101,
1006,
14101,
8873,
2571,
1010,
10425,
1010,
16021,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/State.java | State.getLargestValueId | public Integer getLargestValueId()
{
if (emits == null || emits.size() == 0) return null;
return emits.iterator().next();
} | java | public Integer getLargestValueId()
{
if (emits == null || emits.size() == 0) return null;
return emits.iterator().next();
} | [
"public",
"Integer",
"getLargestValueId",
"(",
")",
"{",
"if",
"(",
"emits",
"==",
"null",
"||",
"emits",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"null",
";",
"return",
"emits",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"}"
] | 获取最大的值
@return | [
"获取最大的值"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/AhoCorasick/State.java#L92-L97 | train | Gets the largest value id of the sequence. | [
30522,
2270,
16109,
2131,
8017,
8449,
9189,
2389,
5657,
3593,
1006,
1007,
1063,
2065,
1006,
12495,
3215,
1027,
1027,
19701,
1064,
1064,
12495,
3215,
1012,
2946,
1006,
1007,
1027,
1027,
1014,
1007,
2709,
19701,
1025,
2709,
12495,
3215,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/dependency/nnparser/Matrix.java | Matrix.plusEquals | public Matrix plusEquals(Matrix B)
{
checkMatrixDimensions(B);
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
A[i][j] = A[i][j] + B.A[i][j];
}
}
return this;
} | java | public Matrix plusEquals(Matrix B)
{
checkMatrixDimensions(B);
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
A[i][j] = A[i][j] + B.A[i][j];
}
}
return this;
} | [
"public",
"Matrix",
"plusEquals",
"(",
"Matrix",
"B",
")",
"{",
"checkMatrixDimensions",
"(",
"B",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"n",... | A = A + B
@param B another matrix
@return A + B | [
"A",
"=",
"A",
"+",
"B"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dependency/nnparser/Matrix.java#L712-L723 | train | A = A + B | [
30522,
2270,
8185,
4606,
2063,
26426,
2015,
1006,
8185,
1038,
1007,
1063,
4638,
18900,
17682,
22172,
6132,
8496,
1006,
1038,
1007,
1025,
2005,
1006,
20014,
1045,
1027,
1014,
1025,
1045,
1026,
1049,
1025,
1045,
1009,
1009,
1007,
1063,
2005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getTriplets | public DataSet<Triplet<K, VV, EV>> getTriplets() {
return this.getVertices()
.join(this.getEdges()).where(0).equalTo(0)
.with(new ProjectEdgeWithSrcValue<>())
.name("Project edge with source value")
.join(this.getVertices()).where(1).equalTo(0)
.with(new ProjectEdgeWithVertexValues<>())
.name("Project edge with vertex values");
} | java | public DataSet<Triplet<K, VV, EV>> getTriplets() {
return this.getVertices()
.join(this.getEdges()).where(0).equalTo(0)
.with(new ProjectEdgeWithSrcValue<>())
.name("Project edge with source value")
.join(this.getVertices()).where(1).equalTo(0)
.with(new ProjectEdgeWithVertexValues<>())
.name("Project edge with vertex values");
} | [
"public",
"DataSet",
"<",
"Triplet",
"<",
"K",
",",
"VV",
",",
"EV",
">",
">",
"getTriplets",
"(",
")",
"{",
"return",
"this",
".",
"getVertices",
"(",
")",
".",
"join",
"(",
"this",
".",
"getEdges",
"(",
")",
")",
".",
"where",
"(",
"0",
")",
... | This method allows access to the graph's edge values along with its source and target vertex values.
@return a triplet DataSet consisting of (srcVertexId, trgVertexId, srcVertexValue, trgVertexValue, edgeValue) | [
"This",
"method",
"allows",
"access",
"to",
"the",
"graph",
"s",
"edge",
"values",
"along",
"with",
"its",
"source",
"and",
"target",
"vertex",
"values",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/Graph.java#L483-L491 | train | Get the triplets of this project. | [
30522,
2270,
2951,
13462,
1026,
6420,
2102,
1026,
1047,
1010,
1058,
2615,
1010,
23408,
1028,
1028,
2131,
24901,
13461,
1006,
1007,
1063,
2709,
2023,
1012,
2131,
16874,
23522,
1006,
1007,
1012,
3693,
1006,
2023,
1012,
2131,
24225,
2015,
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-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducerBase.java | FlinkKafkaProducerBase.checkErroneous | protected void checkErroneous() throws Exception {
Exception e = asyncException;
if (e != null) {
// prevent double throwing
asyncException = null;
throw new Exception("Failed to send data to Kafka: " + e.getMessage(), e);
}
} | java | protected void checkErroneous() throws Exception {
Exception e = asyncException;
if (e != null) {
// prevent double throwing
asyncException = null;
throw new Exception("Failed to send data to Kafka: " + e.getMessage(), e);
}
} | [
"protected",
"void",
"checkErroneous",
"(",
")",
"throws",
"Exception",
"{",
"Exception",
"e",
"=",
"asyncException",
";",
"if",
"(",
"e",
"!=",
"null",
")",
"{",
"// prevent double throwing",
"asyncException",
"=",
"null",
";",
"throw",
"new",
"Exception",
"(... | ----------------------------------- Utilities -------------------------- | [
"-----------------------------------",
"Utilities",
"--------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducerBase.java#L370-L377 | train | Check if any errors are thrown. | [
30522,
5123,
11675,
4638,
2121,
20793,
3560,
1006,
1007,
11618,
6453,
1063,
6453,
1041,
1027,
2004,
6038,
3401,
2595,
24422,
1025,
2065,
1006,
1041,
999,
1027,
19701,
1007,
1063,
1013,
1013,
4652,
3313,
6886,
2004,
6038,
3401,
2595,
24422,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/mining/word/TermFrequencyCounter.java | TermFrequencyCounter.top | public Collection<TermFrequency> top(int N)
{
MaxHeap<TermFrequency> heap = new MaxHeap<TermFrequency>(N, new Comparator<TermFrequency>()
{
@Override
public int compare(TermFrequency o1, TermFrequency o2)
{
return o1.compareTo(o2);
}
});
heap.addAll(termFrequencyMap.values());
return heap.toList();
} | java | public Collection<TermFrequency> top(int N)
{
MaxHeap<TermFrequency> heap = new MaxHeap<TermFrequency>(N, new Comparator<TermFrequency>()
{
@Override
public int compare(TermFrequency o1, TermFrequency o2)
{
return o1.compareTo(o2);
}
});
heap.addAll(termFrequencyMap.values());
return heap.toList();
} | [
"public",
"Collection",
"<",
"TermFrequency",
">",
"top",
"(",
"int",
"N",
")",
"{",
"MaxHeap",
"<",
"TermFrequency",
">",
"heap",
"=",
"new",
"MaxHeap",
"<",
"TermFrequency",
">",
"(",
"N",
",",
"new",
"Comparator",
"<",
"TermFrequency",
">",
"(",
")",
... | 取前N个高频词
@param N
@return | [
"取前N个高频词"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/mining/word/TermFrequencyCounter.java#L85-L97 | train | Get the top N terms. | [
30522,
2270,
3074,
1026,
2744,
19699,
2063,
4226,
9407,
1028,
2327,
1006,
20014,
1050,
1007,
1063,
4098,
20192,
2361,
1026,
2744,
19699,
2063,
4226,
9407,
1028,
16721,
1027,
2047,
4098,
20192,
2361,
1026,
2744,
19699,
2063,
4226,
9407,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/api/environment/PythonEnvironmentFactory.java | PythonEnvironmentFactory.create_local_execution_environment | public PythonStreamExecutionEnvironment create_local_execution_environment(Configuration config) {
return new PythonStreamExecutionEnvironment(new LocalStreamEnvironment(config), new Path(localTmpPath), scriptName);
} | java | public PythonStreamExecutionEnvironment create_local_execution_environment(Configuration config) {
return new PythonStreamExecutionEnvironment(new LocalStreamEnvironment(config), new Path(localTmpPath), scriptName);
} | [
"public",
"PythonStreamExecutionEnvironment",
"create_local_execution_environment",
"(",
"Configuration",
"config",
")",
"{",
"return",
"new",
"PythonStreamExecutionEnvironment",
"(",
"new",
"LocalStreamEnvironment",
"(",
"config",
")",
",",
"new",
"Path",
"(",
"localTmpPat... | Creates a {@link LocalStreamEnvironment}. The local execution environment
will run the program in a multi-threaded fashion in the same JVM as the
environment was created in. The default parallelism of the local
environment is the number of hardware contexts (CPU cores / threads),
unless it was specified differently by {@link PythonStreamExecutionEnvironment#set_parallelism(int)}.
@param config Pass a custom configuration into the cluster
@return A local execution environment with the specified parallelism. | [
"Creates",
"a",
"{",
"@link",
"LocalStreamEnvironment",
"}",
".",
"The",
"local",
"execution",
"environment",
"will",
"run",
"the",
"program",
"in",
"a",
"multi",
"-",
"threaded",
"fashion",
"in",
"the",
"same",
"JVM",
"as",
"the",
"environment",
"was",
"cre... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/api/environment/PythonEnvironmentFactory.java#L63-L65 | train | Create a local Python stream execution environment. | [
30522,
2270,
18750,
21422,
10288,
8586,
13700,
2368,
21663,
2239,
3672,
3443,
1035,
2334,
1035,
7781,
1035,
4044,
1006,
9563,
9530,
8873,
2290,
1007,
1063,
2709,
2047,
18750,
21422,
10288,
8586,
13700,
2368,
21663,
2239,
3672,
1006,
2047,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/DataSourceTask.java | DataSourceTask.initInputFormat | private void initInputFormat() {
ClassLoader userCodeClassLoader = getUserCodeClassLoader();
// obtain task configuration (including stub parameters)
Configuration taskConf = getTaskConfiguration();
this.config = new TaskConfig(taskConf);
try {
this.format = config.<InputFormat<OT, InputSplit>>getStubWrapper(userCodeClassLoader)
.getUserCodeObject(InputFormat.class, userCodeClassLoader);
// check if the class is a subclass, if the check is required
if (!InputFormat.class.isAssignableFrom(this.format.getClass())) {
throw new RuntimeException("The class '" + this.format.getClass().getName() + "' is not a subclass of '" +
InputFormat.class.getName() + "' as is required.");
}
}
catch (ClassCastException ccex) {
throw new RuntimeException("The stub class is not a proper subclass of " + InputFormat.class.getName(),
ccex);
}
Thread thread = Thread.currentThread();
ClassLoader original = thread.getContextClassLoader();
// configure the stub. catch exceptions here extra, to report them as originating from the user code
try {
thread.setContextClassLoader(userCodeClassLoader);
this.format.configure(this.config.getStubParameters());
}
catch (Throwable t) {
throw new RuntimeException("The user defined 'configure()' method caused an error: " + t.getMessage(), t);
}
finally {
thread.setContextClassLoader(original);
}
// get the factory for the type serializer
this.serializerFactory = this.config.getOutputSerializer(userCodeClassLoader);
} | java | private void initInputFormat() {
ClassLoader userCodeClassLoader = getUserCodeClassLoader();
// obtain task configuration (including stub parameters)
Configuration taskConf = getTaskConfiguration();
this.config = new TaskConfig(taskConf);
try {
this.format = config.<InputFormat<OT, InputSplit>>getStubWrapper(userCodeClassLoader)
.getUserCodeObject(InputFormat.class, userCodeClassLoader);
// check if the class is a subclass, if the check is required
if (!InputFormat.class.isAssignableFrom(this.format.getClass())) {
throw new RuntimeException("The class '" + this.format.getClass().getName() + "' is not a subclass of '" +
InputFormat.class.getName() + "' as is required.");
}
}
catch (ClassCastException ccex) {
throw new RuntimeException("The stub class is not a proper subclass of " + InputFormat.class.getName(),
ccex);
}
Thread thread = Thread.currentThread();
ClassLoader original = thread.getContextClassLoader();
// configure the stub. catch exceptions here extra, to report them as originating from the user code
try {
thread.setContextClassLoader(userCodeClassLoader);
this.format.configure(this.config.getStubParameters());
}
catch (Throwable t) {
throw new RuntimeException("The user defined 'configure()' method caused an error: " + t.getMessage(), t);
}
finally {
thread.setContextClassLoader(original);
}
// get the factory for the type serializer
this.serializerFactory = this.config.getOutputSerializer(userCodeClassLoader);
} | [
"private",
"void",
"initInputFormat",
"(",
")",
"{",
"ClassLoader",
"userCodeClassLoader",
"=",
"getUserCodeClassLoader",
"(",
")",
";",
"// obtain task configuration (including stub parameters)",
"Configuration",
"taskConf",
"=",
"getTaskConfiguration",
"(",
")",
";",
"thi... | Initializes the InputFormat implementation and configuration.
@throws RuntimeException
Throws if instance of InputFormat implementation can not be
obtained. | [
"Initializes",
"the",
"InputFormat",
"implementation",
"and",
"configuration",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/DataSourceTask.java#L265-L302 | train | Initialize the input format. | [
30522,
2797,
11675,
1999,
25090,
16275,
4904,
14192,
4017,
1006,
1007,
1063,
2465,
11066,
2121,
5310,
16044,
26266,
11066,
2121,
1027,
2131,
20330,
16044,
26266,
11066,
2121,
1006,
1007,
1025,
1013,
1013,
6855,
4708,
9563,
1006,
2164,
24646,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/thrift/ThriftCLIServiceClient.java | ThriftCLIServiceClient.getColumns | @Override
public OperationHandle getColumns(SessionHandle sessionHandle,
String catalogName, String schemaName, String tableName, String columnName)
throws HiveSQLException {
try {
TGetColumnsReq req = new TGetColumnsReq();
req.setSessionHandle(sessionHandle.toTSessionHandle());
req.setCatalogName(catalogName);
req.setSchemaName(schemaName);
req.setTableName(tableName);
req.setColumnName(columnName);
TGetColumnsResp resp = cliService.GetColumns(req);
checkStatus(resp.getStatus());
TProtocolVersion protocol = sessionHandle.getProtocolVersion();
return new OperationHandle(resp.getOperationHandle(), protocol);
} catch (HiveSQLException e) {
throw e;
} catch (Exception e) {
throw new HiveSQLException(e);
}
} | java | @Override
public OperationHandle getColumns(SessionHandle sessionHandle,
String catalogName, String schemaName, String tableName, String columnName)
throws HiveSQLException {
try {
TGetColumnsReq req = new TGetColumnsReq();
req.setSessionHandle(sessionHandle.toTSessionHandle());
req.setCatalogName(catalogName);
req.setSchemaName(schemaName);
req.setTableName(tableName);
req.setColumnName(columnName);
TGetColumnsResp resp = cliService.GetColumns(req);
checkStatus(resp.getStatus());
TProtocolVersion protocol = sessionHandle.getProtocolVersion();
return new OperationHandle(resp.getOperationHandle(), protocol);
} catch (HiveSQLException e) {
throw e;
} catch (Exception e) {
throw new HiveSQLException(e);
}
} | [
"@",
"Override",
"public",
"OperationHandle",
"getColumns",
"(",
"SessionHandle",
"sessionHandle",
",",
"String",
"catalogName",
",",
"String",
"schemaName",
",",
"String",
"tableName",
",",
"String",
"columnName",
")",
"throws",
"HiveSQLException",
"{",
"try",
"{",... | /* (non-Javadoc)
@see org.apache.hive.service.cli.ICLIService#getColumns(org.apache.hive.service.cli.SessionHandle) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java#L252-L272 | train | Get columns. | [
30522,
1030,
2058,
15637,
2270,
3169,
11774,
2571,
2131,
25778,
2819,
3619,
1006,
5219,
11774,
2571,
5219,
11774,
2571,
1010,
5164,
12105,
18442,
1010,
5164,
8040,
28433,
18442,
1010,
5164,
2795,
18442,
1010,
5164,
5930,
18442,
1007,
11618,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/old/parser/clause/SelectRestClauseParser.java | SelectRestClauseParser.parse | public final void parse() {
Collection<Keyword> unsupportedRestKeywords = new LinkedList<>();
unsupportedRestKeywords.addAll(Arrays.asList(DefaultKeyword.UNION, DefaultKeyword.INTERSECT, DefaultKeyword.EXCEPT, DefaultKeyword.MINUS));
unsupportedRestKeywords.addAll(Arrays.asList(getUnsupportedKeywordsRest()));
lexerEngine.unsupportedIfEqual(unsupportedRestKeywords.toArray(new Keyword[unsupportedRestKeywords.size()]));
} | java | public final void parse() {
Collection<Keyword> unsupportedRestKeywords = new LinkedList<>();
unsupportedRestKeywords.addAll(Arrays.asList(DefaultKeyword.UNION, DefaultKeyword.INTERSECT, DefaultKeyword.EXCEPT, DefaultKeyword.MINUS));
unsupportedRestKeywords.addAll(Arrays.asList(getUnsupportedKeywordsRest()));
lexerEngine.unsupportedIfEqual(unsupportedRestKeywords.toArray(new Keyword[unsupportedRestKeywords.size()]));
} | [
"public",
"final",
"void",
"parse",
"(",
")",
"{",
"Collection",
"<",
"Keyword",
">",
"unsupportedRestKeywords",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"unsupportedRestKeywords",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"DefaultKeyword",
".",
... | Parse select rest. | [
"Parse",
"select",
"rest",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/old/parser/clause/SelectRestClauseParser.java#L42-L47 | train | Parse the XML document. | [
30522,
2270,
2345,
11675,
11968,
3366,
1006,
1007,
1063,
3074,
1026,
3145,
18351,
1028,
4895,
6342,
9397,
15613,
28533,
14839,
22104,
1027,
2047,
5799,
9863,
1026,
1028,
1006,
1007,
1025,
4895,
6342,
9397,
15613,
28533,
14839,
22104,
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... |
SeleniumHQ/selenium | java/server/src/org/openqa/selenium/remote/server/rest/Responses.java | Responses.success | public static Response success(SessionId sessionId, Object value) {
Response response = new Response();
response.setSessionId(sessionId != null ? sessionId.toString() : null);
response.setValue(value);
response.setStatus(ErrorCodes.SUCCESS);
response.setState(ErrorCodes.SUCCESS_STRING);
return response;
} | java | public static Response success(SessionId sessionId, Object value) {
Response response = new Response();
response.setSessionId(sessionId != null ? sessionId.toString() : null);
response.setValue(value);
response.setStatus(ErrorCodes.SUCCESS);
response.setState(ErrorCodes.SUCCESS_STRING);
return response;
} | [
"public",
"static",
"Response",
"success",
"(",
"SessionId",
"sessionId",
",",
"Object",
"value",
")",
"{",
"Response",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"response",
".",
"setSessionId",
"(",
"sessionId",
"!=",
"null",
"?",
"sessionId",
".",... | Creates a response object for a successful command execution.
@param sessionId ID of the session that executed the command.
@param value the command result value.
@return the new response object. | [
"Creates",
"a",
"response",
"object",
"for",
"a",
"successful",
"command",
"execution",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/selenium/remote/server/rest/Responses.java#L46-L53 | train | Create a response with a success response. | [
30522,
2270,
10763,
3433,
3112,
1006,
5219,
3593,
5219,
3593,
1010,
4874,
3643,
1007,
1063,
3433,
3433,
1027,
2047,
3433,
1006,
1007,
1025,
3433,
1012,
4520,
7971,
3258,
3593,
1006,
5219,
3593,
999,
1027,
19701,
1029,
5219,
3593,
1012,
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... |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/useragent/UserAgentParser.java | UserAgentParser.parseEngine | private static Engine parseEngine(String userAgentString) {
for (Engine engine : Engine.engines) {
if (engine.isMatch(userAgentString)) {
return engine;
}
}
return Engine.Unknown;
} | java | private static Engine parseEngine(String userAgentString) {
for (Engine engine : Engine.engines) {
if (engine.isMatch(userAgentString)) {
return engine;
}
}
return Engine.Unknown;
} | [
"private",
"static",
"Engine",
"parseEngine",
"(",
"String",
"userAgentString",
")",
"{",
"for",
"(",
"Engine",
"engine",
":",
"Engine",
".",
"engines",
")",
"{",
"if",
"(",
"engine",
".",
"isMatch",
"(",
"userAgentString",
")",
")",
"{",
"return",
"engine... | 解析引擎类型
@param userAgentString User-Agent字符串
@return 引擎类型 | [
"解析引擎类型"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/useragent/UserAgentParser.java#L63-L70 | train | Parses the user agent string to get the corresponding Engine object. | [
30522,
2797,
10763,
3194,
11968,
19763,
3070,
3170,
1006,
5164,
5310,
4270,
7666,
18886,
3070,
1007,
1063,
2005,
1006,
3194,
3194,
1024,
3194,
1012,
5209,
1007,
1063,
2065,
1006,
3194,
1012,
2003,
18900,
2818,
1006,
5310,
4270,
7666,
18886,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.