java/core/src/main/java/se/lth/cs/docria/io/MsgpackDocumentStreamReader.java
/**
     * Gets a stream for a single block.
     *
     * <b>Remarks:</b> Safe for concurrent use, only reading is synchronized i.e. will be I/O limited.
     * Deserialization and potential decompression is concurrent.
     * @return null if no more blocks.
     */
Gets a stream for a single block.
Remarks: Safe for concurrent use, only reading is synchronized i.e. will be I/O limited.
Deserialization and potential decompression is concurrent.
@return null if no more blocks.
Gets a stream for a single block . Remarks : Safe for concurrent use only reading is synchronized i . e . will be I / O limited . Deserialization and potential decompression is concurrent . @return null if no more blocks .
public Stream<MsgpackDocument> nextBlock() {
        final MessageUnpacker unpacker = readNextBlock();
        if(unpacker == null)
            return null;
        Iterator<MsgpackDocument> iterator = new Iterator<MsgpackDocument>() {
            @Override
            public boolean hasNext() {
                try {
                    return unpacker.hasNext();
                } catch (IOException e) {
                    throw new IOError(e);
                }
            }
            @Override
            public MsgpackDocument next() {
                try {
                    int docsz = unpacker.unpackBinaryHeader();
                    byte[] docdata = unpacker.readPayload(docsz);
                    return new MsgpackDocument(docdata);
                } catch (IOException e) {
                    throw new IOError(e);
                }
            }
        };
        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT | Spliterator.NONNULL), false);
    }
public Stream < MsgpackDocument > nextBlock ( ) { final MessageUnpacker unpacker = readNextBlock ( ) ; if ( unpacker == null ) return null ; Iterator < MsgpackDocument > iterator = new Iterator < MsgpackDocument > ( ) { @ Override public boolean hasNext ( ) { try { return unpacker . hasNext ( ) ; } catch ( IOException e ) { throw new IOError ( e ) ; } } @ Override public MsgpackDocument next ( ) { try { int docsz = unpacker . unpackBinaryHeader ( ) ; byte [ ] docdata = unpacker . readPayload ( docsz ) ; return new MsgpackDocument ( docdata ) ; } catch ( IOException e ) { throw new IOError ( e ) ; } } } ; return StreamSupport . stream ( Spliterators . spliteratorUnknownSize ( iterator , Spliterator . DISTINCT | Spliterator . NONNULL ) , false ) ; }
Gets a stream for a single block.
Gets a stream for a single block .