@@ -35,12 +35,12 @@ this software and associated documentation files (the "Software"), to deal in
3535
3636import javax .persistence .*;
3737import java .io .UnsupportedEncodingException ;
38- import java .io .IOException ;
3938import java .lang .reflect .Field ;
4039import java .util .ArrayList ;
40+ import java .util .HashMap ;
4141import java .util .List ;
4242import java .lang .reflect .*;
43- import java .net . MalformedURLException ;
43+ import java .util . Map ;
4444import java .util .concurrent .atomic .AtomicInteger ;
4545
4646/**
@@ -63,8 +63,10 @@ public class DataChunk implements Chunk {
6363 private byte [] serializedId ;
6464 private Object entity ;
6565 private Object undoentity ;
66+ private Map <Integer , DataChunk > ics = new HashMap <>();
6667 private DataChunk source ;
6768 private UndoChunk uc ;
69+ private FrameData uframe ;
6870 private boolean terminate ;
6971 private final CustomSerializer sr = new CustomSerializer ();
7072
@@ -175,6 +177,10 @@ public Table getT() {
175177 return t ;
176178 }
177179
180+ protected void setT (Table t ) {
181+ this .t = t ;
182+ }
183+
178184 public Comparable getId (Field idfield , Session s ) throws InvocationTargetException , NoSuchMethodException , IllegalAccessException {
179185 if (serializedId ==null ) {
180186 if (entity ==null ) {
@@ -275,7 +281,7 @@ public DataChunk () {
275281 }
276282
277283 //for index implementation
278- public DataChunk (ValueSet vs , Session s , RowId r , Table t ) throws ClassNotFoundException , IllegalAccessException , UnsupportedEncodingException , InternalException , MalformedURLException , InstantiationException {
284+ public DataChunk (ValueSet vs , Session s , RowId r , Table t ) throws ClassNotFoundException , IllegalAccessException , UnsupportedEncodingException , InternalException , InstantiationException {
279285 this .state = INIT_STATE ;
280286 this .t = t ;
281287 final ByteString res = new ByteString ();
@@ -325,18 +331,18 @@ public DataChunk (ValueSet vs, Session s, Table t) {
325331 }
326332
327333 //serializer INSERT ONLY!!! (with generate Id value)
328- public DataChunk (Object o , Session s ) throws IOException , InvocationTargetException , NoSuchMethodException , InternalException , ClassNotFoundException , InstantiationException , IllegalAccessException {
334+ public DataChunk (Object o , Session s ) {
329335 this (o , s , null );
330336 }
331337
332338 //serializer INSERT ONLY!!! (with generate Id value) - rowid for index chunk
333- public DataChunk (Object o , Session s , RowId r ) throws IOException , InvocationTargetException , NoSuchMethodException , InternalException , ClassNotFoundException , InstantiationException , IllegalAccessException {
339+ public DataChunk (Object o , Session s , RowId r ) {
334340 this .entity = o ;
335341 this .state = NORMAL_STATE ;
336342 this .header = new RowHeader (r , null , getChunk ().length , false );
337343 }
338344
339- public DataChunk (byte [] b , int file , long frame , int hsize , Table t , Class c ) throws ClassNotFoundException , InstantiationException , IllegalAccessException , InternalException , MalformedURLException {
345+ public DataChunk (byte [] b , int file , long frame , int hsize , Table t , Class c ) {
340346 final ByteString bs = new ByteString (b );
341347 this .t = t ;
342348 this .class_ = c ;
@@ -347,7 +353,7 @@ public DataChunk (byte[] b, int file, long frame, int hsize, Table t, Class c) t
347353 }
348354
349355 //constructor for clone method - de-serialize chunk only without header
350- public DataChunk (byte [] b , Table t , RowHeader h , DataChunk source ) throws ClassNotFoundException , InstantiationException , IllegalAccessException , InternalException , MalformedURLException {
356+ public DataChunk (byte [] b , Table t , RowHeader h , DataChunk source ) {
351357 this .chunk = b ;
352358 this .header = h ;
353359 this .state = INIT_STATE ;
@@ -484,6 +490,7 @@ public Object getEntity () {
484490 if (t .isIndex ()) {
485491 final ResultSetEntity rsa = (ResultSetEntity ) ((Table ) this .t ).getTableClass ().getAnnotation (ResultSetEntity .class );
486492 final DataChunk dc = rsa == null ? (DataChunk ) Instance .getInstance ().getChunkByPointer (this .getHeader ().getFramePtr (), this .getHeader ().getFramePtrRowId ().getRowPointer ()) : this ;
493+ dc .setIc (this );
487494 ((IndexChunk )o ).setDataChunk (dc );
488495 if (dc == null ) {
489496// todo during rframe.IndexFrame.init system directory not yet contains replicated FrameData objects
@@ -553,7 +560,8 @@ public void setFrameData(FrameData b) {
553560 entity = b ;
554561 }
555562
556- public Object getUndoEntity () { //throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
563+ @ Deprecated
564+ public Object getUndoEntity () {
557565 if (undoentity ==null ) {
558566 try {
559567 final ClassLoader cl = this .getClass ().getClassLoader ();
@@ -575,7 +583,7 @@ public Object getUndoEntity () { //throws ClassNotFoundException, InstantiationE
575583 return undoentity ;
576584 }
577585
578- public void updateEntity (Object o ) throws InternalException , ClassNotFoundException , InstantiationException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , MalformedURLException {
586+ public void updateEntity (Object o ) throws InternalException , IllegalAccessException {
579587 final Object oo = this .getEntity ();
580588 if (!oo .getClass ().getName ().equals (o .getClass ().getName ())) {
581589 throw new InternalException (); //classes of object do not match
@@ -610,9 +618,15 @@ protected void setNormalState() {
610618 }
611619
612620 //for UNDO processing
613- public DataChunk cloneEntity (Session s ) throws IOException , InvocationTargetException , NoSuchMethodException , InternalException , ClassNotFoundException , InstantiationException , IllegalAccessException {
621+ public DataChunk cloneEntity (Session s ) throws InternalException {
614622 final byte [] b = this .getChunk ();
615- return new DataChunk (b , this .t , new RowHeader (this .getHeader ()), this );
623+ final DataChunk dc_ = new DataChunk (b , this .t , new RowHeader (this .getHeader ()), this );
624+ final Object entity_ = this .getEntity ();
625+ if (this .t == null ) {
626+ dc_ .t = Instance .getInstance ().getTableByName (entity_ .getClass ().getName ());
627+ }
628+ dc_ .class_ = entity_ .getClass ();
629+ return dc_ ;
616630 }
617631
618632 public DataChunk restore (Frame b , Session s ) throws Exception {
@@ -622,13 +636,11 @@ public DataChunk restore(Frame b, Session s) throws Exception {
622636 if (!(this .getHeader ().getRowID ().getFileId () == source .getHeader ().getRowID ().getFileId () && this .getHeader ().getRowID ().getFramePointer () == source .getHeader ().getRowID ().getFramePointer ())) {
623637 final long srcFrameId = source .getHeader ().getRowID ().getFileId () + source .getHeader ().getRowID ().getFramePointer ();
624638 final Frame srcFrame = Instance .getInstance ().getFrameById (srcFrameId ).getFrame ();
625- //final LLT llt = LLT.getLLT();
626- // not need for use llt here
627- srcFrame .removeChunk (source .getHeader ().getRowID ().getRowPointer (), null , true );
628- //llt.commit();
639+ //todo ???
640+ srcFrame .removeChunk (source .getHeader ().getRowID ().getRowPointer (), null , false );
629641 }
630642 source .setHeader (this .getHeader ());
631- source .setEntity (this .getEntity (), false );
643+ source .updateEntity (this .getEntity ());
632644 return source ;
633645 }
634646
@@ -668,13 +680,15 @@ private synchronized DataChunk insertUC (FrameData cb, UndoChunk uc, Session s,
668680 final DataChunk dc = new DataChunk (uc , s );
669681 final int p = ub .getDataFrame ().insertChunk (dc , s , true , llt );
670682 if (p == 0 ) {
671- final Table t = Instance .getInstance ().getTableByName ("su.interference.persistent.UndoChunk" );
683+ final Table t = Instance .getInstance ().getTableByName (UndoChunk . class . getName () );
672684 final FrameData nb = t .createNewFrame (ub , ub .getFile (), 0 , 0 , false , false , false , s , llt );
673685 s .getTransaction ().setNewLB (ub , nb , false );
674686 nb .getDataFrame ().insertChunk (dc , s , true , llt );
675- s .getTransaction ().storeFrame (cb , nb , 0 , s , llt );
687+ dc .uframe = nb ;
688+ //s.getTransaction().storeFrame(cb, nb, 0, s, llt);
676689 } else {
677- s .getTransaction ().storeFrame (cb , ub , 0 , s , llt );
690+ dc .uframe = ub ;
691+ //s.getTransaction().storeFrame(cb, ub, 0, s, llt);
678692 }
679693 ubw .release ();
680694 return dc ;
@@ -746,6 +760,10 @@ protected synchronized void undo(Session s, LLT llt) throws Exception {
746760 }
747761 }
748762
763+ public FrameData getUframe () {
764+ return uframe ;
765+ }
766+
749767 public boolean isTerminate () {
750768 return terminate ;
751769 }
@@ -754,6 +772,15 @@ public void setTerminate(boolean terminate) {
754772 this .terminate = terminate ;
755773 }
756774
775+ public void setIc (DataChunk ic ) {
776+ final Table t_ = ic .t == null ? Instance .getInstance ().getTableByName (ic .getEntity ().getClass ().getName ()) : ic .t ;
777+ this .ics .put (t_ .getObjectId (), ic );
778+ }
779+
780+ public Map <Integer , DataChunk > getIcs () {
781+ return this .ics ;
782+ }
783+
757784 private byte [] getBytesFromHexString (String s ) {
758785 byte b [] = new byte [s .length ()/2 ];
759786 for (int i =0 ; i <s .length (); i +=2 ) {
0 commit comments