Skip to content

Commit

Permalink
Specific interface for populator part supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Oct 10, 2018
1 parent fe63228 commit 6f0c2d3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.impl.index.schema;

import java.io.File;

@FunctionalInterface
interface NativeIndexPopulatorPartSupplier<KEY extends NativeIndexKey<KEY>,VALUE extends NativeIndexValue>
{
NativeIndexPopulator<KEY,VALUE> part( File partFileName );
}
Expand Up @@ -28,7 +28,6 @@
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Function;


import org.neo4j.cursor.RawCursor; import org.neo4j.cursor.RawCursor;
import org.neo4j.index.internal.gbptree.Hit; import org.neo4j.index.internal.gbptree.Hit;
Expand Down Expand Up @@ -68,7 +67,7 @@ class ParallelNativeIndexPopulator<KEY extends NativeIndexKey<KEY>,VALUE extends
// from being created beyond that point. // from being created beyond that point.
private volatile boolean closed; private volatile boolean closed;


ParallelNativeIndexPopulator( File baseIndexFile, IndexLayout<KEY,VALUE> layout, Function<File,NativeIndexPopulator<KEY,VALUE>> populatorSupplier ) ParallelNativeIndexPopulator( File baseIndexFile, IndexLayout<KEY,VALUE> layout, NativeIndexPopulatorPartSupplier<KEY,VALUE> partSupplier )
{ {
this.layout = layout; this.layout = layout;
this.threadLocalPopulators = new ThreadLocal<ThreadLocalPopulator>() this.threadLocalPopulators = new ThreadLocal<ThreadLocalPopulator>()
Expand All @@ -86,14 +85,14 @@ protected synchronized ThreadLocalPopulator initialValue()
} }


File file = new File( baseIndexFile + "-part-" + partPopulators.size() ); File file = new File( baseIndexFile + "-part-" + partPopulators.size() );
NativeIndexPopulator<KEY,VALUE> populator = populatorSupplier.apply( file ); NativeIndexPopulator<KEY,VALUE> populator = partSupplier.part( file );
ThreadLocalPopulator tlPopulator = new ThreadLocalPopulator( populator ); ThreadLocalPopulator tlPopulator = new ThreadLocalPopulator( populator );
partPopulators.add( tlPopulator ); partPopulators.add( tlPopulator );
populator.create(); populator.create();
return tlPopulator; return tlPopulator;
} }
}; };
this.completePopulator = populatorSupplier.apply( baseIndexFile ); this.completePopulator = partSupplier.part( baseIndexFile );
} }


@Override @Override
Expand Down

0 comments on commit 6f0c2d3

Please sign in to comment.