_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q165800 | PropertyModelBuilder.readAnnotations | validation | public PropertyModelBuilder<T> readAnnotations(final List<Annotation> annotations) {
this.readAnnotations = unmodifiableList(notNull("annotations", annotations));
return this;
} | java | {
"resource": ""
} |
q165801 | IndexHelper.getIndexNames | validation | public static List<String> getIndexNames(final List<IndexModel> indexes, final CodecRegistry codecRegistry) {
List<String> indexNames = new ArrayList<String>(indexes.size());
for (IndexModel index : indexes) {
String name = index.getOptions().getName();
if (name != null) {
indexNames.add(name);
} else {
indexNames.add(IndexHelper.generateIndexName(index.getKeys().toBsonDocument(BsonDocument.class, codecRegistry)));
}
}
return indexNames;
} | java | {
"resource": ""
} |
q165802 | IndexHelper.generateIndexName | validation | public static String generateIndexName(final BsonDocument index) {
StringBuilder indexName = new StringBuilder();
for (final String keyNames : index.keySet()) {
if (indexName.length() != 0) {
indexName.append('_');
}
indexName.append(keyNames).append('_');
BsonValue ascOrDescValue = index.get(keyNames);
if (ascOrDescValue instanceof BsonNumber) {
indexName.append(((BsonNumber) ascOrDescValue).intValue());
} else if (ascOrDescValue instanceof BsonString) {
indexName.append(((BsonString) ascOrDescValue).getValue().replace(' ', '_'));
}
}
return indexName.toString();
} | java | {
"resource": ""
} |
q165803 | GridFSFile.validate | validation | @Deprecated
public void validate() {
if (fs == null) {
throw new MongoException("no fs");
}
if (md5 == null) {
throw new MongoException("no md5 stored");
}
DBObject cmd = new BasicDBObject("filemd5", id);
cmd.put("root", fs.getBucketName());
DBObject res = fs.getDB().command(cmd);
if (res != null && res.containsField("md5")) {
String m = res.get("md5").toString();
if (m.equals(md5)) {
return;
}
throw new MongoException("md5 differ. mine [" + md5 + "] theirs [" + m + "]");
}
// no md5 from the server
throw new MongoException("no md5 returned from server: " + res);
} | java | {
"resource": ""
} |
q165804 | BsonTypeCodecMap.get | validation | public Codec<?> get(final BsonType bsonType) {
Codec<?> codec = codecs[bsonType.getValue()];
if (codec == null) {
Class<?> clazz = bsonTypeClassMap.get(bsonType);
if (clazz == null) {
throw new CodecConfigurationException(format("No class mapped for BSON type %s.", bsonType));
} else {
throw new CodecConfigurationException(format("Can't find a codec for %s.", clazz));
}
}
return codec;
} | java | {
"resource": ""
} |
q165805 | MongoIterableSubscription.calculateBatchSize | validation | private int calculateBatchSize() {
Integer batchSize = mongoIterable.getBatchSize();
if (batchSize != null) {
return batchSize;
}
long requested = getRequested();
if (requested <= 1) {
return 2;
} else if (requested < Integer.MAX_VALUE) {
return (int) requested;
} else {
return Integer.MAX_VALUE;
}
} | java | {
"resource": ""
} |
q165806 | UnsignedLongs.parse | validation | public static long parse(final String string) {
if (string.length() == 0) {
throw new NumberFormatException("empty string");
}
int radix = 10;
int maxSafePos = MAX_SAFE_DIGITS[radix] - 1;
long value = 0;
for (int pos = 0; pos < string.length(); pos++) {
int digit = Character.digit(string.charAt(pos), radix);
if (digit == -1) {
throw new NumberFormatException(string);
}
if (pos > maxSafePos && overflowInParse(value, digit, radix)) {
throw new NumberFormatException("Too large for unsigned long: " + string);
}
value = (value * radix) + digit;
}
return value;
} | java | {
"resource": ""
} |
q165807 | DecoderContext.decodeWithChildContext | validation | public <T> T decodeWithChildContext(final Decoder<T> decoder, final BsonReader reader) {
return decoder.decode(reader, DEFAULT_CONTEXT);
} | java | {
"resource": ""
} |
q165808 | AbstractBsonWriter.checkState | validation | protected boolean checkState(final State[] validStates) {
for (final State cur : validStates) {
if (cur == getState()) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q165809 | AbstractBsonWriter.pipe | validation | public void pipe(final BsonReader reader, final List<BsonElement> extraElements) {
notNull("reader", reader);
notNull("extraElements", extraElements);
pipeDocument(reader, extraElements);
} | java | {
"resource": ""
} |
q165810 | AbstractBsonWriter.pipeExtraElements | validation | protected void pipeExtraElements(final List<BsonElement> extraElements) {
notNull("extraElements", extraElements);
for (BsonElement cur : extraElements) {
writeName(cur.getName());
pipeValue(cur.getValue());
}
} | java | {
"resource": ""
} |
q165811 | ObjectId.toByteArray | validation | public byte[] toByteArray() {
ByteBuffer buffer = ByteBuffer.allocate(OBJECT_ID_LENGTH);
putToByteBuffer(buffer);
return buffer.array(); // using .allocate ensures there is a backing array that can be returned
} | java | {
"resource": ""
} |
q165812 | ObjectId.putToByteBuffer | validation | public void putToByteBuffer(final ByteBuffer buffer) {
notNull("buffer", buffer);
isTrueArgument("buffer.remaining() >=12", buffer.remaining() >= OBJECT_ID_LENGTH);
buffer.put(int3(timestamp));
buffer.put(int2(timestamp));
buffer.put(int1(timestamp));
buffer.put(int0(timestamp));
buffer.put(int2(randomValue1));
buffer.put(int1(randomValue1));
buffer.put(int0(randomValue1));
buffer.put(short1(randomValue2));
buffer.put(short0(randomValue2));
buffer.put(int2(counter));
buffer.put(int1(counter));
buffer.put(int0(counter));
} | java | {
"resource": ""
} |
q165813 | ObjectId.toHexString | validation | public String toHexString() {
char[] chars = new char[OBJECT_ID_LENGTH * 2];
int i = 0;
for (byte b : toByteArray()) {
chars[i++] = HEX_CHARS[b >> 4 & 0xF];
chars[i++] = HEX_CHARS[b & 0xF];
}
return new String(chars);
} | java | {
"resource": ""
} |
q165814 | ServerDescription.getShortDescription | validation | public String getShortDescription() {
return "{"
+ "address=" + address
+ ", type=" + type
+ (!tagSet.iterator().hasNext() ? "" : ", " + tagSet)
+ (state == CONNECTED ? (", roundTripTime=" + getRoundTripFormattedInMilliseconds() + " ms") : "")
+ ", state=" + state
+ (exception == null ? "" : ", exception=" + translateExceptionToString())
+ '}';
} | java | {
"resource": ""
} |
q165815 | BasicDBObjectBuilder.start | validation | @SuppressWarnings("unchecked")
public static BasicDBObjectBuilder start(final Map documentAsMap) {
BasicDBObjectBuilder builder = new BasicDBObjectBuilder();
Iterator<Map.Entry> i = documentAsMap.entrySet().iterator();
while (i.hasNext()) {
Map.Entry entry = i.next();
builder.add(entry.getKey().toString(), entry.getValue());
}
return builder;
} | java | {
"resource": ""
} |
q165816 | BasicDBObjectBuilder.push | validation | public BasicDBObjectBuilder push(final String key) {
BasicDBObject o = new BasicDBObject();
_cur().put(key, o);
_stack.addLast(o);
return this;
} | java | {
"resource": ""
} |
q165817 | BulkWriteBatchCombiner.addResult | validation | public void addResult(final BulkWriteResult result, final IndexMap indexMap) {
insertedCount += result.getInsertedCount();
matchedCount += result.getMatchedCount();
deletedCount += result.getDeletedCount();
modifiedCount += result.getModifiedCount();
mergeUpserts(result.getUpserts(), indexMap);
} | java | {
"resource": ""
} |
q165818 | BulkWriteBatchCombiner.addErrorResult | validation | public void addErrorResult(final MongoBulkWriteException exception, final IndexMap indexMap) {
addResult(exception.getWriteResult(), indexMap);
mergeWriteErrors(exception.getWriteErrors(), indexMap);
mergeWriteConcernError(exception.getWriteConcernError());
} | java | {
"resource": ""
} |
q165819 | BulkWriteBatchCombiner.addWriteErrorResult | validation | public void addWriteErrorResult(final BulkWriteError writeError, final IndexMap indexMap) {
notNull("writeError", writeError);
mergeWriteErrors(asList(writeError), indexMap);
} | java | {
"resource": ""
} |
q165820 | BulkWriteBatchCombiner.addErrorResult | validation | public void addErrorResult(final List<BulkWriteError> writeErrors,
final WriteConcernError writeConcernError, final IndexMap indexMap) {
mergeWriteErrors(writeErrors, indexMap);
mergeWriteConcernError(writeConcernError);
} | java | {
"resource": ""
} |
q165821 | BulkWriteBatchCombiner.getError | validation | public MongoBulkWriteException getError() {
return hasErrors() ? new MongoBulkWriteException(createResult(),
new ArrayList<BulkWriteError>(writeErrors),
writeConcernErrors.isEmpty() ? null
: writeConcernErrors.get(writeConcernErrors.size() - 1),
serverAddress) : null;
} | java | {
"resource": ""
} |
q165822 | Node.casNext | validation | private boolean casNext(Node<E> cmp, Node<E> val) {
return compareAndSet(cmp, val);
} | java | {
"resource": ""
} |
q165823 | Node.nextNonmarker | validation | private Node<E> nextNonmarker() {
Node<E> f = getNext();
return (f == null || !f.isMarker()) ? f : f.getNext();
} | java | {
"resource": ""
} |
q165824 | Node.successor | validation | Node<E> successor() {
Node<E> f = nextNonmarker();
for (;;) {
if (f == null)
return null;
if (!f.isDeleted()) {
if (f.getPrev() != this && !isDeleted())
f.setPrev(this); // relink f's prev
return f;
}
Node<E> s = f.nextNonmarker();
if (f == getNext())
casNext(f, s); // unlink f
f = s;
}
} | java | {
"resource": ""
} |
q165825 | Node.predecessor | validation | Node<E> predecessor() {
Node<E> n = this;
for (;;) {
Node<E> b = n.getPrev();
if (b == null)
return n.findPredecessorOf(this);
Node<E> s = b.getNext();
if (s == this)
return b;
if (s == null || !s.isMarker()) {
Node<E> p = b.findPredecessorOf(this);
if (p != null)
return p;
}
n = b;
}
} | java | {
"resource": ""
} |
q165826 | Node.forward | validation | Node<E> forward() {
Node<E> f = successor();
return (f == null || f.isSpecial()) ? null : f;
} | java | {
"resource": ""
} |
q165827 | Node.back | validation | Node<E> back() {
Node<E> f = predecessor();
return (f == null || f.isSpecial()) ? null : f;
} | java | {
"resource": ""
} |
q165828 | Node.append | validation | Node<E> append(E element) {
for (;;) {
Node<E> f = getNext();
if (f == null || f.isMarker())
return null;
Node<E> x = new Node<E>(element, f, this);
if (casNext(f, x)) {
f.setPrev(x); // optimistically link
return x;
}
}
} | java | {
"resource": ""
} |
q165829 | Node.prepend | validation | Node<E> prepend(E element) {
for (;;) {
Node<E> b = predecessor();
if (b == null)
return null;
Node<E> x = new Node<E>(element, this, b);
if (b.casNext(this, x)) {
setPrev(x); // optimistically link
return x;
}
}
} | java | {
"resource": ""
} |
q165830 | Node.delete | validation | boolean delete() {
Node<E> b = getPrev();
Node<E> f = getNext();
if (b != null && f != null && !f.isMarker() &&
casNext(f, new Node<E>(f))) {
if (b.casNext(this, f))
f.setPrev(b);
return true;
}
return false;
} | java | {
"resource": ""
} |
q165831 | Node.replace | validation | Node<E> replace(E newElement) {
for (;;) {
Node<E> b = getPrev();
Node<E> f = getNext();
if (b == null || f == null || f.isMarker())
return null;
Node<E> x = new Node<E>(newElement, f, b);
if (casNext(f, new Node<E>(x))) {
b.successor(); // to relink b
x.successor(); // to relink f
return x;
}
}
} | java | {
"resource": ""
} |
q165832 | FsyncUnlockOperation.execute | validation | @Deprecated
@Override
public BsonDocument execute(final WriteBinding binding) {
return withConnection(binding, new CallableWithConnection<BsonDocument>() {
@Override
public BsonDocument call(final Connection connection) {
if (serverIsAtLeastVersionThreeDotTwo(connection.getDescription())) {
return executeCommand(binding, "admin", FSYNC_UNLOCK_COMMAND, connection);
} else {
return queryUnlock(connection);
}
}
});
} | java | {
"resource": ""
} |
q165833 | ReadPreference.choose | validation | public final List<ServerDescription> choose(final ClusterDescription clusterDescription) {
switch (clusterDescription.getType()) {
case REPLICA_SET:
return chooseForReplicaSet(clusterDescription);
case SHARDED:
case STANDALONE:
return chooseForNonReplicaSet(clusterDescription);
case UNKNOWN:
return Collections.emptyList();
default:
throw new UnsupportedOperationException("Unsupported cluster type: " + clusterDescription.getType());
}
} | java | {
"resource": ""
} |
q165834 | ReadPreference.primaryPreferred | validation | public static ReadPreference primaryPreferred(final long maxStaleness, final TimeUnit timeUnit) {
return new PrimaryPreferredReadPreference(Collections.<TagSet>emptyList(), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165835 | ReadPreference.secondary | validation | public static ReadPreference secondary(final long maxStaleness, final TimeUnit timeUnit) {
return new SecondaryReadPreference(Collections.<TagSet>emptyList(), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165836 | ReadPreference.secondaryPreferred | validation | public static ReadPreference secondaryPreferred(final long maxStaleness, final TimeUnit timeUnit) {
return new SecondaryPreferredReadPreference(Collections.<TagSet>emptyList(), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165837 | ReadPreference.nearest | validation | public static ReadPreference nearest(final long maxStaleness, final TimeUnit timeUnit) {
return new NearestReadPreference(Collections.<TagSet>emptyList(), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165838 | ReadPreference.primaryPreferred | validation | public static TaggableReadPreference primaryPreferred(final TagSet tagSet,
final long maxStaleness, final TimeUnit timeUnit) {
return new PrimaryPreferredReadPreference(singletonList(tagSet), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165839 | ReadPreference.secondary | validation | public static TaggableReadPreference secondary(final TagSet tagSet,
final long maxStaleness, final TimeUnit timeUnit) {
return new SecondaryReadPreference(singletonList(tagSet), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165840 | ReadPreference.secondaryPreferred | validation | public static TaggableReadPreference secondaryPreferred(final TagSet tagSet,
final long maxStaleness, final TimeUnit timeUnit) {
return new SecondaryPreferredReadPreference(singletonList(tagSet), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165841 | ReadPreference.nearest | validation | public static TaggableReadPreference nearest(final TagSet tagSet,
final long maxStaleness, final TimeUnit timeUnit) {
return new NearestReadPreference(singletonList(tagSet), maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165842 | ReadPreference.primaryPreferred | validation | public static TaggableReadPreference primaryPreferred(final List<TagSet> tagSetList,
final long maxStaleness, final TimeUnit timeUnit) {
return new PrimaryPreferredReadPreference(tagSetList, maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165843 | ReadPreference.nearest | validation | public static TaggableReadPreference nearest(final List<TagSet> tagSetList,
final long maxStaleness, final TimeUnit timeUnit) {
return new NearestReadPreference(tagSetList, maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165844 | ReadPreference.valueOf | validation | public static ReadPreference valueOf(final String name) {
notNull("name", name);
String nameToCheck = name.toLowerCase();
if (nameToCheck.equals(PRIMARY.getName().toLowerCase())) {
return PRIMARY;
}
if (nameToCheck.equals(SECONDARY.getName().toLowerCase())) {
return SECONDARY;
}
if (nameToCheck.equals(SECONDARY_PREFERRED.getName().toLowerCase())) {
return SECONDARY_PREFERRED;
}
if (nameToCheck.equals(PRIMARY_PREFERRED.getName().toLowerCase())) {
return PRIMARY_PREFERRED;
}
if (nameToCheck.equals(NEAREST.getName().toLowerCase())) {
return NEAREST;
}
throw new IllegalArgumentException("No match for read preference of " + name);
} | java | {
"resource": ""
} |
q165845 | ReadPreference.valueOf | validation | public static TaggableReadPreference valueOf(final String name, final List<TagSet> tagSetList) {
return valueOf(name, tagSetList, null, MILLISECONDS);
} | java | {
"resource": ""
} |
q165846 | ReadPreference.valueOf | validation | public static TaggableReadPreference valueOf(final String name, final List<TagSet> tagSetList, final long maxStaleness,
final TimeUnit timeUnit) {
return valueOf(name, tagSetList, (Long) maxStaleness, timeUnit);
} | java | {
"resource": ""
} |
q165847 | Bits.readFully | validation | public static void readFully(final InputStream inputStream, final byte[] buffer, final int offset, final int length)
throws IOException {
if (buffer.length < length + offset) {
throw new IllegalArgumentException("Buffer is too small");
}
int arrayOffset = offset;
int bytesToRead = length;
while (bytesToRead > 0) {
int bytesRead = inputStream.read(buffer, arrayOffset, bytesToRead);
if (bytesRead < 0) {
throw new EOFException();
}
bytesToRead -= bytesRead;
arrayOffset += bytesRead;
}
} | java | {
"resource": ""
} |
q165848 | Bits.readInt | validation | public static int readInt(final InputStream inputStream, final byte[] buffer) throws IOException {
readFully(inputStream, buffer, 4);
return readInt(buffer);
} | java | {
"resource": ""
} |
q165849 | Bits.readInt | validation | public static int readInt(final byte[] buffer, final int offset) {
int x = 0;
x |= (0xFF & buffer[offset + 0]) << 0;
x |= (0xFF & buffer[offset + 1]) << 8;
x |= (0xFF & buffer[offset + 2]) << 16;
x |= (0xFF & buffer[offset + 3]) << 24;
return x;
} | java | {
"resource": ""
} |
q165850 | Bits.readIntBE | validation | public static int readIntBE(final byte[] buffer, final int offset) {
int x = 0;
x |= (0xFF & buffer[offset + 0]) << 24;
x |= (0xFF & buffer[offset + 1]) << 16;
x |= (0xFF & buffer[offset + 2]) << 8;
x |= (0xFF & buffer[offset + 3]) << 0;
return x;
} | java | {
"resource": ""
} |
q165851 | Bits.readLong | validation | public static long readLong(final InputStream inputStream, final byte[] buffer) throws IOException {
readFully(inputStream, buffer, 8);
return readLong(buffer);
} | java | {
"resource": ""
} |
q165852 | ConnectionString.getCredentialList | validation | @Deprecated
public List<MongoCredential> getCredentialList() {
return credential != null ? singletonList(credential) : Collections.<MongoCredential>emptyList();
} | java | {
"resource": ""
} |
q165853 | BaseCluster.getRandomServer | validation | private ClusterableServer getRandomServer(final List<ServerDescription> serverDescriptions) {
while (!serverDescriptions.isEmpty()) {
int serverPos = getRandom().nextInt(serverDescriptions.size());
ClusterableServer server = getServer(serverDescriptions.get(serverPos).getAddress());
if (server != null) {
return server;
} else {
serverDescriptions.remove(serverPos);
}
}
return null;
} | java | {
"resource": ""
} |
q165854 | MongoClients.create | validation | public static MongoClient create(final ConnectionString connectionString,
@Nullable final MongoDriverInformation mongoDriverInformation) {
return create(MongoClientSettings.builder().applyConnectionString(connectionString).build(),
mongoDriverInformation, connectionString.getStreamType());
} | java | {
"resource": ""
} |
q165855 | BasicDBList.copy | validation | public Object copy() {
// copy field values into new object
BasicDBList newobj = new BasicDBList();
// need to clone the sub obj
for (int i = 0; i < size(); ++i) {
Object val = get(i);
if (val instanceof BasicDBObject) {
val = ((BasicDBObject) val).copy();
} else if (val instanceof BasicDBList) {
val = ((BasicDBList) val).copy();
}
newobj.add(val);
}
return newobj;
} | java | {
"resource": ""
} |
q165856 | ClassModel.builder | validation | public static <S> ClassModelBuilder<S> builder(final Class<S> type) {
return new ClassModelBuilder<S>(type);
} | java | {
"resource": ""
} |
q165857 | DB.getCollection | validation | public DBCollection getCollection(final String name) {
DBCollection collection = collectionCache.get(name);
if (collection != null) {
return collection;
}
collection = new DBCollection(name, this, executor);
if (mongo.getMongoClientOptions().getDbDecoderFactory() != DefaultDBDecoder.FACTORY) {
collection.setDBDecoderFactory(mongo.getMongoClientOptions().getDbDecoderFactory());
}
if (mongo.getMongoClientOptions().getDbEncoderFactory() != DefaultDBEncoder.FACTORY) {
collection.setDBEncoderFactory(mongo.getMongoClientOptions().getDbEncoderFactory());
}
DBCollection old = collectionCache.putIfAbsent(name, collection);
return old != null ? old : collection;
} | java | {
"resource": ""
} |
q165858 | DB.dropDatabase | validation | public void dropDatabase() {
try {
getExecutor().execute(new DropDatabaseOperation(getName(), getWriteConcern()), getReadConcern());
} catch (MongoWriteConcernException e) {
throw createWriteConcernException(e);
}
} | java | {
"resource": ""
} |
q165859 | DB.getCollectionNames | validation | public Set<String> getCollectionNames() {
List<String> collectionNames =
new MongoIterableImpl<DBObject>(null, executor, ReadConcern.DEFAULT, primary(),
mongo.getMongoClientOptions().getRetryReads()) {
@Override
public ReadOperation<BatchCursor<DBObject>> asReadOperation() {
return new ListCollectionsOperation<DBObject>(name, commandCodec)
.nameOnly(true);
}
}.map(new Function<DBObject, String>() {
@Override
public String apply(final DBObject result) {
return (String) result.get("name");
}
}).into(new ArrayList<String>());
Collections.sort(collectionNames);
return new LinkedHashSet<String>(collectionNames);
} | java | {
"resource": ""
} |
q165860 | DB.command | validation | public CommandResult command(final DBObject command, final ReadPreference readPreference, @Nullable final DBEncoder encoder) {
try {
return executeCommand(wrap(command, encoder), getCommandReadPreference(command, readPreference));
} catch (MongoCommandException ex) {
return new CommandResult(ex.getResponse(), ex.getServerAddress());
}
} | java | {
"resource": ""
} |
q165861 | DB.command | validation | public CommandResult command(final DBObject command, final ReadPreference readPreference) {
return command(command, readPreference, null);
} | java | {
"resource": ""
} |
q165862 | DB.collectionExists | validation | public boolean collectionExists(final String collectionName) {
Set<String> collectionNames = getCollectionNames();
for (final String name : collectionNames) {
if (name.equalsIgnoreCase(collectionName)) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q165863 | DB.doEval | validation | @Deprecated
public CommandResult doEval(final String code, final Object... args) {
DBObject commandDocument = new BasicDBObject("$eval", code).append("args", asList(args));
return executeCommand(wrap(commandDocument));
} | java | {
"resource": ""
} |
q165864 | DB.getStats | validation | @Deprecated
public CommandResult getStats() {
BsonDocument commandDocument = new BsonDocument("dbStats", new BsonInt32(1)).append("scale", new BsonInt32(1));
return executeCommand(commandDocument);
} | java | {
"resource": ""
} |
q165865 | DB.removeUser | validation | @Deprecated
public WriteResult removeUser(final String userName) {
try {
executor.execute(new com.mongodb.operation.DropUserOperation(getName(), userName, getWriteConcern()), getReadConcern());
return new WriteResult(1, true, null);
} catch (MongoWriteConcernException e) {
throw createWriteConcernException(e);
}
} | java | {
"resource": ""
} |
q165866 | DB.getCommandReadPreference | validation | ReadPreference getCommandReadPreference(final DBObject command, @Nullable final ReadPreference requestedPreference) {
String comString = command.keySet().iterator().next().toLowerCase();
boolean primaryRequired = !OBEDIENT_COMMANDS.contains(comString);
if (primaryRequired) {
return ReadPreference.primary();
} else if (requestedPreference == null) {
return ReadPreference.primary();
} else {
return requestedPreference;
}
} | java | {
"resource": ""
} |
q165867 | ChildCodecRegistry.get | validation | public <U> Codec<U> get(final Class<U> clazz) {
if (hasCycles(clazz)) {
return new LazyCodec<U>(registry, clazz);
} else {
return registry.get(new ChildCodecRegistry<U>(this, clazz));
}
} | java | {
"resource": ""
} |
q165868 | DBCollection.insert | validation | public WriteResult insert(final DBObject document, final WriteConcern writeConcern) {
return insert(asList(document), writeConcern);
} | java | {
"resource": ""
} |
q165869 | DBCollection.update | validation | public WriteResult update(final DBObject query, final DBObject update, final DBCollectionUpdateOptions options) {
notNull("query", query);
notNull("update", update);
notNull("options", options);
WriteConcern writeConcern = options.getWriteConcern() != null ? options.getWriteConcern() : getWriteConcern();
com.mongodb.bulk.WriteRequest.Type updateType = !update.keySet().isEmpty() && update.keySet().iterator().next().startsWith("$")
? com.mongodb.bulk.WriteRequest.Type.UPDATE
: com.mongodb.bulk.WriteRequest.Type.REPLACE;
UpdateRequest updateRequest = new UpdateRequest(wrap(query), wrap(update, options.getEncoder()), updateType)
.upsert(options.isUpsert()).multi(options.isMulti())
.collation(options.getCollation())
.arrayFilters(wrapAllowNull(options.getArrayFilters(), options.getEncoder()));
return executeWriteOperation(new UpdateOperation(getNamespace(), true, writeConcern, retryWrites,
singletonList(updateRequest)).bypassDocumentValidation(options.getBypassDocumentValidation()));
} | java | {
"resource": ""
} |
q165870 | DBCollection.findOne | validation | @Nullable
public DBObject findOne(final Object id, final DBObject projection) {
return findOne(new BasicDBObject("_id", id), new DBCollectionFindOptions().projection(projection));
} | java | {
"resource": ""
} |
q165871 | DBCollection.rename | validation | public DBCollection rename(final String newName, final boolean dropTarget) {
try {
executor.execute(new RenameCollectionOperation(getNamespace(),
new MongoNamespace(getNamespace().getDatabaseName(), newName), getWriteConcern())
.dropTarget(dropTarget), getReadConcern());
return getDB().getCollection(newName);
} catch (MongoWriteConcernException e) {
throw createWriteConcernException(e);
}
} | java | {
"resource": ""
} |
q165872 | DBCollection.mapReduce | validation | public MapReduceOutput mapReduce(final String map, final String reduce, final String outputTarget,
final MapReduceCommand.OutputType outputType, final DBObject query,
final ReadPreference readPreference) {
MapReduceCommand command = new MapReduceCommand(this, map, reduce, outputTarget, outputType, query);
command.setReadPreference(readPreference);
return mapReduce(command);
} | java | {
"resource": ""
} |
q165873 | DBCollection.explainAggregate | validation | public CommandResult explainAggregate(final List<? extends DBObject> pipeline, final AggregationOptions options) {
AggregateOperation<BsonDocument> operation = new AggregateOperation<BsonDocument>(getNamespace(), preparePipeline(pipeline),
new BsonDocumentCodec())
.maxTime(options.getMaxTime(MILLISECONDS), MILLISECONDS)
.allowDiskUse(options.getAllowDiskUse())
.collation(options.getCollation())
.retryReads(retryReads);
return new CommandResult(executor.execute(operation.asExplainableOperation(ExplainVerbosity.QUERY_PLANNER), primaryPreferred(),
getReadConcern()));
} | java | {
"resource": ""
} |
q165874 | DBCollection.createIndex | validation | public void createIndex(final DBObject keys, @Nullable final String name, final boolean unique) {
DBObject options = new BasicDBObject();
if (name != null && name.length() > 0) {
options.put("name", name);
}
if (unique) {
options.put("unique", Boolean.TRUE);
}
createIndex(keys, options);
} | java | {
"resource": ""
} |
q165875 | DBCollection.createIndex | validation | public void createIndex(final DBObject keys, final DBObject options) {
try {
executor.execute(createIndexOperation(keys, options), getReadConcern());
} catch (MongoWriteConcernException e) {
throw createWriteConcernException(e);
}
} | java | {
"resource": ""
} |
q165876 | DBCollection.findAndRemove | validation | @Nullable
public DBObject findAndRemove(@Nullable final DBObject query) {
return findAndModify(query, null, null, true, null, false, false);
} | java | {
"resource": ""
} |
q165877 | DBCollection.setDBDecoderFactory | validation | public synchronized void setDBDecoderFactory(@Nullable final DBDecoderFactory factory) {
this.decoderFactory = factory;
//Are we are using default factory?
// If yes then we can use CollectibleDBObjectCodec directly, otherwise it will be wrapped.
Decoder<DBObject> decoder = (factory == null || factory == DefaultDBDecoder.FACTORY)
? getDefaultDBObjectCodec()
: new DBDecoderAdapter(factory.create(), this, getBufferPool());
this.objectCodec = new CompoundDBObjectCodec(objectCodec.getEncoder(), decoder);
} | java | {
"resource": ""
} |
q165878 | DBCollection.setDBEncoderFactory | validation | public synchronized void setDBEncoderFactory(@Nullable final DBEncoderFactory factory) {
this.encoderFactory = factory;
//Are we are using default factory?
// If yes then we can use CollectibleDBObjectCodec directly, otherwise it will be wrapped.
Encoder<DBObject> encoder = (factory == null || factory == DefaultDBEncoder.FACTORY)
? getDefaultDBObjectCodec()
: new DBEncoderFactoryAdapter(encoderFactory);
this.objectCodec = new CompoundDBObjectCodec(encoder, objectCodec.getDecoder());
} | java | {
"resource": ""
} |
q165879 | DBCollection.getIndexInfo | validation | public List<DBObject> getIndexInfo() {
return new MongoIterableImpl<DBObject>(null, executor, ReadConcern.DEFAULT, primary(), retryReads) {
@Override
public ReadOperation<BatchCursor<DBObject>> asReadOperation() {
return new ListIndexesOperation<DBObject>(getNamespace(), getDefaultDBObjectCodec()).retryReads(retryReads);
}
}.into(new ArrayList<DBObject>());
} | java | {
"resource": ""
} |
q165880 | DBCollection.dropIndex | validation | public void dropIndex(final DBObject index) {
try {
executor.execute(new DropIndexOperation(getNamespace(), wrap(index), getWriteConcern()), getReadConcern());
} catch (MongoWriteConcernException e) {
throw createWriteConcernException(e);
}
} | java | {
"resource": ""
} |
q165881 | DBCollection.dropIndex | validation | public void dropIndex(final String indexName) {
try {
executor.execute(new DropIndexOperation(getNamespace(), indexName, getWriteConcern()), getReadConcern());
} catch (MongoWriteConcernException e) {
throw createWriteConcernException(e);
}
} | java | {
"resource": ""
} |
q165882 | DBCollection.isCapped | validation | public boolean isCapped() {
CommandResult commandResult = getStats();
Object cappedField = commandResult.get("capped");
return cappedField != null && (cappedField.equals(1) || cappedField.equals(true));
} | java | {
"resource": ""
} |
q165883 | DBCollection.setInternalClass | validation | public void setInternalClass(final String path, final Class<? extends DBObject> aClass) {
setObjectFactory(objectFactory.update(aClass, asList(path.split("\\."))));
} | java | {
"resource": ""
} |
q165884 | DBCollection.getInternalClass | validation | protected Class<? extends DBObject> getInternalClass(final String path) {
return objectFactory.getClassForPath(asList(path.split("\\.")));
} | java | {
"resource": ""
} |
q165885 | Updates.set | validation | public static <TItem> Bson set(final String fieldName, @Nullable final TItem value) {
return new SimpleUpdate<TItem>(fieldName, value, "$set");
} | java | {
"resource": ""
} |
q165886 | Updates.setOnInsert | validation | public static <TItem> Bson setOnInsert(final String fieldName, @Nullable final TItem value) {
return new SimpleUpdate<TItem>(fieldName, value, "$setOnInsert");
} | java | {
"resource": ""
} |
q165887 | Updates.rename | validation | public static Bson rename(final String fieldName, final String newFieldName) {
notNull("newFieldName", newFieldName);
return new SimpleUpdate<String>(fieldName, newFieldName, "$rename");
} | java | {
"resource": ""
} |
q165888 | Updates.inc | validation | public static Bson inc(final String fieldName, final Number number) {
notNull("number", number);
return new SimpleUpdate<Number>(fieldName, number, "$inc");
} | java | {
"resource": ""
} |
q165889 | Updates.mul | validation | public static Bson mul(final String fieldName, final Number number) {
notNull("number", number);
return new SimpleUpdate<Number>(fieldName, number, "$mul");
} | java | {
"resource": ""
} |
q165890 | Updates.min | validation | public static <TItem> Bson min(final String fieldName, final TItem value) {
return new SimpleUpdate<TItem>(fieldName, value, "$min");
} | java | {
"resource": ""
} |
q165891 | Updates.max | validation | public static <TItem> Bson max(final String fieldName, final TItem value) {
return new SimpleUpdate<TItem>(fieldName, value, "$max");
} | java | {
"resource": ""
} |
q165892 | Updates.addToSet | validation | public static <TItem> Bson addToSet(final String fieldName, @Nullable final TItem value) {
return new SimpleUpdate<TItem>(fieldName, value, "$addToSet");
} | java | {
"resource": ""
} |
q165893 | Updates.addEachToSet | validation | public static <TItem> Bson addEachToSet(final String fieldName, final List<TItem> values) {
return new WithEachUpdate<TItem>(fieldName, values, "$addToSet");
} | java | {
"resource": ""
} |
q165894 | Updates.push | validation | public static <TItem> Bson push(final String fieldName, @Nullable final TItem value) {
return new SimpleUpdate<TItem>(fieldName, value, "$push");
} | java | {
"resource": ""
} |
q165895 | Updates.pushEach | validation | public static <TItem> Bson pushEach(final String fieldName, final List<TItem> values) {
return new PushUpdate<TItem>(fieldName, values, new PushOptions());
} | java | {
"resource": ""
} |
q165896 | Updates.pull | validation | public static <TItem> Bson pull(final String fieldName, @Nullable final TItem value) {
return new SimpleUpdate<TItem>(fieldName, value, "$pull");
} | java | {
"resource": ""
} |
q165897 | Updates.pullByFilter | validation | public static Bson pullByFilter(final Bson filter) {
return new Bson() {
@Override
public <TDocument> BsonDocument toBsonDocument(final Class<TDocument> tDocumentClass, final CodecRegistry codecRegistry) {
BsonDocumentWriter writer = new BsonDocumentWriter(new BsonDocument());
writer.writeStartDocument();
writer.writeName("$pull");
encodeValue(writer, filter, codecRegistry);
writer.writeEndDocument();
return writer.getDocument();
}
};
} | java | {
"resource": ""
} |
q165898 | Updates.pullAll | validation | public static <TItem> Bson pullAll(final String fieldName, final List<TItem> values) {
return new PullAllUpdate<TItem>(fieldName, values);
} | java | {
"resource": ""
} |
q165899 | BaseQueryMessage.writeQueryPrologue | validation | protected void writeQueryPrologue(final BsonOutput bsonOutput) {
bsonOutput.writeInt32(getCursorFlag());
bsonOutput.writeCString(getCollectionName());
bsonOutput.writeInt32(skip);
bsonOutput.writeInt32(numberToReturn);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.