Пример #1
0
 protected void change(long nodeId, Object value)
     throws IOException, IndexCapacityExceededException {
   Fieldable encodedValue = documentStructure.encodeAsFieldable(value);
   writer.updateDocument(
       documentStructure.newQueryForChangeOrRemove(nodeId),
       documentStructure.newDocumentRepresentingProperty(nodeId, encodedValue));
 }
Пример #2
0
 LuceneIndexAccessor(
     LuceneDocumentStructure documentStructure,
     IndexWriterFactory<ReservingLuceneIndexWriter> indexWriterFactory,
     IndexWriterStatus writerStatus,
     DirectoryFactory dirFactory,
     File dirFile,
     int bufferSizeLimit)
     throws IOException {
   this.documentStructure = documentStructure;
   this.dirFile = dirFile;
   this.bufferSizeLimit = bufferSizeLimit;
   this.dir = dirFactory.open(dirFile);
   this.writer = indexWriterFactory.create(dir);
   this.writerStatus = writerStatus;
   this.searcherManager = writer.createSearcherManager();
 }
Пример #3
0
 private void addRecovered(long nodeId, Object value)
     throws IOException, IndexCapacityExceededException {
   IndexSearcher searcher = searcherManager.acquire();
   try {
     TopDocs hits =
         searcher.search(new TermQuery(documentStructure.newQueryForChangeOrRemove(nodeId)), 1);
     if (hits.totalHits > 0) {
       Fieldable encodedValue = documentStructure.encodeAsFieldable(value);
       writer.updateDocument(
           documentStructure.newQueryForChangeOrRemove(nodeId),
           documentStructure.newDocumentRepresentingProperty(nodeId, encodedValue));
     } else {
       add(nodeId, value);
     }
   } finally {
     searcherManager.release(searcher);
   }
 }
Пример #4
0
 protected void remove(long nodeId) throws IOException {
   writer.deleteDocuments(documentStructure.newQueryForChangeOrRemove(nodeId));
 }
Пример #5
0
 protected void add(long nodeId, Object value) throws IOException, IndexCapacityExceededException {
   Fieldable encodedValue = documentStructure.encodeAsFieldable(value);
   writer.addDocument(documentStructure.newDocumentRepresentingProperty(nodeId, encodedValue));
 }