Examples of HeapRecord


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

    for (int index = 0; index < 10; index++) {
      final long position = (long) HeapHeader.HEAP_HEADER_SIZE
          + (long) index
          * (HeapRecord.DATA_RECORD_HEADER_SIZE + 100 + 4);
      logger.info("position " + position + " for #" + index);
      @SuppressWarnings("PMD")
      final HeapRecord heapRecord =
      /**/new HeapRecord(
      /**/heapElementManager, position, previousPosition,
          newDataRecordIdentifier(index), false/* freeRecord */,
          10/* dataAssociatedSize */, 100/* areaSize */);

      // final HeapRecord heapRecord = heapElementManager
      // .newHeapFileRecord(position, previousPosition,
      // newDataRecordIdentifier(index),
      // false/* freeRecord */, 10/* dataAssociatedSize */,
      // 100/* areaSize */);
      heapElementManager.appendHeapFileRecord(heapRecord);

      heapRecord.setDataAssociated(new byte[10]);// NOPMD new in loop is
      // ok
      previousPosition = position;
      final HeapIdNode node = (HeapIdNode) heapRecord.getIdNode();
      idNodeTree.append(node);
      heapElementManager.closeTransaction();
      heapElementManager.openTransaction();

      final HeapIdNode foundNode = (HeapIdNode) idNodeTree
View Full Code Here

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

  @Override
  public IFileStorable createHeapRecord(
      final IHeapElementManager heapElementManager,
      final long positionInFile) throws HeapException {
    return new HeapRecord(heapElementManager, positionInFile);
  }
View Full Code Here

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

    }
    return header;
  }

  public HeapRecord getNextHeapRecord() throws HeapException {
    final HeapRecord heapRecord;
    if (positionInFile <= lastRecordPositionInFile) {
      heapRecord = (HeapRecord) manager
          .readHeapFileDataRecord(positionInFile);
      // heapRecord = new HeapRecord(manager, positionInFile);
      recordCount++;
      // heapRecord.readFromFile();

      final long previousRecordPositionInFile = heapRecord
          .getPreviousRecordPositionInFile();

      // ASSERTX
      assert previousRecordPositionInFile == expectedPreviousRecordPositionInFile : "bad previous position in file for record #"
          + recordCount
          + " position="
          + positionInFile
          + " expected="
          + expectedPreviousRecordPositionInFile
          + " in record=" + previousRecordPositionInFile;

      expectedPreviousRecordPositionInFile = positionInFile;

      final long nextRecordFilePosition = heapRecord
          .getNextRecordFilePosition();
      positionInFile += heapRecord.getRecordSize();
      // ASSERTX
      assert !(nextRecordFilePosition == -1
          && positionInFile <= lastRecordPositionInFile || nextRecordFilePosition != -1
          && positionInFile != nextRecordFilePosition) : "bad next record position in file";
    } else {
View Full Code Here

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

    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);
View Full Code Here

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

    final long freeRootNodeFilePosition = heapHeader
        .getFreeRootNodeFilePosition();
    if (freeRootNodeFilePosition == -1) {
      heapFreeRootNode = null;
    } else {
      final HeapRecord heapRecord = (HeapRecord) heapElementManager
          .readHeapFileDataRecord(freeRootNodeFilePosition);
      heapFreeRootNode = (HeapFreeNode) heapRecord.getFreeNode();
    }
    return heapFreeRootNode;
  }
View Full Code Here

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

    final long idRootNodeFilePosition = heapHeader
        .getIdRootNodeFilePosition();
    if (idRootNodeFilePosition == -1) {
      heapIdRootNode = null;
    } else {
      final HeapRecord heapRecord = (HeapRecord) heapElementManager
          .readHeapFileDataRecord(idRootNodeFilePosition);
      heapIdRootNode = (HeapIdNode) heapRecord.getIdNode();
    }
    return heapIdRootNode;
  }
View Full Code Here

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

  @Override
  public boolean writeDataRecordImpl(
      final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
      throws HeapException {
    HeapRecord heapRecord = getHeapRecord(dataRecordIdentifier);
    final boolean created;
    if (heapRecord == null) {
      created = true;
      heapRecord = createHeapRecordForData(data.length,
          dataRecordIdentifier);
      heapRecord.setDataAssociated(data);
    } else {
      created = false;
      if (data.length == heapRecord.getDataAssociatedSize()) {
        if (!Arrays.equals(data, heapRecord.getDataAssociated())) {
          heapRecord.setDataAssociated(data);
        }
      } else {
        deleteDataRecord(dataRecordIdentifier);
        heapRecord = createHeapRecordForData(data.length,
            dataRecordIdentifier);
        heapRecord.setDataAssociated(data);
      }
    }
    if (logger.debugEnabled) {
      logger.debug("create heap record #" + dataRecordIdentifier
          + FOR_DATA_SIZE + data.length);
View Full Code Here

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

    } else {
      neededAreaSize = 4 + neededDataSize
          + HeapRecord.MAX_RECORD_HEADER_SIZE
          + dataRecordKeyDataSize(nodeIdentifier);
    }
    final HeapRecord heapRecord;

    final HeapFreeNode freeNode = getHeapFreeNode(neededAreaSize);

    if (freeNode == null) {

      heapRecord = createRecordForDataAtEndOfHeap(neededDataSize,
          neededAreaSize, nodeIdentifier);

    } else {
      heapRecord = createRecordForDataFromFree(neededDataSize,
          nodeIdentifier, neededAreaSize, freeNode);
    }

    idNodeTreeAppend(heapRecord);
    if (logger.debugEnabled) {
      logger.debug("data record #" + nodeIdentifier
          + " position in file " + heapRecord.getPositionInFile()
          + " is free record " + heapRecord.isFreeRecord());
    }
    return heapRecord;
  }
View Full Code Here

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

   *            the heap id node of record to delete
   * @throws HeapException
   */
  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;
    } else {
      previous = readHeapFileDataRecord(positionInFile);
    }
    positionInFile = heapRecord.getNextRecordFilePosition();
    final HeapRecord next;
    if (positionInFile == -1) {
      next = null;
    } else {
      next = readHeapFileDataRecord(positionInFile);
    }
View Full Code Here

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

    assert freeHeapRecord.isFreeRecord() : "must be a free heap record";
    freeHeapRecord.setRecordSize(areaSize);
    freeNodeTreeAppend(freeHeapRecord);

    if (nextPositionInFile != -1) {
      final HeapRecord nextOfFreeHeapRecord = readHeapFileDataRecord(nextPositionInFile);
      nextOfFreeHeapRecord
          .setPreviousRecordPositionInFile(positionInFile);
    }
  }
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.