Examples of FastBlobReader


Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        FastBlobWriter writer = new FastBlobWriter(stateEngine);
        writer.writeSnapshot(baos);

        FastBlobStateEngine deserializeEngine = typeAStateEngine();

        FastBlobReader reader = new FastBlobReader(deserializeEngine);

        reader.readSnapshot(new ByteArrayInputStream(baos.toByteArray()));

        deserializeEngine.fillSerializationStatesFromDeserializedData();

        deserializeEngine.prepareForWrite();
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

    protected void serializeAndDeserializeDelta() throws IOException, Exception {
        serializationState.prepareForWrite();
        new FastBlobWriter(serializationState, 0).writeDelta(new DataOutputStream(baos));
        serializationState.prepareForNextCycle();
        new FastBlobReader(serializationState).readDelta(new ByteArrayInputStream(baos.toByteArray()));
        baos.reset();
    }
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        deserializeSnapshot(data);
    }

    protected void deserializeSnapshot(final byte[] data) throws IOException {
        final InputStream is = new ByteArrayInputStream(data);
        new FastBlobReader(serializationState).readSnapshot(is);
    }
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        stateEngine.prepareForWrite();

        FastBlobWriter writer = new FastBlobWriter(stateEngine);
        writer.writeSnapshot(dataOutputStream);

        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(baos.toByteArray()));

        return stateEngine;
    }
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

    @Test
    public void testListenerSnapshot() throws IOException {
        TestTypeDeserializationStateListener listener = new TestTypeDeserializationStateListener();
        stateEngine.setTypeDeserializationStateListener("TypeF", listener);
        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(snapshot1));

        Assert.assertEquals(0, listener.getRemovedValuesSize());
        Assert.assertEquals(10, listener.getAddedValuesSize());
        Assert.assertEquals(3, listener.getAddedValueOrdinal(4));
    }
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        Assert.assertEquals(3, listener.getAddedValueOrdinal(4));
    }

    @Test
    public void testListenerDelta() throws IOException {
        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(snapshot1));

        TestTypeDeserializationStateListener listener = new TestTypeDeserializationStateListener();
        stateEngine.setTypeDeserializationStateListener("TypeF", listener);
        reader.readDelta(new ByteArrayInputStream(delta));

        Assert.assertEquals(3, listener.getRemovedValuesSize());
        Assert.assertEquals(2, listener.getRemovedValueOrdinal(3));
        Assert.assertEquals(2, listener.getAddedValuesSize());
        Assert.assertEquals(10, listener.getAddedValueOrdinal(11));
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        Assert.assertEquals(10, listener.getAddedValueOrdinal(11));
    }

    @Test
    public void testListenerDoubleSnapshot() throws IOException {
        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(snapshot1));

        TestTypeDeserializationStateListener listener = new TestTypeDeserializationStateListener();
        stateEngine.setTypeDeserializationStateListener("TypeF", listener);
        reader.readSnapshot(new ByteArrayInputStream(snapshot2));

        Assert.assertEquals(3, listener.getRemovedValuesSize());
        Assert.assertEquals(2, listener.getRemovedValueOrdinal(3));
        Assert.assertEquals(2, listener.getAddedValuesSize());
        Assert.assertEquals(10, listener.getAddedValueOrdinal(11));
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        Assert.assertEquals(new OrdinalReassignment(3, 3), listener.getOrdinalReassignment(4));
    }

    @Test
    public void testListenerDoubleSnapshotDiscontinuousState() throws IOException {
        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(snapshot1));

        TestTypeDeserializationStateListener listener = new TestTypeDeserializationStateListener();
        stateEngine.setTypeDeserializationStateListener("TypeF", listener);
        reader.readSnapshot(new ByteArrayInputStream(brokenDeltaChainSnapshot2));

        Assert.assertEquals(3, listener.getRemovedValuesSize());
        Assert.assertEquals(2, listener.getRemovedValueOrdinal(3));
        Assert.assertEquals(2, listener.getAddedValuesSize());
        Assert.assertEquals(7, listener.getAddedValueOrdinal(11));
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        /// tell it about our data model.
        FastBlobStateEngine stateEngine = new FastBlobStateEngine(new ExampleSerializerFactory());

        /// we need to create a FastBlobReader, which is responsible for reading
        /// serialized blobs.
        FastBlobReader reader = new FastBlobReader(stateEngine);

        /// get a stream from the snapshot file location
        ByteArrayInputStream snapshotStream = new ByteArrayInputStream(snapshot);
        /// get a stream from the delta file location
        ByteArrayInputStream deltaStream = new ByteArrayInputStream(delta);


        try {
            /// first read the snapshot
            reader.readSnapshot(snapshotStream);
            /// then apply the delta
            reader.readDelta(deltaStream);
        } catch (IOException e) {
            /// either of these methods throws an exception if the FastBlobReader
            /// is unable to read from the provided stream.
        } finally {
            /// it is your responsibility to close the streams.  The FastBlobReader will not do this.
View Full Code Here

Examples of com.netflix.zeno.fastblob.io.FastBlobReader

        /// tell it about our data model.
        FastBlobStateEngine stateEngine = new FastBlobStateEngine(new ExampleSerializerFactory());

        /// we need to create a FastBlobReader, which is responsible for reading
        /// serialized blobs.
        FastBlobReader reader = new FastBlobReader(stateEngine);

        /// get a stream from the snapshot file location
        ByteArrayInputStream snapshotStream = new ByteArrayInputStream(snapshot);
        /// get a stream from the delta file location
        ByteArrayInputStream deltaStream = new ByteArrayInputStream(delta);


        try {
            /// first read the snapshot
            reader.readSnapshot(snapshotStream);
            /// then apply the delta
            reader.readDelta(deltaStream);
        } catch (IOException e) {
            /// either of these methods throws an exception if the FastBlobReader
            /// is unable to read from the provided stream.
        } finally {
            /// it is your responsibility to close the streams.  The FastBlobReader will not do this.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.