Skip to content

Commit b93985c

Browse files
committed
proof of concept to avoid EMF pooling
1 parent a97e8d5 commit b93985c

File tree

2 files changed

+392
-0
lines changed

2 files changed

+392
-0
lines changed

com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/persistence/DirectLinkingResourceStorageLoadable.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Collections;
2121
import java.util.Deque;
2222
import java.util.Map;
23+
import java.util.concurrent.ConcurrentHashMap;
2324
import java.util.zip.ZipInputStream;
2425

2526
import org.apache.logging.log4j.LogManager;
@@ -62,6 +63,8 @@ public class DirectLinkingResourceStorageLoadable extends ResourceStorageLoadabl
6263

6364
private static final Logger LOG = LogManager.getLogger(DirectLinkingResourceStorageLoadable.class);
6465

66+
private static final Map<String, URI> resourceUriMap = new ConcurrentHashMap<>(100_000);
67+
private static final Map<String, URI> fragmentUriMap = new ConcurrentHashMap<>(500_000);
6568
private static final int SOURCE_BUFFER_CAPACITY = 0x10000; // 64 KiB
6669

6770
private final boolean loadNodeModel;
@@ -314,6 +317,29 @@ public InternalEObject loadEObject() throws IOException {
314317
return result;
315318
}
316319

320+
@Override
321+
public URI readURI() throws IOException {
322+
int id = readCompressedInt();
323+
if (id == -1) {
324+
return null;
325+
} else {
326+
URI uri;
327+
if (uriList.size() <= id) {
328+
String value = readSegmentedString();
329+
uri = resolve(resourceUriMap.computeIfAbsent(value, key -> new DirectLinkingURI(key)));
330+
uriList.add(uri);
331+
} else {
332+
uri = uriList.get(id);
333+
}
334+
String fragment = readSegmentedString();
335+
if (fragment != null) {
336+
uri = fragmentUriMap.computeIfAbsent(uri.toString() + '#' + fragment, key -> new DirectLinkingURI(key));
337+
// uri = uri.appendFragment(fragment);
338+
}
339+
return uri;
340+
}
341+
}
342+
317343
@Override
318344
protected void loadFeatureValue(final InternalEObject internalEObject, final EStructuralFeatureData eStructuralFeatureData) throws IOException {
319345
try {

0 commit comments

Comments
 (0)