Package com.netflix.zeno.fastblob.record

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


    @Test
    public void booleanUsesDefaultWhenActualValueIsNull() {
        TestSerializer testSerializer = new TestSerializer();
        testSerializer.setSerializationFramework(new FastBlobStateEngine(serializerFactory));
        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(testSerializer.getFastBlobSchema());
        testSerializer.serialize(null, rec);

        ByteDataBuffer buf = new ByteDataBuffer();

        rec.writeDataTo(buf);

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

        Boolean deserialized = testSerializer.deserialize(deserializeRec);
View Full Code Here


    byte[] bytes2 = new byte[]{2,56};

    @Test
    public void testBytes() throws Exception {
        NFTypeSerializer<Object[]> testSerializer = framework.getSerializer(TestSerializerBytes.NAME);
        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(testSerializer.getFastBlobSchema());
        testSerializer.serialize(new Object[]{bytes, bytes2}, rec);

        ByteDataBuffer buf = new ByteDataBuffer();

        rec.writeDataTo(buf);

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

        Object[] deserialized = testSerializer.deserialize(deserializeRec);
View Full Code Here

    String text2 = "String2";

    @Test
    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);
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);
View Full Code Here

            }
        });

        schema = stateEngine.getSerializer("TestType").getFastBlobSchema();

        rec = new FastBlobSerializationRecord(schema);
    }
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);
                serializationRecord.writeDataTo(deserializedRecordBuffer);

                int previousOrdinal = map.get(deserializedRecordBuffer);

                serializationRecord.reset();
                deserializedRecordBuffer.reset();

                if(previousOrdinal != -1 && !frameworkSerializer.isSerializationIntegrityFlawed()) {
                    typeDeserializationState.copyPrevious(currentOrdinal, previousOrdinal);
                    numObjectsReused++;
View Full Code Here

     * Not intended for external consumption.<p/>
     *
     * This method is only intended to be used during heap-friendly double snapshot refresh.
     */
    public void populateByteArrayOrdinalMap(ByteArrayOrdinalMap ordinalMap) {
        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(serializer.getFastBlobSchema());
        ByteDataBuffer scratch = new ByteDataBuffer();

        for(int i=0;i<objects.size();i++) {
            T obj = objects.get(i);
            if(obj != null) {
                serializer.serialize(obj, rec);
                rec.writeDataTo(scratch);
                ordinalMap.put(scratch, i);
                scratch.reset();
                rec.reset();
            }
        }

        previousObjects = objects;
        copiedPreviousObjects = new BitSet(previousObjects.size());
View Full Code Here

    @Test
    public void remapsListOrdinals() {
        NFTypeSerializer<List<TypeA>> listSerializer = stateEngine.getSerializer(LIST_SERIALIZER.getName());
        FastBlobSchema listSchema = listSerializer.getFastBlobSchema();
        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(listSchema);
        rec.setImageMembershipsFlags(FastBlobImageUtils.ONE_TRUE);

        List<TypeA> list = new ArrayList<TypeA>();
        list.add(new TypeA(3, 3));
        list.add(new TypeA(0, 0));
        list.add(null);
View Full Code Here

    @Test
    public void remapsSetOrdinals() {
        NFTypeSerializer<Set<TypeA>> setSerializer = stateEngine.getSerializer(SET_SERIALIZER.getName());
        FastBlobSchema setSchema = setSerializer.getFastBlobSchema();
        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(setSchema);
        rec.setImageMembershipsFlags(FastBlobImageUtils.ONE_TRUE);

        Set<TypeA> set = new HashSet<TypeA>();
        set.add(new TypeA(1, 1));
        set.add(new TypeA(4, 4));
        set.add(null);
View Full Code Here

    @Test
    public void remapsMapOrdinals() {
        NFTypeSerializer<Map<TypeA, TypeA>> mapSerializer = stateEngine.getSerializer(MAP_SERIALIZER.getName());
        FastBlobSchema mapSchema = mapSerializer.getFastBlobSchema();
        FastBlobSerializationRecord rec = new FastBlobSerializationRecord(mapSchema);
        rec.setImageMembershipsFlags(FastBlobImageUtils.ONE_TRUE);

        Map<TypeA, TypeA> map = new HashMap<TypeA, TypeA>();
        map.put(new TypeA(1, 1), new TypeA(4, 4));
        map.put(new TypeA(3, 3), new TypeA(1, 1));
        map.put(null, new TypeA(1, 1));
View Full Code Here

TOP

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

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.