Package xbird.storage.index

Examples of xbird.storage.index.BTree$Synchronizer


    }

    public void testBplusTreeUniq() throws IOException, DbException {
        File tmpFile = File.createTempFile("btree", ".tmp");
        tmpFile.deleteOnExit();
        BTree btree = new BTree(tmpFile, false);
        btree.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        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);

        btree.flush(true, true);

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


        this(name, file, false);
    }

    public BTreeIndexer(String name, File file, boolean bulkBuild) {
        this.name = name;
        final BTree tree = new BTree(file, PAGE_SIZE, bulkBuild ? INDEX_BUILD_PAGES
                : IN_MEMORY_PAGES, true);
        try {
            tree.init(bulkBuild);
        } catch (DbException e) {
            throw new IllegalStateException("failed on initializing b+-tree: "
                    + file.getAbsolutePath(), e);
        }
        this.btree = tree;
View Full Code Here

        public DescriptorBTree(File baseFile, int cacheSize) {
            String descName = baseFile.getName() + DESCRIPTOR_APPENDIX_BTREE;
            File descFile = new File(baseFile.getParent(), descName);
            this.descFile = descFile;
            BTree tree = new BTree(descFile, 2048, cacheSize, false);
            try {
                tree.init(false);
            } catch (DbException e) {
                throw new IllegalStateException("failed on initializing b+-tree: "
                        + descFile.getAbsolutePath(), e);
            }
            this.btree = tree;
View Full Code Here

        public DescriptorBTree(File baseFile, int cacheSize) {
            String descName = baseFile.getName() + DESCRIPTOR_APPENDIX_BTREE;
            File descFile = new File(baseFile.getParent(), descName);
            this.descFile = descFile;
            BTree tree = new BTree(descFile, 2048, cacheSize, false);
            try {
                tree.init(false);
            } catch (DbException e) {
                throw new IllegalStateException("failed on initializing b+-tree: "
                        + descFile.getAbsolutePath(), e);
            }
            this.btree = tree;
View Full Code Here

TOP

Related Classes of xbird.storage.index.BTree$Synchronizer

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.