@Override public GetMoreMessage decode(ByteBuf buffer, RequestBaseMessage requestBaseMessage) throws InvalidNamespaceException, InvalidBsonException { try { buffer.skipBytes(4); String fullCollectionName = stringReader.readCString(buffer, true); int numberToReturn = buffer.readInt(); long cursorId = buffer.readLong(); //TODO: improve the way database and cache are pooled return new GetMoreMessage( requestBaseMessage, getDatabase(fullCollectionName).intern(), getCollection(fullCollectionName).intern(), numberToReturn, cursorId ); } catch (NettyBsonReaderException ex) { throw new InvalidBsonException(ex); } } }
@Override BsonJavaScriptWithScope readJavaScriptWithScope(@Loose @ModifiesIndexes ByteBuf byteBuf) throws NettyBsonReaderException { byteBuf.readInt(); String js = getStringReader().readString(byteBuf, false); BsonDocument scope = readJavaScriptScope(byteBuf); return new DefaultBsonJavaScriptWithCode(js, scope); }
@Override BsonString readString(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new NettyBsonString(getStringReader().readStringAsSlice(byteBuf)); }
public BsonValue<?> readArrayEntry(@Loose @ModifiesIndexes ByteBuf byteBuf) throws NettyBsonReaderException { BsonType bsonType = ParsingTools.getBsonType(byteBuf.readByte()); stringReader.skipCString(byteBuf); switch (bsonType) { case ARRAY:
@Override BsonRegex readRegex(@Loose @ModifiesIndexes ByteBuf byteBuf) throws NettyBsonReaderException { String pattern = getStringReader().readCString(byteBuf, false); String options = getStringReader().readCString(byteBuf, true); EnumSet<BsonRegex.Options> optionsSet = ParsingTools.parseRegexOptions(options); return new DefaultBsonRegex(optionsSet, pattern); }
@Override BsonJavaScript readJavaScript(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new DefaultBsonJavaScript(getStringReader().readString(byteBuf, false)); }
@Override @SuppressFBWarnings(value = {"RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"}, justification = "Findbugs thinks ByteBuf#readerIndex(...) has no" + "side effect") public InsertMessage decode(ByteBuf buffer, RequestBaseMessage requestBaseMessage) throws InvalidNamespaceException, InvalidBsonException { try { MyBsonContext context = new MyBsonContext(buffer); int flags = buffer.readInt(); String fullCollectionName = stringReader.readCString(buffer, true); ByteBuf docBuf = buffer.slice(buffer.readerIndex(), buffer.readableBytes()); docBuf.retain(); buffer.readerIndex(buffer.writerIndex()); ByteBufIterableDocumentProvider documents = new ByteBufIterableDocumentProvider(docBuf, docReader); //TODO: improve the way database and cache are pooled return new InsertMessage( requestBaseMessage, context, getDatabase(fullCollectionName).intern(), getCollection(fullCollectionName).intern(), EnumInt32FlagsUtil.isActive(Flag.CONTINUE_ON_ERROR, flags), documents ); } catch (NettyBsonReaderException ex) { throw new InvalidBsonException(ex); } }
@Override BsonValue<?> readDeprecated(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new StringBsonDeprecated(getStringReader().readString(byteBuf, false)); }
@Override @Nonnegative public DeleteMessage decode(ByteBuf buffer, RequestBaseMessage requestBaseMessage) throws InvalidNamespaceException, InvalidBsonException { try { MyBsonContext context = new MyBsonContext(buffer); buffer.skipBytes(4); String fullCollectionName = stringReader.readCString(buffer, true); int flags = buffer.readInt(); BsonDocument document = docReader.readDocument(HEAP, buffer); //TODO: improve the way database and cache are pooled String database = getDatabase(fullCollectionName).intern(); String collection = getCollection(fullCollectionName).intern(); return new DeleteMessage( requestBaseMessage, context, database, collection, document, EnumInt32FlagsUtil.isActive(Flag.SINGLE_REMOVE, flags) ); } catch (NettyBsonReaderException ex) { throw new InvalidBsonException(ex); } }
@Override BsonString readString(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new StringBsonString(getStringReader().readString(byteBuf, false)); }
@Override public UpdateMessage decode(ByteBuf buffer, RequestBaseMessage requestBaseMessage) throws InvalidNamespaceException, InvalidBsonException { try { buffer.skipBytes(4); String fullCollectionName = stringReader.readCString(buffer, true); int flags = buffer.readInt(); BsonDocument selector = docReader.readDocument(HEAP, buffer); BsonDocument update = docReader.readDocument(HEAP, buffer); //TODO: improve the way database and cache are pooled return new UpdateMessage( requestBaseMessage, EmptyBsonContext.getInstance(), getDatabase(fullCollectionName).intern(), getCollection(fullCollectionName).intern(), selector, update, EnumInt32FlagsUtil.isActive(Flag.UPSERT, flags), EnumInt32FlagsUtil.isActive(Flag.MULTI_UPDATE, flags) ); } catch (NettyBsonReaderException ex) { throw new InvalidBsonException(ex); } }
@Override BsonDbPointer readDbPointer(@Loose @ModifiesIndexes ByteBuf byteBuf) { String str = getStringReader().readString(byteBuf, false); byte[] bytes = new byte[12]; byteBuf.readBytes(bytes); return new DefaultBsonDbPointer(str, new ByteArrayBsonObjectId(bytes)); }
String fullCollectionName = stringReader.readCString(buffer, true); final int numberToSkip = buffer.readInt(); final int numberToReturn = buffer.readInt();
public Entry<?> readDocumentEntry(@Loose @ModifiesIndexes ByteBuf byteBuf) throws NettyBsonReaderException { BsonType bsonType = ParsingTools.getBsonType(byteBuf.readByte()); String key = stringReader.readCString(byteBuf, true); switch (bsonType) { case ARRAY: