| 295 | } |
| 296 | |
| 297 | public static class BinaryGet<K, V> implements StoreBinaryGetLong { |
| 298 | final GroupSerializer<K> keySerializer; |
| 299 | final GroupSerializer<V> valueSerializer; |
| 300 | final Comparator<K> comparator; |
| 301 | final K key; |
| 302 | |
| 303 | V value = null; |
| 304 | |
| 305 | public BinaryGet( |
| 306 | @NotNull GroupSerializer<K> keySerializer, |
| 307 | @NotNull GroupSerializer<V> valueSerializer, |
| 308 | @NotNull Comparator<K> comparator, |
| 309 | @NotNull K key |
| 310 | ) { |
| 311 | this.keySerializer = keySerializer; |
| 312 | this.valueSerializer = valueSerializer; |
| 313 | this.comparator = comparator; |
| 314 | this.key = key; |
| 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public long get(DataInput2 input, int size) throws IOException { |
| 319 | //read size and flags |
| 320 | int keysLen = DataIO.parity1Get(input.unpackInt())>>>1; |
| 321 | int flags = keysLen&0xF; |
| 322 | keysLen = keysLen>>>4; |
| 323 | if(keysLen==0) |
| 324 | return -1L; |
| 325 | |
| 326 | long link = (flags&RIGHT)!=0 |
| 327 | ? 0L : |
| 328 | input.unpackLong(); |
| 329 | |
| 330 | int intLeft = ((flags >>> 2) & 1); |
| 331 | int intRight = ((flags >>> 1) & 1); |
| 332 | |
| 333 | int pos = keySerializer.valueArrayBinarySearch(key, input, keysLen, comparator); |
| 334 | if((flags&DIR)!=0){ |
| 335 | //is directory, return related children |
| 336 | |
| 337 | if(pos<0) |
| 338 | pos = -pos-1; |
| 339 | |
| 340 | pos += -1 + intLeft; // plus left edge |
| 341 | pos = Math.max(0, pos); |
| 342 | keysLen = keysLen - 1 + intLeft + intRight; |
| 343 | |
| 344 | if(pos>=keysLen) { |
| 345 | if(CC.ASSERT && intRight==1) |
| 346 | throw new AssertionError(); |
| 347 | return link; |
| 348 | } |
| 349 | if(pos>0) |
| 350 | input.unpackLongSkip(pos-1); |
| 351 | return input.unpackLong(); |
| 352 | } |
| 353 | |
| 354 | //is leaf, get value from leaf |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…