From 6024173a15b870f44f4de81f56a30322a8709cf0 Mon Sep 17 00:00:00 2001 From: sepgh Date: Tue, 11 Jun 2024 11:56:42 +0330 Subject: [PATCH] refactor: renamed strategy to B(b)inaryObjectWrapper --- .../tree/BPlusTreeIndexCreateOperation.java | 24 +++++----- .../tree/BPlusTreeIndexDeleteOperation.java | 26 +++++----- .../index/tree/BPlusTreeIndexManager.java | 26 +++++----- .../internal/index/tree/BPlusTreeUtils.java | 8 ++-- .../internal/index/tree/TreeNodeUtils.java | 20 ++++---- .../index/tree/node/AbstractLeafTreeNode.java | 38 +++++++-------- .../index/tree/node/AbstractTreeNode.java | 18 +++---- .../index/tree/node/InternalTreeNode.java | 48 +++++++++---------- .../internal/index/tree/node/NodeFactory.java | 14 +++--- .../cluster/ClusterBPlusTreeIndexManager.java | 8 ++-- .../node/cluster/LeafClusterTreeNode.java | 4 +- .../internal/helper/IndexFileDescriptor.java | 4 +- ....java => BinaryObjectWrapperTestCase.java} | 4 +- 13 files changed, 121 insertions(+), 121 deletions(-) rename src/test/java/com/github/sepgh/internal/index/tree/{NodeDataOldTestCase.java => BinaryObjectWrapperTestCase.java} (98%) diff --git a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexCreateOperation.java b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexCreateOperation.java index cf66fa0..cffe9a6 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexCreateOperation.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexCreateOperation.java @@ -17,14 +17,14 @@ public class BPlusTreeIndexCreateOperation, V extends Comparable> { private final int degree; private final IndexIOSession indexIOSession; - private final BinaryObjectWrapper keyStrategy; - private final BinaryObjectWrapper valueStrategy; + private final BinaryObjectWrapper keyBinaryObjectWrapper; + private final BinaryObjectWrapper valueBinaryObjectWrapper; - public BPlusTreeIndexCreateOperation(int degree, IndexIOSession indexIOSession, BinaryObjectWrapper keyStrategy, BinaryObjectWrapper valueStrategy) { + public BPlusTreeIndexCreateOperation(int degree, IndexIOSession indexIOSession, BinaryObjectWrapper keyBinaryObjectWrapper, BinaryObjectWrapper valueBinaryObjectWrapper) { this.degree = degree; this.indexIOSession = indexIOSession; - this.keyStrategy = keyStrategy; - this.valueStrategy = valueStrategy; + this.keyBinaryObjectWrapper = keyBinaryObjectWrapper; + this.valueBinaryObjectWrapper = valueBinaryObjectWrapper; } public AbstractTreeNode addIndex(AbstractTreeNode root, K identifier, V value) throws ExecutionException, InterruptedException, IOException, BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { @@ -44,7 +44,7 @@ public AbstractTreeNode addIndex(AbstractTreeNode root, K identifier, V va /* current node is a leaf which should handle storing the data */ /* If current node has space, store and exit */ - if (currentNode.getKeyList(degree, valueStrategy.size()).size() < (degree - 1)){ + if (currentNode.getKeyList(degree, valueBinaryObjectWrapper.size()).size() < (degree - 1)){ ((AbstractLeafTreeNode) currentNode).addKeyValue(identifier, value, degree); indexIOSession.write(currentNode); indexIOSession.commit(); @@ -52,7 +52,7 @@ public AbstractTreeNode addIndex(AbstractTreeNode root, K identifier, V va } /* Current node didn't have any space, so let's create a sibling and split */ - AbstractLeafTreeNode newSiblingLeafNode = new AbstractLeafTreeNode<>(indexIOSession.getIndexStorageManager().getEmptyNode(), keyStrategy, valueStrategy); + AbstractLeafTreeNode newSiblingLeafNode = new AbstractLeafTreeNode<>(indexIOSession.getIndexStorageManager().getEmptyNode(), keyBinaryObjectWrapper, valueBinaryObjectWrapper); List> passingKeyValues = ((AbstractLeafTreeNode) currentNode).split(identifier, value, degree); newSiblingLeafNode.setKeyValues(passingKeyValues, degree); indexIOSession.write(newSiblingLeafNode); // we want the node to have a value so that we can fix siblings @@ -61,12 +61,12 @@ public AbstractTreeNode addIndex(AbstractTreeNode root, K identifier, V va indexIOSession.write(newSiblingLeafNode); indexIOSession.write(currentNode); - answer = currentNode.getKeyList(degree, valueStrategy.size()).contains(identifier) ? currentNode : newSiblingLeafNode; + answer = currentNode.getKeyList(degree, valueBinaryObjectWrapper.size()).contains(identifier) ? currentNode : newSiblingLeafNode; /* this leaf doesn't have a parent! create one and deal with it right here! */ if (path.size() == 1) { currentNode.unsetAsRoot(); - InternalTreeNode newRoot = new InternalTreeNode<>(indexIOSession.getIndexStorageManager().getEmptyNode(), keyStrategy); + InternalTreeNode newRoot = new InternalTreeNode<>(indexIOSession.getIndexStorageManager().getEmptyNode(), keyBinaryObjectWrapper); newRoot.setAsRoot(); newRoot.addChildPointers( passingKeyValues.getFirst().key(), @@ -91,7 +91,7 @@ public AbstractTreeNode addIndex(AbstractTreeNode root, K identifier, V va if (currentInternalTreeNode.getKeyList(degree).size() < degree - 1) { /* current internal node can store the key */ int indexOfAddedKey = currentInternalTreeNode.addKey(idForParentToStore, degree); - if (newChildForParent.getKeyList(degree, valueStrategy.size()).getFirst().compareTo(idForParentToStore) < 0){ + if (newChildForParent.getKeyList(degree, valueBinaryObjectWrapper.size()).getFirst().compareTo(idForParentToStore) < 0){ currentInternalTreeNode.addChildAtIndex(indexOfAddedKey, newChildForParent.getPointer()); } else { currentInternalTreeNode.addChildAtIndex(indexOfAddedKey + 1, newChildForParent.getPointer()); @@ -108,14 +108,14 @@ public AbstractTreeNode addIndex(AbstractTreeNode root, K identifier, V va idForParentToStore = firstPassingChildPointers.getKey(); passingChildPointers.removeFirst(); - InternalTreeNode newInternalSibling = new InternalTreeNode(indexIOSession.getIndexStorageManager().getEmptyNode(), keyStrategy); + InternalTreeNode newInternalSibling = new InternalTreeNode(indexIOSession.getIndexStorageManager().getEmptyNode(), keyBinaryObjectWrapper); newInternalSibling.setChildPointers(passingChildPointers, degree, true); indexIOSession.write(newInternalSibling); // Current node was root and needs a new parent if (currentInternalTreeNode.isRoot()){ currentInternalTreeNode.unsetAsRoot(); - InternalTreeNode newRoot = new InternalTreeNode(indexIOSession.getIndexStorageManager().getEmptyNode(), keyStrategy); + InternalTreeNode newRoot = new InternalTreeNode(indexIOSession.getIndexStorageManager().getEmptyNode(), keyBinaryObjectWrapper); newRoot.setAsRoot(); newRoot.addChildPointers( diff --git a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexDeleteOperation.java b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexDeleteOperation.java index 4fa659b..8fe30d6 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexDeleteOperation.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexDeleteOperation.java @@ -18,15 +18,15 @@ public class BPlusTreeIndexDeleteOperation, V extends Co private final int table; private final IndexIOSession indexIOSession; private final int minKeys; - private final BinaryObjectWrapper valueStrategy; + private final BinaryObjectWrapper valueBinaryObjectWrapper; private final NodeFactory nodeFactory; - public BPlusTreeIndexDeleteOperation(int degree, int table, IndexIOSession indexIOSession, BinaryObjectWrapper valueStrategy, NodeFactory nodeFactory) { + public BPlusTreeIndexDeleteOperation(int degree, int table, IndexIOSession indexIOSession, BinaryObjectWrapper valueBinaryObjectWrapper, NodeFactory nodeFactory) { this.degree = degree; this.table = table; this.indexIOSession = indexIOSession; this.minKeys = (degree - 1) / 2; - this.valueStrategy = valueStrategy; + this.valueBinaryObjectWrapper = valueBinaryObjectWrapper; this.nodeFactory = nodeFactory; } @@ -74,14 +74,14 @@ private void deleteInternalNode(InternalTreeNode parent, InternalTreeNode List childrenList = node.getChildrenList(); if (idx != 0){ AbstractTreeNode leftIDXChild = indexIOSession.read(childrenList.get(idx - 1)); - if (leftIDXChild.getKeyList(degree, valueStrategy.size()).size() >= minKeys){ + if (leftIDXChild.getKeyList(degree, valueBinaryObjectWrapper.size()).size() >= minKeys){ K pred = this.getPredecessor(node, idx); node.setKey(idx, pred); indexIOSession.update(node); } } else { AbstractTreeNode rightIDXChild = indexIOSession.read(childrenList.get(idx + 1)); - if (rightIDXChild.getKeyList(degree, valueStrategy.size()).size() >= minKeys) { + if (rightIDXChild.getKeyList(degree, valueBinaryObjectWrapper.size()).size() >= minKeys) { K succ = getSuccessor(node, idx); node.setKey(idx, succ); indexIOSession.update(node); @@ -95,9 +95,9 @@ private void deleteInternalNode(InternalTreeNode parent, InternalTreeNode private K getPredecessor(InternalTreeNode node, int idx) throws ExecutionException, InterruptedException, IOException { AbstractTreeNode cur = indexIOSession.read(node.getChildrenList().get(idx)); while (!cur.isLeaf()) { - cur = indexIOSession.read(node.getChildrenList().get(cur.getKeyList(degree, valueStrategy.size()).size())); + cur = indexIOSession.read(node.getChildrenList().get(cur.getKeyList(degree, valueBinaryObjectWrapper.size()).size())); } - return cur.getKeyList(degree, valueStrategy.size()).getLast(); + return cur.getKeyList(degree, valueBinaryObjectWrapper.size()).getLast(); } private K getSuccessor(InternalTreeNode node, int idx) throws ExecutionException, InterruptedException, IOException { @@ -105,7 +105,7 @@ private K getSuccessor(InternalTreeNode node, int idx) throws ExecutionExcept while (!cur.isLeaf()) { cur = indexIOSession.read(((InternalTreeNode) cur).getChildrenList().getFirst()); } - return cur.getKeyList(degree, valueStrategy.size()).getFirst(); + return cur.getKeyList(degree, valueBinaryObjectWrapper.size()).getFirst(); } private void checkInternalNode(InternalTreeNode internalTreeNode, List> path, int nodeIndex, K identifier) throws ExecutionException, InterruptedException, IOException, BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { @@ -136,7 +136,7 @@ private void fillRootAtIndex(InternalTreeNode internalTreeNode, int indexOfKe table, degree, nodeFactory, - valueStrategy + valueBinaryObjectWrapper ); internalTreeNode.setKey(indexOfKey, leafTreeNode.getKeyList(degree).getLast()); @@ -165,7 +165,7 @@ private void fillNode(AbstractTreeNode currentNode, InternalTreeNode paren private boolean tryBorrowRight(InternalTreeNode parentNode, int idx, AbstractTreeNode child) throws ExecutionException, InterruptedException, IOException, BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { AbstractTreeNode sibling = indexIOSession.read(parentNode.getChildrenList().get(idx + 1)); - if (sibling.getKeyList(degree, valueStrategy.size()).size() > minKeys){ + if (sibling.getKeyList(degree, valueBinaryObjectWrapper.size()).size() > minKeys){ this.borrowFromNext(parentNode, idx, child); return true; } @@ -174,7 +174,7 @@ private boolean tryBorrowRight(InternalTreeNode parentNode, int idx, Abstract private boolean tryBorrowLeft(InternalTreeNode parentNode, int idx, AbstractTreeNode child) throws ExecutionException, InterruptedException, IOException, BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { AbstractTreeNode sibling = indexIOSession.read(parentNode.getChildrenList().get(idx - 1)); - if (sibling.getKeyList(degree, valueStrategy.size()).size() > minKeys){ + if (sibling.getKeyList(degree, valueBinaryObjectWrapper.size()).size() > minKeys){ this.borrowFromPrev(parentNode, idx, child); return true; } @@ -319,7 +319,7 @@ private void merge(InternalTreeNode parent, AbstractTreeNode child, int id AbstractTreeNode sibling = indexIOSession.read(parent.getChildrenList().get(siblingIndex)); AbstractTreeNode toRemove = sibling; - if (sibling.getKeyList(degree, valueStrategy.size()).size() > child.getKeyList(degree, valueStrategy.size()).size()){ + if (sibling.getKeyList(degree, valueBinaryObjectWrapper.size()).size() > child.getKeyList(degree, valueBinaryObjectWrapper.size()).size()){ // Sibling has more keys, lets merge from child to sibling and remove child AbstractTreeNode temp = child; child = sibling; @@ -339,7 +339,7 @@ private void merge(InternalTreeNode parent, AbstractTreeNode child, int id InternalTreeNode childInternalTreeNode = (InternalTreeNode) child; List childKeyList = new ArrayList<>(childInternalTreeNode.getKeyList(degree)); - childKeyList.addAll(sibling.getKeyList(degree, valueStrategy.size())); + childKeyList.addAll(sibling.getKeyList(degree, valueBinaryObjectWrapper.size())); childKeyList.sort(K::compareTo); childInternalTreeNode.setKeys(childKeyList); diff --git a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexManager.java b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexManager.java index c772453..c7e13ed 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexManager.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeIndexManager.java @@ -22,35 +22,35 @@ public class BPlusTreeIndexManager, V extends Comparable private final IndexStorageManager indexStorageManager; private final IndexIOSessionFactory indexIOSessionFactory; private final int degree; - private final BinaryObjectWrapper keyStrategy; - private final BinaryObjectWrapper valueStrategy; + private final BinaryObjectWrapper keyBinaryObjectWrapper; + private final BinaryObjectWrapper valueBinaryObjectWrapper; private final NodeFactory nodeFactory; - public BPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, IndexIOSessionFactory indexIOSessionFactory, BinaryObjectWrapper keyStrategy, BinaryObjectWrapper valueStrategy, NodeFactory nodeFactory){ + public BPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, IndexIOSessionFactory indexIOSessionFactory, BinaryObjectWrapper keyBinaryObjectWrapper, BinaryObjectWrapper valueBinaryObjectWrapper, NodeFactory nodeFactory){ this.degree = degree; this.indexStorageManager = indexStorageManager; this.indexIOSessionFactory = indexIOSessionFactory; - this.keyStrategy = keyStrategy; - this.valueStrategy = valueStrategy; + this.keyBinaryObjectWrapper = keyBinaryObjectWrapper; + this.valueBinaryObjectWrapper = valueBinaryObjectWrapper; this.nodeFactory = nodeFactory; } - public BPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, BinaryObjectWrapper keyStrategy, BinaryObjectWrapper valueStrategy, NodeFactory nodeFactory){ - this(degree, indexStorageManager, ImmediateCommitIndexIOSession.Factory.getInstance(), keyStrategy, valueStrategy, nodeFactory); + public BPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, BinaryObjectWrapper keyBinaryObjectWrapper, BinaryObjectWrapper valueBinaryObjectWrapper, NodeFactory nodeFactory){ + this(degree, indexStorageManager, ImmediateCommitIndexIOSession.Factory.getInstance(), keyBinaryObjectWrapper, valueBinaryObjectWrapper, nodeFactory); } @Override public AbstractTreeNode addIndex(int table, K identifier, V value) throws ExecutionException, InterruptedException, IOException, BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { IndexIOSession indexIOSession = this.indexIOSessionFactory.create(indexStorageManager, table, nodeFactory); AbstractTreeNode root = getRoot(indexIOSession); - return new BPlusTreeIndexCreateOperation<>(degree, indexIOSession, keyStrategy, valueStrategy).addIndex(root, identifier, value); + return new BPlusTreeIndexCreateOperation<>(degree, indexIOSession, keyBinaryObjectWrapper, valueBinaryObjectWrapper).addIndex(root, identifier, value); } @Override public Optional getIndex(int table, K identifier) throws ExecutionException, InterruptedException, IOException { IndexIOSession indexIOSession = this.indexIOSessionFactory.create(indexStorageManager, table, nodeFactory); - AbstractLeafTreeNode baseTreeNode = BPlusTreeUtils.getResponsibleNode(indexStorageManager, getRoot(indexIOSession), identifier, table, degree, nodeFactory, valueStrategy); + AbstractLeafTreeNode baseTreeNode = BPlusTreeUtils.getResponsibleNode(indexStorageManager, getRoot(indexIOSession), identifier, table, degree, nodeFactory, valueBinaryObjectWrapper); for (AbstractLeafTreeNode.KeyValue entry : baseTreeNode.getKeyValueList(degree)) { if (entry.key() == identifier) return Optional.of(entry.value()); @@ -63,7 +63,7 @@ public Optional getIndex(int table, K identifier) throws ExecutionException, public boolean removeIndex(int table, K identifier) throws ExecutionException, InterruptedException, IOException { IndexIOSession indexIOSession = this.indexIOSessionFactory.create(indexStorageManager, table, nodeFactory); AbstractTreeNode root = getRoot(indexIOSession); - return new BPlusTreeIndexDeleteOperation<>(degree, table, indexIOSession, valueStrategy, nodeFactory).removeIndex(root, identifier); + return new BPlusTreeIndexDeleteOperation<>(degree, table, indexIOSession, valueBinaryObjectWrapper, nodeFactory).removeIndex(root, identifier); } @Override @@ -74,7 +74,7 @@ public int size(int table) throws InterruptedException, ExecutionException, IOEx AbstractTreeNode root = nodeFactory.fromNodeData(optionalNodeData.get()); if (root.isLeaf()){ - return root.getKeyList(degree, valueStrategy.size()).size(); + return root.getKeyList(degree, valueBinaryObjectWrapper.size()).size(); } AbstractTreeNode curr = root; @@ -82,11 +82,11 @@ public int size(int table) throws InterruptedException, ExecutionException, IOEx curr = IndexTreeNodeIO.read(indexStorageManager, table, ((InternalTreeNode) curr).getChildrenList().getFirst(), nodeFactory); } - int size = curr.getKeyList(degree, valueStrategy.size()).size(); + int size = curr.getKeyList(degree, valueBinaryObjectWrapper.size()).size(); Optional optionalNext = ((LeafClusterTreeNode) curr).getNextSiblingPointer(degree); while (optionalNext.isPresent()){ AbstractTreeNode nextNode = IndexTreeNodeIO.read(indexStorageManager, table, optionalNext.get(), nodeFactory); - size += nextNode.getKeyList(degree, valueStrategy.size()).size(); + size += nextNode.getKeyList(degree, valueBinaryObjectWrapper.size()).size(); optionalNext = ((LeafClusterTreeNode) nextNode).getNextSiblingPointer(degree); } diff --git a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeUtils.java b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeUtils.java index 8be45b0..3835d46 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeUtils.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/BPlusTreeUtils.java @@ -50,13 +50,13 @@ public static > void getPathToResponsibleNode(IndexIOSes } } - public static , V extends Comparable> AbstractLeafTreeNode getResponsibleNode(IndexStorageManager indexStorageManager, AbstractTreeNode node, K identifier, int table, int degree, NodeFactory nodeFactory, BinaryObjectWrapper valueStrategy) throws ExecutionException, InterruptedException, IOException { + public static , V extends Comparable> AbstractLeafTreeNode getResponsibleNode(IndexStorageManager indexStorageManager, AbstractTreeNode node, K identifier, int table, int degree, NodeFactory nodeFactory, BinaryObjectWrapper valueBinaryObjectWrapper) throws ExecutionException, InterruptedException, IOException { if (node.isLeaf()){ return (AbstractLeafTreeNode) node; } List childrenList = ((InternalTreeNode) node).getChildrenList(); - List keys = node.getKeyList(degree, valueStrategy.size()); + List keys = node.getKeyList(degree, valueBinaryObjectWrapper.size()); int i; K keyAtIndex; boolean flag = false; @@ -76,7 +76,7 @@ public static , V extends Comparable> AbstractLeafTre table, degree, nodeFactory, - valueStrategy + valueBinaryObjectWrapper ); } else { return getResponsibleNode( @@ -86,7 +86,7 @@ public static , V extends Comparable> AbstractLeafTre table, degree, nodeFactory, - valueStrategy + valueBinaryObjectWrapper ); } diff --git a/src/main/java/com/github/sepgh/internal/index/tree/TreeNodeUtils.java b/src/main/java/com/github/sepgh/internal/index/tree/TreeNodeUtils.java index 349a242..d257a1c 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/TreeNodeUtils.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/TreeNodeUtils.java @@ -114,9 +114,9 @@ public static > void setKeyAtIndex(AbstractTreeNode t * @param index to read they key at * @return key value at index */ - public static > BinaryObjectWrapper getKeyAtIndex(AbstractTreeNode treeNode, int index, BinaryObjectWrapper kStrategy, int valueSize) { - int keyStartIndex = getKeyStartOffset(treeNode, index, kStrategy.size(), valueSize); - return kStrategy.load(treeNode.getData(), keyStartIndex); + public static > BinaryObjectWrapper getKeyAtIndex(AbstractTreeNode treeNode, int index, BinaryObjectWrapper kBinaryObjectWrapper, int valueSize) { + int keyStartIndex = getKeyStartOffset(treeNode, index, kBinaryObjectWrapper.size(), valueSize); + return kBinaryObjectWrapper.load(treeNode.getData(), keyStartIndex); } public static void removeKeyAtIndex(AbstractTreeNode treeNode, int index, int keySize, int valueSize) { @@ -132,13 +132,13 @@ public static void removeKeyAtIndex(AbstractTreeNode treeNode, int index, int public static , V extends Comparable> Map.Entry getKeyValueAtIndex( AbstractTreeNode treeNode, int index, - BinaryObjectWrapper kStrategy, - BinaryObjectWrapper vStrategy + BinaryObjectWrapper kBinaryObjectWrapper, + BinaryObjectWrapper vBinaryObjectWrapper ){ - int keyStartIndex = getKeyStartOffset(treeNode, index, kStrategy.size(), vStrategy.size()); + int keyStartIndex = getKeyStartOffset(treeNode, index, kBinaryObjectWrapper.size(), vBinaryObjectWrapper.size()); return new AbstractMap.SimpleImmutableEntry( - kStrategy.load(treeNode.getData(), keyStartIndex).asObject(), - vStrategy.load(treeNode.getData(), keyStartIndex + kStrategy.size()).asObject() + kBinaryObjectWrapper.load(treeNode.getData(), keyStartIndex).asObject(), + vBinaryObjectWrapper.load(treeNode.getData(), keyStartIndex + kBinaryObjectWrapper.size()).asObject() ); } @@ -174,7 +174,7 @@ public static , V extends Comparable> int addKeyValue BinaryObjectWrapper binaryObjectWrapper, K key, int keySize, - BinaryObjectWrapper valueStrategy, + BinaryObjectWrapper valueBinaryObjectWrapper, V value, int valueSize ) throws BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { @@ -210,7 +210,7 @@ public static , V extends Comparable> int addKeyValue treeNode, indexToFill, binaryObjectWrapper.load(key), - valueStrategy.load(value) + valueBinaryObjectWrapper.load(value) ); System.arraycopy( diff --git a/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractLeafTreeNode.java b/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractLeafTreeNode.java index 04069ad..ceb1cb2 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractLeafTreeNode.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractLeafTreeNode.java @@ -10,47 +10,47 @@ import java.util.*; public class AbstractLeafTreeNode, V extends Comparable> extends AbstractTreeNode { - protected final BinaryObjectWrapper valueStrategy; + protected final BinaryObjectWrapper valueBinaryObjectWrapper; - public AbstractLeafTreeNode(byte[] data, BinaryObjectWrapper keyStrategy, BinaryObjectWrapper valueStrategy) { - super(data, keyStrategy); - this.valueStrategy = valueStrategy; + public AbstractLeafTreeNode(byte[] data, BinaryObjectWrapper keyBinaryObjectWrapper, BinaryObjectWrapper valueBinaryObjectWrapper) { + super(data, keyBinaryObjectWrapper); + this.valueBinaryObjectWrapper = valueBinaryObjectWrapper; setType(Type.LEAF); } public Iterator getKeys(int degree) { - return super.getKeys(degree, valueStrategy.size()); + return super.getKeys(degree, valueBinaryObjectWrapper.size()); } public List getKeyList(int degree) { - return super.getKeyList(degree, valueStrategy.size()); + return super.getKeyList(degree, valueBinaryObjectWrapper.size()); } @SneakyThrows public void setKey(int index, K key) { - super.setKey(index, key, valueStrategy.size()); + super.setKey(index, key, valueBinaryObjectWrapper.size()); } public void removeKey(int idx, int degree) { - super.removeKey(idx, degree, valueStrategy.size()); + super.removeKey(idx, degree, valueBinaryObjectWrapper.size()); } public void setNextSiblingPointer(Pointer pointer, int degree){ modified(); - TreeNodeUtils.setNextPointer(this, degree, pointer, keyStrategy.size(), valueStrategy.size()); + TreeNodeUtils.setNextPointer(this, degree, pointer, keyBinaryObjectWrapper.size(), valueBinaryObjectWrapper.size()); } public void setPreviousSiblingPointer(Pointer pointer, int degree){ modified(); - TreeNodeUtils.setPreviousPointer(this, degree, pointer, keyStrategy.size(), valueStrategy.size()); + TreeNodeUtils.setPreviousPointer(this, degree, pointer, keyBinaryObjectWrapper.size(), valueBinaryObjectWrapper.size()); } public Optional getPreviousSiblingPointer(int degree){ - return TreeNodeUtils.getPreviousPointer(this, degree, keyStrategy.size(), valueStrategy.size()); + return TreeNodeUtils.getPreviousPointer(this, degree, keyBinaryObjectWrapper.size(), valueBinaryObjectWrapper.size()); } public Optional getNextSiblingPointer(int degree){ - return TreeNodeUtils.getNextPointer(this, degree, keyStrategy.size(), valueStrategy.size()); + return TreeNodeUtils.getNextPointer(this, degree, keyBinaryObjectWrapper.size(), valueBinaryObjectWrapper.size()); } public Iterator> getKeyValues(int degree){ @@ -68,12 +68,12 @@ public void setKeyValues(List> keyValueList, int degree) throws B this.setKeyValue(i, keyValue); } for (int i = keyValueList.size(); i < (degree - 1); i++){ - TreeNodeUtils.removeKeyValueAtIndex(this, i, keyStrategy.size(), valueStrategy.size()); + TreeNodeUtils.removeKeyValueAtIndex(this, i, keyBinaryObjectWrapper.size(), valueBinaryObjectWrapper.size()); } } public void setKeyValue(int index, KeyValue keyValue) throws BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { - TreeNodeUtils.setKeyValueAtIndex(this, index, keyStrategy.load(keyValue.key()), valueStrategy.load(keyValue.value())); + TreeNodeUtils.setKeyValueAtIndex(this, index, keyBinaryObjectWrapper.load(keyValue.key()), valueBinaryObjectWrapper.load(keyValue.value())); } public List> split(K identifier, V v, int degree) throws BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { @@ -90,7 +90,7 @@ public List> split(K identifier, V v, int degree) throws BinaryOb } public int addKeyValue(K identifier, V v, int degree) throws BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { - return TreeNodeUtils.addKeyValueAndGetIndex(this, degree, keyStrategy, identifier, keyStrategy.size(), valueStrategy, v, valueStrategy.size()); + return TreeNodeUtils.addKeyValueAndGetIndex(this, degree, keyBinaryObjectWrapper, identifier, keyBinaryObjectWrapper.size(), valueBinaryObjectWrapper, v, valueBinaryObjectWrapper.size()); } public int addKeyValue(KeyValue keyValue, int degree) throws BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { @@ -98,7 +98,7 @@ public int addKeyValue(KeyValue keyValue, int degree) throws BinaryObjectW } public void removeKeyValue(int index) { - TreeNodeUtils.removeKeyValueAtIndex(this, index, keyStrategy.size(), valueStrategy.size()); + TreeNodeUtils.removeKeyValueAtIndex(this, index, keyBinaryObjectWrapper.size(), valueBinaryObjectWrapper.size()); } public boolean removeKeyValue(K key, int degree) throws BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { @@ -132,7 +132,7 @@ public KeyValueIterator(AbstractLeafTreeNode node, int degree) { @SneakyThrows @Override public boolean hasNext() { - return TreeNodeUtils.hasKeyAtIndex(node, cursor, degree, keyStrategy, valueStrategy.size()); + return TreeNodeUtils.hasKeyAtIndex(node, cursor, degree, keyBinaryObjectWrapper, valueBinaryObjectWrapper.size()); } @SneakyThrows @@ -141,8 +141,8 @@ public KeyValue next() { Map.Entry kvAtIndex = TreeNodeUtils.getKeyValueAtIndex( node, cursor, - keyStrategy, - valueStrategy + keyBinaryObjectWrapper, + valueBinaryObjectWrapper ); cursor++; return new KeyValue<>(kvAtIndex.getKey(), kvAtIndex.getValue()); diff --git a/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractTreeNode.java b/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractTreeNode.java index dcd99ac..e990487 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractTreeNode.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/node/AbstractTreeNode.java @@ -29,11 +29,11 @@ public abstract class AbstractTreeNode> { private final byte[] data; @Getter private boolean modified = false; - protected final BinaryObjectWrapper keyStrategy; + protected final BinaryObjectWrapper keyBinaryObjectWrapper; - public AbstractTreeNode(byte[] data, BinaryObjectWrapper keyStrategy) { + public AbstractTreeNode(byte[] data, BinaryObjectWrapper keyBinaryObjectWrapper) { this.data = data; - this.keyStrategy = keyStrategy; + this.keyBinaryObjectWrapper = keyBinaryObjectWrapper; } public boolean isLeaf(){ // 0 0 & 0 0 @@ -85,13 +85,13 @@ public List getKeyList(int degree, int valueSize){ } public void setKey(int index, K key, int valueSize) throws BinaryObjectWrapper.InvalidBinaryObjectWrapperValue { - TreeNodeUtils.setKeyAtIndex(this, index, keyStrategy.load(key), valueSize); + TreeNodeUtils.setKeyAtIndex(this, index, keyBinaryObjectWrapper.load(key), valueSize); } @SneakyThrows public void removeKey(int idx, int degree, int valueSize) { List keyList = this.getKeyList(degree, valueSize); - TreeNodeUtils.removeKeyAtIndex(this, idx, keyStrategy.size(), valueSize); + TreeNodeUtils.removeKeyAtIndex(this, idx, keyBinaryObjectWrapper.size(), valueSize); List subList = keyList.subList(idx + 1, keyList.size()); int lastIndex = -1; for (int i = 0; i < subList.size(); i++) { @@ -99,13 +99,13 @@ public void removeKey(int idx, int degree, int valueSize) { TreeNodeUtils.setKeyAtIndex( this, lastIndex, - keyStrategy.load(subList.get(i)), + keyBinaryObjectWrapper.load(subList.get(i)), valueSize ); } if (lastIndex != -1){ for (int i = lastIndex + 1; i < degree - 1; i++){ - TreeNodeUtils.removeKeyAtIndex(this, i, keyStrategy.size(), valueSize); + TreeNodeUtils.removeKeyAtIndex(this, i, keyBinaryObjectWrapper.size(), valueSize); } } } @@ -139,14 +139,14 @@ public boolean hasNext() { if (!hasNext) return false; - hasNext = TreeNodeUtils.hasKeyAtIndex(this.node, cursor, degree, this.node.keyStrategy, valueSize); + hasNext = TreeNodeUtils.hasKeyAtIndex(this.node, cursor, degree, this.node.keyBinaryObjectWrapper, valueSize); return hasNext; } @SneakyThrows @Override public K next() { - BinaryObjectWrapper binaryObjectWrapper = TreeNodeUtils.getKeyAtIndex(this.node, cursor, this.node.keyStrategy, valueSize); + BinaryObjectWrapper binaryObjectWrapper = TreeNodeUtils.getKeyAtIndex(this.node, cursor, this.node.keyBinaryObjectWrapper, valueSize); cursor++; return binaryObjectWrapper.asObject(); } diff --git a/src/main/java/com/github/sepgh/internal/index/tree/node/InternalTreeNode.java b/src/main/java/com/github/sepgh/internal/index/tree/node/InternalTreeNode.java index 6429e48..1a2153a 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/node/InternalTreeNode.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/node/InternalTreeNode.java @@ -14,8 +14,8 @@ import java.util.List; public class InternalTreeNode> extends AbstractTreeNode { - public InternalTreeNode(byte[] data, BinaryObjectWrapper strategy) { - super(data, strategy); + public InternalTreeNode(byte[] data, BinaryObjectWrapper binaryObjectWrapper) { + super(data, binaryObjectWrapper); setType(Type.INTERNAL); } @@ -30,20 +30,20 @@ public List> getChildPointersList(int degree){ public void setChildPointers(List> childPointers, int degree, boolean cleanRest){ modified(); if (cleanRest) - TreeNodeUtils.cleanChildrenPointers(this, degree, keyStrategy.size(), PointerBinaryObjectWrapper.BYTES); + TreeNodeUtils.cleanChildrenPointers(this, degree, keyBinaryObjectWrapper.size(), PointerBinaryObjectWrapper.BYTES); int i = 0; for (ChildPointers keyPointer : childPointers) { keyPointer.setIndex(i); try { - TreeNodeUtils.setKeyAtIndex(this, keyPointer.index, keyStrategy.load(keyPointer.key), PointerBinaryObjectWrapper.BYTES); + TreeNodeUtils.setKeyAtIndex(this, keyPointer.index, keyBinaryObjectWrapper.load(keyPointer.key), PointerBinaryObjectWrapper.BYTES); } catch (BinaryObjectWrapper.InvalidBinaryObjectWrapperValue e) { throw new RuntimeException(e); } if (i == 0){ - TreeNodeUtils.setPointerToChild(this, 0, keyPointer.left, keyStrategy.size()); - TreeNodeUtils.setPointerToChild(this, 1, keyPointer.right, keyStrategy.size()); + TreeNodeUtils.setPointerToChild(this, 0, keyPointer.left, keyBinaryObjectWrapper.size()); + TreeNodeUtils.setPointerToChild(this, 1, keyPointer.right, keyBinaryObjectWrapper.size()); } else { - TreeNodeUtils.setPointerToChild(this, keyPointer.index + 1, keyPointer.right, keyStrategy.size()); + TreeNodeUtils.setPointerToChild(this, keyPointer.index + 1, keyPointer.right, keyBinaryObjectWrapper.size()); } i++; } @@ -74,7 +74,7 @@ public int addKey(K identifier, int degree) { keyList.add(idx, identifier); for (int j = idx; j < keyList.size() && j < degree - 1; j++){ - TreeNodeUtils.setKeyAtIndex(this, j, keyStrategy.load(keyList.get(j)), PointerBinaryObjectWrapper.BYTES); + TreeNodeUtils.setKeyAtIndex(this, j, keyBinaryObjectWrapper.load(keyList.get(j)), PointerBinaryObjectWrapper.BYTES); } return idx; @@ -84,14 +84,14 @@ public void addChildPointers(K identifier, @Nullable Pointer left, @Nullable Poi modified(); int i = this.addKey(identifier, degree); if (left != null){ - TreeNodeUtils.setPointerToChild(this, i, left, keyStrategy.size()); + TreeNodeUtils.setPointerToChild(this, i, left, keyBinaryObjectWrapper.size()); } else if (clearForNull) - TreeNodeUtils.removeChildAtIndex(this, i, keyStrategy.size()); + TreeNodeUtils.removeChildAtIndex(this, i, keyBinaryObjectWrapper.size()); if (right != null) - TreeNodeUtils.setPointerToChild(this, i+1, right, keyStrategy.size()); + TreeNodeUtils.setPointerToChild(this, i+1, right, keyBinaryObjectWrapper.size()); else if (clearForNull) - TreeNodeUtils.removeChildAtIndex(this, i + 1, keyStrategy.size()); + TreeNodeUtils.removeChildAtIndex(this, i + 1, keyBinaryObjectWrapper.size()); } public void addChildPointers(ChildPointers childPointers, int degree) { @@ -123,11 +123,11 @@ public void addChildAtIndex(int index, Pointer pointer){ } public void setChildAtIndex(int index, Pointer pointer){ - TreeNodeUtils.setPointerToChild(this, index, pointer, keyStrategy.size()); + TreeNodeUtils.setPointerToChild(this, index, pointer, keyBinaryObjectWrapper.size()); } public Pointer getChildAtIndex(int index) { - return TreeNodeUtils.getChildPointerAtIndex(this, index, keyStrategy.size()); + return TreeNodeUtils.getChildPointerAtIndex(this, index, keyBinaryObjectWrapper.size()); } public int getIndexOfChild(Pointer pointer){ @@ -185,16 +185,16 @@ public void setChildren(ArrayList childPointers) { public void removeChild(int idx, int degree) { List pointerList = this.getChildrenList(); - TreeNodeUtils.removeChildAtIndex(this, idx, keyStrategy.size()); + TreeNodeUtils.removeChildAtIndex(this, idx, keyBinaryObjectWrapper.size()); List subList = pointerList.subList(idx + 1, pointerList.size()); int lastIndex = -1; for (int i = 0; i < subList.size(); i++) { lastIndex = idx + i; - TreeNodeUtils.setPointerToChild(this, lastIndex, subList.get(i), keyStrategy.size()); + TreeNodeUtils.setPointerToChild(this, lastIndex, subList.get(i), keyBinaryObjectWrapper.size()); } if (lastIndex != -1){ for (int i = lastIndex + 1; i < degree; i++){ - TreeNodeUtils.removeChildAtIndex(this, i, keyStrategy.size()); + TreeNodeUtils.removeChildAtIndex(this, i, keyBinaryObjectWrapper.size()); } } } @@ -210,12 +210,12 @@ private ChildrenIterator(InternalTreeNode node) { @Override public boolean hasNext() { - return TreeNodeUtils.hasChildPointerAtIndex(this.node, cursor, node.keyStrategy.size()); + return TreeNodeUtils.hasChildPointerAtIndex(this.node, cursor, node.keyBinaryObjectWrapper.size()); } @Override public Pointer next() { - Pointer pointer = TreeNodeUtils.getChildPointerAtIndex(this.node, cursor, node.keyStrategy.size()); + Pointer pointer = TreeNodeUtils.getChildPointerAtIndex(this.node, cursor, node.keyBinaryObjectWrapper.size()); cursor++; return pointer; } @@ -238,27 +238,27 @@ private ChildPointersIterator(InternalTreeNode node, int degree) { @SneakyThrows @Override public boolean hasNext() { - return TreeNodeUtils.hasKeyAtIndex(node, cursor, degree, keyStrategy, PointerBinaryObjectWrapper.BYTES); + return TreeNodeUtils.hasKeyAtIndex(node, cursor, degree, keyBinaryObjectWrapper, PointerBinaryObjectWrapper.BYTES); } @SneakyThrows @Override public ChildPointers next() { - BinaryObjectWrapper binaryObjectWrapper = TreeNodeUtils.getKeyAtIndex(node, cursor, keyStrategy, PointerBinaryObjectWrapper.BYTES); + BinaryObjectWrapper binaryObjectWrapper = TreeNodeUtils.getKeyAtIndex(node, cursor, keyBinaryObjectWrapper, PointerBinaryObjectWrapper.BYTES); ChildPointers childPointers = null; if (cursor == 0){ childPointers = new ChildPointers<>( cursor, binaryObjectWrapper.asObject(), - TreeNodeUtils.getChildPointerAtIndex(node, 0, keyStrategy.size()), - TreeNodeUtils.getChildPointerAtIndex(node, 1, keyStrategy.size()) + TreeNodeUtils.getChildPointerAtIndex(node, 0, keyBinaryObjectWrapper.size()), + TreeNodeUtils.getChildPointerAtIndex(node, 1, keyBinaryObjectWrapper.size()) ); } else { childPointers = new ChildPointers<>( cursor, binaryObjectWrapper.asObject(), lastRightPointer, - TreeNodeUtils.getChildPointerAtIndex(node, cursor + 1, keyStrategy.size()) + TreeNodeUtils.getChildPointerAtIndex(node, cursor + 1, keyBinaryObjectWrapper.size()) ); } lastRightPointer = childPointers.getRight(); diff --git a/src/main/java/com/github/sepgh/internal/index/tree/node/NodeFactory.java b/src/main/java/com/github/sepgh/internal/index/tree/node/NodeFactory.java index 4bb3599..1dc6afe 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/node/NodeFactory.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/node/NodeFactory.java @@ -15,17 +15,17 @@ public interface NodeFactory> { class ClusterNodeFactory> implements NodeFactory { - private final BinaryObjectWrapper keyStrategy; + private final BinaryObjectWrapper keyBinaryObjectWrapper; - public ClusterNodeFactory(BinaryObjectWrapper keyStrategy) { - this.keyStrategy = keyStrategy; + public ClusterNodeFactory(BinaryObjectWrapper keyBinaryObjectWrapper) { + this.keyBinaryObjectWrapper = keyBinaryObjectWrapper; } @Override public AbstractTreeNode fromBytes(byte[] bytes) { if ((bytes[0] & TYPE_LEAF_NODE_BIT) == TYPE_LEAF_NODE_BIT) - return new LeafClusterTreeNode<>(bytes, keyStrategy); - return new InternalTreeNode<>(bytes, keyStrategy); + return new LeafClusterTreeNode<>(bytes, keyBinaryObjectWrapper); + return new InternalTreeNode<>(bytes, keyBinaryObjectWrapper); } @Override @@ -44,8 +44,8 @@ public AbstractTreeNode fromNodeData(IndexStorageManager.NodeData nodeData) { public AbstractTreeNode fromBytes(byte[] bytes, AbstractTreeNode.Type type) { bytes[0] = type.getSign(); if (type.equals(AbstractTreeNode.Type.LEAF)) - return new LeafClusterTreeNode<>(bytes, keyStrategy); - return new InternalTreeNode<>(bytes, keyStrategy); + return new LeafClusterTreeNode<>(bytes, keyBinaryObjectWrapper); + return new InternalTreeNode<>(bytes, keyBinaryObjectWrapper); } } diff --git a/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/ClusterBPlusTreeIndexManager.java b/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/ClusterBPlusTreeIndexManager.java index 41e90f1..3e3090a 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/ClusterBPlusTreeIndexManager.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/ClusterBPlusTreeIndexManager.java @@ -10,13 +10,13 @@ import com.github.sepgh.internal.storage.session.IndexIOSessionFactory; public class ClusterBPlusTreeIndexManager, V extends Comparable> extends BPlusTreeIndexManager { - public ClusterBPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, IndexIOSessionFactory indexIOSessionFactory, BinaryObjectWrapper keyStrategy){ - super(degree, indexStorageManager, indexIOSessionFactory, keyStrategy, new PointerBinaryObjectWrapper(), new NodeFactory.ClusterNodeFactory<>(keyStrategy)); + public ClusterBPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, IndexIOSessionFactory indexIOSessionFactory, BinaryObjectWrapper keyBinaryObjectWrapper){ + super(degree, indexStorageManager, indexIOSessionFactory, keyBinaryObjectWrapper, new PointerBinaryObjectWrapper(), new NodeFactory.ClusterNodeFactory<>(keyBinaryObjectWrapper)); } - public ClusterBPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, BinaryObjectWrapper keyStrategy){ - this(degree, indexStorageManager, ImmediateCommitIndexIOSession.Factory.getInstance(), keyStrategy); + public ClusterBPlusTreeIndexManager(int degree, IndexStorageManager indexStorageManager, BinaryObjectWrapper keyBinaryObjectWrapper){ + this(degree, indexStorageManager, ImmediateCommitIndexIOSession.Factory.getInstance(), keyBinaryObjectWrapper); } } diff --git a/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/LeafClusterTreeNode.java b/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/LeafClusterTreeNode.java index 2e2d5dc..378b1ab 100644 --- a/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/LeafClusterTreeNode.java +++ b/src/main/java/com/github/sepgh/internal/index/tree/node/cluster/LeafClusterTreeNode.java @@ -6,7 +6,7 @@ import com.github.sepgh.internal.index.tree.node.data.PointerBinaryObjectWrapper; public class LeafClusterTreeNode> extends AbstractLeafTreeNode { - public LeafClusterTreeNode(byte[] data, BinaryObjectWrapper keyStrategy) { - super(data, keyStrategy, new PointerBinaryObjectWrapper()); + public LeafClusterTreeNode(byte[] data, BinaryObjectWrapper keyBinaryObjectWrapper) { + super(data, keyBinaryObjectWrapper, new PointerBinaryObjectWrapper()); } } \ No newline at end of file diff --git a/src/test/java/com/github/sepgh/internal/helper/IndexFileDescriptor.java b/src/test/java/com/github/sepgh/internal/helper/IndexFileDescriptor.java index c08257a..7a464b2 100644 --- a/src/test/java/com/github/sepgh/internal/helper/IndexFileDescriptor.java +++ b/src/test/java/com/github/sepgh/internal/helper/IndexFileDescriptor.java @@ -24,7 +24,7 @@ public class IndexFileDescriptor { private final HeaderManager headerManager; private final EngineConfig engineConfig; - public > void describe(BinaryObjectWrapper strategy) throws IOException, ExecutionException, InterruptedException { + public > void describe(BinaryObjectWrapper binaryObjectWrapper) throws IOException, ExecutionException, InterruptedException { long paddingCounts = asynchronousFileChannel.size() / engineConfig.getPaddedSize(); for (int i = 0; i < paddingCounts; i++){ @@ -36,7 +36,7 @@ public > void describe(BinaryObjectWrapper strategy) continue; } - AbstractTreeNode baseClusterTreeNode = new NodeFactory.ClusterNodeFactory<>(strategy).fromBytes(bytes); + AbstractTreeNode baseClusterTreeNode = new NodeFactory.ClusterNodeFactory<>(binaryObjectWrapper).fromBytes(bytes); if (baseClusterTreeNode.getType() == AbstractTreeNode.Type.LEAF) this.printLeafNode((LeafClusterTreeNode) baseClusterTreeNode, offset); else if (baseClusterTreeNode.getType() == AbstractTreeNode.Type.INTERNAL) diff --git a/src/test/java/com/github/sepgh/internal/index/tree/NodeDataOldTestCase.java b/src/test/java/com/github/sepgh/internal/index/tree/BinaryObjectWrapperTestCase.java similarity index 98% rename from src/test/java/com/github/sepgh/internal/index/tree/NodeDataOldTestCase.java rename to src/test/java/com/github/sepgh/internal/index/tree/BinaryObjectWrapperTestCase.java index 65f381e..5a16377 100644 --- a/src/test/java/com/github/sepgh/internal/index/tree/NodeDataOldTestCase.java +++ b/src/test/java/com/github/sepgh/internal/index/tree/BinaryObjectWrapperTestCase.java @@ -26,7 +26,7 @@ import static com.github.sepgh.internal.storage.BaseFileIndexStorageManager.INDEX_FILE_NAME; -public class NodeDataOldTestCase { +public class BinaryObjectWrapperTestCase { private Path dbPath; private EngineConfig engineConfig; private Header header; @@ -34,7 +34,7 @@ public class NodeDataOldTestCase { @BeforeEach public void setUp() throws IOException { - dbPath = Files.createTempDirectory("TEST_NodeInnerObjTestCase"); + dbPath = Files.createTempDirectory("TEST_BinaryObjectWrapperTestCase"); engineConfig = EngineConfig.builder() .bTreeDegree(degree) .bTreeGrowthNodeAllocationCount(2)