-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12bf4e5
commit 5693759
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...m-index/src/main/java/org/neo4j/kernel/api/impl/bloom/extension/BloomKernelExtension.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,64 @@ | ||
/* | ||
* Copyright (c) 2002-2017 "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.bloom.extension; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.neo4j.graphdb.GraphDatabaseService; | ||
import org.neo4j.index.impl.lucene.legacy.LuceneIndexImplementation; | ||
import org.neo4j.io.fs.FileSystemAbstraction; | ||
import org.neo4j.kernel.api.impl.bloom.BloomIndex; | ||
import org.neo4j.kernel.api.impl.bloom.BloomIndexTransactionEventUpdater; | ||
import org.neo4j.kernel.configuration.Config; | ||
import org.neo4j.kernel.lifecycle.LifecycleAdapter; | ||
|
||
public class BloomKernelExtension extends LifecycleAdapter | ||
{ | ||
private final File storeDir; | ||
private final Config config; | ||
private final FileSystemAbstraction fileSystemAbstraction; | ||
private GraphDatabaseService db; | ||
private BloomIndex bloomIndex; | ||
private BloomIndexTransactionEventUpdater bloomIndexTransactionEventUpdater; | ||
|
||
public BloomKernelExtension( FileSystemAbstraction fileSystemAbstraction, File storeDir, Config config, GraphDatabaseService db ) | ||
{ | ||
this.storeDir = storeDir; | ||
this.config = config; | ||
this.fileSystemAbstraction = fileSystemAbstraction; | ||
this.db = db; | ||
} | ||
|
||
@Override | ||
public void init() throws IOException | ||
{ | ||
bloomIndex = new BloomIndex( fileSystemAbstraction, storeDir, config ); | ||
bloomIndexTransactionEventUpdater = bloomIndex.getUpdater(); | ||
db.registerTransactionEventHandler( bloomIndexTransactionEventUpdater ); | ||
} | ||
|
||
@Override | ||
public void shutdown() throws Exception | ||
{ | ||
db.unregisterTransactionEventHandler( bloomIndexTransactionEventUpdater ); | ||
bloomIndex.close(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../src/main/java/org/neo4j/kernel/api/impl/bloom/extension/BloomKernelExtensionFactory.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,53 @@ | ||
/* | ||
* Copyright (c) 2002-2017 "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.bloom.extension; | ||
|
||
import org.neo4j.graphdb.GraphDatabaseService; | ||
import org.neo4j.io.fs.FileSystemAbstraction; | ||
import org.neo4j.kernel.configuration.Config; | ||
import org.neo4j.kernel.extension.KernelExtensionFactory; | ||
import org.neo4j.kernel.impl.spi.KernelContext; | ||
import org.neo4j.kernel.lifecycle.Lifecycle; | ||
|
||
public class BloomKernelExtensionFactory extends KernelExtensionFactory<BloomKernelExtensionFactory.Dependencies> | ||
{ | ||
|
||
public static final String SERVICE_NAME = "bloom"; | ||
|
||
public interface Dependencies | ||
{ | ||
Config getConfig(); | ||
|
||
GraphDatabaseService db(); | ||
|
||
FileSystemAbstraction fileSystem(); | ||
} | ||
|
||
public BloomKernelExtensionFactory() | ||
{ | ||
super( SERVICE_NAME ); | ||
} | ||
|
||
@Override | ||
public Lifecycle newInstance( KernelContext context, Dependencies dependencies ) throws Throwable | ||
{ | ||
return new BloomKernelExtension( dependencies.fileSystem(), context.storeDir(), dependencies.getConfig(), dependencies.db() ); | ||
} | ||
} |