Skip to content

Commit

Permalink
only insert 1 entry for each dataentry
Browse files Browse the repository at this point in the history
  • Loading branch information
firestar committed Dec 7, 2023
1 parent 69cb39f commit ef4dfab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.nucleodb'
version = '1.13.5'
version = '1.13.6'

repositories {
mavenCentral()
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/nucleodb/library/database/index/TrieIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ Node getNodeFromIntBuffer(TreeMap<Integer, Node> treeMap, int character) {

@Override
public void add(T obj) throws JsonProcessingException {
String key = getKey(obj);
Entry entry = entries.get(key);
if(entry==null){
entry = new Entry(obj);
}
for (Object o : getIndexValue(obj)) {
if(o instanceof String){
insert(obj, (String) o);
insert(entry, (String) o);
}
}
}
Expand Down Expand Up @@ -126,15 +131,14 @@ public void delete(Entry entry){
}

public void insert(T obj, String val) {
Entry entry = new Entry(obj, new Stack<>());
Entry entry = new Entry(obj);
insert(entry, val);
}

public void insert(Entry entry, String val) {
String key = getKey((T)entry.getData());
PrimitiveIterator.OfInt iterator = val.chars().iterator();
Node tmp = this.root;
Stack<Node> nodePath = entry.getLastNodes();
while (iterator.hasNext()) {
int character = iterator.next();
Node nodeTraversal = getNodeFromIntBuffer(tmp.getNodes(), character);
Expand All @@ -148,7 +152,7 @@ public void insert(Entry entry, String val) {
tmp = nodeTraversal;
tmp.getPartialEntries().add(entry);
}
nodePath.add(tmp); // add leaf
entry.getLastNodes().add(tmp); // add leaf
entries.put(key, entry);
tmp.getEntries().add(entry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
public class Entry<T>{
T data;

Stack<Node> lastNodes;
Stack<Node> lastNodes = new Stack<>();

public Entry(T data, Stack<Node> nodes) {
public Entry(T data) {
this.data = data;
this.lastNodes = nodes;
}

public T getData() {
Expand Down

0 comments on commit ef4dfab

Please sign in to comment.