@@ -656,6 +656,7 @@ public Table (DataChunk chunk, IndexList ixl) throws IllegalAccessException, Cla
656656 this .genericClass = Instance .getUCL ().loadClass (name );
657657 final SystemEntity sa = (SystemEntity )this .genericClass .getAnnotation (SystemEntity .class );
658658 final IndexEntity xa = (IndexEntity )this .genericClass .getAnnotation (IndexEntity .class );
659+ final ResultSetEntity rsa = (ResultSetEntity )this .genericClass .getAnnotation (ResultSetEntity .class );
659660 this .notran = sa !=null ;
660661 this .index = xa !=null ;
661662 this .idfield = getTableIdField ();
@@ -681,39 +682,32 @@ public Table (DataChunk chunk, IndexList ixl) throws IllegalAccessException, Cla
681682 }
682683 getMapFieldByColumn ("frameId" ).setMap (ixlb );
683684 getMapFieldByColumn ("allocId" ).setMap (ixla );
684- getIndexFieldByColumn ("started" ).setIndex (ixls );
685685 } else if (this .name .equals ("su.interference.persistent.UndoChunk" )) {
686686 //none
687687 } else {
688- Class cc = this .getTableClass ();
689688 try {
690- java .lang .reflect .Field fc = null ;
691- Constructor ccc = null ;
692- try {
693- fc = cc .getField ("CLASS_ID" );
694- } catch (NoSuchFieldException e ) { logger .info ("NoSuchFieldException: CLASS_ID during Table construct" );; }
695- try {
696- ccc = cc .getConstructor (DataChunk .class );
697- } catch (NoSuchMethodException e ) { logger .info ("NoSuchMethodException: <init>(DataChunk) during Table:" +cc .getName ()+" construct" ); }
698- if (fc != null && ccc != null ) {
699- final List <Object > bds = ixl .getObjectsByKey (fc .getInt (this ));
700- for (Object b : bds ) {
701- final FrameData bd = (FrameData )((DataChunk )b ).getEntity ();
702- bd .setDataObject (this ); //todo must be refactored, FrameData->new DataFrame->new DataChunk->t.getFields() possibly may be simply
703- DataFrame db = null ;
689+ final List <Object > bds = ixl .getObjectsByKey (this .getObjectId ());
690+ for (Object b : bds ) {
691+ final FrameData bd = (FrameData )((DataChunk )b ).getEntity ();
692+ bd .setDataObject (this ); //todo must be refactored, FrameData->new DataFrame->new DataChunk->t.getFields() possibly may be simply
693+
694+ if (sa != null && rsa == null && this .objectId != Table .CLASS_ID ) {
695+ Frame db = null ;
704696 try {
705- db = bd .getDataFrame ();
697+ db = bd .getFrame ();
706698 } catch (Exception e ) {
699+ logger .error ("internal Table.<init>" );
707700 }
708- for (Chunk ck : db .getChunks ()) {
709- if (ck .getHeader ().getState ()==Header .RECORD_NORMAL_STATE ) { //miss deleted or archived records
710- //Object to;
711- //to = ccc.newInstance((DataChunk)ck);
712- //this.addIndexValue(to);
713- this .addIndexValue ((DataChunk )ck );
701+ for (Chunk ck : ((DataFrame )db ).getChunks ()) {
702+ if (ck .getHeader ().getState () == Header .RECORD_NORMAL_STATE ) { //miss deleted or archived records
703+ this .addIndexValue ((DataChunk ) ck );
714704 }
715705 }
716706 }
707+ //set start frames for remote indexes
708+ if (bd .getStarted () > 0 ) {
709+ ixstartfs .put (bd .getStarted (), bd .getFrameId ());
710+ }
717711 }
718712 } catch (Exception e ) {
719713 e .printStackTrace ();
@@ -1355,12 +1349,8 @@ public Boolean call() throws Exception {
13551349 synchronized (t ) {
13561350 List <Long > startframes = new ArrayList <>();
13571351 startframes .add (t .fileStart + t .frameStart );
1358- List <FrameData > bb = Instance .getInstance ().getTableById (getObjectId ()).getFrames ();
1359-
1360- for (FrameData b : bb ) {
1361- if (b .getStarted () > 0 ) {
1362- startframes .add (b .getFrameId ());
1363- }
1352+ for (Map .Entry <Integer , Long > entry : ixstartfs .entrySet ()) {
1353+ startframes .add (entry .getValue ());
13641354 }
13651355
13661356 //todo need to implement merge algorithm for multinode indexes
@@ -1712,6 +1702,7 @@ public synchronized void remove (ValueSet key, Object o, Session s, LLT llt) thr
17121702 public synchronized void storeFrames (List <SyncFrame > frames , int sourceNodeId , LLT llt , Session s ) throws Exception {
17131703 for (SyncFrame b : frames ) {
17141704 b .getBd ().setStarted (0 );
1705+ b .getBd ().setFrame (b .getRFrame ());
17151706 if (b .isStarted ()) {
17161707 ixstartfs .put (sourceNodeId , b .getBd ().getFrameId ());
17171708 b .getBd ().setStarted (sourceNodeId );
@@ -1724,12 +1715,8 @@ public synchronized void storeFrames(List<SyncFrame> frames, int sourceNodeId, L
17241715 public synchronized List <Chunk > getContent (Session s ) throws IOException , InternalException , NoSuchMethodException , InvocationTargetException , EmptyFrameHeaderFound , ClassNotFoundException , InstantiationException , IllegalAccessException {
17251716 ArrayList <Chunk > res = new ArrayList <Chunk >();
17261717 res .addAll (getLocalContent (this .fileStart +this .frameStart , s ));
1727- //todo need performance optimizing
1728- List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1729- for (FrameData b : bb ) {
1730- if (b .getStarted () > 0 ) {
1731- res .addAll (getLocalContent (b .getFrameId (), s ));
1732- }
1718+ for (Map .Entry <Integer , Long > entry : ixstartfs .entrySet ()) {
1719+ res .addAll (getLocalContent (entry .getValue (), s ));
17331720 }
17341721 return res ;
17351722 }
@@ -1782,12 +1769,8 @@ private synchronized List<Chunk> getLocalContent(long start, Session s) throws I
17821769 private synchronized ArrayList <FrameData > getLeafFrames (Session s ) throws IOException , InternalException , NoSuchMethodException , InvocationTargetException , EmptyFrameHeaderFound , ClassNotFoundException , InstantiationException , IllegalAccessException {
17831770 ArrayList <FrameData > res = new ArrayList <FrameData >();
17841771 res .addAll (getLocalLeafFrames (this .fileStart +this .frameStart , s ));
1785- //todo need performance optimizing
1786- List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1787- for (FrameData b : bb ) {
1788- if (b .getStarted () > 0 ) {
1789- res .addAll (getLocalLeafFrames (b .getFrameId (), s ));
1790- }
1772+ for (Map .Entry <Integer , Long > entry : ixstartfs .entrySet ()) {
1773+ res .addAll (getLocalLeafFrames (entry .getValue (), s ));
17911774 }
17921775 return res ;
17931776 }
@@ -1878,14 +1861,10 @@ public synchronized DataChunk getObjectByKey (ValueSet key) throws IOException,
18781861 if (dc != null ) {
18791862 return dc ;
18801863 } else {
1881- //todo need performance optimizing
1882- final List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1883- for (FrameData b : bb ) {
1884- if (b .getStarted () > 0 ) {
1885- final DataChunk dc_ = getLocalObjectByKey (b .getFrameId (), key );
1886- if (dc_ != null ) {
1887- return dc_ ;
1888- }
1864+ for (Map .Entry <Integer , Long > entry : ixstartfs .entrySet ()) {
1865+ final DataChunk dc_ = getLocalObjectByKey (entry .getValue (), key );
1866+ if (dc_ != null ) {
1867+ return dc_ ;
18891868 }
18901869 }
18911870 }
@@ -1895,12 +1874,8 @@ public synchronized DataChunk getObjectByKey (ValueSet key) throws IOException,
18951874 public synchronized List <DataChunk > getObjectsByKey (ValueSet key ) throws IOException , InternalException , NoSuchMethodException , InvocationTargetException , EmptyFrameHeaderFound , ClassNotFoundException , InstantiationException , IllegalAccessException {
18961875 final long start = this .fileStart +this .frameStart ;
18971876 final List <DataChunk > r = getLocalObjectsByKey (start , key );
1898- //todo need performance optimizing
1899- final List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1900- for (FrameData b : bb ) {
1901- if (b .getStarted () > 0 ) {
1902- r .addAll (getLocalObjectsByKey (b .getFrameId (), key ));
1903- }
1877+ for (Map .Entry <Integer , Long > entry : ixstartfs .entrySet ()) {
1878+ r .addAll (getLocalObjectsByKey (entry .getValue (), key ));
19041879 }
19051880 return r ;
19061881 }
0 commit comments