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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user