@@ -37,72 +37,80 @@ public class ChunkMap {
3737 private final ConcurrentHashMap <Integer , Chunk > hmap ;
3838 private final ConcurrentHashMap <ValueSet , Chunk > imap ;
3939 private final List <Chunk > list ;
40+ private final Frame frame ;
4041 private volatile boolean sorted ;
4142
42- public ChunkMap () {
43+ public ChunkMap (Frame frame ) {
4344 hmap = new ConcurrentHashMap <>();
4445 imap = new ConcurrentHashMap <>();
4546 list = new CopyOnWriteArrayList <>();
47+ this .frame = frame ;
4648 }
4749
48- public void sort () {
50+ public synchronized void sort () {
4951 Collections .sort (list );
5052 sorted = true ;
5153 }
5254
53- public void add (Chunk c ) {
55+ public synchronized void add (Chunk c ) {
5456 hmap .put (c .getHeader ().getPtr (), c );
55- imap .put (c .getDcs (), c );
57+ if (frame instanceof IndexFrame ) {
58+ imap .put (c .getDcs (), c );
59+ }
5660 list .add (c );
5761 sorted = false ;
5862 }
5963
60- public List <Chunk > getChunks () {
64+ public synchronized List <Chunk > getChunks () {
6165 return list ;
6266 }
6367
64- public Chunk getByPtr (int i ) {
68+ public synchronized Chunk getByPtr (int i ) {
6569 return hmap .get (i );
6670 }
6771
68- public Chunk get (int i ) {
72+ public synchronized Chunk get (int i ) {
6973 return list .get (i );
7074 }
7175
72- public Chunk getByKey (ValueSet key ) {
76+ public synchronized Chunk getByKey (ValueSet key ) {
7377 return imap .get (key );
7478 }
7579
76- public void removeByPtr (int i ) {
80+ public synchronized void removeByPtr (int i ) {
7781 final boolean x = list .remove (hmap .get (i ));
7882 final Chunk c = (Chunk )hmap .remove (i );
79- imap .remove (c .getDcs ());
83+ if (frame instanceof IndexFrame ) {
84+ imap .remove (c .getDcs ());
85+ }
8086 sorted = false ;
8187 if (!x || c == null ) {
8288 throw new RuntimeException ("Internal error during remove object from frame" );
8389 }
8490 }
8591
86- public void remove (int i ) {
92+ public synchronized void remove (int i ) {
8793 final Chunk c = list .get (i );
8894 list .remove (i );
8995 hmap .remove (c .getHeader ().getPtr ());
90- imap .remove (c .getDcs ());
96+ if (frame instanceof IndexFrame ) {
97+ imap .remove (c .getDcs ());
98+ }
9199 sorted = false ;
92100 }
93101
94- public int size () {
102+ public synchronized int size () {
95103 return list .size ();
96104 }
97105
98- public void clear () {
106+ public synchronized void clear () {
99107 hmap .clear ();
100108 list .clear ();
101109 imap .clear ();
102110 sorted = false ;
103111 }
104112
105- public boolean isSorted () {
113+ public synchronized boolean isSorted () {
106114 return sorted ;
107115 }
108116}
0 commit comments