mirror of
https://github.com/ChronosX88/Influence-Bootstrap-Node.git
synced 2024-11-26 00:42:20 +00:00
Added key sorting in StorageBerkeleyDB
This commit is contained in:
parent
eb1f703d4f
commit
8aacb71152
@ -0,0 +1,14 @@
|
|||||||
|
package io.github.chronosx88.dhtBootstrap;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class CompareLong implements Comparator<byte[]>, Serializable {
|
||||||
|
@Override
|
||||||
|
public int compare(byte[] o1, byte[] o2) {
|
||||||
|
Serializer<Long> serializer = new Serializer<>();
|
||||||
|
Long num1 = serializer.deserialize(o1);
|
||||||
|
Long num2 = serializer.deserialize(o2);
|
||||||
|
return num1.compareTo(num2);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package io.github.chronosx88.dhtBootstrap;
|
||||||
|
|
||||||
|
import net.tomp2p.peers.Number640;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class CompareNumber640 implements Comparator<byte[]>, Serializable {
|
||||||
|
@Override
|
||||||
|
public int compare(byte[] o1, byte[] o2) {
|
||||||
|
Serializer<Number640> serializer = new Serializer<>();
|
||||||
|
Number640 num1 = serializer.deserialize(o1);
|
||||||
|
Number640 num2 = serializer.deserialize(o2);
|
||||||
|
return num1.compareTo(num2);
|
||||||
|
}
|
||||||
|
}
|
@ -47,16 +47,24 @@ class StorageBerkeleyDB(peerId: Number160, path : File, signatureFactory: Signat
|
|||||||
val envConfig = EnvironmentConfig()
|
val envConfig = EnvironmentConfig()
|
||||||
envConfig.allowCreate = true
|
envConfig.allowCreate = true
|
||||||
dbEnvironment = Environment(path, envConfig)
|
dbEnvironment = Environment(path, envConfig)
|
||||||
val dbConfig = DatabaseConfig()
|
val configMap : HashMap<String, com.sleepycat.je.DatabaseConfig> = HashMap()
|
||||||
dbConfig.allowCreate = true
|
|
||||||
|
|
||||||
dataMapDB = dbEnvironment.openDatabase(null, "dataMap_$peerId", dbConfig)
|
val compareNumber640 = CompareNumber640()
|
||||||
timeoutMapDB = dbEnvironment.openDatabase(null, "timeoutMap_$peerId", dbConfig)
|
val compareLong = CompareLong()
|
||||||
timeoutMapRevDB = dbEnvironment.openDatabase(null, "timeoutMapRev_$peerId", dbConfig)
|
configMap["dataMapConfig"] = DatabaseConfig().setBtreeComparator(compareNumber640)
|
||||||
protectedDomainMapDB = dbEnvironment.openDatabase(null, "protectedDomainMap_$peerId", dbConfig)
|
configMap["dataMapConfig"]!!.allowCreate = true
|
||||||
protectedEntryMapDB = dbEnvironment.openDatabase(null, "protectedEntryMap_$peerId", dbConfig)
|
configMap["timeoutMapRevConfig"] = DatabaseConfig().setBtreeComparator(compareLong)
|
||||||
responsibilityMapDB = dbEnvironment.openDatabase(null, "responsibilityMap_$peerId", dbConfig)
|
configMap["timeoutMapRevConfig"]!!.allowCreate = true
|
||||||
responsibilityMapRevDB = dbEnvironment.openDatabase(null, "responsibilityMapRev_$peerId", dbConfig)
|
configMap["other"] = DatabaseConfig()
|
||||||
|
configMap["other"]!!.allowCreate = true
|
||||||
|
|
||||||
|
dataMapDB = dbEnvironment.openDatabase(null, "dataMap_$peerId", configMap["dataMapConfig"])
|
||||||
|
timeoutMapDB = dbEnvironment.openDatabase(null, "timeoutMap_$peerId", configMap["other"])
|
||||||
|
timeoutMapRevDB = dbEnvironment.openDatabase(null, "timeoutMapRev_$peerId", configMap["timeoutMapRevConfig"])
|
||||||
|
protectedDomainMapDB = dbEnvironment.openDatabase(null, "protectedDomainMap_$peerId", configMap["other"])
|
||||||
|
protectedEntryMapDB = dbEnvironment.openDatabase(null, "protectedEntryMap_$peerId", configMap["other"])
|
||||||
|
responsibilityMapDB = dbEnvironment.openDatabase(null, "responsibilityMap_$peerId", configMap["other"])
|
||||||
|
responsibilityMapRevDB = dbEnvironment.openDatabase(null, "responsibilityMapRev_$peerId", configMap["other"])
|
||||||
|
|
||||||
storageCheckIntervalMillis = 60 * 1000
|
storageCheckIntervalMillis = 60 * 1000
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user