Package net.sf.joafip.heapfile.record.entity

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


  public HeapFileDataManager(final HeapFileSetup setup,
      final boolean manageNodeIndex) throws HeapException {
    super();
    heapElementManager = HeapElementManagerFactory.create(setup);
    heapElementManager.setHeapRecordFactory(this);
    heapElementManager.setHeapHeader(new HeapHeader(heapElementManager));
    final HeapFreeNodeManager heapFreeNodeManager = new HeapFreeNodeManager(
        heapElementManager);
    freeNodeTree = new RedBlackTree<Integer>(heapFreeNodeManager, false,
        false);
    final HeapIdNodeManager heapIdNodeManager = new HeapIdNodeManager(
View Full Code Here


   */
  private void deleteDataRecord(final HeapIdNode heapIdNode)
      throws HeapException {
    final HeapRecord heapRecord = deleteAndGetDataRecord(heapIdNode);
    /* will update heap header for free and used size */
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    heapHeader.addFreeSize(heapRecord.getRecordSize());

    long positionInFile = heapRecord.getPreviousRecordPositionInFile();
    final HeapRecord previous;
    if (positionInFile == -1) {
      previous = null;
View Full Code Here

  }

  @Override
  protected DataRecordIdentifier getNextFreeDataRecordIdentifierImpl()
      throws HeapException {
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    final DataRecordIdentifier dataRecordIdentifier = new DataRecordIdentifier(
        heapHeader.getNextDataRecordIdentifier());
    return dataRecordIdentifier;
  }
View Full Code Here

  @Override
  protected void setNextFreeDataRecordIdentifierImpl(
      final DataRecordIdentifier dataRecordIdentifier)
      throws HeapException {
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    heapHeader.setNextDataRecordIdentifier(dataRecordIdentifier);
  }
View Full Code Here

  }

  @Override
  protected DataRecordIdentifier getNewDataRecordIdentifierImpl()
      throws HeapException {
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    final long nextDataRecordIdentifier = heapHeader
        .getNextDataRecordIdentifier();
    final DataRecordIdentifier dataRecordIdentifier = new DataRecordIdentifier(
        nextDataRecordIdentifier);
    heapHeader.setNextDataRecordIdentifier(nextDataRecordIdentifier + 1);
    return dataRecordIdentifier;
  }
View Full Code Here

    /* no more free */
    freeNodeTreeDelete(heapRecord);
    // NO NO NO do not delete, reused as data record
    // heapElementManager.delete(heapRecord.getPositionInFile());
    /* will update heap header for free and used size */
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();

    if (newFreeRecordSize >= HeapRecord.MAX_RECORD_HEADER_SIZE
        + MINIMUM_RECORD_DATA_SIZE + 4) {
      /*
       * split free record : one part used for data the other keep free
       */
      final long nextRecordFilePosition = heapRecord
          .getNextRecordFilePosition();
      heapRecord.unfreeRecord(neededDataSize, neededRecordSize,
          nodeIdentifier, false);
      final long positionInFile = heapRecord.getPositionInFile();
      final long newFreeRecordPositionInFile = positionInFile
          + neededRecordSize;

      final HeapRecord newFreeHeapRecord = new HeapRecord(
          heapElementManager,
          newFreeRecordPositionInFile/* positionInFile */,
          positionInFile/* previousPositionInFile */,
          null/* nodeIdentifier */, true/* freeRecord */,
          0/* dataAssociatedSize */, newFreeRecordSize/* recordSize */);

      // final HeapRecord newFreeHeapRecord = heapElementManager
      // .newHeapFileRecord(
      // newFreeRecordPositionInFile/* positionInFile */,
      // positionInFile/* previousPositionInFile */,
      // null/* nodeIdentifier */, true/* freeRecord */,
      // null/* dataAssociatedSize */, newFreeRecordSize/*recordSize*/);

      heapElementManager.appendHeapFileRecord(newFreeHeapRecord);

      if (heapRecord.getPositionInFile() == heapHeader
          .getLastRecordPositionInFile()) {
        heapHeader
            .setLastRecordPositionInFile(newFreeRecordPositionInFile);
      }
      freeNodeTreeAppend(newFreeHeapRecord);
      if (nextRecordFilePosition != -1) {
        final HeapRecord nextHeapRecord = readHeapFileDataRecord(nextRecordFilePosition);
        nextHeapRecord
            .setPreviousRecordPositionInFile(newFreeRecordPositionInFile);
      }
    } else {
      heapRecord.unfreeRecord(neededDataSize, nodeIdentifier);
    }
    heapHeader.unfreeSize(heapRecord.getRecordSize());
    return heapRecord;
  }
View Full Code Here

      throws HeapException {
    /*
     * will update heap header last record position in file information, end
     * of record position in file, and used size
     */
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    /* position at end of heap */
    final long positionInFile = heapHeader.getEndOfRecordPositionInFile();
    heapHeader.setEndOfRecordPositionInFile(positionInFile + needAreaSize);
    /*
     * previous record is current last record in file, may be -1 ( undefined
     * ) if first record
     */
    final long previousRecordPositionInFile = heapHeader
        .getLastRecordPositionInFile();
    // ASSERTX
    assert assertFirstPositionInFile(positionInFile,
        previousRecordPositionInFile);
    heapHeader.setLastRecordPositionInFile(positionInFile);
    heapHeader.addUsedSize(needAreaSize);
    /* new at end of file with a new record identification */
    final HeapRecord heapRecord = new HeapRecord(heapElementManager,
        positionInFile, previousRecordPositionInFile, nodeIdentifier,
        false, needDataSize, needAreaSize);
    // final HeapRecord heapRecord = heapElementManager.newHeapFileRecord(
View Full Code Here

    return numberOfFreeRecord;
  }

  @Override
  protected long heapSizeImpl() throws HeapException {
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    return heapHeader.getEndOfRecordPositionInFile();
  }
View Full Code Here

    return heapHeader.getEndOfRecordPositionInFile();
  }

  @Override
  protected long freeSizeImpl() throws HeapException {
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    return heapHeader.getFreeSize();
  }
View Full Code Here

    return heapHeader.getFreeSize();
  }

  @Override
  protected long usedSizeImpl() throws HeapException {
    final HeapHeader heapHeader = (HeapHeader) heapElementManager
        .getHeapHeader();
    return heapHeader.getUsedSize();
  }
View Full Code Here

TOP

Related Classes of net.sf.joafip.heapfile.record.entity.HeapHeader

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.