Skip to content

Commit

Permalink
Better package structure in lucene-index module
Browse files Browse the repository at this point in the history
Currently all classes related to both schema indexes and label scan store are
located in `org.neo4j.kernel.api.impl.index` package. This makes it quite a
big and messy package.

This commit keeps common components in `org.neo4j.kernel.api.impl.index`, moves
classes related to schema indexes to `org.neo4j.kernel.api.impl.schema` and
classes related to label scan store to `org.neo4j.kernel.api.impl.labelscan`.
Same restructuring is done for tests.
  • Loading branch information
lutovich authored and MishaDemianenko committed Jan 21, 2016
1 parent 9e96dc0 commit 5e70224
Show file tree
Hide file tree
Showing 93 changed files with 210 additions and 209 deletions.
Expand Up @@ -27,25 +27,25 @@

import org.neo4j.function.Suppliers;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.helpers.progress.ProgressMonitorFactory;
import org.neo4j.index.lucene.LuceneLabelScanStoreBuilder;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
import org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory;
import org.neo4j.kernel.api.direct.DirectStoreAccess;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.index.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.locking.LockService;
import org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory;
import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.StoreAccess;
import org.neo4j.kernel.impl.store.StoreFactory;
import org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory;
import org.neo4j.kernel.impl.transaction.state.NeoStoreIndexStoreView;
import org.neo4j.legacy.consistency.checking.full.ConsistencyCheckIncompleteException;
import org.neo4j.legacy.consistency.checking.full.FullCheck;
Expand Down
Expand Up @@ -38,7 +38,7 @@
import org.neo4j.kernel.api.direct.DirectStoreAccess;
import org.neo4j.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.index.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess;
import org.neo4j.kernel.impl.api.TransactionToApply;
Expand Down Expand Up @@ -68,7 +68,6 @@
import org.neo4j.test.TestGraphDatabaseFactory;

import static java.lang.System.currentTimeMillis;

import static org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider.fullStoreLabelUpdateStream;

public abstract class GraphStoreFixture extends PageCacheRule implements TestRule
Expand Down
Expand Up @@ -39,7 +39,7 @@
import java.util.ArrayList;
import java.util.List;

import org.neo4j.kernel.api.impl.index.LuceneNodeLabelRange;
import org.neo4j.kernel.api.impl.labelscan.LuceneNodeLabelRange;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.kernel.impl.store.record.DynamicRecord;
Expand All @@ -57,12 +57,6 @@
import org.neo4j.legacy.consistency.checking.CheckerEngine;
import org.neo4j.legacy.consistency.checking.ComparativeRecordChecker;
import org.neo4j.legacy.consistency.checking.RecordCheck;
import org.neo4j.legacy.consistency.report.ConsistencyReport;
import org.neo4j.legacy.consistency.report.ConsistencyReporter;
import org.neo4j.legacy.consistency.report.ConsistencySummaryStatistics;
import org.neo4j.legacy.consistency.report.InconsistencyLogger;
import org.neo4j.legacy.consistency.report.InconsistencyReport;
import org.neo4j.legacy.consistency.report.PendingReferenceCheck;
import org.neo4j.legacy.consistency.store.DiffRecordAccess;
import org.neo4j.legacy.consistency.store.RecordAccess;
import org.neo4j.legacy.consistency.store.RecordReference;
Expand All @@ -72,15 +66,13 @@
import org.neo4j.storageengine.api.schema.SchemaRule;

import static java.lang.String.format;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;

import static org.neo4j.kernel.impl.store.counts.keys.CountsKeyFactory.nodeKey;

@RunWith(Suite.class)
Expand Down
Expand Up @@ -43,8 +43,8 @@
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
import org.neo4j.kernel.api.direct.DirectStoreAccess;
import org.neo4j.kernel.api.impl.index.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.configuration.Config;
Expand Down
Expand Up @@ -43,7 +43,7 @@
import org.neo4j.kernel.api.direct.DirectStoreAccess;
import org.neo4j.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.index.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess;
import org.neo4j.kernel.impl.api.TransactionToApply;
Expand Down Expand Up @@ -77,7 +77,6 @@
import org.neo4j.test.TestGraphDatabaseFactory;

import static java.lang.System.currentTimeMillis;

import static org.neo4j.consistency.ConsistencyCheckService.defaultConsistencyCheckThreadsNumber;
import static org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider.fullStoreLabelUpdateStream;

Expand Down
Expand Up @@ -48,7 +48,7 @@
import org.neo4j.consistency.store.synthetic.CountsEntry;
import org.neo4j.consistency.store.synthetic.IndexEntry;
import org.neo4j.consistency.store.synthetic.LabelScanDocument;
import org.neo4j.kernel.api.impl.index.LuceneNodeLabelRange;
import org.neo4j.kernel.api.impl.labelscan.LuceneNodeLabelRange;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.kernel.impl.store.record.DynamicRecord;
Expand All @@ -64,16 +64,14 @@
import org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord;
import org.neo4j.storageengine.api.schema.SchemaRule;

import static java.lang.String.format;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;

import static java.lang.String.format;

import static org.neo4j.consistency.report.ConsistencyReporter.NO_MONITOR;
import static org.neo4j.kernel.impl.store.counts.keys.CountsKeyFactory.nodeKey;

Expand Down
Expand Up @@ -22,6 +22,9 @@
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.register.Register;

/**
* Component able to sample schema index.
*/
public interface IndexSampler
{
IndexSampler EMPTY = result -> {
Expand Down
Expand Up @@ -52,7 +52,7 @@

import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.index.lucene.QueryContext;
import org.neo4j.kernel.api.impl.index.DocValuesCollector;
import org.neo4j.kernel.api.impl.index.collector.DocValuesCollector;

import static java.util.Collections.emptyList;
import static org.neo4j.index.impl.lucene.legacy.LuceneLegacyIndex.KEY_DOC_ID;
Expand Down
Expand Up @@ -48,7 +48,7 @@
import org.neo4j.index.lucene.ValueContext;
import org.neo4j.io.IOUtils;
import org.neo4j.kernel.api.LegacyIndexHits;
import org.neo4j.kernel.api.impl.index.DocValuesCollector;
import org.neo4j.kernel.api.impl.index.collector.DocValuesCollector;
import org.neo4j.kernel.impl.index.IndexEntityType;
import org.neo4j.kernel.impl.util.IoPrimitiveUtils;
import org.neo4j.unsafe.batchinsert.BatchInserterIndex;
Expand Down
Expand Up @@ -50,7 +50,7 @@
import org.neo4j.index.lucene.ValueContext;
import org.neo4j.kernel.api.LegacyIndex;
import org.neo4j.kernel.api.LegacyIndexHits;
import org.neo4j.kernel.api.impl.index.DocValuesCollector;
import org.neo4j.kernel.api.impl.index.collector.DocValuesCollector;
import org.neo4j.kernel.impl.util.IoPrimitiveUtils;
import org.neo4j.kernel.spi.legacyindex.IndexCommandFactory;

Expand Down
Expand Up @@ -23,18 +23,14 @@
import java.io.IOException;

import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.api.impl.index.LuceneLabelScanIndex;
import org.neo4j.kernel.api.impl.index.LuceneLabelScanStore;
import org.neo4j.kernel.api.impl.index.builder.LuceneLabelScanIndexBuilder;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage;
import org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanIndex;
import org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanIndexBuilder;
import org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStore;
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider;
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider.FullStoreChangeStream;
import org.neo4j.logging.LogProvider;

import static org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider.fullStoreLabelUpdateStream;

/**
* Means of obtaining a {@link LabelScanStore}, independent of the {@link org.neo4j.kernel.extension.KernelExtensions}
* mechanism, when you need to access the store without running a full database. This is used during consistency
Expand Down
Expand Up @@ -98,7 +98,7 @@ public void open() throws IOException
open = true;
}

boolean isOpen()
public boolean isOpen()
{
return open;
}
Expand Down Expand Up @@ -321,19 +321,29 @@ public void maybeRefreshBlocking() throws IOException
}
}

List<IndexPartition> getPartitions()
public List<IndexPartition> getPartitions()
{
ensureOpen();
return partitions;
}

public boolean hasSinglePartition( List<IndexPartition> partitions )
{
return partitions.size() == 1;
}

public IndexPartition getFirstPartition( List<IndexPartition> partitions )
{
return partitions.get( 0 );
}

/**
* Add new partition to the index.
*
* @return newly created partition
* @throws IOException
*/
IndexPartition addNewPartition() throws IOException
public IndexPartition addNewPartition() throws IOException
{
ensureOpen();
partitionsLock.lock();
Expand Down Expand Up @@ -368,16 +378,6 @@ protected void ensureNotOpen()
}
}

protected boolean hasSinglePartition( List<IndexPartition> partitions )
{
return partitions.size() == 1;
}

protected IndexPartition getFirstPartition( List<IndexPartition> partitions )
{
return partitions.get( 0 );
}

private boolean luceneDirectoryExists( File folder ) throws IOException
{
try ( Directory directory = indexStorage.openDirectory( folder ) )
Expand Down
Expand Up @@ -30,7 +30,7 @@
*
* @param <T> actual index type
*/
abstract class AbstractLuceneIndexBuilder<T extends AbstractLuceneIndexBuilder<T>>
public abstract class AbstractLuceneIndexBuilder<T extends AbstractLuceneIndexBuilder<T>>
{
protected LuceneIndexStorageBuilder storageBuilder = LuceneIndexStorageBuilder.create();

Expand Down
Expand Up @@ -17,13 +17,13 @@
* 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.kernel.api.impl.index;
package org.neo4j.kernel.api.impl.index.collector;

/**
* Represents a point-in-time view on a set of numeric values
* that are read from a {@code NumericDocValues} field.
*/
interface DocValuesAccess
public interface DocValuesAccess
{
/**
* @return the current value of the main field that is driving the values.
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.kernel.api.impl.index;
package org.neo4j.kernel.api.impl.index.collector;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.DocValuesType;
Expand Down Expand Up @@ -199,7 +199,7 @@ public void setScorer( Scorer scorer ) throws IOException
}

@Override
protected void doSetNextReader( LeafReaderContext context ) throws IOException
public void doSetNextReader( LeafReaderContext context ) throws IOException
{
if ( docs != null && segmentHits > 0 )
{
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.kernel.api.impl.index;
package org.neo4j.kernel.api.impl.index.collector;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.CollectionTerminatedException;
Expand Down
Expand Up @@ -17,16 +17,22 @@
* 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.kernel.api.impl.index;
package org.neo4j.kernel.api.impl.labelscan;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.concurrent.locks.Lock;

import org.neo4j.kernel.api.impl.index.AbstractLuceneIndex;
import org.neo4j.kernel.api.impl.index.partition.IndexPartition;
import org.neo4j.kernel.api.impl.index.partition.PartitionSearcher;
import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage;
import org.neo4j.kernel.api.impl.labelscan.reader.SimpleLuceneLabelScanStoreReader;
import org.neo4j.kernel.api.impl.labelscan.storestrategy.BitmapDocumentFormat;
import org.neo4j.kernel.api.impl.labelscan.storestrategy.LabelScanStorageStrategy;
import org.neo4j.kernel.api.impl.labelscan.storestrategy.NodeRangeDocumentLabelScanStorageStrategy;
import org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter;
import org.neo4j.kernel.api.labelscan.AllEntriesLabelScanReader;
import org.neo4j.kernel.api.labelscan.LabelScanWriter;
import org.neo4j.kernel.api.labelscan.NodeLabelRange;
Expand Down
Expand Up @@ -17,10 +17,10 @@
* 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.kernel.api.impl.index.builder;
package org.neo4j.kernel.api.impl.labelscan;

import org.neo4j.kernel.api.impl.index.BitmapDocumentFormat;
import org.neo4j.kernel.api.impl.index.LuceneLabelScanIndex;
import org.neo4j.kernel.api.impl.index.builder.AbstractLuceneIndexBuilder;
import org.neo4j.kernel.api.impl.labelscan.storestrategy.BitmapDocumentFormat;

/**
* Helper builder class to simplify construction and instantiation of lucene label scan indexes.
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.kernel.api.impl.index;
package org.neo4j.kernel.api.impl.labelscan;

import org.apache.lucene.store.LockObtainFailedException;

Expand Down
Expand Up @@ -17,16 +17,13 @@
* 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.kernel.api.impl.index;
package org.neo4j.kernel.api.impl.labelscan;

import java.util.function.Supplier;

import org.neo4j.helpers.Service;
import org.neo4j.kernel.NeoStoreDataSource;
import org.neo4j.kernel.api.impl.index.LuceneLabelScanStore.Monitor;
import org.neo4j.kernel.api.impl.index.builder.LuceneLabelScanIndexBuilder;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.extension.KernelExtensionFactory;
import org.neo4j.kernel.impl.api.index.IndexStoreView;
Expand All @@ -37,6 +34,7 @@
import org.neo4j.kernel.lifecycle.Lifecycle;

import static org.neo4j.kernel.api.impl.index.LuceneKernelExtensions.directoryFactory;
import static org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStore.Monitor;
import static org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider.fullStoreLabelUpdateStream;

@Service.Implementation(KernelExtensionFactory.class)
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.kernel.api.impl.index;
package org.neo4j.kernel.api.impl.labelscan;

import java.util.ArrayList;
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.kernel.api.impl.index.bitmaps;
package org.neo4j.kernel.api.impl.labelscan.bitmaps;

public class Bitmap
{
Expand Down

0 comments on commit 5e70224

Please sign in to comment.