@Override public KVValue visit(BsonBinary value, Void arg) { KVBinarySubtype subtype; switch (value.getSubtype()) { case FUNCTION: subtype = KVBinarySubtype.MONGO_FUNCTION; break; return new ByteSourceKVBinary(subtype, value.getNumericSubType(), value.getByteSource().getDelegate());
@Override public Void visit(BsonBinary value, ByteBuf arg) { NonIoByteSource byteSource = value.getByteSource(); UnsignedInteger unsignedSize; unsignedSize = UnsignedInteger.valueOf(byteSource.size()); arg.writeInt(unsignedSize.intValue()).writeByte(value.getNumericSubType()); try (OutputStream os = new ByteBufOutputStream(arg)) { value.getByteSource().copyTo(os); } catch (IOException ex) { throw new AssertionError("Unexpected IOException", ex); } return null; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof BsonBinary)) { return false; } BsonBinary other = (BsonBinary) obj; if (this.getSubtype() != other.getSubtype()) { return false; } return this.getByteSource().contentEquals(other.getByteSource()); }
diff = this.size() - other.size(); if (diff != 0) { return diff; diff = this.getNumericSubType() - other.getNumericSubType(); if (diff != 0) { return diff; if (this.getByteSource().getDelegate() == other.getByteSource().getDelegate()) { return 0; InputStream otherBis = other.getByteSource().openBufferedStream()) { int myByte = myBis.read(); int otherByte = otherBis.read();
com.eightkdata.mongowp.bson.BsonBinary casted = (com.eightkdata.mongowp.bson.BsonBinary) value; return new BsonBinary(casted.getNumericSubType(), casted.getByteSource().read());