Ejemplo n.º 1
0
 private void showNodeCounts(ReadOperations read, DbStructureVisitor visitor) {
   visitor.visitAllNodesCount(read.countsForNode(ANY_LABEL));
   for (Label label : glops.getAllLabels()) {
     int labelId = read.labelGetForName(label.name());
     visitor.visitNodeCount(labelId, label.name(), read.countsForNode(labelId));
   }
 }
Ejemplo n.º 2
0
  private void showRelCounts(ReadOperations read, DbStructureVisitor visitor) {
    // all wildcards
    noSide(read, visitor, WILDCARD_REL_TYPE, ANY_RELATIONSHIP_TYPE);

    // one label only
    for (Label label : glops.getAllLabels()) {
      int labelId = read.labelGetForName(label.name());

      leftSide(read, visitor, label, labelId, WILDCARD_REL_TYPE, ANY_RELATIONSHIP_TYPE);
      rightSide(read, visitor, label, labelId, WILDCARD_REL_TYPE, ANY_RELATIONSHIP_TYPE);
    }

    // fixed rel type
    for (RelationshipType relType : glops.getAllRelationshipTypes()) {
      int relTypeId = read.relationshipTypeGetForName(relType.name());
      noSide(read, visitor, relType, relTypeId);

      for (Label label : glops.getAllLabels()) {
        int labelId = read.labelGetForName(label.name());

        // wildcard on right
        leftSide(read, visitor, label, labelId, relType, relTypeId);

        // wildcard on left
        rightSide(read, visitor, label, labelId, relType, relTypeId);
      }
    }
  }
Ejemplo n.º 3
0
 private void showIndices(
     DbStructureVisitor visitor, ReadOperations read, TokenNameLookup nameLookup)
     throws IndexNotFoundKernelException {
   Iterator<IndexDescriptor> indexDescriptors = read.indexesGetAll();
   while (indexDescriptors.hasNext()) {
     IndexDescriptor descriptor = indexDescriptors.next();
     String userDescription = descriptor.userDescription(nameLookup);
     double uniqueValuesPercentage = read.indexUniqueValuesSelectivity(descriptor);
     visitor.visitIndex(descriptor, userDescription, uniqueValuesPercentage);
   }
 }
Ejemplo n.º 4
0
  private void noSide(
      ReadOperations read, DbStructureVisitor visitor, RelationshipType relType, int relTypeId) {
    String userDescription = format("MATCH ()-[%s]->() RETURN count(*)", colon(relType.name()));
    long amount = read.countsForRelationship(ANY_LABEL, relTypeId, ANY_LABEL);

    visitor.visitRelCount(ANY_LABEL, relTypeId, ANY_LABEL, userDescription, amount);
  }
Ejemplo n.º 5
0
 private void showUniqueConstraints(
     DbStructureVisitor visitor, ReadOperations read, TokenNameLookup nameLookup) {
   Iterator<UniquenessConstraint> constraints = read.constraintsGetAll();
   while (constraints.hasNext()) {
     UniquenessConstraint constraint = constraints.next();
     String userDescription = constraint.userDescription(nameLookup);
     visitor.visitUniqueConstraint(constraint, userDescription);
   }
 }
  public static void awaitIndexOnline(ReadOperations readOperations, IndexDescriptor indexRule)
      throws IndexNotFoundKernelException {
    long start = System.currentTimeMillis();
    while (true) {
      if (readOperations.indexGetState(indexRule) == InternalIndexState.ONLINE) {
        break;
      }

      if (start + 1000 * 10 < System.currentTimeMillis()) {
        throw new RuntimeException("Index didn't come online within a reasonable time.");
      }
    }
  }
Ejemplo n.º 7
0
 private void showLabels(ReadOperations read, DbStructureVisitor visitor) {
   for (Label label : glops.getAllLabels()) {
     int labelId = read.labelGetForName(label.name());
     visitor.visitLabel(labelId, label.name());
   }
 }
Ejemplo n.º 8
0
 private void showRelTypes(ReadOperations read, DbStructureVisitor visitor) {
   for (RelationshipType relType : glops.getAllRelationshipTypes()) {
     int relTypeId = read.relationshipTypeGetForName(relType.name());
     visitor.visitRelationshipType(relTypeId, relType.name());
   }
 }
Ejemplo n.º 9
0
 private void showPropertyKeys(ReadOperations read, DbStructureVisitor visitor) {
   for (String propertyKeyName : glops.getAllPropertyKeys()) {
     int propertyKeyId = read.propertyKeyGetForName(propertyKeyName);
     visitor.visitPropertyKey(propertyKeyId, propertyKeyName);
   }
 }