use PersistentMap in DataStore

Replaces the use of in-memory data structures with the PersistentMap.
This is the crucial step in reducing memory usage for both persistent
storage and main memory.
This commit is contained in:
2018-11-17 09:45:35 +01:00
parent 3ccf526608
commit fce0f6a04d
12 changed files with 379 additions and 459 deletions

View File

@@ -39,6 +39,10 @@ public class Tags {
filenameBytes = EMPTY_BYTES;
}
public Tags(final byte[] filenameBytes) {
this(new String(filenameBytes, StandardCharsets.UTF_8));
}
public Tags(final String serializedTags) {
// serialized tags look like this: 0-1_2-1M_H-28_4-5$1.pdb
// there can be several files for the same set of tags, in which case the number
@@ -85,6 +89,10 @@ public class Tags {
return new String(this.filenameBytes, StandardCharsets.UTF_8);
}
public byte[] getFilenameBytes() {
return filenameBytes;
}
public String getValue(final String key) {
final Set<Tag> tags = toTags();
@@ -96,7 +104,7 @@ public class Tags {
return null;
}
private SortedSet<Tag> toTags() {
public SortedSet<Tag> toTags() {
final SortedSet<Tag> result = new TreeSet<>(TagByKeyComparator.INSTANCE);
final String filename = new String(this.filenameBytes, StandardCharsets.UTF_8);
final Matcher matcher = EXTRACT_TAGS_PATTERN.matcher(filename);