@@ -27,6 +27,7 @@ this software and associated documentation files (the "Software"), to deal in
27
27
import java .io .IOException ;
28
28
import java .util .*;
29
29
import java .util .concurrent .ConcurrentHashMap ;
30
+ import java .util .concurrent .ExecutionException ;
30
31
import java .util .concurrent .LinkedBlockingQueue ;
31
32
import java .util .concurrent .atomic .AtomicBoolean ;
32
33
import java .util .concurrent .atomic .AtomicInteger ;
@@ -102,6 +103,8 @@ public class Table implements DataObject, ResultSet {
102
103
@ Column
103
104
private AtomicLong incValue ;
104
105
106
+ @ Transient
107
+ private Map <Integer , Long > ixstartfs = new HashMap <>();
105
108
@ Transient
106
109
private AtomicLong idValue2 ;
107
110
@ Transient
@@ -1212,6 +1215,7 @@ protected void delete (final Object o, final Session s, LLT extllt) throws Excep
1212
1215
if (extllt == null ) { llt .commit (); }
1213
1216
}
1214
1217
1218
+ //todo deprecated started param
1215
1219
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 {
1216
1220
final DataFile df = Storage .getStorage ().getDataFileById (fileId );
1217
1221
final FrameData bd = df .createNewFrame (frame , frameType , allocId , started , external , this , s , llt );
@@ -1354,7 +1358,7 @@ public Boolean call() throws Exception {
1354
1358
List <FrameData > bb = Instance .getInstance ().getTableById (getObjectId ()).getFrames ();
1355
1359
1356
1360
for (FrameData b : bb ) {
1357
- if (b .getStarted ()== 1 ) {
1361
+ if (b .getStarted () > 0 ) {
1358
1362
startframes .add (b .getFrameId ());
1359
1363
}
1360
1364
}
@@ -1368,7 +1372,7 @@ public Boolean call() throws Exception {
1368
1372
throw new InternalException ();
1369
1373
}
1370
1374
//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 ) {
1372
1376
throw new InternalException ();
1373
1377
}
1374
1378
IndexFrame el = bd .getIndexFrame ();
@@ -1705,14 +1709,24 @@ public synchronized void remove (ValueSet key, Object o, Session s, LLT llt) thr
1705
1709
removeObjects (key , o , s , llt );
1706
1710
}
1707
1711
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
+
1708
1722
@ Deprecated
1709
1723
public synchronized List <Chunk > getContent (Session s ) throws IOException , InternalException , NoSuchMethodException , InvocationTargetException , EmptyFrameHeaderFound , ClassNotFoundException , InstantiationException , IllegalAccessException {
1710
1724
ArrayList <Chunk > res = new ArrayList <Chunk >();
1711
1725
res .addAll (getLocalContent (this .fileStart +this .frameStart , s ));
1712
1726
//todo need performance optimizing
1713
1727
List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1714
1728
for (FrameData b : bb ) {
1715
- if (b .getStarted ()== 1 ) {
1729
+ if (b .getStarted () > 0 ) {
1716
1730
res .addAll (getLocalContent (b .getFrameId (), s ));
1717
1731
}
1718
1732
}
@@ -1729,7 +1743,7 @@ private synchronized List<Chunk> getLocalContent(long start, Session s) throws I
1729
1743
return res ;
1730
1744
}
1731
1745
//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 ) {
1733
1747
return res ;
1734
1748
}
1735
1749
IndexFrame el = bd .getIndexFrame ();
@@ -1770,7 +1784,7 @@ private synchronized ArrayList<FrameData> getLeafFrames (Session s) throws IOExc
1770
1784
//todo need performance optimizing
1771
1785
List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1772
1786
for (FrameData b : bb ) {
1773
- if (b .getStarted ()== 1 ) {
1787
+ if (b .getStarted () > 0 ) {
1774
1788
res .addAll (getLocalLeafFrames (b .getFrameId (), s ));
1775
1789
}
1776
1790
}
@@ -1783,7 +1797,7 @@ private synchronized ArrayList<FrameData> getLocalLeafFrames (long start, Sessio
1783
1797
boolean cnue = true ;
1784
1798
FrameData bd = Instance .getInstance ().getFrameById (start );
1785
1799
//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 ) {
1787
1801
return res ;
1788
1802
}
1789
1803
IndexFrame el = bd .getIndexFrame ();
@@ -1866,7 +1880,7 @@ public synchronized DataChunk getObjectByKey (ValueSet key) throws IOException,
1866
1880
//todo need performance optimizing
1867
1881
final List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1868
1882
for (FrameData b : bb ) {
1869
- if (b .getStarted () == 1 ) {
1883
+ if (b .getStarted () > 0 ) {
1870
1884
final DataChunk dc_ = getLocalObjectByKey (b .getFrameId (), key );
1871
1885
if (dc_ != null ) {
1872
1886
return dc_ ;
@@ -1883,7 +1897,7 @@ public synchronized List<DataChunk> getObjectsByKey (ValueSet key) throws IOExce
1883
1897
//todo need performance optimizing
1884
1898
final List <FrameData > bb = Instance .getInstance ().getTableById (this .getObjectId ()).getFrames ();
1885
1899
for (FrameData b : bb ) {
1886
- if (b .getStarted () == 1 ) {
1900
+ if (b .getStarted () > 0 ) {
1887
1901
r .addAll (getLocalObjectsByKey (b .getFrameId (), key ));
1888
1902
}
1889
1903
}
0 commit comments