@Override public ConceptId generate() { return ConceptId.of(gen(String.class)); } }
public static ConceptId convert(GrpcConcept.ConceptId id) { return ConceptId.of(id.getValue()); }
@Override public ConceptId visitId(GraqlParser.IdContext ctx) { return ConceptId.of(visitIdentifier(ctx.identifier())); }
private <X extends Concept> X getOrBuildConcept(VertexElement element, Function<VertexElement, X> conceptBuilder){ ConceptId conceptId = ConceptId.of(element.property(Schema.VertexProperty.ID)); return getOrBuildConcept(element, conceptId, conceptBuilder); }
@Override public ConceptId id() { return ConceptId.of(edge().id().getValue()); }
.map(v -> IdPredicate.create(v, ConceptId.of(PLACEHOLDER_ID), query)) .collect(Collectors.toSet());
private <X extends Concept> X getOrBuildConcept(EdgeElement element, Function<EdgeElement, X> conceptBuilder){ ConceptId conceptId = ConceptId.of(element.id().getValue()); return getOrBuildConcept(element, conceptId, conceptBuilder); }
@Override public void safeMap(final Vertex vertex, final MapEmitter<Serializable, Set<ConceptId>> emitter) { if (vertex.property((String) persistentProperties.get(CLUSTER_LABEL)).isPresent()) { String clusterPropertyKey = (String) persistentProperties.get(CLUSTER_LABEL); String clusterId = vertex.value(clusterPropertyKey); ConceptId conceptId = ConceptId.of(vertex.value(Schema.VertexProperty.ID.name())); Set<ConceptId> cluster = Collections.singleton(conceptId); emitter.emit(clusterId, cluster); } else { emitter.emit(NullObject.instance(), Collections.emptySet()); } }
@Override public void safeMap(final Vertex vertex, final MapEmitter<Serializable, Set<ConceptId>> emitter) { if (vertex.property((String) persistentProperties.get(DegreeVertexProgram.DEGREE)).isPresent() && vertexHasSelectedTypeId(vertex, selectedTypes)) { String degreePropertyKey = (String) persistentProperties.get(DegreeVertexProgram.DEGREE); Long centralityCount = vertex.value(degreePropertyKey); ConceptId conceptId = ConceptId.of(vertex.value(Schema.VertexProperty.ID.name())); emitter.emit(centralityCount, Collections.singleton(conceptId)); } else { emitter.emit(NullObject.instance(), Collections.emptySet()); } }
/** * The Graql compute path query run method * * @return a Answer containing the list of shortest paths */ private Stream<ConceptList> runComputePath() { ConceptId fromID = query.from().get(); ConceptId toID = query.to().get(); if (!scopeContainsInstances(fromID, toID)) throw GraqlQueryException.instanceDoesNotExist(); if (fromID.equals(toID)) return Stream.of(new ConceptList(ImmutableList.of(fromID))); Set<LabelId> scopedLabelIds = convertLabelsToIds(scopeTypeLabels()); ComputerResult result = compute(new ShortestPathVertexProgram(fromID, toID), null, scopedLabelIds); Multimap<ConceptId, ConceptId> pathsAsEdgeList = HashMultimap.create(); Map<String, Set<String>> resultFromMemory = result.memory().get(ShortestPathVertexProgram.SHORTEST_PATH); resultFromMemory.forEach((id, idSet) -> idSet.forEach(id2 -> { pathsAsEdgeList.put(ConceptId.of(id), ConceptId.of(id2)); })); List<List<ConceptId>> paths; if (!resultFromMemory.isEmpty()) { paths = getComputePathResultList(pathsAsEdgeList, fromID); if (scopeIncludesAttributes()) { paths = getComputePathResultListIncludingImplicitRelations(paths); } } else { paths = Collections.emptyList(); } return paths.stream().map(ConceptList::new); }
public Entity entity(OWLNamedIndividual individual) { String id = namer.individualEntityName(individual.getIRI()); Entity entity = tx.getConcept(ConceptId.of(id)); if (entity != null) { return entity; } OWLClass owlclass = eval(() -> { Optional<OWLClassAssertionAxiom> expr = ontology .classAssertionAxioms(individual) .filter(ax -> ax.getClassExpression().isOWLClass()) .findFirst(); return expr.isPresent() ? expr.get().getClassExpression().asOWLClass() : null; }); return putEntity(id, owlclass == null ? owlThingEntityType() : entityType(owlclass)); }
public <X extends Concept> X buildConcept(EdgeElement edgeElement){ Schema.EdgeLabel label = Schema.EdgeLabel.valueOf(edgeElement.label().toUpperCase(Locale.getDefault())); ConceptId conceptId = ConceptId.of(edgeElement.id().getValue()); if(!tx.txCache().isConceptCached(conceptId)){ Concept concept; switch (label) { case ATTRIBUTE: concept = RelationshipImpl.create(RelationshipEdge.get(edgeElement)); break; default: throw GraknTxOperationException.unknownConcept(label.name()); } tx.txCache().cacheConcept(concept); } return tx.txCache().getCachedConcept(conceptId); }
public static Concept of(ConceptProto.Concept concept, Grakn.Transaction tx) { ConceptId id = ConceptId.of(concept.getId()); switch (concept.getBaseType()) { case ENTITY: return RemoteEntity.construct(tx, id); case RELATION: return RemoteRelationship.construct(tx, id); case ATTRIBUTE: return RemoteAttribute.construct(tx, id); case ENTITY_TYPE: return RemoteEntityType.construct(tx, id); case RELATION_TYPE: return RemoteRelationshipType.construct(tx, id); case ATTRIBUTE_TYPE: return RemoteAttributeType.construct(tx, id); case ROLE: return RemoteRole.construct(tx, id); case RULE: return RemoteRule.construct(tx, id); case META_TYPE: return RemoteMetaType.construct(tx, id); default: case UNRECOGNIZED: throw new IllegalArgumentException("Unrecognised " + concept); } }
private Concept convert(GrpcConcept.Concept concept) { ConceptId id = ConceptId.of(concept.getId().getValue()); switch (concept.getBaseType()) { case Entity: return RemoteConcepts.createEntity(this, id); case Relationship: return RemoteConcepts.createRelationship(this, id); case Attribute: return RemoteConcepts.createAttribute(this, id); case EntityType: return RemoteConcepts.createEntityType(this, id); case RelationshipType: return RemoteConcepts.createRelationshipType(this, id); case AttributeType: return RemoteConcepts.createAttributeType(this, id); case Role: return RemoteConcepts.createRole(this, id); case Rule: return RemoteConcepts.createRule(this, id); case MetaType: return RemoteConcepts.createMetaType(this, id); default: case UNRECOGNIZED: throw new IllegalArgumentException("Unrecognised " + concept); } } }
ConceptId conceptId = ConceptId.of(vertexElement.property(Schema.VertexProperty.ID)); if(!tx.txCache().isConceptCached(conceptId)){ Concept concept;