use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class SchemaStatementProcedureTest method schemaStatementsShouldHandleIndexWithBackticks.
@Test
void schemaStatementsShouldHandleIndexWithBackticks() throws IndexNotFoundKernelException, ProcedureException, LabelNotFoundKernelException, PropertyKeyIdNotFoundKernelException {
IndexDescriptor index = forSchema(forLabel(1, 1)).withName(NAME_WITH_BACKTICKS).materialise(1);
InternalIndexState internalIndexState = InternalIndexState.ONLINE;
SchemaReadCore schemaReadCore = getSchemaReadCore(index, internalIndexState);
TokenRead tokenRead = mock(TokenRead.class);
when(tokenRead.nodeLabelName(1)).thenReturn(LABEL_WITH_BACKTICKS);
when(tokenRead.propertyKeyName(1)).thenReturn(PROPERTY_KEY_WITH_BACKTICKS);
Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
Iterator<BuiltInProcedures.SchemaStatementResult> iter = result.iterator();
assertTrue(iter.hasNext());
BuiltInProcedures.SchemaStatementResult next = iter.next();
assertEquals(NAME_WITH_BACKTICKS, next.name);
assertEquals(format("CALL db.createIndex('%s', ['%s'], ['%s'], 'Undecided-0', {})", NAME_WITH_BACKTICKS, LABEL_WITH_BACKTICKS, PROPERTY_KEY_WITH_BACKTICKS), next.createStatement);
assertEquals(format("DROP INDEX %s", ESCAPED_NAME_WITH_BACKTICKS), next.dropStatement);
assertFalse(iter.hasNext());
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class SchemaStatementProcedureTest method schemaStatementsMustNotIncludeFailedIndexes.
@Test
void schemaStatementsMustNotIncludeFailedIndexes() throws IndexNotFoundKernelException, ProcedureException {
IndexDescriptor index = someIndex();
InternalIndexState indexState = InternalIndexState.FAILED;
SchemaReadCore schemaReadCore = getSchemaReadCore(index, indexState);
TokenRead tokenRead = mock(TokenRead.class);
Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
assertEquals(0, result.size());
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class KernelAPIParallelLabelScanStressIT method shouldDoParallelLabelScans.
@Test
void shouldDoParallelLabelScans() throws Throwable {
int[] labels = new int[3];
// Create nodes with labels
try (KernelTransaction tx = kernel.beginTransaction(EXPLICIT, LoginContext.AUTH_DISABLED)) {
labels[0] = createLabeledNodes(tx, N_NODES, "LABEL1");
labels[1] = createLabeledNodes(tx, N_NODES, "LABEL2");
labels[2] = createLabeledNodes(tx, N_NODES, "LABEL3");
tx.commit();
}
IndexDescriptor nodeLabelIndex;
try (KernelTransaction tx = kernel.beginTransaction(EXPLICIT, LoginContext.AUTH_DISABLED)) {
nodeLabelIndex = tx.schemaRead().index(SchemaDescriptor.forAnyEntityTokens(EntityType.NODE)).next();
tx.commit();
}
KernelAPIParallelStress.parallelStressInTx(kernel, N_THREADS, tx -> tx.cursors().allocateNodeLabelIndexCursor(tx.cursorContext()), (read, cursor) -> labelScan(read, cursor, nodeLabelIndex, labels[random.nextInt(labels.length)]));
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class RecordStorageReaderSchemaTest method shouldListAllIndexesForRelationshipTypeAtTimeOfSnapshot.
@Test
void shouldListAllIndexesForRelationshipTypeAtTimeOfSnapshot() throws Exception {
// Given
IndexDescriptor expectedIndex = createIndex(relType1, propertyKey);
createIndex(relType2, propertyKey);
// When
StorageSchemaReader snapshot = storageReader.schemaSnapshot();
Set<IndexDescriptor> indexes = asSet(snapshot.indexesGetForRelationshipType(relationshipTypeId(relType1)));
// Then
assertEquals(asSet(expectedIndex), indexes);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class RecordStorageReaderSchemaTest method shouldListAllIndexesForRelationshipType.
@Test
void shouldListAllIndexesForRelationshipType() throws Exception {
// Given
IndexDescriptor expectedIndex = createIndex(relType1, propertyKey);
createIndex(relType2, propertyKey);
// When
Set<IndexDescriptor> indexes = asSet(storageReader.indexesGetForRelationshipType(relationshipTypeId(relType1)));
// Then
assertEquals(asSet(expectedIndex), indexes);
}
Aggregations