Пример #1
0
  /**
   * {@inheritDoc}
   *
   * <p>Overridden to write the kill_cursors message.
   *
   * @see Message#write(int, BsonOutputStream)
   */
  @Override
  public void write(final int messageId, final BufferingBsonOutputStream out) throws IOException {
    final long start = writeHeader(out, messageId, 0, Operation.KILL_CURSORS);
    out.writeInt(0);
    out.writeInt(myCursorIds.length);
    for (final long myCursorId : myCursorIds) {
      out.writeLong(myCursorId);
    }
    finishHeader(out, start);

    out.flushBuffer();
  }
Пример #2
0
  /**
   * {@inheritDoc}
   *
   * <p>Overridden to write the insert message.
   *
   * @see Message#write(int, BsonOutputStream)
   */
  @Override
  public void write(final int messageId, final BufferingBsonOutputStream out) throws IOException {
    final int flags = computeFlags();

    final long start = writeHeader(out, messageId, 0, Operation.INSERT);
    out.writeInt(flags);
    out.writeCString(myDatabaseName, ".", myCollectionName);
    for (final Document document : myDocuments) {
      out.writeDocument(document);
    }
    finishHeader(out, start);

    out.flushBuffer();
  }