Example #1
0
  @Override
  public void startObject(long oid, int prevSchemaVersion) {
    if (posIndex == null) {
      if (schemaIndexEntry == null) {
        schemaIndexEntry = schemaIndex.getSchema(def);
      }
      posIndex = schemaIndexEntry.getObjectIndexLatestSchemaVersion();
    }
    PagedPosIndex prevIndex = schemaIndexEntry.getObjectIndexVersion(prevSchemaVersion);
    currentPage = out.getPage();
    currentOffs = out.getOffset();

    // first remove possible previous position
    final LongLongIndex.LLEntry objPos = oidIndex.findOidGetLong(oid);
    if (objPos != null) {
      long pos = objPos.getValue(); // long with 32=page + 32=offs
      // prevPos.getValue() returns > 0, so the loop is performed at least once.
      do {
        // remove and report to FSM if applicable
        // TODO
        // In cache, use separate list for evolved objects to be written (Map<PC/OID,
        // OriginalClassDef)
        // Do not put those objects in dirty-list
        // When checking for dirty (external) return whether contained in dirty-list.
        // When...???

        long nextPos = prevIndex.removePosLongAndCheck(pos);
        // all secondary pages are marked.
        nextPos |= PagedPosIndex.MARK_SECONDARY;
        pos = nextPos;
      } while (pos != PagedPosIndex.MARK_SECONDARY);
    }
    // Update pos index
    oidIndex.insertLong(oid, currentPage, (int) currentOffs);
  }
Example #2
0
 /** Not a true flush, just writes the stuff... */
 @Override
 public final void flush() {
   // flush associated splits.
   for (StorageChannelOutput paf : viewsOut) {
     // flush() only writers
     paf.flush();
   }
   for (StorageChannelInput paf : viewsIn) {
     paf.reset();
   }
   try {
     fc.force(false);
   } catch (IOException e) {
     throw DBLogger.newFatal("Error writing database file.", e);
   }
 }
Example #3
0
 @Override
 public void flush() {
   out.flush();
   // posIndex may change during next transaction due to schema evolution
   posIndex = null;
   // setting this to null is important for revert() on failed commits
   schemaIndexEntry = null;
 }
Example #4
0
 public ObjectWriterSV(
     StorageChannel file, PagedOidIndex oidIndex, ZooClassDef def, SchemaIndex schemaIndex) {
   this.out = file.getWriter(true);
   this.oidIndex = oidIndex;
   out.setOverflowCallbackWrite(this);
   this.def = def;
   this.headerForWrite = def.getOid();
   this.schemaIndex = schemaIndex;
 }
Example #5
0
 @Override
 public void writeDouble(double double1) {
   out.writeDouble(double1);
 }
Example #6
0
 @Override
 public void skipWrite(int nBytes) {
   out.skipWrite(nBytes);
 }
Example #7
0
 @Override
 public void writeLong(long long1) {
   out.writeLong(long1);
 }
Example #8
0
 @Override
 public void writeShort(short short1) {
   out.writeShort(short1);
 }
Example #9
0
 @Override
 public void writeFloat(float float1) {
   out.writeFloat(float1);
 }
Example #10
0
 @Override
 public void writeInt(int int1) {
   out.writeInt(int1);
 }
Example #11
0
 @Override
 public void writeChar(char char1) {
   out.writeChar(char1);
 }
Example #12
0
 /** This can be necessary when subsequent objects are of a different class. */
 @Override
 public void newPage() {
   out.allocateAndSeekAP(PAGE_TYPE.DATA, 0, headerForWrite);
   writeHeader();
 }
Example #13
0
 @Override
 public void writeByte(byte byte1) {
   out.writeByte(byte1);
 }
Example #14
0
 @Override
 public void writeBoolean(boolean boolean1) {
   out.writeBoolean(boolean1);
 }
Example #15
0
 @Override
 public void write(byte[] array) {
   out.write(array);
 }
Example #16
0
 @Override
 public void writeString(String string) {
   out.writeString(string);
 }
Example #17
0
 private void writeHeader() {
   out.writeLong(headerForWrite);
 }