@@ -43,8 +43,6 @@ this software and associated documentation files (the "Software"), to deal in
4343import java .util .Map ;
4444import java .util .concurrent .atomic .AtomicInteger ;
4545
46- import static su .interference .persistent .Table .SYSTEM_PKG_PREFIX ;
47-
4846/**
4947 * @author Yuriy Glotanov
5048 * @since 1.0
@@ -355,7 +353,7 @@ public DataChunk (byte[] b, int file, long frame, int hsize, Table t, Class c)
355353 this .chunk = bsc .getBytes ();
356354 }
357355
358- //constructor for clone method - de-serialize chunk only without header
356+ //constructor for clone method - de-serialize chunk only without header
359357 public DataChunk (byte [] b , Table t , RowHeader h , DataChunk source ) {
360358 this .chunk = b ;
361359 this .header = h ;
@@ -695,13 +693,13 @@ public DataChunk cloneEntity(Session s) throws InternalException {
695693 return dc_ ;
696694 }
697695
698- public DataChunk restore (UndoChunk uc ) throws Exception {
696+ public DataChunk restore (UndoChunk uc , Session s , LLT llt ) throws Exception {
699697 // since we are using a dirty hack with changing the header in a source chunk for rollback his,
700698 // we need to first delete the source chunk in the target block to prevent inconsistency within ChunkMap / chunk headers
701699 if (!(this .getHeader ().getRowID ().getFileId () == uc .getFile () && this .getHeader ().getRowID ().getFramePointer () == uc .getFrame ())) {
702700 final long srcFrameId = uc .getFile () + uc .getFrame ();
703701 final Frame srcFrame = Instance .getInstance ().getFrameById (srcFrameId ).getFrame ();
704- srcFrame .removeChunk (uc .getPtr (), null , true );
702+ srcFrame .removeChunk (uc .getPtr (), llt , true );
705703 }
706704 return this ;
707705 }
@@ -727,7 +725,6 @@ public void setHeader(Header header) {
727725 }
728726
729727 //lock mechanism
730-
731728 private synchronized DataChunk insertUC (UndoChunk uc , Session s , LLT llt ) throws Exception {
732729 final WaitFrame ubw = s .getTransaction ().getAvailableFrame (uc , true );
733730 final FrameData ub = ubw .getBd ();
@@ -827,13 +824,12 @@ protected void cleanUpIcs() {
827824 }
828825
829826 public DataChunk getIc (IndexDescript ids , Session s ) throws Exception {
830- final Table ixt = Instance .getInstance ().getTableByName (SYSTEM_PKG_PREFIX + ids .getName ());
831- final DataChunk ic = this .ics .get (ixt .getObjectId ());
827+ final DataChunk ic = this .ics .get (ids .getIndex ().getObjectId ());
832828 if (ic == null ) {
833829 final ValueSet key = this .getValueByColumnName (ids .getColumns (), s );
834- final DataChunk ic_ = ixt .getObjectByKey (key , s );
830+ final DataChunk ic_ = ids . getIndex () .getObjectByKey (key , s );
835831 if (ic_ != null ) {
836- this .ics .put (ixt .getObjectId (), ic_ );
832+ this .ics .put (ids . getIndex () .getObjectId (), ic_ );
837833 return ic_ ;
838834 } else {
839835 throw new RuntimeException ("Unable to retrieve index chunk: " + ids .getName ());
@@ -842,6 +838,13 @@ public DataChunk getIc(IndexDescript ids, Session s) throws Exception {
842838 return ic ;
843839 }
844840
841+ public DataChunk getIcForUpdate (IndexDescript ids , Session s , LLT llt ) throws Exception {
842+ final DataChunk ic = getIc (ids , s );
843+ llt .add (ic .getFrameData ().getFrame ());
844+ this .ics .remove (ids .getIndex ().getObjectId ());
845+ return getIc (ids , s );
846+ }
847+
845848 public ValueSet getValueByColumnName (String [] columns , Session s ) throws Exception {
846849 final Class c = this .getEntity ().getClass ();
847850 final SystemEntity sa = (SystemEntity )c .getAnnotation (SystemEntity .class );
@@ -874,4 +877,9 @@ public synchronized String getHexByChunk() {
874877 return sb .toString ();
875878 }
876879
880+ public FrameData getFrameData () {
881+ final long ptr = this .getHeader ().getRowID ().getFileId () + this .getHeader ().getRowID ().getFramePointer ();
882+ return Instance .getInstance ().getFrameById (ptr );
883+ }
884+
877885}
0 commit comments