Examples of IPageRecordable


Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

  public void testAppendPageRecordable() throws HeapException {
    btreePlusElementMgr.openTransaction();
    final LeafPage leafPage = new LeafPage(1, true);
    leafPage.setEntry(0, 0, new DataRecordIdentifier());
    leafPage.updateByteSize();
    IPageRecordable pageRecordable = leafPage;
    assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
    btreePlusElementMgr.appendPageRecordable(pageRecordable);
    pageRecordable.setValueIsChangedValueToSave();
    IPageRecord pageRecord = pageRecordable.getPageRecord();
    assertNotNull(MUST_BE_STORED, pageRecord);
    assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 1,
        pageRecord.getPositionInFile());
    assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 1,
        btreePlusElementMgr.getLastRecordPositionInFile());

    NonTerminalPage nonTerminalPage = new NonTerminalPage(1, true);
    nonTerminalPage.setKey(0, new DataRecordIdentifier());
    pageRecordable = nonTerminalPage;
    pageRecordable.updateByteSize();
    assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
    btreePlusElementMgr.appendPageRecordable(pageRecordable);
    pageRecordable.setValueIsChangedValueToSave();
    pageRecord = pageRecordable.getPageRecord();
    assertNotNull(MUST_BE_STORED, pageRecord);
    assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 2,
        pageRecord.getPositionInFile());
    assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 2,
        btreePlusElementMgr.getLastRecordPositionInFile());
    btreePlusElementMgr.closeTransaction();
    assertEquals("", PageConstant.PAGE_SIZE * 3, btreePlusElementMgr
        .getFileForStorable().getFileSize());

    btreePlusElementMgr.openTransaction();
    final int numberOfKeyEntries = 1;
    final DataRecordIdentifier[] keys = new DataRecordIdentifier[] { new DataRecordIdentifier(
        0) };
    final long[] pagePosition = new long[] { 0, 1 };
    pageRecordable = new NonTerminalPage(numberOfKeyEntries, keys,
        pagePosition, true);
    assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
    btreePlusElementMgr.appendPageRecordable(pageRecordable);
    pageRecordable.setValueIsChangedValueToSave();
    pageRecord = pageRecordable.getPageRecord();
    assertNotNull(MUST_BE_STORED, pageRecord);
    assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 3,
        pageRecord.getPositionInFile());
    assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 3,
        btreePlusElementMgr.getLastRecordPositionInFile());
 
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

  public void testFreePage() throws HeapException {
    btreePlusElementMgr.openTransaction();
    assertEquals("must not has free page", -1, getHeapHeader()
        .getPageNumberOfFirstFreePage());
    IPageRecordable pageRecordable = newLeafPage();
    pageRecordable.updateByteSize();
    btreePlusElementMgr.appendPageRecordable(pageRecordable);
    pageRecordable.setValueIsChangedValueToSave();
    pageRecordable = newLeafPage();
    pageRecordable.updateByteSize();
    btreePlusElementMgr.appendPageRecordable(pageRecordable);
    pageRecordable.setValueIsChangedValueToSave();
    final long pageNumber = pageRecordable.getPageRecord().getPageNumber();
    pageRecordable = newLeafPage();
    pageRecordable.updateByteSize();
    btreePlusElementMgr.appendPageRecordable(pageRecordable);
    pageRecordable.setValueIsChangedValueToSave();
    btreePlusElementMgr.closeTransaction();

    btreePlusElementMgr.openTransaction();
    assertEquals("must not has free page", -1, getHeapHeader()
        .getPageNumberOfFirstFreePage());
    final IPageRecord pageRecord = btreePlusElementMgr
        .getPage(pageNumber << PageConstant.PAGE_BITS,
            null/* parentPage */, -1/* index */).getPageRecord();
    btreePlusElementMgr.freePage(pageRecord);
    btreePlusElementMgr.closeTransaction();

    btreePlusElementMgr.openTransaction();
    assertEquals("must has free page", pageNumber, getHeapHeader()
        .getPageNumberOfFirstFreePage());
    pageRecordable = newLeafPage();
    btreePlusElementMgr.appendPageRecordable(pageRecordable);
    pageRecordable.setValueIsChangedValueToSave();
    final long pageNumber2 = pageRecordable.getPageRecord().getPageNumber();
    assertEquals("must reuse", pageNumber, pageNumber2);
    assertEquals("must not has free page", -1, getHeapHeader()
        .getPageNumberOfFirstFreePage());
    btreePlusElementMgr.closeTransaction();
  }
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

    final Deque<State> stack = new LinkedList<State>();
    State state = new State(lessThanMinKey, maxKey);
    stack.push(state);
    final BtreePlusElementMgr elementMgr = btreePlusDataManager
        .getBtreePlusElementMgr();
    IPageRecordable pageRecordable = elementMgr.getRoot();
    long currentLeafPagePosition = elementMgr.getFirstLeafPagePosition();
    int index = 0;
    int currentDepth = 0;
    int depth = -1;
    int entriesCount = 0;
    int leafPageCount = 0;
    int nonTerminalPageCount = 0;
    // System.out.println("--- begin ---");
    while (pageRecordable != null) {
      elementMgr.clearReadCache();
      final EnumRecordType recordType = pageRecordable.getRecordType();
      switch (recordType) {// NOPMD
      case LEAF_PAGE: {
        final LeafPage leafPage = (LeafPage) pageRecordable;

        // check keys
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

  @Override
  protected byte[] readDataRecordImpl(
      final DataRecordIdentifier dataRecordIdentifier)
      throws HeapException {
    final IPageRecordable root = btreePlusElementMgr.getRoot();
    final long dataBlockPosition = dataBlockPosition(root,
        dataRecordIdentifier);
    final byte[] data;
    if (dataBlockPosition == -1) {
      data = null;
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

  @Override
  protected boolean hasDataRecordImpl(
      final DataRecordIdentifier dataRecordIdentifier)
      throws HeapException {
    final IPageRecordable root = btreePlusElementMgr.getRoot();
    final long dataBlockPosition = dataBlockPosition(root,
        dataRecordIdentifier);
    return dataBlockPosition != -1L;
  }
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

  @Override
  protected boolean writeDataRecordImpl(
      final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
      throws HeapException {
    final IPageRecordable root = btreePlusElementMgr.getRoot();
    final LeafPage leafPage = leafPage(root, dataRecordIdentifier);
    final boolean created;
    if (leafPage == null) {
      // no existing data because no leaf page for key
      created = true;
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

  @Override
  protected DataRecordIdentifier removeFirstDataRecordImpl()
      throws HeapException {
    final DataRecordIdentifier first;
    final IPageRecordable root = btreePlusElementMgr.getRoot();
    if (root == null) {
      first = null;
    } else {
      IPageRecordable page = root;
      while (!EnumRecordType.LEAF_PAGE.equals(page.getRecordType())) {
        final NonTerminalPage nonTerminalPage = (NonTerminalPage) page;
        final long pagePosition = nonTerminalPage.getPagePointer(0);
        page = btreePlusElementMgr.getPage(pagePosition, page, 0);
      }
      final LeafPage leafPage = (LeafPage) page;
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

    return dataBlockPosition;
  }

  private IDataBlock dataBlock(final DataRecordIdentifier dataRecordIdentifier)
      throws HeapException {
    final IPageRecordable root = btreePlusElementMgr.getRoot();
    return dataBlock(root, dataRecordIdentifier);
  }
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

  }

  private LeafPage leafPage(final IPageRecordable root,
      final DataRecordIdentifier dataRecordIdentifier)
      throws HeapException {
    IPageRecordable page;
    if (root == null) {
      page = null;// NOPMD
    } else {
      page = root;
      while (!EnumRecordType.LEAF_PAGE.equals(page.getRecordType())) {
        final NonTerminalPage nonTerminalPage = (NonTerminalPage) page;
        final int index = nonTerminalPage
            .getIndex(dataRecordIdentifier);
        final long pagePosition = nonTerminalPage.getPagePointer(index);
        page = btreePlusElementMgr.getPage(pagePosition, page, index);
View Full Code Here

Examples of net.sf.joafip.btreeplus.entity.IPageRecordable

   * @return root page or null if none (no data)
   * @throws HeapException
   */
  public IPageRecordable getRoot() throws HeapException {
    final long position = header.getRootPagePosition();
    final IPageRecordable page;
    if (position == -1L) {
      page = null;
    } else {
      page = getPage(position, null, -1);
    }
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.