Package com.netflix.zeno.fastblob.record

Examples of com.netflix.zeno.fastblob.record.FastBlobDeserializationRecord


        ByteDataBuffer buf = new ByteDataBuffer();

        rec.writeDataTo(buf);

        FastBlobDeserializationRecord deserializeRec = new FastBlobDeserializationRecord(testSerializer.getFastBlobSchema(), buf.getUnderlyingArray());
        deserializeRec.position(0);

        Boolean deserialized = testSerializer.deserialize(deserializeRec);

        Assert.assertEquals(Boolean.TRUE, deserialized);
    }
View Full Code Here


        ByteDataBuffer buf = new ByteDataBuffer();

        rec.writeDataTo(buf);

        FastBlobDeserializationRecord deserializeRec = new FastBlobDeserializationRecord(testSerializer.getFastBlobSchema(), buf.getUnderlyingArray());
        deserializeRec.position(0);

        Object[] deserialized = testSerializer.deserialize(deserializeRec);

        Assert.assertArrayEquals(bytes, (byte[])deserialized[0]);
        Assert.assertArrayEquals(bytes2, (byte[])deserialized[1]);
View Full Code Here

        for(int i=0;i<numThreads;i++) {
            final int threadNumber = i;
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    FastBlobDeserializationRecord rec = new FastBlobDeserializationRecord(fill.getSchema(), byteData.getUnderlyingArray());
                    for(int i=threadNumber;i<pointersAndOrdinals.length();i += numThreads) {
                        long pointerAndOrdinal = pointersAndOrdinals.get(i);
                        if(pointerAndOrdinal != EMPTY_BUCKET_VALUE) {
                            long pointer = pointerAndOrdinal & 0xFFFFFFFFFL;
                            int ordinal = (int)(pointerAndOrdinal >> 36);

                            int sizeOfData = VarInt.readVInt(byteData.getUnderlyingArray(), pointer);
                            pointer += VarInt.sizeOfVInt(sizeOfData);

                            rec.position(pointer);

                            fill.add(ordinal, rec);
                        }
                    }
                }
View Full Code Here

            final int threadNumber = i;
            executor.submit( new Runnable() {
                @Override
                public void run() {
                    final ByteDataBuffer mappedBuffer = new ByteDataBuffer();
                    final FastBlobDeserializationRecord rec = new FastBlobDeserializationRecord(destState.getSchema(), byteData.getUnderlyingArray());
                    final boolean imageMembershipsFlags[] = new boolean[imageMemberships.length];
                    final OrdinalRemapper remapper = new OrdinalRemapper(ordinalMapping);

                    for(int j = threadNumber;j < pointersAndOrdinals.length();j += numThreads) {
                        long pointerAndOrdinal = pointersAndOrdinals.get(j);
                        if(pointerAndOrdinal != EMPTY_BUCKET_VALUE) {
                            long pointer = pointerAndOrdinal & 0xFFFFFFFFFL;
                            int ordinal = (int)(pointerAndOrdinal >> 36);

                            for(int imageIndex=0;imageIndex<imageMemberships.length;imageIndex++) {
                                imageMembershipsFlags[imageIndex] = imageMemberships[imageIndex].get(ordinal);
                            }

                            int sizeOfData = VarInt.readVInt(byteData.getUnderlyingArray(), pointer);
                            pointer += VarInt.sizeOfVInt(sizeOfData);

                            rec.position(pointer);
                            remapper.remapOrdinals(rec, mappedBuffer);

                            int newOrdinal = destState.addData(mappedBuffer, FastBlobImageUtils.toLong(imageMembershipsFlags));
                            stateOrdinalMapping.setMappedOrdinal(ordinal, newOrdinal);
View Full Code Here

    public void testRemove() throws Exception {

        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(testSerializer2.getFastBlobSchema());
        testSerializer2.serialize(new String[]{text1, text2}, rec);

        FastBlobDeserializationRecord result = serializeDeserialize(testSerializer2, rec);

        String[] deserialized = testSerializer1.deserialize(result);

        Assert.assertEquals(text1, deserialized[0]);
    }
View Full Code Here

    @Test
    public void testAdd() throws Exception {

        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(testSerializer1.getFastBlobSchema());
        testSerializer1.serialize(new String[]{text1}, rec);
        FastBlobDeserializationRecord result = serializeDeserialize(testSerializer1, rec);

        String[] deserialized = testSerializer2.deserialize(result);

        Assert.assertEquals(text1, deserialized[0]);
        Assert.assertEquals(null, deserialized[1]);
View Full Code Here

        ByteDataBuffer buf = new ByteDataBuffer();

        rec.writeDataTo(buf);

        FastBlobDeserializationRecord deserializeRec = new FastBlobDeserializationRecord(testSerializer.getFastBlobSchema(), buf.getUnderlyingArray());

        deserializeRec.position(0);

        return deserializeRec;
    }
View Full Code Here

        ByteDataBuffer buf = new ByteDataBuffer();

        rec.writeDataTo(buf);

        FastBlobDeserializationRecord deserializationRecord = new FastBlobDeserializationRecord(schema, buf.getUnderlyingArray());
        deserializationRecord.position(0);

        PojoWithAllTypes deserialized = serializer.deserialize(deserializationRecord);

        Assert.assertTrue(deserialized.boolField);
        Assert.assertTrue(Arrays.equals(new byte[] {7, 8}, deserialized.bytesField));
View Full Code Here

            }
        }
    }

    private void readTypeStateObjects(StreamingByteData byteData,FastBlobSchema schema) throws IOException {
        FastBlobDeserializationRecord rec = new FastBlobDeserializationRecord(schema, byteData);
        FastBlobTypeDeserializationState<?> typeDeserializationState = stateEngine.getTypeDeserializationState(schema.getName());

        int numObjects = VarInt.readVInt(byteData);

        if(numObjects != 0 && eventHandler != null) {
            eventHandler.addedObjects(schema.getName(), numObjects);
        }

        int currentOrdinal = 0;

        for(int j=0;j<numObjects;j++) {
            int currentOrdinalDelta = VarInt.readVInt(byteData);

            currentOrdinal += currentOrdinalDelta;

            int objectSize = rec.position(byteData.currentStreamPosition());
            byteData.incrementStreamPosition(objectSize);

            if(typeDeserializationState != null) {
                typeDeserializationState.add(currentOrdinal, rec);
            }
View Full Code Here

        }
    }

    private <T> void readTypeStateObjectsDoubleSnapshotRefresh(StreamingByteData byteData, FastBlobSchema schema, ByteArrayOrdinalMap map) throws IOException{
        FastBlobHeapFriendlyClientFrameworkSerializer frameworkSerializer = (FastBlobHeapFriendlyClientFrameworkSerializer)stateEngine.getFrameworkSerializer();
        FastBlobDeserializationRecord rec = new FastBlobDeserializationRecord(schema, byteData);
        FastBlobTypeDeserializationState<T> typeDeserializationState = stateEngine.getTypeDeserializationState(schema.getName());
        FastBlobSerializationRecord serializationRecord = null;
        ByteDataBuffer deserializedRecordBuffer = null;

        int numObjects = VarInt.readVInt(byteData);
        int numObjectsReused = 0;
        int numFlawedSerializationIntegrity = 0;

        if(numObjects != 0 && eventHandler != null) {
            eventHandler.addedObjects(schema.getName(), numObjects);
        }

        if(typeDeserializationState != null) {
            serializationRecord = new FastBlobSerializationRecord(typeDeserializationState.getSchema());

            frameworkSerializer.setCheckSerializationIntegrity(false);

            deserializedRecordBuffer = new ByteDataBuffer();
            typeDeserializationState.populateByteArrayOrdinalMap(map);

            frameworkSerializer.setCheckSerializationIntegrity(true);
        }

        int currentOrdinal = 0;

        for(int j=0;j<numObjects;j++) {
            int currentOrdinalDelta = VarInt.readVInt(byteData);

            currentOrdinal += currentOrdinalDelta;

            int recordSize = rec.position(byteData.currentStreamPosition());

            if(typeDeserializationState != null) {
                NFTypeSerializer<T> serializer = typeDeserializationState.getSerializer();
                T deserializedObject = serializer.deserialize(rec);
                serializer.serialize(deserializedObject, serializationRecord);
View Full Code Here

TOP

Related Classes of com.netflix.zeno.fastblob.record.FastBlobDeserializationRecord

Copyright © 2018 www.massapicom. 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.