Package net.sf.joafip.btreeplus.entity.mock

Examples of net.sf.joafip.btreeplus.entity.mock.MockDataBlock


    /**/new int[] { 5, 7, 10, 15, 17 },
    /**/new long[] { 2000, 4000, 1000, 3000, 5000 });

    // test no more add possible
    final int maxNumberOfEntries = maxNumberOfEntries();
    final MockDataBlock dataBlock = new MockDataBlock();
    while (leafPage.getNumberOfKeyEntries() != maxNumberOfEntries) {
      assertTrue("add must suceed",
          leafPage.add(DataRecordIdentifier.ZERO, dataBlock));
    }
    assertFalse("add must failed",
View Full Code Here


  }

  private void addToLeafPage(final LeafPage leafPage, final int position,
      final int idValue, final int lastKeyValue,
      final int numberOfKeyEntries) throws HeapException {
    final MockDataBlock dataBlock = new MockDataBlock();
    dataBlock.setPosition(position);
    final DataRecordIdentifier dataRecordIdentifier = new DataRecordIdentifier(
        idValue);
    leafPage.add(dataRecordIdentifier, dataBlock);
    assertEquals("must has " + numberOfKeyEntries + " entry",
        numberOfKeyEntries, leafPage.getNumberOfKeyEntries());
    assertEquals("bad byte size", byteSize(numberOfKeyEntries),
        leafPage.getByteSize());
    assertEquals("must find", dataBlock.getPositionInFile(),
        leafPage.getDataBlockPosition(dataRecordIdentifier));
    assertEquals("must not find", -1L,
        leafPage.getDataBlockPosition(new DataRecordIdentifier(0)));
    assertEquals("bad last key", new DataRecordIdentifier(lastKeyValue),
        leafPage.getLastKey());
View Full Code Here

  public void testSetDataBlock() throws HeapException {
    final LeafPage leafPage = new LeafPage(0, true);
    leafPage.setPageRecord(PAGE_RECORD);
    leafPage.updateByteSize();
    MockDataBlock dataBlock = new MockDataBlock();
    dataBlock.setPosition(0);
    leafPage.add(new DataRecordIdentifier(), dataBlock);

    dataBlock = new MockDataBlock();
    final long position = 1000;
    dataBlock.setPosition(position);
    final int index = 0;
    leafPage.setDataBlock(index, dataBlock);
    assertEquals("set data block failure", position,
        leafPage.getBlockPointer(index));
  }
View Full Code Here

    leafPage.updateByteSize();
    leafPage.setPageRecord(PAGE_RECORD);
    final int maxNumberOfEntries = maxNumberOfEntries();
    int count = 0;
    while (leafPage.getNumberOfKeyEntries() != maxNumberOfEntries) {
      final MockDataBlock dataBlock = new MockDataBlock();// NOPMD
      dataBlock.setPosition(count);
      assertTrue("add must suceed",
          leafPage.add(new DataRecordIdentifier(count), dataBlock));// NOPMD
      count++;
    }
    final MockDataBlock dataBlock = new MockDataBlock();
    dataBlock.setPosition(count);
    final LeafPage rightLeafPage = leafPage.split(new DataRecordIdentifier(
        count), dataBlock);
    checkSplit(leafPage, maxNumberOfEntries, rightLeafPage);
  }
View Full Code Here

    leafPage.updateByteSize();
    leafPage.setPageRecord(PAGE_RECORD);
    final int maxNumberOfEntries = maxNumberOfEntries();
    int count = 1;
    while (leafPage.getNumberOfKeyEntries() != maxNumberOfEntries) {
      final MockDataBlock dataBlock = new MockDataBlock();// NOPMD
      dataBlock.setPosition(count);
      assertTrue("add must suceed",
          leafPage.add(new DataRecordIdentifier(count), dataBlock));// NOPMD
      count++;
    }
    final MockDataBlock dataBlock = new MockDataBlock();
    dataBlock.setPosition(0);
    final LeafPage rightLeafPage = leafPage.split(new DataRecordIdentifier(
        0), dataBlock);
    checkSplit(leafPage, maxNumberOfEntries, rightLeafPage);
  }
View Full Code Here

  }

  private void addToLeafPage(final LeafPage leafPage, final int[] keys,
      final long[] pointers) throws HeapException {
    for (int index = 0; index < keys.length; index++) {
      MockDataBlock dataBlock = new MockDataBlock();// NOPMD
      dataBlock.setPosition(pointers[index]);
      final DataRecordIdentifier dataRecordIdentifier = new DataRecordIdentifier(// NOPMD
          keys[index]);
      leafPage.add(dataRecordIdentifier, dataBlock);
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.joafip.btreeplus.entity.mock.MockDataBlock

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.