use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldReturnEmptyIteratorWhenNoDocValuesInOrder.
@Test
void shouldReturnEmptyIteratorWhenNoDocValuesInOrder() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(false);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
// then
LongIterator valuesIterator = collector.getValuesSortedByRelevance("id");
assertFalse(valuesIterator.hasNext());
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class IndexingCompositeQueryAcceptanceTest method shouldConsiderEntitiesChangedInSameTxInIndexSeek.
@ParameterizedTest(name = "shouldConsiderEntitiesChangedInSameTxInIndexSeek using {0} with {1} index for {2}")
@MethodSource("data")
public void shouldConsiderEntitiesChangedInSameTxInIndexSeek(DataSet dataSet, IndexingMode withIndex, EntityControl entityControl) {
createIndex(withIndex, dataSet.keys, entityControl);
// GIVEN
createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.nonMatching[0]);
LongSet toChangeToMatch = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.nonMatching[1]);
LongSet toChangeToNotMatch = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.values);
MutableLongSet expected = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.values);
// WHEN
LongSet found;
try (Transaction tx = db.beginTx()) {
LongIterator toMatching = toChangeToMatch.longIterator();
while (toMatching.hasNext()) {
long id = toMatching.next();
entityControl.setProperties(tx, id, dataSet.keys, dataSet.values);
expected.add(id);
}
LongIterator toNotMatching = toChangeToNotMatch.longIterator();
while (toNotMatching.hasNext()) {
long id = toNotMatching.next();
entityControl.setProperties(tx, id, dataSet.keys, dataSet.nonMatching[2]);
expected.remove(id);
}
found = dataSet.indexSeek.findEntities(tx, dataSet.keys, dataSet.values, entityControl);
}
// THEN
assertThat(found).isEqualTo(expected);
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class AbstractLinearProbeLongHashSet method appendString.
@Override
public void appendString(Appendable appendable, String start, String separator, String end) {
try {
appendable.append(start);
appendable.append("offheap,size=").append(String.valueOf(size())).append("; ");
final LongIterator iterator = longIterator();
for (int i = 0; i < 100 && iterator.hasNext(); i++) {
appendable.append(Long.toString(iterator.next()));
if (iterator.hasNext()) {
appendable.append(", ");
}
}
if (iterator.hasNext()) {
appendable.append("...");
}
appendable.append(end);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class ImportLogic method prepareIdMapper.
/**
* Prepares {@link IdMapper} to be queried for ID --> nodeId lookups. This is required for running {@link #importRelationships()}.
*/
public void prepareIdMapper() {
if (idMapper.needsPreparation()) {
MemoryUsageStatsProvider memoryUsageStats = new MemoryUsageStatsProvider(neoStore, idMapper);
PropertyValueLookup inputIdLookup = new NodeInputIdPropertyLookup(neoStore.getTemporaryPropertyStore());
executeStage(new IdMapperPreparationStage(config, idMapper, inputIdLookup, badCollector, memoryUsageStats));
final LongIterator duplicateNodeIds = idMapper.leftOverDuplicateNodesIds();
if (duplicateNodeIds.hasNext()) {
executeStage(new DeleteDuplicateNodesStage(config, duplicateNodeIds, neoStore, storeUpdateMonitor, pageCacheTracer));
}
updatePeakMemoryUsage();
}
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class DatabaseManagementServiceImpl method findNodeForCreatedDatabaseInTransactionState.
private long findNodeForCreatedDatabaseInTransactionState(TransactionState txState, TokenHolders tokenHolders, String name) {
int databaseLabelTokenId = tokenHolders.labelTokens().getIdByName(DATABASE_LABEL.name());
int databaseNamePropertyKeyTokenId = tokenHolders.propertyKeyTokens().getIdByName(DATABASE_NAME_PROPERTY);
LongIterator addedNodes = txState.addedAndRemovedNodes().getAdded().longIterator();
while (addedNodes.hasNext()) {
long nodeId = addedNodes.next();
NodeState nodeState = txState.getNodeState(nodeId);
// The database name entered by user goes through the DatabaseNameValidator, which also makes the name lower-case.
// Use the same validator to end up with the same name to compare with.
String validatedName = DatabaseNameValidator.validateDatabaseNamePattern(name);
if (nodeState.labelDiffSets().isAdded(databaseLabelTokenId) && validatedName.equals(nodeState.propertyValue(databaseNamePropertyKeyTokenId).asObjectCopy().toString())) {
return nodeId;
}
}
throw new IllegalStateException("Couldn't find the node representing the created database '" + name + "'");
}
Aggregations