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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36,000 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/CounterMutation.java | CounterMutation.getCurrentValuesFromCFS | private void getCurrentValuesFromCFS(List<CounterUpdateCell> counterUpdateCells,
ColumnFamilyStore cfs,
ClockAndCount[] currentValues)
{
SortedSet<CellName> names = new TreeSet<>(cfs.metadata.comparator);
for (int i = 0; i < currentValues.length; i++)
if (currentValues[i] == null)
names.add(counterUpdateCells.get(i).name());
ReadCommand cmd = new SliceByNamesReadCommand(getKeyspaceName(), key(), cfs.metadata.cfName, Long.MIN_VALUE, new NamesQueryFilter(names));
Row row = cmd.getRow(cfs.keyspace);
ColumnFamily cf = row == null ? null : row.cf;
for (int i = 0; i < currentValues.length; i++)
{
if (currentValues[i] != null)
continue;
Cell cell = cf == null ? null : cf.getColumn(counterUpdateCells.get(i).name());
if (cell == null || !cell.isLive()) // absent or a tombstone.
currentValues[i] = ClockAndCount.BLANK;
else
currentValues[i] = CounterContext.instance().getLocalClockAndCount(cell.value());
}
} | java | private void getCurrentValuesFromCFS(List<CounterUpdateCell> counterUpdateCells,
ColumnFamilyStore cfs,
ClockAndCount[] currentValues)
{
SortedSet<CellName> names = new TreeSet<>(cfs.metadata.comparator);
for (int i = 0; i < currentValues.length; i++)
if (currentValues[i] == null)
names.add(counterUpdateCells.get(i).name());
ReadCommand cmd = new SliceByNamesReadCommand(getKeyspaceName(), key(), cfs.metadata.cfName, Long.MIN_VALUE, new NamesQueryFilter(names));
Row row = cmd.getRow(cfs.keyspace);
ColumnFamily cf = row == null ? null : row.cf;
for (int i = 0; i < currentValues.length; i++)
{
if (currentValues[i] != null)
continue;
Cell cell = cf == null ? null : cf.getColumn(counterUpdateCells.get(i).name());
if (cell == null || !cell.isLive()) // absent or a tombstone.
currentValues[i] = ClockAndCount.BLANK;
else
currentValues[i] = CounterContext.instance().getLocalClockAndCount(cell.value());
}
} | [
"private",
"void",
"getCurrentValuesFromCFS",
"(",
"List",
"<",
"CounterUpdateCell",
">",
"counterUpdateCells",
",",
"ColumnFamilyStore",
"cfs",
",",
"ClockAndCount",
"[",
"]",
"currentValues",
")",
"{",
"SortedSet",
"<",
"CellName",
">",
"names",
"=",
"new",
"Tre... | Reads the missing current values from the CFS. | [
"Reads",
"the",
"missing",
"current",
"values",
"from",
"the",
"CFS",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/CounterMutation.java#L252-L276 |
36,001 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java | BytesConversionFcts.makeToBlobFunction | public static Function makeToBlobFunction(AbstractType<?> fromType)
{
String name = fromType.asCQL3Type() + "asblob";
return new AbstractFunction(name, BytesType.instance, fromType)
{
public ByteBuffer execute(List<ByteBuffer> parameters)
{
return parameters.get(0);
}
};
} | java | public static Function makeToBlobFunction(AbstractType<?> fromType)
{
String name = fromType.asCQL3Type() + "asblob";
return new AbstractFunction(name, BytesType.instance, fromType)
{
public ByteBuffer execute(List<ByteBuffer> parameters)
{
return parameters.get(0);
}
};
} | [
"public",
"static",
"Function",
"makeToBlobFunction",
"(",
"AbstractType",
"<",
"?",
">",
"fromType",
")",
"{",
"String",
"name",
"=",
"fromType",
".",
"asCQL3Type",
"(",
")",
"+",
"\"asblob\"",
";",
"return",
"new",
"AbstractFunction",
"(",
"name",
",",
"By... | bytes internally. They only "trick" the type system. | [
"bytes",
"internally",
".",
"They",
"only",
"trick",
"the",
"type",
"system",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java#L34-L44 |
36,002 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java | RangeClient.run | public void run()
{
outer:
while (run || !queue.isEmpty())
{
List<ByteBuffer> bindVariables;
try
{
bindVariables = queue.take();
}
catch (InterruptedException e)
{
// re-check loop condition after interrupt
continue;
}
Iterator<InetAddress> iter = endpoints.iterator();
while (true)
{
// send the mutation to the last-used endpoint. first time through, this will NPE harmlessly.
try
{
int i = 0;
int itemId = preparedStatement(client);
while (bindVariables != null)
{
client.execute_prepared_cql3_query(itemId, bindVariables, ConsistencyLevel.ONE);
i++;
if (i >= batchThreshold)
break;
bindVariables = queue.poll();
}
break;
}
catch (Exception e)
{
closeInternal();
if (!iter.hasNext())
{
lastException = new IOException(e);
break outer;
}
}
// attempt to connect to a different endpoint
try
{
InetAddress address = iter.next();
String host = address.getHostName();
int port = ConfigHelper.getOutputRpcPort(conf);
client = CqlOutputFormat.createAuthenticatedClient(host, port, conf);
}
catch (Exception e)
{
closeInternal();
// TException means something unexpected went wrong to that endpoint, so
// we should try again to another. Other exceptions (auth or invalid request) are fatal.
if ((!(e instanceof TException)) || !iter.hasNext())
{
lastException = new IOException(e);
break outer;
}
}
}
}
// close all our connections once we are done.
closeInternal();
} | java | public void run()
{
outer:
while (run || !queue.isEmpty())
{
List<ByteBuffer> bindVariables;
try
{
bindVariables = queue.take();
}
catch (InterruptedException e)
{
// re-check loop condition after interrupt
continue;
}
Iterator<InetAddress> iter = endpoints.iterator();
while (true)
{
// send the mutation to the last-used endpoint. first time through, this will NPE harmlessly.
try
{
int i = 0;
int itemId = preparedStatement(client);
while (bindVariables != null)
{
client.execute_prepared_cql3_query(itemId, bindVariables, ConsistencyLevel.ONE);
i++;
if (i >= batchThreshold)
break;
bindVariables = queue.poll();
}
break;
}
catch (Exception e)
{
closeInternal();
if (!iter.hasNext())
{
lastException = new IOException(e);
break outer;
}
}
// attempt to connect to a different endpoint
try
{
InetAddress address = iter.next();
String host = address.getHostName();
int port = ConfigHelper.getOutputRpcPort(conf);
client = CqlOutputFormat.createAuthenticatedClient(host, port, conf);
}
catch (Exception e)
{
closeInternal();
// TException means something unexpected went wrong to that endpoint, so
// we should try again to another. Other exceptions (auth or invalid request) are fatal.
if ((!(e instanceof TException)) || !iter.hasNext())
{
lastException = new IOException(e);
break outer;
}
}
}
}
// close all our connections once we are done.
closeInternal();
} | [
"public",
"void",
"run",
"(",
")",
"{",
"outer",
":",
"while",
"(",
"run",
"||",
"!",
"queue",
".",
"isEmpty",
"(",
")",
")",
"{",
"List",
"<",
"ByteBuffer",
">",
"bindVariables",
";",
"try",
"{",
"bindVariables",
"=",
"queue",
".",
"take",
"(",
")... | Loops collecting cql binded variable values from the queue and sending to Cassandra | [
"Loops",
"collecting",
"cql",
"binded",
"variable",
"values",
"from",
"the",
"queue",
"and",
"sending",
"to",
"Cassandra"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java#L218-L289 |
36,003 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java | RangeClient.preparedStatement | private int preparedStatement(Cassandra.Client client)
{
Integer itemId = preparedStatements.get(client);
if (itemId == null)
{
CqlPreparedResult result;
try
{
result = client.prepare_cql3_query(ByteBufferUtil.bytes(cql), Compression.NONE);
}
catch (InvalidRequestException e)
{
throw new RuntimeException("failed to prepare cql query " + cql, e);
}
catch (TException e)
{
throw new RuntimeException("failed to prepare cql query " + cql, e);
}
Integer previousId = preparedStatements.putIfAbsent(client, Integer.valueOf(result.itemId));
itemId = previousId == null ? result.itemId : previousId;
}
return itemId;
} | java | private int preparedStatement(Cassandra.Client client)
{
Integer itemId = preparedStatements.get(client);
if (itemId == null)
{
CqlPreparedResult result;
try
{
result = client.prepare_cql3_query(ByteBufferUtil.bytes(cql), Compression.NONE);
}
catch (InvalidRequestException e)
{
throw new RuntimeException("failed to prepare cql query " + cql, e);
}
catch (TException e)
{
throw new RuntimeException("failed to prepare cql query " + cql, e);
}
Integer previousId = preparedStatements.putIfAbsent(client, Integer.valueOf(result.itemId));
itemId = previousId == null ? result.itemId : previousId;
}
return itemId;
} | [
"private",
"int",
"preparedStatement",
"(",
"Cassandra",
".",
"Client",
"client",
")",
"{",
"Integer",
"itemId",
"=",
"preparedStatements",
".",
"get",
"(",
"client",
")",
";",
"if",
"(",
"itemId",
"==",
"null",
")",
"{",
"CqlPreparedResult",
"result",
";",
... | get prepared statement id from cache, otherwise prepare it from Cassandra server | [
"get",
"prepared",
"statement",
"id",
"from",
"cache",
"otherwise",
"prepare",
"it",
"from",
"Cassandra",
"server"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java#L292-L315 |
36,004 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/Validator.java | Validator.complete | public void complete()
{
completeTree();
StageManager.getStage(Stage.ANTI_ENTROPY).execute(this);
if (logger.isDebugEnabled())
{
// log distribution of rows in tree
logger.debug("Validated {} partitions for {}. Partitions per leaf are:", validated, desc.sessionId);
tree.histogramOfRowCountPerLeaf().log(logger);
logger.debug("Validated {} partitions for {}. Partition sizes are:", validated, desc.sessionId);
tree.histogramOfRowSizePerLeaf().log(logger);
}
} | java | public void complete()
{
completeTree();
StageManager.getStage(Stage.ANTI_ENTROPY).execute(this);
if (logger.isDebugEnabled())
{
// log distribution of rows in tree
logger.debug("Validated {} partitions for {}. Partitions per leaf are:", validated, desc.sessionId);
tree.histogramOfRowCountPerLeaf().log(logger);
logger.debug("Validated {} partitions for {}. Partition sizes are:", validated, desc.sessionId);
tree.histogramOfRowSizePerLeaf().log(logger);
}
} | [
"public",
"void",
"complete",
"(",
")",
"{",
"completeTree",
"(",
")",
";",
"StageManager",
".",
"getStage",
"(",
"Stage",
".",
"ANTI_ENTROPY",
")",
".",
"execute",
"(",
"this",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
... | Registers the newly created tree for rendezvous in Stage.ANTIENTROPY. | [
"Registers",
"the",
"newly",
"created",
"tree",
"for",
"rendezvous",
"in",
"Stage",
".",
"ANTIENTROPY",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/Validator.java#L208-L222 |
36,005 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/Validator.java | Validator.fail | public void fail()
{
logger.error("Failed creating a merkle tree for {}, {} (see log for details)", desc, initiator);
// send fail message only to nodes >= version 2.0
MessagingService.instance().sendOneWay(new ValidationComplete(desc).createMessage(), initiator);
} | java | public void fail()
{
logger.error("Failed creating a merkle tree for {}, {} (see log for details)", desc, initiator);
// send fail message only to nodes >= version 2.0
MessagingService.instance().sendOneWay(new ValidationComplete(desc).createMessage(), initiator);
} | [
"public",
"void",
"fail",
"(",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed creating a merkle tree for {}, {} (see log for details)\"",
",",
"desc",
",",
"initiator",
")",
";",
"// send fail message only to nodes >= version 2.0",
"MessagingService",
".",
"instance",
"("... | Called when some error during the validation happened.
This sends RepairStatus to inform the initiator that the validation has failed.
The actual reason for failure should be looked up in the log of the host calling this function. | [
"Called",
"when",
"some",
"error",
"during",
"the",
"validation",
"happened",
".",
"This",
"sends",
"RepairStatus",
"to",
"inform",
"the",
"initiator",
"that",
"the",
"validation",
"has",
"failed",
".",
"The",
"actual",
"reason",
"for",
"failure",
"should",
"b... | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/Validator.java#L243-L248 |
36,006 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/Validator.java | Validator.run | public void run()
{
// respond to the request that triggered this validation
if (!initiator.equals(FBUtilities.getBroadcastAddress()))
logger.info(String.format("[repair #%s] Sending completed merkle tree to %s for %s/%s", desc.sessionId, initiator, desc.keyspace, desc.columnFamily));
MessagingService.instance().sendOneWay(new ValidationComplete(desc, tree).createMessage(), initiator);
} | java | public void run()
{
// respond to the request that triggered this validation
if (!initiator.equals(FBUtilities.getBroadcastAddress()))
logger.info(String.format("[repair #%s] Sending completed merkle tree to %s for %s/%s", desc.sessionId, initiator, desc.keyspace, desc.columnFamily));
MessagingService.instance().sendOneWay(new ValidationComplete(desc, tree).createMessage(), initiator);
} | [
"public",
"void",
"run",
"(",
")",
"{",
"// respond to the request that triggered this validation",
"if",
"(",
"!",
"initiator",
".",
"equals",
"(",
"FBUtilities",
".",
"getBroadcastAddress",
"(",
")",
")",
")",
"logger",
".",
"info",
"(",
"String",
".",
"format... | Called after the validation lifecycle to respond with the now valid tree. Runs in Stage.ANTIENTROPY. | [
"Called",
"after",
"the",
"validation",
"lifecycle",
"to",
"respond",
"with",
"the",
"now",
"valid",
"tree",
".",
"Runs",
"in",
"Stage",
".",
"ANTIENTROPY",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/Validator.java#L253-L259 |
36,007 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/concurrent/SEPExecutor.java | SEPExecutor.maybeSchedule | boolean maybeSchedule()
{
if (pool.spinningCount.get() > 0 || !takeWorkPermit(true))
return false;
pool.schedule(new Work(this));
return true;
} | java | boolean maybeSchedule()
{
if (pool.spinningCount.get() > 0 || !takeWorkPermit(true))
return false;
pool.schedule(new Work(this));
return true;
} | [
"boolean",
"maybeSchedule",
"(",
")",
"{",
"if",
"(",
"pool",
".",
"spinningCount",
".",
"get",
"(",
")",
">",
"0",
"||",
"!",
"takeWorkPermit",
"(",
"true",
")",
")",
"return",
"false",
";",
"pool",
".",
"schedule",
"(",
"new",
"Work",
"(",
"this",
... | will self-assign to it in the immediate future | [
"will",
"self",
"-",
"assign",
"to",
"it",
"in",
"the",
"immediate",
"future"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/concurrent/SEPExecutor.java#L71-L78 |
36,008 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/concurrent/SEPExecutor.java | SEPExecutor.returnWorkPermit | void returnWorkPermit()
{
while (true)
{
long current = permits.get();
int workPermits = workPermits(current);
if (permits.compareAndSet(current, updateWorkPermits(current, workPermits + 1)))
return;
}
} | java | void returnWorkPermit()
{
while (true)
{
long current = permits.get();
int workPermits = workPermits(current);
if (permits.compareAndSet(current, updateWorkPermits(current, workPermits + 1)))
return;
}
} | [
"void",
"returnWorkPermit",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"long",
"current",
"=",
"permits",
".",
"get",
"(",
")",
";",
"int",
"workPermits",
"=",
"workPermits",
"(",
"current",
")",
";",
"if",
"(",
"permits",
".",
"compareAndSet",
"("... | gives up a work permit | [
"gives",
"up",
"a",
"work",
"permit"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/concurrent/SEPExecutor.java#L169-L178 |
36,009 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/cql3/ErrorCollector.java | ErrorCollector.areTokensValid | private static boolean areTokensValid(Token... tokens)
{
for (Token token : tokens)
{
if (!isTokenValid(token))
return false;
}
return true;
} | java | private static boolean areTokensValid(Token... tokens)
{
for (Token token : tokens)
{
if (!isTokenValid(token))
return false;
}
return true;
} | [
"private",
"static",
"boolean",
"areTokensValid",
"(",
"Token",
"...",
"tokens",
")",
"{",
"for",
"(",
"Token",
"token",
":",
"tokens",
")",
"{",
"if",
"(",
"!",
"isTokenValid",
"(",
"token",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";"... | Checks if the specified tokens are valid.
@param tokens the tokens to check
@return <code>true</code> if all the specified tokens are valid ones, <code>false</code> otherwise. | [
"Checks",
"if",
"the",
"specified",
"tokens",
"are",
"valid",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cql3/ErrorCollector.java#L168-L176 |
36,010 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/cql3/ErrorCollector.java | ErrorCollector.highlightToken | private static String highlightToken(String line, Token token)
{
String newLine = insertChar(line, getLastCharPositionInLine(token), ']');
return insertChar(newLine, token.getCharPositionInLine(), '[');
} | java | private static String highlightToken(String line, Token token)
{
String newLine = insertChar(line, getLastCharPositionInLine(token), ']');
return insertChar(newLine, token.getCharPositionInLine(), '[');
} | [
"private",
"static",
"String",
"highlightToken",
"(",
"String",
"line",
",",
"Token",
"token",
")",
"{",
"String",
"newLine",
"=",
"insertChar",
"(",
"line",
",",
"getLastCharPositionInLine",
"(",
"token",
")",
",",
"'",
"'",
")",
";",
"return",
"insertChar"... | Puts the specified token within square brackets.
@param line the line containing the token
@param token the token to put within square brackets | [
"Puts",
"the",
"specified",
"token",
"within",
"square",
"brackets",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cql3/ErrorCollector.java#L210-L214 |
36,011 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/Differencer.java | Differencer.run | public void run()
{
// compare trees, and collect differences
differences.addAll(MerkleTree.difference(r1.tree, r2.tree));
// choose a repair method based on the significance of the difference
String format = String.format("[repair #%s] Endpoints %s and %s %%s for %s", desc.sessionId, r1.endpoint, r2.endpoint, desc.columnFamily);
if (differences.isEmpty())
{
logger.info(String.format(format, "are consistent"));
// send back sync complete message
MessagingService.instance().sendOneWay(new SyncComplete(desc, r1.endpoint, r2.endpoint, true).createMessage(), FBUtilities.getLocalAddress());
return;
}
// non-0 difference: perform streaming repair
logger.info(String.format(format, "have " + differences.size() + " range(s) out of sync"));
performStreamingRepair();
} | java | public void run()
{
// compare trees, and collect differences
differences.addAll(MerkleTree.difference(r1.tree, r2.tree));
// choose a repair method based on the significance of the difference
String format = String.format("[repair #%s] Endpoints %s and %s %%s for %s", desc.sessionId, r1.endpoint, r2.endpoint, desc.columnFamily);
if (differences.isEmpty())
{
logger.info(String.format(format, "are consistent"));
// send back sync complete message
MessagingService.instance().sendOneWay(new SyncComplete(desc, r1.endpoint, r2.endpoint, true).createMessage(), FBUtilities.getLocalAddress());
return;
}
// non-0 difference: perform streaming repair
logger.info(String.format(format, "have " + differences.size() + " range(s) out of sync"));
performStreamingRepair();
} | [
"public",
"void",
"run",
"(",
")",
"{",
"// compare trees, and collect differences",
"differences",
".",
"addAll",
"(",
"MerkleTree",
".",
"difference",
"(",
"r1",
".",
"tree",
",",
"r2",
".",
"tree",
")",
")",
";",
"// choose a repair method based on the significan... | Compares our trees, and triggers repairs for any ranges that mismatch. | [
"Compares",
"our",
"trees",
"and",
"triggers",
"repairs",
"for",
"any",
"ranges",
"that",
"mismatch",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/Differencer.java#L58-L76 |
36,012 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/Differencer.java | Differencer.minEndpoint | private InetAddress minEndpoint()
{
return FBUtilities.compareUnsigned(r1.endpoint.getAddress(), r2.endpoint.getAddress()) < 0
? r1.endpoint
: r2.endpoint;
} | java | private InetAddress minEndpoint()
{
return FBUtilities.compareUnsigned(r1.endpoint.getAddress(), r2.endpoint.getAddress()) < 0
? r1.endpoint
: r2.endpoint;
} | [
"private",
"InetAddress",
"minEndpoint",
"(",
")",
"{",
"return",
"FBUtilities",
".",
"compareUnsigned",
"(",
"r1",
".",
"endpoint",
".",
"getAddress",
"(",
")",
",",
"r2",
".",
"endpoint",
".",
"getAddress",
"(",
")",
")",
"<",
"0",
"?",
"r1",
".",
"e... | So we just order endpoint deterministically to simplify this | [
"So",
"we",
"just",
"order",
"endpoint",
"deterministically",
"to",
"simplify",
"this"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/Differencer.java#L118-L123 |
36,013 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/compress/CompressionMetadata.java | CompressionMetadata.create | public static CompressionMetadata create(String dataFilePath)
{
Descriptor desc = Descriptor.fromFilename(dataFilePath);
return new CompressionMetadata(desc.filenameFor(Component.COMPRESSION_INFO), new File(dataFilePath).length(), desc.version.hasPostCompressionAdlerChecksums);
} | java | public static CompressionMetadata create(String dataFilePath)
{
Descriptor desc = Descriptor.fromFilename(dataFilePath);
return new CompressionMetadata(desc.filenameFor(Component.COMPRESSION_INFO), new File(dataFilePath).length(), desc.version.hasPostCompressionAdlerChecksums);
} | [
"public",
"static",
"CompressionMetadata",
"create",
"(",
"String",
"dataFilePath",
")",
"{",
"Descriptor",
"desc",
"=",
"Descriptor",
".",
"fromFilename",
"(",
"dataFilePath",
")",
";",
"return",
"new",
"CompressionMetadata",
"(",
"desc",
".",
"filenameFor",
"(",... | Create metadata about given compressed file including uncompressed data length, chunk size
and list of the chunk offsets of the compressed data.
This is an expensive operation! Don't create more than one for each
sstable.
@param dataFilePath Path to the compressed file
@return metadata about given compressed file. | [
"Create",
"metadata",
"about",
"given",
"compressed",
"file",
"including",
"uncompressed",
"data",
"length",
"chunk",
"size",
"and",
"list",
"of",
"the",
"chunk",
"offsets",
"of",
"the",
"compressed",
"data",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java#L82-L86 |
36,014 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.reset | boolean reset(double useChance, int targetCount, boolean isWrite)
{
this.isWrite = isWrite;
if (this.useChance < 1d)
{
// we clear our prior roll-modifiers if the use chance was previously less-than zero
Arrays.fill(rollmodifier, 1d);
Arrays.fill(chancemodifier, 1d);
}
// set the seed for the first clustering component
generator.clusteringComponents.get(0).setSeed(idseed);
// calculate how many first clustering components we'll generate, and how many total rows this predicts
int firstComponentCount = (int) generator.clusteringComponents.get(0).clusteringDistribution.next();
int expectedRowCount;
int position = seed.position();
if (isWrite)
expectedRowCount = firstComponentCount * generator.clusteringDescendantAverages[0];
else if (position != 0)
expectedRowCount = setLastRow(position - 1);
else
expectedRowCount = setNoLastRow(firstComponentCount);
if (Double.isNaN(useChance))
useChance = Math.max(0d, Math.min(1d, targetCount / (double) expectedRowCount));
this.useChance = useChance;
while (true)
{
// we loop in case we have picked an entirely non-existent range, in which case
// we will reset the seed's position, then try again (until we exhaust it or find
// some real range)
for (Queue<?> q : clusteringComponents)
q.clear();
clusteringSeeds[0] = idseed;
fill(clusteringComponents[0], firstComponentCount, generator.clusteringComponents.get(0));
if (!isWrite)
{
if (seek(0) != State.SUCCESS)
throw new IllegalStateException();
return true;
}
int count = Math.max(1, expectedRowCount / seed.visits);
position = seed.moveForwards(count);
isFirstWrite = position == 0;
setLastRow(position + count - 1);
// seek to our start position
switch (seek(position))
{
case END_OF_PARTITION:
return false;
case SUCCESS:
return true;
}
}
} | java | boolean reset(double useChance, int targetCount, boolean isWrite)
{
this.isWrite = isWrite;
if (this.useChance < 1d)
{
// we clear our prior roll-modifiers if the use chance was previously less-than zero
Arrays.fill(rollmodifier, 1d);
Arrays.fill(chancemodifier, 1d);
}
// set the seed for the first clustering component
generator.clusteringComponents.get(0).setSeed(idseed);
// calculate how many first clustering components we'll generate, and how many total rows this predicts
int firstComponentCount = (int) generator.clusteringComponents.get(0).clusteringDistribution.next();
int expectedRowCount;
int position = seed.position();
if (isWrite)
expectedRowCount = firstComponentCount * generator.clusteringDescendantAverages[0];
else if (position != 0)
expectedRowCount = setLastRow(position - 1);
else
expectedRowCount = setNoLastRow(firstComponentCount);
if (Double.isNaN(useChance))
useChance = Math.max(0d, Math.min(1d, targetCount / (double) expectedRowCount));
this.useChance = useChance;
while (true)
{
// we loop in case we have picked an entirely non-existent range, in which case
// we will reset the seed's position, then try again (until we exhaust it or find
// some real range)
for (Queue<?> q : clusteringComponents)
q.clear();
clusteringSeeds[0] = idseed;
fill(clusteringComponents[0], firstComponentCount, generator.clusteringComponents.get(0));
if (!isWrite)
{
if (seek(0) != State.SUCCESS)
throw new IllegalStateException();
return true;
}
int count = Math.max(1, expectedRowCount / seed.visits);
position = seed.moveForwards(count);
isFirstWrite = position == 0;
setLastRow(position + count - 1);
// seek to our start position
switch (seek(position))
{
case END_OF_PARTITION:
return false;
case SUCCESS:
return true;
}
}
} | [
"boolean",
"reset",
"(",
"double",
"useChance",
",",
"int",
"targetCount",
",",
"boolean",
"isWrite",
")",
"{",
"this",
".",
"isWrite",
"=",
"isWrite",
";",
"if",
"(",
"this",
".",
"useChance",
"<",
"1d",
")",
"{",
"// we clear our prior roll-modifiers if the ... | initialise the iterator state
if we're a write, the expected behaviour is that the requested
batch count is compounded with the seed's visit count to decide
how much we should return in one iteration
@param useChance uniform chance of visiting any single row (NaN if targetCount provided)
@param targetCount number of rows we would like to visit (0 if useChance provided)
@param isWrite true if the action requires write semantics
@return true if there is data to return, false otherwise | [
"initialise",
"the",
"iterator",
"state"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L204-L267 |
36,015 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.setNoLastRow | private int setNoLastRow(int firstComponentCount)
{
Arrays.fill(lastRow, Integer.MAX_VALUE);
return firstComponentCount * generator.clusteringDescendantAverages[0];
} | java | private int setNoLastRow(int firstComponentCount)
{
Arrays.fill(lastRow, Integer.MAX_VALUE);
return firstComponentCount * generator.clusteringDescendantAverages[0];
} | [
"private",
"int",
"setNoLastRow",
"(",
"int",
"firstComponentCount",
")",
"{",
"Arrays",
".",
"fill",
"(",
"lastRow",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"return",
"firstComponentCount",
"*",
"generator",
".",
"clusteringDescendantAverages",
"[",
"0",
"]... | returns expected row count | [
"returns",
"expected",
"row",
"count"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L270-L274 |
36,016 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.setLastRow | private int setLastRow(int position)
{
if (position < 0)
throw new IllegalStateException();
decompose(position, lastRow);
int expectedRowCount = 0;
for (int i = 0 ; i < lastRow.length ; i++)
{
int l = lastRow[i];
expectedRowCount += l * generator.clusteringDescendantAverages[i];
}
return expectedRowCount + 1;
} | java | private int setLastRow(int position)
{
if (position < 0)
throw new IllegalStateException();
decompose(position, lastRow);
int expectedRowCount = 0;
for (int i = 0 ; i < lastRow.length ; i++)
{
int l = lastRow[i];
expectedRowCount += l * generator.clusteringDescendantAverages[i];
}
return expectedRowCount + 1;
} | [
"private",
"int",
"setLastRow",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
")",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"decompose",
"(",
"position",
",",
"lastRow",
")",
";",
"int",
"expectedRowCount",
"=",
"0",
"... | returns expected distance from zero | [
"returns",
"expected",
"distance",
"from",
"zero"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L278-L291 |
36,017 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.compareToLastRow | private int compareToLastRow(int depth)
{
for (int i = 0 ; i <= depth ; i++)
{
int p = currentRow[i], l = lastRow[i], r = clusteringComponents[i].size();
if ((p == l) | (r == 1))
continue;
return p - l;
}
return 0;
} | java | private int compareToLastRow(int depth)
{
for (int i = 0 ; i <= depth ; i++)
{
int p = currentRow[i], l = lastRow[i], r = clusteringComponents[i].size();
if ((p == l) | (r == 1))
continue;
return p - l;
}
return 0;
} | [
"private",
"int",
"compareToLastRow",
"(",
"int",
"depth",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"depth",
";",
"i",
"++",
")",
"{",
"int",
"p",
"=",
"currentRow",
"[",
"i",
"]",
",",
"l",
"=",
"lastRow",
"[",
"i",
"]",
"... | OR if that row does not exist, it is the last row prior to it | [
"OR",
"if",
"that",
"row",
"does",
"not",
"exist",
"it",
"is",
"the",
"last",
"row",
"prior",
"to",
"it"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L297-L307 |
36,018 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.decompose | private void decompose(int scalar, int[] decomposed)
{
for (int i = 0 ; i < decomposed.length ; i++)
{
int avg = generator.clusteringDescendantAverages[i];
decomposed[i] = scalar / avg;
scalar %= avg;
}
for (int i = lastRow.length - 1 ; i > 0 ; i--)
{
int avg = generator.clusteringComponentAverages[i];
if (decomposed[i] >= avg)
{
decomposed[i - 1] += decomposed[i] / avg;
decomposed[i] %= avg;
}
}
} | java | private void decompose(int scalar, int[] decomposed)
{
for (int i = 0 ; i < decomposed.length ; i++)
{
int avg = generator.clusteringDescendantAverages[i];
decomposed[i] = scalar / avg;
scalar %= avg;
}
for (int i = lastRow.length - 1 ; i > 0 ; i--)
{
int avg = generator.clusteringComponentAverages[i];
if (decomposed[i] >= avg)
{
decomposed[i - 1] += decomposed[i] / avg;
decomposed[i] %= avg;
}
}
} | [
"private",
"void",
"decompose",
"(",
"int",
"scalar",
",",
"int",
"[",
"]",
"decomposed",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"decomposed",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"avg",
"=",
"generator",
".",
"clus... | Translate the scalar position into a tiered position based on mean expected counts
@param scalar scalar position
@param decomposed target container | [
"Translate",
"the",
"scalar",
"position",
"into",
"a",
"tiered",
"position",
"based",
"on",
"mean",
"expected",
"counts"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L314-L331 |
36,019 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.seek | private State seek(int scalar)
{
if (scalar == 0)
{
this.currentRow[0] = -1;
clusteringComponents[0].addFirst(this);
return setHasNext(advance(0, true));
}
int[] position = this.currentRow;
decompose(scalar, position);
for (int i = 0 ; i < position.length ; i++)
{
if (i != 0)
fill(i);
for (int c = position[i] ; c > 0 ; c--)
clusteringComponents[i].poll();
// we can have started from a position that does not exist, in which
// case we need to ascend back up our clustering components, advancing as we go
if (clusteringComponents[i].isEmpty())
{
int j = i;
while (true)
{
// if we've exhausted the whole partition, we're done
if (--j < 0)
return setHasNext(false);
clusteringComponents[j].poll();
if (!clusteringComponents[j].isEmpty())
break;
}
// we don't check here to see if we've exceeded our lastRow,
// because if we came to a non-existent position and generated a lastRow
// we want to at least find the next real position, and set it on the seed
// in this case we do then yield false and select a different seed to continue with
position[j]++;
Arrays.fill(position, j + 1, position.length, 0);
while (j < i)
fill(++j);
}
row.row[i] = clusteringComponents[i].peek();
}
if (compareToLastRow(currentRow.length - 1) > 0)
return setHasNext(false);
// call advance so we honour any select chance
position[position.length - 1]--;
clusteringComponents[position.length - 1].addFirst(this);
return setHasNext(advance(position.length - 1, true));
} | java | private State seek(int scalar)
{
if (scalar == 0)
{
this.currentRow[0] = -1;
clusteringComponents[0].addFirst(this);
return setHasNext(advance(0, true));
}
int[] position = this.currentRow;
decompose(scalar, position);
for (int i = 0 ; i < position.length ; i++)
{
if (i != 0)
fill(i);
for (int c = position[i] ; c > 0 ; c--)
clusteringComponents[i].poll();
// we can have started from a position that does not exist, in which
// case we need to ascend back up our clustering components, advancing as we go
if (clusteringComponents[i].isEmpty())
{
int j = i;
while (true)
{
// if we've exhausted the whole partition, we're done
if (--j < 0)
return setHasNext(false);
clusteringComponents[j].poll();
if (!clusteringComponents[j].isEmpty())
break;
}
// we don't check here to see if we've exceeded our lastRow,
// because if we came to a non-existent position and generated a lastRow
// we want to at least find the next real position, and set it on the seed
// in this case we do then yield false and select a different seed to continue with
position[j]++;
Arrays.fill(position, j + 1, position.length, 0);
while (j < i)
fill(++j);
}
row.row[i] = clusteringComponents[i].peek();
}
if (compareToLastRow(currentRow.length - 1) > 0)
return setHasNext(false);
// call advance so we honour any select chance
position[position.length - 1]--;
clusteringComponents[position.length - 1].addFirst(this);
return setHasNext(advance(position.length - 1, true));
} | [
"private",
"State",
"seek",
"(",
"int",
"scalar",
")",
"{",
"if",
"(",
"scalar",
"==",
"0",
")",
"{",
"this",
".",
"currentRow",
"[",
"0",
"]",
"=",
"-",
"1",
";",
"clusteringComponents",
"[",
"0",
"]",
".",
"addFirst",
"(",
"this",
")",
";",
"re... | seek to the provided position to initialise the iterator
@param scalar scalar position
@return resultant iterator state | [
"seek",
"to",
"the",
"provided",
"position",
"to",
"initialise",
"the",
"iterator"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L344-L398 |
36,020 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.advance | void advance()
{
// we are always at the leaf level when this method is invoked
// so we calculate the seed for generating the row by combining the seed that generated the clustering components
int depth = clusteringComponents.length - 1;
long parentSeed = clusteringSeeds[depth];
long rowSeed = seed(clusteringComponents[depth].peek(), generator.clusteringComponents.get(depth).type, parentSeed);
// and then fill the row with the _non-clustering_ values for the position we _were_ at, as this is what we'll deliver
for (int i = clusteringSeeds.length ; i < row.row.length ; i++)
{
Generator gen = generator.valueComponents.get(i - clusteringSeeds.length);
gen.setSeed(rowSeed);
row.row[i] = gen.generate();
}
// then we advance the leaf level
setHasNext(advance(depth, false));
} | java | void advance()
{
// we are always at the leaf level when this method is invoked
// so we calculate the seed for generating the row by combining the seed that generated the clustering components
int depth = clusteringComponents.length - 1;
long parentSeed = clusteringSeeds[depth];
long rowSeed = seed(clusteringComponents[depth].peek(), generator.clusteringComponents.get(depth).type, parentSeed);
// and then fill the row with the _non-clustering_ values for the position we _were_ at, as this is what we'll deliver
for (int i = clusteringSeeds.length ; i < row.row.length ; i++)
{
Generator gen = generator.valueComponents.get(i - clusteringSeeds.length);
gen.setSeed(rowSeed);
row.row[i] = gen.generate();
}
// then we advance the leaf level
setHasNext(advance(depth, false));
} | [
"void",
"advance",
"(",
")",
"{",
"// we are always at the leaf level when this method is invoked",
"// so we calculate the seed for generating the row by combining the seed that generated the clustering components",
"int",
"depth",
"=",
"clusteringComponents",
".",
"length",
"-",
"1",
... | to move the iterator to the next item | [
"to",
"move",
"the",
"iterator",
"to",
"the",
"next",
"item"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L402-L420 |
36,021 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.fill | void fill(int depth)
{
long seed = clusteringSeeds[depth - 1];
Generator gen = generator.clusteringComponents.get(depth);
gen.setSeed(seed);
clusteringSeeds[depth] = seed(clusteringComponents[depth - 1].peek(), generator.clusteringComponents.get(depth - 1).type, seed);
fill(clusteringComponents[depth], (int) gen.clusteringDistribution.next(), gen);
} | java | void fill(int depth)
{
long seed = clusteringSeeds[depth - 1];
Generator gen = generator.clusteringComponents.get(depth);
gen.setSeed(seed);
clusteringSeeds[depth] = seed(clusteringComponents[depth - 1].peek(), generator.clusteringComponents.get(depth - 1).type, seed);
fill(clusteringComponents[depth], (int) gen.clusteringDistribution.next(), gen);
} | [
"void",
"fill",
"(",
"int",
"depth",
")",
"{",
"long",
"seed",
"=",
"clusteringSeeds",
"[",
"depth",
"-",
"1",
"]",
";",
"Generator",
"gen",
"=",
"generator",
".",
"clusteringComponents",
".",
"get",
"(",
"depth",
")",
";",
"gen",
".",
"setSeed",
"(",
... | to have been generated and their seeds populated into clusteringSeeds | [
"to",
"have",
"been",
"generated",
"and",
"their",
"seeds",
"populated",
"into",
"clusteringSeeds"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L486-L493 |
36,022 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java | MultiRowIterator.fill | void fill(Queue<Object> queue, int count, Generator generator)
{
if (count == 1)
{
queue.add(generator.generate());
return;
}
switch (this.generator.order)
{
case SORTED:
if (Comparable.class.isAssignableFrom(generator.clazz))
{
tosort.clear();
for (int i = 0 ; i < count ; i++)
tosort.add(generator.generate());
Collections.sort((List<Comparable>) (List<?>) tosort);
for (int i = 0 ; i < count ; i++)
if (i == 0 || ((Comparable) tosort.get(i - 1)).compareTo(i) < 0)
queue.add(tosort.get(i));
break;
}
case ARBITRARY:
unique.clear();
for (int i = 0 ; i < count ; i++)
{
Object next = generator.generate();
if (unique.add(next))
queue.add(next);
}
break;
case SHUFFLED:
unique.clear();
tosort.clear();
ThreadLocalRandom rand = ThreadLocalRandom.current();
for (int i = 0 ; i < count ; i++)
{
Object next = generator.generate();
if (unique.add(next))
tosort.add(next);
}
for (int i = 0 ; i < tosort.size() ; i++)
{
int index = rand.nextInt(i, tosort.size());
Object obj = tosort.get(index);
tosort.set(index, tosort.get(i));
queue.add(obj);
}
break;
default:
throw new IllegalStateException();
}
} | java | void fill(Queue<Object> queue, int count, Generator generator)
{
if (count == 1)
{
queue.add(generator.generate());
return;
}
switch (this.generator.order)
{
case SORTED:
if (Comparable.class.isAssignableFrom(generator.clazz))
{
tosort.clear();
for (int i = 0 ; i < count ; i++)
tosort.add(generator.generate());
Collections.sort((List<Comparable>) (List<?>) tosort);
for (int i = 0 ; i < count ; i++)
if (i == 0 || ((Comparable) tosort.get(i - 1)).compareTo(i) < 0)
queue.add(tosort.get(i));
break;
}
case ARBITRARY:
unique.clear();
for (int i = 0 ; i < count ; i++)
{
Object next = generator.generate();
if (unique.add(next))
queue.add(next);
}
break;
case SHUFFLED:
unique.clear();
tosort.clear();
ThreadLocalRandom rand = ThreadLocalRandom.current();
for (int i = 0 ; i < count ; i++)
{
Object next = generator.generate();
if (unique.add(next))
tosort.add(next);
}
for (int i = 0 ; i < tosort.size() ; i++)
{
int index = rand.nextInt(i, tosort.size());
Object obj = tosort.get(index);
tosort.set(index, tosort.get(i));
queue.add(obj);
}
break;
default:
throw new IllegalStateException();
}
} | [
"void",
"fill",
"(",
"Queue",
"<",
"Object",
">",
"queue",
",",
"int",
"count",
",",
"Generator",
"generator",
")",
"{",
"if",
"(",
"count",
"==",
"1",
")",
"{",
"queue",
".",
"add",
"(",
"generator",
".",
"generate",
"(",
")",
")",
";",
"return",
... | generate the clustering components into the queue | [
"generate",
"the",
"clustering",
"components",
"into",
"the",
"queue"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/generate/PartitionIterator.java#L496-L548 |
36,023 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/commitlog/AbstractCommitLogService.java | AbstractCommitLogService.requestExtraSync | public WaitQueue.Signal requestExtraSync()
{
WaitQueue.Signal signal = syncComplete.register();
haveWork.release(1);
return signal;
} | java | public WaitQueue.Signal requestExtraSync()
{
WaitQueue.Signal signal = syncComplete.register();
haveWork.release(1);
return signal;
} | [
"public",
"WaitQueue",
".",
"Signal",
"requestExtraSync",
"(",
")",
"{",
"WaitQueue",
".",
"Signal",
"signal",
"=",
"syncComplete",
".",
"register",
"(",
")",
";",
"haveWork",
".",
"release",
"(",
"1",
")",
";",
"return",
"signal",
";",
"}"
] | Sync immediately, but don't block for the sync to cmplete | [
"Sync",
"immediately",
"but",
"don",
"t",
"block",
"for",
"the",
"sync",
"to",
"cmplete"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/commitlog/AbstractCommitLogService.java#L160-L165 |
36,024 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/config/YamlConfigurationLoader.java | YamlConfigurationLoader.getStorageConfigURL | static URL getStorageConfigURL() throws ConfigurationException
{
String configUrl = System.getProperty("cassandra.config");
if (configUrl == null)
configUrl = DEFAULT_CONFIGURATION;
URL url;
try
{
url = new URL(configUrl);
url.openStream().close(); // catches well-formed but bogus URLs
}
catch (Exception e)
{
ClassLoader loader = DatabaseDescriptor.class.getClassLoader();
url = loader.getResource(configUrl);
if (url == null)
{
String required = "file:" + File.separator + File.separator;
if (!configUrl.startsWith(required))
throw new ConfigurationException("Expecting URI in variable: [cassandra.config]. Please prefix the file with " + required + File.separator +
" for local files or " + required + "<server>" + File.separator + " for remote files. Aborting. If you are executing this from an external tool, it needs to set Config.setClientMode(true) to avoid loading configuration.");
throw new ConfigurationException("Cannot locate " + configUrl + ". If this is a local file, please confirm you've provided " + required + File.separator + " as a URI prefix.");
}
}
return url;
} | java | static URL getStorageConfigURL() throws ConfigurationException
{
String configUrl = System.getProperty("cassandra.config");
if (configUrl == null)
configUrl = DEFAULT_CONFIGURATION;
URL url;
try
{
url = new URL(configUrl);
url.openStream().close(); // catches well-formed but bogus URLs
}
catch (Exception e)
{
ClassLoader loader = DatabaseDescriptor.class.getClassLoader();
url = loader.getResource(configUrl);
if (url == null)
{
String required = "file:" + File.separator + File.separator;
if (!configUrl.startsWith(required))
throw new ConfigurationException("Expecting URI in variable: [cassandra.config]. Please prefix the file with " + required + File.separator +
" for local files or " + required + "<server>" + File.separator + " for remote files. Aborting. If you are executing this from an external tool, it needs to set Config.setClientMode(true) to avoid loading configuration.");
throw new ConfigurationException("Cannot locate " + configUrl + ". If this is a local file, please confirm you've provided " + required + File.separator + " as a URI prefix.");
}
}
return url;
} | [
"static",
"URL",
"getStorageConfigURL",
"(",
")",
"throws",
"ConfigurationException",
"{",
"String",
"configUrl",
"=",
"System",
".",
"getProperty",
"(",
"\"cassandra.config\"",
")",
";",
"if",
"(",
"configUrl",
"==",
"null",
")",
"configUrl",
"=",
"DEFAULT_CONFIG... | Inspect the classpath to find storage configuration file | [
"Inspect",
"the",
"classpath",
"to",
"find",
"storage",
"configuration",
"file"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java#L53-L80 |
36,025 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/config/ColumnDefinition.java | ColumnDefinition.deleteFromSchema | public void deleteFromSchema(Mutation mutation, long timestamp)
{
ColumnFamily cf = mutation.addOrGet(CFMetaData.SchemaColumnsCf);
int ldt = (int) (System.currentTimeMillis() / 1000);
// Note: we do want to use name.toString(), not name.bytes directly for backward compatibility (For CQL3, this won't make a difference).
Composite prefix = CFMetaData.SchemaColumnsCf.comparator.make(cfName, name.toString());
cf.addAtom(new RangeTombstone(prefix, prefix.end(), timestamp, ldt));
} | java | public void deleteFromSchema(Mutation mutation, long timestamp)
{
ColumnFamily cf = mutation.addOrGet(CFMetaData.SchemaColumnsCf);
int ldt = (int) (System.currentTimeMillis() / 1000);
// Note: we do want to use name.toString(), not name.bytes directly for backward compatibility (For CQL3, this won't make a difference).
Composite prefix = CFMetaData.SchemaColumnsCf.comparator.make(cfName, name.toString());
cf.addAtom(new RangeTombstone(prefix, prefix.end(), timestamp, ldt));
} | [
"public",
"void",
"deleteFromSchema",
"(",
"Mutation",
"mutation",
",",
"long",
"timestamp",
")",
"{",
"ColumnFamily",
"cf",
"=",
"mutation",
".",
"addOrGet",
"(",
"CFMetaData",
".",
"SchemaColumnsCf",
")",
";",
"int",
"ldt",
"=",
"(",
"int",
")",
"(",
"Sy... | Drop specified column from the schema using given mutation.
@param mutation The schema mutation
@param timestamp The timestamp to use for column modification | [
"Drop",
"specified",
"column",
"from",
"the",
"schema",
"using",
"given",
"mutation",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/config/ColumnDefinition.java#L316-L324 |
36,026 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/config/ColumnDefinition.java | ColumnDefinition.fromSchema | public static List<ColumnDefinition> fromSchema(UntypedResultSet serializedColumns, String ksName, String cfName, AbstractType<?> rawComparator, boolean isSuper)
{
List<ColumnDefinition> cds = new ArrayList<>();
for (UntypedResultSet.Row row : serializedColumns)
{
Kind kind = row.has(KIND)
? Kind.deserialize(row.getString(KIND))
: Kind.REGULAR;
Integer componentIndex = null;
if (row.has(COMPONENT_INDEX))
componentIndex = row.getInt(COMPONENT_INDEX);
else if (kind == Kind.CLUSTERING_COLUMN && isSuper)
componentIndex = 1; // A ColumnDefinition for super columns applies to the column component
// Note: we save the column name as string, but we should not assume that it is an UTF8 name, we
// we need to use the comparator fromString method
AbstractType<?> comparator = getComponentComparator(rawComparator, componentIndex, kind);
ColumnIdentifier name = new ColumnIdentifier(comparator.fromString(row.getString(COLUMN_NAME)), comparator);
AbstractType<?> validator;
try
{
validator = TypeParser.parse(row.getString(TYPE));
}
catch (RequestValidationException e)
{
throw new RuntimeException(e);
}
IndexType indexType = null;
if (row.has(INDEX_TYPE))
indexType = IndexType.valueOf(row.getString(INDEX_TYPE));
Map<String, String> indexOptions = null;
if (row.has(INDEX_OPTIONS))
indexOptions = FBUtilities.fromJsonMap(row.getString(INDEX_OPTIONS));
String indexName = null;
if (row.has(INDEX_NAME))
indexName = row.getString(INDEX_NAME);
cds.add(new ColumnDefinition(ksName, cfName, name, validator, indexType, indexOptions, indexName, componentIndex, kind));
}
return cds;
} | java | public static List<ColumnDefinition> fromSchema(UntypedResultSet serializedColumns, String ksName, String cfName, AbstractType<?> rawComparator, boolean isSuper)
{
List<ColumnDefinition> cds = new ArrayList<>();
for (UntypedResultSet.Row row : serializedColumns)
{
Kind kind = row.has(KIND)
? Kind.deserialize(row.getString(KIND))
: Kind.REGULAR;
Integer componentIndex = null;
if (row.has(COMPONENT_INDEX))
componentIndex = row.getInt(COMPONENT_INDEX);
else if (kind == Kind.CLUSTERING_COLUMN && isSuper)
componentIndex = 1; // A ColumnDefinition for super columns applies to the column component
// Note: we save the column name as string, but we should not assume that it is an UTF8 name, we
// we need to use the comparator fromString method
AbstractType<?> comparator = getComponentComparator(rawComparator, componentIndex, kind);
ColumnIdentifier name = new ColumnIdentifier(comparator.fromString(row.getString(COLUMN_NAME)), comparator);
AbstractType<?> validator;
try
{
validator = TypeParser.parse(row.getString(TYPE));
}
catch (RequestValidationException e)
{
throw new RuntimeException(e);
}
IndexType indexType = null;
if (row.has(INDEX_TYPE))
indexType = IndexType.valueOf(row.getString(INDEX_TYPE));
Map<String, String> indexOptions = null;
if (row.has(INDEX_OPTIONS))
indexOptions = FBUtilities.fromJsonMap(row.getString(INDEX_OPTIONS));
String indexName = null;
if (row.has(INDEX_NAME))
indexName = row.getString(INDEX_NAME);
cds.add(new ColumnDefinition(ksName, cfName, name, validator, indexType, indexOptions, indexName, componentIndex, kind));
}
return cds;
} | [
"public",
"static",
"List",
"<",
"ColumnDefinition",
">",
"fromSchema",
"(",
"UntypedResultSet",
"serializedColumns",
",",
"String",
"ksName",
",",
"String",
"cfName",
",",
"AbstractType",
"<",
"?",
">",
"rawComparator",
",",
"boolean",
"isSuper",
")",
"{",
"Lis... | Deserialize columns from storage-level representation
@param serializedColumns storage-level partition containing the column definitions
@return the list of processed ColumnDefinitions | [
"Deserialize",
"columns",
"from",
"storage",
"-",
"level",
"representation"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/config/ColumnDefinition.java#L379-L425 |
36,027 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/serializers/MapSerializer.java | MapSerializer.getSerializedValue | public ByteBuffer getSerializedValue(ByteBuffer serializedMap, ByteBuffer serializedKey, AbstractType keyType)
{
try
{
ByteBuffer input = serializedMap.duplicate();
int n = readCollectionSize(input, Server.VERSION_3);
for (int i = 0; i < n; i++)
{
ByteBuffer kbb = readValue(input, Server.VERSION_3);
ByteBuffer vbb = readValue(input, Server.VERSION_3);
int comparison = keyType.compare(kbb, serializedKey);
if (comparison == 0)
return vbb;
else if (comparison > 0)
// since the map is in sorted order, we know we've gone too far and the element doesn't exist
return null;
}
return null;
}
catch (BufferUnderflowException e)
{
throw new MarshalException("Not enough bytes to read a map");
}
} | java | public ByteBuffer getSerializedValue(ByteBuffer serializedMap, ByteBuffer serializedKey, AbstractType keyType)
{
try
{
ByteBuffer input = serializedMap.duplicate();
int n = readCollectionSize(input, Server.VERSION_3);
for (int i = 0; i < n; i++)
{
ByteBuffer kbb = readValue(input, Server.VERSION_3);
ByteBuffer vbb = readValue(input, Server.VERSION_3);
int comparison = keyType.compare(kbb, serializedKey);
if (comparison == 0)
return vbb;
else if (comparison > 0)
// since the map is in sorted order, we know we've gone too far and the element doesn't exist
return null;
}
return null;
}
catch (BufferUnderflowException e)
{
throw new MarshalException("Not enough bytes to read a map");
}
} | [
"public",
"ByteBuffer",
"getSerializedValue",
"(",
"ByteBuffer",
"serializedMap",
",",
"ByteBuffer",
"serializedKey",
",",
"AbstractType",
"keyType",
")",
"{",
"try",
"{",
"ByteBuffer",
"input",
"=",
"serializedMap",
".",
"duplicate",
"(",
")",
";",
"int",
"n",
... | Given a serialized map, gets the value associated with a given key.
@param serializedMap a serialized map
@param serializedKey a serialized key
@param keyType the key type for the map
@return the value associated with the key if one exists, null otherwise | [
"Given",
"a",
"serialized",
"map",
"gets",
"the",
"value",
"associated",
"with",
"a",
"given",
"key",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/serializers/MapSerializer.java#L126-L149 |
36,028 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/btree/BTree.java | BTree.build | public static <V> Object[] build(Iterable<V> source, int size, Comparator<V> comparator, boolean sorted, UpdateFunction<V> updateF)
{
if (size < FAN_FACTOR)
{
// pad to even length to match contract that all leaf nodes are even
V[] values = (V[]) new Object[size + (size & 1)];
{
int i = 0;
for (V v : source)
values[i++] = v;
}
// inline sorting since we're already calling toArray
if (!sorted)
Arrays.sort(values, 0, size, comparator);
// if updateF is specified
if (updateF != null)
{
for (int i = 0 ; i < size ; i++)
values[i] = updateF.apply(values[i]);
updateF.allocated(ObjectSizes.sizeOfArray(values));
}
return values;
}
if (!sorted)
source = sorted(source, comparator, size);
Queue<Builder> queue = modifier.get();
Builder builder = queue.poll();
if (builder == null)
builder = new Builder();
Object[] btree = builder.build(source, updateF, size);
queue.add(builder);
return btree;
} | java | public static <V> Object[] build(Iterable<V> source, int size, Comparator<V> comparator, boolean sorted, UpdateFunction<V> updateF)
{
if (size < FAN_FACTOR)
{
// pad to even length to match contract that all leaf nodes are even
V[] values = (V[]) new Object[size + (size & 1)];
{
int i = 0;
for (V v : source)
values[i++] = v;
}
// inline sorting since we're already calling toArray
if (!sorted)
Arrays.sort(values, 0, size, comparator);
// if updateF is specified
if (updateF != null)
{
for (int i = 0 ; i < size ; i++)
values[i] = updateF.apply(values[i]);
updateF.allocated(ObjectSizes.sizeOfArray(values));
}
return values;
}
if (!sorted)
source = sorted(source, comparator, size);
Queue<Builder> queue = modifier.get();
Builder builder = queue.poll();
if (builder == null)
builder = new Builder();
Object[] btree = builder.build(source, updateF, size);
queue.add(builder);
return btree;
} | [
"public",
"static",
"<",
"V",
">",
"Object",
"[",
"]",
"build",
"(",
"Iterable",
"<",
"V",
">",
"source",
",",
"int",
"size",
",",
"Comparator",
"<",
"V",
">",
"comparator",
",",
"boolean",
"sorted",
",",
"UpdateFunction",
"<",
"V",
">",
"updateF",
"... | Creates a BTree containing all of the objects in the provided collection
@param source the items to build the tree with
@param comparator the comparator that defines the ordering over the items in the tree
@param sorted if false, the collection will be copied and sorted to facilitate construction
@param <V>
@return | [
"Creates",
"a",
"BTree",
"containing",
"all",
"of",
"the",
"objects",
"in",
"the",
"provided",
"collection"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/btree/BTree.java#L96-L132 |
36,029 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/btree/BTree.java | BTree.slice | public static <V> Cursor<V, V> slice(Object[] btree, boolean forwards)
{
Cursor<V, V> r = new Cursor<>();
r.reset(btree, forwards);
return r;
} | java | public static <V> Cursor<V, V> slice(Object[] btree, boolean forwards)
{
Cursor<V, V> r = new Cursor<>();
r.reset(btree, forwards);
return r;
} | [
"public",
"static",
"<",
"V",
">",
"Cursor",
"<",
"V",
",",
"V",
">",
"slice",
"(",
"Object",
"[",
"]",
"btree",
",",
"boolean",
"forwards",
")",
"{",
"Cursor",
"<",
"V",
",",
"V",
">",
"r",
"=",
"new",
"Cursor",
"<>",
"(",
")",
";",
"r",
"."... | Returns an Iterator over the entire tree
@param btree the tree to iterate over
@param forwards if false, the iterator will start at the end and move backwards
@param <V>
@return | [
"Returns",
"an",
"Iterator",
"over",
"the",
"entire",
"tree"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/btree/BTree.java#L199-L204 |
36,030 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/btree/BTree.java | BTree.slice | public static <K, V extends K> Cursor<K, V> slice(Object[] btree, Comparator<K> comparator, K start, boolean startInclusive, K end, boolean endInclusive, boolean forwards)
{
Cursor<K, V> r = new Cursor<>();
r.reset(btree, comparator, start, startInclusive, end, endInclusive, forwards);
return r;
} | java | public static <K, V extends K> Cursor<K, V> slice(Object[] btree, Comparator<K> comparator, K start, boolean startInclusive, K end, boolean endInclusive, boolean forwards)
{
Cursor<K, V> r = new Cursor<>();
r.reset(btree, comparator, start, startInclusive, end, endInclusive, forwards);
return r;
} | [
"public",
"static",
"<",
"K",
",",
"V",
"extends",
"K",
">",
"Cursor",
"<",
"K",
",",
"V",
">",
"slice",
"(",
"Object",
"[",
"]",
"btree",
",",
"Comparator",
"<",
"K",
">",
"comparator",
",",
"K",
"start",
",",
"boolean",
"startInclusive",
",",
"K"... | Returns an Iterator over a sub-range of the tree
@param btree the tree to iterate over
@param comparator the comparator that defines the ordering over the items in the tree
@param start the first item to include
@param end the last item to include
@param forwards if false, the iterator will start at end and move backwards
@param <V>
@return | [
"Returns",
"an",
"Iterator",
"over",
"a",
"sub",
"-",
"range",
"of",
"the",
"tree"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/btree/BTree.java#L235-L240 |
36,031 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/btree/BTree.java | BTree.getLeafKeyEnd | static int getLeafKeyEnd(Object[] node)
{
int len = node.length;
if (len == 0)
return 0;
else if (node[len - 1] == null)
return len - 1;
else
return len;
} | java | static int getLeafKeyEnd(Object[] node)
{
int len = node.length;
if (len == 0)
return 0;
else if (node[len - 1] == null)
return len - 1;
else
return len;
} | [
"static",
"int",
"getLeafKeyEnd",
"(",
"Object",
"[",
"]",
"node",
")",
"{",
"int",
"len",
"=",
"node",
".",
"length",
";",
"if",
"(",
"len",
"==",
"0",
")",
"return",
"0",
";",
"else",
"if",
"(",
"node",
"[",
"len",
"-",
"1",
"]",
"==",
"null"... | get the last index that is non-null in the leaf node | [
"get",
"the",
"last",
"index",
"that",
"is",
"non",
"-",
"null",
"in",
"the",
"leaf",
"node"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/btree/BTree.java#L299-L308 |
36,032 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/btree/BTree.java | BTree.sorted | private static <V> Collection<V> sorted(Iterable<V> source, Comparator<V> comparator, int size)
{
V[] vs = (V[]) new Object[size];
int i = 0;
for (V v : source)
vs[i++] = v;
Arrays.sort(vs, comparator);
return Arrays.asList(vs);
} | java | private static <V> Collection<V> sorted(Iterable<V> source, Comparator<V> comparator, int size)
{
V[] vs = (V[]) new Object[size];
int i = 0;
for (V v : source)
vs[i++] = v;
Arrays.sort(vs, comparator);
return Arrays.asList(vs);
} | [
"private",
"static",
"<",
"V",
">",
"Collection",
"<",
"V",
">",
"sorted",
"(",
"Iterable",
"<",
"V",
">",
"source",
",",
"Comparator",
"<",
"V",
">",
"comparator",
",",
"int",
"size",
")",
"{",
"V",
"[",
"]",
"vs",
"=",
"(",
"V",
"[",
"]",
")"... | return a sorted collection | [
"return",
"a",
"sorted",
"collection"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/btree/BTree.java#L365-L373 |
36,033 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/DatacenterAwareRequestCoordinator.java | DatacenterAwareRequestCoordinator.completed | public int completed(InetAddress request)
{
String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(request);
Queue<InetAddress> requests = requestsByDatacenter.get(dc);
assert requests != null;
assert request.equals(requests.peek());
requests.poll();
if (!requests.isEmpty())
processor.process(requests.peek());
return --remaining;
} | java | public int completed(InetAddress request)
{
String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(request);
Queue<InetAddress> requests = requestsByDatacenter.get(dc);
assert requests != null;
assert request.equals(requests.peek());
requests.poll();
if (!requests.isEmpty())
processor.process(requests.peek());
return --remaining;
} | [
"public",
"int",
"completed",
"(",
"InetAddress",
"request",
")",
"{",
"String",
"dc",
"=",
"DatabaseDescriptor",
".",
"getEndpointSnitch",
"(",
")",
".",
"getDatacenter",
"(",
"request",
")",
";",
"Queue",
"<",
"InetAddress",
">",
"requests",
"=",
"requestsBy... | Returns how many request remains | [
"Returns",
"how",
"many",
"request",
"remains"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/DatacenterAwareRequestCoordinator.java#L62-L72 |
36,034 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/auth/DataResource.java | DataResource.fromName | public static DataResource fromName(String name)
{
String[] parts = StringUtils.split(name, '/');
if (!parts[0].equals(ROOT_NAME) || parts.length > 3)
throw new IllegalArgumentException(String.format("%s is not a valid data resource name", name));
if (parts.length == 1)
return root();
if (parts.length == 2)
return keyspace(parts[1]);
return columnFamily(parts[1], parts[2]);
} | java | public static DataResource fromName(String name)
{
String[] parts = StringUtils.split(name, '/');
if (!parts[0].equals(ROOT_NAME) || parts.length > 3)
throw new IllegalArgumentException(String.format("%s is not a valid data resource name", name));
if (parts.length == 1)
return root();
if (parts.length == 2)
return keyspace(parts[1]);
return columnFamily(parts[1], parts[2]);
} | [
"public",
"static",
"DataResource",
"fromName",
"(",
"String",
"name",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"StringUtils",
".",
"split",
"(",
"name",
",",
"'",
"'",
")",
";",
"if",
"(",
"!",
"parts",
"[",
"0",
"]",
".",
"equals",
"(",
"ROOT_... | Parses a data resource name into a DataResource instance.
@param name Name of the data resource.
@return DataResource instance matching the name. | [
"Parses",
"a",
"data",
"resource",
"name",
"into",
"a",
"DataResource",
"instance",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/auth/DataResource.java#L105-L119 |
36,035 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java | ColumnFamilyMetrics.createColumnFamilyGauge | protected <T extends Number> Gauge<T> createColumnFamilyGauge(final String name, Gauge<T> gauge)
{
return createColumnFamilyGauge(name, gauge, new Gauge<Long>()
{
public Long value()
{
long total = 0;
for (Metric cfGauge : allColumnFamilyMetrics.get(name))
{
total = total + ((Gauge<? extends Number>) cfGauge).value().longValue();
}
return total;
}
});
} | java | protected <T extends Number> Gauge<T> createColumnFamilyGauge(final String name, Gauge<T> gauge)
{
return createColumnFamilyGauge(name, gauge, new Gauge<Long>()
{
public Long value()
{
long total = 0;
for (Metric cfGauge : allColumnFamilyMetrics.get(name))
{
total = total + ((Gauge<? extends Number>) cfGauge).value().longValue();
}
return total;
}
});
} | [
"protected",
"<",
"T",
"extends",
"Number",
">",
"Gauge",
"<",
"T",
">",
"createColumnFamilyGauge",
"(",
"final",
"String",
"name",
",",
"Gauge",
"<",
"T",
">",
"gauge",
")",
"{",
"return",
"createColumnFamilyGauge",
"(",
"name",
",",
"gauge",
",",
"new",
... | Create a gauge that will be part of a merged version of all column families. The global gauge
will merge each CF gauge by adding their values | [
"Create",
"a",
"gauge",
"that",
"will",
"be",
"part",
"of",
"a",
"merged",
"version",
"of",
"all",
"column",
"families",
".",
"The",
"global",
"gauge",
"will",
"merge",
"each",
"CF",
"gauge",
"by",
"adding",
"their",
"values"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java#L639-L653 |
36,036 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java | ColumnFamilyMetrics.createColumnFamilyGauge | protected <G,T> Gauge<T> createColumnFamilyGauge(String name, Gauge<T> gauge, Gauge<G> globalGauge)
{
Gauge<T> cfGauge = Metrics.newGauge(factory.createMetricName(name), gauge);
if (register(name, cfGauge))
{
Metrics.newGauge(globalNameFactory.createMetricName(name), globalGauge);
}
return cfGauge;
} | java | protected <G,T> Gauge<T> createColumnFamilyGauge(String name, Gauge<T> gauge, Gauge<G> globalGauge)
{
Gauge<T> cfGauge = Metrics.newGauge(factory.createMetricName(name), gauge);
if (register(name, cfGauge))
{
Metrics.newGauge(globalNameFactory.createMetricName(name), globalGauge);
}
return cfGauge;
} | [
"protected",
"<",
"G",
",",
"T",
">",
"Gauge",
"<",
"T",
">",
"createColumnFamilyGauge",
"(",
"String",
"name",
",",
"Gauge",
"<",
"T",
">",
"gauge",
",",
"Gauge",
"<",
"G",
">",
"globalGauge",
")",
"{",
"Gauge",
"<",
"T",
">",
"cfGauge",
"=",
"Met... | Create a gauge that will be part of a merged version of all column families. The global gauge
is defined as the globalGauge parameter | [
"Create",
"a",
"gauge",
"that",
"will",
"be",
"part",
"of",
"a",
"merged",
"version",
"of",
"all",
"column",
"families",
".",
"The",
"global",
"gauge",
"is",
"defined",
"as",
"the",
"globalGauge",
"parameter"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java#L659-L667 |
36,037 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java | ColumnFamilyMetrics.createColumnFamilyCounter | protected Counter createColumnFamilyCounter(final String name)
{
Counter cfCounter = Metrics.newCounter(factory.createMetricName(name));
if (register(name, cfCounter))
{
Metrics.newGauge(globalNameFactory.createMetricName(name), new Gauge<Long>()
{
public Long value()
{
long total = 0;
for (Metric cfGauge : allColumnFamilyMetrics.get(name))
{
total += ((Counter) cfGauge).count();
}
return total;
}
});
}
return cfCounter;
} | java | protected Counter createColumnFamilyCounter(final String name)
{
Counter cfCounter = Metrics.newCounter(factory.createMetricName(name));
if (register(name, cfCounter))
{
Metrics.newGauge(globalNameFactory.createMetricName(name), new Gauge<Long>()
{
public Long value()
{
long total = 0;
for (Metric cfGauge : allColumnFamilyMetrics.get(name))
{
total += ((Counter) cfGauge).count();
}
return total;
}
});
}
return cfCounter;
} | [
"protected",
"Counter",
"createColumnFamilyCounter",
"(",
"final",
"String",
"name",
")",
"{",
"Counter",
"cfCounter",
"=",
"Metrics",
".",
"newCounter",
"(",
"factory",
".",
"createMetricName",
"(",
"name",
")",
")",
";",
"if",
"(",
"register",
"(",
"name",
... | Creates a counter that will also have a global counter thats the sum of all counters across
different column families | [
"Creates",
"a",
"counter",
"that",
"will",
"also",
"have",
"a",
"global",
"counter",
"thats",
"the",
"sum",
"of",
"all",
"counters",
"across",
"different",
"column",
"families"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java#L673-L692 |
36,038 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java | ColumnFamilyMetrics.createColumnFamilyHistogram | protected ColumnFamilyHistogram createColumnFamilyHistogram(String name, Histogram keyspaceHistogram)
{
Histogram cfHistogram = Metrics.newHistogram(factory.createMetricName(name), true);
register(name, cfHistogram);
return new ColumnFamilyHistogram(cfHistogram, keyspaceHistogram, Metrics.newHistogram(globalNameFactory.createMetricName(name), true));
} | java | protected ColumnFamilyHistogram createColumnFamilyHistogram(String name, Histogram keyspaceHistogram)
{
Histogram cfHistogram = Metrics.newHistogram(factory.createMetricName(name), true);
register(name, cfHistogram);
return new ColumnFamilyHistogram(cfHistogram, keyspaceHistogram, Metrics.newHistogram(globalNameFactory.createMetricName(name), true));
} | [
"protected",
"ColumnFamilyHistogram",
"createColumnFamilyHistogram",
"(",
"String",
"name",
",",
"Histogram",
"keyspaceHistogram",
")",
"{",
"Histogram",
"cfHistogram",
"=",
"Metrics",
".",
"newHistogram",
"(",
"factory",
".",
"createMetricName",
"(",
"name",
")",
","... | Create a histogram-like interface that will register both a CF, keyspace and global level
histogram and forward any updates to both | [
"Create",
"a",
"histogram",
"-",
"like",
"interface",
"that",
"will",
"register",
"both",
"a",
"CF",
"keyspace",
"and",
"global",
"level",
"histogram",
"and",
"forward",
"any",
"updates",
"to",
"both"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java#L698-L703 |
36,039 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java | ColumnFamilyMetrics.register | private boolean register(String name, Metric metric)
{
boolean ret = allColumnFamilyMetrics.putIfAbsent(name, new HashSet<Metric>()) == null;
allColumnFamilyMetrics.get(name).add(metric);
all.add(name);
return ret;
} | java | private boolean register(String name, Metric metric)
{
boolean ret = allColumnFamilyMetrics.putIfAbsent(name, new HashSet<Metric>()) == null;
allColumnFamilyMetrics.get(name).add(metric);
all.add(name);
return ret;
} | [
"private",
"boolean",
"register",
"(",
"String",
"name",
",",
"Metric",
"metric",
")",
"{",
"boolean",
"ret",
"=",
"allColumnFamilyMetrics",
".",
"putIfAbsent",
"(",
"name",
",",
"new",
"HashSet",
"<",
"Metric",
">",
"(",
")",
")",
"==",
"null",
";",
"al... | Registers a metric to be removed when unloading CF.
@return true if first time metric with that name has been registered | [
"Registers",
"a",
"metric",
"to",
"be",
"removed",
"when",
"unloading",
"CF",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java#L709-L715 |
36,040 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/ConfigHelper.java | ConfigHelper.setOutputKeyspace | public static void setOutputKeyspace(Configuration conf, String keyspace)
{
if (keyspace == null)
throw new UnsupportedOperationException("keyspace may not be null");
conf.set(OUTPUT_KEYSPACE_CONFIG, keyspace);
} | java | public static void setOutputKeyspace(Configuration conf, String keyspace)
{
if (keyspace == null)
throw new UnsupportedOperationException("keyspace may not be null");
conf.set(OUTPUT_KEYSPACE_CONFIG, keyspace);
} | [
"public",
"static",
"void",
"setOutputKeyspace",
"(",
"Configuration",
"conf",
",",
"String",
"keyspace",
")",
"{",
"if",
"(",
"keyspace",
"==",
"null",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"keyspace may not be null\"",
")",
";",
"conf",
".... | Set the keyspace for the output of this job.
@param conf Job configuration you are about to run
@param keyspace | [
"Set",
"the",
"keyspace",
"for",
"the",
"output",
"of",
"this",
"job",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/ConfigHelper.java#L114-L120 |
36,041 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/ConfigHelper.java | ConfigHelper.setOutputColumnFamily | public static void setOutputColumnFamily(Configuration conf, String keyspace, String columnFamily)
{
setOutputKeyspace(conf, keyspace);
setOutputColumnFamily(conf, columnFamily);
} | java | public static void setOutputColumnFamily(Configuration conf, String keyspace, String columnFamily)
{
setOutputKeyspace(conf, keyspace);
setOutputColumnFamily(conf, columnFamily);
} | [
"public",
"static",
"void",
"setOutputColumnFamily",
"(",
"Configuration",
"conf",
",",
"String",
"keyspace",
",",
"String",
"columnFamily",
")",
"{",
"setOutputKeyspace",
"(",
"conf",
",",
"keyspace",
")",
";",
"setOutputColumnFamily",
"(",
"conf",
",",
"columnFa... | Set the column family for the output of this job.
@param conf Job configuration you are about to run
@param keyspace
@param columnFamily | [
"Set",
"the",
"column",
"family",
"for",
"the",
"output",
"of",
"this",
"job",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/ConfigHelper.java#L140-L144 |
36,042 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/ConfigHelper.java | ConfigHelper.setInputSlicePredicate | public static void setInputSlicePredicate(Configuration conf, SlicePredicate predicate)
{
conf.set(INPUT_PREDICATE_CONFIG, thriftToString(predicate));
} | java | public static void setInputSlicePredicate(Configuration conf, SlicePredicate predicate)
{
conf.set(INPUT_PREDICATE_CONFIG, thriftToString(predicate));
} | [
"public",
"static",
"void",
"setInputSlicePredicate",
"(",
"Configuration",
"conf",
",",
"SlicePredicate",
"predicate",
")",
"{",
"conf",
".",
"set",
"(",
"INPUT_PREDICATE_CONFIG",
",",
"thriftToString",
"(",
"predicate",
")",
")",
";",
"}"
] | Set the predicate that determines what columns will be selected from each row.
@param conf Job configuration you are about to run
@param predicate | [
"Set",
"the",
"predicate",
"that",
"determines",
"what",
"columns",
"will",
"be",
"selected",
"from",
"each",
"row",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/ConfigHelper.java#L198-L201 |
36,043 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/ConfigHelper.java | ConfigHelper.getInputKeyRange | public static KeyRange getInputKeyRange(Configuration conf)
{
String str = conf.get(INPUT_KEYRANGE_CONFIG);
return str == null ? null : keyRangeFromString(str);
} | java | public static KeyRange getInputKeyRange(Configuration conf)
{
String str = conf.get(INPUT_KEYRANGE_CONFIG);
return str == null ? null : keyRangeFromString(str);
} | [
"public",
"static",
"KeyRange",
"getInputKeyRange",
"(",
"Configuration",
"conf",
")",
"{",
"String",
"str",
"=",
"conf",
".",
"get",
"(",
"INPUT_KEYRANGE_CONFIG",
")",
";",
"return",
"str",
"==",
"null",
"?",
"null",
":",
"keyRangeFromString",
"(",
"str",
"... | may be null if unset | [
"may",
"be",
"null",
"if",
"unset"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/ConfigHelper.java#L271-L275 |
36,044 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/AtomDeserializer.java | AtomDeserializer.readNext | public OnDiskAtom readNext() throws IOException
{
Composite name = nameDeserializer.readNext();
assert !name.isEmpty(); // This would imply hasNext() hasn't been called
nextFlags = nextFlags == Integer.MIN_VALUE ? in.readUnsignedByte() : nextFlags;
OnDiskAtom atom = (nextFlags & ColumnSerializer.RANGE_TOMBSTONE_MASK) != 0
? type.rangeTombstoneSerializer().deserializeBody(in, name, version)
: type.columnSerializer().deserializeColumnBody(in, (CellName)name, nextFlags, flag, expireBefore);
nextFlags = Integer.MIN_VALUE;
return atom;
} | java | public OnDiskAtom readNext() throws IOException
{
Composite name = nameDeserializer.readNext();
assert !name.isEmpty(); // This would imply hasNext() hasn't been called
nextFlags = nextFlags == Integer.MIN_VALUE ? in.readUnsignedByte() : nextFlags;
OnDiskAtom atom = (nextFlags & ColumnSerializer.RANGE_TOMBSTONE_MASK) != 0
? type.rangeTombstoneSerializer().deserializeBody(in, name, version)
: type.columnSerializer().deserializeColumnBody(in, (CellName)name, nextFlags, flag, expireBefore);
nextFlags = Integer.MIN_VALUE;
return atom;
} | [
"public",
"OnDiskAtom",
"readNext",
"(",
")",
"throws",
"IOException",
"{",
"Composite",
"name",
"=",
"nameDeserializer",
".",
"readNext",
"(",
")",
";",
"assert",
"!",
"name",
".",
"isEmpty",
"(",
")",
";",
"// This would imply hasNext() hasn't been called",
"nex... | Returns the next atom. | [
"Returns",
"the",
"next",
"atom",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/AtomDeserializer.java#L102-L113 |
36,045 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/AtomDeserializer.java | AtomDeserializer.skipNext | public void skipNext() throws IOException
{
nameDeserializer.skipNext();
nextFlags = nextFlags == Integer.MIN_VALUE ? in.readUnsignedByte() : nextFlags;
if ((nextFlags & ColumnSerializer.RANGE_TOMBSTONE_MASK) != 0)
type.rangeTombstoneSerializer().skipBody(in, version);
else
type.columnSerializer().skipColumnBody(in, nextFlags);
nextFlags = Integer.MIN_VALUE;
} | java | public void skipNext() throws IOException
{
nameDeserializer.skipNext();
nextFlags = nextFlags == Integer.MIN_VALUE ? in.readUnsignedByte() : nextFlags;
if ((nextFlags & ColumnSerializer.RANGE_TOMBSTONE_MASK) != 0)
type.rangeTombstoneSerializer().skipBody(in, version);
else
type.columnSerializer().skipColumnBody(in, nextFlags);
nextFlags = Integer.MIN_VALUE;
} | [
"public",
"void",
"skipNext",
"(",
")",
"throws",
"IOException",
"{",
"nameDeserializer",
".",
"skipNext",
"(",
")",
";",
"nextFlags",
"=",
"nextFlags",
"==",
"Integer",
".",
"MIN_VALUE",
"?",
"in",
".",
"readUnsignedByte",
"(",
")",
":",
"nextFlags",
";",
... | Skips the next atom. | [
"Skips",
"the",
"next",
"atom",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/AtomDeserializer.java#L118-L127 |
36,046 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/thrift/ThriftSessionManager.java | ThriftSessionManager.connectionComplete | public void connectionComplete(SocketAddress socket)
{
assert socket != null;
activeSocketSessions.remove(socket);
if (logger.isTraceEnabled())
logger.trace("ClientState removed for socket addr {}", socket);
} | java | public void connectionComplete(SocketAddress socket)
{
assert socket != null;
activeSocketSessions.remove(socket);
if (logger.isTraceEnabled())
logger.trace("ClientState removed for socket addr {}", socket);
} | [
"public",
"void",
"connectionComplete",
"(",
"SocketAddress",
"socket",
")",
"{",
"assert",
"socket",
"!=",
"null",
";",
"activeSocketSessions",
".",
"remove",
"(",
"socket",
")",
";",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"logger",
".",... | The connection associated with @param socket is permanently finished. | [
"The",
"connection",
"associated",
"with"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/thrift/ThriftSessionManager.java#L69-L75 |
36,047 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/RowService.java | RowService.delete | public void delete(final DecoratedKey partitionKey) {
if (indexQueue == null) {
deleteInner(partitionKey);
} else {
indexQueue.submitAsynchronous(partitionKey, new Runnable() {
@Override
public void run() {
deleteInner(partitionKey);
}
});
}
} | java | public void delete(final DecoratedKey partitionKey) {
if (indexQueue == null) {
deleteInner(partitionKey);
} else {
indexQueue.submitAsynchronous(partitionKey, new Runnable() {
@Override
public void run() {
deleteInner(partitionKey);
}
});
}
} | [
"public",
"void",
"delete",
"(",
"final",
"DecoratedKey",
"partitionKey",
")",
"{",
"if",
"(",
"indexQueue",
"==",
"null",
")",
"{",
"deleteInner",
"(",
"partitionKey",
")",
";",
"}",
"else",
"{",
"indexQueue",
".",
"submitAsynchronous",
"(",
"partitionKey",
... | Deletes the partition identified by the specified partition key. This operation is performed asynchronously.
@param partitionKey The partition key identifying the partition to be deleted. | [
"Deletes",
"the",
"partition",
"identified",
"by",
"the",
"specified",
"partition",
"key",
".",
"This",
"operation",
"is",
"performed",
"asynchronously",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/RowService.java#L165-L176 |
36,048 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/RowService.java | RowService.commit | public final void commit() {
if (indexQueue == null) {
luceneIndex.commit();
} else {
indexQueue.submitSynchronous(new Runnable() {
@Override
public void run() {
luceneIndex.commit();
}
});
}
} | java | public final void commit() {
if (indexQueue == null) {
luceneIndex.commit();
} else {
indexQueue.submitSynchronous(new Runnable() {
@Override
public void run() {
luceneIndex.commit();
}
});
}
} | [
"public",
"final",
"void",
"commit",
"(",
")",
"{",
"if",
"(",
"indexQueue",
"==",
"null",
")",
"{",
"luceneIndex",
".",
"commit",
"(",
")",
";",
"}",
"else",
"{",
"indexQueue",
".",
"submitSynchronous",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"O... | Commits the pending changes. This operation is performed asynchronously. | [
"Commits",
"the",
"pending",
"changes",
".",
"This",
"operation",
"is",
"performed",
"asynchronously",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/RowService.java#L203-L214 |
36,049 | Stratio/stratio-cassandra | tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java | GroupedOptions.printOptions | public static void printOptions(PrintStream out, String command, GroupedOptions... groupings)
{
out.println();
boolean firstRow = true;
for (GroupedOptions grouping : groupings)
{
if (!firstRow)
{
out.println(" OR ");
}
firstRow = false;
StringBuilder sb = new StringBuilder("Usage: " + command);
for (Option option : grouping.options())
{
sb.append(" ");
sb.append(option.shortDisplay());
}
out.println(sb.toString());
}
out.println();
final Set<Option> printed = new HashSet<>();
for (GroupedOptions grouping : groupings)
{
for (Option option : grouping.options())
{
if (printed.add(option))
{
if (option.longDisplay() != null)
{
out.println(" " + option.longDisplay());
for (String row : option.multiLineDisplay())
out.println(" " + row);
}
}
}
}
} | java | public static void printOptions(PrintStream out, String command, GroupedOptions... groupings)
{
out.println();
boolean firstRow = true;
for (GroupedOptions grouping : groupings)
{
if (!firstRow)
{
out.println(" OR ");
}
firstRow = false;
StringBuilder sb = new StringBuilder("Usage: " + command);
for (Option option : grouping.options())
{
sb.append(" ");
sb.append(option.shortDisplay());
}
out.println(sb.toString());
}
out.println();
final Set<Option> printed = new HashSet<>();
for (GroupedOptions grouping : groupings)
{
for (Option option : grouping.options())
{
if (printed.add(option))
{
if (option.longDisplay() != null)
{
out.println(" " + option.longDisplay());
for (String row : option.multiLineDisplay())
out.println(" " + row);
}
}
}
}
} | [
"public",
"static",
"void",
"printOptions",
"(",
"PrintStream",
"out",
",",
"String",
"command",
",",
"GroupedOptions",
"...",
"groupings",
")",
"{",
"out",
".",
"println",
"(",
")",
";",
"boolean",
"firstRow",
"=",
"true",
";",
"for",
"(",
"GroupedOptions",... | pretty prints all of the option groupings | [
"pretty",
"prints",
"all",
"of",
"the",
"option",
"groupings"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java#L78-L115 |
36,050 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/streaming/messages/StreamInitMessage.java | StreamInitMessage.createMessage | public ByteBuffer createMessage(boolean compress, int version)
{
int header = 0;
// set compression bit.
if (compress)
header |= 4;
// set streaming bit
header |= 8;
// Setting up the version bit
header |= (version << 8);
byte[] bytes;
try
{
int size = (int)StreamInitMessage.serializer.serializedSize(this, version);
DataOutputBuffer buffer = new DataOutputBuffer(size);
StreamInitMessage.serializer.serialize(this, buffer, version);
bytes = buffer.getData();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
assert bytes.length > 0;
ByteBuffer buffer = ByteBuffer.allocate(4 + 4 + bytes.length);
buffer.putInt(MessagingService.PROTOCOL_MAGIC);
buffer.putInt(header);
buffer.put(bytes);
buffer.flip();
return buffer;
} | java | public ByteBuffer createMessage(boolean compress, int version)
{
int header = 0;
// set compression bit.
if (compress)
header |= 4;
// set streaming bit
header |= 8;
// Setting up the version bit
header |= (version << 8);
byte[] bytes;
try
{
int size = (int)StreamInitMessage.serializer.serializedSize(this, version);
DataOutputBuffer buffer = new DataOutputBuffer(size);
StreamInitMessage.serializer.serialize(this, buffer, version);
bytes = buffer.getData();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
assert bytes.length > 0;
ByteBuffer buffer = ByteBuffer.allocate(4 + 4 + bytes.length);
buffer.putInt(MessagingService.PROTOCOL_MAGIC);
buffer.putInt(header);
buffer.put(bytes);
buffer.flip();
return buffer;
} | [
"public",
"ByteBuffer",
"createMessage",
"(",
"boolean",
"compress",
",",
"int",
"version",
")",
"{",
"int",
"header",
"=",
"0",
";",
"// set compression bit.",
"if",
"(",
"compress",
")",
"header",
"|=",
"4",
";",
"// set streaming bit",
"header",
"|=",
"8",
... | Create serialized message.
@param compress true if message is compressed
@param version Streaming protocol version
@return serialized message in ByteBuffer format | [
"Create",
"serialized",
"message",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/streaming/messages/StreamInitMessage.java#L66-L97 |
36,051 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java | SSTableRewriter.tryAppend | public RowIndexEntry tryAppend(AbstractCompactedRow row)
{
writer.mark();
try
{
return append(row);
}
catch (Throwable t)
{
writer.resetAndTruncate();
throw t;
}
} | java | public RowIndexEntry tryAppend(AbstractCompactedRow row)
{
writer.mark();
try
{
return append(row);
}
catch (Throwable t)
{
writer.resetAndTruncate();
throw t;
}
} | [
"public",
"RowIndexEntry",
"tryAppend",
"(",
"AbstractCompactedRow",
"row",
")",
"{",
"writer",
".",
"mark",
"(",
")",
";",
"try",
"{",
"return",
"append",
"(",
"row",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"writer",
".",
"resetAndTrunc... | attempts to append the row, if fails resets the writer position | [
"attempts",
"to",
"append",
"the",
"row",
"if",
"fails",
"resets",
"the",
"writer",
"position"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java#L146-L158 |
36,052 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java | SSTableRewriter.moveStarts | private void moveStarts(SSTableReader newReader, DecoratedKey lowerbound, boolean reset)
{
if (isOffline)
return;
List<SSTableReader> toReplace = new ArrayList<>();
List<SSTableReader> replaceWith = new ArrayList<>();
final List<DecoratedKey> invalidateKeys = new ArrayList<>();
if (!reset)
{
invalidateKeys.addAll(cachedKeys.keySet());
for (Map.Entry<DecoratedKey, RowIndexEntry> cacheKey : cachedKeys.entrySet())
newReader.cacheKey(cacheKey.getKey(), cacheKey.getValue());
}
cachedKeys = new HashMap<>();
for (SSTableReader sstable : ImmutableList.copyOf(rewriting))
{
// we call getCurrentReplacement() to support multiple rewriters operating over the same source readers at once.
// note: only one such writer should be written to at any moment
final SSTableReader latest = sstable.getCurrentReplacement();
SSTableReader replacement;
if (reset)
{
DecoratedKey newStart = originalStarts.get(sstable.descriptor);
replacement = latest.cloneWithNewStart(newStart, null);
}
else
{
// skip any sstables that we know to already be shadowed
if (latest.openReason == SSTableReader.OpenReason.SHADOWED)
continue;
if (latest.first.compareTo(lowerbound) > 0)
continue;
final Runnable runOnClose = new Runnable()
{
public void run()
{
// this is somewhat racey, in that we could theoretically be closing this old reader
// when an even older reader is still in use, but it's not likely to have any major impact
for (DecoratedKey key : invalidateKeys)
latest.invalidateCacheKey(key);
}
};
if (lowerbound.compareTo(latest.last) >= 0)
{
replacement = latest.cloneAsShadowed(runOnClose);
}
else
{
DecoratedKey newStart = latest.firstKeyBeyond(lowerbound);
assert newStart != null;
replacement = latest.cloneWithNewStart(newStart, runOnClose);
}
}
toReplace.add(latest);
replaceWith.add(replacement);
rewriting.remove(sstable);
rewriting.add(replacement);
}
cfs.getDataTracker().replaceWithNewInstances(toReplace, replaceWith);
} | java | private void moveStarts(SSTableReader newReader, DecoratedKey lowerbound, boolean reset)
{
if (isOffline)
return;
List<SSTableReader> toReplace = new ArrayList<>();
List<SSTableReader> replaceWith = new ArrayList<>();
final List<DecoratedKey> invalidateKeys = new ArrayList<>();
if (!reset)
{
invalidateKeys.addAll(cachedKeys.keySet());
for (Map.Entry<DecoratedKey, RowIndexEntry> cacheKey : cachedKeys.entrySet())
newReader.cacheKey(cacheKey.getKey(), cacheKey.getValue());
}
cachedKeys = new HashMap<>();
for (SSTableReader sstable : ImmutableList.copyOf(rewriting))
{
// we call getCurrentReplacement() to support multiple rewriters operating over the same source readers at once.
// note: only one such writer should be written to at any moment
final SSTableReader latest = sstable.getCurrentReplacement();
SSTableReader replacement;
if (reset)
{
DecoratedKey newStart = originalStarts.get(sstable.descriptor);
replacement = latest.cloneWithNewStart(newStart, null);
}
else
{
// skip any sstables that we know to already be shadowed
if (latest.openReason == SSTableReader.OpenReason.SHADOWED)
continue;
if (latest.first.compareTo(lowerbound) > 0)
continue;
final Runnable runOnClose = new Runnable()
{
public void run()
{
// this is somewhat racey, in that we could theoretically be closing this old reader
// when an even older reader is still in use, but it's not likely to have any major impact
for (DecoratedKey key : invalidateKeys)
latest.invalidateCacheKey(key);
}
};
if (lowerbound.compareTo(latest.last) >= 0)
{
replacement = latest.cloneAsShadowed(runOnClose);
}
else
{
DecoratedKey newStart = latest.firstKeyBeyond(lowerbound);
assert newStart != null;
replacement = latest.cloneWithNewStart(newStart, runOnClose);
}
}
toReplace.add(latest);
replaceWith.add(replacement);
rewriting.remove(sstable);
rewriting.add(replacement);
}
cfs.getDataTracker().replaceWithNewInstances(toReplace, replaceWith);
} | [
"private",
"void",
"moveStarts",
"(",
"SSTableReader",
"newReader",
",",
"DecoratedKey",
"lowerbound",
",",
"boolean",
"reset",
")",
"{",
"if",
"(",
"isOffline",
")",
"return",
";",
"List",
"<",
"SSTableReader",
">",
"toReplace",
"=",
"new",
"ArrayList",
"<>",... | Replace the readers we are rewriting with cloneWithNewStart, reclaiming any page cache that is no longer
needed, and transferring any key cache entries over to the new reader, expiring them from the old. if reset
is true, we are instead restoring the starts of the readers from before the rewriting began
note that we replace an existing sstable with a new *instance* of the same sstable, the replacement
sstable .equals() the old one, BUT, it is a new instance, so, for example, since we releaseReference() on the old
one, the old *instance* will have reference count == 0 and if we were to start a new compaction with that old
instance, we would get exceptions.
@param newReader the rewritten reader that replaces them for this region
@param lowerbound if !reset, must be non-null, and marks the exclusive lowerbound of the start for each sstable
@param reset true iff we are restoring earlier starts (increasing the range over which they are valid) | [
"Replace",
"the",
"readers",
"we",
"are",
"rewriting",
"with",
"cloneWithNewStart",
"reclaiming",
"any",
"page",
"cache",
"that",
"is",
"no",
"longer",
"needed",
"and",
"transferring",
"any",
"key",
"cache",
"entries",
"over",
"to",
"the",
"new",
"reader",
"ex... | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java#L277-L340 |
36,053 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java | SSTableRewriter.replaceWithFinishedReaders | private void replaceWithFinishedReaders(List<SSTableReader> finished)
{
if (isOffline)
{
for (SSTableReader reader : discard)
{
if (reader.getCurrentReplacement() == reader)
reader.markObsolete();
reader.selfRef().release();
}
}
else
{
dataTracker.replaceEarlyOpenedFiles(discard, finished);
dataTracker.unmarkCompacting(discard);
}
discard.clear();
} | java | private void replaceWithFinishedReaders(List<SSTableReader> finished)
{
if (isOffline)
{
for (SSTableReader reader : discard)
{
if (reader.getCurrentReplacement() == reader)
reader.markObsolete();
reader.selfRef().release();
}
}
else
{
dataTracker.replaceEarlyOpenedFiles(discard, finished);
dataTracker.unmarkCompacting(discard);
}
discard.clear();
} | [
"private",
"void",
"replaceWithFinishedReaders",
"(",
"List",
"<",
"SSTableReader",
">",
"finished",
")",
"{",
"if",
"(",
"isOffline",
")",
"{",
"for",
"(",
"SSTableReader",
"reader",
":",
"discard",
")",
"{",
"if",
"(",
"reader",
".",
"getCurrentReplacement",... | cleanup all our temporary readers and swap in our new ones | [
"cleanup",
"all",
"our",
"temporary",
"readers",
"and",
"swap",
"in",
"our",
"new",
"ones"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java#L481-L498 |
36,054 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java | CQLSSTableWriter.rawAddRow | public CQLSSTableWriter rawAddRow(ByteBuffer... values)
throws InvalidRequestException, IOException
{
return rawAddRow(Arrays.asList(values));
} | java | public CQLSSTableWriter rawAddRow(ByteBuffer... values)
throws InvalidRequestException, IOException
{
return rawAddRow(Arrays.asList(values));
} | [
"public",
"CQLSSTableWriter",
"rawAddRow",
"(",
"ByteBuffer",
"...",
"values",
")",
"throws",
"InvalidRequestException",
",",
"IOException",
"{",
"return",
"rawAddRow",
"(",
"Arrays",
".",
"asList",
"(",
"values",
")",
")",
";",
"}"
] | Adds a new row to the writer given already serialized values.
@param values the row values (corresponding to the bind variables of the
insertion statement used when creating by this writer) as binary.
@return this writer. | [
"Adds",
"a",
"new",
"row",
"to",
"the",
"writer",
"given",
"already",
"serialized",
"values",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java#L186-L190 |
36,055 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/service/PendingRangeCalculatorService.java | PendingRangeCalculatorService.calculatePendingRanges | public static void calculatePendingRanges(AbstractReplicationStrategy strategy, String keyspaceName)
{
TokenMetadata tm = StorageService.instance.getTokenMetadata();
Multimap<Range<Token>, InetAddress> pendingRanges = HashMultimap.create();
BiMultiValMap<Token, InetAddress> bootstrapTokens = tm.getBootstrapTokens();
Set<InetAddress> leavingEndpoints = tm.getLeavingEndpoints();
if (bootstrapTokens.isEmpty() && leavingEndpoints.isEmpty() && tm.getMovingEndpoints().isEmpty())
{
if (logger.isDebugEnabled())
logger.debug("No bootstrapping, leaving or moving nodes, and no relocating tokens -> empty pending ranges for {}", keyspaceName);
tm.setPendingRanges(keyspaceName, pendingRanges);
return;
}
Multimap<InetAddress, Range<Token>> addressRanges = strategy.getAddressRanges();
// Copy of metadata reflecting the situation after all leave operations are finished.
TokenMetadata allLeftMetadata = tm.cloneAfterAllLeft();
// get all ranges that will be affected by leaving nodes
Set<Range<Token>> affectedRanges = new HashSet<Range<Token>>();
for (InetAddress endpoint : leavingEndpoints)
affectedRanges.addAll(addressRanges.get(endpoint));
// for each of those ranges, find what new nodes will be responsible for the range when
// all leaving nodes are gone.
TokenMetadata metadata = tm.cloneOnlyTokenMap(); // don't do this in the loop! #7758
for (Range<Token> range : affectedRanges)
{
Set<InetAddress> currentEndpoints = ImmutableSet.copyOf(strategy.calculateNaturalEndpoints(range.right, metadata));
Set<InetAddress> newEndpoints = ImmutableSet.copyOf(strategy.calculateNaturalEndpoints(range.right, allLeftMetadata));
pendingRanges.putAll(range, Sets.difference(newEndpoints, currentEndpoints));
}
// At this stage pendingRanges has been updated according to leave operations. We can
// now continue the calculation by checking bootstrapping nodes.
// For each of the bootstrapping nodes, simply add and remove them one by one to
// allLeftMetadata and check in between what their ranges would be.
Multimap<InetAddress, Token> bootstrapAddresses = bootstrapTokens.inverse();
for (InetAddress endpoint : bootstrapAddresses.keySet())
{
Collection<Token> tokens = bootstrapAddresses.get(endpoint);
allLeftMetadata.updateNormalTokens(tokens, endpoint);
for (Range<Token> range : strategy.getAddressRanges(allLeftMetadata).get(endpoint))
pendingRanges.put(range, endpoint);
allLeftMetadata.removeEndpoint(endpoint);
}
// At this stage pendingRanges has been updated according to leaving and bootstrapping nodes.
// We can now finish the calculation by checking moving and relocating nodes.
// For each of the moving nodes, we do the same thing we did for bootstrapping:
// simply add and remove them one by one to allLeftMetadata and check in between what their ranges would be.
for (Pair<Token, InetAddress> moving : tm.getMovingEndpoints())
{
InetAddress endpoint = moving.right; // address of the moving node
// moving.left is a new token of the endpoint
allLeftMetadata.updateNormalToken(moving.left, endpoint);
for (Range<Token> range : strategy.getAddressRanges(allLeftMetadata).get(endpoint))
{
pendingRanges.put(range, endpoint);
}
allLeftMetadata.removeEndpoint(endpoint);
}
tm.setPendingRanges(keyspaceName, pendingRanges);
if (logger.isDebugEnabled())
logger.debug("Pending ranges:\n" + (pendingRanges.isEmpty() ? "<empty>" : tm.printPendingRanges()));
} | java | public static void calculatePendingRanges(AbstractReplicationStrategy strategy, String keyspaceName)
{
TokenMetadata tm = StorageService.instance.getTokenMetadata();
Multimap<Range<Token>, InetAddress> pendingRanges = HashMultimap.create();
BiMultiValMap<Token, InetAddress> bootstrapTokens = tm.getBootstrapTokens();
Set<InetAddress> leavingEndpoints = tm.getLeavingEndpoints();
if (bootstrapTokens.isEmpty() && leavingEndpoints.isEmpty() && tm.getMovingEndpoints().isEmpty())
{
if (logger.isDebugEnabled())
logger.debug("No bootstrapping, leaving or moving nodes, and no relocating tokens -> empty pending ranges for {}", keyspaceName);
tm.setPendingRanges(keyspaceName, pendingRanges);
return;
}
Multimap<InetAddress, Range<Token>> addressRanges = strategy.getAddressRanges();
// Copy of metadata reflecting the situation after all leave operations are finished.
TokenMetadata allLeftMetadata = tm.cloneAfterAllLeft();
// get all ranges that will be affected by leaving nodes
Set<Range<Token>> affectedRanges = new HashSet<Range<Token>>();
for (InetAddress endpoint : leavingEndpoints)
affectedRanges.addAll(addressRanges.get(endpoint));
// for each of those ranges, find what new nodes will be responsible for the range when
// all leaving nodes are gone.
TokenMetadata metadata = tm.cloneOnlyTokenMap(); // don't do this in the loop! #7758
for (Range<Token> range : affectedRanges)
{
Set<InetAddress> currentEndpoints = ImmutableSet.copyOf(strategy.calculateNaturalEndpoints(range.right, metadata));
Set<InetAddress> newEndpoints = ImmutableSet.copyOf(strategy.calculateNaturalEndpoints(range.right, allLeftMetadata));
pendingRanges.putAll(range, Sets.difference(newEndpoints, currentEndpoints));
}
// At this stage pendingRanges has been updated according to leave operations. We can
// now continue the calculation by checking bootstrapping nodes.
// For each of the bootstrapping nodes, simply add and remove them one by one to
// allLeftMetadata and check in between what their ranges would be.
Multimap<InetAddress, Token> bootstrapAddresses = bootstrapTokens.inverse();
for (InetAddress endpoint : bootstrapAddresses.keySet())
{
Collection<Token> tokens = bootstrapAddresses.get(endpoint);
allLeftMetadata.updateNormalTokens(tokens, endpoint);
for (Range<Token> range : strategy.getAddressRanges(allLeftMetadata).get(endpoint))
pendingRanges.put(range, endpoint);
allLeftMetadata.removeEndpoint(endpoint);
}
// At this stage pendingRanges has been updated according to leaving and bootstrapping nodes.
// We can now finish the calculation by checking moving and relocating nodes.
// For each of the moving nodes, we do the same thing we did for bootstrapping:
// simply add and remove them one by one to allLeftMetadata and check in between what their ranges would be.
for (Pair<Token, InetAddress> moving : tm.getMovingEndpoints())
{
InetAddress endpoint = moving.right; // address of the moving node
// moving.left is a new token of the endpoint
allLeftMetadata.updateNormalToken(moving.left, endpoint);
for (Range<Token> range : strategy.getAddressRanges(allLeftMetadata).get(endpoint))
{
pendingRanges.put(range, endpoint);
}
allLeftMetadata.removeEndpoint(endpoint);
}
tm.setPendingRanges(keyspaceName, pendingRanges);
if (logger.isDebugEnabled())
logger.debug("Pending ranges:\n" + (pendingRanges.isEmpty() ? "<empty>" : tm.printPendingRanges()));
} | [
"public",
"static",
"void",
"calculatePendingRanges",
"(",
"AbstractReplicationStrategy",
"strategy",
",",
"String",
"keyspaceName",
")",
"{",
"TokenMetadata",
"tm",
"=",
"StorageService",
".",
"instance",
".",
"getTokenMetadata",
"(",
")",
";",
"Multimap",
"<",
"Ra... | public & static for testing purposes | [
"public",
"&",
"static",
"for",
"testing",
"purposes"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/service/PendingRangeCalculatorService.java#L118-L193 |
36,056 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java | YamlFileNetworkTopologySnitch.gossiperStarting | @Override
public synchronized void gossiperStarting()
{
gossiperInitialized = true;
StorageService.instance.gossipSnitchInfo();
Gossiper.instance.register(new ReconnectableSnitchHelper(this, localNodeData.datacenter, true));
} | java | @Override
public synchronized void gossiperStarting()
{
gossiperInitialized = true;
StorageService.instance.gossipSnitchInfo();
Gossiper.instance.register(new ReconnectableSnitchHelper(this, localNodeData.datacenter, true));
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"gossiperStarting",
"(",
")",
"{",
"gossiperInitialized",
"=",
"true",
";",
"StorageService",
".",
"instance",
".",
"gossipSnitchInfo",
"(",
")",
";",
"Gossiper",
".",
"instance",
".",
"register",
"(",
"new",
... | Called in preparation for the initiation of the gossip loop. | [
"Called",
"in",
"preparation",
"for",
"the",
"initiation",
"of",
"the",
"gossip",
"loop",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java#L407-L413 |
36,057 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/streaming/StreamTransferTask.java | StreamTransferTask.scheduleTimeout | public synchronized ScheduledFuture scheduleTimeout(final int sequenceNumber, long time, TimeUnit unit)
{
if (!files.containsKey(sequenceNumber))
return null;
ScheduledFuture future = timeoutExecutor.schedule(new Runnable()
{
public void run()
{
synchronized (StreamTransferTask.this)
{
// remove so we don't cancel ourselves
timeoutTasks.remove(sequenceNumber);
StreamTransferTask.this.complete(sequenceNumber);
}
}
}, time, unit);
ScheduledFuture prev = timeoutTasks.put(sequenceNumber, future);
assert prev == null;
return future;
} | java | public synchronized ScheduledFuture scheduleTimeout(final int sequenceNumber, long time, TimeUnit unit)
{
if (!files.containsKey(sequenceNumber))
return null;
ScheduledFuture future = timeoutExecutor.schedule(new Runnable()
{
public void run()
{
synchronized (StreamTransferTask.this)
{
// remove so we don't cancel ourselves
timeoutTasks.remove(sequenceNumber);
StreamTransferTask.this.complete(sequenceNumber);
}
}
}, time, unit);
ScheduledFuture prev = timeoutTasks.put(sequenceNumber, future);
assert prev == null;
return future;
} | [
"public",
"synchronized",
"ScheduledFuture",
"scheduleTimeout",
"(",
"final",
"int",
"sequenceNumber",
",",
"long",
"time",
",",
"TimeUnit",
"unit",
")",
"{",
"if",
"(",
"!",
"files",
".",
"containsKey",
"(",
"sequenceNumber",
")",
")",
"return",
"null",
";",
... | Schedule timeout task to release reference for file sent.
When not receiving ACK after sending to receiver in given time,
the task will release reference.
@param sequenceNumber sequence number of file sent.
@param time time to timeout
@param unit unit of given time
@return scheduled future for timeout task | [
"Schedule",
"timeout",
"task",
"to",
"release",
"reference",
"for",
"file",
"sent",
".",
"When",
"not",
"receiving",
"ACK",
"after",
"sending",
"to",
"receiver",
"in",
"given",
"time",
"the",
"task",
"will",
"release",
"reference",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/streaming/StreamTransferTask.java#L153-L174 |
36,058 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/RangeTombstoneList.java | RangeTombstoneList.add | public void add(Composite start, Composite end, long markedAt, int delTime)
{
if (isEmpty())
{
addInternal(0, start, end, markedAt, delTime);
return;
}
int c = comparator.compare(ends[size-1], start);
// Fast path if we add in sorted order
if (c <= 0)
{
addInternal(size, start, end, markedAt, delTime);
}
else
{
// Note: insertFrom expect i to be the insertion point in term of interval ends
int pos = Arrays.binarySearch(ends, 0, size, start, comparator);
insertFrom((pos >= 0 ? pos : -pos-1), start, end, markedAt, delTime);
}
boundaryHeapSize += start.unsharedHeapSize() + end.unsharedHeapSize();
} | java | public void add(Composite start, Composite end, long markedAt, int delTime)
{
if (isEmpty())
{
addInternal(0, start, end, markedAt, delTime);
return;
}
int c = comparator.compare(ends[size-1], start);
// Fast path if we add in sorted order
if (c <= 0)
{
addInternal(size, start, end, markedAt, delTime);
}
else
{
// Note: insertFrom expect i to be the insertion point in term of interval ends
int pos = Arrays.binarySearch(ends, 0, size, start, comparator);
insertFrom((pos >= 0 ? pos : -pos-1), start, end, markedAt, delTime);
}
boundaryHeapSize += start.unsharedHeapSize() + end.unsharedHeapSize();
} | [
"public",
"void",
"add",
"(",
"Composite",
"start",
",",
"Composite",
"end",
",",
"long",
"markedAt",
",",
"int",
"delTime",
")",
"{",
"if",
"(",
"isEmpty",
"(",
")",
")",
"{",
"addInternal",
"(",
"0",
",",
"start",
",",
"end",
",",
"markedAt",
",",
... | Adds a new range tombstone.
This method will be faster if the new tombstone sort after all the currently existing ones (this is a common use case),
but it doesn't assume it. | [
"Adds",
"a",
"new",
"range",
"tombstone",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/RangeTombstoneList.java#L152-L174 |
36,059 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/RangeTombstoneList.java | RangeTombstoneList.purge | public void purge(int gcBefore)
{
int j = 0;
for (int i = 0; i < size; i++)
{
if (delTimes[i] >= gcBefore)
setInternal(j++, starts[i], ends[i], markedAts[i], delTimes[i]);
}
size = j;
} | java | public void purge(int gcBefore)
{
int j = 0;
for (int i = 0; i < size; i++)
{
if (delTimes[i] >= gcBefore)
setInternal(j++, starts[i], ends[i], markedAts[i], delTimes[i]);
}
size = j;
} | [
"public",
"void",
"purge",
"(",
"int",
"gcBefore",
")",
"{",
"int",
"j",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"delTimes",
"[",
"i",
"]",
">=",
"gcBefore",
")",
"setIntern... | Removes all range tombstones whose local deletion time is older than gcBefore. | [
"Removes",
"all",
"range",
"tombstones",
"whose",
"local",
"deletion",
"time",
"is",
"older",
"than",
"gcBefore",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/RangeTombstoneList.java#L337-L346 |
36,060 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/RangeTombstoneList.java | RangeTombstoneList.updateDigest | public void updateDigest(MessageDigest digest)
{
ByteBuffer longBuffer = ByteBuffer.allocate(8);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < starts[i].size(); j++)
digest.update(starts[i].get(j).duplicate());
for (int j = 0; j < ends[i].size(); j++)
digest.update(ends[i].get(j).duplicate());
longBuffer.putLong(0, markedAts[i]);
digest.update(longBuffer.array(), 0, 8);
}
} | java | public void updateDigest(MessageDigest digest)
{
ByteBuffer longBuffer = ByteBuffer.allocate(8);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < starts[i].size(); j++)
digest.update(starts[i].get(j).duplicate());
for (int j = 0; j < ends[i].size(); j++)
digest.update(ends[i].get(j).duplicate());
longBuffer.putLong(0, markedAts[i]);
digest.update(longBuffer.array(), 0, 8);
}
} | [
"public",
"void",
"updateDigest",
"(",
"MessageDigest",
"digest",
")",
"{",
"ByteBuffer",
"longBuffer",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"8",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"for",
... | Calculates digest for triggering read repair on mismatch | [
"Calculates",
"digest",
"for",
"triggering",
"read",
"repair",
"on",
"mismatch"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/RangeTombstoneList.java#L464-L477 |
36,061 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/BloomFilter.java | BloomFilter.getHashBuckets | @VisibleForTesting
public long[] getHashBuckets(ByteBuffer key, int hashCount, long max)
{
long[] hash = new long[2];
hash(key, key.position(), key.remaining(), 0L, hash);
long[] indexes = new long[hashCount];
setIndexes(hash[0], hash[1], hashCount, max, indexes);
return indexes;
} | java | @VisibleForTesting
public long[] getHashBuckets(ByteBuffer key, int hashCount, long max)
{
long[] hash = new long[2];
hash(key, key.position(), key.remaining(), 0L, hash);
long[] indexes = new long[hashCount];
setIndexes(hash[0], hash[1], hashCount, max, indexes);
return indexes;
} | [
"@",
"VisibleForTesting",
"public",
"long",
"[",
"]",
"getHashBuckets",
"(",
"ByteBuffer",
"key",
",",
"int",
"hashCount",
",",
"long",
"max",
")",
"{",
"long",
"[",
"]",
"hash",
"=",
"new",
"long",
"[",
"2",
"]",
";",
"hash",
"(",
"key",
",",
"key",... | rather than using the threadLocal like we do in production | [
"rather",
"than",
"using",
"the",
"threadLocal",
"like",
"we",
"do",
"in",
"production"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/BloomFilter.java#L63-L71 |
36,062 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/BloomFilter.java | BloomFilter.indexes | private long[] indexes(ByteBuffer key)
{
// we use the same array both for storing the hash result, and for storing the indexes we return,
// so that we do not need to allocate two arrays.
long[] indexes = reusableIndexes.get();
hash(key, key.position(), key.remaining(), 0L, indexes);
setIndexes(indexes[0], indexes[1], hashCount, bitset.capacity(), indexes);
return indexes;
} | java | private long[] indexes(ByteBuffer key)
{
// we use the same array both for storing the hash result, and for storing the indexes we return,
// so that we do not need to allocate two arrays.
long[] indexes = reusableIndexes.get();
hash(key, key.position(), key.remaining(), 0L, indexes);
setIndexes(indexes[0], indexes[1], hashCount, bitset.capacity(), indexes);
return indexes;
} | [
"private",
"long",
"[",
"]",
"indexes",
"(",
"ByteBuffer",
"key",
")",
"{",
"// we use the same array both for storing the hash result, and for storing the indexes we return,",
"// so that we do not need to allocate two arrays.",
"long",
"[",
"]",
"indexes",
"=",
"reusableIndexes",... | a second threadlocal lookup. | [
"a",
"second",
"threadlocal",
"lookup",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/BloomFilter.java#L77-L85 |
36,063 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java | ClusteringKeyMapper.addFields | public final void addFields(Document document, CellName cellName) {
String serializedKey = ByteBufferUtils.toString(cellName.toByteBuffer());
Field field = new StringField(FIELD_NAME, serializedKey, Field.Store.YES);
document.add(field);
} | java | public final void addFields(Document document, CellName cellName) {
String serializedKey = ByteBufferUtils.toString(cellName.toByteBuffer());
Field field = new StringField(FIELD_NAME, serializedKey, Field.Store.YES);
document.add(field);
} | [
"public",
"final",
"void",
"addFields",
"(",
"Document",
"document",
",",
"CellName",
"cellName",
")",
"{",
"String",
"serializedKey",
"=",
"ByteBufferUtils",
".",
"toString",
"(",
"cellName",
".",
"toByteBuffer",
"(",
")",
")",
";",
"Field",
"field",
"=",
"... | Adds to the specified document the clustering key contained in the specified cell name.
@param document The document where the clustering key is going to be added.
@param cellName A cell name containing the clustering key to be added. | [
"Adds",
"to",
"the",
"specified",
"document",
"the",
"clustering",
"key",
"contained",
"in",
"the",
"specified",
"cell",
"name",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java#L110-L114 |
36,064 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java | ClusteringKeyMapper.clusteringKeys | public final List<CellName> clusteringKeys(ColumnFamily columnFamily) {
List<CellName> clusteringKeys = new ArrayList<>();
CellName lastClusteringKey = null;
for (Cell cell : columnFamily) {
CellName cellName = cell.name();
if (!isStatic(cellName)) {
CellName clusteringKey = extractClusteringKey(cellName);
if (lastClusteringKey == null || !lastClusteringKey.isSameCQL3RowAs(cellNameType, clusteringKey)) {
lastClusteringKey = clusteringKey;
clusteringKeys.add(clusteringKey);
}
}
}
return sort(clusteringKeys);
} | java | public final List<CellName> clusteringKeys(ColumnFamily columnFamily) {
List<CellName> clusteringKeys = new ArrayList<>();
CellName lastClusteringKey = null;
for (Cell cell : columnFamily) {
CellName cellName = cell.name();
if (!isStatic(cellName)) {
CellName clusteringKey = extractClusteringKey(cellName);
if (lastClusteringKey == null || !lastClusteringKey.isSameCQL3RowAs(cellNameType, clusteringKey)) {
lastClusteringKey = clusteringKey;
clusteringKeys.add(clusteringKey);
}
}
}
return sort(clusteringKeys);
} | [
"public",
"final",
"List",
"<",
"CellName",
">",
"clusteringKeys",
"(",
"ColumnFamily",
"columnFamily",
")",
"{",
"List",
"<",
"CellName",
">",
"clusteringKeys",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"CellName",
"lastClusteringKey",
"=",
"null",
";",
... | Returns the common clustering keys of the specified column family.
@param columnFamily A storage engine {@link ColumnFamily}.
@return The common clustering keys of the specified column family. | [
"Returns",
"the",
"common",
"clustering",
"keys",
"of",
"the",
"specified",
"column",
"family",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java#L134-L148 |
36,065 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java | ClusteringKeyMapper.makeCellName | public final CellName makeCellName(CellName cellName, ColumnDefinition columnDefinition) {
return cellNameType.create(start(cellName), columnDefinition);
} | java | public final CellName makeCellName(CellName cellName, ColumnDefinition columnDefinition) {
return cellNameType.create(start(cellName), columnDefinition);
} | [
"public",
"final",
"CellName",
"makeCellName",
"(",
"CellName",
"cellName",
",",
"ColumnDefinition",
"columnDefinition",
")",
"{",
"return",
"cellNameType",
".",
"create",
"(",
"start",
"(",
"cellName",
")",
",",
"columnDefinition",
")",
";",
"}"
] | Returns the storage engine column name for the specified column identifier using the specified clustering key.
@param cellName The clustering key.
@param columnDefinition The column definition.
@return A storage engine column name. | [
"Returns",
"the",
"storage",
"engine",
"column",
"name",
"for",
"the",
"specified",
"column",
"identifier",
"using",
"the",
"specified",
"clustering",
"key",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java#L177-L179 |
36,066 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java | ClusteringKeyMapper.clusteringKey | public final CellName clusteringKey(BytesRef bytesRef) {
String string = bytesRef.utf8ToString();
ByteBuffer bb = ByteBufferUtils.fromString(string);
return cellNameType.cellFromByteBuffer(bb);
} | java | public final CellName clusteringKey(BytesRef bytesRef) {
String string = bytesRef.utf8ToString();
ByteBuffer bb = ByteBufferUtils.fromString(string);
return cellNameType.cellFromByteBuffer(bb);
} | [
"public",
"final",
"CellName",
"clusteringKey",
"(",
"BytesRef",
"bytesRef",
")",
"{",
"String",
"string",
"=",
"bytesRef",
".",
"utf8ToString",
"(",
")",
";",
"ByteBuffer",
"bb",
"=",
"ByteBufferUtils",
".",
"fromString",
"(",
"string",
")",
";",
"return",
... | Returns the clustering key contained in the specified Lucene field value.
@param bytesRef The {@link BytesRef} containing the raw clustering key to be get.
@return The clustering key contained in the specified Lucene field value. | [
"Returns",
"the",
"clustering",
"key",
"contained",
"in",
"the",
"specified",
"Lucene",
"field",
"value",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java#L209-L213 |
36,067 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java | ClusteringKeyMapper.start | public final Composite start(CellName cellName) {
CBuilder builder = cellNameType.builder();
for (int i = 0; i < cellName.clusteringSize(); i++) {
ByteBuffer component = cellName.get(i);
builder.add(component);
}
return builder.build();
} | java | public final Composite start(CellName cellName) {
CBuilder builder = cellNameType.builder();
for (int i = 0; i < cellName.clusteringSize(); i++) {
ByteBuffer component = cellName.get(i);
builder.add(component);
}
return builder.build();
} | [
"public",
"final",
"Composite",
"start",
"(",
"CellName",
"cellName",
")",
"{",
"CBuilder",
"builder",
"=",
"cellNameType",
".",
"builder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cellName",
".",
"clusteringSize",
"(",
")",
";"... | Returns the first possible cell name of those having the same clustering key that the specified cell name.
@param cellName A storage engine cell name.
@return The first column name of for {@code clusteringKey}. | [
"Returns",
"the",
"first",
"possible",
"cell",
"name",
"of",
"those",
"having",
"the",
"same",
"clustering",
"key",
"that",
"the",
"specified",
"cell",
"name",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java#L237-L244 |
36,068 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java | ClusteringKeyMapper.end | public final Composite end(CellName cellName) {
return start(cellName).withEOC(Composite.EOC.END);
} | java | public final Composite end(CellName cellName) {
return start(cellName).withEOC(Composite.EOC.END);
} | [
"public",
"final",
"Composite",
"end",
"(",
"CellName",
"cellName",
")",
"{",
"return",
"start",
"(",
"cellName",
")",
".",
"withEOC",
"(",
"Composite",
".",
"EOC",
".",
"END",
")",
";",
"}"
] | Returns the last possible cell name of those having the same clustering key that the specified cell name.
@param cellName A storage engine cell name.
@return The first column name of for {@code clusteringKey}. | [
"Returns",
"the",
"last",
"possible",
"cell",
"name",
"of",
"those",
"having",
"the",
"same",
"clustering",
"key",
"that",
"the",
"specified",
"cell",
"name",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java#L252-L254 |
36,069 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java | ClusteringKeyMapper.sort | public final List<CellName> sort(List<CellName> clusteringKeys) {
List<CellName> result = new ArrayList<>(clusteringKeys);
Collections.sort(result, new Comparator<CellName>() {
@Override
public int compare(CellName o1, CellName o2) {
return cellNameType.compare(o1, o2);
}
});
return result;
} | java | public final List<CellName> sort(List<CellName> clusteringKeys) {
List<CellName> result = new ArrayList<>(clusteringKeys);
Collections.sort(result, new Comparator<CellName>() {
@Override
public int compare(CellName o1, CellName o2) {
return cellNameType.compare(o1, o2);
}
});
return result;
} | [
"public",
"final",
"List",
"<",
"CellName",
">",
"sort",
"(",
"List",
"<",
"CellName",
">",
"clusteringKeys",
")",
"{",
"List",
"<",
"CellName",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
"clusteringKeys",
")",
";",
"Collections",
".",
"sort",
"(... | Returns the specified list of clustering keys sorted according to the table cell name comparator.
@param clusteringKeys The list of clustering keys to be sorted.
@return The specified list of clustering keys sorted according to the table cell name comparator. | [
"Returns",
"the",
"specified",
"list",
"of",
"clustering",
"keys",
"sorted",
"according",
"to",
"the",
"table",
"cell",
"name",
"comparator",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/service/ClusteringKeyMapper.java#L310-L319 |
36,070 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/locator/SnitchProperties.java | SnitchProperties.get | public String get(String propertyName, String defaultValue)
{
return properties.getProperty(propertyName, defaultValue);
} | java | public String get(String propertyName, String defaultValue)
{
return properties.getProperty(propertyName, defaultValue);
} | [
"public",
"String",
"get",
"(",
"String",
"propertyName",
",",
"String",
"defaultValue",
")",
"{",
"return",
"properties",
".",
"getProperty",
"(",
"propertyName",
",",
"defaultValue",
")",
";",
"}"
] | Get a snitch property value or return defaultValue if not defined. | [
"Get",
"a",
"snitch",
"property",
"value",
"or",
"return",
"defaultValue",
"if",
"not",
"defined",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/locator/SnitchProperties.java#L65-L68 |
36,071 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/marshal/TypeParser.java | TypeParser.parse | public static AbstractType<?> parse(String str) throws SyntaxException, ConfigurationException
{
if (str == null)
return BytesType.instance;
AbstractType<?> type = cache.get(str);
if (type != null)
return type;
// This could be simplier (i.e. new TypeParser(str).parse()) but we avoid creating a TypeParser object if not really necessary.
int i = 0;
i = skipBlank(str, i);
int j = i;
while (!isEOS(str, i) && isIdentifierChar(str.charAt(i)))
++i;
if (i == j)
return BytesType.instance;
String name = str.substring(j, i);
i = skipBlank(str, i);
if (!isEOS(str, i) && str.charAt(i) == '(')
type = getAbstractType(name, new TypeParser(str, i));
else
type = getAbstractType(name);
// We don't really care about concurrency here. Worst case scenario, we do some parsing unnecessarily
cache.put(str, type);
return type;
} | java | public static AbstractType<?> parse(String str) throws SyntaxException, ConfigurationException
{
if (str == null)
return BytesType.instance;
AbstractType<?> type = cache.get(str);
if (type != null)
return type;
// This could be simplier (i.e. new TypeParser(str).parse()) but we avoid creating a TypeParser object if not really necessary.
int i = 0;
i = skipBlank(str, i);
int j = i;
while (!isEOS(str, i) && isIdentifierChar(str.charAt(i)))
++i;
if (i == j)
return BytesType.instance;
String name = str.substring(j, i);
i = skipBlank(str, i);
if (!isEOS(str, i) && str.charAt(i) == '(')
type = getAbstractType(name, new TypeParser(str, i));
else
type = getAbstractType(name);
// We don't really care about concurrency here. Worst case scenario, we do some parsing unnecessarily
cache.put(str, type);
return type;
} | [
"public",
"static",
"AbstractType",
"<",
"?",
">",
"parse",
"(",
"String",
"str",
")",
"throws",
"SyntaxException",
",",
"ConfigurationException",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"return",
"BytesType",
".",
"instance",
";",
"AbstractType",
"<",
"?"... | Parse a string containing an type definition. | [
"Parse",
"a",
"string",
"containing",
"an",
"type",
"definition",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/marshal/TypeParser.java#L64-L95 |
36,072 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/marshal/TypeParser.java | TypeParser.parse | public AbstractType<?> parse() throws SyntaxException, ConfigurationException
{
skipBlank();
String name = readNextIdentifier();
skipBlank();
if (!isEOS() && str.charAt(idx) == '(')
return getAbstractType(name, this);
else
return getAbstractType(name);
} | java | public AbstractType<?> parse() throws SyntaxException, ConfigurationException
{
skipBlank();
String name = readNextIdentifier();
skipBlank();
if (!isEOS() && str.charAt(idx) == '(')
return getAbstractType(name, this);
else
return getAbstractType(name);
} | [
"public",
"AbstractType",
"<",
"?",
">",
"parse",
"(",
")",
"throws",
"SyntaxException",
",",
"ConfigurationException",
"{",
"skipBlank",
"(",
")",
";",
"String",
"name",
"=",
"readNextIdentifier",
"(",
")",
";",
"skipBlank",
"(",
")",
";",
"if",
"(",
"!",... | Parse an AbstractType from current position of this parser. | [
"Parse",
"an",
"AbstractType",
"from",
"current",
"position",
"of",
"this",
"parser",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/marshal/TypeParser.java#L110-L120 |
36,073 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/marshal/TypeParser.java | TypeParser.skipBlankAndComma | private boolean skipBlankAndComma()
{
boolean commaFound = false;
while (!isEOS())
{
int c = str.charAt(idx);
if (c == ',')
{
if (commaFound)
return true;
else
commaFound = true;
}
else if (!isBlank(c))
{
return true;
}
++idx;
}
return false;
} | java | private boolean skipBlankAndComma()
{
boolean commaFound = false;
while (!isEOS())
{
int c = str.charAt(idx);
if (c == ',')
{
if (commaFound)
return true;
else
commaFound = true;
}
else if (!isBlank(c))
{
return true;
}
++idx;
}
return false;
} | [
"private",
"boolean",
"skipBlankAndComma",
"(",
")",
"{",
"boolean",
"commaFound",
"=",
"false",
";",
"while",
"(",
"!",
"isEOS",
"(",
")",
")",
"{",
"int",
"c",
"=",
"str",
".",
"charAt",
"(",
"idx",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")"... | skip all blank and at best one comma, return true if there not EOS | [
"skip",
"all",
"blank",
"and",
"at",
"best",
"one",
"comma",
"return",
"true",
"if",
"there",
"not",
"EOS"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/marshal/TypeParser.java#L467-L487 |
36,074 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/marshal/TypeParser.java | TypeParser.readNextIdentifier | public String readNextIdentifier()
{
int i = idx;
while (!isEOS() && isIdentifierChar(str.charAt(idx)))
++idx;
return str.substring(i, idx);
} | java | public String readNextIdentifier()
{
int i = idx;
while (!isEOS() && isIdentifierChar(str.charAt(idx)))
++idx;
return str.substring(i, idx);
} | [
"public",
"String",
"readNextIdentifier",
"(",
")",
"{",
"int",
"i",
"=",
"idx",
";",
"while",
"(",
"!",
"isEOS",
"(",
")",
"&&",
"isIdentifierChar",
"(",
"str",
".",
"charAt",
"(",
"idx",
")",
")",
")",
"++",
"idx",
";",
"return",
"str",
".",
"sub... | left idx positioned on the character stopping the read | [
"left",
"idx",
"positioned",
"on",
"the",
"character",
"stopping",
"the",
"read"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/marshal/TypeParser.java#L500-L507 |
36,075 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java | CompressedSequentialWriter.seekToChunkStart | private void seekToChunkStart()
{
if (getOnDiskFilePointer() != chunkOffset)
{
try
{
out.seek(chunkOffset);
}
catch (IOException e)
{
throw new FSReadError(e, getPath());
}
}
} | java | private void seekToChunkStart()
{
if (getOnDiskFilePointer() != chunkOffset)
{
try
{
out.seek(chunkOffset);
}
catch (IOException e)
{
throw new FSReadError(e, getPath());
}
}
} | [
"private",
"void",
"seekToChunkStart",
"(",
")",
"{",
"if",
"(",
"getOnDiskFilePointer",
"(",
")",
"!=",
"chunkOffset",
")",
"{",
"try",
"{",
"out",
".",
"seek",
"(",
"chunkOffset",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"n... | Seek to the offset where next compressed data chunk should be stored. | [
"Seek",
"to",
"the",
"offset",
"where",
"next",
"compressed",
"data",
"chunk",
"should",
"be",
"stored",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java#L243-L256 |
36,076 | Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/schema/mapping/Mapping.java | Mapping.validate | public void validate(CFMetaData metadata) {
for (Map.Entry<String, ColumnMapper> entry : columnMappers.entrySet()) {
String name = entry.getKey();
ColumnMapper columnMapper = entry.getValue();
ByteBuffer columnName = UTF8Type.instance.decompose(name);
ColumnDefinition columnDefinition = metadata.getColumnDefinition(columnName);
if (columnDefinition == null) {
throw new RuntimeException("No column definition for mapper " + name);
}
if (columnDefinition.isStatic()) {
throw new RuntimeException("Lucene indexes are not allowed on static columns as " + name);
}
AbstractType<?> type = columnDefinition.type;
if (!columnMapper.supports(type)) {
throw new RuntimeException(String.format("Type '%s' is not supported by mapper '%s'", type, name));
}
}
} | java | public void validate(CFMetaData metadata) {
for (Map.Entry<String, ColumnMapper> entry : columnMappers.entrySet()) {
String name = entry.getKey();
ColumnMapper columnMapper = entry.getValue();
ByteBuffer columnName = UTF8Type.instance.decompose(name);
ColumnDefinition columnDefinition = metadata.getColumnDefinition(columnName);
if (columnDefinition == null) {
throw new RuntimeException("No column definition for mapper " + name);
}
if (columnDefinition.isStatic()) {
throw new RuntimeException("Lucene indexes are not allowed on static columns as " + name);
}
AbstractType<?> type = columnDefinition.type;
if (!columnMapper.supports(type)) {
throw new RuntimeException(String.format("Type '%s' is not supported by mapper '%s'", type, name));
}
}
} | [
"public",
"void",
"validate",
"(",
"CFMetaData",
"metadata",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"ColumnMapper",
">",
"entry",
":",
"columnMappers",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"name",
"=",
"entry",
".",
"g... | Checks if this is consistent with the specified column family metadata.
@param metadata A column family metadata. | [
"Checks",
"if",
"this",
"is",
"consistent",
"with",
"the",
"specified",
"column",
"family",
"metadata",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/schema/mapping/Mapping.java#L50-L71 |
36,077 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.reload | public void reload()
{
// figure out what needs to be added and dropped.
// future: if/when we have modifiable settings for secondary indexes,
// they'll need to be handled here.
Collection<ByteBuffer> indexedColumnNames = indexesByColumn.keySet();
for (ByteBuffer indexedColumn : indexedColumnNames)
{
ColumnDefinition def = baseCfs.metadata.getColumnDefinition(indexedColumn);
if (def == null || def.getIndexType() == null)
removeIndexedColumn(indexedColumn);
}
// TODO: allow all ColumnDefinition type
for (ColumnDefinition cdef : baseCfs.metadata.allColumns())
if (cdef.getIndexType() != null && !indexedColumnNames.contains(cdef.name.bytes))
addIndexedColumn(cdef);
for (SecondaryIndex index : allIndexes)
index.reload();
} | java | public void reload()
{
// figure out what needs to be added and dropped.
// future: if/when we have modifiable settings for secondary indexes,
// they'll need to be handled here.
Collection<ByteBuffer> indexedColumnNames = indexesByColumn.keySet();
for (ByteBuffer indexedColumn : indexedColumnNames)
{
ColumnDefinition def = baseCfs.metadata.getColumnDefinition(indexedColumn);
if (def == null || def.getIndexType() == null)
removeIndexedColumn(indexedColumn);
}
// TODO: allow all ColumnDefinition type
for (ColumnDefinition cdef : baseCfs.metadata.allColumns())
if (cdef.getIndexType() != null && !indexedColumnNames.contains(cdef.name.bytes))
addIndexedColumn(cdef);
for (SecondaryIndex index : allIndexes)
index.reload();
} | [
"public",
"void",
"reload",
"(",
")",
"{",
"// figure out what needs to be added and dropped.",
"// future: if/when we have modifiable settings for secondary indexes,",
"// they'll need to be handled here.",
"Collection",
"<",
"ByteBuffer",
">",
"indexedColumnNames",
"=",
"indexesByCol... | Drops and adds new indexes associated with the underlying CF | [
"Drops",
"and",
"adds",
"new",
"indexes",
"associated",
"with",
"the",
"underlying",
"CF"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L118-L138 |
36,078 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.maybeBuildSecondaryIndexes | public void maybeBuildSecondaryIndexes(Collection<SSTableReader> sstables, Set<String> idxNames)
{
if (idxNames.isEmpty())
return;
logger.info(String.format("Submitting index build of %s for data in %s",
idxNames, StringUtils.join(sstables, ", ")));
SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs, idxNames, new ReducingKeyIterator(sstables));
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
flushIndexesBlocking();
logger.info("Index build of {} complete", idxNames);
} | java | public void maybeBuildSecondaryIndexes(Collection<SSTableReader> sstables, Set<String> idxNames)
{
if (idxNames.isEmpty())
return;
logger.info(String.format("Submitting index build of %s for data in %s",
idxNames, StringUtils.join(sstables, ", ")));
SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs, idxNames, new ReducingKeyIterator(sstables));
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
flushIndexesBlocking();
logger.info("Index build of {} complete", idxNames);
} | [
"public",
"void",
"maybeBuildSecondaryIndexes",
"(",
"Collection",
"<",
"SSTableReader",
">",
"sstables",
",",
"Set",
"<",
"String",
">",
"idxNames",
")",
"{",
"if",
"(",
"idxNames",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"logger",
".",
"info",
"(",... | Does a full, blocking rebuild of the indexes specified by columns from the sstables.
Does nothing if columns is empty.
Caller must acquire and release references to the sstables used here.
@param sstables the data to build from
@param idxNames the list of columns to index, ordered by comparator | [
"Does",
"a",
"full",
"blocking",
"rebuild",
"of",
"the",
"indexes",
"specified",
"by",
"columns",
"from",
"the",
"sstables",
".",
"Does",
"nothing",
"if",
"columns",
"is",
"empty",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L157-L172 |
36,079 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.removeIndexedColumn | public void removeIndexedColumn(ByteBuffer column)
{
SecondaryIndex index = indexesByColumn.remove(column);
if (index == null)
return;
// Remove this column from from row level index map as well as all indexes set
if (index instanceof PerRowSecondaryIndex)
{
index.removeColumnDef(column);
// If no columns left remove from row level lookup as well as all indexes set
if (index.getColumnDefs().isEmpty())
{
allIndexes.remove(index);
rowLevelIndexMap.remove(index.getClass());
}
}
else
{
allIndexes.remove(index);
}
index.removeIndex(column);
SystemKeyspace.setIndexRemoved(baseCfs.metadata.ksName, index.getNameForSystemKeyspace(column));
} | java | public void removeIndexedColumn(ByteBuffer column)
{
SecondaryIndex index = indexesByColumn.remove(column);
if (index == null)
return;
// Remove this column from from row level index map as well as all indexes set
if (index instanceof PerRowSecondaryIndex)
{
index.removeColumnDef(column);
// If no columns left remove from row level lookup as well as all indexes set
if (index.getColumnDefs().isEmpty())
{
allIndexes.remove(index);
rowLevelIndexMap.remove(index.getClass());
}
}
else
{
allIndexes.remove(index);
}
index.removeIndex(column);
SystemKeyspace.setIndexRemoved(baseCfs.metadata.ksName, index.getNameForSystemKeyspace(column));
} | [
"public",
"void",
"removeIndexedColumn",
"(",
"ByteBuffer",
"column",
")",
"{",
"SecondaryIndex",
"index",
"=",
"indexesByColumn",
".",
"remove",
"(",
"column",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"return",
";",
"// Remove this column from from row le... | Removes a existing index
@param column the indexed column to remove | [
"Removes",
"a",
"existing",
"index"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L237-L263 |
36,080 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.addIndexedColumn | public synchronized Future<?> addIndexedColumn(ColumnDefinition cdef)
{
if (indexesByColumn.containsKey(cdef.name.bytes))
return null;
assert cdef.getIndexType() != null;
SecondaryIndex index;
try
{
index = SecondaryIndex.createInstance(baseCfs, cdef);
}
catch (ConfigurationException e)
{
throw new RuntimeException(e);
}
// Keep a single instance of the index per-cf for row level indexes
// since we want all columns to be under the index
if (index instanceof PerRowSecondaryIndex)
{
SecondaryIndex currentIndex = rowLevelIndexMap.get(index.getClass());
if (currentIndex == null)
{
rowLevelIndexMap.put(index.getClass(), index);
index.init();
}
else
{
index = currentIndex;
index.addColumnDef(cdef);
logger.info("Creating new index : {}",cdef);
}
}
else
{
// TODO: We sould do better than throw a RuntimeException
if (cdef.getIndexType() == IndexType.CUSTOM && index instanceof AbstractSimplePerColumnSecondaryIndex)
throw new RuntimeException("Cannot use a subclass of AbstractSimplePerColumnSecondaryIndex as a CUSTOM index, as they assume they are CFS backed");
index.init();
}
// link in indexedColumns. this means that writes will add new data to
// the index immediately,
// so we don't have to lock everything while we do the build. it's up to
// the operator to wait
// until the index is actually built before using in queries.
indexesByColumn.put(cdef.name.bytes, index);
// Add to all indexes set:
allIndexes.add(index);
// if we're just linking in the index to indexedColumns on an
// already-built index post-restart, we're done
if (index.isIndexBuilt(cdef.name.bytes))
return null;
return index.buildIndexAsync();
} | java | public synchronized Future<?> addIndexedColumn(ColumnDefinition cdef)
{
if (indexesByColumn.containsKey(cdef.name.bytes))
return null;
assert cdef.getIndexType() != null;
SecondaryIndex index;
try
{
index = SecondaryIndex.createInstance(baseCfs, cdef);
}
catch (ConfigurationException e)
{
throw new RuntimeException(e);
}
// Keep a single instance of the index per-cf for row level indexes
// since we want all columns to be under the index
if (index instanceof PerRowSecondaryIndex)
{
SecondaryIndex currentIndex = rowLevelIndexMap.get(index.getClass());
if (currentIndex == null)
{
rowLevelIndexMap.put(index.getClass(), index);
index.init();
}
else
{
index = currentIndex;
index.addColumnDef(cdef);
logger.info("Creating new index : {}",cdef);
}
}
else
{
// TODO: We sould do better than throw a RuntimeException
if (cdef.getIndexType() == IndexType.CUSTOM && index instanceof AbstractSimplePerColumnSecondaryIndex)
throw new RuntimeException("Cannot use a subclass of AbstractSimplePerColumnSecondaryIndex as a CUSTOM index, as they assume they are CFS backed");
index.init();
}
// link in indexedColumns. this means that writes will add new data to
// the index immediately,
// so we don't have to lock everything while we do the build. it's up to
// the operator to wait
// until the index is actually built before using in queries.
indexesByColumn.put(cdef.name.bytes, index);
// Add to all indexes set:
allIndexes.add(index);
// if we're just linking in the index to indexedColumns on an
// already-built index post-restart, we're done
if (index.isIndexBuilt(cdef.name.bytes))
return null;
return index.buildIndexAsync();
} | [
"public",
"synchronized",
"Future",
"<",
"?",
">",
"addIndexedColumn",
"(",
"ColumnDefinition",
"cdef",
")",
"{",
"if",
"(",
"indexesByColumn",
".",
"containsKey",
"(",
"cdef",
".",
"name",
".",
"bytes",
")",
")",
"return",
"null",
";",
"assert",
"cdef",
"... | Adds and builds a index for a column
@param cdef the column definition holding the index data
@return a future which the caller can optionally block on signaling the index is built | [
"Adds",
"and",
"builds",
"a",
"index",
"for",
"a",
"column"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L270-L329 |
36,081 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.flushIndexesBlocking | public void flushIndexesBlocking()
{
// despatch flushes for all CFS backed indexes
List<Future<?>> wait = new ArrayList<>();
synchronized (baseCfs.getDataTracker())
{
for (SecondaryIndex index : allIndexes)
if (index.getIndexCfs() != null)
wait.add(index.getIndexCfs().forceFlush());
}
// blockingFlush any non-CFS-backed indexes
for (SecondaryIndex index : allIndexes)
if (index.getIndexCfs() == null)
index.forceBlockingFlush();
// wait for the CFS-backed index flushes to complete
FBUtilities.waitOnFutures(wait);
} | java | public void flushIndexesBlocking()
{
// despatch flushes for all CFS backed indexes
List<Future<?>> wait = new ArrayList<>();
synchronized (baseCfs.getDataTracker())
{
for (SecondaryIndex index : allIndexes)
if (index.getIndexCfs() != null)
wait.add(index.getIndexCfs().forceFlush());
}
// blockingFlush any non-CFS-backed indexes
for (SecondaryIndex index : allIndexes)
if (index.getIndexCfs() == null)
index.forceBlockingFlush();
// wait for the CFS-backed index flushes to complete
FBUtilities.waitOnFutures(wait);
} | [
"public",
"void",
"flushIndexesBlocking",
"(",
")",
"{",
"// despatch flushes for all CFS backed indexes",
"List",
"<",
"Future",
"<",
"?",
">",
">",
"wait",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"synchronized",
"(",
"baseCfs",
".",
"getDataTracker",
"("... | Flush all indexes to disk | [
"Flush",
"all",
"indexes",
"to",
"disk"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L353-L371 |
36,082 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.indexRow | public void indexRow(ByteBuffer key, ColumnFamily cf, OpOrder.Group opGroup)
{
// Update entire row only once per row level index
Set<Class<? extends SecondaryIndex>> appliedRowLevelIndexes = null;
for (SecondaryIndex index : allIndexes)
{
if (index instanceof PerRowSecondaryIndex)
{
if (appliedRowLevelIndexes == null)
appliedRowLevelIndexes = new HashSet<>();
if (appliedRowLevelIndexes.add(index.getClass()))
((PerRowSecondaryIndex)index).index(key, cf);
}
else
{
for (Cell cell : cf)
if (cell.isLive() && index.indexes(cell.name()))
((PerColumnSecondaryIndex) index).insert(key, cell, opGroup);
}
}
} | java | public void indexRow(ByteBuffer key, ColumnFamily cf, OpOrder.Group opGroup)
{
// Update entire row only once per row level index
Set<Class<? extends SecondaryIndex>> appliedRowLevelIndexes = null;
for (SecondaryIndex index : allIndexes)
{
if (index instanceof PerRowSecondaryIndex)
{
if (appliedRowLevelIndexes == null)
appliedRowLevelIndexes = new HashSet<>();
if (appliedRowLevelIndexes.add(index.getClass()))
((PerRowSecondaryIndex)index).index(key, cf);
}
else
{
for (Cell cell : cf)
if (cell.isLive() && index.indexes(cell.name()))
((PerColumnSecondaryIndex) index).insert(key, cell, opGroup);
}
}
} | [
"public",
"void",
"indexRow",
"(",
"ByteBuffer",
"key",
",",
"ColumnFamily",
"cf",
",",
"OpOrder",
".",
"Group",
"opGroup",
")",
"{",
"// Update entire row only once per row level index",
"Set",
"<",
"Class",
"<",
"?",
"extends",
"SecondaryIndex",
">",
">",
"appli... | When building an index against existing data, add the given row to the index
@param key the row key
@param cf the current rows data | [
"When",
"building",
"an",
"index",
"against",
"existing",
"data",
"add",
"the",
"given",
"row",
"to",
"the",
"index"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L443-L465 |
36,083 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.deleteFromIndexes | public void deleteFromIndexes(DecoratedKey key, List<Cell> indexedColumnsInRow, OpOrder.Group opGroup)
{
// Update entire row only once per row level index
Set<Class<? extends SecondaryIndex>> cleanedRowLevelIndexes = null;
for (Cell cell : indexedColumnsInRow)
{
for (SecondaryIndex index : indexFor(cell.name()))
{
if (index instanceof PerRowSecondaryIndex)
{
if (cleanedRowLevelIndexes == null)
cleanedRowLevelIndexes = new HashSet<>();
if (cleanedRowLevelIndexes.add(index.getClass()))
((PerRowSecondaryIndex) index).delete(key, opGroup);
}
else
{
((PerColumnSecondaryIndex) index).deleteForCleanup(key.getKey(), cell, opGroup);
}
}
}
} | java | public void deleteFromIndexes(DecoratedKey key, List<Cell> indexedColumnsInRow, OpOrder.Group opGroup)
{
// Update entire row only once per row level index
Set<Class<? extends SecondaryIndex>> cleanedRowLevelIndexes = null;
for (Cell cell : indexedColumnsInRow)
{
for (SecondaryIndex index : indexFor(cell.name()))
{
if (index instanceof PerRowSecondaryIndex)
{
if (cleanedRowLevelIndexes == null)
cleanedRowLevelIndexes = new HashSet<>();
if (cleanedRowLevelIndexes.add(index.getClass()))
((PerRowSecondaryIndex) index).delete(key, opGroup);
}
else
{
((PerColumnSecondaryIndex) index).deleteForCleanup(key.getKey(), cell, opGroup);
}
}
}
} | [
"public",
"void",
"deleteFromIndexes",
"(",
"DecoratedKey",
"key",
",",
"List",
"<",
"Cell",
">",
"indexedColumnsInRow",
",",
"OpOrder",
".",
"Group",
"opGroup",
")",
"{",
"// Update entire row only once per row level index",
"Set",
"<",
"Class",
"<",
"?",
"extends"... | Delete all columns from all indexes for this row. For when cleanup rips a row out entirely.
@param key the row key
@param indexedColumnsInRow all column names in row | [
"Delete",
"all",
"columns",
"from",
"all",
"indexes",
"for",
"this",
"row",
".",
"For",
"when",
"cleanup",
"rips",
"a",
"row",
"out",
"entirely",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L473-L495 |
36,084 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.getIndexSearchersForQuery | public List<SecondaryIndexSearcher> getIndexSearchersForQuery(List<IndexExpression> clause)
{
Map<String, Set<ByteBuffer>> groupByIndexType = new HashMap<>();
//Group columns by type
for (IndexExpression ix : clause)
{
SecondaryIndex index = getIndexForColumn(ix.column);
if (index == null || !index.supportsOperator(ix.operator))
continue;
Set<ByteBuffer> columns = groupByIndexType.get(index.indexTypeForGrouping());
if (columns == null)
{
columns = new HashSet<>();
groupByIndexType.put(index.indexTypeForGrouping(), columns);
}
columns.add(ix.column);
}
List<SecondaryIndexSearcher> indexSearchers = new ArrayList<>(groupByIndexType.size());
//create searcher per type
for (Set<ByteBuffer> column : groupByIndexType.values())
indexSearchers.add(getIndexForColumn(column.iterator().next()).createSecondaryIndexSearcher(column));
return indexSearchers;
} | java | public List<SecondaryIndexSearcher> getIndexSearchersForQuery(List<IndexExpression> clause)
{
Map<String, Set<ByteBuffer>> groupByIndexType = new HashMap<>();
//Group columns by type
for (IndexExpression ix : clause)
{
SecondaryIndex index = getIndexForColumn(ix.column);
if (index == null || !index.supportsOperator(ix.operator))
continue;
Set<ByteBuffer> columns = groupByIndexType.get(index.indexTypeForGrouping());
if (columns == null)
{
columns = new HashSet<>();
groupByIndexType.put(index.indexTypeForGrouping(), columns);
}
columns.add(ix.column);
}
List<SecondaryIndexSearcher> indexSearchers = new ArrayList<>(groupByIndexType.size());
//create searcher per type
for (Set<ByteBuffer> column : groupByIndexType.values())
indexSearchers.add(getIndexForColumn(column.iterator().next()).createSecondaryIndexSearcher(column));
return indexSearchers;
} | [
"public",
"List",
"<",
"SecondaryIndexSearcher",
">",
"getIndexSearchersForQuery",
"(",
"List",
"<",
"IndexExpression",
">",
"clause",
")",
"{",
"Map",
"<",
"String",
",",
"Set",
"<",
"ByteBuffer",
">",
">",
"groupByIndexType",
"=",
"new",
"HashMap",
"<>",
"("... | Get a list of IndexSearchers from the union of expression index types
@param clause the query clause
@return the searchers needed to query the index | [
"Get",
"a",
"list",
"of",
"IndexSearchers",
"from",
"the",
"union",
"of",
"expression",
"index",
"types"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L524-L554 |
36,085 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java | SecondaryIndexManager.search | public List<Row> search(ExtendedFilter filter)
{
SecondaryIndexSearcher mostSelective = getHighestSelectivityIndexSearcher(filter.getClause());
if (mostSelective == null)
return Collections.emptyList();
else
return mostSelective.search(filter);
} | java | public List<Row> search(ExtendedFilter filter)
{
SecondaryIndexSearcher mostSelective = getHighestSelectivityIndexSearcher(filter.getClause());
if (mostSelective == null)
return Collections.emptyList();
else
return mostSelective.search(filter);
} | [
"public",
"List",
"<",
"Row",
">",
"search",
"(",
"ExtendedFilter",
"filter",
")",
"{",
"SecondaryIndexSearcher",
"mostSelective",
"=",
"getHighestSelectivityIndexSearcher",
"(",
"filter",
".",
"getClause",
"(",
")",
")",
";",
"if",
"(",
"mostSelective",
"==",
"... | Performs a search across a number of column indexes
@param filter the column range to restrict to
@return found indexed rows | [
"Performs",
"a",
"search",
"across",
"a",
"number",
"of",
"column",
"indexes"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java#L638-L645 |
36,086 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/ColumnFamilySplit.java | ColumnFamilySplit.write | public void write(DataOutput out) throws IOException
{
out.writeUTF(startToken);
out.writeUTF(endToken);
out.writeInt(dataNodes.length);
for (String endpoint : dataNodes)
{
out.writeUTF(endpoint);
}
} | java | public void write(DataOutput out) throws IOException
{
out.writeUTF(startToken);
out.writeUTF(endToken);
out.writeInt(dataNodes.length);
for (String endpoint : dataNodes)
{
out.writeUTF(endpoint);
}
} | [
"public",
"void",
"write",
"(",
"DataOutput",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"writeUTF",
"(",
"startToken",
")",
";",
"out",
".",
"writeUTF",
"(",
"endToken",
")",
";",
"out",
".",
"writeInt",
"(",
"dataNodes",
".",
"length",
")",
... | KeyspaceSplits as needed by the Writable interface. | [
"KeyspaceSplits",
"as",
"needed",
"by",
"the",
"Writable",
"interface",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/ColumnFamilySplit.java#L78-L87 |
36,087 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/concurrent/DebuggableScheduledThreadPoolExecutor.java | DebuggableScheduledThreadPoolExecutor.afterExecute | @Override
public void afterExecute(Runnable r, Throwable t)
{
super.afterExecute(r,t);
DebuggableThreadPoolExecutor.logExceptionsAfterExecute(r, t);
} | java | @Override
public void afterExecute(Runnable r, Throwable t)
{
super.afterExecute(r,t);
DebuggableThreadPoolExecutor.logExceptionsAfterExecute(r, t);
} | [
"@",
"Override",
"public",
"void",
"afterExecute",
"(",
"Runnable",
"r",
",",
"Throwable",
"t",
")",
"{",
"super",
".",
"afterExecute",
"(",
"r",
",",
"t",
")",
";",
"DebuggableThreadPoolExecutor",
".",
"logExceptionsAfterExecute",
"(",
"r",
",",
"t",
")",
... | We need this as well as the wrapper for the benefit of non-repeating tasks | [
"We",
"need",
"this",
"as",
"well",
"as",
"the",
"wrapper",
"for",
"the",
"benefit",
"of",
"non",
"-",
"repeating",
"tasks"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/concurrent/DebuggableScheduledThreadPoolExecutor.java#L49-L54 |
36,088 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/Directories.java | Directories.snapshotCreationTime | public long snapshotCreationTime(String snapshotName)
{
for (File dir : dataPaths)
{
File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, snapshotName));
if (snapshotDir.exists())
return snapshotDir.lastModified();
}
throw new RuntimeException("Snapshot " + snapshotName + " doesn't exist");
} | java | public long snapshotCreationTime(String snapshotName)
{
for (File dir : dataPaths)
{
File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, snapshotName));
if (snapshotDir.exists())
return snapshotDir.lastModified();
}
throw new RuntimeException("Snapshot " + snapshotName + " doesn't exist");
} | [
"public",
"long",
"snapshotCreationTime",
"(",
"String",
"snapshotName",
")",
"{",
"for",
"(",
"File",
"dir",
":",
"dataPaths",
")",
"{",
"File",
"snapshotDir",
"=",
"new",
"File",
"(",
"dir",
",",
"join",
"(",
"SNAPSHOT_SUBDIR",
",",
"snapshotName",
")",
... | The snapshot must exist | [
"The",
"snapshot",
"must",
"exist"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/Directories.java#L622-L631 |
36,089 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/Directories.java | Directories.getKSChildDirectories | public static List<File> getKSChildDirectories(String ksName)
{
List<File> result = new ArrayList<>();
for (DataDirectory dataDirectory : dataDirectories)
{
File ksDir = new File(dataDirectory.location, ksName);
File[] cfDirs = ksDir.listFiles();
if (cfDirs == null)
continue;
for (File cfDir : cfDirs)
{
if (cfDir.isDirectory())
result.add(cfDir);
}
}
return result;
} | java | public static List<File> getKSChildDirectories(String ksName)
{
List<File> result = new ArrayList<>();
for (DataDirectory dataDirectory : dataDirectories)
{
File ksDir = new File(dataDirectory.location, ksName);
File[] cfDirs = ksDir.listFiles();
if (cfDirs == null)
continue;
for (File cfDir : cfDirs)
{
if (cfDir.isDirectory())
result.add(cfDir);
}
}
return result;
} | [
"public",
"static",
"List",
"<",
"File",
">",
"getKSChildDirectories",
"(",
"String",
"ksName",
")",
"{",
"List",
"<",
"File",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"DataDirectory",
"dataDirectory",
":",
"dataDirectories",
... | Recursively finds all the sub directories in the KS directory. | [
"Recursively",
"finds",
"all",
"the",
"sub",
"directories",
"in",
"the",
"KS",
"directory",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/Directories.java#L665-L681 |
36,090 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java | AbstractSSTableSimpleWriter.makeFilename | protected static String makeFilename(File directory, final String keyspace, final String columnFamily)
{
final Set<Descriptor> existing = new HashSet<Descriptor>();
directory.list(new FilenameFilter()
{
public boolean accept(File dir, String name)
{
Pair<Descriptor, Component> p = SSTable.tryComponentFromFilename(dir, name);
Descriptor desc = p == null ? null : p.left;
if (desc == null)
return false;
if (desc.cfname.equals(columnFamily))
existing.add(desc);
return false;
}
});
int maxGen = generation.getAndIncrement();
for (Descriptor desc : existing)
{
while (desc.generation > maxGen)
{
maxGen = generation.getAndIncrement();
}
}
return new Descriptor(directory, keyspace, columnFamily, maxGen + 1, Descriptor.Type.TEMP).filenameFor(Component.DATA);
} | java | protected static String makeFilename(File directory, final String keyspace, final String columnFamily)
{
final Set<Descriptor> existing = new HashSet<Descriptor>();
directory.list(new FilenameFilter()
{
public boolean accept(File dir, String name)
{
Pair<Descriptor, Component> p = SSTable.tryComponentFromFilename(dir, name);
Descriptor desc = p == null ? null : p.left;
if (desc == null)
return false;
if (desc.cfname.equals(columnFamily))
existing.add(desc);
return false;
}
});
int maxGen = generation.getAndIncrement();
for (Descriptor desc : existing)
{
while (desc.generation > maxGen)
{
maxGen = generation.getAndIncrement();
}
}
return new Descriptor(directory, keyspace, columnFamily, maxGen + 1, Descriptor.Type.TEMP).filenameFor(Component.DATA);
} | [
"protected",
"static",
"String",
"makeFilename",
"(",
"File",
"directory",
",",
"final",
"String",
"keyspace",
",",
"final",
"String",
"columnFamily",
")",
"{",
"final",
"Set",
"<",
"Descriptor",
">",
"existing",
"=",
"new",
"HashSet",
"<",
"Descriptor",
">",
... | find available generation and pick up filename from that | [
"find",
"available",
"generation",
"and",
"pick",
"up",
"filename",
"from",
"that"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java#L68-L96 |
36,091 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/columniterator/IndexedSliceReader.java | IndexedSliceReader.setToRowStart | private void setToRowStart(RowIndexEntry rowEntry, FileDataInput in) throws IOException
{
if (in == null)
{
this.file = sstable.getFileDataInput(rowEntry.position);
}
else
{
this.file = in;
in.seek(rowEntry.position);
}
sstable.partitioner.decorateKey(ByteBufferUtil.readWithShortLength(file));
} | java | private void setToRowStart(RowIndexEntry rowEntry, FileDataInput in) throws IOException
{
if (in == null)
{
this.file = sstable.getFileDataInput(rowEntry.position);
}
else
{
this.file = in;
in.seek(rowEntry.position);
}
sstable.partitioner.decorateKey(ByteBufferUtil.readWithShortLength(file));
} | [
"private",
"void",
"setToRowStart",
"(",
"RowIndexEntry",
"rowEntry",
",",
"FileDataInput",
"in",
")",
"throws",
"IOException",
"{",
"if",
"(",
"in",
"==",
"null",
")",
"{",
"this",
".",
"file",
"=",
"sstable",
".",
"getFileDataInput",
"(",
"rowEntry",
".",
... | Sets the seek position to the start of the row for column scanning. | [
"Sets",
"the",
"seek",
"position",
"to",
"the",
"start",
"of",
"the",
"row",
"for",
"column",
"scanning",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/columniterator/IndexedSliceReader.java#L103-L115 |
36,092 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/cql3/ColumnCondition.java | ColumnCondition.collectMarkerSpecification | public void collectMarkerSpecification(VariableSpecifications boundNames)
{
if (collectionElement != null)
collectionElement.collectMarkerSpecification(boundNames);
if (operator.equals(Operator.IN) && inValues != null)
{
for (Term value : inValues)
value.collectMarkerSpecification(boundNames);
}
else
{
value.collectMarkerSpecification(boundNames);
}
} | java | public void collectMarkerSpecification(VariableSpecifications boundNames)
{
if (collectionElement != null)
collectionElement.collectMarkerSpecification(boundNames);
if (operator.equals(Operator.IN) && inValues != null)
{
for (Term value : inValues)
value.collectMarkerSpecification(boundNames);
}
else
{
value.collectMarkerSpecification(boundNames);
}
} | [
"public",
"void",
"collectMarkerSpecification",
"(",
"VariableSpecifications",
"boundNames",
")",
"{",
"if",
"(",
"collectionElement",
"!=",
"null",
")",
"collectionElement",
".",
"collectMarkerSpecification",
"(",
"boundNames",
")",
";",
"if",
"(",
"operator",
".",
... | Collects the column specification for the bind variables of this operation.
@param boundNames the list of column specification where to collect the
bind variables of this term in. | [
"Collects",
"the",
"column",
"specification",
"for",
"the",
"bind",
"variables",
"of",
"this",
"operation",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cql3/ColumnCondition.java#L105-L119 |
36,093 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/streaming/DefaultConnectionFactory.java | DefaultConnectionFactory.createConnection | public Socket createConnection(InetAddress peer) throws IOException
{
int attempts = 0;
while (true)
{
try
{
Socket socket = OutboundTcpConnectionPool.newSocket(peer);
socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
socket.setKeepAlive(true);
return socket;
}
catch (IOException e)
{
if (++attempts >= MAX_CONNECT_ATTEMPTS)
throw e;
long waitms = DatabaseDescriptor.getRpcTimeout() * (long)Math.pow(2, attempts);
logger.warn("Failed attempt " + attempts + " to connect to " + peer + ". Retrying in " + waitms + " ms. (" + e + ")");
try
{
Thread.sleep(waitms);
}
catch (InterruptedException wtf)
{
throw new IOException("interrupted", wtf);
}
}
}
} | java | public Socket createConnection(InetAddress peer) throws IOException
{
int attempts = 0;
while (true)
{
try
{
Socket socket = OutboundTcpConnectionPool.newSocket(peer);
socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
socket.setKeepAlive(true);
return socket;
}
catch (IOException e)
{
if (++attempts >= MAX_CONNECT_ATTEMPTS)
throw e;
long waitms = DatabaseDescriptor.getRpcTimeout() * (long)Math.pow(2, attempts);
logger.warn("Failed attempt " + attempts + " to connect to " + peer + ". Retrying in " + waitms + " ms. (" + e + ")");
try
{
Thread.sleep(waitms);
}
catch (InterruptedException wtf)
{
throw new IOException("interrupted", wtf);
}
}
}
} | [
"public",
"Socket",
"createConnection",
"(",
"InetAddress",
"peer",
")",
"throws",
"IOException",
"{",
"int",
"attempts",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"Socket",
"socket",
"=",
"OutboundTcpConnectionPool",
".",
"newSocket",
"(",
... | Connect to peer and start exchanging message.
When connect attempt fails, this retries for maximum of MAX_CONNECT_ATTEMPTS times.
@param peer the peer to connect to.
@return the created socket.
@throws IOException when connection failed. | [
"Connect",
"to",
"peer",
"and",
"start",
"exchanging",
"message",
".",
"When",
"connect",
"attempt",
"fails",
"this",
"retries",
"for",
"maximum",
"of",
"MAX_CONNECT_ATTEMPTS",
"times",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/streaming/DefaultConnectionFactory.java#L45-L74 |
36,094 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/MerkleTree.java | MerkleTree.init | public void init()
{
// determine the depth to which we can safely split the tree
byte sizedepth = (byte)(Math.log10(maxsize) / Math.log10(2));
byte depth = (byte)Math.min(sizedepth, hashdepth);
root = initHelper(fullRange.left, fullRange.right, (byte)0, depth);
size = (long)Math.pow(2, depth);
} | java | public void init()
{
// determine the depth to which we can safely split the tree
byte sizedepth = (byte)(Math.log10(maxsize) / Math.log10(2));
byte depth = (byte)Math.min(sizedepth, hashdepth);
root = initHelper(fullRange.left, fullRange.right, (byte)0, depth);
size = (long)Math.pow(2, depth);
} | [
"public",
"void",
"init",
"(",
")",
"{",
"// determine the depth to which we can safely split the tree",
"byte",
"sizedepth",
"=",
"(",
"byte",
")",
"(",
"Math",
".",
"log10",
"(",
"maxsize",
")",
"/",
"Math",
".",
"log10",
"(",
"2",
")",
")",
";",
"byte",
... | Initializes this tree by splitting it until hashdepth is reached,
or until an additional level of splits would violate maxsize.
NB: Replaces all nodes in the tree. | [
"Initializes",
"this",
"tree",
"by",
"splitting",
"it",
"until",
"hashdepth",
"is",
"reached",
"or",
"until",
"an",
"additional",
"level",
"of",
"splits",
"would",
"violate",
"maxsize",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/MerkleTree.java#L167-L175 |
36,095 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/MerkleTree.java | MerkleTree.get | public TreeRange get(Token t)
{
return getHelper(root, fullRange.left, fullRange.right, (byte)0, t);
} | java | public TreeRange get(Token t)
{
return getHelper(root, fullRange.left, fullRange.right, (byte)0, t);
} | [
"public",
"TreeRange",
"get",
"(",
"Token",
"t",
")",
"{",
"return",
"getHelper",
"(",
"root",
",",
"fullRange",
".",
"left",
",",
"fullRange",
".",
"right",
",",
"(",
"byte",
")",
"0",
",",
"t",
")",
";",
"}"
] | For testing purposes.
Gets the smallest range containing the token. | [
"For",
"testing",
"purposes",
".",
"Gets",
"the",
"smallest",
"range",
"containing",
"the",
"token",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/MerkleTree.java#L320-L323 |
36,096 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/MerkleTree.java | MerkleTree.split | public boolean split(Token t)
{
if (!(size < maxsize))
return false;
try
{
root = splitHelper(root, fullRange.left, fullRange.right, (byte)0, t);
}
catch (StopRecursion.TooDeep e)
{
return false;
}
return true;
} | java | public boolean split(Token t)
{
if (!(size < maxsize))
return false;
try
{
root = splitHelper(root, fullRange.left, fullRange.right, (byte)0, t);
}
catch (StopRecursion.TooDeep e)
{
return false;
}
return true;
} | [
"public",
"boolean",
"split",
"(",
"Token",
"t",
")",
"{",
"if",
"(",
"!",
"(",
"size",
"<",
"maxsize",
")",
")",
"return",
"false",
";",
"try",
"{",
"root",
"=",
"splitHelper",
"(",
"root",
",",
"fullRange",
".",
"left",
",",
"fullRange",
".",
"ri... | Splits the range containing the given token, if no tree limits would be
violated. If the range would be split to a depth below hashdepth, or if
the tree already contains maxsize subranges, this operation will fail.
@return True if the range was successfully split. | [
"Splits",
"the",
"range",
"containing",
"the",
"given",
"token",
"if",
"no",
"tree",
"limits",
"would",
"be",
"violated",
".",
"If",
"the",
"range",
"would",
"be",
"split",
"to",
"a",
"depth",
"below",
"hashdepth",
"or",
"if",
"the",
"tree",
"already",
"... | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/MerkleTree.java#L441-L455 |
36,097 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/JVMStabilityInspector.java | JVMStabilityInspector.inspectThrowable | public static void inspectThrowable(Throwable t)
{
boolean isUnstable = false;
if (t instanceof OutOfMemoryError)
isUnstable = true;
if (DatabaseDescriptor.getDiskFailurePolicy() == Config.DiskFailurePolicy.die)
if (t instanceof FSError || t instanceof CorruptSSTableException)
isUnstable = true;
// Check for file handle exhaustion
if (t instanceof FileNotFoundException || t instanceof SocketException)
if (t.getMessage().contains("Too many open files"))
isUnstable = true;
if (isUnstable)
killer.killCurrentJVM(t);
} | java | public static void inspectThrowable(Throwable t)
{
boolean isUnstable = false;
if (t instanceof OutOfMemoryError)
isUnstable = true;
if (DatabaseDescriptor.getDiskFailurePolicy() == Config.DiskFailurePolicy.die)
if (t instanceof FSError || t instanceof CorruptSSTableException)
isUnstable = true;
// Check for file handle exhaustion
if (t instanceof FileNotFoundException || t instanceof SocketException)
if (t.getMessage().contains("Too many open files"))
isUnstable = true;
if (isUnstable)
killer.killCurrentJVM(t);
} | [
"public",
"static",
"void",
"inspectThrowable",
"(",
"Throwable",
"t",
")",
"{",
"boolean",
"isUnstable",
"=",
"false",
";",
"if",
"(",
"t",
"instanceof",
"OutOfMemoryError",
")",
"isUnstable",
"=",
"true",
";",
"if",
"(",
"DatabaseDescriptor",
".",
"getDiskFa... | Certain Throwables and Exceptions represent "Die" conditions for the server.
@param t
The Throwable to check for server-stop conditions | [
"Certain",
"Throwables",
"and",
"Exceptions",
"represent",
"Die",
"conditions",
"for",
"the",
"server",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/JVMStabilityInspector.java#L48-L65 |
36,098 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/CollationController.java | CollationController.reduceNameFilter | private void reduceNameFilter(QueryFilter filter, ColumnFamily container, long sstableTimestamp)
{
if (container == null)
return;
for (Iterator<CellName> iterator = ((NamesQueryFilter) filter.filter).columns.iterator(); iterator.hasNext(); )
{
CellName filterColumn = iterator.next();
Cell cell = container.getColumn(filterColumn);
if (cell != null && cell.timestamp() > sstableTimestamp)
iterator.remove();
}
} | java | private void reduceNameFilter(QueryFilter filter, ColumnFamily container, long sstableTimestamp)
{
if (container == null)
return;
for (Iterator<CellName> iterator = ((NamesQueryFilter) filter.filter).columns.iterator(); iterator.hasNext(); )
{
CellName filterColumn = iterator.next();
Cell cell = container.getColumn(filterColumn);
if (cell != null && cell.timestamp() > sstableTimestamp)
iterator.remove();
}
} | [
"private",
"void",
"reduceNameFilter",
"(",
"QueryFilter",
"filter",
",",
"ColumnFamily",
"container",
",",
"long",
"sstableTimestamp",
")",
"{",
"if",
"(",
"container",
"==",
"null",
")",
"return",
";",
"for",
"(",
"Iterator",
"<",
"CellName",
">",
"iterator"... | remove columns from @param filter where we already have data in @param container newer than @param sstableTimestamp | [
"remove",
"columns",
"from"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/CollationController.java#L184-L196 |
36,099 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java | CompositesIndex.getIndexComparator | public static CellNameType getIndexComparator(CFMetaData baseMetadata, ColumnDefinition cfDef)
{
if (cfDef.type.isCollection() && cfDef.type.isMultiCell())
{
switch (((CollectionType)cfDef.type).kind)
{
case LIST:
return CompositesIndexOnCollectionValue.buildIndexComparator(baseMetadata, cfDef);
case SET:
return CompositesIndexOnCollectionKey.buildIndexComparator(baseMetadata, cfDef);
case MAP:
return cfDef.hasIndexOption(SecondaryIndex.INDEX_KEYS_OPTION_NAME)
? CompositesIndexOnCollectionKey.buildIndexComparator(baseMetadata, cfDef)
: CompositesIndexOnCollectionValue.buildIndexComparator(baseMetadata, cfDef);
}
}
switch (cfDef.kind)
{
case CLUSTERING_COLUMN:
return CompositesIndexOnClusteringKey.buildIndexComparator(baseMetadata, cfDef);
case REGULAR:
return CompositesIndexOnRegular.buildIndexComparator(baseMetadata, cfDef);
case PARTITION_KEY:
return CompositesIndexOnPartitionKey.buildIndexComparator(baseMetadata, cfDef);
//case COMPACT_VALUE:
// return CompositesIndexOnCompactValue.buildIndexComparator(baseMetadata, cfDef);
}
throw new AssertionError();
} | java | public static CellNameType getIndexComparator(CFMetaData baseMetadata, ColumnDefinition cfDef)
{
if (cfDef.type.isCollection() && cfDef.type.isMultiCell())
{
switch (((CollectionType)cfDef.type).kind)
{
case LIST:
return CompositesIndexOnCollectionValue.buildIndexComparator(baseMetadata, cfDef);
case SET:
return CompositesIndexOnCollectionKey.buildIndexComparator(baseMetadata, cfDef);
case MAP:
return cfDef.hasIndexOption(SecondaryIndex.INDEX_KEYS_OPTION_NAME)
? CompositesIndexOnCollectionKey.buildIndexComparator(baseMetadata, cfDef)
: CompositesIndexOnCollectionValue.buildIndexComparator(baseMetadata, cfDef);
}
}
switch (cfDef.kind)
{
case CLUSTERING_COLUMN:
return CompositesIndexOnClusteringKey.buildIndexComparator(baseMetadata, cfDef);
case REGULAR:
return CompositesIndexOnRegular.buildIndexComparator(baseMetadata, cfDef);
case PARTITION_KEY:
return CompositesIndexOnPartitionKey.buildIndexComparator(baseMetadata, cfDef);
//case COMPACT_VALUE:
// return CompositesIndexOnCompactValue.buildIndexComparator(baseMetadata, cfDef);
}
throw new AssertionError();
} | [
"public",
"static",
"CellNameType",
"getIndexComparator",
"(",
"CFMetaData",
"baseMetadata",
",",
"ColumnDefinition",
"cfDef",
")",
"{",
"if",
"(",
"cfDef",
".",
"type",
".",
"isCollection",
"(",
")",
"&&",
"cfDef",
".",
"type",
".",
"isMultiCell",
"(",
")",
... | Check SecondaryIndex.getIndexComparator if you want to know why this is static | [
"Check",
"SecondaryIndex",
".",
"getIndexComparator",
"if",
"you",
"want",
"to",
"know",
"why",
"this",
"is",
"static"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java#L91-L120 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.