Package com.sleepycat.bdb.bind.tuple

Examples of com.sleepycat.bdb.bind.tuple.TupleFormat


    // also tests TupleSerialBinding since TupleSerialMarshalledBinding extends
    // 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);
        assertSame(valueFormat, binding.getValueFormat());
        assertSame(keyFormat, binding.getKeyFormat());
View Full Code Here


    // also tests TupleSerialKeyExtractor since
    // 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);

        KeyExtractor extractor =
            new TupleSerialMarshalledKeyExtractor(binding, indexKeyFormat, "1",
                                                  false, true);
        assertSame(valueFormat, extractor.getValueFormat());
        assertNull(extractor.getPrimaryKeyFormat());
        assertSame(indexKeyFormat, extractor.getIndexKeyFormat());

        MarshalledObject val = new MarshalledObject("abc", "primary",
                                                    "index1", "index2");
        binding.objectToValue(val, buffer);
        binding.objectToKey(val, keyBuffer);

        extractor.extractIndexKey(keyBuffer, buffer, indexKeyBuffer);
        TupleInput in = indexKeyFormat.dataToInput(indexKeyBuffer);
        assertEquals("index1", in.readString());

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

    }

    public void setUp() {

        System.out.println("TupleOrderingTest." + getName());
        format = new TupleFormat();
        out = format.newOutput();
        prevBuf = null;
    }
View Full Code Here

    }

    public void setUp() {

        System.out.println("TupleFormatTest." + getName());
        format = new TupleFormat();
        buffer = new SimpleBuffer();
        out = format.newOutput();
    }
View Full Code Here

    }

    public void setUp() {

        System.out.println("TupleBindingTest." + getName());
        format = new TupleFormat();
        keyFormat = new TupleFormat();
        indexKeyFormat = new TupleFormat();
        buffer = new SimpleBuffer();
        keyBuffer = new SimpleBuffer();
        indexKeyBuffer = new SimpleBuffer();
    }
View Full Code Here

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

        // 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.
        // In this sample, the stores are opened with the DB_BTREE access
        // method and no duplicate keys allowed.  The DB_BTREE method is used
View Full Code Here

        // catalog is needed for serial data format (java serialization)
        catalog = new StoredClassCatalog(env, "catalog.db", null, dbFlags);

        // use Integer tuple format and binding for keys
        TupleFormat keyFormat = new TupleFormat();
        TupleBinding keyBinding =
            TupleBinding.getPrimitiveBinding(Integer.class, keyFormat);

        // use String serial format and binding for values
        SerialFormat valueFormat =
View Full Code Here

        // Create the data formats.  In this example, all key formats are
        // TupleFormat and all value formats are SerialFormat.  Note that
        // entity (combined key/value) classes are used for the value
        // formats--for details see the bindings in the SampleViews class.
        //
        partKeyFormat = new TupleFormat();
        partValueFormat = new SerialFormat(javaCatalog, Part.class);
        supplierKeyFormat = new TupleFormat();
        supplierValueFormat = new SerialFormat(javaCatalog, Supplier.class);
        shipmentKeyFormat = new TupleFormat();
        shipmentValueFormat = new SerialFormat(javaCatalog, Shipment.class);
        cityKeyFormat = new TupleFormat();

        // 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.  The DB_BTREE method is used
View Full Code Here

        // Create the data formats.  In this example, all key formats are
        // TupleFormat and all value formats are SerialFormat.  Note that
        // entity (combined key/value) classes are used for the value
        // formats--for details see the bindings in the SampleViews class.
        //
        partKeyFormat = new TupleFormat();
        partValueFormat = new SerialFormat(javaCatalog, Part.class);
        supplierKeyFormat = new TupleFormat();
        supplierValueFormat = new SerialFormat(javaCatalog, Supplier.class);
        shipmentKeyFormat = new TupleFormat();
        shipmentValueFormat = new SerialFormat(javaCatalog, Shipment.class);
        cityKeyFormat = new TupleFormat();

        // 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.  The DB_BTREE method is used
View Full Code Here

TOP

Related Classes of com.sleepycat.bdb.bind.tuple.TupleFormat

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.