Examples of BTree

The first reference was used to implement this class.

TODO: clean up code @author Arjohn Kampman @author Enrico Minack

  • uk.ac.open.kmi.smartproducts.sesame.sail.btree.BTree
    tvincent.edu/swd/btree/btree.html
  • ,
  • http://bluerwhite.org/btree/
  • , and
  • http://semaphorecorp.com/btp/algo.html
  • . The first reference was used to implement this class.

    TODO: clean up code @author Arjohn Kampman @author Enrico Minack

  • xbird.storage.index.BTree
    BTree represents a Variable Magnitude Simple-Prefix B+Tree File.
    @author Makoto YUI (yuin405+xbird@gmail.com)

  • Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.BTree

      private void checkAllCommitted()
        throws IOException
      {
        for (TripleIndex index : indexes) {
          System.out.println("Checking " + index + " index");
          BTree btree = index.getBTree();
          RecordIterator iter = btree.iterateAll();
          try {
            for (byte[] data = iter.next(); data != null; data = iter.next()) {
              byte flags = data[FLAG_IDX];
              boolean wasAdded = (flags & ADDED_FLAG) != 0;
              boolean wasRemoved = (flags & REMOVED_FLAG) != 0;
    View Full Code Here

    Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.BTree

        boolean validCache = updatedTriplesCache != null && updatedTriplesCache.isValid();

        byte txnFlagsMask = ~(ADDED_FLAG | REMOVED_FLAG | TOGGLE_EXPLICIT_FLAG);

        for (TripleIndex index : indexes) {
          BTree btree = index.getBTree();

          RecordIterator iter;
          if (validCache) {
            // Use the cached set of updated triples
            iter = updatedTriplesCache.getRecords();
          }
          else {
            // Cache is invalid; too much updates(?). Iterate over all triples
            iter = btree.iterateAll();
          }

          try {
            byte[] data = null;
            while ((data = iter.next()) != null) {
              byte flags = data[FLAG_IDX];
              boolean wasAdded = (flags & ADDED_FLAG) != 0;
              boolean wasRemoved = (flags & REMOVED_FLAG) != 0;
              boolean wasToggled = (flags & TOGGLE_EXPLICIT_FLAG) != 0;

              if (wasAdded) {
                btree.remove(data);
              }
              else {
                if (wasRemoved || wasToggled) {
                  data[FLAG_IDX] &= txnFlagsMask;

                  if (validCache) {
                    // We're iterating the cache
                    btree.insert(data);
                  }
                  else {
                    // We're iterating the BTree itself
                    iter.set(data);
                  }
    View Full Code Here

    Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.BTree

        public TripleIndex(String fieldSeq)
          throws IOException
        {
          tripleComparator = new TripleComparator(fieldSeq);
          btree = new BTree(dir, getFilenamePrefix(fieldSeq), 2048, RECORD_LENGTH, tripleComparator, forceSync);
        }
    View Full Code Here

    Examples of xbird.storage.index.BTree

        }

        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

    Examples of xbird.storage.index.BTree

            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

    Examples of xbird.storage.index.BTree

            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
    Copyright © 2018 www.massapi.com. 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.