Skip to content

Commit

Permalink
Introduce org.neo4j.index.lucene.legacy package for legacy indexes.
Browse files Browse the repository at this point in the history
Move org.neo4j.index.impl.lucene into org.neo4j.index.lucene.legacy.
  • Loading branch information
MishaDemianenko committed Dec 5, 2015
1 parent 2d5a4ff commit b48af5b
Show file tree
Hide file tree
Showing 69 changed files with 190 additions and 195 deletions.
Expand Up @@ -22,7 +22,7 @@ package org.neo4j.cypher.performance
import java.io.File
import org.neo4j.cypher.internal.frontend.v3_0.test_helpers.CypherFunSuite
import org.neo4j.graphdb.RelationshipType
import org.neo4j.index.impl.lucene.LuceneBatchInserterIndexProviderNewImpl
import org.neo4j.index.lucene.legacy.LuceneBatchInserterIndexProviderNewImpl
import org.neo4j.unsafe.batchinsert.{BatchInserter, BatchInserterIndex, BatchInserters}

import scala.collection.JavaConverters._
Expand Down
Expand Up @@ -23,7 +23,7 @@
import java.util.function.Supplier;

import org.neo4j.graphdb.index.IndexProviders;
import org.neo4j.index.impl.lucene.LuceneIndexImplementation;
import org.neo4j.index.lucene.legacy.LuceneIndexImplementation;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.index.IndexConfigStore;
Expand Down
Expand Up @@ -20,7 +20,7 @@
package org.neo4j.index.lucene;

import org.neo4j.graphdb.index.IndexProviders;
import org.neo4j.index.impl.lucene.LuceneIndexImplementation;
import org.neo4j.index.lucene.legacy.LuceneIndexImplementation;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.extension.KernelExtensionFactory;
import org.neo4j.kernel.impl.index.IndexConfigStore;
Expand Down
Expand Up @@ -29,7 +29,7 @@

import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexHits;
import org.neo4j.index.impl.lucene.LuceneUtil;
import org.neo4j.index.lucene.legacy.LuceneUtil;

/**
* This class has the extra query configuration to use
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.util.Iterator;

Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.neo4j.collection.primitive.PrimitiveLongCollections.PrimitiveLongBaseIterator;
import org.neo4j.kernel.api.LegacyIndexHits;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.util.Collection;

Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.util.Collection;
import java.util.Iterator;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.document.Document;

Expand Down
Expand Up @@ -17,10 +17,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.StringField;

Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field.Store;
Expand Down Expand Up @@ -55,7 +55,7 @@
import org.neo4j.kernel.api.impl.index.DocValuesCollector;

import static java.util.Collections.emptyList;
import static org.neo4j.index.impl.lucene.LuceneIndex.KEY_DOC_ID;
import static org.neo4j.index.lucene.legacy.LuceneIndex.KEY_DOC_ID;

class FullTxData extends TxData
{
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.io.IOException;

Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.neo4j.kernel.impl.index.IndexEntityType;

Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
Expand Down Expand Up @@ -56,8 +56,6 @@
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;

import static org.neo4j.index.impl.lucene.LuceneIndexImplementation.KEY_TO_LOWER_CASE;

public abstract class IndexType
{
public static final IndexType EXACT = new IndexType( LuceneDataSource.KEYWORD_ANALYZER, false )
Expand Down Expand Up @@ -195,8 +193,8 @@ static IndexType getIndexType( Map<String, String> config )
String type = config.get( LuceneIndexImplementation.KEY_TYPE );
IndexType result = null;
Similarity similarity = getCustomSimilarity( config );
Boolean toLowerCaseUnbiased = config.get( KEY_TO_LOWER_CASE ) != null ?
parseBoolean( config.get( KEY_TO_LOWER_CASE ), true ) : null;
Boolean toLowerCaseUnbiased = config.get( LuceneIndexImplementation.KEY_TO_LOWER_CASE ) != null ?
parseBoolean( config.get( LuceneIndexImplementation.KEY_TO_LOWER_CASE ), true ) : null;
Analyzer customAnalyzer = getCustomAnalyzer( config );
if ( type != null )
{
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.util.Collections;
import java.util.HashMap;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordTokenizer;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.CorruptIndexException;
Expand All @@ -43,7 +43,6 @@
import org.neo4j.collection.primitive.PrimitiveLongCollections;
import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.graphdb.index.IndexHits;
import org.neo4j.index.impl.lucene.EntityId.IdData;
import org.neo4j.index.lucene.ValueContext;
import org.neo4j.kernel.api.LegacyIndexHits;
import org.neo4j.kernel.api.exceptions.index.IndexCapacityExceededException;
Expand All @@ -57,8 +56,6 @@

import static java.util.concurrent.TimeUnit.MILLISECONDS;

import static org.neo4j.index.impl.lucene.LuceneDataSource.getDirectory;

class LuceneBatchInserterIndex implements BatchInserterIndex
{
private final IndexIdentifier identifier;
Expand Down Expand Up @@ -118,7 +115,7 @@ private EntityId entityId( long id )
{
if ( identifier.entityType == IndexEntityType.Node )
{
return new IdData( id );
return new EntityId.IdData( id );
}

return relationshipLookup.lookup( id );
Expand Down Expand Up @@ -157,7 +154,7 @@ private void addToCache( long entityId, String key, Object value )
ids = new HashSet<>();
cache.put( valueAsString, ids );
}
ids.add( new IdData( entityId ) );
ids.add( new EntityId.IdData( entityId ) );
}
}

Expand Down Expand Up @@ -249,7 +246,7 @@ private void removeFromCache( long entityId, String key, Object value )
Collection<EntityId> ids = cache.get( valueAsString );
if ( ids != null )
{
ids.remove( new IdData(entityId) );
ids.remove( new EntityId.IdData(entityId) );
}
}
}
Expand All @@ -260,7 +257,7 @@ private LuceneIndexWriter instantiateWriter( File directory )
{
IndexWriterConfig writerConfig = new IndexWriterConfig( type.analyzer );
writerConfig.setRAMBufferSizeMB( determineGoodBufferSize( writerConfig.getRAMBufferSizeMB() ) );
Directory luceneDir = getDirectory( directory, identifier );
Directory luceneDir = LuceneDataSource.getDirectory( directory, identifier );
return IndexWriterFactories.batchInsert( writerConfig ).create( luceneDir );
}
catch ( IOException e )
Expand Down Expand Up @@ -358,7 +355,7 @@ protected boolean fetchNext()
{
if ( super.fetchNext() )
{
ids.add( new IdData( next ) );
ids.add( new EntityId.IdData( next ) );
return true;
}
addToCache( ids, key, value );
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.io.File;
import java.util.HashMap;
Expand All @@ -29,8 +29,7 @@
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexManager;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.index.impl.lucene.EntityId.RelationshipData;
import org.neo4j.index.impl.lucene.LuceneBatchInserterIndex.RelationshipLookup;
import org.neo4j.index.lucene.legacy.LuceneBatchInserterIndex.RelationshipLookup;
import org.neo4j.kernel.impl.index.IndexConfigStore;
import org.neo4j.kernel.impl.index.IndexEntityType;
import org.neo4j.unsafe.batchinsert.BatchInserter;
Expand Down Expand Up @@ -62,7 +61,7 @@ public EntityId lookup( long id )
{
// TODO too may objects allocated here
BatchRelationship rel = inserter.getRelationshipById( id );
return new RelationshipData( id, rel.getStartNode(), rel.getEndNode() );
return new EntityId.RelationshipData( id, rel.getStartNode(), rel.getEndNode() );
}
};
}
Expand Down
Expand Up @@ -17,16 +17,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.neo4j.graphdb.index.IndexImplementation;
import org.neo4j.index.impl.lucene.CommitContext.DocumentContext;
import org.neo4j.index.impl.lucene.EntityId.IdData;
import org.neo4j.index.impl.lucene.EntityId.RelationshipData;
import org.neo4j.index.lucene.legacy.CommitContext.DocumentContext;
import org.neo4j.kernel.impl.index.IndexCommand;
import org.neo4j.kernel.impl.index.IndexCommand.AddNodeCommand;
import org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand;
Expand Down Expand Up @@ -62,7 +60,7 @@ public boolean visitIndexAddNodeCommand( AddNodeCommand command ) throws IOExcep
String key = definitions.getKey( command.getKeyId() );
Object value = command.getValue();
context.ensureWriterInstantiated();
context.indexType.addToDocument( context.getDocument( new IdData( command.getEntityId() ), true ).document,
context.indexType.addToDocument( context.getDocument( new EntityId.IdData( command.getEntityId() ), true ).document,
key, value );
return false;
}
Expand All @@ -74,7 +72,7 @@ public boolean visitIndexAddRelationshipCommand( AddRelationshipCommand command
String key = definitions.getKey( command.getKeyId() );
Object value = command.getValue();
context.ensureWriterInstantiated();
RelationshipData entityId = new RelationshipData( command.getEntityId(),
EntityId.RelationshipData entityId = new EntityId.RelationshipData( command.getEntityId(),
command.getStartNode(), command.getEndNode() );
context.indexType.addToDocument( context.getDocument( entityId, true ).document, key, value );
return false;
Expand All @@ -87,7 +85,7 @@ public boolean visitIndexRemoveCommand( RemoveCommand command ) throws IOExcepti
String key = definitions.getKey( command.getKeyId() );
Object value = command.getValue();
context.ensureWriterInstantiated();
DocumentContext document = context.getDocument( new IdData( command.getEntityId() ), false );
DocumentContext document = context.getDocument( new EntityId.IdData( command.getEntityId() ), false );
if ( document != null )
{
context.indexType.removeFromDocument( document.document, key, value );
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;
package org.neo4j.index.lucene.legacy;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;
Expand All @@ -42,7 +42,6 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.Version;

import java.io.File;
import java.io.IOException;
Expand Down

0 comments on commit b48af5b

Please sign in to comment.