Examples of HeapHeader


Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

  }

  @Override
  protected void setUp() throws Exception { // NOPMD
    super.setUp();
    heapElementManager.setHeapHeader(new HeapHeader(heapElementManager));
  }
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

   */
  public void testEmptyHeap() throws HeapException {// NOPMD assertion in
    // method called

    /* new heap header creation and write with check */
    final HeapHeader heapHeader1 = appendHeaderInEmptyFile();

    /* check the wrote header */
    heapElementManager.startService();
    heapElementManager.openTransaction();
    getHeapHeaderAndCheckPosition(heapHeader1);
 
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

   * @throws RBTException
   *
   */
  public void testChangeHeader() throws HeapException, RBTException {
    /* new heap header creation and write with check */
    final HeapHeader heapHeader1 = appendHeaderInEmptyFile();

    /* then read header */
    heapElementManager.startService();
    heapElementManager.openTransaction();
    final HeapHeader heapHeader2 = getHeapHeaderAndCheckPosition(heapHeader1);
    /* create heap record */
    final HeapRecord heapRecord = new HeapRecord(heapElementManager,
    /**/HeapHeader.HEAP_HEADER_SIZE/* position in file */);
    // heapHeader2.setFreeRootNodeFilePosition(new HeapFreeNode(
    // heapElementManager, heapRecord).getPositionInFile());
    heapHeader2.setFreeRootNodeFilePosition(heapRecord.getPositionInFile());
    // heapHeader2.setIdRootNodeFilePosition(new HeapIdNode(
    // heapElementManager, heapRecord).getPositionInFile());
    heapHeader2.setIdRootNodeFilePosition(heapRecord.getPositionInFile());
    /* write modifications */
    heapElementManager.closeTransaction();

    /* read the last modification */
    heapElementManager.openTransaction();
    final HeapHeader heapHeader3 = getHeapHeaderAndCheckPosition(heapHeader2);

    /* check modifications */
    assertEquals("FreeRootNodeFilePosition must be "
        + HeapHeader.HEAP_HEADER_SIZE, HeapHeader.HEAP_HEADER_SIZE,
        heapHeader3.getFreeRootNodeFilePosition());

    assertEquals("IdRootNodeFilePosition must be "
        + HeapHeader.HEAP_HEADER_SIZE, HeapHeader.HEAP_HEADER_SIZE,
        heapHeader3.getIdRootNodeFilePosition());

    heapElementManager.closeTransaction();
    heapElementManager.stopService();
  }
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

   *
   */
  private HeapHeader appendHeaderInEmptyFile() throws HeapException {
    heapElementManager.startService();
    heapElementManager.openTransaction();
    final HeapHeader heapHeader1 = getHeapHeaderAndCheckPosition(null);
    assertEquals("FreeRootNodeFilePosition must be -1", -1,
        heapHeader1.getFreeRootNodeFilePosition());
    assertEquals("IdRootNodeFilePosition must be -1", -1,
        heapHeader1.getIdRootNodeFilePosition());
    assertFalse("created header must be saved",
        heapHeader1.isValueChangedToSave());
    heapElementManager.closeTransaction();
    heapElementManager.stopService();
    assertFalse("saving implies no more value changed",
        heapHeader1.isValueChangedToSave());
    assertFalse("just created must be false", heapHeader1.isJustCreated());
    return heapHeader1;
  }
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

   * @return heap header
   * @throws HeapException
   */
  private HeapHeader getHeapHeaderAndCheckPosition(
      final HeapHeader heapHeaderReference) throws HeapException {
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    assertEquals("header must be at file beginning", 0,
        heapHeader.getPositionInFile());
    if (heapHeaderReference != null) {
      // header is now the same object
      // assertNotSame("new header must not be same of creation one",
      // heapHeaderReference, heapHeader);
      assertEquals("wrote and read must be equals", heapHeaderReference,
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

    heapElementManager = new HeapElementManager(fileForStorable,
        stateDataFile, backupFileForStorage, stateDataBackupFile,
        globalStateFile, false, false, 1, 0, openFileTraceFile);
    heapElementManager.setHeapRecordFactory(this);
    heapElementManager.setHeapHeader(new HeapHeader(heapElementManager));
    final HeapIdNodeManager heapIdNodeManager = new HeapIdNodeManager(
        heapElementManager);
    idNodeTree = new RedBlackTree<DataRecordIdentifier>(heapIdNodeManager,
        false, true);
    heapElementManager.startService();
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

    super();
    this.manager = manager;
  }

  public HeapHeader getHeapHeader() throws HeapException {
    final HeapHeader header;
    final long heapSize = manager.getFileSize();
    if (heapSize == 0) {
      header = null;
    } else {
      header = (HeapHeader) manager.getHeapHeader();
      // header = new HeapHeader(manager);
      // header.readFromFile();
      lastRecordPositionInFile = header.getLastRecordPositionInFile();
      recordCount = 0;
      positionInFile = header.getPositionInFile()
          + HeapHeader.HEAP_HEADER_SIZE;
      // ASSERTX
      assert positionInFile == HeapHeader.HEAP_HEADER_SIZE : "bad position for first record";
      expectedPreviousRecordPositionInFile = -1;
    }
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

    checkTrees();

    final HeapRecordIterator heapRecordIterator = new HeapRecordIterator(
        heapElementManager);

    final HeapHeader header = heapRecordIterator.getHeapHeader();
    if (header != null) {
      int freeRecordCount = 0;
      int dataRecordCount = 0;
      long identifier = -1;
      HeapRecord heapRecord = heapRecordIterator.getNextHeapRecord();
      HeapRecord lastHeapRecord = null;
      try {
        while (heapRecord != null) {
          if (heapRecord.isFreeRecord()) {
            freeRecordCount++;
            checkFreeNodeInTree(heapRecord);
          } else {
            dataRecordCount++;
            checkDataNodeInTree(heapRecord);
            final long heapRecordId = heapRecord
                .getNodeIdentifier().value;
            if (heapRecordId > identifier) {
              identifier = heapRecordId;
            }
          }
          lastHeapRecord = heapRecord;
          heapRecord = heapRecordIterator.getNextHeapRecord();
        }
        final long nextId = header.getNextDataRecordIdentifier();
        if (nextId <= identifier) {
          throw new HeapException("bad data record identifier");
        }
        checkLastRecord(header, lastHeapRecord);
      } catch (RBTException exception) {
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

    this.heapElementManager = heapElementManager;
  }

  public IRBTNode<E> getRootNode() throws RBTException {
    try {
      final HeapHeader heapHeader = (HeapHeader) heapElementManager
          .getHeapHeader();
      return getRootNode(heapHeader);
    } catch (HeapException exception) {
      throw new RBTException(exception);
    }
View Full Code Here

Examples of net.sf.joafip.heapfile.record.entity.HeapHeader

   */
  protected abstract IRBTNode<E> getRootNode(final HeapHeader heapHeader)
      throws HeapException;

  public void setRootNode(final IRBTNode<E> rootNode) throws RBTException {
    final HeapHeader heapHeader;
    try {
      heapHeader = (HeapHeader) heapElementManager.getHeapHeader();
    } catch (HeapException exception) {
      throw new RBTException(exception);
    }
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.