Package com.sleepycat.bdb.bind.serial

Examples of com.sleepycat.bdb.bind.serial.SerialFormat


        catalog = new StoredClassCatalog(env, CATALOG_FILE,
                                         null, openFlags);
        catalog2 = new StoredClassCatalog(env, "new_catalog.db", null,
                                          openFlags);

        SerialFormat keyFormat = new SerialFormat(catalog,
                                                  String.class);
        SerialFormat valueFormat = new SerialFormat(catalog,
                                                    TestSerial.class);
        store = new DataStore(openDb(STORE_FILE),
                              keyFormat, valueFormat, null);

        SerialBinding keyBinding = new SerialBinding(keyFormat);
View Full Code Here


    private void primitiveBindingTest(Object val)
        throws IOException {

        Class cls = val.getClass();
        SerialFormat format = new SerialFormat(catalog, cls);
        DataBinding binding = new SerialBinding(format);
        assertSame(format, binding.getDataFormat());

        binding.objectToData(val, buffer);
        assertTrue(buffer.getDataLength() > 0);
View Full Code Here

    }

    public void testSerialSerialBinding()
        throws IOException {

        SerialFormat keyFormat = new SerialFormat(catalog, String.class);
        SerialFormat valueFormat = new SerialFormat(catalog, String.class);
        EntityBinding binding = new MySerialSerialBinding(keyFormat,
                                                          valueFormat);
        assertSame(keyFormat, binding.getKeyFormat());
        assertSame(valueFormat, binding.getValueFormat());
View Full Code Here

    }

    public void testSerialSerialKeyExtractor()
        throws IOException {

        SerialFormat keyFormat = new SerialFormat(catalog, String.class);
        SerialFormat valueFormat = new SerialFormat(catalog, String.class);
        SerialFormat indexKeyFormat = new SerialFormat(catalog, String.class);
        EntityBinding binding = new MySerialSerialBinding(keyFormat,
                                                          valueFormat);
        KeyExtractor extractor = new MySerialSerialExtractor(keyFormat,
                                                             valueFormat,
                                                             indexKeyFormat);
        assertSame(keyFormat, extractor.getPrimaryKeyFormat());
        assertSame(valueFormat, extractor.getValueFormat());
        assertSame(indexKeyFormat, extractor.getIndexKeyFormat());

        String val = "key#value?indexKey";
        binding.objectToValue(val, buffer);
        binding.objectToKey(val, keyBuffer);

        extractor.extractIndexKey(keyBuffer, buffer, indexKeyBuffer);
        assertEquals("indexKey", indexKeyFormat.dataToObject(indexKeyBuffer));

        extractor.clearIndexKey(buffer);
        extractor.extractIndexKey(keyBuffer, buffer, indexKeyBuffer);
        assertEquals(0, indexKeyBuffer.getDataLength());
    }
View Full Code Here

    // it
    public void testTupleSerialMarshalledBinding()
        throws IOException {

        TupleFormat keyFormat = new TupleFormat();
        SerialFormat valueFormat = new SerialFormat(catalog,
                                                    MarshalledObject.class);
        TupleFormat indexKeyFormat = new TupleFormat();

        EntityBinding binding =
            new TupleSerialMarshalledBinding(keyFormat, valueFormat);
View Full Code Here

    // TupleSerialMarshalledKeyExtractor extends it
    public void testTupleSerialMarshalledKeyExtractor()
        throws IOException {

        TupleFormat keyFormat = new TupleFormat();
        SerialFormat valueFormat = new SerialFormat(catalog,
                                                    MarshalledObject.class);
        TupleFormat indexKeyFormat = new TupleFormat();
        TupleSerialMarshalledBinding binding =
            new TupleSerialMarshalledBinding(keyFormat, valueFormat);
View Full Code Here

     */
    public DataStore newDataStore(Db db, Class baseClass,
                                  PrimaryKeyAssigner keyAssigner) {

        return new DataStore(db, TUPLE_FORMAT,
                             new SerialFormat(catalog, baseClass),
                             keyAssigner);
    }
View Full Code Here

        // Create the data formats.  In this example, all key formats are
        // TupleFormat and all value formats are SerialFormat.
        //
        partKeyFormat = new TupleFormat();
        partValueFormat = new SerialFormat(javaCatalog, PartValue.class);
        supplierKeyFormat = new TupleFormat();
        supplierValueFormat = new SerialFormat(javaCatalog,
                                               SupplierValue.class);
        shipmentKeyFormat = new TupleFormat();
        shipmentValueFormat = new SerialFormat(javaCatalog,
                                               ShipmentValue.class);
        cityKeyFormat = new TupleFormat();

        // Open the Berkeley DB database, along with the associated
        // DataStore, for the part, supplier and shipment stores.
View Full Code Here

        TupleFormat keyFormat = new TupleFormat();
        TupleBinding keyBinding =
            TupleBinding.getPrimitiveBinding(Integer.class, keyFormat);

        // use String serial format and binding for values
        SerialFormat valueFormat =
            new SerialFormat(catalog, String.class);
        SerialBinding valueBinding = new SerialBinding(valueFormat);

        // open a BTREE (sorted) data store
        Db db = new Db(env, 0);
        db.open(null, "data.db", null, Db.DB_BTREE, dbFlags, 0);
View Full Code Here

        javaCatalog = new StoredClassCatalog(env, CLASS_CATALOG, null, flags);

        // Create the data formats.  In this example, all formats are
        // SerialFormat.
        //
        partKeyFormat = new SerialFormat(javaCatalog, PartKey.class);
        partValueFormat = new SerialFormat(javaCatalog, PartValue.class);
        supplierKeyFormat = new SerialFormat(javaCatalog, SupplierKey.class);
        supplierValueFormat =
                new SerialFormat(javaCatalog, SupplierValue.class);
        shipmentKeyFormat = new SerialFormat(javaCatalog, ShipmentKey.class);
        shipmentValueFormat =
            new SerialFormat(javaCatalog, ShipmentValue.class);

        // Open the Berkeley DB database, along with the associated
        // DataStore, for the part, supplier and shipment stores.
        // In this sample, the stores are opened with the DB_BTREE access
        // method and no duplicate keys allowed.  Although the DB_BTREE method
View Full Code Here

TOP

Related Classes of com.sleepycat.bdb.bind.serial.SerialFormat

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.