Package com.sleepycat.db

Examples of com.sleepycat.db.DatabaseEntry


    }

    public void setUp() {

        SharedTestUtils.printTestName("TupleFormatTest." + getName());
        buffer = new DatabaseEntry();
        out = new TupleOutput();
    }
View Full Code Here


    }

    public void setUp() {

        SharedTestUtils.printTestName("TupleBindingTest." + getName());
        buffer = new DatabaseEntry();
        keyBuffer = new DatabaseEntry();
    }
View Full Code Here

        primitiveBindingTest(Float.TYPE, Float.class,
                             new Float(123.123), 4);
        primitiveBindingTest(Double.TYPE, Double.class,
                             new Double(123.123), 8);

        DatabaseEntry entry = new DatabaseEntry();
 
        StringBinding.stringToEntry("abc", entry);
  assertEquals(4, entry.getData().length);
        assertEquals("abc", StringBinding.entryToString(entry));

        new StringBinding().objectToEntry("abc", entry);
  assertEquals(4, entry.getData().length);

        StringBinding.stringToEntry(null, entry);
  assertEquals(2, entry.getData().length);
        assertEquals(null, StringBinding.entryToString(entry));

        new StringBinding().objectToEntry(null, entry);
  assertEquals(2, entry.getData().length);

        CharacterBinding.charToEntry('a', entry);
  assertEquals(2, entry.getData().length);
        assertEquals('a', CharacterBinding.entryToChar(entry));

        new CharacterBinding().objectToEntry(new Character('a'), entry);
  assertEquals(2, entry.getData().length);

        BooleanBinding.booleanToEntry(true, entry);
  assertEquals(1, entry.getData().length);
        assertEquals(true, BooleanBinding.entryToBoolean(entry));

        new BooleanBinding().objectToEntry(Boolean.TRUE, entry);
  assertEquals(1, entry.getData().length);

        ByteBinding.byteToEntry((byte) 123, entry);
  assertEquals(1, entry.getData().length);
        assertEquals((byte) 123, ByteBinding.entryToByte(entry));

        ShortBinding.shortToEntry((short) 123, entry);
  assertEquals(2, entry.getData().length);
        assertEquals((short) 123, ShortBinding.entryToShort(entry));

        new ByteBinding().objectToEntry(new Byte((byte) 123), entry);
  assertEquals(1, entry.getData().length);

        IntegerBinding.intToEntry(123, entry);
  assertEquals(4, entry.getData().length);
        assertEquals(123, IntegerBinding.entryToInt(entry));

        new IntegerBinding().objectToEntry(new Integer(123), entry);
  assertEquals(4, entry.getData().length);

        LongBinding.longToEntry(123, entry);
  assertEquals(8, entry.getData().length);
        assertEquals(123, LongBinding.entryToLong(entry));

        new LongBinding().objectToEntry(new Long(123), entry);
  assertEquals(8, entry.getData().length);

        FloatBinding.floatToEntry((float) 123.123, entry);
  assertEquals(4, entry.getData().length);
        assertTrue(((float) 123.123) == FloatBinding.entryToFloat(entry));

        new FloatBinding().objectToEntry(new Float((float) 123.123), entry);
  assertEquals(4, entry.getData().length);

        DoubleBinding.doubleToEntry(123.123, entry);
  assertEquals(8, entry.getData().length);
        assertTrue(123.123 == DoubleBinding.entryToDouble(entry));

        new DoubleBinding().objectToEntry(new Double(123.123), entry);
  assertEquals(8, entry.getData().length);

        BigIntegerBinding.bigIntegerToEntry
                (new BigInteger("1234567890123456"), entry);
        assertEquals(9, entry.getData().length);
        assertTrue((new BigInteger("1234567890123456")).equals
       (BigIntegerBinding.entryToBigInteger(entry)));

        new BigIntegerBinding().objectToEntry
                (new BigInteger("1234567890123456"), entry);
        assertEquals(9, entry.getData().length);
        forMoreCoverageTest(new BigIntegerBinding(),
                            new BigInteger("1234567890123456"));
 
        SortedFloatBinding.floatToEntry((float) 123.123, entry);
  assertEquals(4, entry.getData().length);
        assertTrue(((float) 123.123) ==
                   SortedFloatBinding.entryToFloat(entry));

        new SortedFloatBinding().objectToEntry
            (new Float((float) 123.123), entry);
  assertEquals(4, entry.getData().length);
        forMoreCoverageTest(new SortedFloatBinding(),
                            new Float((float) 123.123));

        SortedDoubleBinding.doubleToEntry(123.123, entry);
  assertEquals(8, entry.getData().length);
        assertTrue(123.123 == SortedDoubleBinding.entryToDouble(entry));

        new SortedDoubleBinding().objectToEntry(new Double(123.123), entry);
  assertEquals(8, entry.getData().length);
        forMoreCoverageTest(new SortedDoubleBinding(),
                            new Double(123.123));
    }
View Full Code Here

        throws DatabaseException {

        Random rand = new Random();

        /* DatabaseEntry represents the key and data of each record */
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();

        /*
         * Create a set of events. Each insertion is a separate, auto-commit
         * transaction.
         */
 
View Full Code Here

        throws DatabaseException {

        System.out.println("time=" +
                           new Date(LongBinding.entryToLong(firstKey)) +
                           eventBinding.entryToObject(firstData));
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();

        while (cursor.getNext(key, data, null) ==
               OperationStatus.SUCCESS) {
            if (LongBinding.entryToLong(key) > endDate) {
                break;
View Full Code Here

        }
    }

    private void printEvents(SecondaryCursor cursor)
        throws DatabaseException {
        DatabaseEntry timeKey = new DatabaseEntry();
        DatabaseEntry priceKey = new DatabaseEntry();
        DatabaseEntry eventData = new DatabaseEntry();

        while (cursor.getNext(priceKey, timeKey, eventData, null) ==
               OperationStatus.SUCCESS) {
            System.out.println("time=" +
                               new Date(LongBinding.entryToLong(timeKey)) +
View Full Code Here

    protected File(String name)
        throws IOException
    {
        setName(name);

        data = new DatabaseEntry(new byte[32]);
        data.setUserBuffer(data.getSize(), true);
    }
View Full Code Here

        {
            if (!create)
                throw new IOException("File does not exist: " + name);
            else
            {
                DatabaseEntry key = new DatabaseEntry(new byte[24]);
                DatabaseEntry data = new DatabaseEntry(null);
                Db blocks = directory.blocks;
                DbTxn txn = directory.txn;
                int flags = directory.flags;

                key.setUserBuffer(24, true);
                data.setPartial(true);

                uuid = new byte[16];

                try {
                    do {
View Full Code Here

        DataOutputStream out = new DataOutputStream(buffer);

        out.writeUTF(name);
        out.close();

        key = new DatabaseEntry(buffer.toByteArray());
        key.setUserBuffer(key.getSize(), true);

        this.name = name;
    }
View Full Code Here

        try {
            try {
                byte[] bytes = getKey();
                int ulen = bytes.length + 8;
                byte[] cursorBytes = new byte[ulen];
                DatabaseEntry cursorKey = new DatabaseEntry(cursorBytes);
                DatabaseEntry cursorData = new DatabaseEntry(null);
                Db files = directory.files;
                Db blocks = directory.blocks;
                DbTxn txn = directory.txn;
                int flags = directory.flags;

                System.arraycopy(bytes, 0, cursorBytes, 0, bytes.length);
                cursorKey.setUserBuffer(ulen, true);
                cursorData.setPartial(true);

                cursor = blocks.cursor(txn, flags);

                if (cursor.get(cursorKey, cursorData,
                               DbConstants.DB_SET_RANGE | flags) != DbConstants.DB_NOTFOUND)
View Full Code Here

TOP

Related Classes of com.sleepycat.db.DatabaseEntry

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.