use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexIT method shouldNotListIndexesAmongConstraintIndexes.
@Test
public void shouldNotListIndexesAmongConstraintIndexes() throws Exception {
// given
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
commit();
// then/when
ReadOperations readOperations = readOperationsInNewTransaction();
assertFalse(readOperations.uniqueIndexesGetAll().hasNext());
assertFalse(readOperations.uniqueIndexesGetForLabel(labelId).hasNext());
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexIT method rollBackIndexRuleShouldNotBeCommitted.
@Test
public void rollBackIndexRuleShouldNotBeCommitted() throws Exception {
// GIVEN
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
// WHEN
schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
// don't mark as success
rollback();
// THEN
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(emptySetOf(NewIndexDescriptor.class), asSet(readOperations.indexesGetForLabel(labelId)));
commit();
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexIT method shouldRemoveAConstraintIndexWithoutOwnerInRecovery.
@Test
public void shouldRemoveAConstraintIndexWithoutOwnerInRecovery() throws Exception {
// given
PropertyAccessor propertyAccessor = mock(PropertyAccessor.class);
ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, propertyAccessor, false);
creator.createConstraintIndex(SchemaBoundary.map(descriptor));
// when
restartDb();
// then
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(emptySetOf(NewIndexDescriptor.class), asSet(readOperations.indexesGetForLabel(labelId)));
commit();
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexCRUDIT method addingALabelToPreExistingNodeShouldGetIndexed.
@Test
public void addingALabelToPreExistingNodeShouldGetIndexed() throws Exception {
// GIVEN
String indexProperty = "indexProperty";
GatheringIndexWriter writer = newWriter();
createIndex(db, myLabel, indexProperty);
// WHEN
String otherProperty = "otherProperty";
int value = 12;
int otherValue = 17;
Node node = createNode(map(indexProperty, value, otherProperty, otherValue));
// THEN
assertThat(writer.updatesCommitted.size(), equalTo(0));
// AND WHEN
try (Transaction tx = db.beginTx()) {
node.addLabel(myLabel);
tx.success();
}
// THEN
try (Transaction tx = db.beginTx()) {
ReadOperations readOperations = ctxSupplier.get().readOperations();
int propertyKey1 = readOperations.propertyKeyGetForName(indexProperty);
int label = readOperations.labelGetForName(myLabel.name());
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(label, propertyKey1);
assertThat(writer.updatesCommitted, equalTo(asSet(IndexEntryUpdate.add(node.getId(), descriptor, value))));
tx.success();
}
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class GraphDbStructureGuide method showStructure.
private void showStructure(Statement statement, DbStructureVisitor visitor) {
ReadOperations read = statement.readOperations();
try {
showTokens(visitor, read);
showSchema(visitor, read);
showStatistics(visitor, read);
} catch (KernelException e) {
throw new IllegalStateException("Kernel exception when traversing database schema structure and statistics. This is not expected to happen.", e);
}
}
Aggregations