MCPcopy Index your code
hub / github.com/jankotek/mapdb / treeRemove

Method treeRemove

src/main/java/org/mapdb/IndexTreeListJava.java:404–451  ·  view source on GitHub ↗
(int dirShift,
                              long recid,
                              Store store,
                              int level,
                              long index,
                              Long expectedValue //null for always remove
    )

Source from the content-addressed store, hash-verified

402 }
403
404 static boolean treeRemove(int dirShift,
405 long recid,
406 Store store,
407 int level,
408 long index,
409 Long expectedValue //null for always remove
410 ){
411 if(CC.ASSERT && level<0)
412 throw new DBException.DataCorruption("level too low");
413 if(CC.ASSERT && index<0)
414 throw new AssertionError();
415 if(CC.ASSERT && (dirShift<0||dirShift>maxDirShift))
416 throw new AssertionError();
417
418// TODO assert at top level
419// if(CC.ASSERT && index>>>(level*dirShift)!=0)
420// throw new AssertionError();
421
422 long[] dir = store.get(recid, dirSer);
423 final int slot = treePos(dirShift, level, index);
424 final int pos = dirOffsetFromSlot(dir, slot);
425 if(pos<0){
426 //slot not found
427 return false;
428 }
429 long oldVal = dir[pos];
430 long oldIndex= dir[pos+1]-1;
431
432 if (oldIndex == -1) {
433 if (oldVal == 0) {
434 throw new AssertionError(); //this was already covered by negative pos
435 } else {
436 //dive deeper
437 return treeRemove(dirShift, oldVal, store, level-1, index, expectedValue);
438 //TODO this should collapse node, if it becomes occupied by single record
439 }
440 } else if (oldIndex == index) {
441 //slot is occupied by the same index
442 if (expectedValue!=null && expectedValue.longValue()!=oldVal)
443 return false;
444 dir = dirRemove(dir, slot);
445 store.update(recid, dir, dirSer);
446 return true;
447 } else {
448 // is occupied by the different value, must split it
449 return false;
450 }
451 }
452
453
454

Callers

nothing calls this directly

Calls 5

treePosMethod · 0.95
dirOffsetFromSlotMethod · 0.95
dirRemoveMethod · 0.95
getMethod · 0.65
longValueMethod · 0.45

Tested by

no test coverage detected