Package xbird.storage.index

Examples of xbird.storage.index.Value


        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[BplusTreeUniq] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            long v = random.nextLong();
            byte[] b = Primitives.toBytes(v);
            Value k = new Value(b);
            Assert.assertTrue(btree.addValue(k, v) == -1);
            list.add(b);
        }
        System.err.println(sw1);
View Full Code Here


                + "_buckets] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
        System.err.println(sw2);
        hash.drop();
    }
View Full Code Here

                + "_buckets_2kPage] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets_2kPage] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
        System.err.println(sw2);
        hash.drop();
    }
View Full Code Here

                + "_buckets] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
        System.err.println(sw2);
        hash.drop();
    }
View Full Code Here

        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[BFileUniq] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            long v = random.nextLong();
            byte[] b = Primitives.toBytes(v);
            Value k = new Value(b);
            bfile.addValue(k, b);
            list.add(b);
        }
        System.err.println(sw1);

        bfile.flush(true, true);

        StopWatch sw2 = new StopWatch("[BFileUniq] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), bfile.getValue(new Value(b)));
        }
        System.err.println(sw2);
        System.err.println("[BFileUniq] " + tmpFile.getAbsolutePath() + " - size: "
                + tmpFile.length());
        bfile.drop();
View Full Code Here

    public String getName() {
        return name;
    }

    public long add(byte[] key, long value) throws DbException {
        return btree.addValue(new Value(key), value);
    }
View Full Code Here

    public long add(byte[] key, long value) throws DbException {
        return btree.addValue(new Value(key), value);
    }

    public long remove(byte[] key) throws DbException {
        return btree.removeValue(new Value(key));
    }
View Full Code Here

    public long remove(byte[] key) throws DbException {
        return btree.removeValue(new Value(key));
    }

    public long remove(byte[] key, long value) throws DbException {
        return btree.removeValue(new Value(key));
    }
View Full Code Here

            this.btree = tree;
        }

        public void addRecord(long idx, long addr) throws IOException {
            try {
                btree.addValue(new Value(idx), addr);
            } catch (DbException e) {
                throw new IOException("failed to add a record addr#" + addr + " to the idx#" + idx);
            }
        }
View Full Code Here

            }
        }

        public long getRecordAddr(long idx) throws IOException {
            try {
                return btree.findValue(new Value(idx));
            } catch (DbException e) {
                throw new IOException("failed to get a record of idx#" + idx);
            }
        }
View Full Code Here

TOP

Related Classes of xbird.storage.index.Value

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.