id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
116,300 | beanshell/beanshell | src/main/java/bsh/util/ClassBrowser.java | ClassBrowser.driveToClass | public void driveToClass( String classname ) {
String [] sa = BshClassPath.splitClassname( classname );
String packn = sa[0];
String classn = sa[1];
// Do we have the package?
if ( classPath.getClassesForPackage(packn).size()==0 )
return;
ptree.setSelectedPa... | java | public void driveToClass( String classname ) {
String [] sa = BshClassPath.splitClassname( classname );
String packn = sa[0];
String classn = sa[1];
// Do we have the package?
if ( classPath.getClassesForPackage(packn).size()==0 )
return;
ptree.setSelectedPa... | [
"public",
"void",
"driveToClass",
"(",
"String",
"classname",
")",
"{",
"String",
"[",
"]",
"sa",
"=",
"BshClassPath",
".",
"splitClassname",
"(",
"classname",
")",
";",
"String",
"packn",
"=",
"sa",
"[",
"0",
"]",
";",
"String",
"classn",
"=",
"sa",
"... | fully qualified classname | [
"fully",
"qualified",
"classname"
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/util/ClassBrowser.java#L500-L518 |
116,301 | beanshell/beanshell | src/main/java/bsh/Primitive.java | Primitive.getValue | public Object getValue()
{
if ( value == Special.NULL_VALUE )
return null;
if ( value == Special.VOID_TYPE )
throw new InterpreterError("attempt to unwrap void type");
return value;
} | java | public Object getValue()
{
if ( value == Special.NULL_VALUE )
return null;
if ( value == Special.VOID_TYPE )
throw new InterpreterError("attempt to unwrap void type");
return value;
} | [
"public",
"Object",
"getValue",
"(",
")",
"{",
"if",
"(",
"value",
"==",
"Special",
".",
"NULL_VALUE",
")",
"return",
"null",
";",
"if",
"(",
"value",
"==",
"Special",
".",
"VOID_TYPE",
")",
"throw",
"new",
"InterpreterError",
"(",
"\"attempt to unwrap void ... | Return the primitive value stored in its java.lang wrapper class | [
"Return",
"the",
"primitive",
"value",
"stored",
"in",
"its",
"java",
".",
"lang",
"wrapper",
"class"
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/Primitive.java#L147-L154 |
116,302 | beanshell/beanshell | src/main/java/bsh/Primitive.java | Primitive.getType | public Class<?> getType()
{
if ( this == Primitive.VOID )
return Void.TYPE;
// NULL return null as type... we currently use null type to indicate
// loose typing throughout bsh.
if ( this == Primitive.NULL )
return null;
return unboxType( value.getCl... | java | public Class<?> getType()
{
if ( this == Primitive.VOID )
return Void.TYPE;
// NULL return null as type... we currently use null type to indicate
// loose typing throughout bsh.
if ( this == Primitive.NULL )
return null;
return unboxType( value.getCl... | [
"public",
"Class",
"<",
"?",
">",
"getType",
"(",
")",
"{",
"if",
"(",
"this",
"==",
"Primitive",
".",
"VOID",
")",
"return",
"Void",
".",
"TYPE",
";",
"// NULL return null as type... we currently use null type to indicate",
"// loose typing throughout bsh.",
"if",
... | Get the corresponding Java primitive TYPE class for this Primitive.
@return the primitive TYPE class type of the value or Void.TYPE for
Primitive.VOID or null value for type of Primitive.NULL | [
"Get",
"the",
"corresponding",
"Java",
"primitive",
"TYPE",
"class",
"for",
"this",
"Primitive",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/Primitive.java#L170-L181 |
116,303 | beanshell/beanshell | src/main/java/bsh/Primitive.java | Primitive.unwrap | public static Object unwrap( Object obj )
{
// map voids to nulls for the outside world
if (obj == Primitive.VOID)
return null;
// unwrap primitives
if (obj instanceof Primitive)
return((Primitive)obj).getValue();
return obj;
} | java | public static Object unwrap( Object obj )
{
// map voids to nulls for the outside world
if (obj == Primitive.VOID)
return null;
// unwrap primitives
if (obj instanceof Primitive)
return((Primitive)obj).getValue();
return obj;
} | [
"public",
"static",
"Object",
"unwrap",
"(",
"Object",
"obj",
")",
"{",
"// map voids to nulls for the outside world",
"if",
"(",
"obj",
"==",
"Primitive",
".",
"VOID",
")",
"return",
"null",
";",
"// unwrap primitives",
"if",
"(",
"obj",
"instanceof",
"Primitive"... | Unwrap primitive values and map voids to nulls.
Non Primitive types remain unchanged.
@param obj object type which may be bsh.Primitive
@return corresponding "normal" Java type, "unwrapping"
any bsh.Primitive types to their wrapper types. | [
"Unwrap",
"primitive",
"values",
"and",
"map",
"voids",
"to",
"nulls",
".",
"Non",
"Primitive",
"types",
"remain",
"unchanged",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/Primitive.java#L288-L299 |
116,304 | beanshell/beanshell | src/main/java/bsh/Primitive.java | Primitive.getDefaultValue | public static Primitive getDefaultValue( Class<?> type )
{
if ( type == null )
return Primitive.NULL;
if ( Boolean.TYPE == type || Boolean.class == type )
return Primitive.FALSE;
if ( Character.TYPE == type || Character.class == type )
return Primitive.ZER... | java | public static Primitive getDefaultValue( Class<?> type )
{
if ( type == null )
return Primitive.NULL;
if ( Boolean.TYPE == type || Boolean.class == type )
return Primitive.FALSE;
if ( Character.TYPE == type || Character.class == type )
return Primitive.ZER... | [
"public",
"static",
"Primitive",
"getDefaultValue",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"return",
"Primitive",
".",
"NULL",
";",
"if",
"(",
"Boolean",
".",
"TYPE",
"==",
"type",
"||",
"Boolean",
".",
"... | Get the appropriate default value per JLS 4.5.4 | [
"Get",
"the",
"appropriate",
"default",
"value",
"per",
"JLS",
"4",
".",
"5",
".",
"4"
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/Primitive.java#L359-L384 |
116,305 | beanshell/beanshell | src/main/java/bsh/org/objectweb/asm/FieldWriter.java | FieldWriter.computeFieldInfoSize | int computeFieldInfoSize() {
// The access_flags, name_index, descriptor_index and attributes_count fields use 8 bytes.
int size = 8;
// For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS.
if (constantValueIndex != 0) {
// ConstantValue attributes always use ... | java | int computeFieldInfoSize() {
// The access_flags, name_index, descriptor_index and attributes_count fields use 8 bytes.
int size = 8;
// For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS.
if (constantValueIndex != 0) {
// ConstantValue attributes always use ... | [
"int",
"computeFieldInfoSize",
"(",
")",
"{",
"// The access_flags, name_index, descriptor_index and attributes_count fields use 8 bytes.",
"int",
"size",
"=",
"8",
";",
"// For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS.",
"if",
"(",
"constantV... | Returns the size of the field_info JVMS structure generated by this FieldWriter. Also adds the
names of the attributes of this field in the constant pool.
@return the size in bytes of the field_info JVMS structure. | [
"Returns",
"the",
"size",
"of",
"the",
"field_info",
"JVMS",
"structure",
"generated",
"by",
"this",
"FieldWriter",
".",
"Also",
"adds",
"the",
"names",
"of",
"the",
"attributes",
"of",
"this",
"field",
"in",
"the",
"constant",
"pool",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/org/objectweb/asm/FieldWriter.java#L142-L173 |
116,306 | beanshell/beanshell | src/main/java/bsh/org/objectweb/asm/FieldWriter.java | FieldWriter.putFieldInfo | void putFieldInfo(final ByteVector output) {
boolean useSyntheticAttribute = symbolTable.getMajorVersion() < Opcodes.V1_5;
// Put the access_flags, name_index and descriptor_index fields.
int mask = useSyntheticAttribute ? Opcodes.ACC_SYNTHETIC : 0;
output.putShort(accessFlags & ~mask).putShort(nameInde... | java | void putFieldInfo(final ByteVector output) {
boolean useSyntheticAttribute = symbolTable.getMajorVersion() < Opcodes.V1_5;
// Put the access_flags, name_index and descriptor_index fields.
int mask = useSyntheticAttribute ? Opcodes.ACC_SYNTHETIC : 0;
output.putShort(accessFlags & ~mask).putShort(nameInde... | [
"void",
"putFieldInfo",
"(",
"final",
"ByteVector",
"output",
")",
"{",
"boolean",
"useSyntheticAttribute",
"=",
"symbolTable",
".",
"getMajorVersion",
"(",
")",
"<",
"Opcodes",
".",
"V1_5",
";",
"// Put the access_flags, name_index and descriptor_index fields.",
"int",
... | Puts the content of the field_info JVMS structure generated by this FieldWriter into the given
ByteVector.
@param output where the field_info structure must be put. | [
"Puts",
"the",
"content",
"of",
"the",
"field_info",
"JVMS",
"structure",
"generated",
"by",
"this",
"FieldWriter",
"into",
"the",
"given",
"ByteVector",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/org/objectweb/asm/FieldWriter.java#L181-L228 |
116,307 | beanshell/beanshell | src/main/java/bsh/UtilTargetError.java | UtilTargetError.toEvalError | public EvalError toEvalError(
String msg, SimpleNode node, CallStack callstack )
{
if ( null == msg )
msg = this.getMessage();
else
msg += ": " + this.getMessage();
return new TargetError( msg, this.getCause(), node, callstack, false );
} | java | public EvalError toEvalError(
String msg, SimpleNode node, CallStack callstack )
{
if ( null == msg )
msg = this.getMessage();
else
msg += ": " + this.getMessage();
return new TargetError( msg, this.getCause(), node, callstack, false );
} | [
"public",
"EvalError",
"toEvalError",
"(",
"String",
"msg",
",",
"SimpleNode",
"node",
",",
"CallStack",
"callstack",
")",
"{",
"if",
"(",
"null",
"==",
"msg",
")",
"msg",
"=",
"this",
".",
"getMessage",
"(",
")",
";",
"else",
"msg",
"+=",
"\": \"",
"+... | Override toEvalError to throw TargetError type. | [
"Override",
"toEvalError",
"to",
"throw",
"TargetError",
"type",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/UtilTargetError.java#L54-L63 |
116,308 | beanshell/beanshell | src/main/java/bsh/BSHMethodDeclaration.java | BSHMethodDeclaration.insureNodesParsed | synchronized void insureNodesParsed()
{
if ( paramsNode != null ) // there is always a paramsNode
return;
Object firstNode = jjtGetChild(0);
firstThrowsClause = 1;
if ( firstNode instanceof BSHReturnType )
{
returnTypeNode = (BSHReturnType)firstNode;
... | java | synchronized void insureNodesParsed()
{
if ( paramsNode != null ) // there is always a paramsNode
return;
Object firstNode = jjtGetChild(0);
firstThrowsClause = 1;
if ( firstNode instanceof BSHReturnType )
{
returnTypeNode = (BSHReturnType)firstNode;
... | [
"synchronized",
"void",
"insureNodesParsed",
"(",
")",
"{",
"if",
"(",
"paramsNode",
"!=",
"null",
")",
"// there is always a paramsNode",
"return",
";",
"Object",
"firstNode",
"=",
"jjtGetChild",
"(",
"0",
")",
";",
"firstThrowsClause",
"=",
"1",
";",
"if",
"... | Set the returnTypeNode, paramsNode, and blockNode based on child
node structure. No evaluation is done here. | [
"Set",
"the",
"returnTypeNode",
"paramsNode",
"and",
"blockNode",
"based",
"on",
"child",
"node",
"structure",
".",
"No",
"evaluation",
"is",
"done",
"here",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/BSHMethodDeclaration.java#L57-L79 |
116,309 | beanshell/beanshell | src/main/java/bsh/BSHMethodDeclaration.java | BSHMethodDeclaration.evalReturnType | Class evalReturnType( CallStack callstack, Interpreter interpreter )
throws EvalError
{
insureNodesParsed();
if ( returnTypeNode != null )
return returnTypeNode.evalReturnType( callstack, interpreter );
else
return null;
} | java | Class evalReturnType( CallStack callstack, Interpreter interpreter )
throws EvalError
{
insureNodesParsed();
if ( returnTypeNode != null )
return returnTypeNode.evalReturnType( callstack, interpreter );
else
return null;
} | [
"Class",
"evalReturnType",
"(",
"CallStack",
"callstack",
",",
"Interpreter",
"interpreter",
")",
"throws",
"EvalError",
"{",
"insureNodesParsed",
"(",
")",
";",
"if",
"(",
"returnTypeNode",
"!=",
"null",
")",
"return",
"returnTypeNode",
".",
"evalReturnType",
"("... | Evaluate the return type node.
@return the type or null indicating loosely typed return | [
"Evaluate",
"the",
"return",
"type",
"node",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/BSHMethodDeclaration.java#L85-L93 |
116,310 | beanshell/beanshell | src/main/java/bsh/BSHMethodDeclaration.java | BSHMethodDeclaration.eval | public Object eval( CallStack callstack, Interpreter interpreter )
throws EvalError
{
returnType = evalReturnType( callstack, interpreter );
evalNodes( callstack, interpreter );
// Install an *instance* of this method in the namespace.
// See notes in BshMethod
// This is n... | java | public Object eval( CallStack callstack, Interpreter interpreter )
throws EvalError
{
returnType = evalReturnType( callstack, interpreter );
evalNodes( callstack, interpreter );
// Install an *instance* of this method in the namespace.
// See notes in BshMethod
// This is n... | [
"public",
"Object",
"eval",
"(",
"CallStack",
"callstack",
",",
"Interpreter",
"interpreter",
")",
"throws",
"EvalError",
"{",
"returnType",
"=",
"evalReturnType",
"(",
"callstack",
",",
"interpreter",
")",
";",
"evalNodes",
"(",
"callstack",
",",
"interpreter",
... | Evaluate the declaration of the method. That is, determine the
structure of the method and install it into the caller's namespace. | [
"Evaluate",
"the",
"declaration",
"of",
"the",
"method",
".",
"That",
"is",
"determine",
"the",
"structure",
"of",
"the",
"method",
"and",
"install",
"it",
"into",
"the",
"caller",
"s",
"namespace",
"."
] | fdddee3de948c9e6babb2d1337028f6fd0a2ba5c | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/BSHMethodDeclaration.java#L115-L135 |
116,311 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/ZooKeeperUtil.java | ZooKeeperUtil.createAcl | public static ArrayList<ACL> createAcl(FailoverWatcher failoverWatcher, String znode) {
if (znode.equals("/chronos")) {
return Ids.OPEN_ACL_UNSAFE;
}
if (failoverWatcher.isZkSecure()) {
ArrayList<ACL> acls = new ArrayList<ACL>();
acls.add(new ACL(ZooDefs.Perms.READ, ZooDefs.Ids.ANYONE... | java | public static ArrayList<ACL> createAcl(FailoverWatcher failoverWatcher, String znode) {
if (znode.equals("/chronos")) {
return Ids.OPEN_ACL_UNSAFE;
}
if (failoverWatcher.isZkSecure()) {
ArrayList<ACL> acls = new ArrayList<ACL>();
acls.add(new ACL(ZooDefs.Perms.READ, ZooDefs.Ids.ANYONE... | [
"public",
"static",
"ArrayList",
"<",
"ACL",
">",
"createAcl",
"(",
"FailoverWatcher",
"failoverWatcher",
",",
"String",
"znode",
")",
"{",
"if",
"(",
"znode",
".",
"equals",
"(",
"\"/chronos\"",
")",
")",
"{",
"return",
"Ids",
".",
"OPEN_ACL_UNSAFE",
";",
... | Create acl for znodes, anyone could read, but only admin can operate if set scure.
@param failoverWatcher the watcher which has the configuration
@return the acls | [
"Create",
"acl",
"for",
"znodes",
"anyone",
"could",
"read",
"but",
"only",
"admin",
"can",
"operate",
"if",
"set",
"scure",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/ZooKeeperUtil.java#L230-L243 |
116,312 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/ZooKeeperUtil.java | ZooKeeperUtil.longToBytes | public static byte[] longToBytes(long val) {
byte[] b = new byte[8];
for (int i = 7; i > 0; i--) {
b[i] = (byte) val;
val >>>= 8;
}
b[0] = (byte) val;
return b;
} | java | public static byte[] longToBytes(long val) {
byte[] b = new byte[8];
for (int i = 7; i > 0; i--) {
b[i] = (byte) val;
val >>>= 8;
}
b[0] = (byte) val;
return b;
} | [
"public",
"static",
"byte",
"[",
"]",
"longToBytes",
"(",
"long",
"val",
")",
"{",
"byte",
"[",
"]",
"b",
"=",
"new",
"byte",
"[",
"8",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"7",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"b",
"[",
"i... | Convert long value to byte array.
@param val the long value
@return the byte array of this value | [
"Convert",
"long",
"value",
"to",
"byte",
"array",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/ZooKeeperUtil.java#L251-L259 |
116,313 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/ZooKeeperUtil.java | ZooKeeperUtil.bytesToLong | public static long bytesToLong(byte[] bytes) {
long l = 0;
for (int i = 0; i < 0 + 8; i++) {
l <<= 8;
l ^= bytes[i] & 0xFF;
}
return l;
} | java | public static long bytesToLong(byte[] bytes) {
long l = 0;
for (int i = 0; i < 0 + 8; i++) {
l <<= 8;
l ^= bytes[i] & 0xFF;
}
return l;
} | [
"public",
"static",
"long",
"bytesToLong",
"(",
"byte",
"[",
"]",
"bytes",
")",
"{",
"long",
"l",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"0",
"+",
"8",
";",
"i",
"++",
")",
"{",
"l",
"<<=",
"8",
";",
"l",
"^=",
"b... | Convert byte array to original long value.
@param bytes the byte array
@return the original long value | [
"Convert",
"byte",
"array",
"to",
"original",
"long",
"value",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/ZooKeeperUtil.java#L267-L274 |
116,314 | XiaoMi/chronos | chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java | ChronosClientWatcher.reconnectZooKeeper | private void reconnectZooKeeper() throws InterruptedException, IOException {
LOG.info("Try to reconnect ZooKeeper " + zkQuorum);
if (zooKeeper != null) {
zooKeeper.close();
}
connectZooKeeper();
} | java | private void reconnectZooKeeper() throws InterruptedException, IOException {
LOG.info("Try to reconnect ZooKeeper " + zkQuorum);
if (zooKeeper != null) {
zooKeeper.close();
}
connectZooKeeper();
} | [
"private",
"void",
"reconnectZooKeeper",
"(",
")",
"throws",
"InterruptedException",
",",
"IOException",
"{",
"LOG",
".",
"info",
"(",
"\"Try to reconnect ZooKeeper \"",
"+",
"zkQuorum",
")",
";",
"if",
"(",
"zooKeeper",
"!=",
"null",
")",
"{",
"zooKeeper",
".",... | Reconnect with ZooKeeper.
@throws InterruptedException when interrupt close ZooKeeper object
@throws IOException when error to connect with ZooKeeper | [
"Reconnect",
"with",
"ZooKeeper",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java#L83-L90 |
116,315 | XiaoMi/chronos | chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java | ChronosClientWatcher.connectChronosServer | private void connectChronosServer() throws IOException {
LOG.info("Try to connect chronos server");
byte[] hostPortBytes = getData(this, masterZnode);
if (hostPortBytes != null) {
String hostPort = new String(hostPortBytes); // e.g. 127.0.0.0_2181
LOG.info("Find the active chronos server i... | java | private void connectChronosServer() throws IOException {
LOG.info("Try to connect chronos server");
byte[] hostPortBytes = getData(this, masterZnode);
if (hostPortBytes != null) {
String hostPort = new String(hostPortBytes); // e.g. 127.0.0.0_2181
LOG.info("Find the active chronos server i... | [
"private",
"void",
"connectChronosServer",
"(",
")",
"throws",
"IOException",
"{",
"LOG",
".",
"info",
"(",
"\"Try to connect chronos server\"",
")",
";",
"byte",
"[",
"]",
"hostPortBytes",
"=",
"getData",
"(",
"this",
",",
"masterZnode",
")",
";",
"if",
"(",
... | Access ZooKeeper to get current master ChronosServer and connect with it.
@throws IOException when error to access ZooKeeper or connect with ChronosServer | [
"Access",
"ZooKeeper",
"to",
"get",
"current",
"master",
"ChronosServer",
"and",
"connect",
"with",
"it",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java#L97-L116 |
116,316 | XiaoMi/chronos | chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java | ChronosClientWatcher.getTimestamps | public long getTimestamps(int range) throws IOException {
long timestamp;
try {
timestamp = client.getTimestamps(range);
} catch (TException e) {
LOG.info("Can't get timestamp, try to connect the active chronos server");
try {
reconnectChronosServer();
return client.getTime... | java | public long getTimestamps(int range) throws IOException {
long timestamp;
try {
timestamp = client.getTimestamps(range);
} catch (TException e) {
LOG.info("Can't get timestamp, try to connect the active chronos server");
try {
reconnectChronosServer();
return client.getTime... | [
"public",
"long",
"getTimestamps",
"(",
"int",
"range",
")",
"throws",
"IOException",
"{",
"long",
"timestamp",
";",
"try",
"{",
"timestamp",
"=",
"client",
".",
"getTimestamps",
"(",
"range",
")",
";",
"}",
"catch",
"(",
"TException",
"e",
")",
"{",
"LO... | Send RPC request to get timestamp from ChronosServer. Use lazy strategy to detect failure.
If request fails, reconnect ChronosServer. If request fails again, reconnect ZooKeeper.
@param range the number of timestamps
@return the first timestamp to use
@throws IOException when error to connect ChronosServer or ZooKeepe... | [
"Send",
"RPC",
"request",
"to",
"get",
"timestamp",
"from",
"ChronosServer",
".",
"Use",
"lazy",
"strategy",
"to",
"detect",
"failure",
".",
"If",
"request",
"fails",
"reconnect",
"ChronosServer",
".",
"If",
"request",
"fails",
"again",
"reconnect",
"ZooKeeper",... | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java#L140-L161 |
116,317 | XiaoMi/chronos | chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java | ChronosClientWatcher.process | @Override
public void process(WatchedEvent event) {
if (LOG.isDebugEnabled()) {
LOG.info("Received ZooKeeper Event, " + "type=" + event.getType() + ", " + "state="
+ event.getState() + ", " + "path=" + event.getPath());
}
switch (event.getType()) {
case None: {
switch (event.get... | java | @Override
public void process(WatchedEvent event) {
if (LOG.isDebugEnabled()) {
LOG.info("Received ZooKeeper Event, " + "type=" + event.getType() + ", " + "state="
+ event.getState() + ", " + "path=" + event.getPath());
}
switch (event.getType()) {
case None: {
switch (event.get... | [
"@",
"Override",
"public",
"void",
"process",
"(",
"WatchedEvent",
"event",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Received ZooKeeper Event, \"",
"+",
"\"type=\"",
"+",
"event",
".",
"getType",
"(... | Deal with connection event, just wait for a while when connected.
@param event ZooKeeper events | [
"Deal",
"with",
"connection",
"event",
"just",
"wait",
"for",
"a",
"while",
"when",
"connected",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java#L178-L209 |
116,318 | XiaoMi/chronos | chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java | ChronosClientWatcher.waitToInitZooKeeper | public void waitToInitZooKeeper(long maxWaitMillis) throws Exception {
long finished = System.currentTimeMillis() + maxWaitMillis;
while (System.currentTimeMillis() < finished) {
if (this.zooKeeper != null) {
return;
}
try {
Thread.sleep(1);
} catch (Inter... | java | public void waitToInitZooKeeper(long maxWaitMillis) throws Exception {
long finished = System.currentTimeMillis() + maxWaitMillis;
while (System.currentTimeMillis() < finished) {
if (this.zooKeeper != null) {
return;
}
try {
Thread.sleep(1);
} catch (Inter... | [
"public",
"void",
"waitToInitZooKeeper",
"(",
"long",
"maxWaitMillis",
")",
"throws",
"Exception",
"{",
"long",
"finished",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"maxWaitMillis",
";",
"while",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
... | Wait to init ZooKeeper object, only sleep when it's null.
@param maxWaitMillis the max sleep time
@throws Exception if ZooKeeper object is still null | [
"Wait",
"to",
"init",
"ZooKeeper",
"object",
"only",
"sleep",
"when",
"it",
"s",
"null",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java#L217-L231 |
116,319 | XiaoMi/chronos | chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java | ChronosClientWatcher.getData | public byte[] getData(ChronosClientWatcher chronosClientWatcher, String znode)
throws IOException {
byte[] data = null;
for (int i = 0; i <= connectRetryTimes; i++) {
try {
data = chronosClientWatcher.getZooKeeper().getData(znode, null, null);
break;
} catch (Exception e) {
... | java | public byte[] getData(ChronosClientWatcher chronosClientWatcher, String znode)
throws IOException {
byte[] data = null;
for (int i = 0; i <= connectRetryTimes; i++) {
try {
data = chronosClientWatcher.getZooKeeper().getData(znode, null, null);
break;
} catch (Exception e) {
... | [
"public",
"byte",
"[",
"]",
"getData",
"(",
"ChronosClientWatcher",
"chronosClientWatcher",
",",
"String",
"znode",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"data",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"connectR... | Get the data from znode.
@param chronosClientWatcher the ZooKeeper watcher
@param znode the znode you want to access
@return the byte array of value in znode
@throws IOException when error to access ZooKeeper | [
"Get",
"the",
"data",
"from",
"znode",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-client/src/main/java/com/xiaomi/infra/chronos/client/ChronosClientWatcher.java#L242-L257 |
116,320 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServer.java | ChronosServer.initThriftServer | private void initThriftServer() throws TTransportException, FatalChronosException,
ChronosException {
int maxThread = Integer.parseInt(properties.getProperty(MAX_THREAD,
String.valueOf(Integer.MAX_VALUE)));
String serverHost = properties.getProperty(FailoverServer.SERVER_HOST);
int serverPort =... | java | private void initThriftServer() throws TTransportException, FatalChronosException,
ChronosException {
int maxThread = Integer.parseInt(properties.getProperty(MAX_THREAD,
String.valueOf(Integer.MAX_VALUE)));
String serverHost = properties.getProperty(FailoverServer.SERVER_HOST);
int serverPort =... | [
"private",
"void",
"initThriftServer",
"(",
")",
"throws",
"TTransportException",
",",
"FatalChronosException",
",",
"ChronosException",
"{",
"int",
"maxThread",
"=",
"Integer",
".",
"parseInt",
"(",
"properties",
".",
"getProperty",
"(",
"MAX_THREAD",
",",
"String"... | Initialize Thrift server of ChronosServer.
@throws TTransportException when error to initialize thrift server
@throws FatalChronosException when set a smaller timestamp in ZooKeeper
@throws ChronosException when error to set timestamp in ZooKeeper | [
"Initialize",
"Thrift",
"server",
"of",
"ChronosServer",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServer.java#L90-L108 |
116,321 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServer.java | ChronosServer.doAsActiveServer | @Override
public void doAsActiveServer() {
try {
LOG.info("As active master, init timestamp from ZooKeeper");
chronosImplement.initTimestamp();
} catch (Exception e) {
LOG.fatal("Exception to init timestamp from ZooKeeper, exit immediately");
System.exit(0);
}
chronosServe... | java | @Override
public void doAsActiveServer() {
try {
LOG.info("As active master, init timestamp from ZooKeeper");
chronosImplement.initTimestamp();
} catch (Exception e) {
LOG.fatal("Exception to init timestamp from ZooKeeper, exit immediately");
System.exit(0);
}
chronosServe... | [
"@",
"Override",
"public",
"void",
"doAsActiveServer",
"(",
")",
"{",
"try",
"{",
"LOG",
".",
"info",
"(",
"\"As active master, init timestamp from ZooKeeper\"",
")",
";",
"chronosImplement",
".",
"initTimestamp",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"... | Initialize persistent timestamp and start to serve as active master. | [
"Initialize",
"persistent",
"timestamp",
"and",
"start",
"to",
"serve",
"as",
"active",
"master",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServer.java#L113-L127 |
116,322 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServer.java | ChronosServer.main | public static void main(String[] args) {
Properties properties = new Properties();
LOG.info("Load chronos.cfg configuration from class path");
try {
properties.load(ChronosServer.class.getClassLoader().getResourceAsStream("chronos.cfg"));
properties.setProperty(FailoverServer.BASE_ZNODE,
... | java | public static void main(String[] args) {
Properties properties = new Properties();
LOG.info("Load chronos.cfg configuration from class path");
try {
properties.load(ChronosServer.class.getClassLoader().getResourceAsStream("chronos.cfg"));
properties.setProperty(FailoverServer.BASE_ZNODE,
... | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Load chronos.cfg configuration from class path\"",
")",
";",
"try",
"{",
"properties... | The main entrance of ChronosServer to start the service.
@param args will ignore all the command-line arguments | [
"The",
"main",
"entrance",
"of",
"ChronosServer",
"to",
"start",
"the",
"service",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServer.java#L152-L173 |
116,323 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java | ChronosServerWatcher.initZnode | @Override
protected void initZnode() {
try {
ZooKeeperUtil.createAndFailSilent(this, "/chronos");
super.initZnode();
ZooKeeperUtil.createAndFailSilent(this, baseZnode + "/persistent-timestamp");
} catch (Exception e) {
LOG.fatal("Error to create znode of chronos, exit immediately");
... | java | @Override
protected void initZnode() {
try {
ZooKeeperUtil.createAndFailSilent(this, "/chronos");
super.initZnode();
ZooKeeperUtil.createAndFailSilent(this, baseZnode + "/persistent-timestamp");
} catch (Exception e) {
LOG.fatal("Error to create znode of chronos, exit immediately");
... | [
"@",
"Override",
"protected",
"void",
"initZnode",
"(",
")",
"{",
"try",
"{",
"ZooKeeperUtil",
".",
"createAndFailSilent",
"(",
"this",
",",
"\"/chronos\"",
")",
";",
"super",
".",
"initZnode",
"(",
")",
";",
"ZooKeeperUtil",
".",
"createAndFailSilent",
"(",
... | Create the base znode of chronos. | [
"Create",
"the",
"base",
"znode",
"of",
"chronos",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java#L54-L64 |
116,324 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java | ChronosServerWatcher.getPersistentTimestamp | public long getPersistentTimestamp() throws ChronosException {
byte[] persistentTimesampBytes = null;
for (int i = 0; i <= connectRetryTimes; ++i) {
try {
persistentTimesampBytes = ZooKeeperUtil.getDataAndWatch(this, persistentTimestampZnode);
break;
} catch (KeeperException e) {
... | java | public long getPersistentTimestamp() throws ChronosException {
byte[] persistentTimesampBytes = null;
for (int i = 0; i <= connectRetryTimes; ++i) {
try {
persistentTimesampBytes = ZooKeeperUtil.getDataAndWatch(this, persistentTimestampZnode);
break;
} catch (KeeperException e) {
... | [
"public",
"long",
"getPersistentTimestamp",
"(",
")",
"throws",
"ChronosException",
"{",
"byte",
"[",
"]",
"persistentTimesampBytes",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"connectRetryTimes",
";",
"++",
"i",
")",
"{",
"try",
... | Get persistent timestamp in ZooKeeper with retries.
@return the persistent timestamp in ZooKeeper
@throws ChronosException error to get data from ZooKeeper after retrying | [
"Get",
"persistent",
"timestamp",
"in",
"ZooKeeper",
"with",
"retries",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java#L72-L97 |
116,325 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java | ChronosServerWatcher.setPersistentTimestamp | public void setPersistentTimestamp(long newTimestamp) throws FatalChronosException,
ChronosException {
if (newTimestamp <= persistentTimestamp) {
throw new FatalChronosException("Fatal error to set a smaller timestamp");
}
if (LOG.isDebugEnabled()) {
LOG.debug("Setting persistent timestam... | java | public void setPersistentTimestamp(long newTimestamp) throws FatalChronosException,
ChronosException {
if (newTimestamp <= persistentTimestamp) {
throw new FatalChronosException("Fatal error to set a smaller timestamp");
}
if (LOG.isDebugEnabled()) {
LOG.debug("Setting persistent timestam... | [
"public",
"void",
"setPersistentTimestamp",
"(",
"long",
"newTimestamp",
")",
"throws",
"FatalChronosException",
",",
"ChronosException",
"{",
"if",
"(",
"newTimestamp",
"<=",
"persistentTimestamp",
")",
"{",
"throw",
"new",
"FatalChronosException",
"(",
"\"Fatal error ... | Set persistent timestamp in ZooKeeper.
@param newTimestamp the new value to set
@throws FatalChronosException if try to set a small value
@throws ChronosException if error to set value in ZooKeeper | [
"Set",
"persistent",
"timestamp",
"in",
"ZooKeeper",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java#L115-L138 |
116,326 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java | ChronosServerWatcher.processConnection | @Override
protected void processConnection(WatchedEvent event) {
super.processConnection(event);
switch (event.getState()) {
case Disconnected:
if (beenActiveMaster) {
LOG.fatal(hostPort.getHostPort()
+ " disconnected from ZooKeeper, stop serving and exit immediately");
S... | java | @Override
protected void processConnection(WatchedEvent event) {
super.processConnection(event);
switch (event.getState()) {
case Disconnected:
if (beenActiveMaster) {
LOG.fatal(hostPort.getHostPort()
+ " disconnected from ZooKeeper, stop serving and exit immediately");
S... | [
"@",
"Override",
"protected",
"void",
"processConnection",
"(",
"WatchedEvent",
"event",
")",
"{",
"super",
".",
"processConnection",
"(",
"event",
")",
";",
"switch",
"(",
"event",
".",
"getState",
"(",
")",
")",
"{",
"case",
"Disconnected",
":",
"if",
"(... | Deal with the connection event.
@param event the ZooKeeper event. | [
"Deal",
"with",
"the",
"connection",
"event",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosServerWatcher.java#L145-L162 |
116,327 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.connectZooKeeper | protected void connectZooKeeper() throws IOException {
LOG.info("Connecting ZooKeeper " + zkQuorum);
for (int i = 0; i <= connectRetryTimes; i++) {
try {
zooKeeper = new ZooKeeper(zkQuorum, sessionTimeout, this);
break;
} catch (IOException e) {
if (i == connectRetryTimes) {... | java | protected void connectZooKeeper() throws IOException {
LOG.info("Connecting ZooKeeper " + zkQuorum);
for (int i = 0; i <= connectRetryTimes; i++) {
try {
zooKeeper = new ZooKeeper(zkQuorum, sessionTimeout, this);
break;
} catch (IOException e) {
if (i == connectRetryTimes) {... | [
"protected",
"void",
"connectZooKeeper",
"(",
")",
"throws",
"IOException",
"{",
"LOG",
".",
"info",
"(",
"\"Connecting ZooKeeper \"",
"+",
"zkQuorum",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"connectRetryTimes",
";",
"i",
"++",
")",
... | Connect with ZooKeeper with retries.
@throws IOException when error to construct ZooKeeper object after retrying | [
"Connect",
"with",
"ZooKeeper",
"with",
"retries",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L94-L108 |
116,328 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.initZnode | protected void initZnode() {
try {
ZooKeeperUtil.createAndFailSilent(this, baseZnode);
ZooKeeperUtil.createAndFailSilent(this, backupServersZnode);
} catch (Exception e) {
LOG.fatal("Error to create znode " + baseZnode + " and " + backupServersZnode
+ ", exit immediately", e);
... | java | protected void initZnode() {
try {
ZooKeeperUtil.createAndFailSilent(this, baseZnode);
ZooKeeperUtil.createAndFailSilent(this, backupServersZnode);
} catch (Exception e) {
LOG.fatal("Error to create znode " + baseZnode + " and " + backupServersZnode
+ ", exit immediately", e);
... | [
"protected",
"void",
"initZnode",
"(",
")",
"{",
"try",
"{",
"ZooKeeperUtil",
".",
"createAndFailSilent",
"(",
"this",
",",
"baseZnode",
")",
";",
"ZooKeeperUtil",
".",
"createAndFailSilent",
"(",
"this",
",",
"backupServersZnode",
")",
";",
"}",
"catch",
"(",... | Initialize the base znodes of chronos. | [
"Initialize",
"the",
"base",
"znodes",
"of",
"chronos",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L113-L122 |
116,329 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.process | @Override
public void process(WatchedEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug("Received ZooKeeper Event, " + "type=" + event.getType() + ", " + "state="
+ event.getState() + ", " + "path=" + event.getPath());
}
switch (event.getType()) {
case None: {
processConnectio... | java | @Override
public void process(WatchedEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug("Received ZooKeeper Event, " + "type=" + event.getType() + ", " + "state="
+ event.getState() + ", " + "path=" + event.getPath());
}
switch (event.getType()) {
case None: {
processConnectio... | [
"@",
"Override",
"public",
"void",
"process",
"(",
"WatchedEvent",
"event",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Received ZooKeeper Event, \"",
"+",
"\"type=\"",
"+",
"event",
".",
"getType",
"... | Override this mothod to deal with events for leader election.
@param event the ZooKeeper event | [
"Override",
"this",
"mothod",
"to",
"deal",
"with",
"events",
"for",
"leader",
"election",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L129-L160 |
116,330 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.processConnection | protected void processConnection(WatchedEvent event) {
switch (event.getState()) {
case SyncConnected:
LOG.info(hostPort.getHostPort() + " sync connect from ZooKeeper");
try {
waitToInitZooKeeper(2000); // init zookeeper in another thread, wait for a while
} catch (Exception e) {
... | java | protected void processConnection(WatchedEvent event) {
switch (event.getState()) {
case SyncConnected:
LOG.info(hostPort.getHostPort() + " sync connect from ZooKeeper");
try {
waitToInitZooKeeper(2000); // init zookeeper in another thread, wait for a while
} catch (Exception e) {
... | [
"protected",
"void",
"processConnection",
"(",
"WatchedEvent",
"event",
")",
"{",
"switch",
"(",
"event",
".",
"getState",
"(",
")",
")",
"{",
"case",
"SyncConnected",
":",
"LOG",
".",
"info",
"(",
"hostPort",
".",
"getHostPort",
"(",
")",
"+",
"\" sync co... | Deal with connection event, exit current process if auth fails or session expires.
@param event the ZooKeeper event | [
"Deal",
"with",
"connection",
"event",
"exit",
"current",
"process",
"if",
"auth",
"fails",
"or",
"session",
"expires",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L167-L191 |
116,331 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.processNodeCreated | protected void processNodeCreated(String path) {
if (path.equals(masterZnode)) {
LOG.info(masterZnode + " created and try to become active master");
handleMasterNodeChange();
}
} | java | protected void processNodeCreated(String path) {
if (path.equals(masterZnode)) {
LOG.info(masterZnode + " created and try to become active master");
handleMasterNodeChange();
}
} | [
"protected",
"void",
"processNodeCreated",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"path",
".",
"equals",
"(",
"masterZnode",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"masterZnode",
"+",
"\" created and try to become active master\"",
")",
";",
"handleMasterN... | Deal with create node event, just call the leader election.
@param path which znode is created | [
"Deal",
"with",
"create",
"node",
"event",
"just",
"call",
"the",
"leader",
"election",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L198-L203 |
116,332 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.processNodeDeleted | protected void processNodeDeleted(String path) {
if (path.equals(masterZnode)) {
LOG.info(masterZnode + " deleted and try to become active master");
handleMasterNodeChange();
}
} | java | protected void processNodeDeleted(String path) {
if (path.equals(masterZnode)) {
LOG.info(masterZnode + " deleted and try to become active master");
handleMasterNodeChange();
}
} | [
"protected",
"void",
"processNodeDeleted",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"path",
".",
"equals",
"(",
"masterZnode",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"masterZnode",
"+",
"\" deleted and try to become active master\"",
")",
";",
"handleMasterN... | Deal with delete node event, just call the leader election.
@param path which znode is deleted | [
"Deal",
"with",
"delete",
"node",
"event",
"just",
"call",
"the",
"leader",
"election",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L210-L215 |
116,333 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.handleMasterNodeChange | private void handleMasterNodeChange() {
try {
synchronized (hasActiveServer) {
if (ZooKeeperUtil.watchAndCheckExists(this, masterZnode)) {
// A master node exists, there is an active master
if (LOG.isDebugEnabled()) {
LOG.debug("A master is now available");
}
... | java | private void handleMasterNodeChange() {
try {
synchronized (hasActiveServer) {
if (ZooKeeperUtil.watchAndCheckExists(this, masterZnode)) {
// A master node exists, there is an active master
if (LOG.isDebugEnabled()) {
LOG.debug("A master is now available");
}
... | [
"private",
"void",
"handleMasterNodeChange",
"(",
")",
"{",
"try",
"{",
"synchronized",
"(",
"hasActiveServer",
")",
"{",
"if",
"(",
"ZooKeeperUtil",
".",
"watchAndCheckExists",
"(",
"this",
",",
"masterZnode",
")",
")",
"{",
"// A master node exists, there is an ac... | Implement the logic of leader election. | [
"Implement",
"the",
"logic",
"of",
"leader",
"election",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L238-L260 |
116,334 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.blockUntilActive | public boolean blockUntilActive() {
while (true) {
try {
if (ZooKeeperUtil.createEphemeralNodeAndWatch(this, masterZnode, hostPort.getHostPort()
.getBytes())) {
// If we were a backup master before, delete our ZNode from the backup
// master directory since we are the a... | java | public boolean blockUntilActive() {
while (true) {
try {
if (ZooKeeperUtil.createEphemeralNodeAndWatch(this, masterZnode, hostPort.getHostPort()
.getBytes())) {
// If we were a backup master before, delete our ZNode from the backup
// master directory since we are the a... | [
"public",
"boolean",
"blockUntilActive",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"if",
"(",
"ZooKeeperUtil",
".",
"createEphemeralNodeAndWatch",
"(",
"this",
",",
"masterZnode",
",",
"hostPort",
".",
"getHostPort",
"(",
")",
".",
"getBytes... | Implement the logic of server to wait to become active master.
@return false if error to wait to become active master | [
"Implement",
"the",
"logic",
"of",
"server",
"to",
"wait",
"to",
"become",
"active",
"master",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L267-L336 |
116,335 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java | FailoverWatcher.close | public void close() {
if (zooKeeper != null) {
try {
zooKeeper.close();
} catch (InterruptedException e) {
LOG.error("Interrupt when closing zookeeper connection", e);
}
}
} | java | public void close() {
if (zooKeeper != null) {
try {
zooKeeper.close();
} catch (InterruptedException e) {
LOG.error("Interrupt when closing zookeeper connection", e);
}
}
} | [
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"zooKeeper",
"!=",
"null",
")",
"{",
"try",
"{",
"zooKeeper",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Interrupt when closin... | Close the ZooKeeper object. | [
"Close",
"the",
"ZooKeeper",
"object",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L341-L349 |
116,336 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/HostPort.java | HostPort.parseHostPort | public static HostPort parseHostPort(String string) {
String[] strings = string.split("_");
return new HostPort(strings[0], Integer.parseInt(strings[1]));
} | java | public static HostPort parseHostPort(String string) {
String[] strings = string.split("_");
return new HostPort(strings[0], Integer.parseInt(strings[1]));
} | [
"public",
"static",
"HostPort",
"parseHostPort",
"(",
"String",
"string",
")",
"{",
"String",
"[",
"]",
"strings",
"=",
"string",
".",
"split",
"(",
"\"_\"",
")",
";",
"return",
"new",
"HostPort",
"(",
"strings",
"[",
"0",
"]",
",",
"Integer",
".",
"pa... | Parse a host_port string to construct the HostPost object.
@param string the host_port string
@return the HostPort object | [
"Parse",
"a",
"host_port",
"string",
"to",
"construct",
"the",
"HostPost",
"object",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/HostPort.java#L39-L42 |
116,337 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java | ChronosImplement.getTimestamps | public long getTimestamps(int range) throws TException {
// can get 2^18(262144) times for each millisecond for about 1115 years
long currentTime = System.currentTimeMillis() << 18;
synchronized (this) {
// maxAssignedTimestamp is assigned last time, can't return currentTime when it's less or equal
... | java | public long getTimestamps(int range) throws TException {
// can get 2^18(262144) times for each millisecond for about 1115 years
long currentTime = System.currentTimeMillis() << 18;
synchronized (this) {
// maxAssignedTimestamp is assigned last time, can't return currentTime when it's less or equal
... | [
"public",
"long",
"getTimestamps",
"(",
"int",
"range",
")",
"throws",
"TException",
"{",
"// can get 2^18(262144) times for each millisecond for about 1115 years",
"long",
"currentTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"<<",
"18",
";",
"synchronized",
... | Assign required number of timestamps, client can use [timestamp, timestamp + range).
@param range, the number of timestamps to assign
@return timestamp, the first available timestamp to client | [
"Assign",
"required",
"number",
"of",
"timestamps",
"client",
"can",
"use",
"[",
"timestamp",
"timestamp",
"+",
"range",
")",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java#L47-L98 |
116,338 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java | ChronosImplement.sleepUntilAsyncSet | private void sleepUntilAsyncSet() {
LOG.info("Sleep a while until asynchronously set persistent timestamp");
while (isAsyncSetPersistentTimestamp) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
LOG.fatal("Interrupt when sleep to set persistent timestamp, exit immediately... | java | private void sleepUntilAsyncSet() {
LOG.info("Sleep a while until asynchronously set persistent timestamp");
while (isAsyncSetPersistentTimestamp) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
LOG.fatal("Interrupt when sleep to set persistent timestamp, exit immediately... | [
"private",
"void",
"sleepUntilAsyncSet",
"(",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Sleep a while until asynchronously set persistent timestamp\"",
")",
";",
"while",
"(",
"isAsyncSetPersistentTimestamp",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"1",
")",
... | Sleep until asynchronously set persistent timestamp successfully. | [
"Sleep",
"until",
"asynchronously",
"set",
"persistent",
"timestamp",
"successfully",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java#L113-L123 |
116,339 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java | ChronosImplement.initTimestamp | public void initTimestamp() throws ChronosException, FatalChronosException {
maxAssignedTimestamp = chronosServerWatcher.getPersistentTimestamp();
long newPersistentTimestamp = maxAssignedTimestamp + zkAdvanceTimestamp;
chronosServerWatcher.setPersistentTimestamp(newPersistentTimestamp);
LOG.info("Get p... | java | public void initTimestamp() throws ChronosException, FatalChronosException {
maxAssignedTimestamp = chronosServerWatcher.getPersistentTimestamp();
long newPersistentTimestamp = maxAssignedTimestamp + zkAdvanceTimestamp;
chronosServerWatcher.setPersistentTimestamp(newPersistentTimestamp);
LOG.info("Get p... | [
"public",
"void",
"initTimestamp",
"(",
")",
"throws",
"ChronosException",
",",
"FatalChronosException",
"{",
"maxAssignedTimestamp",
"=",
"chronosServerWatcher",
".",
"getPersistentTimestamp",
"(",
")",
";",
"long",
"newPersistentTimestamp",
"=",
"maxAssignedTimestamp",
... | Get the persistent timestamp in ZooKeeper and initialize the new one in ZooKeeper.
@throws ChronosException when error to set value in ZooKeeper
@throws FatalChronosException when set a smaller timestamp in ZooKeeper | [
"Get",
"the",
"persistent",
"timestamp",
"in",
"ZooKeeper",
"and",
"initialize",
"the",
"new",
"one",
"in",
"ZooKeeper",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java#L131-L137 |
116,340 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java | ChronosImplement.asyncSetPersistentTimestamp | public synchronized void asyncSetPersistentTimestamp(final long newPersistentTimestamp) {
new Thread() {
@Override
public void run() {
try {
chronosServerWatcher.setPersistentTimestamp(newPersistentTimestamp);
isAsyncSetPersistentTimestamp = false;
} catch (Exception ... | java | public synchronized void asyncSetPersistentTimestamp(final long newPersistentTimestamp) {
new Thread() {
@Override
public void run() {
try {
chronosServerWatcher.setPersistentTimestamp(newPersistentTimestamp);
isAsyncSetPersistentTimestamp = false;
} catch (Exception ... | [
"public",
"synchronized",
"void",
"asyncSetPersistentTimestamp",
"(",
"final",
"long",
"newPersistentTimestamp",
")",
"{",
"new",
"Thread",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"chronosServerWatcher",
".",
"setPersi... | Create a new thread to asynchronously set persistent timestamp in ZooKeeper.
@param newPersistentTimestamp the new timestamp to set | [
"Create",
"a",
"new",
"thread",
"to",
"asynchronously",
"set",
"persistent",
"timestamp",
"in",
"ZooKeeper",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/ChronosImplement.java#L144-L157 |
116,341 | XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverServer.java | FailoverServer.doAsActiveServer | public void doAsActiveServer() {
while (true) {
LOG.info("No business logic, sleep for " + Integer.MAX_VALUE);
try {
Thread.sleep(Integer.MAX_VALUE);
} catch (InterruptedException e) {
LOG.error("Interrupt when sleeping as active master", e);
}
}
} | java | public void doAsActiveServer() {
while (true) {
LOG.info("No business logic, sleep for " + Integer.MAX_VALUE);
try {
Thread.sleep(Integer.MAX_VALUE);
} catch (InterruptedException e) {
LOG.error("Interrupt when sleeping as active master", e);
}
}
} | [
"public",
"void",
"doAsActiveServer",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"LOG",
".",
"info",
"(",
"\"No business logic, sleep for \"",
"+",
"Integer",
".",
"MAX_VALUE",
")",
";",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"Integer",
".",
"MAX_VAL... | The method you should override to do your business logic after becoming active master. | [
"The",
"method",
"you",
"should",
"override",
"to",
"do",
"your",
"business",
"logic",
"after",
"becoming",
"active",
"master",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverServer.java#L72-L81 |
116,342 | XiaoMi/chronos | chronos-client/src/main/java/com/xiaomi/infra/chronos/benchmark/BenchmarkChronosServer.java | BenchmarkChronosServer.startBenchmark | public void startBenchmark() {
startTime = System.currentTimeMillis();
LOG.info("Start to benchmark chronos server");
Thread t = new Thread() { // new thread to output the metrics
@Override
public void run() {
final long collectPeriod = 10000;
LOG.info("Start another thread to e... | java | public void startBenchmark() {
startTime = System.currentTimeMillis();
LOG.info("Start to benchmark chronos server");
Thread t = new Thread() { // new thread to output the metrics
@Override
public void run() {
final long collectPeriod = 10000;
LOG.info("Start another thread to e... | [
"public",
"void",
"startBenchmark",
"(",
")",
"{",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Start to benchmark chronos server\"",
")",
";",
"Thread",
"t",
"=",
"new",
"Thread",
"(",
")",
"{",
"// new th... | Benchmark ChronosServer and print metrics in another thread. | [
"Benchmark",
"ChronosServer",
"and",
"print",
"metrics",
"in",
"another",
"thread",
"."
] | 92e4a30c98947e87aba47ea88c944a56505a4ec0 | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-client/src/main/java/com/xiaomi/infra/chronos/benchmark/BenchmarkChronosServer.java#L43-L123 |
116,343 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitSet.java | BitSet.set | public void set(long startIndex, long endIndex)
{
if (endIndex <= startIndex) return;
int startWord = (int) (startIndex >> 6);
// since endIndex is one past the end, this is index of the last
// word to be changed.
int endWord = expandingWordNum(endIndex - 1);
long... | java | public void set(long startIndex, long endIndex)
{
if (endIndex <= startIndex) return;
int startWord = (int) (startIndex >> 6);
// since endIndex is one past the end, this is index of the last
// word to be changed.
int endWord = expandingWordNum(endIndex - 1);
long... | [
"public",
"void",
"set",
"(",
"long",
"startIndex",
",",
"long",
"endIndex",
")",
"{",
"if",
"(",
"endIndex",
"<=",
"startIndex",
")",
"return",
";",
"int",
"startWord",
"=",
"(",
"int",
")",
"(",
"startIndex",
">>",
"6",
")",
";",
"// since endIndex is ... | Sets a range of bits, expanding the set size if necessary
@param startIndex lower index
@param endIndex one-past the last bit to set | [
"Sets",
"a",
"range",
"of",
"bits",
"expanding",
"the",
"set",
"size",
"if",
"necessary"
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java#L217-L240 |
116,344 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitSet.java | BitSet.clear | public void clear(int startIndex, int endIndex)
{
if (endIndex <= startIndex) return;
int startWord = (startIndex >> 6);
if (startWord >= wlen) return;
// since endIndex is one past the end, this is index of the last
// word to be changed.
int endWord = ((endIndex -... | java | public void clear(int startIndex, int endIndex)
{
if (endIndex <= startIndex) return;
int startWord = (startIndex >> 6);
if (startWord >= wlen) return;
// since endIndex is one past the end, this is index of the last
// word to be changed.
int endWord = ((endIndex -... | [
"public",
"void",
"clear",
"(",
"int",
"startIndex",
",",
"int",
"endIndex",
")",
"{",
"if",
"(",
"endIndex",
"<=",
"startIndex",
")",
"return",
";",
"int",
"startWord",
"=",
"(",
"startIndex",
">>",
"6",
")",
";",
"if",
"(",
"startWord",
">=",
"wlen",... | Clears a range of bits. Clearing past the end does not change the size of the set.
@param startIndex lower index
@param endIndex one-past the last bit to clear | [
"Clears",
"a",
"range",
"of",
"bits",
".",
"Clearing",
"past",
"the",
"end",
"does",
"not",
"change",
"the",
"size",
"of",
"the",
"set",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java#L281-L314 |
116,345 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitSet.java | BitSet.getAndSet | public boolean getAndSet(int index)
{
int wordNum = index >> 6; // div 64
int bit = index & 0x3f; // mod 64
long bitmask = 1L << bit;
boolean val = (bits[wordNum] & bitmask) != 0;
bits[wordNum] |= bitmask;
return val;
} | java | public boolean getAndSet(int index)
{
int wordNum = index >> 6; // div 64
int bit = index & 0x3f; // mod 64
long bitmask = 1L << bit;
boolean val = (bits[wordNum] & bitmask) != 0;
bits[wordNum] |= bitmask;
return val;
} | [
"public",
"boolean",
"getAndSet",
"(",
"int",
"index",
")",
"{",
"int",
"wordNum",
"=",
"index",
">>",
"6",
";",
"// div 64",
"int",
"bit",
"=",
"index",
"&",
"0x3f",
";",
"// mod 64",
"long",
"bitmask",
"=",
"1L",
"<<",
"bit",
";",
"boolean",
"val",
... | Sets a bit and returns the previous value. The index should be less than the BitSet
size.
@param index the index to set
@return previous state of the index | [
"Sets",
"a",
"bit",
"and",
"returns",
"the",
"previous",
"value",
".",
"The",
"index",
"should",
"be",
"less",
"than",
"the",
"BitSet",
"size",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java#L364-L372 |
116,346 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitSet.java | BitSet.flipAndGet | public boolean flipAndGet(long index)
{
int wordNum = (int) (index >> 6); // div 64
int bit = (int) index & 0x3f; // mod 64
long bitmask = 1L << bit;
bits[wordNum] ^= bitmask;
return (bits[wordNum] & bitmask) != 0;
} | java | public boolean flipAndGet(long index)
{
int wordNum = (int) (index >> 6); // div 64
int bit = (int) index & 0x3f; // mod 64
long bitmask = 1L << bit;
bits[wordNum] ^= bitmask;
return (bits[wordNum] & bitmask) != 0;
} | [
"public",
"boolean",
"flipAndGet",
"(",
"long",
"index",
")",
"{",
"int",
"wordNum",
"=",
"(",
"int",
")",
"(",
"index",
">>",
"6",
")",
";",
"// div 64",
"int",
"bit",
"=",
"(",
"int",
")",
"index",
"&",
"0x3f",
";",
"// mod 64",
"long",
"bitmask",
... | flips a bit and returns the resulting bit value. The index should be less than the
BitSet size.
@param index the index to flip
@return previous state of the index | [
"flips",
"a",
"bit",
"and",
"returns",
"the",
"resulting",
"bit",
"value",
".",
"The",
"index",
"should",
"be",
"less",
"than",
"the",
"BitSet",
"size",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java#L427-L434 |
116,347 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitSet.java | BitSet.flip | public void flip(long startIndex, long endIndex)
{
if (endIndex <= startIndex) return;
int startWord = (int) (startIndex >> 6);
// since endIndex is one past the end, this is index of the last
// word to be changed.
int endWord = expandingWordNum(endIndex - 1);
long... | java | public void flip(long startIndex, long endIndex)
{
if (endIndex <= startIndex) return;
int startWord = (int) (startIndex >> 6);
// since endIndex is one past the end, this is index of the last
// word to be changed.
int endWord = expandingWordNum(endIndex - 1);
long... | [
"public",
"void",
"flip",
"(",
"long",
"startIndex",
",",
"long",
"endIndex",
")",
"{",
"if",
"(",
"endIndex",
"<=",
"startIndex",
")",
"return",
";",
"int",
"startWord",
"=",
"(",
"int",
")",
"(",
"startIndex",
">>",
"6",
")",
";",
"// since endIndex is... | Flips a range of bits, expanding the set size if necessary
@param startIndex lower index
@param endIndex one-past the last bit to flip | [
"Flips",
"a",
"range",
"of",
"bits",
"expanding",
"the",
"set",
"size",
"if",
"necessary"
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java#L442-L469 |
116,348 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitSetIterator.java | BitSetIterator.shift | private void shift() {
if ((int)word ==0) {wordShift +=32; word = word >>>32; }
if ((word & 0x0000FFFF) == 0) { wordShift +=16; word >>>=16; }
if ((word & 0x000000FF) == 0) { wordShift +=8; word >>>=8; }
indexArray = bitlist[(int)word & 0xff];
} | java | private void shift() {
if ((int)word ==0) {wordShift +=32; word = word >>>32; }
if ((word & 0x0000FFFF) == 0) { wordShift +=16; word >>>=16; }
if ((word & 0x000000FF) == 0) { wordShift +=8; word >>>=8; }
indexArray = bitlist[(int)word & 0xff];
} | [
"private",
"void",
"shift",
"(",
")",
"{",
"if",
"(",
"(",
"int",
")",
"word",
"==",
"0",
")",
"{",
"wordShift",
"+=",
"32",
";",
"word",
"=",
"word",
">>>",
"32",
";",
"}",
"if",
"(",
"(",
"word",
"&",
"0x0000FFFF",
")",
"==",
"0",
")",
"{",... | 64 bit shifts | [
"64",
"bit",
"shifts"
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitSetIterator.java#L106-L111 |
116,349 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java | KTypeStack.push | public void push(KType e1, KType e2) {
ensureBufferSpace(2);
buffer[elementsCount++] = e1;
buffer[elementsCount++] = e2;
} | java | public void push(KType e1, KType e2) {
ensureBufferSpace(2);
buffer[elementsCount++] = e1;
buffer[elementsCount++] = e2;
} | [
"public",
"void",
"push",
"(",
"KType",
"e1",
",",
"KType",
"e2",
")",
"{",
"ensureBufferSpace",
"(",
"2",
")",
";",
"buffer",
"[",
"elementsCount",
"++",
"]",
"=",
"e1",
";",
"buffer",
"[",
"elementsCount",
"++",
"]",
"=",
"e2",
";",
"}"
] | Adds two KTypes to the stack. | [
"Adds",
"two",
"KTypes",
"to",
"the",
"stack",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java#L65-L69 |
116,350 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java | KTypeStack.push | public void push(KType[] elements, int start, int len) {
assert start >= 0 && len >= 0;
ensureBufferSpace(len);
System.arraycopy(elements, start, buffer, elementsCount, len);
elementsCount += len;
} | java | public void push(KType[] elements, int start, int len) {
assert start >= 0 && len >= 0;
ensureBufferSpace(len);
System.arraycopy(elements, start, buffer, elementsCount, len);
elementsCount += len;
} | [
"public",
"void",
"push",
"(",
"KType",
"[",
"]",
"elements",
",",
"int",
"start",
",",
"int",
"len",
")",
"{",
"assert",
"start",
">=",
"0",
"&&",
"len",
">=",
"0",
";",
"ensureBufferSpace",
"(",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"... | Add a range of array elements to the stack. | [
"Add",
"a",
"range",
"of",
"array",
"elements",
"to",
"the",
"stack",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java#L95-L101 |
116,351 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java | KTypeStack.discard | public void discard(int count) {
assert elementsCount >= count;
elementsCount -= count;
/* #if ($TemplateOptions.KTypeGeneric) */
Arrays.fill(buffer, elementsCount, elementsCount + count, null);
/* #end */
} | java | public void discard(int count) {
assert elementsCount >= count;
elementsCount -= count;
/* #if ($TemplateOptions.KTypeGeneric) */
Arrays.fill(buffer, elementsCount, elementsCount + count, null);
/* #end */
} | [
"public",
"void",
"discard",
"(",
"int",
"count",
")",
"{",
"assert",
"elementsCount",
">=",
"count",
";",
"elementsCount",
"-=",
"count",
";",
"/* #if ($TemplateOptions.KTypeGeneric) */",
"Arrays",
".",
"fill",
"(",
"buffer",
",",
"elementsCount",
",",
"elementsC... | Discard an arbitrary number of elements from the top of the stack. | [
"Discard",
"an",
"arbitrary",
"number",
"of",
"elements",
"from",
"the",
"top",
"of",
"the",
"stack",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java#L134-L141 |
116,352 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java | KTypeStack.pop | public KType pop() {
assert elementsCount > 0;
final KType v = Intrinsics.<KType> cast(buffer[--elementsCount]);
/* #if ($TemplateOptions.KTypeGeneric) */
buffer[elementsCount] = null;
/* #end */
return v;
} | java | public KType pop() {
assert elementsCount > 0;
final KType v = Intrinsics.<KType> cast(buffer[--elementsCount]);
/* #if ($TemplateOptions.KTypeGeneric) */
buffer[elementsCount] = null;
/* #end */
return v;
} | [
"public",
"KType",
"pop",
"(",
")",
"{",
"assert",
"elementsCount",
">",
"0",
";",
"final",
"KType",
"v",
"=",
"Intrinsics",
".",
"<",
"KType",
">",
"cast",
"(",
"buffer",
"[",
"--",
"elementsCount",
"]",
")",
";",
"/* #if ($TemplateOptions.KTypeGeneric) */"... | Remove the top element from the stack and return it. | [
"Remove",
"the",
"top",
"element",
"from",
"the",
"stack",
"and",
"return",
"it",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeStack.java#L158-L166 |
116,353 | carrotsearch/hppc | hppc-template-processor/src/main/java/com/carrotsearch/hppc/Intrinsics.java | Intrinsics.add | @SuppressWarnings("unchecked")
public static <T> T add(T op1, T op2) {
if (op1.getClass() != op2.getClass()) {
throw new RuntimeException("Arguments of different classes: " + op1 + " " + op2);
}
if (Byte.class.isInstance(op1)) {
return (T)(Byte)(byte)(((Byte) op1).byteValue() + ((Byte) op2).b... | java | @SuppressWarnings("unchecked")
public static <T> T add(T op1, T op2) {
if (op1.getClass() != op2.getClass()) {
throw new RuntimeException("Arguments of different classes: " + op1 + " " + op2);
}
if (Byte.class.isInstance(op1)) {
return (T)(Byte)(byte)(((Byte) op1).byteValue() + ((Byte) op2).b... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"add",
"(",
"T",
"op1",
",",
"T",
"op2",
")",
"{",
"if",
"(",
"op1",
".",
"getClass",
"(",
")",
"!=",
"op2",
".",
"getClass",
"(",
")",
")",
"{",
"throw",... | An intrinsic that is replaced with plain addition of arguments for
primitive template types. Invalid for non-number generic types. | [
"An",
"intrinsic",
"that",
"is",
"replaced",
"with",
"plain",
"addition",
"of",
"arguments",
"for",
"primitive",
"template",
"types",
".",
"Invalid",
"for",
"non",
"-",
"number",
"generic",
"types",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc-template-processor/src/main/java/com/carrotsearch/hppc/Intrinsics.java#L116-L145 |
116,354 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/AbstractKTypeCollection.java | AbstractKTypeCollection.removeAll | @Override
public int removeAll(final KTypeLookupContainer<? super KType> c) {
// We know c holds sub-types of KType and we're not modifying c, so go unchecked.
return this.removeAll(new KTypePredicate<KType>() {
public boolean apply(KType k) {
return c.contains(k);
}
});
} | java | @Override
public int removeAll(final KTypeLookupContainer<? super KType> c) {
// We know c holds sub-types of KType and we're not modifying c, so go unchecked.
return this.removeAll(new KTypePredicate<KType>() {
public boolean apply(KType k) {
return c.contains(k);
}
});
} | [
"@",
"Override",
"public",
"int",
"removeAll",
"(",
"final",
"KTypeLookupContainer",
"<",
"?",
"super",
"KType",
">",
"c",
")",
"{",
"// We know c holds sub-types of KType and we're not modifying c, so go unchecked.\r",
"return",
"this",
".",
"removeAll",
"(",
"new",
"K... | Default implementation uses a predicate for removal. | [
"Default",
"implementation",
"uses",
"a",
"predicate",
"for",
"removal",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/AbstractKTypeCollection.java#L22-L30 |
116,355 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/AbstractKTypeCollection.java | AbstractKTypeCollection.toArray | @Override
/*!#if ($TemplateOptions.KTypePrimitive)
public KType [] toArray()
#else !*/
public Object[] toArray()
/*! #end !*/
{
KType[] array = Intrinsics.<KType> newArray(size());
int i = 0;
for (KTypeCursor<KType> c : this) {
array[i++] = c.value;
}
return array;
... | java | @Override
/*!#if ($TemplateOptions.KTypePrimitive)
public KType [] toArray()
#else !*/
public Object[] toArray()
/*! #end !*/
{
KType[] array = Intrinsics.<KType> newArray(size());
int i = 0;
for (KTypeCursor<KType> c : this) {
array[i++] = c.value;
}
return array;
... | [
"@",
"Override",
"/*!#if ($TemplateOptions.KTypePrimitive)\r\n public KType [] toArray()\r\n #else !*/",
"public",
"Object",
"[",
"]",
"toArray",
"(",
")",
"/*! #end !*/",
"{",
"KType",
"[",
"]",
"array",
"=",
"Intrinsics",
".",
"<",
"KType",
">",
"newArray",
"(",
... | Default implementation of copying to an array. | [
"Default",
"implementation",
"of",
"copying",
"to",
"an",
"array",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/AbstractKTypeCollection.java#L61-L74 |
116,356 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeVTypeHashMap.java | KTypeVTypeHashMap.from | public static <KType, VType> KTypeVTypeHashMap<KType, VType> from(KType[] keys, VType[] values) {
if (keys.length != values.length) {
throw new IllegalArgumentException("Arrays of keys and values must have an identical length.");
}
KTypeVTypeHashMap<KType, VType> map = new KTypeVTypeHashMap<>(keys.le... | java | public static <KType, VType> KTypeVTypeHashMap<KType, VType> from(KType[] keys, VType[] values) {
if (keys.length != values.length) {
throw new IllegalArgumentException("Arrays of keys and values must have an identical length.");
}
KTypeVTypeHashMap<KType, VType> map = new KTypeVTypeHashMap<>(keys.le... | [
"public",
"static",
"<",
"KType",
",",
"VType",
">",
"KTypeVTypeHashMap",
"<",
"KType",
",",
"VType",
">",
"from",
"(",
"KType",
"[",
"]",
"keys",
",",
"VType",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"keys",
".",
"length",
"!=",
"values",
".",
"l... | Creates a hash map from two index-aligned arrays of key-value pairs. | [
"Creates",
"a",
"hash",
"map",
"from",
"two",
"index",
"-",
"aligned",
"arrays",
"of",
"key",
"-",
"value",
"pairs",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeVTypeHashMap.java#L1066-L1077 |
116,357 | carrotsearch/hppc | hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/parser/SignatureProcessor.java | SignatureProcessor.processComment | private String processComment(String text, TemplateOptions options) {
if (options.hasKType()) {
text = text.replaceAll("(KType)(?=\\p{Lu})", options.getKType().getBoxedType());
text = text.replace("KType", options.getKType().getType());
}
if (options.hasVType()) {
text = text.replace... | java | private String processComment(String text, TemplateOptions options) {
if (options.hasKType()) {
text = text.replaceAll("(KType)(?=\\p{Lu})", options.getKType().getBoxedType());
text = text.replace("KType", options.getKType().getType());
}
if (options.hasVType()) {
text = text.replace... | [
"private",
"String",
"processComment",
"(",
"String",
"text",
",",
"TemplateOptions",
"options",
")",
"{",
"if",
"(",
"options",
".",
"hasKType",
"(",
")",
")",
"{",
"text",
"=",
"text",
".",
"replaceAll",
"(",
"\"(KType)(?=\\\\p{Lu})\"",
",",
"options",
"."... | Process references inside comment blocks, javadocs, etc. | [
"Process",
"references",
"inside",
"comment",
"blocks",
"javadocs",
"etc",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/parser/SignatureProcessor.java#L63-L73 |
116,358 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java | KTypeHashSet.addAll | public int addAll(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int count = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
if (add(cursor.value)) {
count++;
}
}
return count;
} | java | public int addAll(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int count = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
if (add(cursor.value)) {
count++;
}
}
return count;
} | [
"public",
"int",
"addAll",
"(",
"Iterable",
"<",
"?",
"extends",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
">",
"iterable",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
"cursor",
":",
... | Adds all elements from the given iterable to this set.
@return Returns the number of elements actually added as a result of this
call (not previously present in the set). | [
"Adds",
"all",
"elements",
"from",
"the",
"given",
"iterable",
"to",
"this",
"set",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java#L212-L220 |
116,359 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java | KTypeHashSet.indexGet | public KType indexGet(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask ||
(index == mask + 1 && hasEmptyKey);
return Intrinsics.<KType> cast(keys[index]);
} | java | public KType indexGet(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask ||
(index == mask + 1 && hasEmptyKey);
return Intrinsics.<KType> cast(keys[index]);
} | [
"public",
"KType",
"indexGet",
"(",
"int",
"index",
")",
"{",
"assert",
"index",
">=",
"0",
":",
"\"The index must point at an existing key.\"",
";",
"assert",
"index",
"<=",
"mask",
"||",
"(",
"index",
"==",
"mask",
"+",
"1",
"&&",
"hasEmptyKey",
")",
";",
... | Returns the exact value of the existing key. This method makes sense for sets
of objects which define custom key-equality relationship.
@see #indexOf
@param index The index of an existing key.
@return Returns the equivalent key currently stored in the set.
@throws AssertionError If assertions are enabled and the inde... | [
"Returns",
"the",
"exact",
"value",
"of",
"the",
"existing",
"key",
".",
"This",
"method",
"makes",
"sense",
"for",
"sets",
"of",
"objects",
"which",
"define",
"custom",
"key",
"-",
"equality",
"relationship",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java#L638-L644 |
116,360 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java | KTypeHashSet.indexReplace | public KType indexReplace(int index, KType equivalentKey) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask ||
(index == mask + 1 && hasEmptyKey);
assert Intrinsics.equals(this, keys[index], equivalentKey);
KType previousValue = Intrinsics.<KType> cast(ke... | java | public KType indexReplace(int index, KType equivalentKey) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask ||
(index == mask + 1 && hasEmptyKey);
assert Intrinsics.equals(this, keys[index], equivalentKey);
KType previousValue = Intrinsics.<KType> cast(ke... | [
"public",
"KType",
"indexReplace",
"(",
"int",
"index",
",",
"KType",
"equivalentKey",
")",
"{",
"assert",
"index",
">=",
"0",
":",
"\"The index must point at an existing key.\"",
";",
"assert",
"index",
"<=",
"mask",
"||",
"(",
"index",
"==",
"mask",
"+",
"1"... | Replaces the existing equivalent key with the given one and returns any previous value
stored for that key.
@see #indexOf
@param index The index of an existing key.
@param equivalentKey The key to put in the set as a replacement. Must be equivalent to
the key currently stored at the provided index.
@return Returns th... | [
"Replaces",
"the",
"existing",
"equivalent",
"key",
"with",
"the",
"given",
"one",
"and",
"returns",
"any",
"previous",
"value",
"stored",
"for",
"that",
"key",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java#L659-L668 |
116,361 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java | KTypeHashSet.indexInsert | public void indexInsert(int index, KType key) {
assert index < 0 : "The index must not point at an existing key.";
index = ~index;
if (Intrinsics.isEmpty(key)) {
assert index == mask + 1;
assert Intrinsics.isEmpty(keys[index]);
hasEmptyKey = true;
} else {
assert Intrinsics.isEm... | java | public void indexInsert(int index, KType key) {
assert index < 0 : "The index must not point at an existing key.";
index = ~index;
if (Intrinsics.isEmpty(key)) {
assert index == mask + 1;
assert Intrinsics.isEmpty(keys[index]);
hasEmptyKey = true;
} else {
assert Intrinsics.isEm... | [
"public",
"void",
"indexInsert",
"(",
"int",
"index",
",",
"KType",
"key",
")",
"{",
"assert",
"index",
"<",
"0",
":",
"\"The index must not point at an existing key.\"",
";",
"index",
"=",
"~",
"index",
";",
"if",
"(",
"Intrinsics",
".",
"isEmpty",
"(",
"ke... | Inserts a key for an index that is not present in the set. This method
may help in avoiding double recalculation of the key's hash.
@see #indexOf
@param index The index of a previously non-existing key, as returned from
{@link #indexOf}.
@throws AssertionError If assertions are enabled and the index does
not correspo... | [
"Inserts",
"a",
"key",
"for",
"an",
"index",
"that",
"is",
"not",
"present",
"in",
"the",
"set",
".",
"This",
"method",
"may",
"help",
"in",
"avoiding",
"double",
"recalculation",
"of",
"the",
"key",
"s",
"hash",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeHashSet.java#L681-L700 |
116,362 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/sorting/IndirectSort.java | IndirectSort.topDownMergeSort | private static void topDownMergeSort(int[] src, int[] dst, int fromIndex, int toIndex, IndirectComparator comp) {
if (toIndex - fromIndex <= MIN_LENGTH_FOR_INSERTION_SORT) {
insertionSort(fromIndex, toIndex - fromIndex, dst, comp);
return;
}
final int mid = (fromIndex + toIndex) >>> 1;
topD... | java | private static void topDownMergeSort(int[] src, int[] dst, int fromIndex, int toIndex, IndirectComparator comp) {
if (toIndex - fromIndex <= MIN_LENGTH_FOR_INSERTION_SORT) {
insertionSort(fromIndex, toIndex - fromIndex, dst, comp);
return;
}
final int mid = (fromIndex + toIndex) >>> 1;
topD... | [
"private",
"static",
"void",
"topDownMergeSort",
"(",
"int",
"[",
"]",
"src",
",",
"int",
"[",
"]",
"dst",
",",
"int",
"fromIndex",
",",
"int",
"toIndex",
",",
"IndirectComparator",
"comp",
")",
"{",
"if",
"(",
"toIndex",
"-",
"fromIndex",
"<=",
"MIN_LEN... | Perform a recursive, descending merge sort.
@param fromIndex
inclusive
@param toIndex
exclusive | [
"Perform",
"a",
"recursive",
"descending",
"merge",
"sort",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/sorting/IndirectSort.java#L70-L101 |
116,363 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/sorting/IndirectSort.java | IndirectSort.createOrderArray | private static int[] createOrderArray(final int start, final int length) {
final int[] order = new int[length];
for (int i = 0; i < length; i++) {
order[i] = start + i;
}
return order;
} | java | private static int[] createOrderArray(final int start, final int length) {
final int[] order = new int[length];
for (int i = 0; i < length; i++) {
order[i] = start + i;
}
return order;
} | [
"private",
"static",
"int",
"[",
"]",
"createOrderArray",
"(",
"final",
"int",
"start",
",",
"final",
"int",
"length",
")",
"{",
"final",
"int",
"[",
"]",
"order",
"=",
"new",
"int",
"[",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
... | Creates the initial order array. | [
"Creates",
"the",
"initial",
"order",
"array",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/sorting/IndirectSort.java#L120-L126 |
116,364 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayList.java | KTypeArrayList.add | public void add(KType[] elements, int start, int length) {
assert length >= 0 : "Length must be >= 0";
ensureBufferSpace(length);
System.arraycopy(elements, start, buffer, elementsCount, length);
elementsCount += length;
} | java | public void add(KType[] elements, int start, int length) {
assert length >= 0 : "Length must be >= 0";
ensureBufferSpace(length);
System.arraycopy(elements, start, buffer, elementsCount, length);
elementsCount += length;
} | [
"public",
"void",
"add",
"(",
"KType",
"[",
"]",
"elements",
",",
"int",
"start",
",",
"int",
"length",
")",
"{",
"assert",
"length",
">=",
"0",
":",
"\"Length must be >= 0\"",
";",
"ensureBufferSpace",
"(",
"length",
")",
";",
"System",
".",
"arraycopy",
... | Add all elements from a range of given array to the list. | [
"Add",
"all",
"elements",
"from",
"a",
"range",
"of",
"given",
"array",
"to",
"the",
"list",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayList.java#L127-L133 |
116,365 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayList.java | KTypeArrayList.addAll | public int addAll(KTypeContainer<? extends KType> container) {
final int size = container.size();
ensureBufferSpace(size);
for (KTypeCursor<? extends KType> cursor : container) {
add(cursor.value);
}
return size;
} | java | public int addAll(KTypeContainer<? extends KType> container) {
final int size = container.size();
ensureBufferSpace(size);
for (KTypeCursor<? extends KType> cursor : container) {
add(cursor.value);
}
return size;
} | [
"public",
"int",
"addAll",
"(",
"KTypeContainer",
"<",
"?",
"extends",
"KType",
">",
"container",
")",
"{",
"final",
"int",
"size",
"=",
"container",
".",
"size",
"(",
")",
";",
"ensureBufferSpace",
"(",
"size",
")",
";",
"for",
"(",
"KTypeCursor",
"<",
... | Adds all elements from another container. | [
"Adds",
"all",
"elements",
"from",
"another",
"container",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayList.java#L152-L161 |
116,366 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayList.java | KTypeArrayList.addAll | public int addAll(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
add(cursor.value);
size++;
}
return size;
} | java | public int addAll(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
add(cursor.value);
size++;
}
return size;
} | [
"public",
"int",
"addAll",
"(",
"Iterable",
"<",
"?",
"extends",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
">",
"iterable",
")",
"{",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
"cursor",
":",
"... | Adds all elements from another iterable. | [
"Adds",
"all",
"elements",
"from",
"another",
"iterable",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayList.java#L166-L173 |
116,367 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayDeque.java | KTypeArrayDeque.addFirst | public int addFirst(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
addFirst(cursor.value);
size++;
}
return size;
} | java | public int addFirst(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
addFirst(cursor.value);
size++;
}
return size;
} | [
"public",
"int",
"addFirst",
"(",
"Iterable",
"<",
"?",
"extends",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
">",
"iterable",
")",
"{",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
"cursor",
":",
... | Inserts all elements from the given iterable to the front of this deque.
@param iterable The iterable to iterate over.
@return Returns the number of elements actually added as a result of this
call. | [
"Inserts",
"all",
"elements",
"from",
"the",
"given",
"iterable",
"to",
"the",
"front",
"of",
"this",
"deque",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayDeque.java#L150-L157 |
116,368 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayDeque.java | KTypeArrayDeque.addLast | public int addLast(KTypeContainer<? extends KType> container) {
int size = container.size();
ensureBufferSpace(size);
for (KTypeCursor<? extends KType> cursor : container) {
addLast(cursor.value);
}
return size;
} | java | public int addLast(KTypeContainer<? extends KType> container) {
int size = container.size();
ensureBufferSpace(size);
for (KTypeCursor<? extends KType> cursor : container) {
addLast(cursor.value);
}
return size;
} | [
"public",
"int",
"addLast",
"(",
"KTypeContainer",
"<",
"?",
"extends",
"KType",
">",
"container",
")",
"{",
"int",
"size",
"=",
"container",
".",
"size",
"(",
")",
";",
"ensureBufferSpace",
"(",
"size",
")",
";",
"for",
"(",
"KTypeCursor",
"<",
"?",
"... | Inserts all elements from the given container to the end of this deque.
@param container The container to iterate over.
@return Returns the number of elements actually added as a result of this
call. | [
"Inserts",
"all",
"elements",
"from",
"the",
"given",
"container",
"to",
"the",
"end",
"of",
"this",
"deque",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayDeque.java#L201-L210 |
116,369 | carrotsearch/hppc | hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayDeque.java | KTypeArrayDeque.addLast | public int addLast(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
addLast(cursor.value);
size++;
}
return size;
} | java | public int addLast(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
addLast(cursor.value);
size++;
}
return size;
} | [
"public",
"int",
"addLast",
"(",
"Iterable",
"<",
"?",
"extends",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
">",
"iterable",
")",
"{",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"KTypeCursor",
"<",
"?",
"extends",
"KType",
">",
"cursor",
":",
... | Inserts all elements from the given iterable to the end of this deque.
@param iterable The iterable to iterate over.
@return Returns the number of elements actually added as a result of this
call. | [
"Inserts",
"all",
"elements",
"from",
"the",
"given",
"iterable",
"to",
"the",
"end",
"of",
"this",
"deque",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayDeque.java#L220-L227 |
116,370 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitUtil.java | BitUtil.pop_array | public static long pop_array(long[] arr, int wordOffset, int numWords) {
long popCount = 0;
for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i) {
popCount += Long.bitCount(arr[i]);
}
return popCount;
} | java | public static long pop_array(long[] arr, int wordOffset, int numWords) {
long popCount = 0;
for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i) {
popCount += Long.bitCount(arr[i]);
}
return popCount;
} | [
"public",
"static",
"long",
"pop_array",
"(",
"long",
"[",
"]",
"arr",
",",
"int",
"wordOffset",
",",
"int",
"numWords",
")",
"{",
"long",
"popCount",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"wordOffset",
",",
"end",
"=",
"wordOffset",
"+",
"numW... | Returns the number of set bits in an array of longs. | [
"Returns",
"the",
"number",
"of",
"set",
"bits",
"in",
"an",
"array",
"of",
"longs",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitUtil.java#L40-L46 |
116,371 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitUtil.java | BitUtil.pop_intersect | public static long pop_intersect(long[] arr1, long[] arr2, int wordOffset, int numWords) {
long popCount = 0;
for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i) {
popCount += Long.bitCount(arr1[i] & arr2[i]);
}
return popCount;
} | java | public static long pop_intersect(long[] arr1, long[] arr2, int wordOffset, int numWords) {
long popCount = 0;
for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i) {
popCount += Long.bitCount(arr1[i] & arr2[i]);
}
return popCount;
} | [
"public",
"static",
"long",
"pop_intersect",
"(",
"long",
"[",
"]",
"arr1",
",",
"long",
"[",
"]",
"arr2",
",",
"int",
"wordOffset",
",",
"int",
"numWords",
")",
"{",
"long",
"popCount",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"wordOffset",
",",
... | Returns the popcount or cardinality of the two sets after an intersection.
Neither array is modified. | [
"Returns",
"the",
"popcount",
"or",
"cardinality",
"of",
"the",
"two",
"sets",
"after",
"an",
"intersection",
".",
"Neither",
"array",
"is",
"modified",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitUtil.java#L50-L56 |
116,372 | carrotsearch/hppc | hppc/src/main/java/com/carrotsearch/hppc/BitMixer.java | BitMixer.mix32 | public static int mix32(int k) {
k = (k ^ (k >>> 16)) * 0x85ebca6b;
k = (k ^ (k >>> 13)) * 0xc2b2ae35;
return k ^ (k >>> 16);
} | java | public static int mix32(int k) {
k = (k ^ (k >>> 16)) * 0x85ebca6b;
k = (k ^ (k >>> 13)) * 0xc2b2ae35;
return k ^ (k >>> 16);
} | [
"public",
"static",
"int",
"mix32",
"(",
"int",
"k",
")",
"{",
"k",
"=",
"(",
"k",
"^",
"(",
"k",
">>>",
"16",
")",
")",
"*",
"0x85ebca6b",
";",
"k",
"=",
"(",
"k",
"^",
"(",
"k",
">>>",
"13",
")",
")",
"*",
"0xc2b2ae35",
";",
"return",
"k"... | MH3's plain finalization step. | [
"MH3",
"s",
"plain",
"finalization",
"step",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/java/com/carrotsearch/hppc/BitMixer.java#L38-L42 |
116,373 | carrotsearch/hppc | hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/TemplateProcessorMojo.java | TemplateProcessorMojo.generate | private void generate(TemplateFile input, List<OutputFile> outputs, TemplateOptions templateOptions) throws IOException {
final String targetFileName = targetFileName(templatesPath.relativize(input.path).toString(), templateOptions);
final OutputFile output = new OutputFile(outputPath.resolve(targetFileName).... | java | private void generate(TemplateFile input, List<OutputFile> outputs, TemplateOptions templateOptions) throws IOException {
final String targetFileName = targetFileName(templatesPath.relativize(input.path).toString(), templateOptions);
final OutputFile output = new OutputFile(outputPath.resolve(targetFileName).... | [
"private",
"void",
"generate",
"(",
"TemplateFile",
"input",
",",
"List",
"<",
"OutputFile",
">",
"outputs",
",",
"TemplateOptions",
"templateOptions",
")",
"throws",
"IOException",
"{",
"final",
"String",
"targetFileName",
"=",
"targetFileName",
"(",
"templatesPath... | Apply templates. | [
"Apply",
"templates",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/TemplateProcessorMojo.java#L217-L264 |
116,374 | carrotsearch/hppc | hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/TemplateProcessorMojo.java | TemplateProcessorMojo.filterVelocity | private String filterVelocity(TemplateFile f, String template, TemplateOptions options) {
final VelocityContext ctx = new VelocityContext();
ctx.put("TemplateOptions", options);
ctx.put("true", true);
ctx.put("templateOnly", false);
ctx.put("false", false);
StringWriter sw = new StringWr... | java | private String filterVelocity(TemplateFile f, String template, TemplateOptions options) {
final VelocityContext ctx = new VelocityContext();
ctx.put("TemplateOptions", options);
ctx.put("true", true);
ctx.put("templateOnly", false);
ctx.put("false", false);
StringWriter sw = new StringWr... | [
"private",
"String",
"filterVelocity",
"(",
"TemplateFile",
"f",
",",
"String",
"template",
",",
"TemplateOptions",
"options",
")",
"{",
"final",
"VelocityContext",
"ctx",
"=",
"new",
"VelocityContext",
"(",
")",
";",
"ctx",
".",
"put",
"(",
"\"TemplateOptions\"... | Apply velocity to the input. | [
"Apply",
"velocity",
"to",
"the",
"input",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/TemplateProcessorMojo.java#L359-L369 |
116,375 | carrotsearch/hppc | hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/TemplateProcessorMojo.java | TemplateProcessorMojo.collectTemplateFiles | private List<TemplateFile> collectTemplateFiles(Path dir) throws IOException {
final List<TemplateFile> paths = new ArrayList<>();
for (Path path : scanFilesMatching(dir, "glob:**.java")) {
paths.add(new TemplateFile(path));
}
return paths;
} | java | private List<TemplateFile> collectTemplateFiles(Path dir) throws IOException {
final List<TemplateFile> paths = new ArrayList<>();
for (Path path : scanFilesMatching(dir, "glob:**.java")) {
paths.add(new TemplateFile(path));
}
return paths;
} | [
"private",
"List",
"<",
"TemplateFile",
">",
"collectTemplateFiles",
"(",
"Path",
"dir",
")",
"throws",
"IOException",
"{",
"final",
"List",
"<",
"TemplateFile",
">",
"paths",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Path",
"path",
":",
... | Collect all template files from this and subdirectories. | [
"Collect",
"all",
"template",
"files",
"from",
"this",
"and",
"subdirectories",
"."
] | e359e9da358e846fcbffc64a765611df954ba3f6 | https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc-template-processor/src/main/java/com/carrotsearch/hppc/generator/TemplateProcessorMojo.java#L400-L406 |
116,376 | PureWriter/ToastCompat | library/src/main/java/me/drakeet/support/toast/ToastCompat.java | ToastCompat.makeText | public static ToastCompat makeText(Context context, CharSequence text, int duration) {
// We cannot pass the SafeToastContext to Toast.makeText() because
// the View will unwrap the base context and we are in vain.
@SuppressLint("ShowToast")
Toast toast = Toast.makeText(context, text, duration);
set... | java | public static ToastCompat makeText(Context context, CharSequence text, int duration) {
// We cannot pass the SafeToastContext to Toast.makeText() because
// the View will unwrap the base context and we are in vain.
@SuppressLint("ShowToast")
Toast toast = Toast.makeText(context, text, duration);
set... | [
"public",
"static",
"ToastCompat",
"makeText",
"(",
"Context",
"context",
",",
"CharSequence",
"text",
",",
"int",
"duration",
")",
"{",
"// We cannot pass the SafeToastContext to Toast.makeText() because",
"// the View will unwrap the base context and we are in vain.",
"@",
"Sup... | Make a standard toast that just contains a text view.
@param context The context to use. Usually your {@link android.app.Application}
or {@link android.app.Activity} object.
@param text The text to show. Can be formatted text.
@param duration How long to display the message. Either {@link #LENGTH_SHORT} or
{@link #... | [
"Make",
"a",
"standard",
"toast",
"that",
"just",
"contains",
"a",
"text",
"view",
"."
] | 79c629c2ca8b2d7803f6dc4a458971b5fa19e7f7 | https://github.com/PureWriter/ToastCompat/blob/79c629c2ca8b2d7803f6dc4a458971b5fa19e7f7/library/src/main/java/me/drakeet/support/toast/ToastCompat.java#L46-L53 |
116,377 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableManager.java | AdaptiveTableManager.switchTwoColumns | void switchTwoColumns(int columnIndex, int columnToIndex) {
checkForInit();
int cellData = mColumnWidths[columnToIndex];
mColumnWidths[columnToIndex] = mColumnWidths[columnIndex];
mColumnWidths[columnIndex] = cellData;
} | java | void switchTwoColumns(int columnIndex, int columnToIndex) {
checkForInit();
int cellData = mColumnWidths[columnToIndex];
mColumnWidths[columnToIndex] = mColumnWidths[columnIndex];
mColumnWidths[columnIndex] = cellData;
} | [
"void",
"switchTwoColumns",
"(",
"int",
"columnIndex",
",",
"int",
"columnToIndex",
")",
"{",
"checkForInit",
"(",
")",
";",
"int",
"cellData",
"=",
"mColumnWidths",
"[",
"columnToIndex",
"]",
";",
"mColumnWidths",
"[",
"columnToIndex",
"]",
"=",
"mColumnWidths"... | Switch 2 items in array with columns data
@param columnIndex from column index
@param columnToIndex to column index | [
"Switch",
"2",
"items",
"in",
"array",
"with",
"columns",
"data"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableManager.java#L341-L346 |
116,378 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableManager.java | AdaptiveTableManager.switchTwoRows | void switchTwoRows(int rowIndex, int rowToIndex) {
checkForInit();
int cellData = mRowHeights[rowToIndex];
mRowHeights[rowToIndex] = mRowHeights[rowIndex];
mRowHeights[rowIndex] = cellData;
} | java | void switchTwoRows(int rowIndex, int rowToIndex) {
checkForInit();
int cellData = mRowHeights[rowToIndex];
mRowHeights[rowToIndex] = mRowHeights[rowIndex];
mRowHeights[rowIndex] = cellData;
} | [
"void",
"switchTwoRows",
"(",
"int",
"rowIndex",
",",
"int",
"rowToIndex",
")",
"{",
"checkForInit",
"(",
")",
";",
"int",
"cellData",
"=",
"mRowHeights",
"[",
"rowToIndex",
"]",
";",
"mRowHeights",
"[",
"rowToIndex",
"]",
"=",
"mRowHeights",
"[",
"rowIndex"... | Switch 2 items in array with rows data
@param rowIndex from row index
@param rowToIndex to row index | [
"Switch",
"2",
"items",
"in",
"array",
"with",
"rows",
"data"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableManager.java#L354-L359 |
116,379 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/SparseMatrix.java | SparseMatrix.remove | void remove(int row, int column) {
SparseArrayCompat<TObj> array = mData.get(row);
if (array != null) {
array.remove(column);
}
} | java | void remove(int row, int column) {
SparseArrayCompat<TObj> array = mData.get(row);
if (array != null) {
array.remove(column);
}
} | [
"void",
"remove",
"(",
"int",
"row",
",",
"int",
"column",
")",
"{",
"SparseArrayCompat",
"<",
"TObj",
">",
"array",
"=",
"mData",
".",
"get",
"(",
"row",
")",
";",
"if",
"(",
"array",
"!=",
"null",
")",
"{",
"array",
".",
"remove",
"(",
"column",
... | Remove item in row, column position int the matrix
@param row item row position
@param column item column position | [
"Remove",
"item",
"in",
"row",
"column",
"position",
"int",
"the",
"matrix"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/SparseMatrix.java#L119-L124 |
116,380 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.refreshViewHolders | private void refreshViewHolders() {
if (mAdapter != null) {
for (ViewHolder holder : mViewHolders.getAll()) {
if (holder != null) {
// cell item
refreshItemViewHolder(holder, mState.isRowDragging(), mState.isColumnDragging());
... | java | private void refreshViewHolders() {
if (mAdapter != null) {
for (ViewHolder holder : mViewHolders.getAll()) {
if (holder != null) {
// cell item
refreshItemViewHolder(holder, mState.isRowDragging(), mState.isColumnDragging());
... | [
"private",
"void",
"refreshViewHolders",
"(",
")",
"{",
"if",
"(",
"mAdapter",
"!=",
"null",
")",
"{",
"for",
"(",
"ViewHolder",
"holder",
":",
"mViewHolders",
".",
"getAll",
"(",
")",
")",
"{",
"if",
"(",
"holder",
"!=",
"null",
")",
"{",
"// cell ite... | Refresh all view holders | [
"Refresh",
"all",
"view",
"holders"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L439-L464 |
116,381 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.refreshHeaderColumnViewHolder | private void refreshHeaderColumnViewHolder(ViewHolder holder) {
int left = getEmptySpace() + mManager.getColumnsWidth(0, Math.max(0, holder.getColumnIndex()));
if (!isRTL()) {
left += mManager.getHeaderRowWidth();
}
int top = mSettings.isHeaderFixed() ? 0 : -mState.getScrollY... | java | private void refreshHeaderColumnViewHolder(ViewHolder holder) {
int left = getEmptySpace() + mManager.getColumnsWidth(0, Math.max(0, holder.getColumnIndex()));
if (!isRTL()) {
left += mManager.getHeaderRowWidth();
}
int top = mSettings.isHeaderFixed() ? 0 : -mState.getScrollY... | [
"private",
"void",
"refreshHeaderColumnViewHolder",
"(",
"ViewHolder",
"holder",
")",
"{",
"int",
"left",
"=",
"getEmptySpace",
"(",
")",
"+",
"mManager",
".",
"getColumnsWidth",
"(",
"0",
",",
"Math",
".",
"max",
"(",
"0",
",",
"holder",
".",
"getColumnInde... | Refresh current column header view holder.
@param holder current view holder | [
"Refresh",
"current",
"column",
"header",
"view",
"holder",
"."
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L548-L620 |
116,382 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.recycleViewHolders | private void recycleViewHolders(boolean isRecycleAll) {
if (mAdapter == null) {
return;
}
final List<Integer> headerKeysToRemove = new ArrayList<>();
// item view holders
for (ViewHolder holder : mViewHolders.getAll()) {
if (holder != null && !holder.is... | java | private void recycleViewHolders(boolean isRecycleAll) {
if (mAdapter == null) {
return;
}
final List<Integer> headerKeysToRemove = new ArrayList<>();
// item view holders
for (ViewHolder holder : mViewHolders.getAll()) {
if (holder != null && !holder.is... | [
"private",
"void",
"recycleViewHolders",
"(",
"boolean",
"isRecycleAll",
")",
"{",
"if",
"(",
"mAdapter",
"==",
"null",
")",
"{",
"return",
";",
"}",
"final",
"List",
"<",
"Integer",
">",
"headerKeysToRemove",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
... | Recycle view holders outside screen
@param isRecycleAll recycle all view holders if true | [
"Recycle",
"view",
"holders",
"outside",
"screen"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L756-L823 |
116,383 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.removeKeys | private void removeKeys(List<Integer> keysToRemove, SparseArrayCompat<ViewHolder> headers) {
for (Integer key : keysToRemove) {
headers.remove(key);
}
} | java | private void removeKeys(List<Integer> keysToRemove, SparseArrayCompat<ViewHolder> headers) {
for (Integer key : keysToRemove) {
headers.remove(key);
}
} | [
"private",
"void",
"removeKeys",
"(",
"List",
"<",
"Integer",
">",
"keysToRemove",
",",
"SparseArrayCompat",
"<",
"ViewHolder",
">",
"headers",
")",
"{",
"for",
"(",
"Integer",
"key",
":",
"keysToRemove",
")",
"{",
"headers",
".",
"remove",
"(",
"key",
")"... | Remove recycled viewholders from sparseArray
@param keysToRemove List of ViewHolders keys that we need to remove
@param headers SparseArray of viewHolders from where we need to remove | [
"Remove",
"recycled",
"viewholders",
"from",
"sparseArray"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L832-L836 |
116,384 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.recycleViewHolder | private void recycleViewHolder(ViewHolder holder) {
mRecycler.pushRecycledView(holder);
removeView(holder.getItemView());
mAdapter.onViewHolderRecycled(holder);
} | java | private void recycleViewHolder(ViewHolder holder) {
mRecycler.pushRecycledView(holder);
removeView(holder.getItemView());
mAdapter.onViewHolderRecycled(holder);
} | [
"private",
"void",
"recycleViewHolder",
"(",
"ViewHolder",
"holder",
")",
"{",
"mRecycler",
".",
"pushRecycledView",
"(",
"holder",
")",
";",
"removeView",
"(",
"holder",
".",
"getItemView",
"(",
")",
")",
";",
"mAdapter",
".",
"onViewHolderRecycled",
"(",
"ho... | Recycle view holder and remove view from layout.
@param holder view holder to recycle | [
"Recycle",
"view",
"holder",
"and",
"remove",
"view",
"from",
"layout",
"."
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L843-L847 |
116,385 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.addViewHolders | private void addViewHolders(Rect filledArea) {
//search indexes for columns and rows which NEED TO BE showed in this area
int leftColumn = mManager.getColumnByXWithShift(filledArea.left, mSettings.getCellMargin());
int rightColumn = mManager.getColumnByXWithShift(filledArea.right, mSettings.getC... | java | private void addViewHolders(Rect filledArea) {
//search indexes for columns and rows which NEED TO BE showed in this area
int leftColumn = mManager.getColumnByXWithShift(filledArea.left, mSettings.getCellMargin());
int rightColumn = mManager.getColumnByXWithShift(filledArea.right, mSettings.getC... | [
"private",
"void",
"addViewHolders",
"(",
"Rect",
"filledArea",
")",
"{",
"//search indexes for columns and rows which NEED TO BE showed in this area",
"int",
"leftColumn",
"=",
"mManager",
".",
"getColumnByXWithShift",
"(",
"filledArea",
".",
"left",
",",
"mSettings",
".",... | Create and add view holders with views to the layout.
@param filledArea visible rect | [
"Create",
"and",
"add",
"view",
"holders",
"with",
"views",
"to",
"the",
"layout",
"."
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L863-L925 |
116,386 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.createViewHolder | @Nullable
private ViewHolder createViewHolder(int itemType) {
if (itemType == ViewHolderType.ITEM) {
return mAdapter.onCreateItemViewHolder(AdaptiveTableLayout.this);
} else if (itemType == ViewHolderType.ROW_HEADER) {
return mAdapter.onCreateRowHeaderViewHolder(AdaptiveTable... | java | @Nullable
private ViewHolder createViewHolder(int itemType) {
if (itemType == ViewHolderType.ITEM) {
return mAdapter.onCreateItemViewHolder(AdaptiveTableLayout.this);
} else if (itemType == ViewHolderType.ROW_HEADER) {
return mAdapter.onCreateRowHeaderViewHolder(AdaptiveTable... | [
"@",
"Nullable",
"private",
"ViewHolder",
"createViewHolder",
"(",
"int",
"itemType",
")",
"{",
"if",
"(",
"itemType",
"==",
"ViewHolderType",
".",
"ITEM",
")",
"{",
"return",
"mAdapter",
".",
"onCreateItemViewHolder",
"(",
"AdaptiveTableLayout",
".",
"this",
")... | Create view holder by type
@param itemType view holder type
@return Created view holder | [
"Create",
"view",
"holder",
"by",
"type"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L1013-L1023 |
116,387 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.shiftColumnsViews | private void shiftColumnsViews(final int fromColumn, final int toColumn) {
if (mAdapter != null) {
// change data
mAdapter.changeColumns(getBindColumn(fromColumn), getBindColumn(toColumn));
// change view holders
switchHeaders(mHeaderColumnViewHolders, fromColum... | java | private void shiftColumnsViews(final int fromColumn, final int toColumn) {
if (mAdapter != null) {
// change data
mAdapter.changeColumns(getBindColumn(fromColumn), getBindColumn(toColumn));
// change view holders
switchHeaders(mHeaderColumnViewHolders, fromColum... | [
"private",
"void",
"shiftColumnsViews",
"(",
"final",
"int",
"fromColumn",
",",
"final",
"int",
"toColumn",
")",
"{",
"if",
"(",
"mAdapter",
"!=",
"null",
")",
"{",
"// change data",
"mAdapter",
".",
"changeColumns",
"(",
"getBindColumn",
"(",
"fromColumn",
")... | Method change columns. Change view holders indexes, kay in map, init changing items in adapter.
@param fromColumn from column index which need to shift
@param toColumn to column index which need to shift | [
"Method",
"change",
"columns",
".",
"Change",
"view",
"holders",
"indexes",
"kay",
"in",
"map",
"init",
"changing",
"items",
"in",
"adapter",
"."
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L1141-L1169 |
116,388 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.shiftRowsViews | private void shiftRowsViews(final int fromRow, final int toRow) {
if (mAdapter != null) {
// change data
mAdapter.changeRows(fromRow, toRow, mSettings.isSolidRowHeader());
// change view holders
switchHeaders(mHeaderRowViewHolders, fromRow, toRow, ViewHolderType.... | java | private void shiftRowsViews(final int fromRow, final int toRow) {
if (mAdapter != null) {
// change data
mAdapter.changeRows(fromRow, toRow, mSettings.isSolidRowHeader());
// change view holders
switchHeaders(mHeaderRowViewHolders, fromRow, toRow, ViewHolderType.... | [
"private",
"void",
"shiftRowsViews",
"(",
"final",
"int",
"fromRow",
",",
"final",
"int",
"toRow",
")",
"{",
"if",
"(",
"mAdapter",
"!=",
"null",
")",
"{",
"// change data",
"mAdapter",
".",
"changeRows",
"(",
"fromRow",
",",
"toRow",
",",
"mSettings",
"."... | Method change rows. Change view holders indexes, kay in map, init changing items in adapter.
@param fromRow from row index which need to shift
@param toRow to row index which need to shift | [
"Method",
"change",
"rows",
".",
"Change",
"view",
"holders",
"indexes",
"kay",
"in",
"map",
"init",
"changing",
"items",
"in",
"adapter",
"."
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L1177-L1216 |
116,389 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.setDraggingToColumn | @SuppressWarnings("unused")
private void setDraggingToColumn(int column, boolean isDragging) {
Collection<ViewHolder> holders = mViewHolders.getColumnItems(column);
for (ViewHolder holder : holders) {
holder.setIsDragging(isDragging);
}
ViewHolder holder = mHeaderColumnV... | java | @SuppressWarnings("unused")
private void setDraggingToColumn(int column, boolean isDragging) {
Collection<ViewHolder> holders = mViewHolders.getColumnItems(column);
for (ViewHolder holder : holders) {
holder.setIsDragging(isDragging);
}
ViewHolder holder = mHeaderColumnV... | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"private",
"void",
"setDraggingToColumn",
"(",
"int",
"column",
",",
"boolean",
"isDragging",
")",
"{",
"Collection",
"<",
"ViewHolder",
">",
"holders",
"=",
"mViewHolders",
".",
"getColumnItems",
"(",
"column",
"... | Method set dragging flag to all view holders in the specific column
@param column specific column
@param isDragging flag to set | [
"Method",
"set",
"dragging",
"flag",
"to",
"all",
"view",
"holders",
"in",
"the",
"specific",
"column"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L1470-L1481 |
116,390 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java | AdaptiveTableLayout.setDraggingToRow | @SuppressWarnings("unused")
private void setDraggingToRow(int row, boolean isDragging) {
Collection<ViewHolder> holders = mViewHolders.getRowItems(row);
for (ViewHolder holder : holders) {
holder.setIsDragging(isDragging);
}
ViewHolder holder = mHeaderRowViewHolders.get(... | java | @SuppressWarnings("unused")
private void setDraggingToRow(int row, boolean isDragging) {
Collection<ViewHolder> holders = mViewHolders.getRowItems(row);
for (ViewHolder holder : holders) {
holder.setIsDragging(isDragging);
}
ViewHolder holder = mHeaderRowViewHolders.get(... | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"private",
"void",
"setDraggingToRow",
"(",
"int",
"row",
",",
"boolean",
"isDragging",
")",
"{",
"Collection",
"<",
"ViewHolder",
">",
"holders",
"=",
"mViewHolders",
".",
"getRowItems",
"(",
"row",
")",
";",
... | Method set dragging flag to all view holders in the specific row
@param row specific row
@param isDragging flag to set | [
"Method",
"set",
"dragging",
"flag",
"to",
"all",
"view",
"holders",
"in",
"the",
"specific",
"row"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableLayout.java#L1489-L1500 |
116,391 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java | BaseDataAdaptiveTableLayoutAdapter.switchTwoColumns | void switchTwoColumns(int columnIndex, int columnToIndex) {
for (int i = 0; i < getRowCount() - 1; i++) {
Object cellData = getItems()[i][columnToIndex];
getItems()[i][columnToIndex] = getItems()[i][columnIndex];
getItems()[i][columnIndex] = cellData;
}
} | java | void switchTwoColumns(int columnIndex, int columnToIndex) {
for (int i = 0; i < getRowCount() - 1; i++) {
Object cellData = getItems()[i][columnToIndex];
getItems()[i][columnToIndex] = getItems()[i][columnIndex];
getItems()[i][columnIndex] = cellData;
}
} | [
"void",
"switchTwoColumns",
"(",
"int",
"columnIndex",
",",
"int",
"columnToIndex",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getRowCount",
"(",
")",
"-",
"1",
";",
"i",
"++",
")",
"{",
"Object",
"cellData",
"=",
"getItems",
"(",
... | Switch 2 columns with data
@param columnIndex column from
@param columnToIndex column to | [
"Switch",
"2",
"columns",
"with",
"data"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java#L35-L41 |
116,392 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java | BaseDataAdaptiveTableLayoutAdapter.switchTwoColumnHeaders | void switchTwoColumnHeaders(int columnIndex, int columnToIndex) {
Object cellData = getColumnHeaders()[columnToIndex];
getColumnHeaders()[columnToIndex] = getColumnHeaders()[columnIndex];
getColumnHeaders()[columnIndex] = cellData;
} | java | void switchTwoColumnHeaders(int columnIndex, int columnToIndex) {
Object cellData = getColumnHeaders()[columnToIndex];
getColumnHeaders()[columnToIndex] = getColumnHeaders()[columnIndex];
getColumnHeaders()[columnIndex] = cellData;
} | [
"void",
"switchTwoColumnHeaders",
"(",
"int",
"columnIndex",
",",
"int",
"columnToIndex",
")",
"{",
"Object",
"cellData",
"=",
"getColumnHeaders",
"(",
")",
"[",
"columnToIndex",
"]",
";",
"getColumnHeaders",
"(",
")",
"[",
"columnToIndex",
"]",
"=",
"getColumnH... | Switch 2 columns headers with data
@param columnIndex column header from
@param columnToIndex column header to | [
"Switch",
"2",
"columns",
"headers",
"with",
"data"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java#L49-L53 |
116,393 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java | BaseDataAdaptiveTableLayoutAdapter.switchTwoRows | void switchTwoRows(int rowIndex, int rowToIndex) {
for (int i = 0; i < getItems().length; i++) {
Object cellData = getItems()[rowToIndex][i];
getItems()[rowToIndex][i] = getItems()[rowIndex][i];
getItems()[rowIndex][i] = cellData;
}
} | java | void switchTwoRows(int rowIndex, int rowToIndex) {
for (int i = 0; i < getItems().length; i++) {
Object cellData = getItems()[rowToIndex][i];
getItems()[rowToIndex][i] = getItems()[rowIndex][i];
getItems()[rowIndex][i] = cellData;
}
} | [
"void",
"switchTwoRows",
"(",
"int",
"rowIndex",
",",
"int",
"rowToIndex",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getItems",
"(",
")",
".",
"length",
";",
"i",
"++",
")",
"{",
"Object",
"cellData",
"=",
"getItems",
"(",
")",
... | Switch 2 rows with data
@param rowIndex row from
@param rowToIndex row to | [
"Switch",
"2",
"rows",
"with",
"data"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java#L71-L77 |
116,394 | Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java | BaseDataAdaptiveTableLayoutAdapter.switchTwoRowHeaders | void switchTwoRowHeaders(int rowIndex, int rowToIndex) {
Object cellData = getRowHeaders()[rowToIndex];
getRowHeaders()[rowToIndex] = getRowHeaders()[rowIndex];
getRowHeaders()[rowIndex] = cellData;
} | java | void switchTwoRowHeaders(int rowIndex, int rowToIndex) {
Object cellData = getRowHeaders()[rowToIndex];
getRowHeaders()[rowToIndex] = getRowHeaders()[rowIndex];
getRowHeaders()[rowIndex] = cellData;
} | [
"void",
"switchTwoRowHeaders",
"(",
"int",
"rowIndex",
",",
"int",
"rowToIndex",
")",
"{",
"Object",
"cellData",
"=",
"getRowHeaders",
"(",
")",
"[",
"rowToIndex",
"]",
";",
"getRowHeaders",
"(",
")",
"[",
"rowToIndex",
"]",
"=",
"getRowHeaders",
"(",
")",
... | Switch 2 rows headers with data
@param rowIndex row header from
@param rowToIndex row header to | [
"Switch",
"2",
"rows",
"headers",
"with",
"data"
] | 188213b35e05e635497b03fe741799782dde7208 | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/BaseDataAdaptiveTableLayoutAdapter.java#L85-L89 |
116,395 | vorburger/MariaDB4j | mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java | DB.newEmbeddedDB | public static DB newEmbeddedDB(DBConfiguration config) throws ManagedProcessException {
DB db = new DB(config);
db.prepareDirectories();
db.unpackEmbeddedDb();
db.install();
return db;
} | java | public static DB newEmbeddedDB(DBConfiguration config) throws ManagedProcessException {
DB db = new DB(config);
db.prepareDirectories();
db.unpackEmbeddedDb();
db.install();
return db;
} | [
"public",
"static",
"DB",
"newEmbeddedDB",
"(",
"DBConfiguration",
"config",
")",
"throws",
"ManagedProcessException",
"{",
"DB",
"db",
"=",
"new",
"DB",
"(",
"config",
")",
";",
"db",
".",
"prepareDirectories",
"(",
")",
";",
"db",
".",
"unpackEmbeddedDb",
... | This factory method is the mechanism for constructing a new embedded database for use. This
method automatically installs the database and prepares it for use.
@param config Configuration of the embedded instance
@return a new DB instance
@throws ManagedProcessException if something fatal went wrong | [
"This",
"factory",
"method",
"is",
"the",
"mechanism",
"for",
"constructing",
"a",
"new",
"embedded",
"database",
"for",
"use",
".",
"This",
"method",
"automatically",
"installs",
"the",
"database",
"and",
"prepares",
"it",
"for",
"use",
"."
] | ddc7aa2a3294c9c56b1127de11949fb33a81ad7b | https://github.com/vorburger/MariaDB4j/blob/ddc7aa2a3294c9c56b1127de11949fb33a81ad7b/mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java#L77-L83 |
116,396 | vorburger/MariaDB4j | mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java | DB.newEmbeddedDB | public static DB newEmbeddedDB(int port) throws ManagedProcessException {
DBConfigurationBuilder config = new DBConfigurationBuilder();
config.setPort(port);
return newEmbeddedDB(config.build());
} | java | public static DB newEmbeddedDB(int port) throws ManagedProcessException {
DBConfigurationBuilder config = new DBConfigurationBuilder();
config.setPort(port);
return newEmbeddedDB(config.build());
} | [
"public",
"static",
"DB",
"newEmbeddedDB",
"(",
"int",
"port",
")",
"throws",
"ManagedProcessException",
"{",
"DBConfigurationBuilder",
"config",
"=",
"new",
"DBConfigurationBuilder",
"(",
")",
";",
"config",
".",
"setPort",
"(",
"port",
")",
";",
"return",
"new... | This factory method is the mechanism for constructing a new embedded database for use. This
method automatically installs the database and prepares it for use with default
configuration, allowing only for specifying port.
@param port the port to start the embedded database on
@return a new DB instance
@throws ManagedP... | [
"This",
"factory",
"method",
"is",
"the",
"mechanism",
"for",
"constructing",
"a",
"new",
"embedded",
"database",
"for",
"use",
".",
"This",
"method",
"automatically",
"installs",
"the",
"database",
"and",
"prepares",
"it",
"for",
"use",
"with",
"default",
"co... | ddc7aa2a3294c9c56b1127de11949fb33a81ad7b | https://github.com/vorburger/MariaDB4j/blob/ddc7aa2a3294c9c56b1127de11949fb33a81ad7b/mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java#L94-L98 |
116,397 | vorburger/MariaDB4j | mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java | DB.install | synchronized protected void install() throws ManagedProcessException {
try {
ManagedProcess mysqlInstallProcess = installPreparation();
mysqlInstallProcess.start();
mysqlInstallProcess.waitForExit();
} catch (Exception e) {
throw new ManagedProcessExceptio... | java | synchronized protected void install() throws ManagedProcessException {
try {
ManagedProcess mysqlInstallProcess = installPreparation();
mysqlInstallProcess.start();
mysqlInstallProcess.waitForExit();
} catch (Exception e) {
throw new ManagedProcessExceptio... | [
"synchronized",
"protected",
"void",
"install",
"(",
")",
"throws",
"ManagedProcessException",
"{",
"try",
"{",
"ManagedProcess",
"mysqlInstallProcess",
"=",
"installPreparation",
"(",
")",
";",
"mysqlInstallProcess",
".",
"start",
"(",
")",
";",
"mysqlInstallProcess"... | Installs the database to the location specified in the configuration.
@throws ManagedProcessException if something fatal went wrong | [
"Installs",
"the",
"database",
"to",
"the",
"location",
"specified",
"in",
"the",
"configuration",
"."
] | ddc7aa2a3294c9c56b1127de11949fb33a81ad7b | https://github.com/vorburger/MariaDB4j/blob/ddc7aa2a3294c9c56b1127de11949fb33a81ad7b/mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java#L135-L144 |
116,398 | vorburger/MariaDB4j | mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java | DB.start | public synchronized void start() throws ManagedProcessException {
logger.info("Starting up the database...");
boolean ready = false;
try {
mysqldProcess = startPreparation();
ready = mysqldProcess.startAndWaitForConsoleMessageMaxMs(getReadyForConnectionsTag(), dbStartMaxW... | java | public synchronized void start() throws ManagedProcessException {
logger.info("Starting up the database...");
boolean ready = false;
try {
mysqldProcess = startPreparation();
ready = mysqldProcess.startAndWaitForConsoleMessageMaxMs(getReadyForConnectionsTag(), dbStartMaxW... | [
"public",
"synchronized",
"void",
"start",
"(",
")",
"throws",
"ManagedProcessException",
"{",
"logger",
".",
"info",
"(",
"\"Starting up the database...\"",
")",
";",
"boolean",
"ready",
"=",
"false",
";",
"try",
"{",
"mysqldProcess",
"=",
"startPreparation",
"("... | Starts up the database, using the data directory and port specified in the configuration.
@throws ManagedProcessException if something fatal went wrong | [
"Starts",
"up",
"the",
"database",
"using",
"the",
"data",
"directory",
"and",
"port",
"specified",
"in",
"the",
"configuration",
"."
] | ddc7aa2a3294c9c56b1127de11949fb33a81ad7b | https://github.com/vorburger/MariaDB4j/blob/ddc7aa2a3294c9c56b1127de11949fb33a81ad7b/mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java#L155-L172 |
116,399 | vorburger/MariaDB4j | mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java | DB.source | public void source(String resource, String username, String password, String dbName) throws ManagedProcessException {
InputStream from = getClass().getClassLoader().getResourceAsStream(resource);
if (from == null)
throw new IllegalArgumentException("Could not find script file on the classpat... | java | public void source(String resource, String username, String password, String dbName) throws ManagedProcessException {
InputStream from = getClass().getClassLoader().getResourceAsStream(resource);
if (from == null)
throw new IllegalArgumentException("Could not find script file on the classpat... | [
"public",
"void",
"source",
"(",
"String",
"resource",
",",
"String",
"username",
",",
"String",
"password",
",",
"String",
"dbName",
")",
"throws",
"ManagedProcessException",
"{",
"InputStream",
"from",
"=",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
"... | Takes in a string that represents a resource on the classpath and sources it via the mysql
command line tool.
@param resource the path to a resource on the classpath to source
@param username the username used to login to the database
@param password the password used to login to the database
@param dbName the name of... | [
"Takes",
"in",
"a",
"string",
"that",
"represents",
"a",
"resource",
"on",
"the",
"classpath",
"and",
"sources",
"it",
"via",
"the",
"mysql",
"command",
"line",
"tool",
"."
] | ddc7aa2a3294c9c56b1127de11949fb33a81ad7b | https://github.com/vorburger/MariaDB4j/blob/ddc7aa2a3294c9c56b1127de11949fb33a81ad7b/mariaDB4j-core/src/main/java/ch/vorburger/mariadb4j/DB.java#L267-L272 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.