use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class AbstractLuceneIndex method addNewPartition.
/**
* Add new partition to the index.
*
* @return newly created partition
* @throws IOException
*/
AbstractIndexPartition addNewPartition() throws IOException {
ensureOpen();
Path partitionFolder = createNewPartitionFolder();
Directory directory = indexStorage.openDirectory(partitionFolder);
AbstractIndexPartition indexPartition = partitionFactory.createPartition(partitionFolder, directory);
partitions.add(indexPartition);
return indexPartition;
}
use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class AbstractLuceneIndex method markAsOnline.
/**
* Marks index as online by including "status" -> "online" map into commit metadata of the first partition.
*
* @throws IOException
*/
public void markAsOnline() throws IOException {
ensureOpen();
AbstractIndexPartition partition = getFirstPartition(getPartitions());
IndexWriter indexWriter = partition.getIndexWriter();
indexWriter.setLiveCommitData(ONLINE_COMMIT_USER_DATA);
flush(false);
}
use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class DatabaseIndexIntegrationTest method firstPartitionWriter.
private IndexWriter firstPartitionWriter() {
List<AbstractIndexPartition> partitions = luceneIndex.getPartitions();
assertEquals(1, partitions.size());
AbstractIndexPartition partition = partitions.get(0);
return partition.getIndexWriter();
}
use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class PartitionedLuceneLabelScanWriter method flush.
private void flush() throws IOException {
if (currentRange < 0) {
return;
}
AbstractIndexPartition partition = getCurrentPartition();
try (PartitionSearcher partitionSearcher = partition.acquireSearcher()) {
IndexSearcher searcher = partitionSearcher.getIndexSearcher();
Map<Long, Bitmap> /*label*/
fields = readLabelBitMapsInRange(searcher, currentRange);
updateFields(updates, fields);
Document document = new Document();
format.addRangeValuesField(document, currentRange);
for (Map.Entry<Long, Bitmap> /*label*/
field : fields.entrySet()) {
// one field per label
Bitmap value = field.getValue();
if (value.hasContent()) {
format.addLabelAndSearchFields(document, field.getKey(), value);
}
}
if (isEmpty(document)) {
partition.getIndexWriter().deleteDocuments(format.rangeTerm(document));
} else {
partition.getIndexWriter().updateDocument(format.rangeTerm(document), document);
}
updates.clear();
}
}
use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class PartitionedIndexWriter method unsafeGetIndexWriter.
private IndexWriter unsafeGetIndexWriter(int numDocs) throws IOException {
List<AbstractIndexPartition> indexPartitions = index.getPartitions();
int size = indexPartitions.size();
// noinspection ForLoopReplaceableByForEach
for (int i = 0; i < size; i++) {
// We should find the *first* writable partition, so we can fill holes left by index deletes,
// after they were merged away:
AbstractIndexPartition partition = indexPartitions.get(i);
if (writablePartition(partition, numDocs)) {
return partition.getIndexWriter();
}
}
AbstractIndexPartition indexPartition = index.addNewPartition();
return indexPartition.getIndexWriter();
}
Aggregations