Skip to content

Commit

Permalink
implement comparable for indexconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
firestar committed Dec 7, 2023
1 parent 1187b60 commit 69cb39f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 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.4'
version = '1.13.5'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.nucleodb.library.database.index.trie.Entry;
import com.nucleodb.library.database.tables.table.DataEntry;
import com.nucleodb.library.database.utils.exceptions.InvalidIndexTypeException;
import org.jetbrains.annotations.NotNull;

import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
Expand All @@ -18,7 +19,7 @@
import java.util.Queue;
import java.util.Set;

public abstract class IndexWrapper<T> implements Serializable{
public abstract class IndexWrapper<T> implements Serializable, Comparable{
private static final long serialVersionUID = 1;
String indexedKeyStr;
public IndexWrapper(String indexedKey) {
Expand Down Expand Up @@ -140,4 +141,12 @@ public Set<T> greaterThan(Object searchObj) {
public Set<T> greaterThanEqual(Object searchObj) {
return (Set<T>) Sets.newTreeSet();
}

@Override
public int compareTo(@NotNull Object o) {
if(o instanceof IndexWrapper) {
return indexedKeyStr.compareTo(((IndexWrapper<?>) o).getIndexedKey());
}
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,5 @@ public List<Entry> startsWithInternal(String findString) {
return tmp.getPartialEntries().stream().collect(Collectors.toList());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nucleodb.library.database.index.IndexWrapper;
import com.nucleodb.library.database.utils.StartupRun;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.time.Instant;
Expand All @@ -14,7 +15,7 @@
public class DataTableConfig implements Serializable{
private static final long serialVersionUID = 4416983891804575837L;

public static class IndexConfig {
public static class IndexConfig implements Comparable {
String name;
Class<? extends IndexWrapper> indexType;

Expand All @@ -38,6 +39,14 @@ public Class<? extends IndexWrapper> getIndexType() {
public void setIndexType(Class<? extends IndexWrapper> indexType) {
this.indexType = indexType;
}

@Override
public int compareTo(@NotNull Object o) {
if(o instanceof IndexConfig){
return this.getName().compareTo(((IndexConfig) o).getName());
}
return 0;
}
}
String bootstrap = "127.0.0.1:19092";
String table;
Expand Down

0 comments on commit 69cb39f

Please sign in to comment.