Package com.thinkaurelius.titan.graphdb.database.serialize.kryo

Examples of com.thinkaurelius.titan.graphdb.database.serialize.kryo.KryoSerializer




    public Serializer getSerializer() {
        Configuration config = configuration.subset(ATTRIBUTE_NAMESPACE);
        Serializer serializer = new KryoSerializer(config);
        for (RegisteredAttributeClass<?> clazz : getRegisteredAttributeClasses(config)) {
            clazz.registerWith(serializer);
        }
        return serializer;
    }
View Full Code Here


        int partitionBits = 21;
        IDManager eid = new IDManager(partitionBits);
        int trails = 1000000;
        assertEquals(eid.getMaxPartitionCount(), (1 << partitionBits) - 1);

        KryoSerializer serializer = new KryoSerializer();
        for (int t = 0; t < trails; t++) {
            long count = RandomGenerator.randomLong(1, eid.getMaxTitanTypeCount());
            long id;
            int dirID;
            RelationType type;
            if (Math.random() < 0.5) {
                id = eid.getEdgeLabelID(count);
                assertTrue(eid.isEdgeLabelID(id));
                type = RelationType.EDGE;
                if (Math.random() < 0.5)
                    dirID = IDHandler.EDGE_IN_DIR;
                else
                    dirID = IDHandler.EDGE_OUT_DIR;
            } else {
                type = RelationType.PROPERTY;
                id = eid.getPropertyKeyID(count);
                assertTrue(eid.isPropertyKeyID(id));
                dirID = IDHandler.PROPERTY_DIR;
            }
            assertTrue(eid.isTypeID(id));

            StaticBuffer b = IDHandler.getEdgeType(id, dirID);
//            System.out.println(dirID);
//            System.out.println(getBinary(id));
//            System.out.println(getBuffer(b.asReadBuffer()));
            ReadBuffer rb = b.asReadBuffer();
            long[] vals = IDHandler.readEdgeType(rb);
            assertEquals(id,vals[0]);
            assertEquals(dirID, vals[1]);
            assertFalse(rb.hasRemaining());

            //Inline edge type
            WriteBuffer wb = new WriteByteBuffer(9);
            IDHandler.writeInlineEdgeType(wb, id);
            long newId = IDHandler.readInlineEdgeType(wb.getStaticBuffer().asReadBuffer());
            assertEquals(id,newId);

            //Compare to Kryo
            DataOutput out = serializer.getDataOutput(10, true);
            IDHandler.writeEdgeType(out, id, dirID);
            assertEquals(b, out.getStaticBuffer());

            //Make sure the bounds are right
            StaticBuffer[] bounds = IDHandler.getBounds(type);
View Full Code Here

    public static final StaticBuffer MAX_KEY = ByteBufferUtil.getLongBuffer(-1);

    public static void setUTF8Serializer() {
        Configuration conf  = new PropertiesConfiguration();
        conf.setProperty(GraphDatabaseConfiguration.STRING_COMPACT_SERIALIZE,true);
        KeyValueStoreUtil.serial = new KryoSerializer(conf);
    }
View Full Code Here

        conf.setProperty(GraphDatabaseConfiguration.STRING_COMPACT_SERIALIZE,true);
        KeyValueStoreUtil.serial = new KryoSerializer(conf);
    }

    public static void setDefaultSerializer() {
        KeyValueStoreUtil.serial = new KryoSerializer();
    }
View Full Code Here

{
    @Before
    public void setUp() throws Exception {
        Configuration conf = new PropertiesConfiguration();
        conf.setProperty(GraphDatabaseConfiguration.STRING_COMPACT_SERIALIZE,true);
        serialize = new KryoSerializer(conf);
        serialize.registerClass(TestEnum.class, RESERVED_ID_OFFSET + 1);
        serialize.registerClass(TestClass.class, RESERVED_ID_OFFSET + 2);
        serialize.registerClass(short[].class, RESERVED_ID_OFFSET + 3);

        printStats = true;
View Full Code Here

    @Before
    public void setUp() throws Exception {
        Configuration conf = new PropertiesConfiguration();
        conf.setProperty(GraphDatabaseConfiguration.ATTRIBUTE_ALLOW_ALL_SERIALIZABLE_KEY,false);
        serialize = new KryoSerializer(conf);
        serialize.registerClass(TestEnum.class, RESERVED_ID_OFFSET + 1);
        serialize.registerClass(TestClass.class, RESERVED_ID_OFFSET + 2);
        serialize.registerClass(short[].class, RESERVED_ID_OFFSET + 3);

        printStats = true;
View Full Code Here

    }


    @Test
    public void testObjectVerification() {
        KryoSerializer s = new KryoSerializer();
        DataOutput out = s.getDataOutput(128, true);
        Long l = Long.valueOf(128);
        out.writeClassAndObject(l);
        Calendar c = Calendar.getInstance();
        out.writeClassAndObject(c);
        NoDefaultConstructor dc = new NoDefaultConstructor(5);
View Full Code Here

TOP

Related Classes of com.thinkaurelius.titan.graphdb.database.serialize.kryo.KryoSerializer

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.