Skip to content

Commit

Permalink
Reuse document instances
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwalker authored and MishaDemianenko committed Dec 5, 2015
1 parent 74681cb commit 0c4a9f3
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 166 deletions.
Expand Up @@ -21,7 +21,6 @@

import org.apache.lucene.document.Document;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
Expand Down Expand Up @@ -113,8 +112,7 @@ public void add( long nodeId, Object propertyValue )
throws IndexEntryConflictException, IOException, IndexCapacityExceededException
{
sampler.increment( 1 );
IndexableField encodedValue = documentStructure.encodeAsFieldable( propertyValue );
Document doc = documentStructure.newDocumentRepresentingProperty( nodeId, encodedValue );
Document doc = documentStructure.documentRepresentingProperty( nodeId, propertyValue );
writer.addDocument( doc );
}

Expand Down Expand Up @@ -194,9 +192,8 @@ public void process( NodePropertyUpdate update )
sampler.increment( 1 ); // add new value

// We don't look at the "before" value, so adding and changing idempotently is done the same way.
IndexableField encodedValue = documentStructure.encodeAsFieldable( update.getValueAfter() );
writer.updateDocument( documentStructure.newTermForChangeOrRemove( nodeId ),
documentStructure.newDocumentRepresentingProperty( nodeId, encodedValue ) );
documentStructure.documentRepresentingProperty( nodeId, update.getValueAfter() ) );
updatedPropertyValues.add( update.getValueAfter() );
break;
case CHANGED:
Expand All @@ -205,9 +202,8 @@ public void process( NodePropertyUpdate update )
// sampler.increment( 1 ); // add new value

// We don't look at the "before" value, so adding and changing idempotently is done the same way.
IndexableField encodedValueAfter = documentStructure.encodeAsFieldable( update.getValueAfter() );
writer.updateDocument( documentStructure.newTermForChangeOrRemove( nodeId ),
documentStructure.newDocumentRepresentingProperty( nodeId, encodedValueAfter ) );
documentStructure.documentRepresentingProperty( nodeId, update.getValueAfter() ) );
updatedPropertyValues.add( update.getValueAfter() );
break;
case REMOVED:
Expand Down

0 comments on commit 0c4a9f3

Please sign in to comment.