Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/123#discussion_r50540841
  
    --- Diff: 
jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexLuceneAssembler.java
 ---
    @@ -123,10 +141,35 @@ public TextIndex open(Assembler a, Resource root, 
Mode mode) {
                 config.setMultilingualSupport(isMultilingualSupport);
                 config.setValueStored(storeValues);
     
    -            return TextDatasetFactory.createLuceneIndex(directory, config) 
;
    +            TextIndexLucene index = 
TextDatasetFactory.createLuceneIndex(directory, config) ;
    +            index.addEventHandler(TextIndexLucene.Event.CLOSED, 
    +                           ( i ) -> ramDirectories.remove(root));
    +            return index;
             } catch (IOException e) {
                 IO.exception(e) ;
                 return null ;
             }
         }
    +protected static class RAMDirectoryMap {
    +           
    +           private static WeakHashMap<RDFNode, 
WeakReference<RAMDirectory>> map = new WeakHashMap<RDFNode, 
WeakReference<RAMDirectory>>();
    +
    +           protected synchronized RAMDirectory get(RDFNode node) {
    +                   WeakReference<RAMDirectory> ref = map.get(node);
    +                   if (ref == null)
    +                           return null;
    +                   RAMDirectory result = ref.get();
    +                   if (result == null)
    +                           map.put(node, null);
    +                   return result;
    +           }
    +           
    +           protected synchronized void put(RDFNode node, RAMDirectory 
directory) {
    +                   map.put(node, new 
WeakReference<RAMDirectory>(directory));
    --- End diff --
    
    Could be little shorter with `new WeakReference<>(directory)`.


---
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.
---

Reply via email to