Esempio n. 1
0
 // When a file gets opened, it uses the file size to determine where
 // new slots can be appended. If this method would not be called, the
 // freespace system could already contain a slot that points beyond
 // the end of the file and this space could be allocated and used twice,
 // for instance if a slot was allocated and freed without ever being
 // written to file.
 void ensureLastSlotWritten() {
   if (!Debug4.xbytes) {
     if (Deploy.overwrite) {
       if (_blockEndAddress > _blockConverter.bytesToBlocks(fileLength())) {
         StatefulBuffer writer =
             createStatefulBuffer(systemTransaction(), _blockEndAddress - 1, blockSize());
         writer.write();
       }
     }
   }
 }
Esempio n. 2
0
  public StatefulBuffer readStatefulBufferBySlot(Transaction trans, int id, Slot slot) {
    if (Slot.isNull(slot)) {
      return null;
    }

    if (DTrace.enabled) {
      DTrace.READ_SLOT.logLength(slot.address(), slot.length());
    }

    StatefulBuffer buffer = createStatefulBuffer(trans, slot.address(), slot.length());
    buffer.setID(id);
    buffer.readEncrypt(this, slot.address());
    return buffer;
  }
Esempio n. 3
0
  public final boolean delete4(
      Transaction transaction, ObjectReference ref, Object obj, int cascade, boolean userCall) {
    int id = ref.getID();
    StatefulBuffer reader = readStatefulBufferById(transaction, id);
    if (reader != null) {
      if (obj != null) {
        if ((!showInternalClasses()) && Const4.CLASS_INTERNAL.isAssignableFrom(obj.getClass())) {
          return false;
        }
      }
      reader.setCascadeDeletes(cascade);
      transaction.idSystem().notifySlotDeleted(id, SlotChangeFactory.USER_OBJECTS);
      ClassMetadata classMetadata = ref.classMetadata();
      classMetadata.delete(reader, obj);

      return true;
    }
    return false;
  }