Github user bwmcbride commented on a diff in the pull request:
https://github.com/apache/jena/pull/123#discussion_r50546853
--- Diff:
jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java ---
@@ -191,5 +213,50 @@ public static DatasetGraph
createSolrIndex(DatasetGraph base, SolrServer server,
TextIndex index = createSolrIndex(server, entMap) ;
return create(base, index, true) ;
}
+
+ protected static class LuceneIndexMap {
+
+ private static HashMap<Object, WeakReference<TextIndex>> map =
new HashMap<Object, WeakReference<TextIndex>>();
+
+ protected synchronized TextIndex get(Directory directory) {
+ Object key = key(directory);
+ WeakReference<TextIndex> ref = map.get(key);
+ if (ref == null)
+ return null;
+ TextIndex result = ref.get();
+ if (result == null)
+ map.put(key, null);
+ return result;
+ }
+
+ protected synchronized void put(Directory directory, TextIndex
index) {
+ map.put(key(directory), new
WeakReference<TextIndex>(index));
+ }
+
+ protected synchronized void remove(Directory directory) {
+ map.put(key(directory), null);
+ }
+
+ private Object key(Directory directory) {
+ // uglyness alert
+ if (directory instanceof FSDirectory) {
+ return getFilePath( ( (FSDirectory)
directory).getDirectory() );
+ } else if (directory instanceof CompoundFileDirectory) {
+ return getFilePath( ( (FSDirectory)
directory).getDirectory() );
--- End diff --
Yes - thank you. Will fix.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---