Skip to content

Commit

Permalink
Remove GBPTreeFileUtil. Use file system abstraction directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaDemianenko committed May 14, 2018
1 parent ad857ee commit 3591d68
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 404 deletions.

This file was deleted.

Expand Up @@ -44,8 +44,6 @@
import org.neo4j.kernel.api.labelscan.LabelScanStore; import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.api.labelscan.LabelScanWriter; import org.neo4j.kernel.api.labelscan.LabelScanWriter;
import org.neo4j.kernel.impl.api.scan.FullStoreChangeStream; import org.neo4j.kernel.impl.api.scan.FullStoreChangeStream;
import org.neo4j.kernel.impl.index.GBPTreeFileUtil;
import org.neo4j.kernel.impl.index.schema.GBPTreeFileSystemFileUtil;
import org.neo4j.kernel.impl.store.UnderlyingStorageException; import org.neo4j.kernel.impl.store.UnderlyingStorageException;
import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.storageengine.api.schema.LabelScanReader; import org.neo4j.storageengine.api.schema.LabelScanReader;
Expand Down Expand Up @@ -135,7 +133,7 @@ public class NativeLabelScanStore implements LabelScanStore
/** /**
* Used for all file operations on the gbpTree file. * Used for all file operations on the gbpTree file.
*/ */
private final GBPTreeFileUtil gbpTreeUtil; private final FileSystemAbstraction fileSystem;


/** /**
* The index which backs this label scan store. Instantiated in {@link #init()} and considered * The index which backs this label scan store. Instantiated in {@link #init()} and considered
Expand Down Expand Up @@ -193,7 +191,7 @@ public NativeLabelScanStore( PageCache pageCache, File storeDir, FileSystemAbstr
this.monitors = monitors; this.monitors = monitors;
this.monitor = monitors.newMonitor( Monitor.class ); this.monitor = monitors.newMonitor( Monitor.class );
this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector; this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector;
this.gbpTreeUtil = new GBPTreeFileSystemFileUtil( fs ); this.fileSystem = fs;
} }


/** /**
Expand Down Expand Up @@ -352,7 +350,7 @@ public void init() throws IOException
@Override @Override
public boolean hasStore() public boolean hasStore()
{ {
return gbpTreeUtil.storeFileExists( storeFile ); return fileSystem.fileExists( storeFile );
} }


@Override @Override
Expand Down Expand Up @@ -412,7 +410,7 @@ private void dropStrict() throws IOException
index.close(); index.close();
index = null; index = null;
} }
gbpTreeUtil.deleteFile( storeFile ); fileSystem.deleteFileOrThrow( storeFile );
} }


/** /**
Expand Down

This file was deleted.

Expand Up @@ -32,7 +32,6 @@
import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.api.index.IndexProvider; import org.neo4j.kernel.api.index.IndexProvider;
import org.neo4j.kernel.api.schema.index.SchemaIndexDescriptor; import org.neo4j.kernel.api.schema.index.SchemaIndexDescriptor;
import org.neo4j.kernel.impl.index.GBPTreeFileUtil;


import static org.neo4j.helpers.Format.duration; import static org.neo4j.helpers.Format.duration;
import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.helpers.collection.MapUtil.map;
Expand All @@ -43,7 +42,7 @@ abstract class NativeSchemaIndex<KEY extends NativeSchemaKey<KEY>, VALUE extends
final PageCache pageCache; final PageCache pageCache;
final File storeFile; final File storeFile;
final Layout<KEY,VALUE> layout; final Layout<KEY,VALUE> layout;
final GBPTreeFileUtil gbpTreeFileUtil; final FileSystemAbstraction fileSystem;
final SchemaIndexDescriptor descriptor; final SchemaIndexDescriptor descriptor;
private final long indexId; private final long indexId;
private final IndexProvider.Monitor monitor; private final IndexProvider.Monitor monitor;
Expand All @@ -56,7 +55,7 @@ abstract class NativeSchemaIndex<KEY extends NativeSchemaKey<KEY>, VALUE extends
this.pageCache = pageCache; this.pageCache = pageCache;
this.storeFile = storeFile; this.storeFile = storeFile;
this.layout = layout; this.layout = layout;
this.gbpTreeFileUtil = new GBPTreeFileSystemFileUtil( fs ); this.fileSystem = fs;
this.descriptor = descriptor; this.descriptor = descriptor;
this.indexId = indexId; this.indexId = indexId;
this.monitor = monitor; this.monitor = monitor;
Expand Down Expand Up @@ -87,15 +86,15 @@ public void cleanupFinished( long numberOfPagesVisited, long numberOfCleanedCras


private void ensureDirectoryExist() throws IOException private void ensureDirectoryExist() throws IOException
{ {
gbpTreeFileUtil.mkdirs( storeFile.getParentFile() ); fileSystem.mkdirs( storeFile.getParentFile() );
} }


void closeTree() throws IOException void closeTree() throws IOException
{ {
tree = closeIfPresent( tree ); tree = closeIfPresent( tree );
} }


<T extends Closeable> T closeIfPresent( T closeable ) throws IOException private <T extends Closeable> T closeIfPresent( T closeable ) throws IOException
{ {
if ( closeable != null ) if ( closeable != null )
{ {
Expand Down
Expand Up @@ -69,7 +69,7 @@ public abstract class NativeSchemaIndexAccessor<KEY extends NativeSchemaKey<KEY>
public void drop() throws IOException public void drop() throws IOException
{ {
closeTree(); closeTree();
gbpTreeFileUtil.deleteFile( storeFile ); fileSystem.deleteFileOrThrow( storeFile );
} }


@Override @Override
Expand Down
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.NoSuchFileException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -106,7 +107,7 @@ public abstract class NativeSchemaIndexPopulator<KEY extends NativeSchemaKey<KEY


public void clear() throws IOException public void clear() throws IOException
{ {
gbpTreeFileUtil.deleteFileIfPresent( storeFile ); deleteFileIfPresent( fileSystem, storeFile );
} }


@Override @Override
Expand All @@ -120,7 +121,7 @@ protected synchronized void create( Consumer<PageCursor> headerWriter ) throws I
assertNotDropped(); assertNotDropped();
assertNotClosed(); assertNotClosed();


gbpTreeFileUtil.deleteFileIfPresent( storeFile ); deleteFileIfPresent( fileSystem, storeFile );
instantiateTree( RecoveryCleanupWorkCollector.IMMEDIATE, headerWriter ); instantiateTree( RecoveryCleanupWorkCollector.IMMEDIATE, headerWriter );


// true: tree uniqueness is (value,entityId) // true: tree uniqueness is (value,entityId)
Expand All @@ -139,7 +140,7 @@ public synchronized void drop()
try try
{ {
closeTree(); closeTree();
gbpTreeFileUtil.deleteFileIfPresent( storeFile ); deleteFileIfPresent( fileSystem, storeFile );
} }
catch ( IOException e ) catch ( IOException e )
{ {
Expand Down Expand Up @@ -390,4 +391,16 @@ public IndexSample sampleResult()
throw new IllegalArgumentException( "Unexpected index type " + descriptor.type() ); throw new IllegalArgumentException( "Unexpected index type " + descriptor.type() );
} }
} }

private static void deleteFileIfPresent( FileSystemAbstraction fs, File storeFile ) throws IOException
{
try
{
fs.deleteFileOrThrow( storeFile );
}
catch ( NoSuchFileException e )
{
// File does not exist, we don't need to delete
}
}
} }

0 comments on commit 3591d68

Please sign in to comment.