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