Package com.netflix.zeno.serializer

Examples of com.netflix.zeno.serializer.NFTypeSerializer


    public <T> void serializeSet(HashGenericRecord rec, String fieldName, String typeName, Set<T> set) {
        if (set == null) {
            return;
        }
        rec.put(null, "<");
        NFTypeSerializer elementSerializer = (NFTypeSerializer) (framework.getSerializer(typeName));
        HashGenericRecord independent = new HashGenericRecord(new HashOrderIndependent());
        for (T t : set) {
            HashGenericRecord dependent = new HashGenericRecord(new HashOrderDependent());
            elementSerializer.serialize(t, dependent);
            independent.put(null, dependent.hash());
        }
        rec.put(null, independent.hash());
        rec.put(null, ">");
    }
View Full Code Here


    public <K, V> void serializeMap(HashGenericRecord rec, String fieldName, String keyTypeName, String valueTypeName, Map<K, V> map) {
        if (map == null) {
            return;
        }
        rec.put(null, "{");
        NFTypeSerializer keySerializer = (NFTypeSerializer) (framework.getSerializer(keyTypeName));
        NFTypeSerializer valueSerializer = (NFTypeSerializer) (framework.getSerializer(valueTypeName));
        HashGenericRecord independent = new HashGenericRecord(new HashOrderIndependent());
        for (Map.Entry<K, V> entry : map.entrySet()) {
            HashGenericRecord dependent = new HashGenericRecord(new HashOrderDependent());
            keySerializer.serialize(entry.getKey(), dependent);
            valueSerializer.serialize(entry.getValue(), dependent);
            independent.put(null, dependent.hash());
        }
        rec.put(null, independent.hash());
        rec.put(null, "}");
    }
View Full Code Here

                return;
            }
            record.getGenerator().writeFieldName(fieldName);
            record.getGenerator().writeStartObject();

            NFTypeSerializer fieldSerializer = getSerializer(typeName);
            JsonWriteGenericRecord fieldRecord = new JsonWriteGenericRecord(record.getGenerator());
            fieldSerializer.serialize(obj, fieldRecord);
            record.getGenerator().writeEndObject();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

            if (obj == null) {
                record.getGenerator().writeObjectField(fieldName, null);
                return;
            }
            record.getGenerator().writeArrayFieldStart(fieldName);
            NFTypeSerializer elemSerializer = getSerializer(typeName);
            JsonWriteGenericRecord elemRecord = new JsonWriteGenericRecord(record.getGenerator());

            for (T t : obj) {
                record.getGenerator().writeStartObject();
                elemSerializer.serialize(t, elemRecord);
                record.getGenerator().writeEndObject();
            }
            record.getGenerator().writeEndArray();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
View Full Code Here

        return deserializeObject(rec, typeName, node);
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    private <T> T deserializeObject(JsonReadGenericRecord rec, String typeName, JsonNode node) {
        NFTypeSerializer serializer = ((NFTypeSerializer) (framework.getSerializer(typeName)));
        return (T) serializer.deserialize(new JsonReadGenericRecord(serializer.getFastBlobSchema(), node));
    }
View Full Code Here

TOP

Related Classes of com.netflix.zeno.serializer.NFTypeSerializer

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.