_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20500 | RestAPIUtil.defineDesignDocument | train | public static void defineDesignDocument(CouchbaseMock mock, String designName, String contents, String bucketName) throws IOException {
URL url = getDesignURL(mock, designName, bucketName);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
setAuthHeaders(mock, bucketName, conn);... | java | {
"resource": ""
} |
q20501 | ControlHandler.sendHelpText | train | private static void sendHelpText(HttpResponse response, int code) throws IOException {
HandlerUtil.makeStringResponse(response, MockHelpCommandHandler.getIndentedHelp());
response.setStatusCode(code);
} | java | {
"resource": ""
} |
q20502 | MutationInfoWriter.write | train | public void write(ByteBuffer bb, VBucketCoordinates coords) {
if (!enabled) {
return;
}
bb.putLong(24, coords.getUuid());
bb.putLong(32, coords.getSeqno());
} | java | {
"resource": ""
} |
q20503 | CouchbaseMock.startHarakiriMonitor | train | public void startHarakiriMonitor(InetSocketAddress address, boolean terminate) throws IOException {
if (terminate) {
harakiriMonitor.setTemrinateAction(new Callable() {
@Override
public Object call() throws Exception {
System.exit(1);
... | java | {
"resource": ""
} |
q20504 | CouchbaseMock.createDefaultConfig | train | private static BucketConfiguration createDefaultConfig(String hostname, int numNodes, int bucketStartPort, int numVBuckets, int numReplicas) {
BucketConfiguration defaultConfig = new BucketConfiguration();
defaultConfig.type = BucketType.COUCHBASE;
defaultConfig.hostname = hostname;
defa... | java | {
"resource": ""
} |
q20505 | CouchbaseMock.getCarrierPort | train | public int getCarrierPort(String bucketName) {
Bucket bucket = buckets.get(bucketName);
if (null == bucket) {
// Buckets are created when the mock is started. Calling getCarrierPort()
// before the mock has been started makes no sense.
throw new RuntimeException("Buck... | java | {
"resource": ""
} |
q20506 | CouchbaseMock.createBucket | train | public void createBucket(BucketConfiguration config) throws BucketAlreadyExistsException, IOException {
if (!config.validate()) {
throw new IllegalArgumentException("Invalid bucket configuration");
}
synchronized (buckets) {
if (buckets.containsKey(config.name)) {
... | java | {
"resource": ""
} |
q20507 | CouchbaseMock.removeBucket | train | public void removeBucket(String name) throws FileNotFoundException {
Bucket bucket;
synchronized (buckets) {
if (!buckets.containsKey(name)) {
throw new FileNotFoundException("No such bucket: "+ name);
}
bucket = buckets.remove(name);
}
... | java | {
"resource": ""
} |
q20508 | CouchbaseMock.start | train | private void start(String docsFile, String monitorAddress, boolean useBeerSample) throws IOException {
try {
if (port == 0) {
ServerSocketChannel ch = ServerSocketChannel.open();
ch.socket().bind(new InetSocketAddress(0));
port = ch.socket().getLocalPo... | java | {
"resource": ""
} |
q20509 | Retryer.run | train | public void run() throws Exception {
// Send the initial command:
client.sendRequest(cmd);
long endTime = System.currentTimeMillis() + spec.getMaxDuration();
// Wait until the 'after' time
Thread.sleep(spec.getAfter());
int numAttempts = 0;
long now = System.cu... | java | {
"resource": ""
} |
q20510 | MemcachedConnection.step | train | public void step() throws IOException {
if (closed) {
throw new ClosedChannelException();
}
if (input.position() == header.length) {
if (command == null) {
command = CommandFactory.create(input);
}
if (command.complete()) {
... | java | {
"resource": ""
} |
q20511 | MemcachedConnection.hasOutput | train | boolean hasOutput() {
if (pending == null) {
return false;
}
if (pending.isEmpty()) {
return false;
}
if (!pending.get(0).hasRemaining()) {
return false;
}
return true;
} | java | {
"resource": ""
} |
q20512 | MemcachedConnection.returnOutputContext | train | public void returnOutputContext(OutputContext ctx) {
List<ByteBuffer> remaining = ctx.releaseRemaining();
if (pending == null) {
pending = remaining;
} else {
List<ByteBuffer> tmp = pending;
pending = remaining;
pending.addAll(tmp);
}
} | java | {
"resource": ""
} |
q20513 | MemcachedConnection.setSupportedFeatures | train | void setSupportedFeatures(boolean[] input) {
if (input.length != supportedFeatures.length) {
throw new IllegalArgumentException("Bad features length!");
}
// Scan through all other features and disable them unless they are supported
for (int i = 0; i < input.length; i++) {
... | java | {
"resource": ""
} |
q20514 | OutputContext.getIov | train | public ByteBuffer[] getIov() {
if (buffers.size() == 1) {
singleArray[0] = buffers.get(0);
return singleArray;
}
return buffers.toArray(new ByteBuffer[buffers.size()]);
} | java | {
"resource": ""
} |
q20515 | OutputContext.getSlice | train | public OutputContext getSlice(int limit) {
List<ByteBuffer> newBufs = new LinkedList<ByteBuffer>();
ByteBuffer buf = ByteBuffer.allocate(limit);
Iterator<ByteBuffer> iter = buffers.iterator();
while (iter.hasNext() && buf.position() < buf.limit()) {
ByteBuffer cur = iter.nex... | java | {
"resource": ""
} |
q20516 | OutputContext.updateBytesSent | train | public void updateBytesSent(long num) {
Iterator<ByteBuffer> iter = buffers.iterator();
while (iter.hasNext()) {
ByteBuffer cur = iter.next();
if (cur.hasRemaining()) {
break;
}
iter.remove();
}
} | java | {
"resource": ""
} |
q20517 | OutputContext.releaseRemaining | train | public List<ByteBuffer> releaseRemaining() {
List<ByteBuffer> ret = buffers;
buffers = null;
return ret;
} | java | {
"resource": ""
} |
q20518 | VBucketStore.incrCoords | train | private MutationStatus incrCoords(KeySpec ks) {
final StorageVBucketCoordinates curCoord;
synchronized (vbCoords) {
curCoord = vbCoords[ks.vbId];
}
long seq = curCoord.incrSeqno();
long uuid = curCoord.getUuid();
VBucketCoordinates coord = new BasicVBucketCoo... | java | {
"resource": ""
} |
q20519 | VBucketStore.forceStorageMutation | train | void forceStorageMutation(Item itm, VBucketCoordinates coords) {
forceMutation(itm.getKeySpec().vbId, itm, coords, false);
} | java | {
"resource": ""
} |
q20520 | VBucketStore.forceDeleteMutation | train | void forceDeleteMutation(Item itm, VBucketCoordinates coords) {
forceMutation(itm.getKeySpec().vbId, itm, coords, true);
} | java | {
"resource": ""
} |
q20521 | VBucketStore.convertExpiryTime | train | public static int convertExpiryTime(int original) {
if (original == 0) {
return original;
} else if (original > THIRTY_DAYS) {
return original + (int)Info.getClockOffset();
}
return (int)((new Date().getTime() / 1000) + original + Info.getClockOffset());
} | java | {
"resource": ""
} |
q20522 | JsonUtils.decode | train | public static <T> T decode(String json, Class<T> cls) {
return GSON.fromJson(json, cls);
} | java | {
"resource": ""
} |
q20523 | JsonUtils.decodeAsMap | train | @SuppressWarnings("unchecked")
public static Map<String,Object> decodeAsMap(String json) {
return decode(json, HashMap.class);
} | java | {
"resource": ""
} |
q20524 | QueryResult.rowAt | train | public Map<String,Object> rowAt(int ix) {
return (Map<String,Object>) rows.get(ix);
} | java | {
"resource": ""
} |
q20525 | View.executeRaw | train | public String executeRaw(Iterable<Item> items, Configuration config) throws QueryExecutionException {
if (config == null) {
config = new Configuration();
}
Context cx = Context.enter();
Scriptable scope = cx.initStandardObjects();
NativeObject configObject = config.t... | java | {
"resource": ""
} |
q20526 | StressSettings.getThriftClient | train | public synchronized ThriftClient getThriftClient()
{
if (mode.api != ConnectionAPI.THRIFT_SMART)
return getSimpleThriftClient();
if (tclient == null)
tclient = getSmartThriftClient();
return tclient;
} | java | {
"resource": ""
} |
q20527 | PropertyFileSnitch.getEndpointInfo | train | public String[] getEndpointInfo(InetAddress endpoint)
{
String[] rawEndpointInfo = getRawEndpointInfo(endpoint);
if (rawEndpointInfo == null)
throw new RuntimeException("Unknown host " + endpoint + " with no default configured");
return rawEndpointInfo;
} | java | {
"resource": ""
} |
q20528 | PropertyFileSnitch.getDatacenter | train | public String getDatacenter(InetAddress endpoint)
{
String[] info = getEndpointInfo(endpoint);
assert info != null : "No location defined for endpoint " + endpoint;
return info[0];
} | java | {
"resource": ""
} |
q20529 | PropertyFileSnitch.getRack | train | public String getRack(InetAddress endpoint)
{
String[] info = getEndpointInfo(endpoint);
assert info != null : "No location defined for endpoint " + endpoint;
return info[1];
} | java | {
"resource": ""
} |
q20530 | CassandraStorage.setPartitionFilter | train | public void setPartitionFilter(Expression partitionFilter) throws IOException
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
property.setProperty(PARTITION_FILTER_SIGNATURE, indexExpressionsToString(filterToI... | java | {
"resource": ""
} |
q20531 | CassandraStorage.putNext | train | public void putNext(Tuple t) throws IOException
{
/*
We support two cases for output:
First, the original output:
(key, (name, value), (name,value), {(name,value)}) (tuples or bag is optional)
For supers, we only accept the original output.
*/
if (t.size(... | java | {
"resource": ""
} |
q20532 | CassandraStorage.writeColumnsFromTuple | train | private void writeColumnsFromTuple(ByteBuffer key, Tuple t, int offset) throws IOException
{
ArrayList<Mutation> mutationList = new ArrayList<Mutation>();
for (int i = offset; i < t.size(); i++)
{
if (t.getType(i) == DataType.BAG)
writeColumnsFromBag(key, (DataBag... | java | {
"resource": ""
} |
q20533 | CassandraStorage.mutationFromTuple | train | private Mutation mutationFromTuple(Tuple t) throws IOException
{
Mutation mutation = new Mutation();
if (t.get(1) == null)
{
if (allow_deletes)
{
mutation.deletion = new Deletion();
mutation.deletion.predicate = new org.apache.cassandra... | java | {
"resource": ""
} |
q20534 | CassandraStorage.writeColumnsFromBag | train | private void writeColumnsFromBag(ByteBuffer key, DataBag bag) throws IOException
{
List<Mutation> mutationList = new ArrayList<Mutation>();
for (Tuple pair : bag)
{
Mutation mutation = new Mutation();
if (DataType.findType(pair.get(1)) == DataType.BAG) // supercolumn
... | java | {
"resource": ""
} |
q20535 | CassandraStorage.writeMutations | train | private void writeMutations(ByteBuffer key, List<Mutation> mutations) throws IOException
{
try
{
writer.write(key, mutations);
}
catch (InterruptedException e)
{
throw new IOException(e);
}
} | java | {
"resource": ""
} |
q20536 | CassandraStorage.filterToIndexExpressions | train | private List<IndexExpression> filterToIndexExpressions(Expression expression) throws IOException
{
List<IndexExpression> indexExpressions = new ArrayList<IndexExpression>();
Expression.BinaryExpression be = (Expression.BinaryExpression)expression;
ByteBuffer name = ByteBuffer.wrap(be.getLhs(... | java | {
"resource": ""
} |
q20537 | CassandraStorage.indexExpressionsToString | train | private static String indexExpressionsToString(List<IndexExpression> indexExpressions) throws IOException
{
assert indexExpressions != null;
// oh, you thought cfdefToString was awful?
IndexClause indexClause = new IndexClause();
indexClause.setExpressions(indexExpressions);
... | java | {
"resource": ""
} |
q20538 | CassandraStorage.indexExpressionsFromString | train | private static List<IndexExpression> indexExpressionsFromString(String ie) throws IOException
{
assert ie != null;
TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
IndexClause indexClause = new IndexClause();
try
{
deserializer.deseri... | java | {
"resource": ""
} |
q20539 | CassandraStorage.getIndexExpressions | train | private List<IndexExpression> getIndexExpressions() throws IOException
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
if (property.getProperty(PARTITION_FILTER_SIGNATURE) != null)
return indexExpr... | java | {
"resource": ""
} |
q20540 | CassandraStorage.getColumnMetadata | train | protected List<ColumnDef> getColumnMetadata(Cassandra.Client client)
throws TException, CharacterCodingException, InvalidRequestException, ConfigurationException
{
return getColumnMeta(client, true, true);
} | java | {
"resource": ""
} |
q20541 | CassandraStorage.keyToTuple | train | private Tuple keyToTuple(ByteBuffer key, CfDef cfDef, AbstractType comparator) throws IOException
{
Tuple tuple = TupleFactory.getInstance().newTuple(1);
addKeyToTuple(tuple, key, cfDef, comparator);
return tuple;
} | java | {
"resource": ""
} |
q20542 | CassandraStorage.addKeyToTuple | train | private void addKeyToTuple(Tuple tuple, ByteBuffer key, CfDef cfDef, AbstractType comparator) throws IOException
{
if( comparator instanceof AbstractCompositeType )
{
setTupleValue(tuple, 0, composeComposite((AbstractCompositeType)comparator,key));
}
else
{
... | java | {
"resource": ""
} |
q20543 | DeletionInfo.rangeIterator | train | public Iterator<RangeTombstone> rangeIterator()
{
return ranges == null ? Iterators.<RangeTombstone>emptyIterator() : ranges.iterator();
} | java | {
"resource": ""
} |
q20544 | BooleanConditionBuilder.must | train | public BooleanConditionBuilder must(ConditionBuilder... conditionBuilders) {
if (must == null) {
must = new ArrayList<>(conditionBuilders.length);
}
for (ConditionBuilder conditionBuilder : conditionBuilders) {
must.add(conditionBuilder.build());
}
return ... | java | {
"resource": ""
} |
q20545 | BooleanConditionBuilder.should | train | public BooleanConditionBuilder should(ConditionBuilder... conditionBuilders) {
if (should == null) {
should = new ArrayList<>(conditionBuilders.length);
}
for (ConditionBuilder conditionBuilder : conditionBuilders) {
should.add(conditionBuilder.build());
}
... | java | {
"resource": ""
} |
q20546 | BooleanConditionBuilder.not | train | public BooleanConditionBuilder not(ConditionBuilder... conditionBuilders) {
if (not == null) {
not = new ArrayList<>(conditionBuilders.length);
}
for (ConditionBuilder conditionBuilder : conditionBuilders) {
not.add(conditionBuilder.build());
}
return this... | java | {
"resource": ""
} |
q20547 | Schema.load | train | public Schema load(KSMetaData keyspaceDef)
{
for (CFMetaData cfm : keyspaceDef.cfMetaData().values())
load(cfm);
setKeyspaceDefinition(keyspaceDef);
return this;
} | java | {
"resource": ""
} |
q20548 | Schema.storeKeyspaceInstance | train | public void storeKeyspaceInstance(Keyspace keyspace)
{
if (keyspaceInstances.containsKey(keyspace.getName()))
throw new IllegalArgumentException(String.format("Keyspace %s was already initialized.", keyspace.getName()));
keyspaceInstances.put(keyspace.getName(), keyspace);
} | java | {
"resource": ""
} |
q20549 | Schema.getCFMetaData | train | public CFMetaData getCFMetaData(String keyspaceName, String cfName)
{
assert keyspaceName != null;
KSMetaData ksm = keyspaces.get(keyspaceName);
return (ksm == null) ? null : ksm.cfMetaData().get(cfName);
} | java | {
"resource": ""
} |
q20550 | Schema.getCFMetaData | train | public CFMetaData getCFMetaData(UUID cfId)
{
Pair<String,String> cf = getCF(cfId);
return (cf == null) ? null : getCFMetaData(cf.left, cf.right);
} | java | {
"resource": ""
} |
q20551 | Schema.getKeyspaceMetaData | train | public Map<String, CFMetaData> getKeyspaceMetaData(String keyspaceName)
{
assert keyspaceName != null;
KSMetaData ksm = keyspaces.get(keyspaceName);
assert ksm != null;
return ksm.cfMetaData();
} | java | {
"resource": ""
} |
q20552 | Schema.purge | train | public void purge(CFMetaData cfm)
{
cfIdMap.remove(Pair.create(cfm.ksName, cfm.cfName));
cfm.markPurged();
} | java | {
"resource": ""
} |
q20553 | Schema.updateVersion | train | public void updateVersion()
{
try
{
MessageDigest versionDigest = MessageDigest.getInstance("MD5");
for (Row row : SystemKeyspace.serializedSchema())
{
if (invalidSchemaRow(row) || ignoredSchemaRow(row))
continue;
... | java | {
"resource": ""
} |
q20554 | WaitQueue.signal | train | public boolean signal()
{
if (!hasWaiters())
return false;
while (true)
{
RegisteredSignal s = queue.poll();
if (s == null || s.signal() != null)
return s != null;
}
} | java | {
"resource": ""
} |
q20555 | WaitQueue.signalAll | train | public void signalAll()
{
if (!hasWaiters())
return;
// to avoid a race where the condition is not met and the woken thread managed to wait on the queue before
// we finish signalling it all, we pick a random thread we have woken-up and hold onto it, so that if we encounter
... | java | {
"resource": ""
} |
q20556 | WaitQueue.getWaiting | train | public int getWaiting()
{
if (!hasWaiters())
return 0;
Iterator<RegisteredSignal> iter = queue.iterator();
int count = 0;
while (iter.hasNext())
{
Signal next = iter.next();
if (!next.isCancelled())
count++;
}
... | java | {
"resource": ""
} |
q20557 | Refs.releaseIfHolds | train | public boolean releaseIfHolds(T referenced)
{
Ref ref = references.remove(referenced);
if (ref != null)
ref.release();
return ref != null;
} | java | {
"resource": ""
} |
q20558 | Refs.release | train | public void release(Collection<T> release)
{
List<Ref<T>> refs = new ArrayList<>();
List<T> notPresent = null;
for (T obj : release)
{
Ref<T> ref = references.remove(obj);
if (ref == null)
{
if (notPresent == null)
... | java | {
"resource": ""
} |
q20559 | Refs.tryRef | train | public boolean tryRef(T t)
{
Ref<T> ref = t.tryRef();
if (ref == null)
return false;
ref = references.put(t, ref);
if (ref != null)
ref.release(); // release dup
return true;
} | java | {
"resource": ""
} |
q20560 | Refs.addAll | train | public Refs<T> addAll(Refs<T> add)
{
List<Ref<T>> overlap = new ArrayList<>();
for (Map.Entry<T, Ref<T>> e : add.references.entrySet())
{
if (this.references.containsKey(e.getKey()))
overlap.add(e.getValue());
else
this.references.put(e... | java | {
"resource": ""
} |
q20561 | Refs.tryRef | train | public static <T extends RefCounted<T>> Refs<T> tryRef(Iterable<T> reference)
{
HashMap<T, Ref<T>> refs = new HashMap<>();
for (T rc : reference)
{
Ref<T> ref = rc.tryRef();
if (ref == null)
{
release(refs.values());
return ... | java | {
"resource": ""
} |
q20562 | CommitLogSegmentManager.allocate | train | public Allocation allocate(Mutation mutation, int size)
{
CommitLogSegment segment = allocatingFrom();
Allocation alloc;
while ( null == (alloc = segment.allocate(mutation, size)) )
{
// failed to allocate, so move to a new segment with enough room
advanceAll... | java | {
"resource": ""
} |
q20563 | CommitLogSegmentManager.allocatingFrom | train | CommitLogSegment allocatingFrom()
{
CommitLogSegment r = allocatingFrom;
if (r == null)
{
advanceAllocatingFrom(null);
r = allocatingFrom;
}
return r;
} | java | {
"resource": ""
} |
q20564 | CommitLogSegmentManager.advanceAllocatingFrom | train | private void advanceAllocatingFrom(CommitLogSegment old)
{
while (true)
{
CommitLogSegment next;
synchronized (this)
{
// do this in a critical section so we can atomically remove from availableSegments and add to allocatingFrom/activeSegments
... | java | {
"resource": ""
} |
q20565 | CommitLogSegmentManager.forceRecycleAll | train | void forceRecycleAll(Iterable<UUID> droppedCfs)
{
List<CommitLogSegment> segmentsToRecycle = new ArrayList<>(activeSegments);
CommitLogSegment last = segmentsToRecycle.get(segmentsToRecycle.size() - 1);
advanceAllocatingFrom(last);
// wait for the commit log modifications
la... | java | {
"resource": ""
} |
q20566 | CommitLogSegmentManager.recycleSegment | train | void recycleSegment(final CommitLogSegment segment)
{
boolean archiveSuccess = CommitLog.instance.archiver.maybeWaitForArchiving(segment.getName());
activeSegments.remove(segment);
if (!archiveSuccess)
{
// if archiving (command) was not successful then leave the file alo... | java | {
"resource": ""
} |
q20567 | CommitLogSegmentManager.recycleSegment | train | void recycleSegment(final File file)
{
if (isCapExceeded()
|| CommitLogDescriptor.fromFileName(file.getName()).getMessagingVersion() != MessagingService.current_version)
{
// (don't decrease managed size, since this was never a "live" segment)
logger.debug("(Unope... | java | {
"resource": ""
} |
q20568 | CommitLogSegmentManager.discardSegment | train | private void discardSegment(final CommitLogSegment segment, final boolean deleteFile)
{
logger.debug("Segment {} is no longer active and will be deleted {}", segment, deleteFile ? "now" : "by the archive script");
size.addAndGet(-DatabaseDescriptor.getCommitLogSegmentSize());
segmentManagem... | java | {
"resource": ""
} |
q20569 | CommitLogSegmentManager.resetUnsafe | train | public void resetUnsafe()
{
logger.debug("Closing and clearing existing commit log segments...");
while (!segmentManagementTasks.isEmpty())
Thread.yield();
for (CommitLogSegment segment : activeSegments)
segment.close();
activeSegments.clear();
for ... | java | {
"resource": ""
} |
q20570 | BloomCalculations.computeBloomSpec | train | public static BloomSpecification computeBloomSpec(int bucketsPerElement)
{
assert bucketsPerElement >= 1;
assert bucketsPerElement <= probs.length - 1;
return new BloomSpecification(optKPerBuckets[bucketsPerElement], bucketsPerElement);
} | java | {
"resource": ""
} |
q20571 | BloomCalculations.maxBucketsPerElement | train | public static int maxBucketsPerElement(long numElements)
{
numElements = Math.max(1, numElements);
double v = (Long.MAX_VALUE - EXCESS) / (double)numElements;
if (v < 1.0)
{
throw new UnsupportedOperationException("Cannot compute probabilities for " + numElements + " elem... | java | {
"resource": ""
} |
q20572 | PropertyDefinitions.getBoolean | train | public Boolean getBoolean(String key, Boolean defaultValue) throws SyntaxException
{
String value = getSimple(key);
return (value == null) ? defaultValue : value.toLowerCase().matches("(1|true|yes)");
} | java | {
"resource": ""
} |
q20573 | PropertyDefinitions.getDouble | train | public Double getDouble(String key, Double defaultValue) throws SyntaxException
{
String value = getSimple(key);
if (value == null)
{
return defaultValue;
}
else
{
try
{
return Double.valueOf(value);
}
... | java | {
"resource": ""
} |
q20574 | PropertyDefinitions.getInt | train | public Integer getInt(String key, Integer defaultValue) throws SyntaxException
{
String value = getSimple(key);
return toInt(key, value, defaultValue);
} | java | {
"resource": ""
} |
q20575 | ReplayPosition.getReplayPosition | train | public static ReplayPosition getReplayPosition(Iterable<? extends SSTableReader> sstables)
{
if (Iterables.isEmpty(sstables))
return NONE;
Function<SSTableReader, ReplayPosition> f = new Function<SSTableReader, ReplayPosition>()
{
public ReplayPosition apply(SSTableR... | java | {
"resource": ""
} |
q20576 | MemtableAllocator.setDiscarding | train | public void setDiscarding()
{
state = state.transition(LifeCycle.DISCARDING);
// mark the memory owned by this allocator as reclaiming
onHeap.markAllReclaiming();
offHeap.markAllReclaiming();
} | java | {
"resource": ""
} |
q20577 | KeyspaceMetrics.createKeyspaceGauge | train | private <T extends Number> Gauge<Long> createKeyspaceGauge(String name, final MetricValue extractor)
{
allMetrics.add(name);
return Metrics.newGauge(factory.createMetricName(name), new Gauge<Long>()
{
public Long value()
{
long sum = 0;
... | java | {
"resource": ""
} |
q20578 | Murmur3Partitioner.getToken | train | public LongToken getToken(ByteBuffer key)
{
if (key.remaining() == 0)
return MINIMUM;
long[] hash = new long[2];
MurmurHash.hash3_x64_128(key, key.position(), key.remaining(), 0, hash);
return new LongToken(normalize(hash[0]));
} | java | {
"resource": ""
} |
q20579 | OrderPreservingPartitioner.bigForString | train | private static BigInteger bigForString(String str, int sigchars)
{
assert str.length() <= sigchars;
BigInteger big = BigInteger.ZERO;
for (int i = 0; i < str.length(); i++)
{
int charpos = 16 * (sigchars - (i + 1));
BigInteger charbig = BigInteger.valueOf(str... | java | {
"resource": ""
} |
q20580 | PasswordAuthenticator.setupDefaultUser | train | private void setupDefaultUser()
{
try
{
// insert the default superuser if AUTH_KS.CREDENTIALS_CF is empty.
if (!hasExistingUsers())
{
process(String.format("INSERT INTO %s.%s (username, salted_hash) VALUES ('%s', '%s') USING TIMESTAMP 0",
... | java | {
"resource": ""
} |
q20581 | StreamReceiveTask.received | train | public synchronized void received(SSTableWriter sstable)
{
if (done)
return;
assert cfId.equals(sstable.metadata.cfId);
sstables.add(sstable);
if (sstables.size() == totalFiles)
{
done = true;
executor.submit(new OnCompletionRunnable(this... | java | {
"resource": ""
} |
q20582 | Path.find | train | <V> void find(Object[] node, Comparator<V> comparator, Object target, Op mode, boolean forwards)
{
// TODO : should not require parameter 'forwards' - consider modifying index to represent both
// child and key position, as opposed to just key position (which necessitates a different value depending... | java | {
"resource": ""
} |
q20583 | Path.successor | train | void successor()
{
Object[] node = currentNode();
int i = currentIndex();
if (!isLeaf(node))
{
// if we're on a key in a branch, we MUST have a descendant either side of us,
// so we always go down the left-most child until we hit a leaf
node = (O... | java | {
"resource": ""
} |
q20584 | AbstractCassandraStorage.composeComposite | train | protected Tuple composeComposite(AbstractCompositeType comparator, ByteBuffer name) throws IOException
{
List<CompositeComponent> result = comparator.deconstruct(name);
Tuple t = TupleFactory.getInstance().newTuple(result.size());
for (int i=0; i<result.size(); i++)
setTupleValue... | java | {
"resource": ""
} |
q20585 | AbstractCassandraStorage.columnToTuple | train | protected Tuple columnToTuple(Cell col, CfInfo cfInfo, AbstractType comparator) throws IOException
{
CfDef cfDef = cfInfo.cfDef;
Tuple pair = TupleFactory.getInstance().newTuple(2);
ByteBuffer colName = col.name().toByteBuffer();
// name
if(comparator instanceof AbstractCom... | java | {
"resource": ""
} |
q20586 | AbstractCassandraStorage.getCfInfo | train | protected CfInfo getCfInfo(String signature) throws IOException
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
String prop = property.getProperty(signature);
CfInfo cfInfo = new CfInfo();
cfIn... | java | {
"resource": ""
} |
q20587 | AbstractCassandraStorage.getDefaultMarshallers | train | protected Map<MarshallerType, AbstractType> getDefaultMarshallers(CfDef cfDef) throws IOException
{
Map<MarshallerType, AbstractType> marshallers = new EnumMap<MarshallerType, AbstractType>(MarshallerType.class);
AbstractType comparator;
AbstractType subcomparator;
AbstractType defau... | java | {
"resource": ""
} |
q20588 | AbstractCassandraStorage.getValidatorMap | train | protected Map<ByteBuffer, AbstractType> getValidatorMap(CfDef cfDef) throws IOException
{
Map<ByteBuffer, AbstractType> validators = new HashMap<ByteBuffer, AbstractType>();
for (ColumnDef cd : cfDef.getColumn_metadata())
{
if (cd.getValidation_class() != null && !cd.getValidatio... | java | {
"resource": ""
} |
q20589 | AbstractCassandraStorage.parseType | train | protected AbstractType parseType(String type) throws IOException
{
try
{
// always treat counters like longs, specifically CCT.compose is not what we need
if (type != null && type.equals("org.apache.cassandra.db.marshal.CounterColumnType"))
return LongType... | java | {
"resource": ""
} |
q20590 | AbstractCassandraStorage.getQueryMap | train | public static Map<String, String> getQueryMap(String query) throws UnsupportedEncodingException
{
String[] params = query.split("&");
Map<String, String> map = new HashMap<String, String>();
for (String param : params)
{
String[] keyValue = param.split("=");
... | java | {
"resource": ""
} |
q20591 | AbstractCassandraStorage.getPigType | train | protected byte getPigType(AbstractType type)
{
if (type instanceof LongType || type instanceof DateType || type instanceof TimestampType) // DateType is bad and it should feel bad
return DataType.LONG;
else if (type instanceof IntegerType || type instanceof Int32Type) // IntegerType will... | java | {
"resource": ""
} |
q20592 | AbstractCassandraStorage.objToBB | train | protected ByteBuffer objToBB(Object o)
{
if (o == null)
return nullToBB();
if (o instanceof java.lang.String)
return ByteBuffer.wrap(new DataByteArray((String)o).get());
if (o instanceof Integer)
return Int32Type.instance.decompose((Integer)o);
if ... | java | {
"resource": ""
} |
q20593 | AbstractCassandraStorage.initSchema | train | protected void initSchema(String signature) throws IOException
{
Properties properties = UDFContext.getUDFContext().getUDFProperties(AbstractCassandraStorage.class);
// Only get the schema if we haven't already gotten it
if (!properties.containsKey(signature))
{
try
... | java | {
"resource": ""
} |
q20594 | AbstractCassandraStorage.cfdefToString | train | protected static String cfdefToString(CfDef cfDef) throws IOException
{
assert cfDef != null;
// this is so awful it's kind of cool!
TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
try
{
return Hex.bytesToHex(serializer.serialize(cfDef));
... | java | {
"resource": ""
} |
q20595 | AbstractCassandraStorage.cfdefFromString | train | protected static CfDef cfdefFromString(String st) throws IOException
{
assert st != null;
TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
CfDef cfDef = new CfDef();
try
{
deserializer.deserialize(cfDef, Hex.hexToBytes(st));
}... | java | {
"resource": ""
} |
q20596 | AbstractCassandraStorage.getCfInfo | train | protected CfInfo getCfInfo(Cassandra.Client client)
throws InvalidRequestException,
UnavailableException,
TimedOutException,
SchemaDisagreementException,
TException,
NotFoundException,
org.apach... | java | {
"resource": ""
} |
q20597 | AbstractCassandraStorage.getColumnMeta | train | protected List<ColumnDef> getColumnMeta(Cassandra.Client client, boolean cassandraStorage, boolean includeCompactValueColumn)
throws InvalidRequestException,
UnavailableException,
TimedOutException,
SchemaDisagreementException,
TException,
Characte... | java | {
"resource": ""
} |
q20598 | AbstractCassandraStorage.getIndexType | train | protected IndexType getIndexType(String type)
{
type = type.toLowerCase();
if ("keys".equals(type))
return IndexType.KEYS;
else if("custom".equals(type))
return IndexType.CUSTOM;
else if("composites".equals(type))
return IndexType.COMPOSITES;
... | java | {
"resource": ""
} |
q20599 | AbstractCassandraStorage.getPartitionKeys | train | public String[] getPartitionKeys(String location, Job job) throws IOException
{
if (!usePartitionFilter)
return null;
List<ColumnDef> indexes = getIndexes();
String[] partitionKeys = new String[indexes.size()];
for (int i = 0; i < indexes.size(); i++)
{
... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.