Пример #1
0
  private void testRangeScan(long rangeSize) throws Exception {
    addAscending(0L, 1L, VALUE_COUNT);
    btree.sync();

    byte[] minData = new byte[8];
    byte[] maxData = new byte[8];

    Thread.sleep(500L);
    long startTime = System.currentTimeMillis();

    for (long minValue = 0L; minValue < VALUE_COUNT; minValue += rangeSize) {
      ByteArrayUtil.putLong(minValue, minData, 0);
      ByteArrayUtil.putLong(minValue + rangeSize, maxData, 0);

      RecordIterator iter = btree.iterateRange(minData, maxData);
      try {
        while (iter.next() != null) {}
      } finally {
        iter.close();
      }
    }

    long endTime = System.currentTimeMillis();
    printTime(startTime, endTime, "testRangeScan" + rangeSize);
  }
Пример #2
0
  private void addRandom(int valueCount) throws IOException {
    Random random = new Random(0L);

    byte[] data = new byte[8];
    for (int i = 0; i < valueCount; i++) {
      ByteArrayUtil.putLong(random.nextLong(), data, 0);
      btree.insert(data);
    }
  }
Пример #3
0
  private void remove(long startValue, long increment, int valueCount) throws IOException {
    long value = startValue;
    byte[] data = new byte[8];

    for (int i = 0; i < valueCount; i++) {
      ByteArrayUtil.putLong(value, data, 0);
      btree.remove(data);
      value += increment;
    }
  }
Пример #4
0
  private void update(long startValue, long increment, int valueCount, long updateDelta)
      throws IOException {
    long oldValue = startValue;
    long newValue;

    byte[] oldData = new byte[8];
    byte[] newData = new byte[8];

    for (int i = 0; i < valueCount; i++) {
      newValue = oldValue += updateDelta;

      ByteArrayUtil.putLong(oldValue, oldData, 0);
      ByteArrayUtil.putLong(newValue, newData, 0);

      btree.insert(newData);
      btree.remove(oldData);

      oldValue += increment;
    }
  }