@@ -27,6 +27,7 @@ this software and associated documentation files (the "Software"), to deal in
2727import java .io .IOException ;
2828import java .util .*;
2929import java .util .concurrent .ConcurrentHashMap ;
30+ import java .util .concurrent .ExecutionException ;
3031import java .util .concurrent .LinkedBlockingQueue ;
3132import java .util .concurrent .atomic .AtomicBoolean ;
3233import java .util .concurrent .atomic .AtomicInteger ;
@@ -102,6 +103,8 @@ public class Table implements DataObject, ResultSet {
102103 @ Column
103104 private AtomicLong incValue ;
104105
106+ @ Transient
107+ private Map <Integer , Long > ixstartfs = new HashMap <>();
105108 @ Transient
106109 private AtomicLong idValue2 ;
107110 @ Transient
@@ -1212,6 +1215,7 @@ protected void delete (final Object o, final Session s, LLT extllt) throws Excep
12121215 if (extllt == null ) { llt .commit (); }
12131216 }
12141217
1218+ //todo deprecated started param
12151219 public synchronized FrameData createNewFrame (final FrameData frame , final int fileId , final int frameType , final long allocId , final boolean started , final boolean setlbs , final boolean external , final Session s , final LLT llt ) throws Exception {
12161220 final DataFile df = Storage .getStorage ().getDataFileById (fileId );
12171221 final FrameData bd = df .createNewFrame (frame , frameType , allocId , started , external , this , s , llt );
@@ -1354,7 +1358,7 @@ public Boolean call() throws Exception {
13541358 List <FrameData > bb = Instance .getInstance ().getTableById (getObjectId ()).getFrames ();
13551359
13561360 for (FrameData b : bb ) {
1357- if (b .getStarted ()== 1 ) {
1361+ if (b .getStarted () > 0 ) {
13581362 startframes .add (b .getFrameId ());
13591363 }
13601364 }
@@ -1368,7 +1372,7 @@ public Boolean call() throws Exception {
13681372 throw new InternalException ();
13691373 }
13701374 //frame must be local or remote chain started (RCS)
1371- if (bd .getFrameId () != bd .getAllocId () && bd .getStarted () != 1 ) {
1375+ if (bd .getFrameId () != bd .getAllocId () && bd .getStarted () == 0 ) {
13721376 throw new InternalException ();
13731377 }
13741378 IndexFrame el = bd .getIndexFrame ();
@@ -1705,14 +1709,24 @@ public synchronized void remove (ValueSet key, Object o, Session s, LLT llt) thr
17051709 removeObjects (key , o , s , llt );
17061710 }
17071711
1712+ public synchronized void storeFrames (List <SyncFrame > frames , int sourceNodeId , LLT llt , Session s ) throws Exception {
1713+ for (SyncFrame b : frames ) {
1714+ if (b .isStarted ()) {
1715+ ixstartfs .put (sourceNodeId , b .getBd ().getFrameId ());
1716+ b .getBd ().setStarted (sourceNodeId );
1717+ }
1718+ b .getDf ().writeFrame (b .getBd (), b .getBd ().getPtr (), b .getBd ().getFrame ().getFrame (), llt , s );
1719+ }
1720+ }
1721+
17081722 @ Deprecated
17091723 public synchronized List <Chunk > getContent (Session s ) throws IOException , InternalException , NoSuchMethodException , InvocationTargetException , EmptyFrameHeaderFound , ClassNotFoundException , InstantiationException , IllegalAccessException {
17101724 ArrayList <Chunk > res = new ArrayList <Chunk >();
17111725 res .addAll (getLocalContent (this .fileStart +this .frameStart , s ));
17121726 //todo need performance optimizing
17131727 List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
17141728 for (FrameData b : bb ) {
1715- if (b .getStarted ()== 1 ) {
1729+ if (b .getStarted () > 0 ) {
17161730 res .addAll (getLocalContent (b .getFrameId (), s ));
17171731 }
17181732 }
@@ -1729,7 +1743,7 @@ private synchronized List<Chunk> getLocalContent(long start, Session s) throws I
17291743 return res ;
17301744 }
17311745 //frame must be local or remote chain started (RCS)
1732- if (bd .getFrameId () != bd .getAllocId () && bd .getStarted () != 1 ) {
1746+ if (bd .getFrameId () != bd .getAllocId () && bd .getStarted () == 0 ) {
17331747 return res ;
17341748 }
17351749 IndexFrame el = bd .getIndexFrame ();
@@ -1770,7 +1784,7 @@ private synchronized ArrayList<FrameData> getLeafFrames (Session s) throws IOExc
17701784 //todo need performance optimizing
17711785 List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
17721786 for (FrameData b : bb ) {
1773- if (b .getStarted ()== 1 ) {
1787+ if (b .getStarted () > 0 ) {
17741788 res .addAll (getLocalLeafFrames (b .getFrameId (), s ));
17751789 }
17761790 }
@@ -1783,7 +1797,7 @@ private synchronized ArrayList<FrameData> getLocalLeafFrames (long start, Sessio
17831797 boolean cnue = true ;
17841798 FrameData bd = Instance .getInstance ().getFrameById (start );
17851799 //frame must be local or remote chain started (RCS)
1786- if (bd .getFrameId () != bd .getAllocId () && bd .getStarted () != 1 ) {
1800+ if (bd .getFrameId () != bd .getAllocId () && bd .getStarted () == 0 ) {
17871801 return res ;
17881802 }
17891803 IndexFrame el = bd .getIndexFrame ();
@@ -1866,7 +1880,7 @@ public synchronized DataChunk getObjectByKey (ValueSet key) throws IOException,
18661880 //todo need performance optimizing
18671881 final List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
18681882 for (FrameData b : bb ) {
1869- if (b .getStarted () == 1 ) {
1883+ if (b .getStarted () > 0 ) {
18701884 final DataChunk dc_ = getLocalObjectByKey (b .getFrameId (), key );
18711885 if (dc_ != null ) {
18721886 return dc_ ;
@@ -1883,7 +1897,7 @@ public synchronized List<DataChunk> getObjectsByKey (ValueSet key) throws IOExce
18831897 //todo need performance optimizing
18841898 final List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
18851899 for (FrameData b : bb ) {
1886- if (b .getStarted () == 1 ) {
1900+ if (b .getStarted () > 0 ) {
18871901 r .addAll (getLocalObjectsByKey (b .getFrameId (), key ));
18881902 }
18891903 }
0 commit comments