@Override public BSONObject readObject(final byte[] bytes) { BSONCallback bsonCallback = new LazyBSONCallback(); decode(bytes, bsonCallback); return (BSONObject) bsonCallback.get(); }
@Override public BSONObject readObject(final InputStream in) throws IOException { BSONCallback bsonCallback = new LazyBSONCallback(); decode(in, bsonCallback); return (BSONObject) bsonCallback.get(); }
@Override public void initialize(final InputSplit inputSplit, final TaskAttemptContext context) throws IOException, InterruptedException { fileSplit = (FileSplit) inputSplit; final Configuration configuration = context.getConfiguration(); if (LOG.isDebugEnabled()) { LOG.debug("reading split " + fileSplit); } Path file = fileSplit.getPath(); FileSystem fs = file.getFileSystem(configuration); in = fs.open(file, 16 * 1024 * 1024); in.seek(fileSplit.getStart()); if (MongoConfigUtil.getLazyBSON(configuration)) { callback = new LazyBSONCallback(); decoder = new LazyBSONDecoder(); } else { callback = new BasicBSONCallback(); decoder = new BasicBSONDecoder(); } }
public void initialize(final InputSplit inputSplit, final Configuration conf) throws IOException { fileSplit = (FileSplit) inputSplit; Path file = fileSplit.getPath(); FileSystem fs = file.getFileSystem(conf); in = fs.open(file, 16 * 1024 * 1024); in.seek(fileSplit.getStart()); if (MongoConfigUtil.getLazyBSON(conf)) { callback = new LazyBSONCallback(); decoder = new LazyBSONDecoder(); } else { callback = new BasicBSONCallback(); decoder = new BasicBSONDecoder(); } }
DBObject dbo = new LazyWriteableDBObject(baos.toByteArray(), new LazyBSONCallback());
@Override public int compare(final byte[] b1, final int s1, final int l1, final byte[] b2, final int s2, final int l2) { LazyBSONCallback cb = new LazyBSONCallback(); DECODER.decode(b1, cb); BSONObject a = (BSONObject) cb.get(); cb.reset(); DECODER.decode(b2, cb); BSONObject b = (BSONObject) cb.get(); return compare(a, b); }
public void init(final InputSplit inputSplit, final Configuration configuration) throws IOException, InterruptedException { this.configuration = configuration; fileSplit = (FileSplit) inputSplit; if (LOG.isDebugEnabled()) { LOG.debug("reading split " + fileSplit); } Path file = fileSplit.getPath(); FileSystem fs = file.getFileSystem(configuration); CompressionCodec codec = new CompressionCodecFactory(configuration) .getCodec(fileSplit.getPath()); inRaw = fs.open(file, 16 * 1024 * 1024); inRaw.seek( startingPosition == BSON_RR_POSITION_NOT_GIVEN ? fileSplit.getStart() : startingPosition); if (codec != null) { decompressor = CodecPool.getDecompressor(codec); in = codec.createInputStream(inRaw, decompressor); } else { in = inRaw; } if (MongoConfigUtil.getLazyBSON(configuration)) { callback = new LazyBSONCallback(); decoder = new LazyBSONDecoder(); } else { callback = new BasicBSONCallback(); decoder = new BasicBSONDecoder(); } }
@Override public int compare(final byte[] b1, final int s1, final int l1, final byte[] b2, final int s2, final int l2) { LazyBSONCallback cb = new LazyBSONCallback(); DECODER.decode(b1, cb); BSONObject a = (BSONObject) cb.get(); cb.reset(); DECODER.decode(b2, cb); BSONObject b = (BSONObject) cb.get(); return compare(a, b); }