Package org.xtreemfs.babudb.index

Examples of org.xtreemfs.babudb.index.DefaultByteRangeComparator


    public DatabaseInternal createDatabase(String databaseName, int numIndices,
            ByteRangeComparator[] comparators) throws BabuDBException {
       
        if (comparators == null) {
            comparators = new ByteRangeComparator[numIndices];
            final ByteRangeComparator defaultComparator = new DefaultByteRangeComparator();
            for (int i = 0; i < numIndices; i++) {
                comparators[i] = defaultComparator;
            }
        }
       
View Full Code Here


       
        this.dbsByName = new HashMap<String, DatabaseInternal>();
        this.dbsById = new HashMap<Integer, DatabaseInternal>();
       
        this.compInstances = new HashMap<String, ByteRangeComparator>();
        this.compInstances.put(DefaultByteRangeComparator.class.getName(), new DefaultByteRangeComparator());
       
        this.nextDbId = 1;
        this.dbModificationLock = new Object();
               
        initializeTransactionManager();
View Full Code Here

    @Override
    public void reset() throws BabuDBException {
        nextDbId = 1;
       
        compInstances.clear();
        compInstances.put(DefaultByteRangeComparator.class.getName(), new DefaultByteRangeComparator());
       
        dbs.getDBConfigFile().reset();
    }
View Full Code Here

        byte[][] vals = new byte[][] { "1".getBytes(), "2".getBytes(), "3".getBytes(), "4".getBytes(),
            "5".getBytes() };
       
        LSMTree tree = new LSMTree(null, DefaultByteRangeComparator.getInstance(), COMPRESSION, 16,
            1024 * 1024 * 512, MMAP, -1);
        TreeMap<byte[], byte[]> map = new TreeMap<byte[], byte[]>(new DefaultByteRangeComparator());
       
        // insert some key-value pairs
        for (int i = 0; i < keys.length; i++) {
            tree.insert(keys[i], vals[i]);
            map.put(keys[i], vals[i]);
View Full Code Here

    public void testPrefixLookups() throws Exception {
       
        // randomly insert 200 elements in a map
       
        final int numElements = 200;
        final DefaultByteRangeComparator comp = DefaultByteRangeComparator.getInstance();
       
        LSMTree tree = new LSMTree(null, comp, COMPRESSION, 16, 1024 * 1024 * 512, MMAP, -1);
       
        final TreeMap<byte[], byte[]> map1 = new TreeMap<byte[], byte[]>(comp);
        for (int i = 0x10; i < numElements; i++) {
View Full Code Here

    public void testRangeLookups() throws Exception {
       
        // randomly insert 200 elements in a map
       
        final int numElements = 200;
        final DefaultByteRangeComparator comp = DefaultByteRangeComparator.getInstance();
       
        LSMTree tree = new LSMTree(null, comp, COMPRESSION, 16, 1024 * 1024 * 512, MMAP, -1);
       
        // insert all 200 keys
        final TreeMap<byte[], byte[]> map1 = new TreeMap<byte[], byte[]>(comp);
View Full Code Here

   
    public void testSnapshotMaterialization() throws Exception {
       
        // randomly insert 200 elements in a map
       
        final DefaultByteRangeComparator comp = DefaultByteRangeComparator.getInstance();
        final byte[] value = "value".getBytes();
        final String[] keys = { "a", "v", "blub", "blubber", "ertz", "yagga", "zwum", "x" };
       
        LSMTree tree = new LSMTree(null, comp, COMPRESSION, 16, 1024 * 1024 * 512, MMAP, -1);
        for (String k : keys)
View Full Code Here

    public void testTransactionSerialization() throws Exception {
       
        // create and initialize a transaction
        BabuDBTransaction txn = new BabuDBTransaction();
        txn.createDatabase("db1", 5);
        txn.createDatabase("db1", 1, new ByteRangeComparator[] { new DefaultByteRangeComparator() });
        txn.insertRecord("db1", 3, "hello".getBytes(), "world".getBytes());
        txn.deleteRecord("db2", 1, "blub".getBytes());
        txn.deleteDatabase("db1");
        txn.insertRecord("new-database", 3, "x".getBytes(), "".getBytes());
       
View Full Code Here

               
            });
        }
       
        // read the LSM tree
        LSMTree tree = new LSMTree(path, new DefaultByteRangeComparator(), false, 16, 1024 * 1024 * 512, true, -1);
       
        System.out.println("inserting " + inserts + " random elements ...");
        for (int i = 0; i < inserts; i++) {
            byte[] entry = createRandomString(minChar, maxChar, minStrLen, maxStrLen).getBytes();
            tree.insert(entry, entry);
View Full Code Here

            } else {
              index.writeIndex(DataGenerator.randomIterator(lookupHits, size, hitrate, minStrLen, maxStrLen, minChar, maxChar));
            }
        } else {
          //   populate the lookup-hits table
          DiskIndex diskIndexTmp = new DiskIndex(path, new DefaultByteRangeComparator(), compress, mmap);
          Iterator<Entry<byte[], byte[]>> itTmp = diskIndexTmp.rangeLookup(null, null, true);
          while(itTmp.hasNext()) {
                if(generator.nextInt() % hitrate == 0)
                  lookupHits.add(itTmp.next().getKey());
          }
          diskIndexTmp.destroy();
        }
       
        // do a warm-up phase to trick the JVM
        int warmups = 5;
       
        while(warmups-- > 0) {
          int readEntries = 10000;         
          //   read the disk index
          DiskIndex diskIndex = new DiskIndex(path, new DefaultByteRangeComparator(), compress, mmap);
          Iterator<Entry<byte[], byte[]>> it = diskIndex.rangeLookup(null, null, true);
          while(it.hasNext() && readEntries-- > 0) it.next();
          diskIndex.destroy();
        }

      // clear caches...
      Runtime.getRuntime().exec("/bin/sync");
      Runtime.getRuntime().exec("/bin/echo 3 > /proc/sys/vm/drop_caches");
   
      // run garbage collection to remove any existing mmap:ed pages
      Runtime.getRuntime().gc();
     
      //   read the disk index
      DiskIndex diskIndex = new DiskIndex(path, new DefaultByteRangeComparator(), compress, mmap);
      Iterator<Entry<byte[], byte[]>> it = diskIndex.rangeLookup(null, null, true);
   
      /* iterate over all data in the disk index to measure the prefix lookup throughput */
      long iterStart = System.currentTimeMillis();
      while(it.hasNext()) it.next();
View Full Code Here

TOP

Related Classes of org.xtreemfs.babudb.index.DefaultByteRangeComparator

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.