Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce builders for all lucene indexes
Add additional builder for label scan store index, separate builder for index storeage creation, update code and tests to use new builder
- Loading branch information
1 parent
1ad1c64
commit ca4b790
Showing
22 changed files
with
367 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
community/io/src/test/java/org/neo4j/test/NestedThrowableMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...dex/src/main/java/org/neo4j/kernel/api/impl/index/builder/AbstractLuceneIndexBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* 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; | ||
|
||
import java.io.File; | ||
|
||
import org.neo4j.io.fs.FileSystemAbstraction; | ||
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory; | ||
import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage; | ||
|
||
abstract class AbstractLuceneIndexBuilder<T extends AbstractLuceneIndexBuilder> | ||
{ | ||
protected LuceneIndexStorageBuilder storageBuilder = LuceneIndexStorageBuilder.create(); | ||
|
||
public T withIndexStorage( PartitionedIndexStorage indexStorage ) | ||
{ | ||
storageBuilder.withIndexStorage( indexStorage ); | ||
return (T) this; | ||
} | ||
|
||
public T withDirectoryFactory( DirectoryFactory directoryFactory ) | ||
{ | ||
storageBuilder.withDirectoryFactory( directoryFactory ); | ||
return (T) this; | ||
} | ||
|
||
public T withFileSystem( FileSystemAbstraction fileSystem ) | ||
{ | ||
storageBuilder.withFileSystem( fileSystem ); | ||
return (T) this; | ||
} | ||
|
||
public T withIndexRootFolder( File indexRootFolder ) | ||
{ | ||
storageBuilder.withIndexRootFolder( indexRootFolder ); | ||
return (T) this; | ||
} | ||
|
||
public T withIndexIdentifier( String indexIdentifier ) | ||
{ | ||
storageBuilder.withIndexIdentifier( indexIdentifier ); | ||
return (T) this; | ||
} | ||
|
||
} |
90 changes: 90 additions & 0 deletions
90
...ndex/src/main/java/org/neo4j/kernel/api/impl/index/builder/LuceneIndexStorageBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* 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; | ||
|
||
import java.io.File; | ||
import java.util.Objects; | ||
|
||
import org.neo4j.io.fs.DefaultFileSystemAbstraction; | ||
import org.neo4j.io.fs.FileSystemAbstraction; | ||
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory; | ||
import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage; | ||
|
||
class LuceneIndexStorageBuilder | ||
{ | ||
private DirectoryFactory directoryFactory = DirectoryFactory.PERSISTENT; | ||
private FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); | ||
private File indexRootFolder; | ||
private String indexIdentifier; | ||
private PartitionedIndexStorage indexStorage; | ||
|
||
private LuceneIndexStorageBuilder() | ||
{ | ||
} | ||
|
||
static LuceneIndexStorageBuilder create() | ||
{ | ||
return new LuceneIndexStorageBuilder(); | ||
} | ||
|
||
PartitionedIndexStorage buildIndexStorage() | ||
{ | ||
if ( indexStorage == null ) | ||
{ | ||
Objects.requireNonNull( directoryFactory ); | ||
Objects.requireNonNull( fileSystem ); | ||
Objects.requireNonNull( indexRootFolder ); | ||
Objects.requireNonNull( indexIdentifier ); | ||
indexStorage = | ||
new PartitionedIndexStorage( directoryFactory, fileSystem, indexRootFolder, indexIdentifier ); | ||
} | ||
return indexStorage; | ||
} | ||
|
||
LuceneIndexStorageBuilder withIndexIdentifier( String indexIdentifier ) | ||
{ | ||
this.indexIdentifier = indexIdentifier; | ||
return this; | ||
} | ||
|
||
LuceneIndexStorageBuilder withDirectoryFactory( DirectoryFactory directoryFactory ) | ||
{ | ||
this.directoryFactory = directoryFactory; | ||
return this; | ||
} | ||
|
||
LuceneIndexStorageBuilder withFileSystem( FileSystemAbstraction fileSystem ) | ||
{ | ||
this.fileSystem = fileSystem; | ||
return this; | ||
} | ||
|
||
LuceneIndexStorageBuilder withIndexRootFolder( File indexRootFolder ) | ||
{ | ||
this.indexRootFolder = indexRootFolder; | ||
return this; | ||
} | ||
|
||
LuceneIndexStorageBuilder withIndexStorage( PartitionedIndexStorage indexStorage ) | ||
{ | ||
this.indexStorage = indexStorage; | ||
return this; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...ex/src/main/java/org/neo4j/kernel/api/impl/index/builder/LuceneLabelScanIndexBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* 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; | ||
|
||
import org.neo4j.kernel.api.impl.index.BitmapDocumentFormat; | ||
import org.neo4j.kernel.api.impl.index.LuceneLabelScanIndex; | ||
|
||
public class LuceneLabelScanIndexBuilder extends AbstractLuceneIndexBuilder<LuceneLabelScanIndexBuilder> | ||
{ | ||
public static final String DEFAULT_INDEX_IDENTIFIER = "labelStore"; | ||
|
||
private BitmapDocumentFormat format = BitmapDocumentFormat._32; | ||
|
||
private LuceneLabelScanIndexBuilder() | ||
{ | ||
super(); | ||
storageBuilder.withIndexIdentifier( DEFAULT_INDEX_IDENTIFIER ); | ||
} | ||
|
||
public static LuceneLabelScanIndexBuilder create() | ||
{ | ||
return new LuceneLabelScanIndexBuilder(); | ||
} | ||
|
||
public LuceneLabelScanIndexBuilder withDocumentFormat( BitmapDocumentFormat format ) | ||
{ | ||
this.format = format; | ||
return this; | ||
} | ||
|
||
public LuceneLabelScanIndex build() | ||
{ | ||
return new LuceneLabelScanIndex( format, storageBuilder.buildIndexStorage() ); | ||
} | ||
} |
Oops, something went wrong.