Package com.sleepycat.bdb

Examples of com.sleepycat.bdb.TransactionWorker


    }

    void readAll()
        throws Exception {

        readRunner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                // map

                assertNotNull(map.toString());
                for (int i = beginKey; i <= endKey; i += 1) {
View Full Code Here


    }

    void readEven()
        throws Exception {

        readRunner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                int readBegin = ((beginKey & 1) != 0) ?
                                    (beginKey + 1) : beginKey;
                int readEnd = ((endKey & 1) != 0) (endKey - 1) : endKey;
                int readIncr = 2;
View Full Code Here

    }

    void readEvenList()
        throws Exception {

        readRunner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                int readBegin = ((beginKey & 1) != 0) ?
                                    (beginKey + 1) : beginKey;
                int readEnd = ((endKey & 1) != 0) (endKey - 1) : endKey;
                int readIncr = 2;
View Full Code Here

    }

    void bulkOperations()
        throws Exception {

        writeRunner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                HashMap hmap = new HashMap();
                for (int i = beginKey; i <= endKey; i += 1) {
                    hmap.put(makeKey(i), makeVal(i));
                }
View Full Code Here

    }

    void bulkListOperations()
        throws Exception {

        writeRunner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                ArrayList alist = new ArrayList();
                for (int i = beginKey; i <= endKey; i += 1) {
                    alist.add(makeVal(i));
                }
View Full Code Here

    void readWriteRange(final int type, final int rangeBegin,
                        final int rangeEnd)
        throws Exception {

        writeRunner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                setRange(type, rangeBegin, rangeEnd);
                createOutOfRange(rangeBegin, rangeEnd);
                if (rangeType != TAIL)
                    writeOutOfRange(new Long(rangeEnd + 1));
View Full Code Here

    }

    void readWriteDuplicates()
        throws Exception {

        writeRunner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                if (index == null) {
                    readWritePrimaryDuplicates(beginKey);
                    readWritePrimaryDuplicates(beginKey + 1);
                    readWritePrimaryDuplicates(endKey);
View Full Code Here

                    }
                    break;
                }
                case 3: {
                    // write with Map.duplicates().iterator().add()
                    writeIterRunner.run(new TransactionWorker() {
                        public void doWork() throws Exception {
                            Collection dups = map.duplicates(key);
                            Iterator iter = dups.iterator();
                            assertEquals(values[0], iter.next());
                            assertTrue(!iter.hasNext());
                            try {
                                for (int j = 1; j < values.length; j += 1) {
                                    ((ListIterator) iter).add(values[j]);
                                }
                            } finally {
                                StoredIterator.close(iter);
                            }
                        }
                    });
                    break;
                }
                case 4: {
                    // write with Map.values().add()
                    if (!isEntityBinding) continue;
                    Collection set = map.values();
                    for (int j = 1; j < values.length; j += 1) {
                        set.add(values[j]);
                    }
                    break;
                }
                default: {
                    break outerLoop;
                }
            }
            // read duplicates
            readDuplicates(i, key, values);
            // remove duplicates
            switch (writeMode) {
                case 0: {
                    // remove with Map.remove()
                    map.remove(key); // remove all values
                    map.put(key, values[0]); // put back original value
                    break;
                }
                case 1: {
                    // remove with Map.keySet().remove()
                    map.keySet().remove(key); // remove all values
                    map.put(key, values[0]); // put back original value
                    break;
                }
                case 2: {
                    // remove with Map.duplicates().clear()
                    dups = map.duplicates(key);
                    dups.clear(); // remove all values
                    dups.add(values[0]); // put back original value
                    break;
                }
                case 3: {
                    // remove with Map.duplicates().iterator().remove()
                    writeIterRunner.run(new TransactionWorker() {
                        public void doWork() throws Exception {
                            Collection dups = map.duplicates(key);
                            Iterator iter = dups.iterator();
                            try {
                                for (int j = 0; j < values.length; j += 1) {
View Full Code Here

        final TransactionRunner runner = new TransactionRunner(env);

        assertNull(currentTxn.getTxn());

        runner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                final DbTxn txn1 = currentTxn.getTxn();
                assertNotNull(txn1);
                assertNull(map.put(ONE, ONE));
                assertEquals(ONE, map.get(ONE));

                runner.run(new TransactionWorker() {
                    public void doWork() throws Exception {
                        final DbTxn txn2 = currentTxn.getTxn();
                        assertNotNull(txn2);
                        assertTrue(txn1 != txn2);
                        assertNull(map.put(TWO, TWO));
View Full Code Here

        final TransactionRunner runner = new TransactionRunner(env);

        assertNull(currentTxn.getTxn());

        runner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                final DbTxn txn1 = currentTxn.getTxn();
                assertNotNull(txn1);
                assertNull(map.put(ONE, ONE));
                assertEquals(ONE, map.get(ONE));

                try {
                    runner.run(new TransactionWorker() {
                        public void doWork() throws Exception {
                            final DbTxn txn2 = currentTxn.getTxn();
                            assertNotNull(txn2);
                            assertTrue(txn1 != txn2);
                            assertNull(map.put(TWO, TWO));
View Full Code Here

TOP

Related Classes of com.sleepycat.bdb.TransactionWorker

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.