Package org.chaidb.db.api.keys

Examples of org.chaidb.db.api.keys.IntKey


        try {
            System.out.println("Initializing database...");
            db = new Database("D:\\temp");
            System.out.println("Initializing BTree...");
            BTree testTree = db.openBTree("notxn.btree", BTreeType.BTREE);
            IntKey testKey = new IntKey(1);
            //store
            System.out.println("Testing store...");
            testTree.store(testKey, "Test Value".getBytes());
            //lookup
            System.out.println("Testing lookup...");
View Full Code Here


        try {
            System.out.println("Initializing database...");
            db = new Database("D:\\temp");
            Transaction txn = db.beginTransaction();
            BTree testTree = null;
            IntKey testKey = null;
            Object o = null;
            try {
                System.out.println("Initializing BTree...");
                testTree = db.openBTree("txn.btree", BTreeType.BTREE);
                testKey = new IntKey(1);
                //store
                System.out.println("Testing store...");
                testTree.store(testKey, "Test Value".getBytes());
                //lookup
                System.out.println("Testing lookup...");
View Full Code Here

        docRoot = (PageNumber) id2root.get(new Integer(docID));

        if (docRoot != null) {
            return docRoot;
        }
        Key tmpKey = new IntKey(docID);
        indexBTree.acquire(kContext, READ_MODE);
        byte[] bRoot = null;
        try {
            bRoot = (byte[]) indexBTree.lookup(tmpKey, kContext);
        } finally {
View Full Code Here

        //search key2root first
        Integer idocID = new Integer(docID);
        PageNumber subRoot = (PageNumber) id2root.get(idocID);
        if (subRoot == null) {
            Key tmpKey = new IntKey(docID);
            indexBTree.acquire(kContext, READ_MODE);
            byte[] bRoot = null;
            try {
                bRoot = (byte[]) indexBTree.lookup(tmpKey, kContext);
            } finally {
View Full Code Here

//            }
            return;
        }
        this.getBTreeSpec().setModified(true);
        /*Appended by ben zhang at aug, 14, 2002 */
        IntKey tmpKey = new IntKey(docID.intValue());

        try {
            indexBTree.acquire(kContext, WRITE_MODE);
            if (docRoot.getPageNumber() <= 0) {
                indexBTree.delete(tmpKey, kContext);
View Full Code Here

        Transaction txn = db.beginTransaction();
        BTree btree = db.openBTree("testtxn.idb", BTreeType.HYPER_BTREE);
        try {
            btree.acquire(LockType.WRITE);
            for (int i = 0; i < 100; i++) {
                IntKey key = new IntKey(i);
                byte[] data = new byte[2];
                data[0] = (byte) (i * 2 + 1);
                data[1] = (byte) (i * 2 + 2);
                btree.store(key, data);
            }
View Full Code Here

        Transaction txn = db.beginTransaction();
        BTree btree = db.openBTree("testtxn.idb", BTreeType.HYPER_BTREE);
        try {
            btree.acquire(LockType.WRITE);
            for (int i = 101; i < 200; i++) {
                IntKey key = new IntKey(i);
                byte[] data = new byte[2];
                data[0] = (byte) (i * 2 + 1);
                data[1] = (byte) (i * 2 + 2);
                btree.store(key, data);
            }
View Full Code Here

        Transaction txn = db.beginTransaction();
        BTree btree = db.openBTree("testtxn.idb", BTreeType.HYPER_BTREE);
        try {
            btree.acquire(LockType.READ);
            for (int i = 0; i < 100; i++) {
                IntKey key = new IntKey(i);
                System.out.print(key + ":");

                DuplicatedKeyIterator it = btree.lookupValues(key);
                while (it.hasNext()) {
                    byte[] bytes = (byte[]) it.next();
View Full Code Here

        Transaction txn = db.beginTransaction();
        BTree btree = db.openBTree("testtxn.idb", BTreeType.HYPER_BTREE);
        try {
            btree.acquire(LockType.WRITE);
            for (int i = 0; i < 200; i++) {
                IntKey key = new IntKey(i);
                btree.delete(key);
            }
            btree.release();
            txn.commit();
View Full Code Here

    private static void testStore() throws ChaiDBException {
        Database db = new Database("D:\\temp");
        BTree btree = db.openBTree("test.idb", BTreeType.HYPER_BTREE);
        try {
            IntKey key = new IntKey(1);
            byte[] data = new byte[2];
            data[0] = 1;
            data[1] = 2;
            btree.acquire(LockType.WRITE);
            btree.store(key, data);
View Full Code Here

TOP

Related Classes of org.chaidb.db.api.keys.IntKey

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.