Package com.orientechnologies.orient.core.storage.fs

Examples of com.orientechnologies.orient.core.storage.fs.OFile


    return recordSize + RECORD_FIX_SIZE;
  }

  protected void writeRecord(final long[] iFilePosition, final int iClusterSegment, final long iClusterPosition,
      final byte[] iContent) throws IOException {
    final OFile file = files[(int) iFilePosition[0]];

    file.writeInt(iFilePosition[1], iContent.length);
    file.writeShort(iFilePosition[1] + OConstants.SIZE_INT, (short) iClusterSegment);
    file.writeLong(iFilePosition[1] + OConstants.SIZE_INT + OConstants.SIZE_SHORT, iClusterPosition);

    file.write(iFilePosition[1] + RECORD_FIX_SIZE, iContent);
  }
View Full Code Here


    acquireSharedLock();
    try {

      final long[] pos = getRelativePosition(iPosition);

      final OFile file = files[(int) pos[0]];
      long p = pos[1];

      iPPosition.dataSegment = file.readShort(p);
      iPPosition.dataPosition = file.readLong(p += OConstants.SIZE_SHORT);
      iPPosition.type = file.readByte(p += OConstants.SIZE_LONG);
      iPPosition.version = file.readInt(p += OConstants.SIZE_BYTE);
      return iPPosition;

    } finally {
      releaseSharedLock();
    }
View Full Code Here

    acquireExclusiveLock();
    try {

      final long[] pos = getRelativePosition(iPosition);

      final OFile file = files[(int) pos[0]];
      long p = pos[1];

      file.writeShort(p, (short) iDataId);
      file.writeLong(p += OConstants.SIZE_SHORT, iDataPosition);
      file.writeByte(p += OConstants.SIZE_LONG, iRecordType);

    } finally {
      releaseExclusiveLock();
    }
  }
View Full Code Here

    acquireExclusiveLock();
    try {

      final long[] pos = getRelativePosition(iPosition);

      final OFile file = files[(int) pos[0]];
      long p = pos[1];

      file.writeLong(p += OConstants.SIZE_SHORT, iDataPosition);

    } finally {
      releaseExclusiveLock();
    }
  }
View Full Code Here

    acquireExclusiveLock();
    try {

      final long[] pos = getRelativePosition(position);
      final OFile file = files[(int) pos[0]];
      long p = pos[1];

      // SAVE THE OLD DATA AND RETRIEVE THEM TO THE CALLER
      iPPosition.dataSegment = file.readShort(p);
      iPPosition.dataPosition = file.readLong(p += OConstants.SIZE_SHORT);
      iPPosition.type = file.readByte(p += OConstants.SIZE_LONG);
      iPPosition.version = file.readInt(p += OConstants.SIZE_BYTE);

      holeSegment.pushPosition(position);

      // SET VERSION = -1
      file.writeInt(p, -1);

      if (iPosition == beginOffsetData) {
        if (getEntries() == 0)
          beginOffsetData = -1;
        else {
View Full Code Here

        // NO HOLES FOUND: ALLOCATE MORE SPACE
        pos = allocateSpace(RECORD_SIZE);
        offset = getAbsolutePosition(pos);
      }

      OFile file = files[(int) pos[0]];
      long p = pos[1];

      file.writeShort(p, (short) iDataSegmentId);
      file.writeLong(p += OConstants.SIZE_SHORT, iPosition);
      file.writeByte(p += OConstants.SIZE_LONG, iRecordType);
      file.writeInt(p += OConstants.SIZE_BYTE, 0);

      final long returnedPosition = offset / RECORD_SIZE;

      if (returnedPosition < beginOffsetData || beginOffsetData == -1) {
        // UPDATE END OF DATA
View Full Code Here

    acquireSharedLock();
    try {

      final long[] pos = getRelativePosition(iPosition);
      final OFile file = files[(int) pos[0]];

      final int recordSize = file.readInt(pos[1]);
      if (recordSize <= 0)
        // RECORD DELETED
        return null;

      if (pos[1] + RECORD_FIX_SIZE + recordSize > file.getFilledUpTo())
        throw new OStorageException(
            "Error on reading record from file '"
                + file.getOsFile().getName()
                + "', position "
                + iPosition
                + ", size "
                + OFileUtils.getSizeAsString(recordSize)
                + ": the record size is bigger then the file itself ("
                + OFileUtils.getSizeAsString(getFilledUpTo())
                + "). Probably the record is dirty due to a previous crash. It strongly suggested to restore the database or export and reimport this one.");

      final byte[] content = new byte[recordSize];
      file.read(pos[1] + RECORD_FIX_SIZE, content, recordSize);
      return content;

    } finally {
      releaseSharedLock();
    }
View Full Code Here

  public int getRecordSize(final long iPosition) throws IOException {
    acquireSharedLock();
    try {

      final long[] pos = getRelativePosition(iPosition);
      final OFile file = files[(int) pos[0]];

      return file.readInt(pos[1]);

    } finally {
      releaseSharedLock();
    }
  }
View Full Code Here

  public long setRecord(final long iPosition, final ORecordId iRid, final byte[] iContent) throws IOException {
    acquireExclusiveLock();
    try {

      long[] pos = getRelativePosition(iPosition);
      final OFile file = files[(int) pos[0]];

      final int recordSize = file.readInt(pos[1]);
      // if (recordSize <= 0)
      // OLogManager.instance().error(this, "Error while writing to data file. The record size was invalid", OIOException.class);

      if (iContent.length == recordSize) {
        // USE THE OLD SPACE SINCE SIZE IT ISN'T CHANGED
        file.write(pos[1] + RECORD_FIX_SIZE, iContent);

        OProfiler.getInstance().updateCounter(PROFILER_UPDATE_REUSED_ALL, +1);
        return iPosition;
      } else if (recordSize - iContent.length > RECORD_FIX_SIZE + 50) {
        // USE THE OLD SPACE BUT UPDATE THE CURRENT SIZE. IT'S PREFEREABLE TO USE THE SAME INSTEAD FINDING A BEST SUITED FOR IT TO
View Full Code Here

  public int deleteRecord(final long iPosition) throws IOException {
    acquireExclusiveLock();
    try {

      final long[] pos = getRelativePosition(iPosition);
      final OFile file = files[(int) pos[0]];

      final int recordSize = file.readInt(pos[1]);
      handleHole(iPosition, recordSize);
      return recordSize;

    } finally {
      releaseExclusiveLock();
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.storage.fs.OFile

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.