Skip to content

Commit

Permalink
Add bloom kernel extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed Sep 12, 2017
1 parent 12bf4e5 commit 5693759
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
@@ -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();
}
}
@@ -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() );
}
}

0 comments on commit 5693759

Please sign in to comment.