use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class BuiltInProcedures method indexDetails.
@Deprecated(since = "4.2.0", forRemoval = true)
@SystemProcedure
@Description("Detailed description of specific index.")
@Procedure(name = "db.indexDetails", mode = READ, deprecatedBy = "SHOW INDEXES YIELD * command")
public Stream<IndexDetailResult> indexDetails(@Name("indexName") String indexName) throws ProcedureException {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
TokenRead tokenRead = kernelTransaction.tokenRead();
IndexingService indexingService = resolver.resolveDependency(IndexingService.class);
SchemaReadCore schemaRead = kernelTransaction.schemaRead().snapshot();
List<IndexDescriptor> indexes = asList(schemaRead.indexesGetAll());
IndexDescriptor index = null;
for (IndexDescriptor candidate : indexes) {
if (candidate.getName().equals(indexName)) {
index = candidate;
break;
}
}
if (index == null) {
throw new ProcedureException(Status.Schema.IndexNotFound, "Could not find index with name \"" + indexName + "\"");
}
final IndexDetailResult indexDetailResult = asIndexDetails(tokenRead, schemaRead, index);
return Stream.of(indexDetailResult);
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class UniqueIndexSeekIT method lockNodeUsingUniqueIndexSeek.
private static void lockNodeUsingUniqueIndexSeek(GraphDatabaseAPI database, String nameProperty) throws KernelException {
try (Transaction transaction = database.beginTx()) {
KernelTransaction kernelTransaction = ((InternalTransaction) transaction).kernelTransaction();
TokenRead tokenRead = kernelTransaction.tokenRead();
Read dataRead = kernelTransaction.dataRead();
int propertyId = tokenRead.propertyKey(nameProperty);
IndexDescriptor indexReference = kernelTransaction.schemaRead().indexGetForName(CONSTRAINT_NAME);
try (NodeValueIndexCursor cursor = kernelTransaction.cursors().allocateNodeValueIndexCursor(kernelTransaction.cursorContext(), kernelTransaction.memoryTracker())) {
dataRead.lockingNodeUniqueIndexSeek(indexReference, cursor, PropertyIndexQuery.ExactPredicate.exact(propertyId, "value"));
}
transaction.commit();
}
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class TxStateTransactionDataSnapshot method takeSnapshot.
private void takeSnapshot(MemoryTracker memoryTracker) {
var cursorContext = transaction.cursorContext();
try (StorageNodeCursor node = store.allocateNodeCursor(cursorContext);
StoragePropertyCursor properties = store.allocatePropertyCursor(cursorContext, memoryTracker)) {
TokenRead tokenRead = transaction.tokenRead();
snapshotRemovedNodes(memoryTracker, node, properties, tokenRead);
snapshotRemovedRelationships(memoryTracker, properties, tokenRead);
snapshotModifiedNodes(memoryTracker, node, properties, tokenRead);
snapshotModifiedRelationships(memoryTracker, properties, tokenRead);
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("An entity that does not exist was modified.", e);
}
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class BatchInsertIndexTest method batchInserterShouldUseConfiguredIndexProvider.
@ParameterizedTest
@EnumSource(SchemaIndex.class)
void batchInserterShouldUseConfiguredIndexProvider(SchemaIndex schemaIndex) throws Exception {
configure(schemaIndex);
BatchInserter inserter = newBatchInserter();
inserter.createDeferredSchemaIndex(LABEL_ONE).on("key").create();
inserter.shutdown();
GraphDatabaseService db = startGraphDatabaseServiceAndAwaitIndexes();
try (Transaction tx = db.beginTx()) {
KernelTransaction kernelTransaction = ((InternalTransaction) tx).kernelTransaction();
TokenRead tokenRead = kernelTransaction.tokenRead();
SchemaRead schemaRead = kernelTransaction.schemaRead();
int labelId = tokenRead.nodeLabel(LABEL_ONE.name());
int propertyId = tokenRead.propertyKey("key");
IndexDescriptor index = single(schemaRead.index(SchemaDescriptor.forLabel(labelId, propertyId)));
assertTrue(schemaIndex.providerName().contains(index.getIndexProvider().getKey()), unexpectedIndexProviderMessage(index));
assertTrue(schemaIndex.providerName().contains(index.getIndexProvider().getVersion()), unexpectedIndexProviderMessage(index));
tx.commit();
}
}
use of org.neo4j.internal.kernel.api.TokenRead in project neo4j by neo4j.
the class SchemaImpl method getIndexes.
@Override
public Iterable<IndexDefinition> getIndexes(final Label label) {
transaction.assertOpen();
TokenRead tokenRead = transaction.tokenRead();
SchemaRead schemaRead = transaction.schemaRead();
List<IndexDefinition> definitions = new ArrayList<>();
int labelId = tokenRead.nodeLabel(label.name());
if (labelId == TokenRead.NO_TOKEN) {
return emptyList();
}
Iterator<IndexDescriptor> indexes = schemaRead.indexesGetForLabel(labelId);
addDefinitions(definitions, tokenRead, IndexDescriptor.sortByType(indexes));
return definitions;
}
Aggregations