G - A vendor specific implementation of a Tinkerpop Graph.public abstract class AbstractGraknGraph<G extends org.apache.tinkerpop.gremlin.structure.Graph> extends Object implements GraknGraph, GraknAdmin
The Grakn Graph Base Implementation
This defines how a grakn graph sits on top of a Tinkerpop Graph.
It mostly act as a construction object which ensure the resulting graph conforms to the Grakn Object model.
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
LOG |
| Constructor and Description |
|---|
AbstractGraknGraph(G graph,
String keyspace,
String engine,
boolean batchLoadingEnabled) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Reverts any changes done to the graph and closes the transaction.
|
GraknAdmin |
admin()
Returns access to the low-level details of the graph via GraknAdmin
|
<T extends Concept> |
buildConcept(org.apache.tinkerpop.gremlin.structure.Vertex vertex) |
void |
clear()
Clears the graph completely.
|
void |
clear(ConceptCache conceptCache)
Clears the graph and empties the provided cache.
|
protected void |
clearGraph() |
void |
close()
Closes the current transaction.
|
void |
commit()
Commits any changes to the graph and closes the transaction.
|
void |
commit(java.util.function.BiConsumer<Set<org.javatuples.Pair<String,ConceptId>>,Set<org.javatuples.Pair<String,ConceptId>>> conceptLogger) |
void |
commit(ConceptCache conceptCache)
Commits the graph and adds concepts for post processing directly to the cache bypassing the REST API.
|
void |
commitNoLogs()
Commits to the graph without submitting any commit logs.
|
boolean |
fixDuplicateCastings(String index,
Set<ConceptId> castingVertexIds)
Merges the provided duplicate castings.
|
boolean |
fixDuplicateResources(String index,
Set<ConceptId> resourceVertexIds)
Merges the provided duplicate resources
|
<T extends Concept> |
getConcept(ConceptId id)
Get the
Concept with identifier provided, if it exists. |
<T extends Concept> |
getConcept(Schema.ConceptProperty key,
String value) |
<T extends Concept> |
getConceptRawId(Object id)
Looks up concept by using id against vertex ids.
|
EntityType |
getEntityType(String label)
Get the Entity Type with the label provided, if it exists.
|
String |
getKeyspace()
Utility function to get the name of the keyspace where the graph is persisted.
|
Type |
getMetaConcept()
Get the root of all Types.
|
EntityType |
getMetaEntityType()
Get the root of all the Entity Types.
|
RelationType |
getMetaRelationType()
Get the root of all Relation Types.
|
ResourceType |
getMetaResourceType()
Get the root of all the Resource Types.
|
RoleType |
getMetaRoleType()
Get the root of all the Role Types.
|
RuleType |
getMetaRuleConstraint()
Get the root of all constraint rules.
|
RuleType |
getMetaRuleInference()
Get the root of all inference rules.
|
RuleType |
getMetaRuleType()
Get the root of all Rule Types;
|
RelationType |
getRelationType(String label)
Get the Relation Type with the label provided, if it exists.
|
<V> Collection<Resource<V>> |
getResourcesByValue(V value)
Get all Resources holding the value provided, if they exist.
|
<V> ResourceType<V> |
getResourceType(String label)
Get the Resource Type with the label provided, if it exists.
|
RoleType |
getRoleType(String label)
Get the Role Type with the label provided, if it exists.
|
RuleType |
getRuleType(String label)
Get the Rule Type with the label provided, if it exists.
|
G |
getTinkerPopGraph() |
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex,org.apache.tinkerpop.gremlin.structure.Vertex> |
getTinkerTraversal()
Utility function to get a read-only Tinkerpop traversal.
|
<T extends Type> |
getType(TypeLabel label)
Get the
Type with the label provided, if it exists. |
QueryBuilder |
graql()
Returns a QueryBuilder
|
boolean |
implicitConceptsVisible()
Utility function to specify whether implicit concepts should be exposed.
|
boolean |
isBatchLoadingEnabled()
A flag to check if batch loading is enabled and consistency checks are switched off
|
boolean |
isClosed()
Utility function to determine whether the graph has been closed.
|
abstract boolean |
isConceptModified(ai.grakn.graph.internal.ConceptImpl concept) |
abstract boolean |
isConnectionClosed() |
boolean |
isReadOnly()
Utility function used to check if the current transaction on the graph is a read only transaction
|
abstract int |
numOpenTx() |
void |
openTransaction(GraknTxType txType)
Opens the thread bound transaction
|
EntityType |
putEntityType(String label)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label. |
EntityType |
putEntityType(TypeLabel label)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label. |
RelationType |
putRelationType(String label)
Create a
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified label. |
RelationType |
putRelationType(TypeLabel label)
Create a
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified label. |
<V> ResourceType<V> |
putResourceType(String label,
ResourceType.DataType<V> dataType)
Create a new non-unique
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type. |
<V> ResourceType<V> |
putResourceType(TypeLabel label,
ResourceType.DataType<V> dataType)
Create a new non-unique
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type. |
RoleType |
putRoleType(String label)
|
RoleType |
putRoleType(TypeLabel label)
|
RuleType |
putRuleType(String label)
|
RuleType |
putRuleType(TypeLabel label)
|
void |
showImplicitConcepts(boolean flag)
Utility function to specify whether implicit and system-generated types should be returned.
|
void |
updateTypeCounts(Map<TypeLabel,Long> typeCounts)
Updates the counts of all the types
|
void |
validVertex(org.apache.tinkerpop.gremlin.structure.Vertex vertex) |
public abstract boolean isConceptModified(ai.grakn.graph.internal.ConceptImpl concept)
concept - A concept in the graphpublic abstract int numOpenTx()
public void openTransaction(GraknTxType txType)
public String getKeyspace()
GraknGraphgetKeyspace in interface GraknGraphpublic boolean isClosed()
GraknGraphisClosed in interface GraknGraphpublic abstract boolean isConnectionClosed()
public boolean implicitConceptsVisible()
GraknGraphimplicitConceptsVisible in interface GraknGraphpublic boolean isReadOnly()
GraknGraphisReadOnly in interface GraknGraphpublic void showImplicitConcepts(boolean flag)
GraknGraphshowImplicitConcepts in interface GraknGraphflag - Specifies if implicit and system-generated types should be returned.public GraknAdmin admin()
GraknGraphadmin in interface GraknGraphGraknAdminpublic <T extends Concept> T buildConcept(org.apache.tinkerpop.gremlin.structure.Vertex vertex)
buildConcept in interface GraknAdminT - The type of the concept being builtvertex - A vertex which contains properties necessary to build a concept from.public boolean isBatchLoadingEnabled()
GraknAdminisBatchLoadingEnabled in interface GraknAdminpublic G getTinkerPopGraph()
public org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex,org.apache.tinkerpop.gremlin.structure.Vertex> getTinkerTraversal()
GraknAdmingetTinkerTraversal in interface GraknAdminpublic QueryBuilder graql()
GraknGraphgraql in interface GraknGraphQueryBuilderpublic <T extends Concept> T getConcept(Schema.ConceptProperty key, String value)
getConcept in interface GraknAdminkey - The concept property tp search by.value - The value of the conceptpublic EntityType putEntityType(String label)
GraknGraphEntityType with super-type entity, or return a pre-existing EntityType,
with the specified label.putEntityType in interface GraknGraphlabel - A unique label for the EntityTypeEntityType with the provided labelpublic EntityType putEntityType(TypeLabel label)
GraknGraphEntityType with super-type entity, or return a pre-existing EntityType,
with the specified label.putEntityType in interface GraknGraphlabel - A unique label for the EntityTypeEntityType with the provided labelpublic RelationType putRelationType(String label)
GraknGraphRelationType with super-type relation, or return a pre-existing RelationType,
with the specified label.putRelationType in interface GraknGraphlabel - A unique label for the RelationTypeRelationType with the provided label.public RelationType putRelationType(TypeLabel label)
GraknGraphRelationType with super-type relation, or return a pre-existing RelationType,
with the specified label.putRelationType in interface GraknGraphlabel - A unique label for the RelationTypeRelationType with the provided label.public RoleType putRoleType(String label)
GraknGraphRoleType with super-type role, or return a pre-existing RoleType, with the
specified label.putRoleType in interface GraknGraphlabel - A unique label for the RoleTypeRoleType with the provided Id.public RoleType putRoleType(TypeLabel label)
GraknGraphRoleType with super-type role, or return a pre-existing RoleType, with the
specified label.putRoleType in interface GraknGraphlabel - A unique label for the RoleTypeRoleType with the provided Id.public <V> ResourceType<V> putResourceType(String label, ResourceType.DataType<V> dataType)
GraknGraphResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type.putResourceType in interface GraknGraphV - The data type of the resource type. Supported types include: String, Long, Double, Boolean.
This should match the parameter typelabel - A unique label for the ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided label and data type.public <V> ResourceType<V> putResourceType(TypeLabel label, ResourceType.DataType<V> dataType)
GraknGraphResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type.putResourceType in interface GraknGraphV - The data type of the resource type. Supported types include: String, Long, Double, Boolean.
This should match the parameter typelabel - A unique label for the ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided label and data type.public RuleType putRuleType(String label)
GraknGraphRuleType with super-type rule, or return a pre-existing RuleType, with the
specified label.putRuleType in interface GraknGraphlabel - A unique label for the RuleTypeRuleType with the provided label.public RuleType putRuleType(TypeLabel label)
GraknGraphRuleType with super-type rule, or return a pre-existing RuleType, with the
specified label.putRuleType in interface GraknGraphlabel - A unique label for the RuleTypeRuleType with the provided label.public <T extends Concept> T getConceptRawId(Object id)
id - The id of the concept which should match the vertex idpublic <T extends Concept> T getConcept(ConceptId id)
GraknGraphConcept with identifier provided, if it exists.getConcept in interface GraknGraphid - A unique identifier for the Concept in the graph.Concept with the provided id or null if no such Concept exists.public <V> Collection<Resource<V>> getResourcesByValue(V value)
GraknGraphgetResourcesByValue in interface GraknGraphV - The data type of the value. Supported types include: String, Long, Double, and Boolean.value - A value which a Resource in the graph may be holding.public <T extends Type> T getType(TypeLabel label)
GraknGraphType with the label provided, if it exists.getType in interface GraknGraphlabel - A unique label which identifies the Type in the graph.Type with the provided label or null if no such Type exists.public EntityType getEntityType(String label)
GraknGraphgetEntityType in interface GraknGraphlabel - A unique label which identifies the Entity Type in the graph.public RelationType getRelationType(String label)
GraknGraphgetRelationType in interface GraknGraphlabel - A unique label which identifies the Relation Type in the graph.public <V> ResourceType<V> getResourceType(String label)
GraknGraphgetResourceType in interface GraknGraphV - The data type of the value. Supported types include: String, Long, Double, and Boolean.label - A unique label which identifies the Resource Type in the graph.public RoleType getRoleType(String label)
GraknGraphgetRoleType in interface GraknGraphlabel - A unique label which identifies the Role Type in the graph.public RuleType getRuleType(String label)
GraknGraphgetRuleType in interface GraknGraphlabel - A unique label which identifies the Rule Type in the graph.public Type getMetaConcept()
GraknAdmingetMetaConcept in interface GraknAdminpublic RelationType getMetaRelationType()
GraknAdmingetMetaRelationType in interface GraknAdminpublic RoleType getMetaRoleType()
GraknAdmingetMetaRoleType in interface GraknAdminpublic ResourceType getMetaResourceType()
GraknAdmingetMetaResourceType in interface GraknAdminpublic EntityType getMetaEntityType()
GraknAdmingetMetaEntityType in interface GraknAdminpublic RuleType getMetaRuleType()
GraknAdmingetMetaRuleType in interface GraknAdminpublic RuleType getMetaRuleInference()
GraknAdmingetMetaRuleInference in interface GraknAdminpublic RuleType getMetaRuleConstraint()
GraknAdmingetMetaRuleConstraint in interface GraknAdminpublic void clear()
clear in interface GraknGraphpublic void clear(ConceptCache conceptCache)
GraknAdminclear in interface GraknAdminconceptCache - The concept Cache to store concepts in for processing laterprotected void clearGraph()
public void close()
GraknGraphGraknSession to
get a new open transaction.close in interface GraknGraphclose in interface AutoCloseablepublic void abort()
GraknGraphGraknSession to
get a new open transaction.abort in interface GraknGraphpublic void commit()
throws GraknValidationException
GraknGraphGraknSession to
get a new open transaction.commit in interface GraknGraphGraknValidationException - when the transaction contains graph mutations which does not conform to the Grakn
knowledge model.public void commit(ConceptCache conceptCache) throws GraknValidationException
commit in interface GraknAdminconceptCache - The concept Cache to store concepts in for processing laterGraknValidationException - when the graph does not conform to the object conceptpublic void commitNoLogs()
throws GraknValidationException
commitNoLogs in interface GraknAdminGraknValidationException - when the graph does not conform to the object conceptpublic void commit(java.util.function.BiConsumer<Set<org.javatuples.Pair<String,ConceptId>>,Set<org.javatuples.Pair<String,ConceptId>>> conceptLogger) throws GraknValidationException
GraknValidationExceptionpublic void validVertex(org.apache.tinkerpop.gremlin.structure.Vertex vertex)
public boolean fixDuplicateCastings(String index, Set<ConceptId> castingVertexIds)
fixDuplicateCastings in interface GraknAdmincastingVertexIds - The vertex Ids of the duplicate castingspublic boolean fixDuplicateResources(String index, Set<ConceptId> resourceVertexIds)
GraknAdminfixDuplicateResources in interface GraknAdminresourceVertexIds - The resource vertex ids which need to be merged.public void updateTypeCounts(Map<TypeLabel,Long> typeCounts)
GraknAdminupdateTypeCounts in interface GraknAdmintypeCounts - The types and the changes to put on their countsCopyright © 2017 Grakn Labs Ltd. All rights reserved.