use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class KernelTransactionImplementation method dropCreatedConstraintIndexes.
private void dropCreatedConstraintIndexes() throws TransactionFailureException {
if (hasTxStateWithChanges()) {
Iterator<IndexDescriptor> createdIndexIds = txState().constraintIndexesCreatedInTx();
while (createdIndexIds.hasNext()) {
IndexDescriptor createdIndex = createdIndexIds.next();
constraintIndexCreator.dropUniquenessConstraintIndex(createdIndex);
}
}
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class IndexMap method putIndexProxy.
public void putIndexProxy(IndexProxy indexProxy) {
IndexDescriptor index = indexProxy.getDescriptor();
Preconditions.checkState(!indexesById.contains(index.getId()), "Trying to overwrite index %d in IndexMap", index.getId());
indexesById.put(index.getId(), indexProxy);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class DeferredConflictCheckingIndexUpdaterTest method shouldQueryAboutAddedAndChangedValueTuples.
@Test
void shouldQueryAboutAddedAndChangedValueTuples() throws Exception {
// given
IndexUpdater actual = mock(IndexUpdater.class);
ValueIndexReader reader = mock(ValueIndexReader.class);
doAnswer(new NodeIdsIndexReaderQueryAnswer(descriptor, 0)).when(reader).query(any(), any(), any(), any(), any());
long nodeId = 0;
List<ValueIndexEntryUpdate<IndexDescriptor>> updates = new ArrayList<>();
updates.add(add(nodeId++, descriptor, tuple(10, 11)));
updates.add(change(nodeId++, descriptor, tuple("abc", "def"), tuple("ghi", "klm")));
updates.add(remove(nodeId++, descriptor, tuple(1001L, 1002L)));
updates.add(change(nodeId++, descriptor, tuple((byte) 2, (byte) 3), tuple((byte) 4, (byte) 5)));
updates.add(add(nodeId, descriptor, tuple(5, "5")));
try (DeferredConflictCheckingIndexUpdater updater = new DeferredConflictCheckingIndexUpdater(actual, () -> reader, descriptor, NULL)) {
// when
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
updater.process(update);
verify(actual).process(update);
}
}
// then
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
if (update.updateMode() == UpdateMode.ADDED || update.updateMode() == UpdateMode.CHANGED) {
Value[] tuple = update.values();
PropertyIndexQuery[] query = new PropertyIndexQuery[tuple.length];
for (int i = 0; i < tuple.length; i++) {
query[i] = PropertyIndexQuery.exact(propertyKeyIds[i], tuple[i]);
}
verify(reader).query(any(), any(), any(), eq(query[0]), eq(query[1]));
}
}
verify(reader).close();
verifyNoMoreInteractions(reader);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class BuiltInProceduresTest method givenIndex.
private void givenIndex(String label, String propKey) {
int labelId = token(label, labels);
int propId = token(propKey, propKeys);
int id = indexes.size() + 1000;
Map<String, Value> configMap = new HashMap<>();
configMap.put("config1", Values.stringValue("value1"));
configMap.put("config2", Values.intValue(2));
configMap.put("config3", Values.booleanValue(true));
LabelSchemaDescriptor schema = forLabel(labelId, propId);
IndexDescriptor index = IndexPrototype.forSchema(schema, EMPTY.getProviderDescriptor()).withName("index_" + id).materialise(id).withIndexConfig(IndexConfig.with(configMap));
indexes.add(index);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class BuiltInProceduresTest method setup.
@BeforeEach
void setup() throws Exception {
procs.registerComponent(KernelTransaction.class, ctx -> ctx.internalTransaction().kernelTransaction(), false);
procs.registerComponent(DependencyResolver.class, Context::dependencyResolver, false);
procs.registerComponent(GraphDatabaseAPI.class, Context::graphDatabaseAPI, false);
procs.registerComponent(Transaction.class, Context::internalTransaction, true);
procs.registerComponent(SecurityContext.class, Context::securityContext, true);
procs.registerComponent(ProcedureCallContext.class, Context::procedureCallContext, true);
procs.registerComponent(SystemGraphComponents.class, ctx -> systemGraphComponents, false);
procs.registerComponent(Log.class, ctx -> log, false);
procs.registerType(Node.class, NTNode);
procs.registerType(Relationship.class, NTRelationship);
procs.registerType(Path.class, NTPath);
new SpecialBuiltInProcedures("1.3.37", Edition.COMMUNITY.toString()).accept(procs);
procs.registerProcedure(BuiltInProcedures.class);
procs.registerProcedure(BuiltInDbmsProcedures.class);
when(transaction.kernelTransaction()).thenReturn(tx);
when(tx.tokenRead()).thenReturn(tokens);
when(tx.dataRead()).thenReturn(read);
when(tx.schemaRead()).thenReturn(schemaRead);
when(tx.securityContext()).thenReturn(SecurityContext.AUTH_DISABLED);
when(callContext.isCalledFromCypher()).thenReturn(false);
when(schemaRead.snapshot()).thenReturn(schemaReadCore);
when(tokens.propertyKeyGetAllTokens()).thenAnswer(asTokens(propKeys));
when(tokens.labelsGetAllTokens()).thenAnswer(asTokens(labels));
when(tokens.relationshipTypesGetAllTokens()).thenAnswer(asTokens(relTypes));
when(schemaReadCore.indexesGetAll()).thenAnswer(i -> Iterators.concat(indexes.iterator(), uniqueIndexes.iterator()));
when(schemaReadCore.index(any(SchemaDescriptor.class))).thenAnswer((Answer<IndexDescriptor>) invocationOnMock -> {
SchemaDescriptor schema = invocationOnMock.getArgument(0);
return getIndexReference(schema);
});
when(schemaReadCore.constraintsGetAll()).thenAnswer(i -> constraints.iterator());
when(tokens.propertyKeyName(anyInt())).thenAnswer(invocation -> propKeys.get(invocation.getArgument(0)));
when(tokens.nodeLabelName(anyInt())).thenAnswer(invocation -> labels.get(invocation.getArgument(0)));
when(tokens.relationshipTypeName(anyInt())).thenAnswer(invocation -> relTypes.get(invocation.getArgument(0)));
when(tokens.propertyKeyGetName(anyInt())).thenAnswer(invocation -> propKeys.get(invocation.getArgument(0)));
when(tokens.labelGetName(anyInt())).thenAnswer(invocation -> labels.get(invocation.getArgument(0)));
when(tokens.relationshipTypeGetName(anyInt())).thenAnswer(invocation -> relTypes.get(invocation.getArgument(0)));
when(tokens.entityTokensGetNames(any(), any())).then(invocation -> {
EntityType type = invocation.getArgument(0);
int[] ids = invocation.getArgument(1);
Map<Integer, String> mapping = type == EntityType.NODE ? labels : relTypes;
return Arrays.stream(ids).mapToObj(mapping::get).toArray(String[]::new);
});
when(schemaReadCore.constraintsGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
when(schemaReadCore.indexesGetForLabel(anyInt())).thenReturn(emptyIterator());
when(schemaReadCore.indexesGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
when(schemaReadCore.constraintsGetForLabel(anyInt())).thenReturn(emptyIterator());
when(read.countsForNode(anyInt())).thenReturn(1L);
when(read.countsForRelationship(anyInt(), anyInt(), anyInt())).thenReturn(1L);
when(schemaReadCore.indexGetState(any(IndexDescriptor.class))).thenReturn(InternalIndexState.ONLINE);
}
Aggregations