-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: buildable beautified branch!
- Loading branch information
Showing
16 changed files
with
927 additions
and
1,587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import sys | ||
|
||
|
||
def parse_leaf(binary: str, degree: int): | ||
print() | ||
print("'%-10s'" % "0-2", "", binary[0:2]) | ||
print() | ||
|
||
offset = 2 | ||
for i in range(0, degree - 1): | ||
print( | ||
"'%-10s'" % f"{offset}-{offset+42}", | ||
"", | ||
binary[offset: offset + 16], | ||
binary[offset + 16: offset + 18], | ||
binary[offset + 18: offset + 34], | ||
binary[offset + 34: offset + 42] | ||
) | ||
offset += 42 | ||
print() | ||
for _ in range(0, 2): | ||
print( | ||
"'%-10s'" % f"{offset}-{offset+26}", | ||
"", | ||
binary[offset: offset + 2], | ||
binary[offset + 2: offset + 18], | ||
binary[offset + 18: offset + 26], | ||
) | ||
offset += 26 | ||
|
||
print() | ||
a = binary[offset:] | ||
print("'%-10s'" % f"{offset}-...", "", ' '.join([a[i:i+4] for i in range(0, len(a), 4)])) | ||
|
||
|
||
if __name__ == "__main__": | ||
parse_leaf(sys.argv[2], int(sys.argv[1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
395 changes: 121 additions & 274 deletions
395
src/main/java/com/github/sepgh/internal/tree/BTreeIndexManager.java
Large diffs are not rendered by default.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
src/main/java/com/github/sepgh/internal/tree/TreeNodeIO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.github.sepgh.internal.tree; | ||
|
||
import com.github.sepgh.internal.storage.IndexStorageManager; | ||
import com.github.sepgh.internal.tree.node.BaseTreeNode; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
public class TreeNodeIO { | ||
public static CompletableFuture<IndexStorageManager.NodeData> write(BaseTreeNode node, IndexStorageManager indexStorageManager, int table) throws IOException, ExecutionException, InterruptedException { | ||
IndexStorageManager.NodeData nodeData = new IndexStorageManager.NodeData(node.getPointer(), node.getData()); | ||
if (!node.isModified() && node.getPointer() != null){ | ||
return CompletableFuture.completedFuture(nodeData); | ||
} | ||
CompletableFuture<IndexStorageManager.NodeData> output = new CompletableFuture<>(); | ||
|
||
if (node.getPointer() == null){ | ||
indexStorageManager.writeNewNode(table, node.getData(), node.isRoot()).whenComplete((nodeData1, throwable) -> { | ||
if (throwable != null){ | ||
output.completeExceptionally(throwable); | ||
return; | ||
} | ||
node.setPointer(nodeData1.pointer()); | ||
output.complete(nodeData1); | ||
}); | ||
} else { | ||
indexStorageManager.updateNode(table, node.getData(), node.getPointer()).whenComplete((integer, throwable) -> { | ||
if (throwable != null){ | ||
output.completeExceptionally(throwable); | ||
return; | ||
} | ||
output.complete(nodeData); | ||
}); | ||
} | ||
return output; | ||
} | ||
|
||
public static BaseTreeNode read(IndexStorageManager indexStorageManager, int table, Pointer pointer) throws ExecutionException, InterruptedException { | ||
return BaseTreeNode.fromNodeData(indexStorageManager.readNode(table, pointer).get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.