Changeset 29484 in osm for applications/editors/josm/plugins/imagerycache/src/org/mapdb/HTreeMap.java
- Timestamp:
- 2013-04-07T17:07:27+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagerycache/src/org/mapdb/HTreeMap.java
r29363 r29484 52 52 protected final int hashSalt; 53 53 54 protected final Atomic.Long counter; 54 55 55 56 protected final Serializer<K> keySerializer; … … 86 87 out.writeBoolean(value.hasValues); 87 88 out.writeInt(value.hashSalt); 89 out.writeLong(value.counterRecid); 88 90 for(int i=0;i<16;i++){ 89 91 Utils.packLong(out, value.segmentRecids[i]); … … 100 102 r.hasValues = in.readBoolean(); 101 103 r.hashSalt = in.readInt(); 104 r.counterRecid = in.readLong(); 102 105 r.segmentRecids = new long[16]; 103 106 for(int i=0;i<16;i++){ … … 116 119 boolean hasValues; 117 120 int hashSalt; 121 long counterRecid; 118 122 Serializer keySerializer; 119 123 Serializer valueSerializer; 124 120 125 } 121 126 … … 212 217 * @param valueSerializer Serializer used for values. May be null for default value 213 218 */ 214 public HTreeMap(Engine engine, boolean hasValues, int hashSalt, Serializer defaultSerializer, Serializer<K> keySerializer, Serializer<V> valueSerializer) {219 public HTreeMap(Engine engine, boolean hasValues, boolean keepCounter, int hashSalt, Serializer defaultSerializer, Serializer<K> keySerializer, Serializer<V> valueSerializer) { 215 220 this.engine = engine; 216 221 this.hasValues = hasValues; 217 222 this.hashSalt = hashSalt; 223 224 218 225 SerializerBase.assertSerializable(keySerializer); 219 226 SerializerBase.assertSerializable(valueSerializer); 227 220 228 221 229 if(defaultSerializer == null) defaultSerializer = Serializer.BASIC_SERIALIZER; … … 229 237 for(int i=0;i<16;i++) 230 238 segmentRecids[i] = engine.put(new long[16][], DIR_SERIALIZER); 239 240 long counterRecid = 0; 241 if(keepCounter){ 242 counterRecid = engine.put(0L, Serializer.LONG_SERIALIZER); 243 this.counter = new Atomic.Long(engine,counterRecid); 244 Bind.size(this,counter); 245 }else{ 246 this.counter = null; 247 } 248 231 249 HashRoot r = new HashRoot(); 232 250 r.hasValues = hasValues; 233 251 r.hashSalt = hashSalt; 252 r.counterRecid = counterRecid; 234 253 r.segmentRecids = segmentRecids; 235 254 r.keySerializer = this.keySerializer; 236 255 r.valueSerializer = this.valueSerializer; 237 256 this.rootRecid = engine.put(r, new HashRootSerializer(defaultSerializer)); 257 238 258 } 239 259 … … 259 279 this.keySerializer = r.keySerializer; 260 280 this.valueSerializer = r.valueSerializer; 281 282 if(r.counterRecid!=0){ 283 counter = new Atomic.Long(engine,r.counterRecid); 284 Bind.size(this,counter); 285 }else{ 286 this.counter = null; 287 } 261 288 } 262 289 … … 294 321 @Override 295 322 public int size() { 323 if(counter!=null) 324 return (int) counter.get(); //TODO larger then MAX_INT 325 326 296 327 long counter = 0; 297 328
Note:
See TracChangeset
for help on using the changeset viewer.