use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class AwaitIndexProcedureTest method setup.
@BeforeEach
void setup() throws LabelNotFoundKernelException, PropertyKeyIdNotFoundKernelException {
final int labelId = 0;
final int propId = 0;
LabelSchemaDescriptor anyDescriptor = SchemaDescriptor.forLabel(labelId, propId);
anyIndex = forSchema(anyDescriptor).withName("index").materialise(13);
KernelTransaction transaction = mock(KernelTransaction.class);
schemaRead = mock(SchemaRead.class);
when(transaction.schemaRead()).thenReturn(schemaRead);
TokenRead tokenRead = mock(TokenRead.class);
when(tokenRead.nodeLabelName(labelId)).thenReturn("label_0");
when(tokenRead.propertyKeyName(propId)).thenReturn("prop_0");
when(tokenRead.labelGetName(labelId)).thenReturn("label_0");
when(tokenRead.propertyKeyGetName(propId)).thenReturn("prop_0");
when(transaction.tokenRead()).thenReturn(tokenRead);
procedure = new IndexProcedures(transaction, null);
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class GraphCountsSection method indexes.
private static List<Map<String, Object>> indexes(TokenRead tokens, SchemaRead schemaRead, Anonymizer anonymizer) throws IndexNotFoundKernelException {
List<Map<String, Object>> indexes = new ArrayList<>();
Iterator<IndexDescriptor> iterator = schemaRead.indexesGetAll();
while (iterator.hasNext()) {
IndexDescriptor index = iterator.next();
IndexType indexType = index.getIndexType();
if (indexType == IndexType.FULLTEXT) {
/* For full text indexes, we currently do not return its options, which makes returning information on
* this index not useful and if the index type is ignored, this would even be misleading.
*/
continue;
}
EntityType entityType = index.schema().entityType();
Map<String, Object> data = new HashMap<>();
switch(entityType) {
case NODE:
data.put("labels", map(index.schema().getEntityTokenIds(), id -> anonymizer.label(tokens.labelGetName(id), id)));
break;
case RELATIONSHIP:
data.put("relationshipTypes", map(index.schema().getEntityTokenIds(), id -> anonymizer.relationshipType(tokens.relationshipTypeGetName(id), id)));
break;
default:
}
data.put("properties", map(index.schema().getPropertyIds(), id -> anonymizer.propertyKey(tokens.propertyKeyGetName(id), id)));
var indexSample = schemaRead.indexSample(index);
data.put("totalSize", indexSample.indexSize());
data.put("updatesSinceEstimation", indexSample.updates());
data.put("estimatedUniqueSize", indexSample.uniqueValues());
data.put("indexType", indexType.name());
indexes.add(data);
}
return indexes;
}
Aggregations