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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
alibaba/canal | parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java | MysqlConnection.loadBinlogChecksum | private void loadBinlogChecksum() {
ResultSetPacket rs = null;
try {
rs = query("select @@global.binlog_checksum");
List<String> columnValues = rs.getFieldValues();
if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0).toUpperCase().equals("CRC32")) {
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
} else {
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
}
} catch (Throwable e) {
logger.error("", e);
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
}
} | java | private void loadBinlogChecksum() {
ResultSetPacket rs = null;
try {
rs = query("select @@global.binlog_checksum");
List<String> columnValues = rs.getFieldValues();
if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0).toUpperCase().equals("CRC32")) {
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
} else {
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
}
} catch (Throwable e) {
logger.error("", e);
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
}
} | [
"private",
"void",
"loadBinlogChecksum",
"(",
")",
"{",
"ResultSetPacket",
"rs",
"=",
"null",
";",
"try",
"{",
"rs",
"=",
"query",
"(",
"\"select @@global.binlog_checksum\"",
")",
";",
"List",
"<",
"String",
">",
"columnValues",
"=",
"rs",
".",
"getFieldValues... | 获取主库checksum信息
<pre>
mariadb区别于mysql会在binlog的第一个事件Rotate_Event里也会采用checksum逻辑,而mysql是在第二个binlog事件之后才感知是否需要处理checksum
导致maraidb只要是开启checksum就会出现binlog文件名解析乱码
fixed issue : https://github.com/alibaba/canal/issues/1081
</pre> | [
"获取主库checksum信息"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java#L519-L533 | train | Load the binlog checksum | [
30522,
2797,
11675,
7170,
8428,
21197,
5403,
10603,
2819,
1006,
1007,
1063,
3463,
3388,
23947,
3388,
12667,
1027,
19701,
1025,
3046,
1063,
12667,
1027,
23032,
1006,
1000,
7276,
1030,
1030,
3795,
1012,
8026,
21197,
1035,
14148,
2819,
1000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-planner/src/main/java/org/apache/flink/table/plan/rules/logical/ExtendedAggregateExtractProjectRule.java | ExtendedAggregateExtractProjectRule.getInputFieldUsed | private ImmutableBitSet.Builder getInputFieldUsed(Aggregate aggregate, RelNode input) {
// 1. group fields are always used
final ImmutableBitSet.Builder inputFieldsUsed =
aggregate.getGroupSet().rebuild();
// 2. agg functions
for (AggregateCall aggCall : aggregate.getAggCallList()) {
for (int i : aggCall.getArgList()) {
inputFieldsUsed.set(i);
}
if (aggCall.filterArg >= 0) {
inputFieldsUsed.set(aggCall.filterArg);
}
}
// 3. window time field if the aggregate is a group window aggregate.
if (aggregate instanceof LogicalWindowAggregate) {
inputFieldsUsed.set(getWindowTimeFieldIndex((LogicalWindowAggregate) aggregate, input));
}
return inputFieldsUsed;
} | java | private ImmutableBitSet.Builder getInputFieldUsed(Aggregate aggregate, RelNode input) {
// 1. group fields are always used
final ImmutableBitSet.Builder inputFieldsUsed =
aggregate.getGroupSet().rebuild();
// 2. agg functions
for (AggregateCall aggCall : aggregate.getAggCallList()) {
for (int i : aggCall.getArgList()) {
inputFieldsUsed.set(i);
}
if (aggCall.filterArg >= 0) {
inputFieldsUsed.set(aggCall.filterArg);
}
}
// 3. window time field if the aggregate is a group window aggregate.
if (aggregate instanceof LogicalWindowAggregate) {
inputFieldsUsed.set(getWindowTimeFieldIndex((LogicalWindowAggregate) aggregate, input));
}
return inputFieldsUsed;
} | [
"private",
"ImmutableBitSet",
".",
"Builder",
"getInputFieldUsed",
"(",
"Aggregate",
"aggregate",
",",
"RelNode",
"input",
")",
"{",
"// 1. group fields are always used",
"final",
"ImmutableBitSet",
".",
"Builder",
"inputFieldsUsed",
"=",
"aggregate",
".",
"getGroupSet",
... | Compute which input fields are used by the aggregate. | [
"Compute",
"which",
"input",
"fields",
"are",
"used",
"by",
"the",
"aggregate",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/plan/rules/logical/ExtendedAggregateExtractProjectRule.java#L124-L142 | train | Gets the input field used by the given aggregate. | [
30522,
2797,
10047,
28120,
3085,
16313,
13462,
1012,
12508,
2131,
2378,
18780,
3790,
13901,
1006,
9572,
9572,
1010,
2128,
19666,
10244,
7953,
1007,
1063,
1013,
1013,
1015,
1012,
2177,
4249,
2024,
2467,
2109,
2345,
10047,
28120,
3085,
16313,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/util/InterpreterUtils.java | InterpreterUtils.deserializeFunction | @SuppressWarnings("unchecked")
public static <X> X deserializeFunction(RuntimeContext context, byte[] serFun) throws FlinkException {
if (!jythonInitialized) {
// This branch is only tested by end-to-end tests
String path = context.getDistributedCache().getFile(PythonConstants.FLINK_PYTHON_DC_ID).getAbsolutePath();
String scriptName = PythonStreamExecutionEnvironment.PythonJobParameters.getScriptName(context.getExecutionConfig().getGlobalJobParameters());
try {
initPythonInterpreter(
new String[]{Paths.get(path, scriptName).toString()},
path,
scriptName);
} catch (Exception e) {
try {
LOG.error("Initialization of jython failed.", e);
throw new FlinkRuntimeException("Initialization of jython failed.", e);
} catch (Exception ie) {
// this may occur if the initial exception relies on jython being initialized properly
LOG.error("Initialization of jython failed. Could not print original stacktrace.", ie);
throw new FlinkRuntimeException("Initialization of jython failed. Could not print original stacktrace.");
}
}
}
try {
return (X) SerializationUtils.deserializeObject(serFun);
} catch (IOException | ClassNotFoundException ex) {
throw new FlinkException("Deserialization of user-function failed.", ex);
}
} | java | @SuppressWarnings("unchecked")
public static <X> X deserializeFunction(RuntimeContext context, byte[] serFun) throws FlinkException {
if (!jythonInitialized) {
// This branch is only tested by end-to-end tests
String path = context.getDistributedCache().getFile(PythonConstants.FLINK_PYTHON_DC_ID).getAbsolutePath();
String scriptName = PythonStreamExecutionEnvironment.PythonJobParameters.getScriptName(context.getExecutionConfig().getGlobalJobParameters());
try {
initPythonInterpreter(
new String[]{Paths.get(path, scriptName).toString()},
path,
scriptName);
} catch (Exception e) {
try {
LOG.error("Initialization of jython failed.", e);
throw new FlinkRuntimeException("Initialization of jython failed.", e);
} catch (Exception ie) {
// this may occur if the initial exception relies on jython being initialized properly
LOG.error("Initialization of jython failed. Could not print original stacktrace.", ie);
throw new FlinkRuntimeException("Initialization of jython failed. Could not print original stacktrace.");
}
}
}
try {
return (X) SerializationUtils.deserializeObject(serFun);
} catch (IOException | ClassNotFoundException ex) {
throw new FlinkException("Deserialization of user-function failed.", ex);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"X",
">",
"X",
"deserializeFunction",
"(",
"RuntimeContext",
"context",
",",
"byte",
"[",
"]",
"serFun",
")",
"throws",
"FlinkException",
"{",
"if",
"(",
"!",
"jythonInitialized",
")"... | Deserialize the given python function. If the functions class definition cannot be found we assume that this is
the first invocation of this method for a given job and load the python script containing the class definition
via jython.
@param context the RuntimeContext of the java function
@param serFun serialized python UDF
@return deserialized python UDF
@throws FlinkException if the deserialization failed | [
"Deserialize",
"the",
"given",
"python",
"function",
".",
"If",
"the",
"functions",
"class",
"definition",
"cannot",
"be",
"found",
"we",
"assume",
"that",
"this",
"is",
"the",
"first",
"invocation",
"of",
"this",
"method",
"for",
"a",
"given",
"job",
"and",... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/util/InterpreterUtils.java#L64-L95 | train | Deserializes a user - defined function. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2270,
10763,
1026,
1060,
1028,
1060,
4078,
11610,
3669,
4371,
11263,
27989,
1006,
2448,
7292,
8663,
18209,
6123,
1010,
24880,
1031,
1033,
14262,
11263,
2078,
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/ClassLoaderUtil.java | ClassLoaderUtil.loadClass | public static Class<?> loadClass(String name, boolean isInitialized) throws UtilException {
return loadClass(name, null, isInitialized);
} | java | public static Class<?> loadClass(String name, boolean isInitialized) throws UtilException {
return loadClass(name, null, isInitialized);
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"loadClass",
"(",
"String",
"name",
",",
"boolean",
"isInitialized",
")",
"throws",
"UtilException",
"{",
"return",
"loadClass",
"(",
"name",
",",
"null",
",",
"isInitialized",
")",
";",
"}"
] | 加载类,通过传入类的字符串,返回其对应的类名,使用默认ClassLoader<br>
扩展{@link Class#forName(String, boolean, ClassLoader)}方法,支持以下几类类名的加载:
<pre>
1、原始类型,例如:int
2、数组类型,例如:int[]、Long[]、String[]
3、内部类,例如:java.lang.Thread.State会被转为java.lang.Thread$State加载
</pre>
@param name 类名
@param isInitialized 是否初始化类(调用static模块内容和初始化static属性)
@return 类名对应的类
@throws UtilException 包装{@link ClassNotFoundException},没有类名对应的类时抛出此异常 | [
"加载类,通过传入类的字符串,返回其对应的类名,使用默认ClassLoader<br",
">",
"扩展",
"{",
"@link",
"Class#forName",
"(",
"String",
"boolean",
"ClassLoader",
")",
"}",
"方法,支持以下几类类名的加载:"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ClassLoaderUtil.java#L125-L127 | train | Load a class from a name. | [
30522,
2270,
10763,
2465,
1026,
1029,
1028,
7170,
26266,
1006,
5164,
2171,
1010,
22017,
20898,
2003,
5498,
20925,
3550,
1007,
11618,
21183,
9463,
2595,
24422,
1063,
2709,
7170,
26266,
1006,
2171,
1010,
19701,
1010,
2003,
5498,
20925,
3550,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/DevtoolsEnablementDeducer.java | DevtoolsEnablementDeducer.shouldEnable | public static boolean shouldEnable(Thread thread) {
for (StackTraceElement element : thread.getStackTrace()) {
if (isSkippedStackElement(element)) {
return false;
}
}
return true;
} | java | public static boolean shouldEnable(Thread thread) {
for (StackTraceElement element : thread.getStackTrace()) {
if (isSkippedStackElement(element)) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"shouldEnable",
"(",
"Thread",
"thread",
")",
"{",
"for",
"(",
"StackTraceElement",
"element",
":",
"thread",
".",
"getStackTrace",
"(",
")",
")",
"{",
"if",
"(",
"isSkippedStackElement",
"(",
"element",
")",
")",
"{",
"return"... | Checks if a specific {@link StackTraceElement} in the current thread's stacktrace
should cause devtools to be disabled.
@param thread the current thread
@return {@code true} if devtools should be enabled skipped | [
"Checks",
"if",
"a",
"specific",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/DevtoolsEnablementDeducer.java#L50-L57 | train | Returns true if the given thread should be enabled. | [
30522,
2270,
10763,
22017,
20898,
2323,
8189,
3468,
1006,
11689,
11689,
1007,
1063,
2005,
1006,
9991,
6494,
3401,
12260,
3672,
5783,
1024,
11689,
1012,
4152,
2696,
3600,
6494,
3401,
1006,
1007,
1007,
1063,
2065,
1006,
26354,
3211,
11469,
91... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Timer.java | Timer.time | public <T> T time(Callable<T> event) throws Exception {
final long startTime = clock.getTick();
try {
return event.call();
} finally {
update(clock.getTick() - startTime);
}
} | java | public <T> T time(Callable<T> event) throws Exception {
final long startTime = clock.getTick();
try {
return event.call();
} finally {
update(clock.getTick() - startTime);
}
} | [
"public",
"<",
"T",
">",
"T",
"time",
"(",
"Callable",
"<",
"T",
">",
"event",
")",
"throws",
"Exception",
"{",
"final",
"long",
"startTime",
"=",
"clock",
".",
"getTick",
"(",
")",
";",
"try",
"{",
"return",
"event",
".",
"call",
"(",
")",
";",
... | Times and records the duration of an event.
@param event a {@link Callable} whose {@link Callable#call()} method implements a process
whose duration should be timed
@param <T> the type of the value returned by {@code event}
@return the value returned by {@code event}
@throws Exception if {@code event} throws an {@link Exception} | [
"Times",
"and",
"records",
"the",
"duration",
"of",
"an",
"event",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/Timer.java#L119-L126 | train | Time a Callable. | [
30522,
2270,
1026,
1056,
1028,
1056,
2051,
1006,
2655,
3085,
1026,
1056,
1028,
2724,
1007,
11618,
6453,
1063,
2345,
2146,
2707,
7292,
1027,
5119,
1012,
2131,
26348,
1006,
1007,
1025,
3046,
1063,
2709,
2724,
1012,
2655,
1006,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java | DateUtil.yearAndQuarter | public static LinkedHashSet<String> yearAndQuarter(long startDate, long endDate) {
LinkedHashSet<String> quarters = new LinkedHashSet<>();
final Calendar cal = calendar(startDate);
while (startDate <= endDate) {
// 如果开始时间超出结束时间,让结束时间为开始时间,处理完后结束循环
quarters.add(yearAndQuarter(cal));
cal.add(Calendar.MONTH, 3);
startDate = cal.getTimeInMillis();
}
return quarters;
} | java | public static LinkedHashSet<String> yearAndQuarter(long startDate, long endDate) {
LinkedHashSet<String> quarters = new LinkedHashSet<>();
final Calendar cal = calendar(startDate);
while (startDate <= endDate) {
// 如果开始时间超出结束时间,让结束时间为开始时间,处理完后结束循环
quarters.add(yearAndQuarter(cal));
cal.add(Calendar.MONTH, 3);
startDate = cal.getTimeInMillis();
}
return quarters;
} | [
"public",
"static",
"LinkedHashSet",
"<",
"String",
">",
"yearAndQuarter",
"(",
"long",
"startDate",
",",
"long",
"endDate",
")",
"{",
"LinkedHashSet",
"<",
"String",
">",
"quarters",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
")",
";",
"final",
"Calendar",
"ca... | 获得指定日期区间内的年份和季节<br>
@param startDate 起始日期(包含)
@param endDate 结束日期(包含)
@return 季度列表 ,元素类似于 20132
@since 4.1.15 | [
"获得指定日期区间内的年份和季节<br",
">"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L443-L455 | train | Gets the calendar year and quarter parts from the start date and end date. | [
30522,
2270,
10763,
5799,
14949,
7898,
3388,
1026,
5164,
1028,
2095,
5685,
16211,
19418,
1006,
2146,
2707,
13701,
1010,
2146,
2203,
13701,
1007,
1063,
5799,
14949,
7898,
3388,
1026,
5164,
1028,
7728,
1027,
2047,
5799,
14949,
7898,
3388,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/Kafka08Fetcher.java | Kafka08Fetcher.createAndStartSimpleConsumerThread | private SimpleConsumerThread<T> createAndStartSimpleConsumerThread(
List<KafkaTopicPartitionState<TopicAndPartition>> seedPartitions,
Node leader,
ExceptionProxy errorHandler) throws IOException, ClassNotFoundException {
// each thread needs its own copy of the deserializer, because the deserializer is
// not necessarily thread safe
final KafkaDeserializationSchema<T> clonedDeserializer =
InstantiationUtil.clone(deserializer, runtimeContext.getUserCodeClassLoader());
// seed thread with list of fetch partitions (otherwise it would shut down immediately again
SimpleConsumerThread<T> brokerThread = new SimpleConsumerThread<>(
this, errorHandler, kafkaConfig, leader, seedPartitions, unassignedPartitionsQueue,
clonedDeserializer, invalidOffsetBehavior);
brokerThread.setName(String.format("SimpleConsumer - %s - broker-%s (%s:%d)",
runtimeContext.getTaskName(), leader.id(), leader.host(), leader.port()));
brokerThread.setDaemon(true);
brokerThread.start();
LOG.info("Starting thread {}", brokerThread.getName());
return brokerThread;
} | java | private SimpleConsumerThread<T> createAndStartSimpleConsumerThread(
List<KafkaTopicPartitionState<TopicAndPartition>> seedPartitions,
Node leader,
ExceptionProxy errorHandler) throws IOException, ClassNotFoundException {
// each thread needs its own copy of the deserializer, because the deserializer is
// not necessarily thread safe
final KafkaDeserializationSchema<T> clonedDeserializer =
InstantiationUtil.clone(deserializer, runtimeContext.getUserCodeClassLoader());
// seed thread with list of fetch partitions (otherwise it would shut down immediately again
SimpleConsumerThread<T> brokerThread = new SimpleConsumerThread<>(
this, errorHandler, kafkaConfig, leader, seedPartitions, unassignedPartitionsQueue,
clonedDeserializer, invalidOffsetBehavior);
brokerThread.setName(String.format("SimpleConsumer - %s - broker-%s (%s:%d)",
runtimeContext.getTaskName(), leader.id(), leader.host(), leader.port()));
brokerThread.setDaemon(true);
brokerThread.start();
LOG.info("Starting thread {}", brokerThread.getName());
return brokerThread;
} | [
"private",
"SimpleConsumerThread",
"<",
"T",
">",
"createAndStartSimpleConsumerThread",
"(",
"List",
"<",
"KafkaTopicPartitionState",
"<",
"TopicAndPartition",
">",
">",
"seedPartitions",
",",
"Node",
"leader",
",",
"ExceptionProxy",
"errorHandler",
")",
"throws",
"IOEx... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/Kafka08Fetcher.java#L384-L405 | train | Creates and starts a SimpleConsumerThread. | [
30522,
2797,
3722,
8663,
23545,
15265,
16416,
2094,
1026,
1056,
1028,
3443,
29560,
7559,
3215,
5714,
10814,
8663,
23545,
15265,
16416,
2094,
1006,
2862,
1026,
10556,
24316,
10610,
24330,
19362,
3775,
9285,
12259,
1026,
8476,
5685,
19362,
3775... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/convert/impl/ArrayConverter.java | ArrayConverter.convertObjectToArray | private Object convertObjectToArray(Object value) {
if (value instanceof CharSequence) {
if (targetComponentType == char.class || targetComponentType == Character.class) {
return convertArrayToArray(value.toString().toCharArray());
}
// 单纯字符串情况下按照逗号分隔后劈开
final String[] strings = StrUtil.split(value.toString(), StrUtil.COMMA);
return convertArrayToArray(strings);
}
final ConverterRegistry converter = ConverterRegistry.getInstance();
Object result = null;
if (value instanceof List) {
// List转数组
final List<?> list = (List<?>) value;
result = Array.newInstance(targetComponentType, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(result, i, converter.convert(targetComponentType, list.get(i)));
}
} else if (value instanceof Collection) {
// 集合转数组
final Collection<?> collection = (Collection<?>) value;
result = Array.newInstance(targetComponentType, collection.size());
int i = 0;
for (Object element : collection) {
Array.set(result, i, converter.convert(targetComponentType, element));
i++;
}
} else if (value instanceof Iterable) {
// 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组
final List<?> list = IterUtil.toList((Iterable<?>) value);
result = Array.newInstance(targetComponentType, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(result, i, converter.convert(targetComponentType, list.get(i)));
}
} else if (value instanceof Iterator) {
// 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组
final List<?> list = IterUtil.toList((Iterator<?>) value);
result = Array.newInstance(targetComponentType, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(result, i, converter.convert(targetComponentType, list.get(i)));
}
} else {
// everything else:
result = convertToSingleElementArray(value);
}
return result;
} | java | private Object convertObjectToArray(Object value) {
if (value instanceof CharSequence) {
if (targetComponentType == char.class || targetComponentType == Character.class) {
return convertArrayToArray(value.toString().toCharArray());
}
// 单纯字符串情况下按照逗号分隔后劈开
final String[] strings = StrUtil.split(value.toString(), StrUtil.COMMA);
return convertArrayToArray(strings);
}
final ConverterRegistry converter = ConverterRegistry.getInstance();
Object result = null;
if (value instanceof List) {
// List转数组
final List<?> list = (List<?>) value;
result = Array.newInstance(targetComponentType, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(result, i, converter.convert(targetComponentType, list.get(i)));
}
} else if (value instanceof Collection) {
// 集合转数组
final Collection<?> collection = (Collection<?>) value;
result = Array.newInstance(targetComponentType, collection.size());
int i = 0;
for (Object element : collection) {
Array.set(result, i, converter.convert(targetComponentType, element));
i++;
}
} else if (value instanceof Iterable) {
// 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组
final List<?> list = IterUtil.toList((Iterable<?>) value);
result = Array.newInstance(targetComponentType, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(result, i, converter.convert(targetComponentType, list.get(i)));
}
} else if (value instanceof Iterator) {
// 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组
final List<?> list = IterUtil.toList((Iterator<?>) value);
result = Array.newInstance(targetComponentType, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(result, i, converter.convert(targetComponentType, list.get(i)));
}
} else {
// everything else:
result = convertToSingleElementArray(value);
}
return result;
} | [
"private",
"Object",
"convertObjectToArray",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"CharSequence",
")",
"{",
"if",
"(",
"targetComponentType",
"==",
"char",
".",
"class",
"||",
"targetComponentType",
"==",
"Character",
".",
"class",... | 非数组对数组转换
@param value 被转换值
@return 转换后的数组 | [
"非数组对数组转换"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/convert/impl/ArrayConverter.java#L87-L137 | train | Convert object to array. | [
30522,
2797,
4874,
10463,
16429,
20614,
3406,
2906,
9447,
1006,
4874,
3643,
1007,
1063,
2065,
1006,
3643,
6013,
11253,
25869,
3366,
4226,
5897,
1007,
1063,
2065,
1006,
4539,
9006,
29513,
3372,
13874,
1027,
1027,
25869,
1012,
2465,
1064,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/OneForOneBlockFetcher.java | OneForOneBlockFetcher.start | public void start() {
if (blockIds.length == 0) {
throw new IllegalArgumentException("Zero-sized blockIds array");
}
client.sendRpc(openMessage.toByteBuffer(), new RpcResponseCallback() {
@Override
public void onSuccess(ByteBuffer response) {
try {
streamHandle = (StreamHandle) BlockTransferMessage.Decoder.fromByteBuffer(response);
logger.trace("Successfully opened blocks {}, preparing to fetch chunks.", streamHandle);
// Immediately request all chunks -- we expect that the total size of the request is
// reasonable due to higher level chunking in [[ShuffleBlockFetcherIterator]].
for (int i = 0; i < streamHandle.numChunks; i++) {
if (downloadFileManager != null) {
client.stream(OneForOneStreamManager.genStreamChunkId(streamHandle.streamId, i),
new DownloadCallback(i));
} else {
client.fetchChunk(streamHandle.streamId, i, chunkCallback);
}
}
} catch (Exception e) {
logger.error("Failed while starting block fetches after success", e);
failRemainingBlocks(blockIds, e);
}
}
@Override
public void onFailure(Throwable e) {
logger.error("Failed while starting block fetches", e);
failRemainingBlocks(blockIds, e);
}
});
} | java | public void start() {
if (blockIds.length == 0) {
throw new IllegalArgumentException("Zero-sized blockIds array");
}
client.sendRpc(openMessage.toByteBuffer(), new RpcResponseCallback() {
@Override
public void onSuccess(ByteBuffer response) {
try {
streamHandle = (StreamHandle) BlockTransferMessage.Decoder.fromByteBuffer(response);
logger.trace("Successfully opened blocks {}, preparing to fetch chunks.", streamHandle);
// Immediately request all chunks -- we expect that the total size of the request is
// reasonable due to higher level chunking in [[ShuffleBlockFetcherIterator]].
for (int i = 0; i < streamHandle.numChunks; i++) {
if (downloadFileManager != null) {
client.stream(OneForOneStreamManager.genStreamChunkId(streamHandle.streamId, i),
new DownloadCallback(i));
} else {
client.fetchChunk(streamHandle.streamId, i, chunkCallback);
}
}
} catch (Exception e) {
logger.error("Failed while starting block fetches after success", e);
failRemainingBlocks(blockIds, e);
}
}
@Override
public void onFailure(Throwable e) {
logger.error("Failed while starting block fetches", e);
failRemainingBlocks(blockIds, e);
}
});
} | [
"public",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"blockIds",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Zero-sized blockIds array\"",
")",
";",
"}",
"client",
".",
"sendRpc",
"(",
"openMessage",
".",
"toByteBu... | Begins the fetching process, calling the listener with every block fetched.
The given message will be serialized with the Java serializer, and the RPC must return a
{@link StreamHandle}. We will send all fetch requests immediately, without throttling. | [
"Begins",
"the",
"fetching",
"process",
"calling",
"the",
"listener",
"with",
"every",
"block",
"fetched",
".",
"The",
"given",
"message",
"will",
"be",
"serialized",
"with",
"the",
"Java",
"serializer",
"and",
"the",
"RPC",
"must",
"return",
"a",
"{"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/OneForOneBlockFetcher.java#L108-L142 | train | Starts the fetch process. | [
30522,
2270,
11675,
2707,
1006,
1007,
1063,
2065,
30524,
3351,
1012,
11291,
2618,
8569,
12494,
1006,
1007,
1010,
2047,
1054,
15042,
6072,
26029,
3366,
9289,
20850,
8684,
1006,
1007,
1063,
1030,
2058,
15637,
2270,
11675,
2006,
6342,
9468,
79... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/DynamicRegistrationBean.java | DynamicRegistrationBean.setInitParameters | public void setInitParameters(Map<String, String> initParameters) {
Assert.notNull(initParameters, "InitParameters must not be null");
this.initParameters = new LinkedHashMap<>(initParameters);
} | java | public void setInitParameters(Map<String, String> initParameters) {
Assert.notNull(initParameters, "InitParameters must not be null");
this.initParameters = new LinkedHashMap<>(initParameters);
} | [
"public",
"void",
"setInitParameters",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"initParameters",
")",
"{",
"Assert",
".",
"notNull",
"(",
"initParameters",
",",
"\"InitParameters must not be null\"",
")",
";",
"this",
".",
"initParameters",
"=",
"new",
"L... | Set init-parameters for this registration. Calling this method will replace any
existing init-parameters.
@param initParameters the init parameters
@see #getInitParameters
@see #addInitParameter | [
"Set",
"init",
"-",
"parameters",
"for",
"this",
"registration",
".",
"Calling",
"this",
"method",
"will",
"replace",
"any",
"existing",
"init",
"-",
"parameters",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/DynamicRegistrationBean.java#L84-L87 | train | Sets the init parameters. | [
30522,
2270,
11675,
2275,
5498,
25856,
5400,
22828,
2015,
1006,
4949,
1026,
5164,
1010,
5164,
1028,
1999,
4183,
28689,
22828,
2015,
1007,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
1999,
4183,
28689,
22828,
2015,
1010,
1000,
1999,
4183,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/BufferUtil.java | BufferUtil.create | public static ByteBuffer create(CharSequence data, Charset charset) {
return create(StrUtil.bytes(data, charset));
} | java | public static ByteBuffer create(CharSequence data, Charset charset) {
return create(StrUtil.bytes(data, charset));
} | [
"public",
"static",
"ByteBuffer",
"create",
"(",
"CharSequence",
"data",
",",
"Charset",
"charset",
")",
"{",
"return",
"create",
"(",
"StrUtil",
".",
"bytes",
"(",
"data",
",",
"charset",
")",
")",
";",
"}"
] | 从字符串创建新Buffer
@param data 数据
@param charset 编码
@return {@link ByteBuffer}
@since 4.5.0 | [
"从字符串创建新Buffer"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/BufferUtil.java#L237-L239 | train | Creates a ByteBuffer from a char sequence. | [
30522,
2270,
10763,
24880,
8569,
12494,
3443,
1006,
25869,
3366,
4226,
5897,
2951,
1010,
25869,
13462,
25869,
13462,
1007,
1063,
2709,
3443,
1006,
2358,
22134,
4014,
1012,
27507,
1006,
2951,
1010,
25869,
13462,
1007,
1007,
1025,
1065,
102,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/operators/SingleInputOperator.java | SingleInputOperator.accept | @Override
public void accept(Visitor<Operator<?>> visitor) {
if (visitor.preVisit(this)) {
this.input.accept(visitor);
for (Operator<?> c : this.broadcastInputs.values()) {
c.accept(visitor);
}
visitor.postVisit(this);
}
} | java | @Override
public void accept(Visitor<Operator<?>> visitor) {
if (visitor.preVisit(this)) {
this.input.accept(visitor);
for (Operator<?> c : this.broadcastInputs.values()) {
c.accept(visitor);
}
visitor.postVisit(this);
}
} | [
"@",
"Override",
"public",
"void",
"accept",
"(",
"Visitor",
"<",
"Operator",
"<",
"?",
">",
">",
"visitor",
")",
"{",
"if",
"(",
"visitor",
".",
"preVisit",
"(",
"this",
")",
")",
"{",
"this",
".",
"input",
".",
"accept",
"(",
"visitor",
")",
";",... | Accepts the visitor and applies it this instance. The visitors pre-visit method is called and, if returning
<tt>true</tt>, the visitor is recursively applied on the single input. After the recursion returned,
the post-visit method is called.
@param visitor The visitor.
@see org.apache.flink.util.Visitable#accept(org.apache.flink.util.Visitor) | [
"Accepts",
"the",
"visitor",
"and",
"applies",
"it",
"this",
"instance",
".",
"The",
"visitors",
"pre",
"-",
"visit",
"method",
"is",
"called",
"and",
"if",
"returning",
"<tt",
">",
"true<",
"/",
"tt",
">",
"the",
"visitor",
"is",
"recursively",
"applied",... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/operators/SingleInputOperator.java#L196-L205 | train | Visit this operator. | [
30522,
1030,
2058,
15637,
2270,
11675,
5138,
1006,
10367,
1026,
6872,
1026,
1029,
1028,
1028,
10367,
1007,
1063,
2065,
1006,
10367,
1012,
3653,
11365,
4183,
1006,
2023,
1007,
1007,
1063,
2023,
1012,
7953,
1012,
5138,
1006,
10367,
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/incubator-shardingsphere | sharding-jdbc/sharding-jdbc-orchestration/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/api/yaml/YamlOrchestrationMasterSlaveDataSourceFactory.java | YamlOrchestrationMasterSlaveDataSourceFactory.createDataSource | public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final File yamlFile) throws SQLException, IOException {
YamlOrchestrationMasterSlaveRuleConfiguration config = unmarshal(yamlFile);
return createDataSource(dataSourceMap, config.getMasterSlaveRule(), config.getProps(), config.getOrchestration());
} | java | public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final File yamlFile) throws SQLException, IOException {
YamlOrchestrationMasterSlaveRuleConfiguration config = unmarshal(yamlFile);
return createDataSource(dataSourceMap, config.getMasterSlaveRule(), config.getProps(), config.getOrchestration());
} | [
"public",
"static",
"DataSource",
"createDataSource",
"(",
"final",
"Map",
"<",
"String",
",",
"DataSource",
">",
"dataSourceMap",
",",
"final",
"File",
"yamlFile",
")",
"throws",
"SQLException",
",",
"IOException",
"{",
"YamlOrchestrationMasterSlaveRuleConfiguration",
... | Create master-slave data source.
@param dataSourceMap data source map
@param yamlFile YAML file for master-slave rule configuration without data sources
@return master-slave data source
@throws SQLException SQL exception
@throws IOException IO exception | [
"Create",
"master",
"-",
"slave",
"data",
"source",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/api/yaml/YamlOrchestrationMasterSlaveDataSourceFactory.java#L74-L77 | train | Create a DataSource from a yaml file. | [
30522,
2270,
10763,
2951,
6499,
3126,
3401,
2580,
6790,
6499,
3126,
3401,
1006,
2345,
4949,
1026,
5164,
1010,
2951,
6499,
3126,
3401,
1028,
2951,
6499,
3126,
3401,
2863,
2361,
1010,
2345,
5371,
8038,
19968,
8873,
2571,
1007,
11618,
29296,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractStreamOperator.java | AbstractStreamOperator.setup | @Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output) {
final Environment environment = containingTask.getEnvironment();
this.container = containingTask;
this.config = config;
try {
OperatorMetricGroup operatorMetricGroup = environment.getMetricGroup().getOrAddOperator(config.getOperatorID(), config.getOperatorName());
this.output = new CountingOutput(output, operatorMetricGroup.getIOMetricGroup().getNumRecordsOutCounter());
if (config.isChainStart()) {
operatorMetricGroup.getIOMetricGroup().reuseInputMetricsForTask();
}
if (config.isChainEnd()) {
operatorMetricGroup.getIOMetricGroup().reuseOutputMetricsForTask();
}
this.metrics = operatorMetricGroup;
} catch (Exception e) {
LOG.warn("An error occurred while instantiating task metrics.", e);
this.metrics = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
this.output = output;
}
try {
Configuration taskManagerConfig = environment.getTaskManagerInfo().getConfiguration();
int historySize = taskManagerConfig.getInteger(MetricOptions.LATENCY_HISTORY_SIZE);
if (historySize <= 0) {
LOG.warn("{} has been set to a value equal or below 0: {}. Using default.", MetricOptions.LATENCY_HISTORY_SIZE, historySize);
historySize = MetricOptions.LATENCY_HISTORY_SIZE.defaultValue();
}
final String configuredGranularity = taskManagerConfig.getString(MetricOptions.LATENCY_SOURCE_GRANULARITY);
LatencyStats.Granularity granularity;
try {
granularity = LatencyStats.Granularity.valueOf(configuredGranularity.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException iae) {
granularity = LatencyStats.Granularity.OPERATOR;
LOG.warn(
"Configured value {} option for {} is invalid. Defaulting to {}.",
configuredGranularity,
MetricOptions.LATENCY_SOURCE_GRANULARITY.key(),
granularity);
}
TaskManagerJobMetricGroup jobMetricGroup = this.metrics.parent().parent();
this.latencyStats = new LatencyStats(jobMetricGroup.addGroup("latency"),
historySize,
container.getIndexInSubtaskGroup(),
getOperatorID(),
granularity);
} catch (Exception e) {
LOG.warn("An error occurred while instantiating latency metrics.", e);
this.latencyStats = new LatencyStats(
UnregisteredMetricGroups.createUnregisteredTaskManagerJobMetricGroup().addGroup("latency"),
1,
0,
new OperatorID(),
LatencyStats.Granularity.SINGLE);
}
this.runtimeContext = new StreamingRuntimeContext(this, environment, container.getAccumulatorMap());
stateKeySelector1 = config.getStatePartitioner(0, getUserCodeClassloader());
stateKeySelector2 = config.getStatePartitioner(1, getUserCodeClassloader());
} | java | @Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output) {
final Environment environment = containingTask.getEnvironment();
this.container = containingTask;
this.config = config;
try {
OperatorMetricGroup operatorMetricGroup = environment.getMetricGroup().getOrAddOperator(config.getOperatorID(), config.getOperatorName());
this.output = new CountingOutput(output, operatorMetricGroup.getIOMetricGroup().getNumRecordsOutCounter());
if (config.isChainStart()) {
operatorMetricGroup.getIOMetricGroup().reuseInputMetricsForTask();
}
if (config.isChainEnd()) {
operatorMetricGroup.getIOMetricGroup().reuseOutputMetricsForTask();
}
this.metrics = operatorMetricGroup;
} catch (Exception e) {
LOG.warn("An error occurred while instantiating task metrics.", e);
this.metrics = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
this.output = output;
}
try {
Configuration taskManagerConfig = environment.getTaskManagerInfo().getConfiguration();
int historySize = taskManagerConfig.getInteger(MetricOptions.LATENCY_HISTORY_SIZE);
if (historySize <= 0) {
LOG.warn("{} has been set to a value equal or below 0: {}. Using default.", MetricOptions.LATENCY_HISTORY_SIZE, historySize);
historySize = MetricOptions.LATENCY_HISTORY_SIZE.defaultValue();
}
final String configuredGranularity = taskManagerConfig.getString(MetricOptions.LATENCY_SOURCE_GRANULARITY);
LatencyStats.Granularity granularity;
try {
granularity = LatencyStats.Granularity.valueOf(configuredGranularity.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException iae) {
granularity = LatencyStats.Granularity.OPERATOR;
LOG.warn(
"Configured value {} option for {} is invalid. Defaulting to {}.",
configuredGranularity,
MetricOptions.LATENCY_SOURCE_GRANULARITY.key(),
granularity);
}
TaskManagerJobMetricGroup jobMetricGroup = this.metrics.parent().parent();
this.latencyStats = new LatencyStats(jobMetricGroup.addGroup("latency"),
historySize,
container.getIndexInSubtaskGroup(),
getOperatorID(),
granularity);
} catch (Exception e) {
LOG.warn("An error occurred while instantiating latency metrics.", e);
this.latencyStats = new LatencyStats(
UnregisteredMetricGroups.createUnregisteredTaskManagerJobMetricGroup().addGroup("latency"),
1,
0,
new OperatorID(),
LatencyStats.Granularity.SINGLE);
}
this.runtimeContext = new StreamingRuntimeContext(this, environment, container.getAccumulatorMap());
stateKeySelector1 = config.getStatePartitioner(0, getUserCodeClassloader());
stateKeySelector2 = config.getStatePartitioner(1, getUserCodeClassloader());
} | [
"@",
"Override",
"public",
"void",
"setup",
"(",
"StreamTask",
"<",
"?",
",",
"?",
">",
"containingTask",
",",
"StreamConfig",
"config",
",",
"Output",
"<",
"StreamRecord",
"<",
"OUT",
">",
">",
"output",
")",
"{",
"final",
"Environment",
"environment",
"=... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractStreamOperator.java#L169-L230 | train | Setup the task. | [
30522,
1030,
2058,
15637,
2270,
11675,
16437,
1006,
5460,
10230,
2243,
1026,
1029,
1010,
1029,
1028,
4820,
10230,
2243,
1010,
5460,
8663,
8873,
2290,
9530,
8873,
2290,
1010,
6434,
1026,
5460,
2890,
27108,
2094,
1026,
2041,
1028,
1028,
6434,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-proxy/sharding-proxy-transport/sharding-proxy-transport-postgresql/src/main/java/org/apache/shardingsphere/shardingproxy/transport/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java | PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue | public static PostgreSQLBinaryProtocolValue getBinaryProtocolValue(final PostgreSQLColumnType columnType) {
Preconditions.checkArgument(BINARY_PROTOCOL_VALUES.containsKey(columnType), "Cannot find PostgreSQL type '%s' in column type when process binary protocol value", columnType);
return BINARY_PROTOCOL_VALUES.get(columnType);
} | java | public static PostgreSQLBinaryProtocolValue getBinaryProtocolValue(final PostgreSQLColumnType columnType) {
Preconditions.checkArgument(BINARY_PROTOCOL_VALUES.containsKey(columnType), "Cannot find PostgreSQL type '%s' in column type when process binary protocol value", columnType);
return BINARY_PROTOCOL_VALUES.get(columnType);
} | [
"public",
"static",
"PostgreSQLBinaryProtocolValue",
"getBinaryProtocolValue",
"(",
"final",
"PostgreSQLColumnType",
"columnType",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"BINARY_PROTOCOL_VALUES",
".",
"containsKey",
"(",
"columnType",
")",
",",
"\"Cannot find... | Get binary protocol value.
@param columnType column type
@return binary protocol value | [
"Get",
"binary",
"protocol",
"value",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-proxy/sharding-proxy-transport/sharding-proxy-transport-postgresql/src/main/java/org/apache/shardingsphere/shardingproxy/transport/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java#L95-L98 | train | Gets binary protocol value. | [
30522,
2270,
10763,
2695,
17603,
2015,
4160,
20850,
3981,
2854,
21572,
3406,
25778,
10175,
5657,
2131,
21114,
2854,
21572,
3406,
25778,
10175,
5657,
1006,
2345,
2695,
17603,
2015,
4160,
22499,
12942,
29405,
5051,
5930,
13874,
1007,
1063,
3653... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/IOUtils.java | IOUtils.copyBytes | public static void copyBytes(final InputStream in, final OutputStream out, final int buffSize, final boolean close)
throws IOException {
@SuppressWarnings("resource")
final PrintStream ps = out instanceof PrintStream ? (PrintStream) out : null;
final byte[] buf = new byte[buffSize];
try {
int bytesRead = in.read(buf);
while (bytesRead >= 0) {
out.write(buf, 0, bytesRead);
if ((ps != null) && ps.checkError()) {
throw new IOException("Unable to write to output stream.");
}
bytesRead = in.read(buf);
}
} finally {
if (close) {
out.close();
in.close();
}
}
} | java | public static void copyBytes(final InputStream in, final OutputStream out, final int buffSize, final boolean close)
throws IOException {
@SuppressWarnings("resource")
final PrintStream ps = out instanceof PrintStream ? (PrintStream) out : null;
final byte[] buf = new byte[buffSize];
try {
int bytesRead = in.read(buf);
while (bytesRead >= 0) {
out.write(buf, 0, bytesRead);
if ((ps != null) && ps.checkError()) {
throw new IOException("Unable to write to output stream.");
}
bytesRead = in.read(buf);
}
} finally {
if (close) {
out.close();
in.close();
}
}
} | [
"public",
"static",
"void",
"copyBytes",
"(",
"final",
"InputStream",
"in",
",",
"final",
"OutputStream",
"out",
",",
"final",
"int",
"buffSize",
",",
"final",
"boolean",
"close",
")",
"throws",
"IOException",
"{",
"@",
"SuppressWarnings",
"(",
"\"resource\"",
... | Copies from one stream to another.
@param in
InputStream to read from
@param out
OutputStream to write to
@param buffSize
the size of the buffer
@param close
whether or not close the InputStream and OutputStream at the end. The streams are closed in the finally
clause.
@throws IOException
thrown if an error occurred while writing to the output stream | [
"Copies",
"from",
"one",
"stream",
"to",
"another",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/IOUtils.java#L56-L77 | train | Copy bytes from the input stream to the output stream. | [
30522,
2270,
10763,
11675,
6100,
3762,
4570,
1006,
2345,
20407,
25379,
1999,
1010,
2345,
27852,
25379,
2041,
1010,
2345,
20014,
23176,
5332,
4371,
1010,
2345,
22017,
20898,
2485,
1007,
11618,
22834,
10288,
24422,
1063,
1030,
16081,
9028,
5582... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/mail/MailUtil.java | MailUtil.send | public static void send(String to, String subject, String content, boolean isHtml, File... files) {
send(splitAddress(to), subject, content, isHtml, files);
} | java | public static void send(String to, String subject, String content, boolean isHtml, File... files) {
send(splitAddress(to), subject, content, isHtml, files);
} | [
"public",
"static",
"void",
"send",
"(",
"String",
"to",
",",
"String",
"subject",
",",
"String",
"content",
",",
"boolean",
"isHtml",
",",
"File",
"...",
"files",
")",
"{",
"send",
"(",
"splitAddress",
"(",
"to",
")",
",",
"subject",
",",
"content",
"... | 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
@param to 收件人
@param subject 标题
@param content 正文
@param isHtml 是否为HTML
@param files 附件列表 | [
"使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br",
">",
"多个收件人可以使用逗号“",
"”分隔,也可以通过分号“",
";",
"”分隔"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/mail/MailUtil.java#L56-L58 | train | Send a message to a list of users. | [
30522,
2270,
10763,
11675,
4604,
1006,
5164,
2000,
1010,
5164,
3395,
1010,
5164,
4180,
1010,
22017,
20898,
2003,
11039,
19968,
1010,
5371,
1012,
1012,
1012,
6764,
1007,
1063,
4604,
1006,
3975,
4215,
16200,
4757,
1006,
2000,
1007,
1010,
3395... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.substituteVars | private String substituteVars(String expr) {
if (expr == null) {
return null;
}
String eval = expr;
for (int s = 0; s < MAX_SUBST; s++) {
final int[] varBounds = findSubVariable(eval);
if (varBounds[SUB_START_IDX] == -1) {
return eval;
}
final String var = eval.substring(varBounds[SUB_START_IDX],
varBounds[SUB_END_IDX]);
String val = null;
try {
val = System.getProperty(var);
} catch(SecurityException se) {
LOG.warn("Unexpected SecurityException in Configuration", se);
}
if (val == null) {
val = getRaw(var);
}
if (val == null) {
return eval; // return literal ${var}: var is unbound
}
final int dollar = varBounds[SUB_START_IDX] - "${".length();
final int afterRightBrace = varBounds[SUB_END_IDX] + "}".length();
// substitute
eval = eval.substring(0, dollar)
+ val
+ eval.substring(afterRightBrace);
}
throw new IllegalStateException("Variable substitution depth too large: "
+ MAX_SUBST + " " + expr);
} | java | private String substituteVars(String expr) {
if (expr == null) {
return null;
}
String eval = expr;
for (int s = 0; s < MAX_SUBST; s++) {
final int[] varBounds = findSubVariable(eval);
if (varBounds[SUB_START_IDX] == -1) {
return eval;
}
final String var = eval.substring(varBounds[SUB_START_IDX],
varBounds[SUB_END_IDX]);
String val = null;
try {
val = System.getProperty(var);
} catch(SecurityException se) {
LOG.warn("Unexpected SecurityException in Configuration", se);
}
if (val == null) {
val = getRaw(var);
}
if (val == null) {
return eval; // return literal ${var}: var is unbound
}
final int dollar = varBounds[SUB_START_IDX] - "${".length();
final int afterRightBrace = varBounds[SUB_END_IDX] + "}".length();
// substitute
eval = eval.substring(0, dollar)
+ val
+ eval.substring(afterRightBrace);
}
throw new IllegalStateException("Variable substitution depth too large: "
+ MAX_SUBST + " " + expr);
} | [
"private",
"String",
"substituteVars",
"(",
"String",
"expr",
")",
"{",
"if",
"(",
"expr",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"eval",
"=",
"expr",
";",
"for",
"(",
"int",
"s",
"=",
"0",
";",
"s",
"<",
"MAX_SUBST",
";",
... | Attempts to repeatedly expand the value {@code expr} by replacing the
left-most substring of the form "${var}" in the following precedence order
<ol>
<li>by the value of the Java system property "var" if defined</li>
<li>by the value of the configuration key "var" if defined</li>
</ol>
If var is unbounded the current state of expansion "prefix${var}suffix" is
returned.
@param expr the literal value of a config key
@return null if expr is null, otherwise the value resulting from expanding
expr using the algorithm above.
@throws IllegalArgumentException when more than
{@link Configuration#MAX_SUBST} replacements are required | [
"Attempts",
"to",
"repeatedly",
"expand",
"the",
"value",
"{",
"@code",
"expr",
"}",
"by",
"replacing",
"the",
"left",
"-",
"most",
"substring",
"of",
"the",
"form",
"$",
"{",
"var",
"}",
"in",
"the",
"following",
"precedence",
"order",
"<ol",
">",
"<li"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-swift-fs-hadoop/src/main/java/org/apache/hadoop/conf/Configuration.java#L904-L937 | train | Substitute variables in the given expression. | [
30522,
2797,
5164,
7681,
10755,
2015,
1006,
5164,
4654,
18098,
1007,
1063,
2065,
1006,
4654,
18098,
1027,
1027,
19701,
1007,
1063,
2709,
19701,
1025,
1065,
5164,
9345,
2140,
1027,
4654,
18098,
1025,
2005,
1006,
20014,
1055,
1027,
1014,
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 | transport/src/main/java/io/netty/channel/PendingWriteQueue.java | PendingWriteQueue.removeAndFailAll | public void removeAndFailAll(Throwable cause) {
assert ctx.executor().inEventLoop();
if (cause == null) {
throw new NullPointerException("cause");
}
// It is possible for some of the failed promises to trigger more writes. The new writes
// will "revive" the queue, so we need to clean them up until the queue is empty.
for (PendingWrite write = head; write != null; write = head) {
head = tail = null;
size = 0;
bytes = 0;
while (write != null) {
PendingWrite next = write.next;
ReferenceCountUtil.safeRelease(write.msg);
ChannelPromise promise = write.promise;
recycle(write, false);
safeFail(promise, cause);
write = next;
}
}
assertEmpty();
} | java | public void removeAndFailAll(Throwable cause) {
assert ctx.executor().inEventLoop();
if (cause == null) {
throw new NullPointerException("cause");
}
// It is possible for some of the failed promises to trigger more writes. The new writes
// will "revive" the queue, so we need to clean them up until the queue is empty.
for (PendingWrite write = head; write != null; write = head) {
head = tail = null;
size = 0;
bytes = 0;
while (write != null) {
PendingWrite next = write.next;
ReferenceCountUtil.safeRelease(write.msg);
ChannelPromise promise = write.promise;
recycle(write, false);
safeFail(promise, cause);
write = next;
}
}
assertEmpty();
} | [
"public",
"void",
"removeAndFailAll",
"(",
"Throwable",
"cause",
")",
"{",
"assert",
"ctx",
".",
"executor",
"(",
")",
".",
"inEventLoop",
"(",
")",
";",
"if",
"(",
"cause",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"cause\"",
... | Remove all pending write operation and fail them with the given {@link Throwable}. The message will be released
via {@link ReferenceCountUtil#safeRelease(Object)}. | [
"Remove",
"all",
"pending",
"write",
"operation",
"and",
"fail",
"them",
"with",
"the",
"given",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/channel/PendingWriteQueue.java#L166-L187 | train | Remove all pending writes and fail all the failed messages. | [
30522,
2270,
11675,
6366,
5685,
7011,
11733,
3363,
1006,
5466,
3085,
3426,
1007,
1063,
20865,
14931,
2595,
1012,
4654,
8586,
16161,
2099,
1006,
1007,
1012,
1999,
18697,
3372,
4135,
7361,
1006,
1007,
1025,
2065,
1006,
3426,
1027,
1027,
19701... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-core/sharding-core-entry/src/main/java/org/apache/shardingsphere/core/BaseShardingEngine.java | BaseShardingEngine.shard | public SQLRouteResult shard(final String sql, final List<Object> parameters) {
List<Object> clonedParameters = cloneParameters(parameters);
SQLRouteResult result = executeRoute(sql, clonedParameters);
result.getRouteUnits().addAll(HintManager.isDatabaseShardingOnly() ? convert(sql, clonedParameters, result) : rewriteAndConvert(sql, clonedParameters, result));
if (shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW)) {
boolean showSimple = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SIMPLE);
SQLLogger.logSQL(sql, showSimple, result.getSqlStatement(), result.getRouteUnits());
}
return result;
} | java | public SQLRouteResult shard(final String sql, final List<Object> parameters) {
List<Object> clonedParameters = cloneParameters(parameters);
SQLRouteResult result = executeRoute(sql, clonedParameters);
result.getRouteUnits().addAll(HintManager.isDatabaseShardingOnly() ? convert(sql, clonedParameters, result) : rewriteAndConvert(sql, clonedParameters, result));
if (shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW)) {
boolean showSimple = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SIMPLE);
SQLLogger.logSQL(sql, showSimple, result.getSqlStatement(), result.getRouteUnits());
}
return result;
} | [
"public",
"SQLRouteResult",
"shard",
"(",
"final",
"String",
"sql",
",",
"final",
"List",
"<",
"Object",
">",
"parameters",
")",
"{",
"List",
"<",
"Object",
">",
"clonedParameters",
"=",
"cloneParameters",
"(",
"parameters",
")",
";",
"SQLRouteResult",
"result... | Shard.
@param sql SQL
@param parameters parameters of SQL
@return SQL route result | [
"Shard",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-entry/src/main/java/org/apache/shardingsphere/core/BaseShardingEngine.java#L65-L74 | train | Shard SQL. | [
30522,
2270,
29296,
22494,
3334,
2229,
11314,
21146,
4103,
1006,
2345,
5164,
29296,
1010,
2345,
2862,
1026,
4874,
1028,
11709,
1007,
1063,
2862,
1026,
4874,
1028,
17598,
18927,
5400,
22828,
2015,
1027,
17598,
28689,
22828,
2015,
1006,
11709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-setting/src/main/java/cn/hutool/setting/AbsSetting.java | AbsSetting.getByGroupWithLog | public String getByGroupWithLog(String key, String group) {
final String value = getByGroup(key, group);
if (value == null) {
log.debug("No key define for [{}] of group [{}] !", key, group);
}
return value;
} | java | public String getByGroupWithLog(String key, String group) {
final String value = getByGroup(key, group);
if (value == null) {
log.debug("No key define for [{}] of group [{}] !", key, group);
}
return value;
} | [
"public",
"String",
"getByGroupWithLog",
"(",
"String",
"key",
",",
"String",
"group",
")",
"{",
"final",
"String",
"value",
"=",
"getByGroup",
"(",
"key",
",",
"group",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"log",
".",
"debug",
"(",
... | 带有日志提示的get,如果没有定义指定的KEY,则打印debug日志
@param key 键
@param group 分组
@return 值 | [
"带有日志提示的get,如果没有定义指定的KEY,则打印debug日志"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/AbsSetting.java#L82-L88 | train | Gets the value of a group with log. | [
30522,
2270,
5164,
2131,
3762,
17058,
24415,
21197,
1006,
5164,
3145,
1010,
5164,
2177,
1007,
1063,
2345,
5164,
3643,
1027,
2131,
3762,
17058,
1006,
3145,
1010,
2177,
1007,
1025,
2065,
1006,
3643,
1027,
1027,
19701,
1007,
1063,
8833,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.addCcToken | public Result addCcToken(ClientRequest request) {
Result<Jwt> result = tokenManager.getJwt(request);
if(result.isFailure()) { return Failure.of(result.getError()); }
request.getRequestHeaders().put(Headers.AUTHORIZATION, "Bearer " + result.getResult().getJwt());
return result;
} | java | public Result addCcToken(ClientRequest request) {
Result<Jwt> result = tokenManager.getJwt(request);
if(result.isFailure()) { return Failure.of(result.getError()); }
request.getRequestHeaders().put(Headers.AUTHORIZATION, "Bearer " + result.getResult().getJwt());
return result;
} | [
"public",
"Result",
"addCcToken",
"(",
"ClientRequest",
"request",
")",
"{",
"Result",
"<",
"Jwt",
">",
"result",
"=",
"tokenManager",
".",
"getJwt",
"(",
"request",
")",
";",
"if",
"(",
"result",
".",
"isFailure",
"(",
")",
")",
"{",
"return",
"Failure"... | Add Client Credentials token cached in the client for standalone application
This is the method called from standalone application like enterprise scheduler for batch jobs
or mobile apps.
@param request the http request
@return Result when fail to get jwt, it will return a Status. | [
"Add",
"Client",
"Credentials",
"token",
"cached",
"in",
"the",
"client",
"for",
"standalone",
"application"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L316-L321 | train | Add a CSRF token to the request. | [
30522,
2270,
2765,
5587,
9468,
18715,
2368,
1006,
7396,
2890,
15500,
5227,
1007,
1063,
2765,
1026,
1046,
26677,
1028,
2765,
1027,
19204,
24805,
4590,
1012,
2131,
3501,
26677,
1006,
5227,
1007,
1025,
2065,
1006,
2765,
1012,
2003,
7011,
4014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/security/DynamicConfiguration.java | DynamicConfiguration.addAppConfigurationEntry | public void addAppConfigurationEntry(String name, AppConfigurationEntry... entry) {
final AppConfigurationEntry[] existing = dynamicEntries.get(name);
final AppConfigurationEntry[] updated;
if (existing == null) {
updated = Arrays.copyOf(entry, entry.length);
}
else {
updated = merge(existing, entry);
}
dynamicEntries.put(name, updated);
} | java | public void addAppConfigurationEntry(String name, AppConfigurationEntry... entry) {
final AppConfigurationEntry[] existing = dynamicEntries.get(name);
final AppConfigurationEntry[] updated;
if (existing == null) {
updated = Arrays.copyOf(entry, entry.length);
}
else {
updated = merge(existing, entry);
}
dynamicEntries.put(name, updated);
} | [
"public",
"void",
"addAppConfigurationEntry",
"(",
"String",
"name",
",",
"AppConfigurationEntry",
"...",
"entry",
")",
"{",
"final",
"AppConfigurationEntry",
"[",
"]",
"existing",
"=",
"dynamicEntries",
".",
"get",
"(",
"name",
")",
";",
"final",
"AppConfiguratio... | Add entries for the given application name. | [
"Add",
"entries",
"for",
"the",
"given",
"application",
"name",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/security/DynamicConfiguration.java#L59-L69 | train | Adds an app configuration entry to the dynamic configuration. | [
30522,
2270,
11675,
5587,
29098,
8663,
8873,
27390,
3370,
4765,
2854,
1006,
5164,
2171,
1010,
10439,
8663,
8873,
27390,
3370,
4765,
2854,
1012,
1012,
1012,
4443,
1007,
1063,
2345,
10439,
8663,
8873,
27390,
3370,
4765,
2854,
1031,
1033,
4493... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-core/src/main/java/org/apache/flink/types/Record.java | Record.serialize | public long serialize(DataOutputView target) throws IOException {
updateBinaryRepresenation();
long bytesForLen = 1;
int len = this.binaryLen;
while (len >= MAX_BIT) {
target.write(len | MAX_BIT);
len >>= 7;
bytesForLen++;
}
target.write(len);
target.write(this.binaryData, 0, this.binaryLen);
return bytesForLen + this.binaryLen;
} | java | public long serialize(DataOutputView target) throws IOException {
updateBinaryRepresenation();
long bytesForLen = 1;
int len = this.binaryLen;
while (len >= MAX_BIT) {
target.write(len | MAX_BIT);
len >>= 7;
bytesForLen++;
}
target.write(len);
target.write(this.binaryData, 0, this.binaryLen);
return bytesForLen + this.binaryLen;
} | [
"public",
"long",
"serialize",
"(",
"DataOutputView",
"target",
")",
"throws",
"IOException",
"{",
"updateBinaryRepresenation",
"(",
")",
";",
"long",
"bytesForLen",
"=",
"1",
";",
"int",
"len",
"=",
"this",
".",
"binaryLen",
";",
"while",
"(",
"len",
">=",
... | Writes this record to the given output view. This method is similar to {@link org.apache.flink.core.io.IOReadableWritable#write(org.apache.flink.core.memory.DataOutputView)}, but
it returns the number of bytes written.
@param target The view to write the record to.
@return The number of bytes written.
@throws IOException Thrown, if an error occurred in the view during writing. | [
"Writes",
"this",
"record",
"to",
"the",
"given",
"output",
"view",
".",
"This",
"method",
"is",
"similar",
"to",
"{",
"@link",
"org",
".",
"apache",
".",
"flink",
".",
"core",
".",
"io",
".",
"IOReadableWritable#write",
"(",
"org",
".",
"apache",
".",
... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/Record.java#L1211-L1225 | train | Serialize this object to the given output view. | [
30522,
2270,
2146,
7642,
4697,
1006,
2951,
5833,
18780,
8584,
4539,
1007,
11618,
22834,
10288,
24422,
1063,
10651,
21114,
2854,
2890,
28994,
8189,
3508,
1006,
1007,
1025,
2146,
27507,
29278,
7770,
1027,
1015,
1025,
20014,
18798,
1027,
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... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java | Task.triggerCheckpointBarrier | public void triggerCheckpointBarrier(
final long checkpointID,
final long checkpointTimestamp,
final CheckpointOptions checkpointOptions,
final boolean advanceToEndOfEventTime) {
final AbstractInvokable invokable = this.invokable;
final CheckpointMetaData checkpointMetaData = new CheckpointMetaData(checkpointID, checkpointTimestamp);
if (executionState == ExecutionState.RUNNING && invokable != null) {
// build a local closure
final String taskName = taskNameWithSubtask;
final SafetyNetCloseableRegistry safetyNetCloseableRegistry =
FileSystemSafetyNet.getSafetyNetCloseableRegistryForThread();
Runnable runnable = new Runnable() {
@Override
public void run() {
// set safety net from the task's context for checkpointing thread
LOG.debug("Creating FileSystem stream leak safety net for {}", Thread.currentThread().getName());
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(safetyNetCloseableRegistry);
try {
boolean success = invokable.triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
if (!success) {
checkpointResponder.declineCheckpoint(
getJobID(), getExecutionId(), checkpointID,
new CheckpointDeclineTaskNotReadyException(taskName));
}
}
catch (Throwable t) {
if (getExecutionState() == ExecutionState.RUNNING) {
failExternally(new Exception(
"Error while triggering checkpoint " + checkpointID + " for " +
taskNameWithSubtask, t));
} else {
LOG.debug("Encountered error while triggering checkpoint {} for " +
"{} ({}) while being not in state running.", checkpointID,
taskNameWithSubtask, executionId, t);
}
} finally {
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(null);
}
}
};
executeAsyncCallRunnable(
runnable,
String.format("Checkpoint Trigger for %s (%s).", taskNameWithSubtask, executionId),
checkpointOptions.getCheckpointType().isSynchronous());
}
else {
LOG.debug("Declining checkpoint request for non-running task {} ({}).", taskNameWithSubtask, executionId);
// send back a message that we did not do the checkpoint
checkpointResponder.declineCheckpoint(jobId, executionId, checkpointID,
new CheckpointDeclineTaskNotReadyException(taskNameWithSubtask));
}
} | java | public void triggerCheckpointBarrier(
final long checkpointID,
final long checkpointTimestamp,
final CheckpointOptions checkpointOptions,
final boolean advanceToEndOfEventTime) {
final AbstractInvokable invokable = this.invokable;
final CheckpointMetaData checkpointMetaData = new CheckpointMetaData(checkpointID, checkpointTimestamp);
if (executionState == ExecutionState.RUNNING && invokable != null) {
// build a local closure
final String taskName = taskNameWithSubtask;
final SafetyNetCloseableRegistry safetyNetCloseableRegistry =
FileSystemSafetyNet.getSafetyNetCloseableRegistryForThread();
Runnable runnable = new Runnable() {
@Override
public void run() {
// set safety net from the task's context for checkpointing thread
LOG.debug("Creating FileSystem stream leak safety net for {}", Thread.currentThread().getName());
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(safetyNetCloseableRegistry);
try {
boolean success = invokable.triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
if (!success) {
checkpointResponder.declineCheckpoint(
getJobID(), getExecutionId(), checkpointID,
new CheckpointDeclineTaskNotReadyException(taskName));
}
}
catch (Throwable t) {
if (getExecutionState() == ExecutionState.RUNNING) {
failExternally(new Exception(
"Error while triggering checkpoint " + checkpointID + " for " +
taskNameWithSubtask, t));
} else {
LOG.debug("Encountered error while triggering checkpoint {} for " +
"{} ({}) while being not in state running.", checkpointID,
taskNameWithSubtask, executionId, t);
}
} finally {
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(null);
}
}
};
executeAsyncCallRunnable(
runnable,
String.format("Checkpoint Trigger for %s (%s).", taskNameWithSubtask, executionId),
checkpointOptions.getCheckpointType().isSynchronous());
}
else {
LOG.debug("Declining checkpoint request for non-running task {} ({}).", taskNameWithSubtask, executionId);
// send back a message that we did not do the checkpoint
checkpointResponder.declineCheckpoint(jobId, executionId, checkpointID,
new CheckpointDeclineTaskNotReadyException(taskNameWithSubtask));
}
} | [
"public",
"void",
"triggerCheckpointBarrier",
"(",
"final",
"long",
"checkpointID",
",",
"final",
"long",
"checkpointTimestamp",
",",
"final",
"CheckpointOptions",
"checkpointOptions",
",",
"final",
"boolean",
"advanceToEndOfEventTime",
")",
"{",
"final",
"AbstractInvokab... | Calls the invokable to trigger a checkpoint.
@param checkpointID The ID identifying the checkpoint.
@param checkpointTimestamp The timestamp associated with the checkpoint.
@param checkpointOptions Options for performing this checkpoint.
@param advanceToEndOfEventTime Flag indicating if the source should inject a {@code MAX_WATERMARK} in the pipeline
to fire any registered event-time timers. | [
"Calls",
"the",
"invokable",
"to",
"trigger",
"a",
"checkpoint",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java#L1161-L1219 | train | Trigger a checkpoint. | [
30522,
2270,
11675,
9495,
5403,
3600,
8400,
8237,
16252,
1006,
2345,
2146,
26520,
3593,
1010,
2345,
2146,
26520,
7292,
9153,
8737,
1010,
2345,
26520,
7361,
9285,
26520,
7361,
9285,
1010,
2345,
22017,
20898,
5083,
3406,
10497,
11253,
18697,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/state/StateUtil.java | StateUtil.discardStateFuture | public static void discardStateFuture(RunnableFuture<? extends StateObject> stateFuture) throws Exception {
if (null != stateFuture) {
if (!stateFuture.cancel(true)) {
try {
// We attempt to get a result, in case the future completed before cancellation.
StateObject stateObject = FutureUtils.runIfNotDoneAndGet(stateFuture);
if (null != stateObject) {
stateObject.discardState();
}
} catch (CancellationException | ExecutionException ex) {
LOG.debug("Cancelled execution of snapshot future runnable. Cancellation produced the following " +
"exception, which is expected an can be ignored.", ex);
}
}
}
} | java | public static void discardStateFuture(RunnableFuture<? extends StateObject> stateFuture) throws Exception {
if (null != stateFuture) {
if (!stateFuture.cancel(true)) {
try {
// We attempt to get a result, in case the future completed before cancellation.
StateObject stateObject = FutureUtils.runIfNotDoneAndGet(stateFuture);
if (null != stateObject) {
stateObject.discardState();
}
} catch (CancellationException | ExecutionException ex) {
LOG.debug("Cancelled execution of snapshot future runnable. Cancellation produced the following " +
"exception, which is expected an can be ignored.", ex);
}
}
}
} | [
"public",
"static",
"void",
"discardStateFuture",
"(",
"RunnableFuture",
"<",
"?",
"extends",
"StateObject",
">",
"stateFuture",
")",
"throws",
"Exception",
"{",
"if",
"(",
"null",
"!=",
"stateFuture",
")",
"{",
"if",
"(",
"!",
"stateFuture",
".",
"cancel",
... | Discards the given state future by first trying to cancel it. If this is not possible, then
the state object contained in the future is calculated and afterwards discarded.
@param stateFuture to be discarded
@throws Exception if the discard operation failed | [
"Discards",
"the",
"given",
"state",
"future",
"by",
"first",
"trying",
"to",
"cancel",
"it",
".",
"If",
"this",
"is",
"not",
"possible",
"then",
"the",
"state",
"object",
"contained",
"in",
"the",
"future",
"is",
"calculated",
"and",
"afterwards",
"discarde... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/state/StateUtil.java#L70-L87 | train | Discards the given state future. | [
30522,
2270,
10763,
11675,
5860,
18117,
12259,
11263,
11244,
1006,
2448,
22966,
11263,
11244,
1026,
1029,
8908,
2110,
16429,
20614,
1028,
2110,
11263,
11244,
1007,
11618,
6453,
1063,
2065,
1006,
19701,
999,
1027,
2110,
11263,
11244,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | common/src/main/java/io/netty/util/NetUtil.java | NetUtil.getHostname | public static String getHostname(InetSocketAddress addr) {
return PlatformDependent.javaVersion() >= 7 ? addr.getHostString() : addr.getHostName();
} | java | public static String getHostname(InetSocketAddress addr) {
return PlatformDependent.javaVersion() >= 7 ? addr.getHostString() : addr.getHostName();
} | [
"public",
"static",
"String",
"getHostname",
"(",
"InetSocketAddress",
"addr",
")",
"{",
"return",
"PlatformDependent",
".",
"javaVersion",
"(",
")",
">=",
"7",
"?",
"addr",
".",
"getHostString",
"(",
")",
":",
"addr",
".",
"getHostName",
"(",
")",
";",
"}... | Returns {@link InetSocketAddress#getHostString()} if Java >= 7,
or {@link InetSocketAddress#getHostName()} otherwise.
@param addr The address
@return the host string | [
"Returns",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/NetUtil.java#L1121-L1123 | train | Get the host name of the given address. | [
30522,
2270,
10763,
5164,
2131,
15006,
2102,
18442,
1006,
1999,
8454,
7432,
12928,
14141,
8303,
5587,
2099,
1007,
1063,
2709,
4132,
3207,
11837,
16454,
1012,
9262,
27774,
1006,
1007,
1028,
1027,
1021,
1029,
5587,
2099,
1012,
2131,
15006,
32... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/liveobject/misc/ClassUtils.java | ClassUtils.translateFromPrimitive | private static Class<?> translateFromPrimitive(Class<?> primitive) {
if (!primitive.isPrimitive()) {
return primitive;
}
if (Boolean.TYPE.equals(primitive)) {
return Boolean.class;
}
if (Character.TYPE.equals(primitive)) {
return Character.class;
}
if (Byte.TYPE.equals(primitive)) {
return Byte.class;
}
if (Short.TYPE.equals(primitive)) {
return Short.class;
}
if (Integer.TYPE.equals(primitive)) {
return Integer.class;
}
if (Long.TYPE.equals(primitive)) {
return Long.class;
}
if (Float.TYPE.equals(primitive)) {
return Float.class;
}
if (Double.TYPE.equals(primitive)) {
return Double.class;
}
throw new RuntimeException("Error translating type:" + primitive);
} | java | private static Class<?> translateFromPrimitive(Class<?> primitive) {
if (!primitive.isPrimitive()) {
return primitive;
}
if (Boolean.TYPE.equals(primitive)) {
return Boolean.class;
}
if (Character.TYPE.equals(primitive)) {
return Character.class;
}
if (Byte.TYPE.equals(primitive)) {
return Byte.class;
}
if (Short.TYPE.equals(primitive)) {
return Short.class;
}
if (Integer.TYPE.equals(primitive)) {
return Integer.class;
}
if (Long.TYPE.equals(primitive)) {
return Long.class;
}
if (Float.TYPE.equals(primitive)) {
return Float.class;
}
if (Double.TYPE.equals(primitive)) {
return Double.class;
}
throw new RuntimeException("Error translating type:" + primitive);
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"translateFromPrimitive",
"(",
"Class",
"<",
"?",
">",
"primitive",
")",
"{",
"if",
"(",
"!",
"primitive",
".",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"primitive",
";",
"}",
"if",
"(",
"Boolean",
".",
... | If this specified class represents a primitive type (int, float, etc.)
then it is translated into its wrapper type (Integer, Float, etc.). If
the passed class is not a primitive then it is just returned.
@param primitive class
@return class | [
"If",
"this",
"specified",
"class",
"represents",
"a",
"primitive",
"type",
"(",
"int",
"float",
"etc",
".",
")",
"then",
"it",
"is",
"translated",
"into",
"its",
"wrapper",
"type",
"(",
"Integer",
"Float",
"etc",
".",
")",
".",
"If",
"the",
"passed",
... | d3acc0249b2d5d658d36d99e2c808ce49332ea44 | https://github.com/redisson/redisson/blob/d3acc0249b2d5d658d36d99e2c808ce49332ea44/redisson/src/main/java/org/redisson/liveobject/misc/ClassUtils.java#L219-L250 | train | Translate a class from a primitive type to a class. | [
30522,
2797,
10763,
2465,
1026,
1029,
1028,
17637,
19699,
25377,
20026,
13043,
1006,
2465,
1026,
1029,
1028,
10968,
1007,
1063,
2065,
1006,
999,
10968,
1012,
2003,
18098,
27605,
6024,
1006,
1007,
1007,
1063,
2709,
10968,
1025,
1065,
2065,
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... |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java | RestTemplateBuilder.customizers | public RestTemplateBuilder customizers(
RestTemplateCustomizer... restTemplateCustomizers) {
Assert.notNull(restTemplateCustomizers,
"RestTemplateCustomizers must not be null");
return customizers(Arrays.asList(restTemplateCustomizers));
} | java | public RestTemplateBuilder customizers(
RestTemplateCustomizer... restTemplateCustomizers) {
Assert.notNull(restTemplateCustomizers,
"RestTemplateCustomizers must not be null");
return customizers(Arrays.asList(restTemplateCustomizers));
} | [
"public",
"RestTemplateBuilder",
"customizers",
"(",
"RestTemplateCustomizer",
"...",
"restTemplateCustomizers",
")",
"{",
"Assert",
".",
"notNull",
"(",
"restTemplateCustomizers",
",",
"\"RestTemplateCustomizers must not be null\"",
")",
";",
"return",
"customizers",
"(",
... | Set the {@link RestTemplateCustomizer RestTemplateCustomizers} that should be
applied to the {@link RestTemplate}. Customizers are applied in the order that they
were added after builder configuration has been applied. Setting this value will
replace any previously configured customizers.
@param restTemplateCustomizers the customizers to set
@return a new builder instance
@see #additionalCustomizers(RestTemplateCustomizer...) | [
"Set",
"the",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java#L399-L404 | train | Add custom template customizers. | [
30522,
2270,
2717,
18532,
15725,
8569,
23891,
2099,
7661,
17629,
2015,
1006,
2717,
18532,
15725,
7874,
20389,
17629,
1012,
1012,
1012,
2717,
18532,
15725,
7874,
20389,
17629,
2015,
1007,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
2717,
18532... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/seg/CharacterBasedSegment.java | CharacterBasedSegment.guessAttribute | public static CoreDictionary.Attribute guessAttribute(Term term)
{
CoreDictionary.Attribute attribute = CoreDictionary.get(term.word);
if (attribute == null)
{
attribute = CustomDictionary.get(term.word);
}
if (attribute == null)
{
if (term.nature != null)
{
if (Nature.nx == term.nature)
attribute = new CoreDictionary.Attribute(Nature.nx);
else if (Nature.m == term.nature)
attribute = CoreDictionary.get(CoreDictionary.M_WORD_ID);
}
else if (term.word.trim().length() == 0)
attribute = new CoreDictionary.Attribute(Nature.x);
else attribute = new CoreDictionary.Attribute(Nature.nz);
}
else term.nature = attribute.nature[0];
return attribute;
} | java | public static CoreDictionary.Attribute guessAttribute(Term term)
{
CoreDictionary.Attribute attribute = CoreDictionary.get(term.word);
if (attribute == null)
{
attribute = CustomDictionary.get(term.word);
}
if (attribute == null)
{
if (term.nature != null)
{
if (Nature.nx == term.nature)
attribute = new CoreDictionary.Attribute(Nature.nx);
else if (Nature.m == term.nature)
attribute = CoreDictionary.get(CoreDictionary.M_WORD_ID);
}
else if (term.word.trim().length() == 0)
attribute = new CoreDictionary.Attribute(Nature.x);
else attribute = new CoreDictionary.Attribute(Nature.nz);
}
else term.nature = attribute.nature[0];
return attribute;
} | [
"public",
"static",
"CoreDictionary",
".",
"Attribute",
"guessAttribute",
"(",
"Term",
"term",
")",
"{",
"CoreDictionary",
".",
"Attribute",
"attribute",
"=",
"CoreDictionary",
".",
"get",
"(",
"term",
".",
"word",
")",
";",
"if",
"(",
"attribute",
"==",
"nu... | 查询或猜测一个词语的属性,
先查词典,然后对字母、数字串的属性进行判断,最后猜测未登录词
@param term
@return | [
"查询或猜测一个词语的属性,",
"先查词典,然后对字母、数字串的属性进行判断,最后猜测未登录词"
] | a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/seg/CharacterBasedSegment.java#L38-L60 | train | Guess the attribute for a term. | [
30522,
2270,
10763,
4563,
29201,
3258,
5649,
1012,
17961,
3984,
19321,
3089,
8569,
2618,
1006,
2744,
2744,
1007,
1063,
4563,
29201,
3258,
5649,
1012,
17961,
17961,
1027,
4563,
29201,
3258,
5649,
1012,
2131,
1006,
2744,
1012,
2773,
1007,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | codec/src/main/java/io/netty/handler/codec/compression/Bzip2HuffmanAllocator.java | Bzip2HuffmanAllocator.findNodesToRelocate | private static int findNodesToRelocate(final int[] array, final int maximumLength) {
int currentNode = array.length - 2;
for (int currentDepth = 1; currentDepth < maximumLength - 1 && currentNode > 1; currentDepth++) {
currentNode = first(array, currentNode - 1, 0);
}
return currentNode;
} | java | private static int findNodesToRelocate(final int[] array, final int maximumLength) {
int currentNode = array.length - 2;
for (int currentDepth = 1; currentDepth < maximumLength - 1 && currentNode > 1; currentDepth++) {
currentNode = first(array, currentNode - 1, 0);
}
return currentNode;
} | [
"private",
"static",
"int",
"findNodesToRelocate",
"(",
"final",
"int",
"[",
"]",
"array",
",",
"final",
"int",
"maximumLength",
")",
"{",
"int",
"currentNode",
"=",
"array",
".",
"length",
"-",
"2",
";",
"for",
"(",
"int",
"currentDepth",
"=",
"1",
";",... | Finds the number of nodes to relocate in order to achieve a given code length limit.
@param array The code length array
@param maximumLength The maximum bit length for the generated codes
@return The number of nodes to relocate | [
"Finds",
"the",
"number",
"of",
"nodes",
"to",
"relocate",
"in",
"order",
"to",
"achieve",
"a",
"given",
"code",
"length",
"limit",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/compression/Bzip2HuffmanAllocator.java#L88-L94 | train | Find nodes to relocate. | [
30522,
2797,
10763,
20014,
2424,
3630,
6155,
19277,
4135,
16280,
1006,
2345,
20014,
1031,
1033,
9140,
1010,
2345,
20014,
4555,
7770,
13512,
2232,
1007,
1063,
20014,
2783,
3630,
3207,
1027,
9140,
1012,
3091,
1011,
1016,
1025,
2005,
1006,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/swing/clipboard/ClipboardUtil.java | ClipboardUtil.listen | public static void listen(ClipboardListener listener, boolean sync) {
listen(ClipboardMonitor.DEFAULT_TRY_COUNT, ClipboardMonitor.DEFAULT_DELAY, listener, sync);
} | java | public static void listen(ClipboardListener listener, boolean sync) {
listen(ClipboardMonitor.DEFAULT_TRY_COUNT, ClipboardMonitor.DEFAULT_DELAY, listener, sync);
} | [
"public",
"static",
"void",
"listen",
"(",
"ClipboardListener",
"listener",
",",
"boolean",
"sync",
")",
"{",
"listen",
"(",
"ClipboardMonitor",
".",
"DEFAULT_TRY_COUNT",
",",
"ClipboardMonitor",
".",
"DEFAULT_DELAY",
",",
"listener",
",",
"sync",
")",
";",
"}"
... | 监听剪贴板修改事件
@param listener 监听处理接口
@param sync 是否同步阻塞
@since 4.5.6
@see ClipboardMonitor#listen(boolean) | [
"监听剪贴板修改事件"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/swing/clipboard/ClipboardUtil.java#L156-L158 | train | Listen to the clipboard events. | [
30522,
2270,
10763,
11675,
4952,
1006,
12528,
6277,
9863,
24454,
19373,
1010,
22017,
20898,
26351,
1007,
1063,
4952,
1006,
12528,
6277,
8202,
15660,
1012,
12398,
1035,
3046,
1035,
4175,
1010,
12528,
6277,
8202,
15660,
1012,
12398,
1035,
8536,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/gen/java/org/apache/hive/service/cli/thrift/TPrimitiveTypeEntry.java | TPrimitiveTypeEntry.isSet | public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case TYPE:
return isSetType();
case TYPE_QUALIFIERS:
return isSetTypeQualifiers();
}
throw new IllegalStateException();
} | java | public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case TYPE:
return isSetType();
case TYPE_QUALIFIERS:
return isSetTypeQualifiers();
}
throw new IllegalStateException();
} | [
"public",
"boolean",
"isSet",
"(",
"_Fields",
"field",
")",
"{",
"if",
"(",
"field",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"switch",
"(",
"field",
")",
"{",
"case",
"TYPE",
":",
"return",
"isSetType",
"... | Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise | [
"Returns",
"true",
"if",
"field",
"corresponding",
"to",
"fieldID",
"is",
"set",
"(",
"has",
"been",
"assigned",
"a",
"value",
")",
"and",
"false",
"otherwise"
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/hive-thriftserver/src/gen/java/org/apache/hive/service/cli/thrift/TPrimitiveTypeEntry.java#L247-L259 | train | Checks if the specified field is set to a value of a CRAsCTYPE object. | [
30522,
2270,
22017,
20898,
26354,
3388,
1006,
1035,
4249,
2492,
1007,
1063,
2065,
1006,
2492,
1027,
1027,
19701,
1007,
1063,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24422,
1006,
1007,
1025,
1065,
6942,
1006,
2492,
1007,
1063,
2553,
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... |
apache/flink | flink-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/client/state/serialization/KvStateSerializer.java | KvStateSerializer.serializeKeyAndNamespace | public static <K, N> byte[] serializeKeyAndNamespace(
K key,
TypeSerializer<K> keySerializer,
N namespace,
TypeSerializer<N> namespaceSerializer) throws IOException {
DataOutputSerializer dos = new DataOutputSerializer(32);
keySerializer.serialize(key, dos);
dos.writeByte(MAGIC_NUMBER);
namespaceSerializer.serialize(namespace, dos);
return dos.getCopyOfBuffer();
} | java | public static <K, N> byte[] serializeKeyAndNamespace(
K key,
TypeSerializer<K> keySerializer,
N namespace,
TypeSerializer<N> namespaceSerializer) throws IOException {
DataOutputSerializer dos = new DataOutputSerializer(32);
keySerializer.serialize(key, dos);
dos.writeByte(MAGIC_NUMBER);
namespaceSerializer.serialize(namespace, dos);
return dos.getCopyOfBuffer();
} | [
"public",
"static",
"<",
"K",
",",
"N",
">",
"byte",
"[",
"]",
"serializeKeyAndNamespace",
"(",
"K",
"key",
",",
"TypeSerializer",
"<",
"K",
">",
"keySerializer",
",",
"N",
"namespace",
",",
"TypeSerializer",
"<",
"N",
">",
"namespaceSerializer",
")",
"thr... | Serializes the key and namespace into a {@link ByteBuffer}.
<p>The serialized format matches the RocksDB state backend key format, i.e.
the key and namespace don't have to be deserialized for RocksDB lookups.
@param key Key to serialize
@param keySerializer Serializer for the key
@param namespace Namespace to serialize
@param namespaceSerializer Serializer for the namespace
@param <K> Key type
@param <N> Namespace type
@return Buffer holding the serialized key and namespace
@throws IOException Serialization errors are forwarded | [
"Serializes",
"the",
"key",
"and",
"namespace",
"into",
"a",
"{",
"@link",
"ByteBuffer",
"}",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-queryable-state/flink-queryable-state-client-java/src/main/java/org/apache/flink/queryablestate/client/state/serialization/KvStateSerializer.java#L59-L72 | train | Serialize a key and namespace. | [
30522,
2270,
10763,
1026,
1047,
1010,
1050,
1028,
24880,
1031,
1033,
7642,
4697,
14839,
5685,
18442,
23058,
1006,
1047,
3145,
1010,
4127,
11610,
28863,
1026,
1047,
1028,
6309,
11610,
28863,
1010,
1050,
3415,
15327,
1010,
4127,
11610,
28863,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | buffer/src/main/java/io/netty/buffer/ByteBufUtil.java | ByteBufUtil.copy | public static void copy(AsciiString src, ByteBuf dst) {
copy(src, 0, dst, src.length());
} | java | public static void copy(AsciiString src, ByteBuf dst) {
copy(src, 0, dst, src.length());
} | [
"public",
"static",
"void",
"copy",
"(",
"AsciiString",
"src",
",",
"ByteBuf",
"dst",
")",
"{",
"copy",
"(",
"src",
",",
"0",
",",
"dst",
",",
"src",
".",
"length",
"(",
")",
")",
";",
"}"
] | Copies the all content of {@code src} to a {@link ByteBuf} using {@link ByteBuf#writeBytes(byte[], int, int)}.
@param src the source string to copy
@param dst the destination buffer | [
"Copies",
"the",
"all",
"content",
"of",
"{",
"@code",
"src",
"}",
"to",
"a",
"{",
"@link",
"ByteBuf",
"}",
"using",
"{",
"@link",
"ByteBuf#writeBytes",
"(",
"byte",
"[]",
"int",
"int",
")",
"}",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java#L866-L868 | train | Copy the bytes from src to dst. | [
30522,
2270,
10763,
11675,
6100,
1006,
2004,
6895,
2923,
4892,
5034,
2278,
1010,
24880,
8569,
2546,
16233,
2102,
1007,
1063,
6100,
1006,
5034,
2278,
1010,
1014,
1010,
16233,
2102,
1010,
5034,
2278,
1012,
3091,
1006,
1007,
1007,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/symmetric/Vigenere.java | Vigenere.decrypt | public static String decrypt(CharSequence data, CharSequence cipherKey) {
final int dataLen = data.length();
final int cipherKeyLen = cipherKey.length();
final char[] clearArray = new char[dataLen];
for (int i = 0; i < dataLen; i++) {
for (int t = 0; t < cipherKeyLen; t++) {
if (t + i * cipherKeyLen < dataLen) {
final char dataChar = data.charAt(t + i * cipherKeyLen);
final char cipherKeyChar = cipherKey.charAt(t);
if (dataChar - cipherKeyChar >= 0) {
clearArray[t + i * cipherKeyLen] = (char) ((dataChar - cipherKeyChar) % 95 + 32);
} else {
clearArray[t + i * cipherKeyLen] = (char) ((dataChar - cipherKeyChar + 95) % 95 + 32);
}
}
}
}
return String.valueOf(clearArray);
} | java | public static String decrypt(CharSequence data, CharSequence cipherKey) {
final int dataLen = data.length();
final int cipherKeyLen = cipherKey.length();
final char[] clearArray = new char[dataLen];
for (int i = 0; i < dataLen; i++) {
for (int t = 0; t < cipherKeyLen; t++) {
if (t + i * cipherKeyLen < dataLen) {
final char dataChar = data.charAt(t + i * cipherKeyLen);
final char cipherKeyChar = cipherKey.charAt(t);
if (dataChar - cipherKeyChar >= 0) {
clearArray[t + i * cipherKeyLen] = (char) ((dataChar - cipherKeyChar) % 95 + 32);
} else {
clearArray[t + i * cipherKeyLen] = (char) ((dataChar - cipherKeyChar + 95) % 95 + 32);
}
}
}
}
return String.valueOf(clearArray);
} | [
"public",
"static",
"String",
"decrypt",
"(",
"CharSequence",
"data",
",",
"CharSequence",
"cipherKey",
")",
"{",
"final",
"int",
"dataLen",
"=",
"data",
".",
"length",
"(",
")",
";",
"final",
"int",
"cipherKeyLen",
"=",
"cipherKey",
".",
"length",
"(",
")... | 解密
@param data 密文
@param cipherKey 密钥
@return 明文 | [
"解密"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/symmetric/Vigenere.java#L45-L64 | train | Decrypt a string using the specified key. | [
30522,
2270,
10763,
5164,
11703,
2854,
13876,
1006,
25869,
3366,
4226,
5897,
2951,
1010,
25869,
3366,
4226,
5897,
27715,
14839,
1007,
1063,
2345,
20014,
2951,
7770,
1027,
2951,
1012,
3091,
1006,
1007,
1025,
2345,
20014,
27715,
14839,
7770,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/concurrent/FastThreadLocal.java | FastThreadLocal.getIfExists | @SuppressWarnings("unchecked")
public final V getIfExists() {
InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet();
if (threadLocalMap != null) {
Object v = threadLocalMap.indexedVariable(index);
if (v != InternalThreadLocalMap.UNSET) {
return (V) v;
}
}
return null;
} | java | @SuppressWarnings("unchecked")
public final V getIfExists() {
InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet();
if (threadLocalMap != null) {
Object v = threadLocalMap.indexedVariable(index);
if (v != InternalThreadLocalMap.UNSET) {
return (V) v;
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"V",
"getIfExists",
"(",
")",
"{",
"InternalThreadLocalMap",
"threadLocalMap",
"=",
"InternalThreadLocalMap",
".",
"getIfSet",
"(",
")",
";",
"if",
"(",
"threadLocalMap",
"!=",
"null",
")",
"... | Returns the current value for the current thread if it exists, {@code null} otherwise. | [
"Returns",
"the",
"current",
"value",
"for",
"the",
"current",
"thread",
"if",
"it",
"exists",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/concurrent/FastThreadLocal.java#L148-L158 | train | Gets the value of the SECTYPE variable. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2270,
2345,
1058,
2131,
29323,
9048,
12837,
1006,
1007,
1063,
4722,
2705,
16416,
19422,
24755,
19145,
2361,
11689,
4135,
9289,
2863,
2361,
1027,
4722,
2705,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | common/src/main/java/io/netty/util/internal/StringUtil.java | StringUtil.validateCsvFormat | private static void validateCsvFormat(CharSequence value) {
int length = value.length();
for (int i = 0; i < length; i++) {
switch (value.charAt(i)) {
case DOUBLE_QUOTE:
case LINE_FEED:
case CARRIAGE_RETURN:
case COMMA:
// If value contains any special character, it should be enclosed with double-quotes
throw newInvalidEscapedCsvFieldException(value, i);
default:
}
}
} | java | private static void validateCsvFormat(CharSequence value) {
int length = value.length();
for (int i = 0; i < length; i++) {
switch (value.charAt(i)) {
case DOUBLE_QUOTE:
case LINE_FEED:
case CARRIAGE_RETURN:
case COMMA:
// If value contains any special character, it should be enclosed with double-quotes
throw newInvalidEscapedCsvFieldException(value, i);
default:
}
}
} | [
"private",
"static",
"void",
"validateCsvFormat",
"(",
"CharSequence",
"value",
")",
"{",
"int",
"length",
"=",
"value",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"switch",
"(... | Validate if {@code value} is a valid csv field without double-quotes.
@throws IllegalArgumentException if {@code value} needs to be encoded with double-quotes. | [
"Validate",
"if",
"{",
"@code",
"value",
"}",
"is",
"a",
"valid",
"csv",
"field",
"without",
"double",
"-",
"quotes",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/StringUtil.java#L506-L519 | train | Validate CSV format. | [
30522,
2797,
10763,
11675,
9398,
3686,
6169,
2615,
14192,
4017,
1006,
25869,
3366,
4226,
5897,
3643,
1007,
1063,
20014,
3091,
1027,
3643,
1012,
3091,
1006,
1007,
1025,
2005,
1006,
20014,
1045,
1027,
1014,
1025,
1045,
1026,
3091,
1025,
1045,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/rpc/akka/AkkaRpcActor.java | AkkaRpcActor.lookupRpcMethod | private Method lookupRpcMethod(final String methodName, final Class<?>[] parameterTypes) throws NoSuchMethodException {
return rpcEndpoint.getClass().getMethod(methodName, parameterTypes);
} | java | private Method lookupRpcMethod(final String methodName, final Class<?>[] parameterTypes) throws NoSuchMethodException {
return rpcEndpoint.getClass().getMethod(methodName, parameterTypes);
} | [
"private",
"Method",
"lookupRpcMethod",
"(",
"final",
"String",
"methodName",
",",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
")",
"throws",
"NoSuchMethodException",
"{",
"return",
"rpcEndpoint",
".",
"getClass",
"(",
")",
".",
"getMethod",
"... | Look up the rpc method on the given {@link RpcEndpoint} instance.
@param methodName Name of the method
@param parameterTypes Parameter types of the method
@return Method of the rpc endpoint
@throws NoSuchMethodException Thrown if the method with the given name and parameter types
cannot be found at the rpc endpoint | [
"Look",
"up",
"the",
"rpc",
"method",
"on",
"the",
"given",
"{",
"@link",
"RpcEndpoint",
"}",
"instance",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcActor.java#L424-L426 | train | Lookup the RPC method. | [
30522,
2797,
4118,
2298,
6279,
14536,
27487,
11031,
7716,
1006,
2345,
5164,
4118,
18442,
1010,
2345,
2465,
1026,
1029,
1028,
1031,
1033,
16381,
13874,
2015,
1007,
11618,
16839,
10875,
11368,
6806,
3207,
2595,
24422,
1063,
2709,
1054,
15042,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TextSimilarity.java | TextSimilarity.similar | public static double similar(String strA, String strB) {
String newStrA, newStrB;
if (strA.length() < strB.length()) {
newStrA = removeSign(strB);
newStrB = removeSign(strA);
} else {
newStrA = removeSign(strA);
newStrB = removeSign(strB);
}
// 用较大的字符串长度作为分母,相似子串作为分子计算出字串相似度
int temp = Math.max(newStrA.length(), newStrB.length());
int temp2 = longestCommonSubstring(newStrA, newStrB).length();
return NumberUtil.div(temp2, temp);
} | java | public static double similar(String strA, String strB) {
String newStrA, newStrB;
if (strA.length() < strB.length()) {
newStrA = removeSign(strB);
newStrB = removeSign(strA);
} else {
newStrA = removeSign(strA);
newStrB = removeSign(strB);
}
// 用较大的字符串长度作为分母,相似子串作为分子计算出字串相似度
int temp = Math.max(newStrA.length(), newStrB.length());
int temp2 = longestCommonSubstring(newStrA, newStrB).length();
return NumberUtil.div(temp2, temp);
} | [
"public",
"static",
"double",
"similar",
"(",
"String",
"strA",
",",
"String",
"strB",
")",
"{",
"String",
"newStrA",
",",
"newStrB",
";",
"if",
"(",
"strA",
".",
"length",
"(",
")",
"<",
"strB",
".",
"length",
"(",
")",
")",
"{",
"newStrA",
"=",
"... | 计算相似度
@param strA 字符串1
@param strB 字符串2
@return 相似度 | [
"计算相似度"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/text/TextSimilarity.java#L22-L35 | train | Returns the similar number of characters in the string A and strB. | [
30522,
2270,
10763,
3313,
2714,
1006,
5164,
2358,
2527,
1010,
5164,
2358,
15185,
1007,
1063,
5164,
2739,
6494,
1010,
2739,
16344,
2497,
1025,
2065,
1006,
2358,
2527,
1012,
3091,
1006,
1007,
1026,
2358,
15185,
1012,
3091,
1006,
1007,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java | DateUtil.secondToTime | public static String secondToTime(int seconds) {
if (seconds < 0) {
throw new IllegalArgumentException("Seconds must be a positive number!");
}
int hour = seconds / 3600;
int other = seconds % 3600;
int minute = other / 60;
int second = other % 60;
final StringBuilder sb = new StringBuilder();
if (hour < 10) {
sb.append("0");
}
sb.append(hour);
sb.append(":");
if (minute < 10) {
sb.append("0");
}
sb.append(minute);
sb.append(":");
if (second < 10) {
sb.append("0");
}
sb.append(second);
return sb.toString();
} | java | public static String secondToTime(int seconds) {
if (seconds < 0) {
throw new IllegalArgumentException("Seconds must be a positive number!");
}
int hour = seconds / 3600;
int other = seconds % 3600;
int minute = other / 60;
int second = other % 60;
final StringBuilder sb = new StringBuilder();
if (hour < 10) {
sb.append("0");
}
sb.append(hour);
sb.append(":");
if (minute < 10) {
sb.append("0");
}
sb.append(minute);
sb.append(":");
if (second < 10) {
sb.append("0");
}
sb.append(second);
return sb.toString();
} | [
"public",
"static",
"String",
"secondToTime",
"(",
"int",
"seconds",
")",
"{",
"if",
"(",
"seconds",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Seconds must be a positive number!\"",
")",
";",
"}",
"int",
"hour",
"=",
"seconds",
"/... | 秒数转为时间格式(HH:mm:ss)<br>
参考:https://github.com/iceroot
@param seconds 需要转换的秒数
@return 转换后的字符串
@since 3.1.2 | [
"秒数转为时间格式",
"(",
"HH",
":",
"mm",
":",
"ss",
")",
"<br",
">",
"参考:https",
":",
"//",
"github",
".",
"com",
"/",
"iceroot"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L1597-L1622 | train | Converts seconds from seconds to seconds - based time. | [
30522,
2270,
10763,
5164,
2117,
3406,
7292,
1006,
20014,
3823,
1007,
1063,
2065,
1006,
3823,
1026,
1014,
1007,
1063,
5466,
2047,
6206,
2906,
22850,
15781,
2595,
24422,
1006,
1000,
3823,
2442,
2022,
1037,
3893,
2193,
999,
1000,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/Assert.java | Assert.notEmpty | public static String notEmpty(String text, String errorMsgTemplate, Object... params) throws IllegalArgumentException {
if (StrUtil.isEmpty(text)) {
throw new IllegalArgumentException(StrUtil.format(errorMsgTemplate, params));
}
return text;
} | java | public static String notEmpty(String text, String errorMsgTemplate, Object... params) throws IllegalArgumentException {
if (StrUtil.isEmpty(text)) {
throw new IllegalArgumentException(StrUtil.format(errorMsgTemplate, params));
}
return text;
} | [
"public",
"static",
"String",
"notEmpty",
"(",
"String",
"text",
",",
"String",
"errorMsgTemplate",
",",
"Object",
"...",
"params",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"StrUtil",
".",
"isEmpty",
"(",
"text",
")",
")",
"{",
"throw",
"ne... | 检查给定字符串是否为空,为空抛出 {@link IllegalArgumentException}
<pre class="code">
Assert.notEmpty(name, "Name must not be empty");
</pre>
@param text 被检查字符串
@param errorMsgTemplate 错误消息模板,变量使用{}表示
@param params 参数
@return 非空字符串
@see StrUtil#isNotEmpty(CharSequence)
@throws IllegalArgumentException 被检查字符串为空 | [
"检查给定字符串是否为空,为空抛出",
"{",
"@link",
"IllegalArgumentException",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Assert.java#L168-L173 | train | Returns a string that is not empty. | [
30522,
2270,
10763,
5164,
3602,
27718,
2100,
1006,
5164,
3793,
1010,
5164,
7561,
5244,
13512,
6633,
15725,
1010,
4874,
1012,
1012,
1012,
11498,
5244,
1007,
11618,
6206,
2906,
22850,
15781,
2595,
24422,
1063,
2065,
1006,
2358,
22134,
4014,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | transport/src/main/java/io/netty/channel/ChannelOption.java | ChannelOption.valueOf | @SuppressWarnings("unchecked")
public static <T> ChannelOption<T> valueOf(String name) {
return (ChannelOption<T>) pool.valueOf(name);
} | java | @SuppressWarnings("unchecked")
public static <T> ChannelOption<T> valueOf(String name) {
return (ChannelOption<T>) pool.valueOf(name);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"ChannelOption",
"<",
"T",
">",
"valueOf",
"(",
"String",
"name",
")",
"{",
"return",
"(",
"ChannelOption",
"<",
"T",
">",
")",
"pool",
".",
"valueOf",
"(",
"name",
... | Returns the {@link ChannelOption} of the specified name. | [
"Returns",
"the",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/channel/ChannelOption.java#L45-L48 | train | Get a channel option from the name. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1000,
4895,
5403,
18141,
1000,
1007,
2270,
10763,
1026,
1056,
1028,
3149,
7361,
3508,
1026,
1056,
1028,
3643,
11253,
1006,
5164,
2171,
1007,
1063,
2709,
1006,
3149,
7361,
3508,
1026,
1056,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java | CombinedChannelDuplexHandler.init | protected final void init(I inboundHandler, O outboundHandler) {
validate(inboundHandler, outboundHandler);
this.inboundHandler = inboundHandler;
this.outboundHandler = outboundHandler;
} | java | protected final void init(I inboundHandler, O outboundHandler) {
validate(inboundHandler, outboundHandler);
this.inboundHandler = inboundHandler;
this.outboundHandler = outboundHandler;
} | [
"protected",
"final",
"void",
"init",
"(",
"I",
"inboundHandler",
",",
"O",
"outboundHandler",
")",
"{",
"validate",
"(",
"inboundHandler",
",",
"outboundHandler",
")",
";",
"this",
".",
"inboundHandler",
"=",
"inboundHandler",
";",
"this",
".",
"outboundHandler... | Initialized this handler with the specified handlers.
@throws IllegalStateException if this handler was not constructed via the default constructor or
if this handler does not implement all required handler interfaces
@throws IllegalArgumentException if the specified handlers cannot be combined into one due to a conflict
in the type hierarchy | [
"Initialized",
"this",
"handler",
"with",
"the",
"specified",
"handlers",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java#L68-L72 | train | Initializes the class. | [
30522,
5123,
2345,
11675,
1999,
4183,
1006,
1045,
1999,
15494,
11774,
3917,
1010,
1051,
2041,
15494,
11774,
3917,
1007,
1063,
9398,
3686,
1006,
1999,
15494,
11774,
3917,
1010,
2041,
15494,
11774,
3917,
1007,
1025,
2023,
1012,
1999,
15494,
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/incubator-shardingsphere | sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/sql/statement/tcl/TCLStatement.java | TCLStatement.isTCLUnsafe | public static boolean isTCLUnsafe(final DatabaseType databaseType, final TokenType tokenType, final LexerEngine lexerEngine) {
if (DefaultKeyword.SET.equals(tokenType) || DatabaseType.SQLServer.equals(databaseType) && DefaultKeyword.IF.equals(tokenType)) {
lexerEngine.skipUntil(DefaultKeyword.TRANSACTION, DefaultKeyword.AUTOCOMMIT, DefaultKeyword.IMPLICIT_TRANSACTIONS);
if (!lexerEngine.isEnd()) {
return true;
}
}
return false;
} | java | public static boolean isTCLUnsafe(final DatabaseType databaseType, final TokenType tokenType, final LexerEngine lexerEngine) {
if (DefaultKeyword.SET.equals(tokenType) || DatabaseType.SQLServer.equals(databaseType) && DefaultKeyword.IF.equals(tokenType)) {
lexerEngine.skipUntil(DefaultKeyword.TRANSACTION, DefaultKeyword.AUTOCOMMIT, DefaultKeyword.IMPLICIT_TRANSACTIONS);
if (!lexerEngine.isEnd()) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isTCLUnsafe",
"(",
"final",
"DatabaseType",
"databaseType",
",",
"final",
"TokenType",
"tokenType",
",",
"final",
"LexerEngine",
"lexerEngine",
")",
"{",
"if",
"(",
"DefaultKeyword",
".",
"SET",
".",
"equals",
"(",
"tokenType",
")... | Is TCL statement.
@param databaseType database type
@param tokenType token type
@param lexerEngine lexer engine
@return is TCL or not | [
"Is",
"TCL",
"statement",
"."
] | 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/antlr/sql/statement/tcl/TCLStatement.java#L65-L73 | train | Is the token type TCL unsafe? | [
30522,
2270,
10763,
22017,
20898,
21541,
20464,
4609,
3736,
7959,
1006,
2345,
7809,
13874,
7809,
13874,
1010,
2345,
19204,
13874,
19204,
13874,
1010,
2345,
17244,
7869,
3070,
3170,
17244,
7869,
3070,
3170,
1007,
1063,
2065,
1006,
12398,
14839... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/local/LocalFileSystem.java | LocalFileSystem.getFileBlockLocations | @Override
public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException {
return new BlockLocation[] {
new LocalBlockLocation(hostName, file.getLen())
};
} | java | @Override
public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException {
return new BlockLocation[] {
new LocalBlockLocation(hostName, file.getLen())
};
} | [
"@",
"Override",
"public",
"BlockLocation",
"[",
"]",
"getFileBlockLocations",
"(",
"FileStatus",
"file",
",",
"long",
"start",
",",
"long",
"len",
")",
"throws",
"IOException",
"{",
"return",
"new",
"BlockLocation",
"[",
"]",
"{",
"new",
"LocalBlockLocation",
... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalFileSystem.java#L100-L105 | train | Override this method to return an array of BlockLocations for a file. | [
30522,
1030,
2058,
15637,
2270,
3796,
4135,
10719,
1031,
1033,
2131,
8873,
2571,
23467,
4135,
10719,
2015,
1006,
6764,
29336,
2271,
5371,
1010,
2146,
2707,
1010,
2146,
18798,
1007,
11618,
22834,
10288,
24422,
1063,
2709,
2047,
3796,
4135,
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/convert/Convert.java | Convert.toDouble | public static Double toDouble(Object value, Double defaultValue) {
return convert(Double.class, value, defaultValue);
} | java | public static Double toDouble(Object value, Double defaultValue) {
return convert(Double.class, value, defaultValue);
} | [
"public",
"static",
"Double",
"toDouble",
"(",
"Object",
"value",
",",
"Double",
"defaultValue",
")",
"{",
"return",
"convert",
"(",
"Double",
".",
"class",
",",
"value",
",",
"defaultValue",
")",
";",
"}"
] | 转换为double<br>
如果给定的值为空,或者转换失败,返回默认值<br>
转换失败不会报错
@param value 被转换的值
@param defaultValue 转换错误时的默认值
@return 结果 | [
"转换为double<br",
">",
"如果给定的值为空,或者转换失败,返回默认值<br",
">",
"转换失败不会报错"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/convert/Convert.java#L291-L293 | train | Converts value of type IDENTITY to Double. | [
30522,
2270,
10763,
3313,
28681,
7140,
3468,
1006,
4874,
3643,
1010,
3313,
12398,
10175,
5657,
1007,
1063,
2709,
10463,
1006,
3313,
1012,
2465,
1010,
3643,
1010,
12398,
10175,
5657,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/tuple/Tuple12.java | Tuple12.setFields | public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
this.f0 = value0;
this.f1 = value1;
this.f2 = value2;
this.f3 = value3;
this.f4 = value4;
this.f5 = value5;
this.f6 = value6;
this.f7 = value7;
this.f8 = value8;
this.f9 = value9;
this.f10 = value10;
this.f11 = value11;
} | java | public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
this.f0 = value0;
this.f1 = value1;
this.f2 = value2;
this.f3 = value3;
this.f4 = value4;
this.f5 = value5;
this.f6 = value6;
this.f7 = value7;
this.f8 = value8;
this.f9 = value9;
this.f10 = value10;
this.f11 = value11;
} | [
"public",
"void",
"setFields",
"(",
"T0",
"value0",
",",
"T1",
"value1",
",",
"T2",
"value2",
",",
"T3",
"value3",
",",
"T4",
"value4",
",",
"T5",
"value5",
",",
"T6",
"value6",
",",
"T7",
"value7",
",",
"T8",
"value8",
",",
"T9",
"value9",
",",
"T... | Sets new values to all fields of the tuple.
@param value0 The value for field 0
@param value1 The value for field 1
@param value2 The value for field 2
@param value3 The value for field 3
@param value4 The value for field 4
@param value5 The value for field 5
@param value6 The value for field 6
@param value7 The value for field 7
@param value8 The value for field 8
@param value9 The value for field 9
@param value10 The value for field 10
@param value11 The value for field 11 | [
"Sets",
"new",
"values",
"to",
"all",
"fields",
"of",
"the",
"tuple",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java#L210-L223 | train | Sets the fields of the object to the values of the specified values. | [
30522,
2270,
11675,
2275,
15155,
1006,
1056,
2692,
3643,
2692,
1010,
1056,
2487,
3643,
2487,
1010,
1056,
2475,
3643,
2475,
1010,
1056,
2509,
3643,
2509,
1010,
1056,
2549,
3643,
2549,
1010,
1056,
2629,
3643,
2629,
1010,
1056,
2575,
3643,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-setting/src/main/java/cn/hutool/setting/AbsSetting.java | AbsSetting.getWithLog | public String getWithLog(String key) {
final String value = getStr(key);
if (value == null) {
log.debug("No key define for [{}]!", key);
}
return value;
} | java | public String getWithLog(String key) {
final String value = getStr(key);
if (value == null) {
log.debug("No key define for [{}]!", key);
}
return value;
} | [
"public",
"String",
"getWithLog",
"(",
"String",
"key",
")",
"{",
"final",
"String",
"value",
"=",
"getStr",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"log",
".",
"debug",
"(",
"\"No key define for [{}]!\"",
",",
"key",
")",
";"... | 带有日志提示的get,如果没有定义指定的KEY,则打印debug日志
@param key 键
@return 值 | [
"带有日志提示的get,如果没有定义指定的KEY,则打印debug日志"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/AbsSetting.java#L67-L73 | train | Get a value from the map with a log. | [
30522,
2270,
5164,
2131,
24415,
21197,
1006,
5164,
3145,
1007,
1063,
2345,
5164,
3643,
1027,
4152,
16344,
1006,
3145,
1007,
1025,
2065,
1006,
3643,
1027,
1027,
19701,
1007,
1063,
8833,
1012,
2139,
8569,
2290,
1006,
1000,
2053,
3145,
9375,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.minBy | @SuppressWarnings({ "unchecked", "rawtypes" })
public ReduceOperator<T> minBy(int... fields) {
if (!getType().isTupleType()) {
throw new InvalidProgramException("DataSet#minBy(int...) only works on Tuple types.");
}
return new ReduceOperator<>(this, new SelectByMinFunction(
(TupleTypeInfo) getType(), fields), Utils.getCallLocationName());
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public ReduceOperator<T> minBy(int... fields) {
if (!getType().isTupleType()) {
throw new InvalidProgramException("DataSet#minBy(int...) only works on Tuple types.");
}
return new ReduceOperator<>(this, new SelectByMinFunction(
(TupleTypeInfo) getType(), fields), Utils.getCallLocationName());
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"ReduceOperator",
"<",
"T",
">",
"minBy",
"(",
"int",
"...",
"fields",
")",
"{",
"if",
"(",
"!",
"getType",
"(",
")",
".",
"isTupleType",
"(",
")",
")",
"{",
... | Selects an element with minimum value.
<p>The minimum is computed over the specified fields in lexicographical order.
<p><strong>Example 1</strong>: Given a data set with elements <code>[0, 1], [1, 0]</code>, the
results will be:
<ul>
<li><code>minBy(0)</code>: <code>[0, 1]</code></li>
<li><code>minBy(1)</code>: <code>[1, 0]</code></li>
</ul>
<p><strong>Example 2</strong>: Given a data set with elements <code>[0, 0], [0, 1]</code>, the
results will be:
<ul>
<li><code>minBy(0, 1)</code>: <code>[0, 0]</code></li>
</ul>
<p>If multiple values with minimum value at the specified fields exist, a random one will be
picked.
<p>Internally, this operation is implemented as a {@link ReduceFunction}.
@param fields Field positions to compute the minimum over
@return A {@link ReduceOperator} representing the minimum | [
"Selects",
"an",
"element",
"with",
"minimum",
"value",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/DataSet.java#L522-L530 | train | Select the minimum value of the DataSet by the given fields. | [
30522,
1030,
16081,
9028,
5582,
2015,
1006,
1063,
1000,
4895,
5403,
18141,
30524,
1006,
1007,
1012,
21541,
6279,
7485,
18863,
1006,
1007,
1007,
1063,
5466,
2047,
19528,
21572,
13113,
10288,
24422,
1006,
1000,
2951,
13462,
1001,
8117,
3762,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/NetUtils.java | NetUtils.getAvailablePort | public static int getAvailablePort() {
for (int i = 0; i < 50; i++) {
try (ServerSocket serverSocket = new ServerSocket(0)) {
int port = serverSocket.getLocalPort();
if (port != 0) {
return port;
}
}
catch (IOException ignored) {}
}
throw new RuntimeException("Could not find a free permitted port on the machine.");
} | java | public static int getAvailablePort() {
for (int i = 0; i < 50; i++) {
try (ServerSocket serverSocket = new ServerSocket(0)) {
int port = serverSocket.getLocalPort();
if (port != 0) {
return port;
}
}
catch (IOException ignored) {}
}
throw new RuntimeException("Could not find a free permitted port on the machine.");
} | [
"public",
"static",
"int",
"getAvailablePort",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"50",
";",
"i",
"++",
")",
"{",
"try",
"(",
"ServerSocket",
"serverSocket",
"=",
"new",
"ServerSocket",
"(",
"0",
")",
")",
"{",
"int",
... | Find a non-occupied port.
@return A non-occupied port. | [
"Find",
"a",
"non",
"-",
"occupied",
"port",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/NetUtils.java#L104-L116 | train | Returns the available port on the machine. | [
30522,
2270,
10763,
20014,
2131,
12462,
11733,
3468,
6442,
1006,
1007,
1063,
2005,
1006,
20014,
1045,
1027,
1014,
1025,
1045,
1026,
2753,
1025,
1045,
1009,
1009,
1007,
1063,
3046,
1006,
14903,
7432,
3388,
14903,
7432,
3388,
1027,
2047,
1490... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/hadoop/mapred/HadoopInputFormatBase.java | HadoopInputFormatBase.getFileStats | private FileBaseStatistics getFileStats(FileBaseStatistics cachedStats, org.apache.hadoop.fs.Path[] hadoopFilePaths,
ArrayList<FileStatus> files) throws IOException {
long latestModTime = 0L;
// get the file info and check whether the cached statistics are still valid.
for (org.apache.hadoop.fs.Path hadoopPath : hadoopFilePaths) {
final Path filePath = new Path(hadoopPath.toUri());
final FileSystem fs = FileSystem.get(filePath.toUri());
final FileStatus file = fs.getFileStatus(filePath);
latestModTime = Math.max(latestModTime, file.getModificationTime());
// enumerate all files and check their modification time stamp.
if (file.isDir()) {
FileStatus[] fss = fs.listStatus(filePath);
files.ensureCapacity(files.size() + fss.length);
for (FileStatus s : fss) {
if (!s.isDir()) {
files.add(s);
latestModTime = Math.max(s.getModificationTime(), latestModTime);
}
}
} else {
files.add(file);
}
}
// check whether the cached statistics are still valid, if we have any
if (cachedStats != null && latestModTime <= cachedStats.getLastModificationTime()) {
return cachedStats;
}
// calculate the whole length
long len = 0;
for (FileStatus s : files) {
len += s.getLen();
}
// sanity check
if (len <= 0) {
len = BaseStatistics.SIZE_UNKNOWN;
}
return new FileBaseStatistics(latestModTime, len, BaseStatistics.AVG_RECORD_BYTES_UNKNOWN);
} | java | private FileBaseStatistics getFileStats(FileBaseStatistics cachedStats, org.apache.hadoop.fs.Path[] hadoopFilePaths,
ArrayList<FileStatus> files) throws IOException {
long latestModTime = 0L;
// get the file info and check whether the cached statistics are still valid.
for (org.apache.hadoop.fs.Path hadoopPath : hadoopFilePaths) {
final Path filePath = new Path(hadoopPath.toUri());
final FileSystem fs = FileSystem.get(filePath.toUri());
final FileStatus file = fs.getFileStatus(filePath);
latestModTime = Math.max(latestModTime, file.getModificationTime());
// enumerate all files and check their modification time stamp.
if (file.isDir()) {
FileStatus[] fss = fs.listStatus(filePath);
files.ensureCapacity(files.size() + fss.length);
for (FileStatus s : fss) {
if (!s.isDir()) {
files.add(s);
latestModTime = Math.max(s.getModificationTime(), latestModTime);
}
}
} else {
files.add(file);
}
}
// check whether the cached statistics are still valid, if we have any
if (cachedStats != null && latestModTime <= cachedStats.getLastModificationTime()) {
return cachedStats;
}
// calculate the whole length
long len = 0;
for (FileStatus s : files) {
len += s.getLen();
}
// sanity check
if (len <= 0) {
len = BaseStatistics.SIZE_UNKNOWN;
}
return new FileBaseStatistics(latestModTime, len, BaseStatistics.AVG_RECORD_BYTES_UNKNOWN);
} | [
"private",
"FileBaseStatistics",
"getFileStats",
"(",
"FileBaseStatistics",
"cachedStats",
",",
"org",
".",
"apache",
".",
"hadoop",
".",
"fs",
".",
"Path",
"[",
"]",
"hadoopFilePaths",
",",
"ArrayList",
"<",
"FileStatus",
">",
"files",
")",
"throws",
"IOExcepti... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/HadoopInputFormatBase.java#L207-L254 | train | Get the file stats for the given paths and files. | [
30522,
2797,
5371,
15058,
9153,
16774,
6558,
2131,
8873,
4244,
29336,
2015,
1006,
5371,
15058,
9153,
16774,
6558,
17053,
5104,
29336,
2015,
1010,
8917,
1012,
15895,
1012,
2018,
18589,
1012,
1042,
2015,
1012,
4130,
1031,
1033,
2018,
18589,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java | KeyUtil.generateKeyPair | public static KeyPair generateKeyPair(String algorithm, int keySize, byte[] seed) {
// SM2算法需要单独定义其曲线生成
if ("SM2".equalsIgnoreCase(algorithm)) {
final ECGenParameterSpec sm2p256v1 = new ECGenParameterSpec(SM2_DEFAULT_CURVE);
return generateKeyPair(algorithm, keySize, seed, sm2p256v1);
}
return generateKeyPair(algorithm, keySize, seed, (AlgorithmParameterSpec[]) null);
} | java | public static KeyPair generateKeyPair(String algorithm, int keySize, byte[] seed) {
// SM2算法需要单独定义其曲线生成
if ("SM2".equalsIgnoreCase(algorithm)) {
final ECGenParameterSpec sm2p256v1 = new ECGenParameterSpec(SM2_DEFAULT_CURVE);
return generateKeyPair(algorithm, keySize, seed, sm2p256v1);
}
return generateKeyPair(algorithm, keySize, seed, (AlgorithmParameterSpec[]) null);
} | [
"public",
"static",
"KeyPair",
"generateKeyPair",
"(",
"String",
"algorithm",
",",
"int",
"keySize",
",",
"byte",
"[",
"]",
"seed",
")",
"{",
"// SM2算法需要单独定义其曲线生成\r",
"if",
"(",
"\"SM2\"",
".",
"equalsIgnoreCase",
"(",
"algorithm",
")",
")",
"{",
"final",
"E... | 生成用于非对称加密的公钥和私钥<br>
密钥对生成算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator
@param algorithm 非对称加密算法
@param keySize 密钥模(modulus )长度
@param seed 种子
@return {@link KeyPair} | [
"生成用于非对称加密的公钥和私钥<br",
">",
"密钥对生成算法见:https",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javase",
"/",
"7",
"/",
"docs",
"/",
"technotes",
"/",
"guides",
"/",
"security",
"/",
"StandardNames",
".",
"html#KeyPairGenerator"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java#L345-L353 | train | Generates a KeyPair with the specified key size and seed. | [
30522,
2270,
10763,
3145,
4502,
4313,
9699,
14839,
4502,
4313,
1006,
5164,
9896,
1010,
20014,
6309,
4697,
1010,
24880,
1031,
1033,
6534,
1007,
1063,
1013,
1013,
15488,
2475,
100,
1901,
100,
100,
100,
100,
1822,
100,
100,
1870,
100,
1910,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ExcelPicUtil.java | ExcelPicUtil.getPicMapXlsx | private static Map<String, PictureData> getPicMapXlsx(XSSFWorkbook workbook, int sheetIndex) {
final Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
final XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
XSSFDrawing drawing;
for (POIXMLDocumentPart dr : sheet.getRelations()) {
if (dr instanceof XSSFDrawing) {
drawing = (XSSFDrawing) dr;
final List<XSSFShape> shapes = drawing.getShapes();
XSSFPicture pic;
CTMarker ctMarker;
for (XSSFShape shape : shapes) {
pic = (XSSFPicture) shape;
ctMarker = pic.getPreferredSize().getFrom();
sheetIndexPicMap.put(StrUtil.format("{}_{}", ctMarker.getRow(), ctMarker.getCol()), pic.getPictureData());
}
}
}
return sheetIndexPicMap;
} | java | private static Map<String, PictureData> getPicMapXlsx(XSSFWorkbook workbook, int sheetIndex) {
final Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
final XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
XSSFDrawing drawing;
for (POIXMLDocumentPart dr : sheet.getRelations()) {
if (dr instanceof XSSFDrawing) {
drawing = (XSSFDrawing) dr;
final List<XSSFShape> shapes = drawing.getShapes();
XSSFPicture pic;
CTMarker ctMarker;
for (XSSFShape shape : shapes) {
pic = (XSSFPicture) shape;
ctMarker = pic.getPreferredSize().getFrom();
sheetIndexPicMap.put(StrUtil.format("{}_{}", ctMarker.getRow(), ctMarker.getCol()), pic.getPictureData());
}
}
}
return sheetIndexPicMap;
} | [
"private",
"static",
"Map",
"<",
"String",
",",
"PictureData",
">",
"getPicMapXlsx",
"(",
"XSSFWorkbook",
"workbook",
",",
"int",
"sheetIndex",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"PictureData",
">",
"sheetIndexPicMap",
"=",
"new",
"HashMap",
"<",
... | 获取XLSX工作簿指定sheet中图片列表
@param workbook 工作簿{@link Workbook}
@param sheetIndex sheet的索引
@return 图片映射,键格式:行_列,值:{@link PictureData} | [
"获取XLSX工作簿指定sheet中图片列表"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java#L89-L107 | train | Gets the picture map for a given sheet index. | [
30522,
2797,
10763,
4949,
1026,
5164,
1010,
15885,
6790,
1028,
2131,
24330,
2863,
2361,
2595,
4877,
2595,
1006,
1060,
4757,
2546,
6198,
8654,
2147,
8654,
1010,
20014,
7123,
22254,
10288,
1007,
1063,
2345,
4949,
1026,
5164,
1010,
15885,
6790... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeRow.java | UnsafeRow.copyFrom | public void copyFrom(UnsafeRow row) {
// copyFrom is only available for UnsafeRow created from byte array.
assert (baseObject instanceof byte[]) && baseOffset == Platform.BYTE_ARRAY_OFFSET;
if (row.sizeInBytes > this.sizeInBytes) {
// resize the underlying byte[] if it's not large enough.
this.baseObject = new byte[row.sizeInBytes];
}
Platform.copyMemory(
row.baseObject, row.baseOffset, this.baseObject, this.baseOffset, row.sizeInBytes);
// update the sizeInBytes.
this.sizeInBytes = row.sizeInBytes;
} | java | public void copyFrom(UnsafeRow row) {
// copyFrom is only available for UnsafeRow created from byte array.
assert (baseObject instanceof byte[]) && baseOffset == Platform.BYTE_ARRAY_OFFSET;
if (row.sizeInBytes > this.sizeInBytes) {
// resize the underlying byte[] if it's not large enough.
this.baseObject = new byte[row.sizeInBytes];
}
Platform.copyMemory(
row.baseObject, row.baseOffset, this.baseObject, this.baseOffset, row.sizeInBytes);
// update the sizeInBytes.
this.sizeInBytes = row.sizeInBytes;
} | [
"public",
"void",
"copyFrom",
"(",
"UnsafeRow",
"row",
")",
"{",
"// copyFrom is only available for UnsafeRow created from byte array.",
"assert",
"(",
"baseObject",
"instanceof",
"byte",
"[",
"]",
")",
"&&",
"baseOffset",
"==",
"Platform",
".",
"BYTE_ARRAY_OFFSET",
"",... | Copies the input UnsafeRow to this UnsafeRow, and resize the underlying byte[] when the
input row is larger than this row. | [
"Copies",
"the",
"input",
"UnsafeRow",
"to",
"this",
"UnsafeRow",
"and",
"resize",
"the",
"underlying",
"byte",
"[]",
"when",
"the",
"input",
"row",
"is",
"larger",
"than",
"this",
"row",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeRow.java#L485-L496 | train | Copy the contents of the UnsafeRow to this UnsafeRow. | [
30522,
2270,
11675,
6100,
19699,
5358,
1006,
25135,
10524,
5216,
1007,
1063,
1013,
1013,
6100,
19699,
5358,
2003,
2069,
2800,
2005,
25135,
10524,
2580,
2013,
24880,
9140,
1012,
20865,
1006,
2918,
16429,
20614,
6013,
11253,
24880,
1031,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Util.java | Util.getUUID | public static String getUUID() {
UUID id = UUID.randomUUID();
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(id.getMostSignificantBits());
bb.putLong(id.getLeastSignificantBits());
return Base64.encodeBase64URLSafeString(bb.array());
} | java | public static String getUUID() {
UUID id = UUID.randomUUID();
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(id.getMostSignificantBits());
bb.putLong(id.getLeastSignificantBits());
return Base64.encodeBase64URLSafeString(bb.array());
} | [
"public",
"static",
"String",
"getUUID",
"(",
")",
"{",
"UUID",
"id",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
";",
"ByteBuffer",
"bb",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"new",
"byte",
"[",
"16",
"]",
")",
";",
"bb",
".",
"putLong",
"(",
"id",
... | Generate UUID across the entire app and it is used for correlationId.
@return String correlationId | [
"Generate",
"UUID",
"across",
"the",
"entire",
"app",
"and",
"it",
"is",
"used",
"for",
"correlationId",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/Util.java#L52-L58 | train | Get a UUID as a Base64 encoded string. | [
30522,
2270,
10763,
5164,
2131,
2226,
21272,
1006,
1007,
1063,
1057,
21272,
8909,
1027,
1057,
21272,
1012,
6721,
2226,
21272,
1006,
1007,
1025,
24880,
8569,
12494,
22861,
1027,
24880,
8569,
12494,
1012,
10236,
1006,
2047,
24880,
1031,
2385,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/runtime/operators/windowing/KeyMap.java | KeyMap.traverseAndCountElements | int traverseAndCountElements() {
int num = 0;
for (Entry<?, ?> entry : table) {
while (entry != null) {
num++;
entry = entry.next;
}
}
return num;
} | java | int traverseAndCountElements() {
int num = 0;
for (Entry<?, ?> entry : table) {
while (entry != null) {
num++;
entry = entry.next;
}
}
return num;
} | [
"int",
"traverseAndCountElements",
"(",
")",
"{",
"int",
"num",
"=",
"0",
";",
"for",
"(",
"Entry",
"<",
"?",
",",
"?",
">",
"entry",
":",
"table",
")",
"{",
"while",
"(",
"entry",
"!=",
"null",
")",
"{",
"num",
"++",
";",
"entry",
"=",
"entry",
... | For testing only: Actively counts the number of entries, rather than using the
counter variable. This method has linear complexity, rather than constant.
@return The counted number of entries. | [
"For",
"testing",
"only",
":",
"Actively",
"counts",
"the",
"number",
"of",
"entries",
"rather",
"than",
"using",
"the",
"counter",
"variable",
".",
"This",
"method",
"has",
"linear",
"complexity",
"rather",
"than",
"constant",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/KeyMap.java#L416-L427 | train | Traverses the table and counts the number of elements in the table. | [
30522,
20014,
20811,
5685,
3597,
16671,
12260,
8163,
1006,
1007,
1063,
20014,
16371,
2213,
1027,
1014,
1025,
2005,
1006,
4443,
1026,
1029,
1010,
1029,
1028,
4443,
1024,
2795,
1007,
1063,
2096,
1006,
4443,
999,
1027,
19701,
1007,
1063,
16371... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java | SocksCmdResponse.host | public String host() {
return host != null && addressType == SocksAddressType.DOMAIN ? IDN.toUnicode(host) : host;
} | java | public String host() {
return host != null && addressType == SocksAddressType.DOMAIN ? IDN.toUnicode(host) : host;
} | [
"public",
"String",
"host",
"(",
")",
"{",
"return",
"host",
"!=",
"null",
"&&",
"addressType",
"==",
"SocksAddressType",
".",
"DOMAIN",
"?",
"IDN",
".",
"toUnicode",
"(",
"host",
")",
":",
"host",
";",
"}"
] | Returns host that is used as a parameter in {@link SocksCmdType}.
Host (BND.ADDR field in response) is address that server used when connecting to the target host.
This is typically different from address which client uses to connect to the SOCKS server.
@return host that is used as a parameter in {@link SocksCmdType}
or null when there was no host specified during response construction | [
"Returns",
"host",
"that",
"is",
"used",
"as",
"a",
"parameter",
"in",
"{",
"@link",
"SocksCmdType",
"}",
".",
"Host",
"(",
"BND",
".",
"ADDR",
"field",
"in",
"response",
")",
"is",
"address",
"that",
"server",
"used",
"when",
"connecting",
"to",
"the",
... | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java#L128-L130 | train | Returns the host of the address. | [
30522,
2270,
5164,
3677,
1006,
1007,
1063,
2709,
3677,
999,
1027,
19701,
1004,
1004,
4769,
13874,
1027,
1027,
14829,
4215,
16200,
4757,
13874,
1012,
5884,
1029,
8909,
2078,
1012,
2000,
19496,
16044,
1006,
3677,
1007,
1024,
3677,
1025,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java | TaskMemoryManager.acquireExecutionMemory | public long acquireExecutionMemory(long required, MemoryConsumer consumer) {
assert(required >= 0);
assert(consumer != null);
MemoryMode mode = consumer.getMode();
// If we are allocating Tungsten pages off-heap and receive a request to allocate on-heap
// memory here, then it may not make sense to spill since that would only end up freeing
// off-heap memory. This is subject to change, though, so it may be risky to make this
// optimization now in case we forget to undo it late when making changes.
synchronized (this) {
long got = memoryManager.acquireExecutionMemory(required, taskAttemptId, mode);
// Try to release memory from other consumers first, then we can reduce the frequency of
// spilling, avoid to have too many spilled files.
if (got < required) {
// Call spill() on other consumers to release memory
// Sort the consumers according their memory usage. So we avoid spilling the same consumer
// which is just spilled in last few times and re-spilling on it will produce many small
// spill files.
TreeMap<Long, List<MemoryConsumer>> sortedConsumers = new TreeMap<>();
for (MemoryConsumer c: consumers) {
if (c != consumer && c.getUsed() > 0 && c.getMode() == mode) {
long key = c.getUsed();
List<MemoryConsumer> list =
sortedConsumers.computeIfAbsent(key, k -> new ArrayList<>(1));
list.add(c);
}
}
while (!sortedConsumers.isEmpty()) {
// Get the consumer using the least memory more than the remaining required memory.
Map.Entry<Long, List<MemoryConsumer>> currentEntry =
sortedConsumers.ceilingEntry(required - got);
// No consumer has used memory more than the remaining required memory.
// Get the consumer of largest used memory.
if (currentEntry == null) {
currentEntry = sortedConsumers.lastEntry();
}
List<MemoryConsumer> cList = currentEntry.getValue();
MemoryConsumer c = cList.get(cList.size() - 1);
try {
long released = c.spill(required - got, consumer);
if (released > 0) {
logger.debug("Task {} released {} from {} for {}", taskAttemptId,
Utils.bytesToString(released), c, consumer);
got += memoryManager.acquireExecutionMemory(required - got, taskAttemptId, mode);
if (got >= required) {
break;
}
} else {
cList.remove(cList.size() - 1);
if (cList.isEmpty()) {
sortedConsumers.remove(currentEntry.getKey());
}
}
} catch (ClosedByInterruptException e) {
// This called by user to kill a task (e.g: speculative task).
logger.error("error while calling spill() on " + c, e);
throw new RuntimeException(e.getMessage());
} catch (IOException e) {
logger.error("error while calling spill() on " + c, e);
// checkstyle.off: RegexpSinglelineJava
throw new SparkOutOfMemoryError("error while calling spill() on " + c + " : "
+ e.getMessage());
// checkstyle.on: RegexpSinglelineJava
}
}
}
// call spill() on itself
if (got < required) {
try {
long released = consumer.spill(required - got, consumer);
if (released > 0) {
logger.debug("Task {} released {} from itself ({})", taskAttemptId,
Utils.bytesToString(released), consumer);
got += memoryManager.acquireExecutionMemory(required - got, taskAttemptId, mode);
}
} catch (ClosedByInterruptException e) {
// This called by user to kill a task (e.g: speculative task).
logger.error("error while calling spill() on " + consumer, e);
throw new RuntimeException(e.getMessage());
} catch (IOException e) {
logger.error("error while calling spill() on " + consumer, e);
// checkstyle.off: RegexpSinglelineJava
throw new SparkOutOfMemoryError("error while calling spill() on " + consumer + " : "
+ e.getMessage());
// checkstyle.on: RegexpSinglelineJava
}
}
consumers.add(consumer);
logger.debug("Task {} acquired {} for {}", taskAttemptId, Utils.bytesToString(got), consumer);
return got;
}
} | java | public long acquireExecutionMemory(long required, MemoryConsumer consumer) {
assert(required >= 0);
assert(consumer != null);
MemoryMode mode = consumer.getMode();
// If we are allocating Tungsten pages off-heap and receive a request to allocate on-heap
// memory here, then it may not make sense to spill since that would only end up freeing
// off-heap memory. This is subject to change, though, so it may be risky to make this
// optimization now in case we forget to undo it late when making changes.
synchronized (this) {
long got = memoryManager.acquireExecutionMemory(required, taskAttemptId, mode);
// Try to release memory from other consumers first, then we can reduce the frequency of
// spilling, avoid to have too many spilled files.
if (got < required) {
// Call spill() on other consumers to release memory
// Sort the consumers according their memory usage. So we avoid spilling the same consumer
// which is just spilled in last few times and re-spilling on it will produce many small
// spill files.
TreeMap<Long, List<MemoryConsumer>> sortedConsumers = new TreeMap<>();
for (MemoryConsumer c: consumers) {
if (c != consumer && c.getUsed() > 0 && c.getMode() == mode) {
long key = c.getUsed();
List<MemoryConsumer> list =
sortedConsumers.computeIfAbsent(key, k -> new ArrayList<>(1));
list.add(c);
}
}
while (!sortedConsumers.isEmpty()) {
// Get the consumer using the least memory more than the remaining required memory.
Map.Entry<Long, List<MemoryConsumer>> currentEntry =
sortedConsumers.ceilingEntry(required - got);
// No consumer has used memory more than the remaining required memory.
// Get the consumer of largest used memory.
if (currentEntry == null) {
currentEntry = sortedConsumers.lastEntry();
}
List<MemoryConsumer> cList = currentEntry.getValue();
MemoryConsumer c = cList.get(cList.size() - 1);
try {
long released = c.spill(required - got, consumer);
if (released > 0) {
logger.debug("Task {} released {} from {} for {}", taskAttemptId,
Utils.bytesToString(released), c, consumer);
got += memoryManager.acquireExecutionMemory(required - got, taskAttemptId, mode);
if (got >= required) {
break;
}
} else {
cList.remove(cList.size() - 1);
if (cList.isEmpty()) {
sortedConsumers.remove(currentEntry.getKey());
}
}
} catch (ClosedByInterruptException e) {
// This called by user to kill a task (e.g: speculative task).
logger.error("error while calling spill() on " + c, e);
throw new RuntimeException(e.getMessage());
} catch (IOException e) {
logger.error("error while calling spill() on " + c, e);
// checkstyle.off: RegexpSinglelineJava
throw new SparkOutOfMemoryError("error while calling spill() on " + c + " : "
+ e.getMessage());
// checkstyle.on: RegexpSinglelineJava
}
}
}
// call spill() on itself
if (got < required) {
try {
long released = consumer.spill(required - got, consumer);
if (released > 0) {
logger.debug("Task {} released {} from itself ({})", taskAttemptId,
Utils.bytesToString(released), consumer);
got += memoryManager.acquireExecutionMemory(required - got, taskAttemptId, mode);
}
} catch (ClosedByInterruptException e) {
// This called by user to kill a task (e.g: speculative task).
logger.error("error while calling spill() on " + consumer, e);
throw new RuntimeException(e.getMessage());
} catch (IOException e) {
logger.error("error while calling spill() on " + consumer, e);
// checkstyle.off: RegexpSinglelineJava
throw new SparkOutOfMemoryError("error while calling spill() on " + consumer + " : "
+ e.getMessage());
// checkstyle.on: RegexpSinglelineJava
}
}
consumers.add(consumer);
logger.debug("Task {} acquired {} for {}", taskAttemptId, Utils.bytesToString(got), consumer);
return got;
}
} | [
"public",
"long",
"acquireExecutionMemory",
"(",
"long",
"required",
",",
"MemoryConsumer",
"consumer",
")",
"{",
"assert",
"(",
"required",
">=",
"0",
")",
";",
"assert",
"(",
"consumer",
"!=",
"null",
")",
";",
"MemoryMode",
"mode",
"=",
"consumer",
".",
... | Acquire N bytes of memory for a consumer. If there is no enough memory, it will call
spill() of consumers to release more memory.
@return number of bytes successfully granted (<= N). | [
"Acquire",
"N",
"bytes",
"of",
"memory",
"for",
"a",
"consumer",
".",
"If",
"there",
"is",
"no",
"enough",
"memory",
"it",
"will",
"call",
"spill",
"()",
"of",
"consumers",
"to",
"release",
"more",
"memory",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java#L138-L231 | train | Acquire the memory for the specified task attempt id. | [
30522,
2270,
2146,
9878,
10288,
8586,
13700,
4168,
5302,
2854,
1006,
2146,
3223,
1010,
3638,
8663,
23545,
2099,
7325,
1007,
1063,
20865,
1006,
3223,
1028,
1027,
1014,
1007,
1025,
20865,
1006,
7325,
999,
1027,
19701,
1007,
1025,
3638,
5302,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java | DnsNameResolver.anyInterfaceSupportsIpV6 | private static boolean anyInterfaceSupportsIpV6() {
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface iface = interfaces.nextElement();
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while (addresses.hasMoreElements()) {
if (addresses.nextElement() instanceof Inet6Address) {
return true;
}
}
}
} catch (SocketException e) {
logger.debug("Unable to detect if any interface supports IPv6, assuming IPv4-only", e);
// ignore
}
return false;
} | java | private static boolean anyInterfaceSupportsIpV6() {
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface iface = interfaces.nextElement();
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while (addresses.hasMoreElements()) {
if (addresses.nextElement() instanceof Inet6Address) {
return true;
}
}
}
} catch (SocketException e) {
logger.debug("Unable to detect if any interface supports IPv6, assuming IPv4-only", e);
// ignore
}
return false;
} | [
"private",
"static",
"boolean",
"anyInterfaceSupportsIpV6",
"(",
")",
"{",
"try",
"{",
"Enumeration",
"<",
"NetworkInterface",
">",
"interfaces",
"=",
"NetworkInterface",
".",
"getNetworkInterfaces",
"(",
")",
";",
"while",
"(",
"interfaces",
".",
"hasMoreElements",... | Returns {@code true} if any {@link NetworkInterface} supports {@code IPv6}, {@code false} otherwise. | [
"Returns",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java#L154-L171 | train | Determine if any interface supports IPv6 | [
30522,
2797,
10763,
22017,
20898,
2151,
18447,
2121,
12172,
6342,
9397,
11589,
5332,
2361,
2615,
2575,
1006,
1007,
1063,
3046,
1063,
4372,
17897,
8156,
1026,
2897,
18447,
2121,
12172,
1028,
19706,
1027,
2897,
18447,
2121,
12172,
1012,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/network-common/src/main/java/org/apache/spark/network/sasl/SaslServerBootstrap.java | SaslServerBootstrap.doBootstrap | public RpcHandler doBootstrap(Channel channel, RpcHandler rpcHandler) {
return new SaslRpcHandler(conf, channel, rpcHandler, secretKeyHolder);
} | java | public RpcHandler doBootstrap(Channel channel, RpcHandler rpcHandler) {
return new SaslRpcHandler(conf, channel, rpcHandler, secretKeyHolder);
} | [
"public",
"RpcHandler",
"doBootstrap",
"(",
"Channel",
"channel",
",",
"RpcHandler",
"rpcHandler",
")",
"{",
"return",
"new",
"SaslRpcHandler",
"(",
"conf",
",",
"channel",
",",
"rpcHandler",
",",
"secretKeyHolder",
")",
";",
"}"
] | Wrap the given application handler in a SaslRpcHandler that will handle the initial SASL
negotiation. | [
"Wrap",
"the",
"given",
"application",
"handler",
"in",
"a",
"SaslRpcHandler",
"that",
"will",
"handle",
"the",
"initial",
"SASL",
"negotiation",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/network-common/src/main/java/org/apache/spark/network/sasl/SaslServerBootstrap.java#L45-L47 | train | This method is called by the client when the client is bootstrapped. | [
30522,
2270,
1054,
15042,
11774,
3917,
2079,
27927,
20528,
2361,
1006,
3149,
3149,
1010,
1054,
15042,
11774,
3917,
1054,
15042,
11774,
3917,
1007,
1063,
2709,
2047,
21871,
20974,
15042,
11774,
3917,
1006,
9530,
2546,
1010,
3149,
1010,
1054,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HtmlUtil.java | HtmlUtil.removeHtmlAttr | public static String removeHtmlAttr(String content, String... attrs) {
String regex = null;
for (String attr : attrs) {
regex = StrUtil.format("(?i)\\s*{}=([\"']).*?\\1", attr);
content = content.replaceAll(regex, StrUtil.EMPTY);
}
return content;
} | java | public static String removeHtmlAttr(String content, String... attrs) {
String regex = null;
for (String attr : attrs) {
regex = StrUtil.format("(?i)\\s*{}=([\"']).*?\\1", attr);
content = content.replaceAll(regex, StrUtil.EMPTY);
}
return content;
} | [
"public",
"static",
"String",
"removeHtmlAttr",
"(",
"String",
"content",
",",
"String",
"...",
"attrs",
")",
"{",
"String",
"regex",
"=",
"null",
";",
"for",
"(",
"String",
"attr",
":",
"attrs",
")",
"{",
"regex",
"=",
"StrUtil",
".",
"format",
"(",
"... | 去除HTML标签中的属性
@param content 文本
@param attrs 属性名(不区分大小写)
@return 处理后的文本 | [
"去除HTML标签中的属性"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HtmlUtil.java#L150-L157 | train | Removes the specified HTML attributes from the specified content. | [
30522,
2270,
10763,
5164,
6366,
11039,
19968,
19321,
2099,
1006,
5164,
4180,
1010,
5164,
1012,
1012,
1012,
2012,
16344,
2015,
1007,
1063,
5164,
19723,
10288,
1027,
19701,
1025,
2005,
1006,
5164,
2012,
16344,
1024,
2012,
16344,
2015,
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... |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/operators/base/CoGroupOperatorBase.java | CoGroupOperatorBase.executeOnCollections | @Override
protected List<OUT> executeOnCollections(List<IN1> input1, List<IN2> input2, RuntimeContext ctx, ExecutionConfig executionConfig) throws Exception {
// --------------------------------------------------------------------
// Setup
// --------------------------------------------------------------------
TypeInformation<IN1> inputType1 = getOperatorInfo().getFirstInputType();
TypeInformation<IN2> inputType2 = getOperatorInfo().getSecondInputType();
// for the grouping / merging comparator
int[] inputKeys1 = getKeyColumns(0);
int[] inputKeys2 = getKeyColumns(1);
boolean[] inputDirections1 = new boolean[inputKeys1.length];
boolean[] inputDirections2 = new boolean[inputKeys2.length];
Arrays.fill(inputDirections1, true);
Arrays.fill(inputDirections2, true);
final TypeSerializer<IN1> inputSerializer1 = inputType1.createSerializer(executionConfig);
final TypeSerializer<IN2> inputSerializer2 = inputType2.createSerializer(executionConfig);
final TypeComparator<IN1> inputComparator1 = getTypeComparator(executionConfig, inputType1, inputKeys1, inputDirections1);
final TypeComparator<IN2> inputComparator2 = getTypeComparator(executionConfig, inputType2, inputKeys2, inputDirections2);
final TypeComparator<IN1> inputSortComparator1;
final TypeComparator<IN2> inputSortComparator2;
if (groupOrder1 == null || groupOrder1.getNumberOfFields() == 0) {
// no group sorting
inputSortComparator1 = inputComparator1;
}
else {
// group sorting
int[] groupSortKeys = groupOrder1.getFieldPositions();
int[] allSortKeys = new int[inputKeys1.length + groupOrder1.getNumberOfFields()];
System.arraycopy(inputKeys1, 0, allSortKeys, 0, inputKeys1.length);
System.arraycopy(groupSortKeys, 0, allSortKeys, inputKeys1.length, groupSortKeys.length);
boolean[] groupSortDirections = groupOrder1.getFieldSortDirections();
boolean[] allSortDirections = new boolean[inputKeys1.length + groupSortKeys.length];
Arrays.fill(allSortDirections, 0, inputKeys1.length, true);
System.arraycopy(groupSortDirections, 0, allSortDirections, inputKeys1.length, groupSortDirections.length);
inputSortComparator1 = getTypeComparator(executionConfig, inputType1, allSortKeys, allSortDirections);
}
if (groupOrder2 == null || groupOrder2.getNumberOfFields() == 0) {
// no group sorting
inputSortComparator2 = inputComparator2;
}
else {
// group sorting
int[] groupSortKeys = groupOrder2.getFieldPositions();
int[] allSortKeys = new int[inputKeys2.length + groupOrder2.getNumberOfFields()];
System.arraycopy(inputKeys2, 0, allSortKeys, 0, inputKeys2.length);
System.arraycopy(groupSortKeys, 0, allSortKeys, inputKeys2.length, groupSortKeys.length);
boolean[] groupSortDirections = groupOrder2.getFieldSortDirections();
boolean[] allSortDirections = new boolean[inputKeys2.length + groupSortKeys.length];
Arrays.fill(allSortDirections, 0, inputKeys2.length, true);
System.arraycopy(groupSortDirections, 0, allSortDirections, inputKeys2.length, groupSortDirections.length);
inputSortComparator2 = getTypeComparator(executionConfig, inputType2, allSortKeys, allSortDirections);
}
CoGroupSortListIterator<IN1, IN2> coGroupIterator =
new CoGroupSortListIterator<IN1, IN2>(input1, inputSortComparator1, inputComparator1, inputSerializer1,
input2, inputSortComparator2, inputComparator2, inputSerializer2);
// --------------------------------------------------------------------
// Run UDF
// --------------------------------------------------------------------
CoGroupFunction<IN1, IN2, OUT> function = userFunction.getUserCodeObject();
FunctionUtils.setFunctionRuntimeContext(function, ctx);
FunctionUtils.openFunction(function, parameters);
List<OUT> result = new ArrayList<OUT>();
Collector<OUT> resultCollector = new CopyingListCollector<OUT>(result, getOperatorInfo().getOutputType().createSerializer(executionConfig));
while (coGroupIterator.next()) {
function.coGroup(coGroupIterator.getValues1(), coGroupIterator.getValues2(), resultCollector);
}
FunctionUtils.closeFunction(function);
return result;
} | java | @Override
protected List<OUT> executeOnCollections(List<IN1> input1, List<IN2> input2, RuntimeContext ctx, ExecutionConfig executionConfig) throws Exception {
// --------------------------------------------------------------------
// Setup
// --------------------------------------------------------------------
TypeInformation<IN1> inputType1 = getOperatorInfo().getFirstInputType();
TypeInformation<IN2> inputType2 = getOperatorInfo().getSecondInputType();
// for the grouping / merging comparator
int[] inputKeys1 = getKeyColumns(0);
int[] inputKeys2 = getKeyColumns(1);
boolean[] inputDirections1 = new boolean[inputKeys1.length];
boolean[] inputDirections2 = new boolean[inputKeys2.length];
Arrays.fill(inputDirections1, true);
Arrays.fill(inputDirections2, true);
final TypeSerializer<IN1> inputSerializer1 = inputType1.createSerializer(executionConfig);
final TypeSerializer<IN2> inputSerializer2 = inputType2.createSerializer(executionConfig);
final TypeComparator<IN1> inputComparator1 = getTypeComparator(executionConfig, inputType1, inputKeys1, inputDirections1);
final TypeComparator<IN2> inputComparator2 = getTypeComparator(executionConfig, inputType2, inputKeys2, inputDirections2);
final TypeComparator<IN1> inputSortComparator1;
final TypeComparator<IN2> inputSortComparator2;
if (groupOrder1 == null || groupOrder1.getNumberOfFields() == 0) {
// no group sorting
inputSortComparator1 = inputComparator1;
}
else {
// group sorting
int[] groupSortKeys = groupOrder1.getFieldPositions();
int[] allSortKeys = new int[inputKeys1.length + groupOrder1.getNumberOfFields()];
System.arraycopy(inputKeys1, 0, allSortKeys, 0, inputKeys1.length);
System.arraycopy(groupSortKeys, 0, allSortKeys, inputKeys1.length, groupSortKeys.length);
boolean[] groupSortDirections = groupOrder1.getFieldSortDirections();
boolean[] allSortDirections = new boolean[inputKeys1.length + groupSortKeys.length];
Arrays.fill(allSortDirections, 0, inputKeys1.length, true);
System.arraycopy(groupSortDirections, 0, allSortDirections, inputKeys1.length, groupSortDirections.length);
inputSortComparator1 = getTypeComparator(executionConfig, inputType1, allSortKeys, allSortDirections);
}
if (groupOrder2 == null || groupOrder2.getNumberOfFields() == 0) {
// no group sorting
inputSortComparator2 = inputComparator2;
}
else {
// group sorting
int[] groupSortKeys = groupOrder2.getFieldPositions();
int[] allSortKeys = new int[inputKeys2.length + groupOrder2.getNumberOfFields()];
System.arraycopy(inputKeys2, 0, allSortKeys, 0, inputKeys2.length);
System.arraycopy(groupSortKeys, 0, allSortKeys, inputKeys2.length, groupSortKeys.length);
boolean[] groupSortDirections = groupOrder2.getFieldSortDirections();
boolean[] allSortDirections = new boolean[inputKeys2.length + groupSortKeys.length];
Arrays.fill(allSortDirections, 0, inputKeys2.length, true);
System.arraycopy(groupSortDirections, 0, allSortDirections, inputKeys2.length, groupSortDirections.length);
inputSortComparator2 = getTypeComparator(executionConfig, inputType2, allSortKeys, allSortDirections);
}
CoGroupSortListIterator<IN1, IN2> coGroupIterator =
new CoGroupSortListIterator<IN1, IN2>(input1, inputSortComparator1, inputComparator1, inputSerializer1,
input2, inputSortComparator2, inputComparator2, inputSerializer2);
// --------------------------------------------------------------------
// Run UDF
// --------------------------------------------------------------------
CoGroupFunction<IN1, IN2, OUT> function = userFunction.getUserCodeObject();
FunctionUtils.setFunctionRuntimeContext(function, ctx);
FunctionUtils.openFunction(function, parameters);
List<OUT> result = new ArrayList<OUT>();
Collector<OUT> resultCollector = new CopyingListCollector<OUT>(result, getOperatorInfo().getOutputType().createSerializer(executionConfig));
while (coGroupIterator.next()) {
function.coGroup(coGroupIterator.getValues1(), coGroupIterator.getValues2(), resultCollector);
}
FunctionUtils.closeFunction(function);
return result;
} | [
"@",
"Override",
"protected",
"List",
"<",
"OUT",
">",
"executeOnCollections",
"(",
"List",
"<",
"IN1",
">",
"input1",
",",
"List",
"<",
"IN2",
">",
"input2",
",",
"RuntimeContext",
"ctx",
",",
"ExecutionConfig",
"executionConfig",
")",
"throws",
"Exception",
... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/operators/base/CoGroupOperatorBase.java#L191-L277 | train | Override this method to perform the actual processing of the CRUD operations. | [
30522,
1030,
2058,
15637,
5123,
2862,
1026,
2041,
1028,
15389,
2239,
26895,
18491,
2015,
1006,
2862,
1026,
1999,
2487,
1028,
7953,
2487,
1010,
2862,
1026,
1999,
2475,
1028,
7953,
2475,
1010,
2448,
7292,
8663,
18209,
14931,
2595,
1010,
7781,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spring-projects/spring-boot | spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java | CommandRunner.addCommands | public void addCommands(Iterable<Command> commands) {
Assert.notNull(commands, "Commands must not be null");
for (Command command : commands) {
addCommand(command);
}
} | java | public void addCommands(Iterable<Command> commands) {
Assert.notNull(commands, "Commands must not be null");
for (Command command : commands) {
addCommand(command);
}
} | [
"public",
"void",
"addCommands",
"(",
"Iterable",
"<",
"Command",
">",
"commands",
")",
"{",
"Assert",
".",
"notNull",
"(",
"commands",
",",
"\"Commands must not be null\"",
")",
";",
"for",
"(",
"Command",
"command",
":",
"commands",
")",
"{",
"addCommand",
... | Add the specified commands.
@param commands the commands to add | [
"Add",
"the",
"specified",
"commands",
"."
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java#L73-L78 | train | Adds commands to the command list. | [
30522,
2270,
11675,
5587,
9006,
2386,
5104,
1006,
2009,
6906,
3468,
1026,
3094,
1028,
10954,
1007,
1063,
20865,
1012,
2025,
11231,
3363,
1006,
10954,
1010,
1000,
10954,
2442,
2025,
2022,
19701,
1000,
1007,
1025,
2005,
1006,
3094,
3094,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-optimizer/src/main/java/org/apache/flink/optimizer/dag/DataSinkNode.java | DataSinkNode.accept | @Override
public void accept(Visitor<OptimizerNode> visitor) {
if (visitor.preVisit(this)) {
if (getPredecessorNode() != null) {
getPredecessorNode().accept(visitor);
} else {
throw new CompilerException();
}
visitor.postVisit(this);
}
} | java | @Override
public void accept(Visitor<OptimizerNode> visitor) {
if (visitor.preVisit(this)) {
if (getPredecessorNode() != null) {
getPredecessorNode().accept(visitor);
} else {
throw new CompilerException();
}
visitor.postVisit(this);
}
} | [
"@",
"Override",
"public",
"void",
"accept",
"(",
"Visitor",
"<",
"OptimizerNode",
">",
"visitor",
")",
"{",
"if",
"(",
"visitor",
".",
"preVisit",
"(",
"this",
")",
")",
"{",
"if",
"(",
"getPredecessorNode",
"(",
")",
"!=",
"null",
")",
"{",
"getPrede... | -------------------------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/dag/DataSinkNode.java#L244-L254 | train | Visit this node. | [
30522,
1030,
2058,
15637,
2270,
11675,
5138,
1006,
10367,
1026,
23569,
27605,
6290,
3630,
3207,
1028,
10367,
1007,
1063,
2065,
1006,
10367,
1012,
3653,
11365,
4183,
1006,
2023,
1007,
1007,
1063,
2065,
1006,
2131,
28139,
3207,
9623,
21748,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-shardingsphere | sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/encrypt/ShardingEncryptorStrategy.java | ShardingEncryptorStrategy.getAssistedQueryColumn | public Optional<String> getAssistedQueryColumn(final String logicTableName, final String columnName) {
if (assistedQueryColumns.isEmpty()) {
return Optional.absent();
}
for (ColumnNode each : columns) {
ColumnNode target = new ColumnNode(logicTableName, columnName);
if (each.equals(target)) {
return Optional.of(assistedQueryColumns.get(columns.indexOf(target)).getColumnName());
}
}
return Optional.absent();
} | java | public Optional<String> getAssistedQueryColumn(final String logicTableName, final String columnName) {
if (assistedQueryColumns.isEmpty()) {
return Optional.absent();
}
for (ColumnNode each : columns) {
ColumnNode target = new ColumnNode(logicTableName, columnName);
if (each.equals(target)) {
return Optional.of(assistedQueryColumns.get(columns.indexOf(target)).getColumnName());
}
}
return Optional.absent();
} | [
"public",
"Optional",
"<",
"String",
">",
"getAssistedQueryColumn",
"(",
"final",
"String",
"logicTableName",
",",
"final",
"String",
"columnName",
")",
"{",
"if",
"(",
"assistedQueryColumns",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"abs... | Get assisted query column.
@param logicTableName logic table name
@param columnName column name
@return assisted query column | [
"Get",
"assisted",
"query",
"column",
"."
] | f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/encrypt/ShardingEncryptorStrategy.java#L107-L118 | train | Gets the assisted query column name. | [
30522,
2270,
11887,
1026,
5164,
1028,
2131,
12054,
27870,
2094,
4226,
2854,
25778,
2819,
2078,
1006,
2345,
5164,
7961,
10880,
18442,
1010,
2345,
5164,
5930,
18442,
1007,
1063,
2065,
1006,
7197,
4226,
2854,
25778,
2819,
3619,
1012,
2003,
663... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/hashtable/BaseHybridHashTable.java | BaseHybridHashTable.ensureNumBuffersReturned | public void ensureNumBuffersReturned(final int minRequiredAvailable) {
if (minRequiredAvailable > this.availableMemory.size() + this.buildSpillRetBufferNumbers) {
throw new IllegalArgumentException("More buffers requested available than totally available.");
}
try {
while (this.availableMemory.size() < minRequiredAvailable) {
this.availableMemory.add(this.buildSpillReturnBuffers.take());
this.buildSpillRetBufferNumbers--;
}
} catch (InterruptedException iex) {
throw new RuntimeException("Hash Join was interrupted.");
}
} | java | public void ensureNumBuffersReturned(final int minRequiredAvailable) {
if (minRequiredAvailable > this.availableMemory.size() + this.buildSpillRetBufferNumbers) {
throw new IllegalArgumentException("More buffers requested available than totally available.");
}
try {
while (this.availableMemory.size() < minRequiredAvailable) {
this.availableMemory.add(this.buildSpillReturnBuffers.take());
this.buildSpillRetBufferNumbers--;
}
} catch (InterruptedException iex) {
throw new RuntimeException("Hash Join was interrupted.");
}
} | [
"public",
"void",
"ensureNumBuffersReturned",
"(",
"final",
"int",
"minRequiredAvailable",
")",
"{",
"if",
"(",
"minRequiredAvailable",
">",
"this",
".",
"availableMemory",
".",
"size",
"(",
")",
"+",
"this",
".",
"buildSpillRetBufferNumbers",
")",
"{",
"throw",
... | This method makes sure that at least a certain number of memory segments is in the list of
free segments.
Free memory can be in the list of free segments, or in the return-queue where segments used
to write behind are
put. The number of segments that are in that return-queue, but are actually reclaimable is
tracked. This method
makes sure at least a certain number of buffers is reclaimed.
@param minRequiredAvailable The minimum number of buffers that needs to be reclaimed. | [
"This",
"method",
"makes",
"sure",
"that",
"at",
"least",
"a",
"certain",
"number",
"of",
"memory",
"segments",
"is",
"in",
"the",
"list",
"of",
"free",
"segments",
".",
"Free",
"memory",
"can",
"be",
"in",
"the",
"list",
"of",
"free",
"segments",
"or",
... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/hashtable/BaseHybridHashTable.java#L420-L433 | train | Ensure that the number of buffers returned by the hash join has been requested. | [
30522,
2270,
11675,
5676,
19172,
8569,
12494,
21338,
3388,
21737,
2094,
1006,
2345,
20014,
8117,
2890,
15549,
5596,
12462,
11733,
3468,
1007,
1063,
2065,
30524,
2800,
1012,
1000,
1007,
1025,
1065,
3046,
1063,
2096,
1006,
2023,
1012,
2800,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java | ByteToMessageDecoder.fireChannelRead | static void fireChannelRead(ChannelHandlerContext ctx, List<Object> msgs, int numElements) {
if (msgs instanceof CodecOutputList) {
fireChannelRead(ctx, (CodecOutputList) msgs, numElements);
} else {
for (int i = 0; i < numElements; i++) {
ctx.fireChannelRead(msgs.get(i));
}
}
} | java | static void fireChannelRead(ChannelHandlerContext ctx, List<Object> msgs, int numElements) {
if (msgs instanceof CodecOutputList) {
fireChannelRead(ctx, (CodecOutputList) msgs, numElements);
} else {
for (int i = 0; i < numElements; i++) {
ctx.fireChannelRead(msgs.get(i));
}
}
} | [
"static",
"void",
"fireChannelRead",
"(",
"ChannelHandlerContext",
"ctx",
",",
"List",
"<",
"Object",
">",
"msgs",
",",
"int",
"numElements",
")",
"{",
"if",
"(",
"msgs",
"instanceof",
"CodecOutputList",
")",
"{",
"fireChannelRead",
"(",
"ctx",
",",
"(",
"Co... | Get {@code numElements} out of the {@link List} and forward these through the pipeline. | [
"Get",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java#L308-L316 | train | Fire channel read event. | [
30522,
10763,
11675,
2543,
26058,
16416,
2094,
1006,
3149,
11774,
3917,
8663,
18209,
14931,
2595,
1010,
2862,
1026,
4874,
1028,
5796,
5620,
1010,
20014,
16371,
10199,
13665,
2015,
1007,
1063,
2065,
1006,
5796,
5620,
6013,
11253,
3642,
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/convert/AbstractConverter.java | AbstractConverter.convertToStr | protected String convertToStr(Object value) {
if (null == value) {
return null;
}
if (value instanceof CharSequence) {
return value.toString();
} else if (ArrayUtil.isArray(value)) {
return ArrayUtil.toString(value);
} else if(CharUtil.isChar(value)) {
//对于ASCII字符使用缓存加速转换,减少空间创建
return CharUtil.toString((char)value);
}
return value.toString();
} | java | protected String convertToStr(Object value) {
if (null == value) {
return null;
}
if (value instanceof CharSequence) {
return value.toString();
} else if (ArrayUtil.isArray(value)) {
return ArrayUtil.toString(value);
} else if(CharUtil.isChar(value)) {
//对于ASCII字符使用缓存加速转换,减少空间创建
return CharUtil.toString((char)value);
}
return value.toString();
} | [
"protected",
"String",
"convertToStr",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"null",
"==",
"value",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"value",
"instanceof",
"CharSequence",
")",
"{",
"return",
"value",
".",
"toString",
"(",
")",
"... | 值转为String,用于内部转换中需要使用String中转的情况<br>
转换规则为:
<pre>
1、字符串类型将被强转
2、数组将被转换为逗号分隔的字符串
3、其它类型将调用默认的toString()方法
</pre>
@param value 值
@return String | [
"值转为String,用于内部转换中需要使用String中转的情况<br",
">",
"转换规则为:"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/convert/AbstractConverter.java#L90-L103 | train | Converts the given value to a String. | [
30522,
5123,
5164,
10463,
13122,
16344,
1006,
4874,
3643,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
3643,
1007,
1063,
2709,
19701,
1025,
1065,
2065,
1006,
3643,
6013,
11253,
25869,
3366,
4226,
5897,
1007,
1063,
2709,
3643,
1012,
2000,
3367... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/AbstractMergeIterator.java | AbstractMergeIterator.crossFirst1withNValues | private void crossFirst1withNValues(final T1 val1, final T2 firstValN,
final Iterator<T2> valsN, final FlatJoinFunction<T1, T2, O> joinFunction, final Collector<O> collector)
throws Exception {
T1 copy1 = createCopy(serializer1, val1, this.copy1);
joinFunction.join(copy1, firstValN, collector);
// set copy and join first element
boolean more = true;
do {
final T2 nRec = valsN.next();
if (valsN.hasNext()) {
copy1 = createCopy(serializer1, val1, this.copy1);
joinFunction.join(copy1, nRec, collector);
} else {
joinFunction.join(val1, nRec, collector);
more = false;
}
}
while (more);
} | java | private void crossFirst1withNValues(final T1 val1, final T2 firstValN,
final Iterator<T2> valsN, final FlatJoinFunction<T1, T2, O> joinFunction, final Collector<O> collector)
throws Exception {
T1 copy1 = createCopy(serializer1, val1, this.copy1);
joinFunction.join(copy1, firstValN, collector);
// set copy and join first element
boolean more = true;
do {
final T2 nRec = valsN.next();
if (valsN.hasNext()) {
copy1 = createCopy(serializer1, val1, this.copy1);
joinFunction.join(copy1, nRec, collector);
} else {
joinFunction.join(val1, nRec, collector);
more = false;
}
}
while (more);
} | [
"private",
"void",
"crossFirst1withNValues",
"(",
"final",
"T1",
"val1",
",",
"final",
"T2",
"firstValN",
",",
"final",
"Iterator",
"<",
"T2",
">",
"valsN",
",",
"final",
"FlatJoinFunction",
"<",
"T1",
",",
"T2",
",",
"O",
">",
"joinFunction",
",",
"final"... | Crosses a single value from the first input with N values, all sharing a common key.
Effectively realizes a <i>1:N</i> join.
@param val1 The value form the <i>1</i> side.
@param firstValN The first of the values from the <i>N</i> side.
@param valsN Iterator over remaining <i>N</i> side values.
@throws Exception Forwards all exceptions thrown by the stub. | [
"Crosses",
"a",
"single",
"value",
"from",
"the",
"first",
"input",
"with",
"N",
"values",
"all",
"sharing",
"a",
"common",
"key",
".",
"Effectively",
"realizes",
"a",
"<i",
">",
"1",
":",
"N<",
"/",
"i",
">",
"join",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/AbstractMergeIterator.java#L169-L189 | train | Cross first 1 with N values. | [
30522,
2797,
11675,
2892,
8873,
12096,
2487,
24415,
2078,
10175,
15808,
1006,
2345,
1056,
2487,
11748,
2487,
1010,
2345,
1056,
2475,
2034,
10175,
2078,
1010,
2345,
2009,
6906,
4263,
1026,
1056,
2475,
1028,
11748,
2015,
2078,
1010,
2345,
425... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Console.java | Console.print | public static void print(String template, Object... values) {
out.print(StrUtil.format(template, values));
} | java | public static void print(String template, Object... values) {
out.print(StrUtil.format(template, values));
} | [
"public",
"static",
"void",
"print",
"(",
"String",
"template",
",",
"Object",
"...",
"values",
")",
"{",
"out",
".",
"print",
"(",
"StrUtil",
".",
"format",
"(",
"template",
",",
"values",
")",
")",
";",
"}"
] | 同 System.out.print()方法,打印控制台日志
@param template 文本模板,被替换的部分用 {} 表示
@param values 值
@since 3.3.1 | [
"同",
"System",
".",
"out",
".",
"print",
"()",
"方法,打印控制台日志"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Console.java#L96-L98 | train | Print a template with the values. | [
30522,
2270,
10763,
11675,
6140,
1006,
5164,
23561,
1010,
4874,
1012,
1012,
1012,
5300,
1007,
1063,
2041,
1012,
6140,
1006,
2358,
22134,
4014,
1012,
4289,
1006,
23561,
1010,
5300,
1007,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/sketch/src/main/java/org/apache/spark/util/sketch/BloomFilter.java | BloomFilter.create | public static BloomFilter create(long expectedNumItems, double fpp) {
if (fpp <= 0D || fpp >= 1D) {
throw new IllegalArgumentException(
"False positive probability must be within range (0.0, 1.0)"
);
}
return create(expectedNumItems, optimalNumOfBits(expectedNumItems, fpp));
} | java | public static BloomFilter create(long expectedNumItems, double fpp) {
if (fpp <= 0D || fpp >= 1D) {
throw new IllegalArgumentException(
"False positive probability must be within range (0.0, 1.0)"
);
}
return create(expectedNumItems, optimalNumOfBits(expectedNumItems, fpp));
} | [
"public",
"static",
"BloomFilter",
"create",
"(",
"long",
"expectedNumItems",
",",
"double",
"fpp",
")",
"{",
"if",
"(",
"fpp",
"<=",
"0D",
"||",
"fpp",
">=",
"1D",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"False positive probability must be ... | Creates a {@link BloomFilter} with the expected number of insertions and expected false
positive probability.
Note that overflowing a {@code BloomFilter} with significantly more elements than specified,
will result in its saturation, and a sharp deterioration of its false positive probability. | [
"Creates",
"a",
"{",
"@link",
"BloomFilter",
"}",
"with",
"the",
"expected",
"number",
"of",
"insertions",
"and",
"expected",
"false",
"positive",
"probability",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/sketch/src/main/java/org/apache/spark/util/sketch/BloomFilter.java#L211-L219 | train | Create a BloomFilter with the given number of items and false positive probability. | [
30522,
2270,
10763,
13426,
8873,
21928,
3443,
1006,
2146,
3517,
19172,
4221,
5244,
1010,
3313,
1042,
9397,
1007,
1063,
2065,
1006,
1042,
9397,
1026,
1027,
1014,
2094,
1064,
1064,
1042,
9397,
1028,
1027,
1015,
2094,
1007,
1063,
5466,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.readUtf8Lines | public static <T extends Collection<String>> T readUtf8Lines(File file, T collection) throws IORuntimeException {
return readLines(file, CharsetUtil.CHARSET_UTF_8, collection);
} | java | public static <T extends Collection<String>> T readUtf8Lines(File file, T collection) throws IORuntimeException {
return readLines(file, CharsetUtil.CHARSET_UTF_8, collection);
} | [
"public",
"static",
"<",
"T",
"extends",
"Collection",
"<",
"String",
">",
">",
"T",
"readUtf8Lines",
"(",
"File",
"file",
",",
"T",
"collection",
")",
"throws",
"IORuntimeException",
"{",
"return",
"readLines",
"(",
"file",
",",
"CharsetUtil",
".",
"CHARSET... | 从文件中读取每一行数据,数据编码为UTF-8
@param <T> 集合类型
@param file 文件路径
@param collection 集合
@return 文件中的每行内容的集合
@throws IORuntimeException IO异常
@since 3.1.1 | [
"从文件中读取每一行数据,数据编码为UTF",
"-",
"8"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2206-L2208 | train | Reads a file of UTF - 8 lines into a collection. | [
30522,
2270,
10763,
1026,
1056,
30524,
4904,
2546,
2620,
12735,
1006,
5371,
5371,
1010,
1056,
3074,
1007,
11618,
22834,
15532,
7292,
10288,
24422,
1063,
2709,
3191,
12735,
1006,
5371,
1010,
25869,
13462,
21823,
2140,
1012,
25869,
13462,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java | Configuration.addDeprecation | public static void addDeprecation(String key, String newKey,
String customMessage) {
addDeprecation(key, new String[] {newKey}, customMessage);
} | java | public static void addDeprecation(String key, String newKey,
String customMessage) {
addDeprecation(key, new String[] {newKey}, customMessage);
} | [
"public",
"static",
"void",
"addDeprecation",
"(",
"String",
"key",
",",
"String",
"newKey",
",",
"String",
"customMessage",
")",
"{",
"addDeprecation",
"(",
"key",
",",
"new",
"String",
"[",
"]",
"{",
"newKey",
"}",
",",
"customMessage",
")",
";",
"}"
] | Adds the deprecated key to the global deprecation map.
It does not override any existing entries in the deprecation map.
This is to be used only by the developers in order to add deprecation of
keys, and attempts to call this method after loading resources once,
would lead to <tt>UnsupportedOperationException</tt>
If you have multiple deprecation entries to add, it is more efficient to
use #addDeprecations(DeprecationDelta[] deltas) instead.
@param key
@param newKey
@param customMessage | [
"Adds",
"the",
"deprecated",
"key",
"to",
"the",
"global",
"deprecation",
"map",
".",
"It",
"does",
"not",
"override",
"any",
"existing",
"entries",
"in",
"the",
"deprecation",
"map",
".",
"This",
"is",
"to",
"be",
"used",
"only",
"by",
"the",
"developers"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L506-L509 | train | Add a deprecation message for the given key. | [
30522,
2270,
10763,
11675,
5587,
3207,
28139,
10719,
1006,
5164,
3145,
1010,
5164,
2047,
14839,
1010,
5164,
7661,
7834,
3736,
3351,
1007,
1063,
5587,
3207,
28139,
10719,
1006,
3145,
1010,
2047,
5164,
1031,
1033,
1063,
2047,
14839,
1065,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-mesos/src/main/java/org/apache/flink/mesos/Utils.java | Utils.ports | public static Protos.Resource ports(String role, Protos.Value.Range... ranges) {
return ranges("ports", role, ranges);
} | java | public static Protos.Resource ports(String role, Protos.Value.Range... ranges) {
return ranges("ports", role, ranges);
} | [
"public",
"static",
"Protos",
".",
"Resource",
"ports",
"(",
"String",
"role",
",",
"Protos",
".",
"Value",
".",
"Range",
"...",
"ranges",
")",
"{",
"return",
"ranges",
"(",
"\"ports\"",
",",
"role",
",",
"ranges",
")",
";",
"}"
] | Construct a port resource. | [
"Construct",
"a",
"port",
"resource",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-mesos/src/main/java/org/apache/flink/mesos/Utils.java#L178-L180 | train | Create a ports resource. | [
30522,
2270,
10763,
15053,
2015,
1012,
7692,
8831,
1006,
5164,
2535,
1010,
15053,
2015,
1012,
3643,
1012,
2846,
1012,
1012,
1012,
8483,
1007,
1063,
2709,
8483,
1006,
1000,
8831,
1000,
1010,
2535,
1010,
8483,
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... |
redisson/redisson | redisson/src/main/java/org/redisson/Redisson.java | Redisson.createReactive | public static RedissonReactiveClient createReactive(Config config) {
RedissonReactive react = new RedissonReactive(config);
if (config.isReferenceEnabled()) {
react.enableRedissonReferenceSupport();
}
return react;
} | java | public static RedissonReactiveClient createReactive(Config config) {
RedissonReactive react = new RedissonReactive(config);
if (config.isReferenceEnabled()) {
react.enableRedissonReferenceSupport();
}
return react;
} | [
"public",
"static",
"RedissonReactiveClient",
"createReactive",
"(",
"Config",
"config",
")",
"{",
"RedissonReactive",
"react",
"=",
"new",
"RedissonReactive",
"(",
"config",
")",
";",
"if",
"(",
"config",
".",
"isReferenceEnabled",
"(",
")",
")",
"{",
"react",
... | Create Reactive Redisson instance with provided config
@param config for Redisson
@return Redisson instance | [
"Create",
"Reactive",
"Redisson",
"instance",
"with",
"provided",
"config"
] | d3acc0249b2d5d658d36d99e2c808ce49332ea44 | https://github.com/redisson/redisson/blob/d3acc0249b2d5d658d36d99e2c808ce49332ea44/redisson/src/main/java/org/redisson/Redisson.java#L209-L215 | train | Create a RedissonReactive client. | [
30522,
2270,
10763,
2417,
24077,
16416,
15277,
20464,
11638,
3443,
16416,
15277,
1006,
9530,
8873,
2290,
9530,
8873,
2290,
1007,
1063,
2417,
24077,
16416,
15277,
10509,
1027,
2047,
2417,
24077,
16416,
15277,
1006,
9530,
8873,
2290,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/Sign.java | Sign.init | @Override
public Sign init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
try {
signature = Signature.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
super.init(algorithm, privateKey, publicKey);
return this;
} | java | @Override
public Sign init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
try {
signature = Signature.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
super.init(algorithm, privateKey, publicKey);
return this;
} | [
"@",
"Override",
"public",
"Sign",
"init",
"(",
"String",
"algorithm",
",",
"PrivateKey",
"privateKey",
",",
"PublicKey",
"publicKey",
")",
"{",
"try",
"{",
"signature",
"=",
"Signature",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"}",
"catch",
"(",
"... | 初始化
@param algorithm 算法
@param privateKey 私钥
@param publicKey 公钥
@return this | [
"初始化"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/Sign.java#L157-L166 | train | Initializes the signature object. | [
30522,
1030,
2058,
15637,
2270,
3696,
1999,
4183,
1006,
5164,
9896,
1010,
2797,
14839,
2797,
14839,
1010,
2270,
14839,
2270,
14839,
1007,
1063,
3046,
1063,
8085,
1027,
8085,
1012,
2131,
7076,
26897,
1006,
9896,
1007,
1025,
1065,
4608,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-poi/src/main/java/cn/hutool/poi/excel/style/StyleUtil.java | StyleUtil.cloneCellStyle | public static CellStyle cloneCellStyle(Cell cell, CellStyle cellStyle) {
return cloneCellStyle(cell.getSheet().getWorkbook(), cellStyle);
} | java | public static CellStyle cloneCellStyle(Cell cell, CellStyle cellStyle) {
return cloneCellStyle(cell.getSheet().getWorkbook(), cellStyle);
} | [
"public",
"static",
"CellStyle",
"cloneCellStyle",
"(",
"Cell",
"cell",
",",
"CellStyle",
"cellStyle",
")",
"{",
"return",
"cloneCellStyle",
"(",
"cell",
".",
"getSheet",
"(",
")",
".",
"getWorkbook",
"(",
")",
",",
"cellStyle",
")",
";",
"}"
] | 克隆新的{@link CellStyle}
@param cell 单元格
@param cellStyle 被复制的样式
@return {@link CellStyle} | [
"克隆新的",
"{",
"@link",
"CellStyle",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/style/StyleUtil.java#L30-L32 | train | Clones a CellStyle object. | [
30522,
2270,
10763,
4442,
27983,
17598,
29109,
4877,
27983,
1006,
3526,
3526,
1010,
4442,
27983,
4442,
27983,
1007,
1063,
2709,
17598,
29109,
4877,
27983,
1006,
3526,
1012,
4152,
21030,
2102,
1006,
1007,
1012,
2131,
6198,
8654,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/spark | common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java | ExternalShuffleBlockResolver.getFile | @VisibleForTesting
static File getFile(String[] localDirs, int subDirsPerLocalDir, String filename) {
int hash = JavaUtils.nonNegativeHash(filename);
String localDir = localDirs[hash % localDirs.length];
int subDirId = (hash / localDirs.length) % subDirsPerLocalDir;
return new File(createNormalizedInternedPathname(
localDir, String.format("%02x", subDirId), filename));
} | java | @VisibleForTesting
static File getFile(String[] localDirs, int subDirsPerLocalDir, String filename) {
int hash = JavaUtils.nonNegativeHash(filename);
String localDir = localDirs[hash % localDirs.length];
int subDirId = (hash / localDirs.length) % subDirsPerLocalDir;
return new File(createNormalizedInternedPathname(
localDir, String.format("%02x", subDirId), filename));
} | [
"@",
"VisibleForTesting",
"static",
"File",
"getFile",
"(",
"String",
"[",
"]",
"localDirs",
",",
"int",
"subDirsPerLocalDir",
",",
"String",
"filename",
")",
"{",
"int",
"hash",
"=",
"JavaUtils",
".",
"nonNegativeHash",
"(",
"filename",
")",
";",
"String",
... | Hashes a filename into the corresponding local directory, in a manner consistent with
Spark's DiskBlockManager.getFile(). | [
"Hashes",
"a",
"filename",
"into",
"the",
"corresponding",
"local",
"directory",
"in",
"a",
"manner",
"consistent",
"with",
"Spark",
"s",
"DiskBlockManager",
".",
"getFile",
"()",
"."
] | 25ee0474f47d9c30d6f553a7892d9549f91071cf | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java#L305-L312 | train | Gets a File from the given filename. | [
30522,
1030,
5710,
13028,
4355,
2075,
10763,
5371,
2131,
8873,
2571,
1006,
5164,
1031,
1033,
2334,
4305,
2869,
1010,
20014,
4942,
4305,
2869,
4842,
4135,
9289,
4305,
2099,
1010,
5164,
5371,
18442,
1007,
1063,
20014,
23325,
1027,
9262,
21823... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValue.java | MeterValue.valueOf | public static MeterValue valueOf(String value) {
if (isNumber(value)) {
return new MeterValue(Long.parseLong(value));
}
return new MeterValue(DurationStyle.detectAndParse(value));
} | java | public static MeterValue valueOf(String value) {
if (isNumber(value)) {
return new MeterValue(Long.parseLong(value));
}
return new MeterValue(DurationStyle.detectAndParse(value));
} | [
"public",
"static",
"MeterValue",
"valueOf",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"isNumber",
"(",
"value",
")",
")",
"{",
"return",
"new",
"MeterValue",
"(",
"Long",
".",
"parseLong",
"(",
"value",
")",
")",
";",
"}",
"return",
"new",
"MeterVa... | Return a new {@link MeterValue} instance for the given String value. The value may
contain a simple number, or a {@link DurationStyle duration style string}.
@param value the source value
@return a {@link MeterValue} instance | [
"Return",
"a",
"new",
"{"
] | 0b27f7c70e164b2b1a96477f1d9c1acba56790c1 | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterValue.java#L84-L89 | train | Creates a MeterValue from the given String value. | [
30522,
2270,
10763,
8316,
10175,
5657,
3643,
11253,
1006,
5164,
3643,
1007,
1063,
2065,
1006,
3475,
29440,
1006,
3643,
1007,
1007,
1063,
2709,
2047,
8316,
10175,
5657,
1006,
2146,
1012,
11968,
11246,
5063,
1006,
3643,
1007,
1007,
1025,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | handler/src/main/java/io/netty/handler/ssl/SslHandler.java | SslHandler.allocate | private ByteBuf allocate(ChannelHandlerContext ctx, int capacity) {
ByteBufAllocator alloc = ctx.alloc();
if (engineType.wantsDirectBuffer) {
return alloc.directBuffer(capacity);
} else {
return alloc.buffer(capacity);
}
} | java | private ByteBuf allocate(ChannelHandlerContext ctx, int capacity) {
ByteBufAllocator alloc = ctx.alloc();
if (engineType.wantsDirectBuffer) {
return alloc.directBuffer(capacity);
} else {
return alloc.buffer(capacity);
}
} | [
"private",
"ByteBuf",
"allocate",
"(",
"ChannelHandlerContext",
"ctx",
",",
"int",
"capacity",
")",
"{",
"ByteBufAllocator",
"alloc",
"=",
"ctx",
".",
"alloc",
"(",
")",
";",
"if",
"(",
"engineType",
".",
"wantsDirectBuffer",
")",
"{",
"return",
"alloc",
"."... | Always prefer a direct buffer when it's pooled, so that we reduce the number of memory copies
in {@link OpenSslEngine}. | [
"Always",
"prefer",
"a",
"direct",
"buffer",
"when",
"it",
"s",
"pooled",
"so",
"that",
"we",
"reduce",
"the",
"number",
"of",
"memory",
"copies",
"in",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/SslHandler.java#L2120-L2127 | train | Allocate a buffer of the specified capacity. | [
30522,
2797,
24880,
8569,
2546,
2035,
24755,
2618,
1006,
3149,
11774,
3917,
8663,
18209,
14931,
2595,
1010,
20014,
3977,
1007,
1063,
24880,
8569,
13976,
24755,
4263,
2035,
10085,
1027,
14931,
2595,
1012,
2035,
10085,
1006,
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... |
netty/netty | transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java | AbstractKQueueChannel.doReadBytes | protected final int doReadBytes(ByteBuf byteBuf) throws Exception {
int writerIndex = byteBuf.writerIndex();
int localReadAmount;
unsafe().recvBufAllocHandle().attemptedBytesRead(byteBuf.writableBytes());
if (byteBuf.hasMemoryAddress()) {
localReadAmount = socket.readAddress(byteBuf.memoryAddress(), writerIndex, byteBuf.capacity());
} else {
ByteBuffer buf = byteBuf.internalNioBuffer(writerIndex, byteBuf.writableBytes());
localReadAmount = socket.read(buf, buf.position(), buf.limit());
}
if (localReadAmount > 0) {
byteBuf.writerIndex(writerIndex + localReadAmount);
}
return localReadAmount;
} | java | protected final int doReadBytes(ByteBuf byteBuf) throws Exception {
int writerIndex = byteBuf.writerIndex();
int localReadAmount;
unsafe().recvBufAllocHandle().attemptedBytesRead(byteBuf.writableBytes());
if (byteBuf.hasMemoryAddress()) {
localReadAmount = socket.readAddress(byteBuf.memoryAddress(), writerIndex, byteBuf.capacity());
} else {
ByteBuffer buf = byteBuf.internalNioBuffer(writerIndex, byteBuf.writableBytes());
localReadAmount = socket.read(buf, buf.position(), buf.limit());
}
if (localReadAmount > 0) {
byteBuf.writerIndex(writerIndex + localReadAmount);
}
return localReadAmount;
} | [
"protected",
"final",
"int",
"doReadBytes",
"(",
"ByteBuf",
"byteBuf",
")",
"throws",
"Exception",
"{",
"int",
"writerIndex",
"=",
"byteBuf",
".",
"writerIndex",
"(",
")",
";",
"int",
"localReadAmount",
";",
"unsafe",
"(",
")",
".",
"recvBufAllocHandle",
"(",
... | Read bytes into the given {@link ByteBuf} and return the amount. | [
"Read",
"bytes",
"into",
"the",
"given",
"{"
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java#L248-L262 | train | Read bytes from the socket. | [
30522,
5123,
2345,
20014,
2079,
16416,
18939,
17250,
2015,
1006,
24880,
8569,
2546,
24880,
8569,
2546,
1007,
11618,
6453,
1063,
20014,
3213,
22254,
10288,
1027,
24880,
8569,
2546,
1012,
3213,
22254,
10288,
1006,
1007,
1025,
20014,
2334,
16416... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getIpByHost | public static String getIpByHost(String hostName) {
try {
return InetAddress.getByName(hostName).getHostAddress();
} catch (UnknownHostException e) {
return hostName;
}
} | java | public static String getIpByHost(String hostName) {
try {
return InetAddress.getByName(hostName).getHostAddress();
} catch (UnknownHostException e) {
return hostName;
}
} | [
"public",
"static",
"String",
"getIpByHost",
"(",
"String",
"hostName",
")",
"{",
"try",
"{",
"return",
"InetAddress",
".",
"getByName",
"(",
"hostName",
")",
".",
"getHostAddress",
"(",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"... | 通过域名得到IP
@param hostName HOST
@return ip address or hostName if UnknownHostException | [
"通过域名得到IP"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/net/NetUtil.java#L285-L291 | train | Gets the ip address of a host name. | [
30522,
2270,
10763,
5164,
2131,
11514,
3762,
15006,
2102,
1006,
5164,
3677,
18442,
1007,
1063,
3046,
1063,
2709,
1999,
12928,
14141,
8303,
1012,
2131,
3762,
18442,
1006,
3677,
18442,
1007,
1012,
2131,
15006,
17713,
16200,
4757,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java | ReflectUtil.getFieldsValue | public static Object[] getFieldsValue(Object obj) {
if (null != obj) {
final Field[] fields = getFields(obj.getClass());
if (null != fields) {
final Object[] values = new Object[fields.length];
for (int i = 0; i < fields.length; i++) {
values[i] = getFieldValue(obj, fields[i]);
}
return values;
}
}
return null;
} | java | public static Object[] getFieldsValue(Object obj) {
if (null != obj) {
final Field[] fields = getFields(obj.getClass());
if (null != fields) {
final Object[] values = new Object[fields.length];
for (int i = 0; i < fields.length; i++) {
values[i] = getFieldValue(obj, fields[i]);
}
return values;
}
}
return null;
} | [
"public",
"static",
"Object",
"[",
"]",
"getFieldsValue",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"null",
"!=",
"obj",
")",
"{",
"final",
"Field",
"[",
"]",
"fields",
"=",
"getFields",
"(",
"obj",
".",
"getClass",
"(",
")",
")",
";",
"if",
"(",
... | 获取所有字段的值
@param obj bean对象
@return 字段值数组
@since 4.1.17 | [
"获取所有字段的值"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java#L214-L226 | train | Gets the fields value. | [
30522,
2270,
10763,
4874,
1031,
1033,
2131,
15155,
10175,
5657,
1006,
4874,
27885,
3501,
1007,
1063,
2065,
1006,
19701,
999,
1027,
27885,
3501,
1007,
1063,
2345,
2492,
1031,
1033,
4249,
1027,
2131,
15155,
1006,
27885,
3501,
1012,
2131,
2626... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FileSystemSafetyNet.java | FileSystemSafetyNet.closeSafetyNetAndGuardedResourcesForThread | @Internal
public static void closeSafetyNetAndGuardedResourcesForThread() {
SafetyNetCloseableRegistry registry = REGISTRIES.get();
if (null != registry) {
REGISTRIES.remove();
IOUtils.closeQuietly(registry);
}
} | java | @Internal
public static void closeSafetyNetAndGuardedResourcesForThread() {
SafetyNetCloseableRegistry registry = REGISTRIES.get();
if (null != registry) {
REGISTRIES.remove();
IOUtils.closeQuietly(registry);
}
} | [
"@",
"Internal",
"public",
"static",
"void",
"closeSafetyNetAndGuardedResourcesForThread",
"(",
")",
"{",
"SafetyNetCloseableRegistry",
"registry",
"=",
"REGISTRIES",
".",
"get",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"registry",
")",
"{",
"REGISTRIES",
".",
"r... | Closes the safety net for a thread. This closes all remaining unclosed streams that were opened
by safety-net-guarded file systems. After this method was called, no streams can be opened any more
from any FileSystem instance that was obtained while the thread was guarded by the safety net.
<p>This method should be called at the very end of a guarded thread. | [
"Closes",
"the",
"safety",
"net",
"for",
"a",
"thread",
".",
"This",
"closes",
"all",
"remaining",
"unclosed",
"streams",
"that",
"were",
"opened",
"by",
"safety",
"-",
"net",
"-",
"guarded",
"file",
"systems",
".",
"After",
"this",
"method",
"was",
"calle... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/fs/FileSystemSafetyNet.java#L100-L107 | train | Close all the safety net and guarded resources for the current thread. | [
30522,
1030,
4722,
2270,
10763,
11675,
14572,
10354,
27405,
7159,
5685,
18405,
2098,
6072,
8162,
9623,
15628,
16416,
2094,
1006,
1007,
1063,
3808,
7159,
20464,
9232,
3085,
2890,
24063,
2854,
15584,
1027,
20588,
21011,
1012,
2131,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | java/server/src/org/openqa/grid/internal/utils/SelfRegisteringRemote.java | SelfRegisteringRemote.startRegistrationProcess | public void startRegistrationProcess() {
// don't advertise that the remote (node) is bound to all IPv4 interfaces (default behavior)
if (registrationRequest.getConfiguration().host.equals("0.0.0.0")) {
// remove the value and call fixUpHost to determine the address of a public (non-loopback) IPv4 interface
registrationRequest.getConfiguration().host = null;
registrationRequest.getConfiguration().fixUpHost();
}
fixUpId();
LOG.fine("Using the json request : " + new Json().toJson(registrationRequest));
Boolean register = registrationRequest.getConfiguration().register;
if (register == null) {
register = false;
}
if (!register) {
LOG.info("No registration sent ( register = false )");
} else {
final int
registerCycleInterval =
registrationRequest.getConfiguration().registerCycle != null ?
registrationRequest.getConfiguration().registerCycle : 0;
if (registerCycleInterval > 0) {
new Thread(new Runnable() { // Thread safety reviewed
@Override
public void run() {
boolean first = true;
LOG.info("Starting auto registration thread. Will try to register every "
+ registerCycleInterval + " ms.");
while (true) {
try {
boolean checkForPresence = true;
if (first) {
first = false;
checkForPresence = false;
}
registerToHub(checkForPresence);
} catch (GridException e) {
LOG.info("Couldn't register this node: " + e.getMessage());
}
try {
Thread.sleep(registerCycleInterval);
} catch (InterruptedException e) {
e.printStackTrace();
}
// While we wait for someone to rewrite server logging.
LoggingManager.perSessionLogHandler().clearThreadTempLogs();
}
}
}).start();
} else {
registerToHub(false);
}
}
LoggingManager.perSessionLogHandler().clearThreadTempLogs();
} | java | public void startRegistrationProcess() {
// don't advertise that the remote (node) is bound to all IPv4 interfaces (default behavior)
if (registrationRequest.getConfiguration().host.equals("0.0.0.0")) {
// remove the value and call fixUpHost to determine the address of a public (non-loopback) IPv4 interface
registrationRequest.getConfiguration().host = null;
registrationRequest.getConfiguration().fixUpHost();
}
fixUpId();
LOG.fine("Using the json request : " + new Json().toJson(registrationRequest));
Boolean register = registrationRequest.getConfiguration().register;
if (register == null) {
register = false;
}
if (!register) {
LOG.info("No registration sent ( register = false )");
} else {
final int
registerCycleInterval =
registrationRequest.getConfiguration().registerCycle != null ?
registrationRequest.getConfiguration().registerCycle : 0;
if (registerCycleInterval > 0) {
new Thread(new Runnable() { // Thread safety reviewed
@Override
public void run() {
boolean first = true;
LOG.info("Starting auto registration thread. Will try to register every "
+ registerCycleInterval + " ms.");
while (true) {
try {
boolean checkForPresence = true;
if (first) {
first = false;
checkForPresence = false;
}
registerToHub(checkForPresence);
} catch (GridException e) {
LOG.info("Couldn't register this node: " + e.getMessage());
}
try {
Thread.sleep(registerCycleInterval);
} catch (InterruptedException e) {
e.printStackTrace();
}
// While we wait for someone to rewrite server logging.
LoggingManager.perSessionLogHandler().clearThreadTempLogs();
}
}
}).start();
} else {
registerToHub(false);
}
}
LoggingManager.perSessionLogHandler().clearThreadTempLogs();
} | [
"public",
"void",
"startRegistrationProcess",
"(",
")",
"{",
"// don't advertise that the remote (node) is bound to all IPv4 interfaces (default behavior)",
"if",
"(",
"registrationRequest",
".",
"getConfiguration",
"(",
")",
".",
"host",
".",
"equals",
"(",
"\"0.0.0.0\"",
")... | register the hub following the configuration :
<p>
- check if the proxy is already registered before sending a reg request.
<p>
- register again every X ms is specified in the config of the node. | [
"register",
"the",
"hub",
"following",
"the",
"configuration",
":",
"<p",
">",
"-",
"check",
"if",
"the",
"proxy",
"is",
"already",
"registered",
"before",
"sending",
"a",
"reg",
"request",
".",
"<p",
">",
"-",
"register",
"again",
"every",
"X",
"ms",
"i... | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/grid/internal/utils/SelfRegisteringRemote.java#L167-L223 | train | Start the registration process. | [
30522,
2270,
11675,
2707,
2890,
24063,
8156,
21572,
9623,
2015,
1006,
1007,
1063,
1013,
1013,
2123,
1005,
1056,
4748,
16874,
5562,
2008,
1996,
6556,
1006,
13045,
1007,
2003,
5391,
2000,
2035,
12997,
2615,
2549,
19706,
1006,
12398,
5248,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java | KeyUtil.readCertificate | public static Certificate readCertificate(String type, InputStream in, char[] password, String alias) {
final KeyStore keyStore = readKeyStore(type, in, password);
try {
return keyStore.getCertificate(alias);
} catch (KeyStoreException e) {
throw new CryptoException(e);
}
} | java | public static Certificate readCertificate(String type, InputStream in, char[] password, String alias) {
final KeyStore keyStore = readKeyStore(type, in, password);
try {
return keyStore.getCertificate(alias);
} catch (KeyStoreException e) {
throw new CryptoException(e);
}
} | [
"public",
"static",
"Certificate",
"readCertificate",
"(",
"String",
"type",
",",
"InputStream",
"in",
",",
"char",
"[",
"]",
"password",
",",
"String",
"alias",
")",
"{",
"final",
"KeyStore",
"keyStore",
"=",
"readKeyStore",
"(",
"type",
",",
"in",
",",
"... | 读取Certification文件<br>
Certification为证书文件<br>
see: http://snowolf.iteye.com/blog/391931
@param type 类型,例如X.509
@param in {@link InputStream} 如果想从文件读取.cer文件,使用 {@link FileUtil#getInputStream(java.io.File)} 读取
@param password 密码
@param alias 别名
@return {@link KeyStore}
@since 4.4.1 | [
"读取Certification文件<br",
">",
"Certification为证书文件<br",
">",
"see",
":",
"http",
":",
"//",
"snowolf",
".",
"iteye",
".",
"com",
"/",
"blog",
"/",
"391931"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java#L675-L682 | train | Reads a certificate from an input stream. | [
30522,
2270,
10763,
8196,
3191,
17119,
3775,
8873,
16280,
1006,
5164,
2828,
1010,
20407,
25379,
1999,
1010,
25869,
1031,
1033,
20786,
1010,
5164,
14593,
1007,
1063,
2345,
6309,
19277,
6309,
19277,
1027,
3191,
14839,
23809,
2063,
1006,
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... |
SeleniumHQ/selenium | java/client/src/com/thoughtworks/selenium/BrowserConfigurationOptions.java | BrowserConfigurationOptions.serialize | public String serialize() {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String key : options.keySet()) {
if (first) {
first = false;
} else {
sb.append(';');
}
sb.append(key).append('=').append(options.get(key));
}
return sb.toString();
} | java | public String serialize() {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String key : options.keySet()) {
if (first) {
first = false;
} else {
sb.append(';');
}
sb.append(key).append('=').append(options.get(key));
}
return sb.toString();
} | [
"public",
"String",
"serialize",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"String",
"key",
":",
"options",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"first... | Serializes to the format "name=value;name=value".
@return String with the above format. | [
"Serializes",
"to",
"the",
"format",
"name",
"=",
"value",
";",
"name",
"=",
"value",
"."
] | 7af172729f17b20269c8ca4ea6f788db48616535 | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/com/thoughtworks/selenium/BrowserConfigurationOptions.java#L67-L79 | train | Serialize the options | [
30522,
2270,
5164,
7642,
4697,
1006,
1007,
1063,
5164,
8569,
23891,
2099,
24829,
1027,
2047,
5164,
8569,
23891,
2099,
1006,
1007,
1025,
22017,
20898,
2034,
1027,
2995,
1025,
2005,
1006,
5164,
3145,
1024,
7047,
1012,
6309,
3388,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/template/engine/freemarker/FreemarkerEngine.java | FreemarkerEngine.createCfg | private static Configuration createCfg(TemplateConfig config) {
if (null == config) {
config = new TemplateConfig();
}
final Configuration cfg = new Configuration(Configuration.VERSION_2_3_28);
cfg.setLocalizedLookup(false);
cfg.setDefaultEncoding(config.getCharset().toString());
switch (config.getResourceMode()) {
case CLASSPATH:
cfg.setTemplateLoader(new ClassTemplateLoader(ClassUtil.getClassLoader(), config.getPath()));
break;
case FILE:
try {
cfg.setTemplateLoader(new FileTemplateLoader(FileUtil.file(config.getPath())));
} catch (IOException e) {
throw new IORuntimeException(e);
}
break;
case WEB_ROOT:
try {
cfg.setTemplateLoader(new FileTemplateLoader(FileUtil.file(FileUtil.getWebRoot(), config.getPath())));
} catch (IOException e) {
throw new IORuntimeException(e);
}
break;
case STRING:
cfg.setTemplateLoader(new SimpleStringTemplateLoader());
break;
default:
break;
}
return cfg;
} | java | private static Configuration createCfg(TemplateConfig config) {
if (null == config) {
config = new TemplateConfig();
}
final Configuration cfg = new Configuration(Configuration.VERSION_2_3_28);
cfg.setLocalizedLookup(false);
cfg.setDefaultEncoding(config.getCharset().toString());
switch (config.getResourceMode()) {
case CLASSPATH:
cfg.setTemplateLoader(new ClassTemplateLoader(ClassUtil.getClassLoader(), config.getPath()));
break;
case FILE:
try {
cfg.setTemplateLoader(new FileTemplateLoader(FileUtil.file(config.getPath())));
} catch (IOException e) {
throw new IORuntimeException(e);
}
break;
case WEB_ROOT:
try {
cfg.setTemplateLoader(new FileTemplateLoader(FileUtil.file(FileUtil.getWebRoot(), config.getPath())));
} catch (IOException e) {
throw new IORuntimeException(e);
}
break;
case STRING:
cfg.setTemplateLoader(new SimpleStringTemplateLoader());
break;
default:
break;
}
return cfg;
} | [
"private",
"static",
"Configuration",
"createCfg",
"(",
"TemplateConfig",
"config",
")",
"{",
"if",
"(",
"null",
"==",
"config",
")",
"{",
"config",
"=",
"new",
"TemplateConfig",
"(",
")",
";",
"}",
"final",
"Configuration",
"cfg",
"=",
"new",
"Configuration... | 创建配置项
@param config 模板配置
@return {@link Configuration } | [
"创建配置项"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/freemarker/FreemarkerEngine.java#L69-L104 | train | Creates a new Configuration object from a TemplateConfig object. | [
30522,
2797,
10763,
9563,
3443,
2278,
2546,
2290,
1006,
23561,
8663,
8873,
2290,
9530,
8873,
2290,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
9530,
8873,
2290,
1007,
1063,
9530,
8873,
2290,
1027,
2047,
23561,
8663,
8873,
2290,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java | ImgUtil.pressText | public static void pressText(ImageInputStream srcStream, ImageOutputStream destStream, String pressText, Color color, Font font, int x, int y, float alpha) {
pressText(read(srcStream), destStream, pressText, color, font, x, y, alpha);
} | java | public static void pressText(ImageInputStream srcStream, ImageOutputStream destStream, String pressText, Color color, Font font, int x, int y, float alpha) {
pressText(read(srcStream), destStream, pressText, color, font, x, y, alpha);
} | [
"public",
"static",
"void",
"pressText",
"(",
"ImageInputStream",
"srcStream",
",",
"ImageOutputStream",
"destStream",
",",
"String",
"pressText",
",",
"Color",
"color",
",",
"Font",
"font",
",",
"int",
"x",
",",
"int",
"y",
",",
"float",
"alpha",
")",
"{",
... | 给图片添加文字水印<br>
此方法并不关闭流
@param srcStream 源图像流
@param destStream 目标图像流
@param pressText 水印文字
@param color 水印的字体颜色
@param font {@link Font} 字体相关信息,如果默认则为{@code null}
@param x 修正值。 默认在中间,偏移量相对于中间偏移
@param y 修正值。 默认在中间,偏移量相对于中间偏移
@param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 | [
"给图片添加文字水印<br",
">",
"此方法并不关闭流"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L788-L790 | train | Press text from srcStream to destStream. | [
30522,
2270,
10763,
11675,
2811,
18209,
1006,
3746,
2378,
18780,
21422,
5034,
6169,
25379,
1010,
3746,
5833,
18780,
21422,
4078,
3215,
25379,
1010,
5164,
2811,
18209,
1010,
3609,
3609,
1010,
15489,
15489,
1010,
20014,
1060,
1010,
20014,
1061,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/XmlUtil.java | XmlUtil.xmlToMap | public static Map<String, Object> xmlToMap(Node node, Map<String, Object> result) {
if (null == result) {
result = new HashMap<>();
}
final NodeList nodeList = node.getChildNodes();
final int length = nodeList.getLength();
Node childNode;
Element childEle;
for (int i = 0; i < length; ++i) {
childNode = nodeList.item(i);
if (isElement(childNode)) {
childEle = (Element) childNode;
result.put(childEle.getNodeName(), childEle.getTextContent());
}
}
return result;
} | java | public static Map<String, Object> xmlToMap(Node node, Map<String, Object> result) {
if (null == result) {
result = new HashMap<>();
}
final NodeList nodeList = node.getChildNodes();
final int length = nodeList.getLength();
Node childNode;
Element childEle;
for (int i = 0; i < length; ++i) {
childNode = nodeList.item(i);
if (isElement(childNode)) {
childEle = (Element) childNode;
result.put(childEle.getNodeName(), childEle.getTextContent());
}
}
return result;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"xmlToMap",
"(",
"Node",
"node",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"if",
"(",
"null",
"==",
"result",
")",
"{",
"result",
"=",
"new",
"HashMap",
"<>",
"(... | XML节点转换为Map
@param node XML节点
@param result 结果Map类型
@return XML数据转换后的Map
@since 4.0.8 | [
"XML节点转换为Map"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/XmlUtil.java#L713-L730 | train | Converts XML to Map. | [
30522,
2270,
10763,
4949,
1026,
5164,
1010,
4874,
1028,
20950,
20389,
9331,
1006,
13045,
13045,
1010,
4949,
1026,
5164,
1010,
4874,
1028,
2765,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
2765,
1007,
1063,
2765,
1027,
2047,
23325,
2863,
2361... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/BroadcastConnectedStream.java | BroadcastConnectedStream.process | @PublicEvolving
public <KS, OUT> SingleOutputStreamOperator<OUT> process(
final KeyedBroadcastProcessFunction<KS, IN1, IN2, OUT> function,
final TypeInformation<OUT> outTypeInfo) {
Preconditions.checkNotNull(function);
Preconditions.checkArgument(inputStream1 instanceof KeyedStream,
"A KeyedBroadcastProcessFunction can only be used on a keyed stream.");
TwoInputStreamOperator<IN1, IN2, OUT> operator =
new CoBroadcastWithKeyedOperator<>(clean(function), broadcastStateDescriptors);
return transform("Co-Process-Broadcast-Keyed", outTypeInfo, operator);
} | java | @PublicEvolving
public <KS, OUT> SingleOutputStreamOperator<OUT> process(
final KeyedBroadcastProcessFunction<KS, IN1, IN2, OUT> function,
final TypeInformation<OUT> outTypeInfo) {
Preconditions.checkNotNull(function);
Preconditions.checkArgument(inputStream1 instanceof KeyedStream,
"A KeyedBroadcastProcessFunction can only be used on a keyed stream.");
TwoInputStreamOperator<IN1, IN2, OUT> operator =
new CoBroadcastWithKeyedOperator<>(clean(function), broadcastStateDescriptors);
return transform("Co-Process-Broadcast-Keyed", outTypeInfo, operator);
} | [
"@",
"PublicEvolving",
"public",
"<",
"KS",
",",
"OUT",
">",
"SingleOutputStreamOperator",
"<",
"OUT",
">",
"process",
"(",
"final",
"KeyedBroadcastProcessFunction",
"<",
"KS",
",",
"IN1",
",",
"IN2",
",",
"OUT",
">",
"function",
",",
"final",
"TypeInformation... | Assumes as inputs a {@link BroadcastStream} and a {@link KeyedStream} and applies the given
{@link KeyedBroadcastProcessFunction} on them, thereby creating a transformed output stream.
@param function The {@link KeyedBroadcastProcessFunction} that is called for each element in the stream.
@param outTypeInfo The type of the output elements.
@param <KS> The type of the keys in the keyed stream.
@param <OUT> The type of the output elements.
@return The transformed {@link DataStream}. | [
"Assumes",
"as",
"inputs",
"a",
"{",
"@link",
"BroadcastStream",
"}",
"and",
"a",
"{",
"@link",
"KeyedStream",
"}",
"and",
"applies",
"the",
"given",
"{",
"@link",
"KeyedBroadcastProcessFunction",
"}",
"on",
"them",
"thereby",
"creating",
"a",
"transformed",
"... | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/BroadcastConnectedStream.java#L152-L164 | train | Processes a single - output stream using a co - broadcast - process function. | [
30522,
1030,
2270,
6777,
4747,
6455,
2270,
1026,
29535,
1010,
2041,
1028,
2309,
5833,
18780,
21422,
25918,
8844,
1026,
2041,
1028,
2832,
1006,
2345,
3145,
2098,
12618,
4215,
10526,
21572,
9623,
22747,
4609,
7542,
1026,
29535,
1010,
1999,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.createRandomAccessFile | public static RandomAccessFile createRandomAccessFile(Path path, FileMode mode) {
return createRandomAccessFile(path.toFile(), mode);
} | java | public static RandomAccessFile createRandomAccessFile(Path path, FileMode mode) {
return createRandomAccessFile(path.toFile(), mode);
} | [
"public",
"static",
"RandomAccessFile",
"createRandomAccessFile",
"(",
"Path",
"path",
",",
"FileMode",
"mode",
")",
"{",
"return",
"createRandomAccessFile",
"(",
"path",
".",
"toFile",
"(",
")",
",",
"mode",
")",
";",
"}"
] | 创建{@link RandomAccessFile}
@param path 文件Path
@param mode 模式,见{@link FileMode}
@return {@link RandomAccessFile}
@since 4.5.2 | [
"创建",
"{",
"@link",
"RandomAccessFile",
"}"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L3445-L3447 | train | Create a RandomAccessFile object for the given path and mode. | [
30522,
2270,
10763,
6721,
6305,
9623,
22747,
9463,
3443,
13033,
9626,
9468,
7971,
8873,
2571,
1006,
4130,
4130,
1010,
5371,
5302,
3207,
5549,
1007,
1063,
2709,
3443,
13033,
9626,
9468,
7971,
8873,
2571,
1006,
4130,
1012,
2000,
8873,
2571,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/MemoryLogger.java | MemoryLogger.run | @Override
public void run() {
try {
while (running && (monitored == null || !monitored.isDone())) {
logger.info(getMemoryUsageStatsAsString(memoryBean));
logger.info(getDirectMemoryStatsAsString(directBufferBean));
logger.info(getMemoryPoolStatsAsString(poolBeans));
logger.info(getGarbageCollectorStatsAsString(gcBeans));
try {
Thread.sleep(interval);
}
catch (InterruptedException e) {
if (running) {
throw e;
}
}
}
}
catch (Throwable t) {
logger.error("Memory logger terminated with exception", t);
}
} | java | @Override
public void run() {
try {
while (running && (monitored == null || !monitored.isDone())) {
logger.info(getMemoryUsageStatsAsString(memoryBean));
logger.info(getDirectMemoryStatsAsString(directBufferBean));
logger.info(getMemoryPoolStatsAsString(poolBeans));
logger.info(getGarbageCollectorStatsAsString(gcBeans));
try {
Thread.sleep(interval);
}
catch (InterruptedException e) {
if (running) {
throw e;
}
}
}
}
catch (Throwable t) {
logger.error("Memory logger terminated with exception", t);
}
} | [
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"while",
"(",
"running",
"&&",
"(",
"monitored",
"==",
"null",
"||",
"!",
"monitored",
".",
"isDone",
"(",
")",
")",
")",
"{",
"logger",
".",
"info",
"(",
"getMemoryUsageStatsAsString... | ------------------------------------------------------------------------ | [
"------------------------------------------------------------------------"
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/MemoryLogger.java#L125-L147 | train | Run the memory logger. | [
30522,
1030,
2058,
15637,
2270,
11675,
2448,
1006,
1007,
1063,
3046,
1063,
2096,
1006,
2770,
1004,
1004,
1006,
17785,
1027,
1027,
19701,
1064,
1064,
999,
17785,
1012,
2003,
5280,
2063,
1006,
1007,
1007,
1007,
1063,
8833,
4590,
1012,
18558,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java | AbstractCustomCommandLine.applyCommandLineOptionsToConfiguration | protected Configuration applyCommandLineOptionsToConfiguration(CommandLine commandLine) throws FlinkException {
final Configuration resultingConfiguration = new Configuration(configuration);
if (commandLine.hasOption(addressOption.getOpt())) {
String addressWithPort = commandLine.getOptionValue(addressOption.getOpt());
InetSocketAddress jobManagerAddress = ClientUtils.parseHostPortAddress(addressWithPort);
setJobManagerAddressInConfig(resultingConfiguration, jobManagerAddress);
}
if (commandLine.hasOption(zookeeperNamespaceOption.getOpt())) {
String zkNamespace = commandLine.getOptionValue(zookeeperNamespaceOption.getOpt());
resultingConfiguration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zkNamespace);
}
return resultingConfiguration;
} | java | protected Configuration applyCommandLineOptionsToConfiguration(CommandLine commandLine) throws FlinkException {
final Configuration resultingConfiguration = new Configuration(configuration);
if (commandLine.hasOption(addressOption.getOpt())) {
String addressWithPort = commandLine.getOptionValue(addressOption.getOpt());
InetSocketAddress jobManagerAddress = ClientUtils.parseHostPortAddress(addressWithPort);
setJobManagerAddressInConfig(resultingConfiguration, jobManagerAddress);
}
if (commandLine.hasOption(zookeeperNamespaceOption.getOpt())) {
String zkNamespace = commandLine.getOptionValue(zookeeperNamespaceOption.getOpt());
resultingConfiguration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zkNamespace);
}
return resultingConfiguration;
} | [
"protected",
"Configuration",
"applyCommandLineOptionsToConfiguration",
"(",
"CommandLine",
"commandLine",
")",
"throws",
"FlinkException",
"{",
"final",
"Configuration",
"resultingConfiguration",
"=",
"new",
"Configuration",
"(",
"configuration",
")",
";",
"if",
"(",
"co... | Override configuration settings by specified command line options.
@param commandLine containing the overriding values
@return Effective configuration with the overridden configuration settings | [
"Override",
"configuration",
"settings",
"by",
"specified",
"command",
"line",
"options",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java#L78-L93 | train | Apply command line options to configuration. | [
30522,
5123,
9563,
6611,
9006,
2386,
19422,
3170,
7361,
9285,
3406,
8663,
8873,
27390,
3370,
1006,
3094,
4179,
3094,
4179,
1007,
11618,
13109,
19839,
10288,
24422,
1063,
2345,
9563,
4525,
8663,
8873,
27390,
3370,
1027,
2047,
9563,
1006,
956... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java | HttpHeaders.getIntHeader | @Deprecated
public static int getIntHeader(HttpMessage message, String name, int defaultValue) {
return message.headers().getInt(name, defaultValue);
} | java | @Deprecated
public static int getIntHeader(HttpMessage message, String name, int defaultValue) {
return message.headers().getInt(name, defaultValue);
} | [
"@",
"Deprecated",
"public",
"static",
"int",
"getIntHeader",
"(",
"HttpMessage",
"message",
",",
"String",
"name",
",",
"int",
"defaultValue",
")",
"{",
"return",
"message",
".",
"headers",
"(",
")",
".",
"getInt",
"(",
"name",
",",
"defaultValue",
")",
"... | @deprecated Use {@link #getInt(CharSequence, int)} instead.
@see #getIntHeader(HttpMessage, CharSequence, int) | [
"@deprecated",
"Use",
"{",
"@link",
"#getInt",
"(",
"CharSequence",
"int",
")",
"}",
"instead",
"."
] | ba06eafa1c1824bd154f1a380019e7ea2edf3c4c | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java#L739-L742 | train | Get a header as an int. | [
30522,
1030,
2139,
28139,
12921,
2270,
10763,
20014,
2131,
18447,
4974,
2121,
1006,
8299,
7834,
3736,
3351,
4471,
1010,
5164,
2171,
1010,
20014,
12398,
10175,
5657,
1007,
1063,
2709,
4471,
1012,
20346,
2015,
1006,
1007,
1012,
2131,
18447,
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/codec/Base64.java | Base64.decodeToStream | public static void decodeToStream(String base64, OutputStream out, boolean isCloseOut) {
IoUtil.write(out, isCloseOut, Base64Decoder.decode(base64));
} | java | public static void decodeToStream(String base64, OutputStream out, boolean isCloseOut) {
IoUtil.write(out, isCloseOut, Base64Decoder.decode(base64));
} | [
"public",
"static",
"void",
"decodeToStream",
"(",
"String",
"base64",
",",
"OutputStream",
"out",
",",
"boolean",
"isCloseOut",
")",
"{",
"IoUtil",
".",
"write",
"(",
"out",
",",
"isCloseOut",
",",
"Base64Decoder",
".",
"decode",
"(",
"base64",
")",
")",
... | base64解码
@param base64 被解码的base64字符串
@param out 写出到的流
@param isCloseOut 是否关闭输出流
@since 4.0.9 | [
"base64解码"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/codec/Base64.java#L301-L303 | train | Decodes a base64 string into an OutputStream. | [
30522,
2270,
10763,
11675,
21933,
3207,
13122,
25379,
1006,
5164,
2918,
21084,
1010,
27852,
25379,
2041,
1010,
22017,
20898,
2003,
20464,
9232,
5833,
1007,
1063,
22834,
21823,
2140,
1012,
4339,
1006,
2041,
1010,
2003,
20464,
9232,
5833,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java | ResourceManager.registerJobMasterInternal | private RegistrationResponse registerJobMasterInternal(
final JobMasterGateway jobMasterGateway,
JobID jobId,
String jobManagerAddress,
ResourceID jobManagerResourceId) {
if (jobManagerRegistrations.containsKey(jobId)) {
JobManagerRegistration oldJobManagerRegistration = jobManagerRegistrations.get(jobId);
if (Objects.equals(oldJobManagerRegistration.getJobMasterId(), jobMasterGateway.getFencingToken())) {
// same registration
log.debug("Job manager {}@{} was already registered.", jobMasterGateway.getFencingToken(), jobManagerAddress);
} else {
// tell old job manager that he is no longer the job leader
disconnectJobManager(
oldJobManagerRegistration.getJobID(),
new Exception("New job leader for job " + jobId + " found."));
JobManagerRegistration jobManagerRegistration = new JobManagerRegistration(
jobId,
jobManagerResourceId,
jobMasterGateway);
jobManagerRegistrations.put(jobId, jobManagerRegistration);
jmResourceIdRegistrations.put(jobManagerResourceId, jobManagerRegistration);
}
} else {
// new registration for the job
JobManagerRegistration jobManagerRegistration = new JobManagerRegistration(
jobId,
jobManagerResourceId,
jobMasterGateway);
jobManagerRegistrations.put(jobId, jobManagerRegistration);
jmResourceIdRegistrations.put(jobManagerResourceId, jobManagerRegistration);
}
log.info("Registered job manager {}@{} for job {}.", jobMasterGateway.getFencingToken(), jobManagerAddress, jobId);
jobManagerHeartbeatManager.monitorTarget(jobManagerResourceId, new HeartbeatTarget<Void>() {
@Override
public void receiveHeartbeat(ResourceID resourceID, Void payload) {
// the ResourceManager will always send heartbeat requests to the JobManager
}
@Override
public void requestHeartbeat(ResourceID resourceID, Void payload) {
jobMasterGateway.heartbeatFromResourceManager(resourceID);
}
});
return new JobMasterRegistrationSuccess(
getFencingToken(),
resourceId);
} | java | private RegistrationResponse registerJobMasterInternal(
final JobMasterGateway jobMasterGateway,
JobID jobId,
String jobManagerAddress,
ResourceID jobManagerResourceId) {
if (jobManagerRegistrations.containsKey(jobId)) {
JobManagerRegistration oldJobManagerRegistration = jobManagerRegistrations.get(jobId);
if (Objects.equals(oldJobManagerRegistration.getJobMasterId(), jobMasterGateway.getFencingToken())) {
// same registration
log.debug("Job manager {}@{} was already registered.", jobMasterGateway.getFencingToken(), jobManagerAddress);
} else {
// tell old job manager that he is no longer the job leader
disconnectJobManager(
oldJobManagerRegistration.getJobID(),
new Exception("New job leader for job " + jobId + " found."));
JobManagerRegistration jobManagerRegistration = new JobManagerRegistration(
jobId,
jobManagerResourceId,
jobMasterGateway);
jobManagerRegistrations.put(jobId, jobManagerRegistration);
jmResourceIdRegistrations.put(jobManagerResourceId, jobManagerRegistration);
}
} else {
// new registration for the job
JobManagerRegistration jobManagerRegistration = new JobManagerRegistration(
jobId,
jobManagerResourceId,
jobMasterGateway);
jobManagerRegistrations.put(jobId, jobManagerRegistration);
jmResourceIdRegistrations.put(jobManagerResourceId, jobManagerRegistration);
}
log.info("Registered job manager {}@{} for job {}.", jobMasterGateway.getFencingToken(), jobManagerAddress, jobId);
jobManagerHeartbeatManager.monitorTarget(jobManagerResourceId, new HeartbeatTarget<Void>() {
@Override
public void receiveHeartbeat(ResourceID resourceID, Void payload) {
// the ResourceManager will always send heartbeat requests to the JobManager
}
@Override
public void requestHeartbeat(ResourceID resourceID, Void payload) {
jobMasterGateway.heartbeatFromResourceManager(resourceID);
}
});
return new JobMasterRegistrationSuccess(
getFencingToken(),
resourceId);
} | [
"private",
"RegistrationResponse",
"registerJobMasterInternal",
"(",
"final",
"JobMasterGateway",
"jobMasterGateway",
",",
"JobID",
"jobId",
",",
"String",
"jobManagerAddress",
",",
"ResourceID",
"jobManagerResourceId",
")",
"{",
"if",
"(",
"jobManagerRegistrations",
".",
... | Registers a new JobMaster.
@param jobMasterGateway to communicate with the registering JobMaster
@param jobId of the job for which the JobMaster is responsible
@param jobManagerAddress address of the JobMaster
@param jobManagerResourceId ResourceID of the JobMaster
@return RegistrationResponse | [
"Registers",
"a",
"new",
"JobMaster",
"."
] | b62db93bf63cb3bb34dd03d611a779d9e3fc61ac | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java#L620-L671 | train | Internal method to register a job master. | [
30522,
2797,
8819,
6072,
26029,
3366,
4236,
5558,
25526,
24268,
18447,
11795,
2389,
1006,
2345,
3105,
8706,
5867,
4576,
3105,
8706,
5867,
4576,
1010,
3105,
3593,
3105,
3593,
1010,
5164,
3105,
24805,
4590,
4215,
16200,
4757,
1010,
7692,
3593... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpRequest.java | HttpRequest.body | public HttpRequest body(String body, String contentType) {
body(StrUtil.bytes(body, this.charset));
this.form = null; // 当使用body时,停止form的使用
contentLength((null != body ? body.length() : 0));
if (null != contentType) {
// Content-Type自定义设置
this.contentType(contentType);
} else {
// 在用户未自定义的情况下自动根据内容判断
contentType = HttpUtil.getContentTypeByRequestBody(body);
if (null != contentType && ContentType.isDefault(this.header(Header.CONTENT_TYPE))) {
if (null != this.charset) {
// 附加编码信息
contentType = ContentType.build(contentType, this.charset);
}
this.contentType(contentType);
}
}
// 判断是否为rest请求
if (StrUtil.containsAnyIgnoreCase(contentType, "json", "xml")) {
this.isRest = true;
}
return this;
} | java | public HttpRequest body(String body, String contentType) {
body(StrUtil.bytes(body, this.charset));
this.form = null; // 当使用body时,停止form的使用
contentLength((null != body ? body.length() : 0));
if (null != contentType) {
// Content-Type自定义设置
this.contentType(contentType);
} else {
// 在用户未自定义的情况下自动根据内容判断
contentType = HttpUtil.getContentTypeByRequestBody(body);
if (null != contentType && ContentType.isDefault(this.header(Header.CONTENT_TYPE))) {
if (null != this.charset) {
// 附加编码信息
contentType = ContentType.build(contentType, this.charset);
}
this.contentType(contentType);
}
}
// 判断是否为rest请求
if (StrUtil.containsAnyIgnoreCase(contentType, "json", "xml")) {
this.isRest = true;
}
return this;
} | [
"public",
"HttpRequest",
"body",
"(",
"String",
"body",
",",
"String",
"contentType",
")",
"{",
"body",
"(",
"StrUtil",
".",
"bytes",
"(",
"body",
",",
"this",
".",
"charset",
")",
")",
";",
"this",
".",
"form",
"=",
"null",
";",
"// 当使用body时,停止form的使用\r... | 设置内容主体<br>
请求体body参数支持两种类型:
<pre>
1. 标准参数,例如 a=1&b=2 这种格式
2. Rest模式,此时body需要传入一个JSON或者XML字符串,Hutool会自动绑定其对应的Content-Type
</pre>
@param body 请求体
@param contentType 请求体类型,{@code null}表示自动判断类型
@return this | [
"设置内容主体<br",
">",
"请求体body参数支持两种类型:"
] | bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java#L620-L645 | train |
body | [
30522,
2270,
8299,
2890,
15500,
2303,
1006,
5164,
2303,
1010,
5164,
4180,
13874,
1007,
1063,
2303,
1006,
2358,
22134,
4014,
1012,
27507,
1006,
2303,
1010,
2023,
1012,
25869,
13462,
1007,
1007,
1025,
2023,
1012,
2433,
1027,
19701,
1025,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.