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 |
|---|---|
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.
|
protected void |
clearGraph() |
void |
close()
Closes the current graph, rendering it unusable.
|
void |
closeGraph(String closedReason) |
void |
closePermanent() |
void |
commit()
Commits the graph
|
void |
commit(boolean submitLogs) |
protected void |
commitTx() |
void |
finaliseClose(Runnable closer,
String closedReason) |
boolean |
fixDuplicateCasting(Object castingId)
Merges duplicate castings if one is found.
|
boolean |
fixDuplicateResources(Set<Object> resourceIds) |
<T extends Concept> |
getConcept(Schema.ConceptProperty key,
String value) |
<T extends Concept> |
getConcept(String id)
Get the Concept with identifier provided, if it exists.
|
<T extends Concept> |
getConceptByBaseIdentifier(Object baseIdentifier) |
ConceptLog |
getConceptLog() |
Set<ai.grakn.graph.internal.ConceptImpl> |
getConcepts(Schema.ConceptProperty key,
Object value) |
ai.grakn.graph.internal.ElementFactory |
getElementFactory() |
EntityType |
getEntityType(String name)
Get the Entity Type with the name 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;
|
Relation |
getRelation(RelationType relationType,
Map<RoleType,Instance> roleMap)
Get a collection of Relations that match the specified Relation Type and role map, if it exists.
|
RelationType |
getRelationType(String name)
Get the Relation Type with the name provided, if it exists.
|
<V> Collection<Resource<V>> |
getResourcesByValue(V value)
Get the Resources holding the value provided, if they exist.
|
<V> ResourceType<V> |
getResourceType(String name)
Get the Resource Type with the name provided, if it exists.
|
RoleType |
getRoleType(String name)
Get the Role Type with the name provided, if it exists.
|
RuleType |
getRuleType(String name)
Get the Rule Type with the name 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.
|
Type |
getType(String name)
Get the Type with the name provided, if it exists.
|
QueryBuilder |
graql()
Returns a QueryBuilder
|
boolean |
hasCommitted() |
boolean |
implicitConceptsVisible()
Utility function to specify whether implicit concepts should be exposed.
|
boolean |
initialiseMetaConcepts() |
boolean |
isBatchLoadingEnabled() |
boolean |
isClosed()
Utility function to determine whether the graph has been closed.
|
EntityType |
putEntityType(String name)
Create a new Entity Type, or return a pre-existing Entity Type, with the specified name.
|
RelationType |
putRelationType(String name)
Create a Relation Type, or return a pre-existing Relation Type, with the specified name.
|
<V> ResourceType<V> |
putResourceType(String name,
ResourceType.DataType<V> dataType)
Create a Resource Type, or return a pre-existing Resource Type, with the specified name.
|
<V> ResourceType<V> |
putResourceTypeUnique(String name,
ResourceType.DataType<V> dataType)
Create a unique Resource Type, or return a pre-existing Resource Type, with the specified name.
|
RoleType |
putRoleType(String name)
Create a Role Type, or return a pre-existing Role Type, with the specified name.
|
RuleType |
putRuleType(String name)
Create a Rule Type, or return a pre-existing Rule Type, with the specified name.
|
void |
rollback()
Resets the current transaction without committing.
|
void |
showImplicitConcepts(boolean flag)
Utility function to specify whether implicit and system-generated types should be returned.
|
public String getKeyspace()
GraknGraphgetKeyspace in interface GraknGraphpublic boolean isClosed()
GraknGraphisClosed in interface GraknGraphpublic boolean implicitConceptsVisible()
GraknGraphimplicitConceptsVisible 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 hasCommitted()
public boolean isBatchLoadingEnabled()
public boolean initialiseMetaConcepts()
public 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 ai.grakn.graph.internal.ElementFactory getElementFactory()
public <T extends Concept> T getConcept(Schema.ConceptProperty key, String value)
public Set<ai.grakn.graph.internal.ConceptImpl> getConcepts(Schema.ConceptProperty key, Object value)
public ConceptLog getConceptLog()
public EntityType putEntityType(String name)
GraknGraphputEntityType in interface GraknGraphname - A unique name for the Entity Typepublic RelationType putRelationType(String name)
GraknGraphputRelationType in interface GraknGraphname - A unique name for the Relation Typepublic RoleType putRoleType(String name)
GraknGraphputRoleType in interface GraknGraphname - A unique name for the Role Typepublic <V> ResourceType<V> putResourceType(String name, ResourceType.DataType<V> dataType)
GraknGraphputResourceType in interface GraknGraphV - The data type of the resource type. Supported types include: String, Long, Double, Boolean.
This should match the parameter typename - A unique name for the Resource TypedataType - The data type of the resource type.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANpublic <V> ResourceType<V> putResourceTypeUnique(String name, ResourceType.DataType<V> dataType)
GraknGraphputResourceTypeUnique in interface GraknGraphV - The data type of the resource type. Supported types include: String, Long, Double, Boolean.
This should match the parameter typename - A unique name for the Resource TypedataType - The data type of the resource type.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANpublic RuleType putRuleType(String name)
GraknGraphputRuleType in interface GraknGraphname - A unique name for the Rule Typepublic <T extends Concept> T getConceptByBaseIdentifier(Object baseIdentifier)
public <T extends Concept> T getConcept(String id)
GraknGraphgetConcept in interface GraknGraphid - A unique identifier for the Concept in the graph.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 Type getType(String name)
GraknGraphgetType in interface GraknGraphname - A unique name which identifies the Type in the graph.public EntityType getEntityType(String name)
GraknGraphgetEntityType in interface GraknGraphname - A unique name which identifies the Entity Type in the graph.public RelationType getRelationType(String name)
GraknGraphgetRelationType in interface GraknGraphname - A unique name which identifies the Relation Type in the graph.public <V> ResourceType<V> getResourceType(String name)
GraknGraphgetResourceType in interface GraknGraphV - The data type of the value. Supported types include: String, Long, Double, and Boolean.name - A unique name which identifies the Resource Type in the graph.public RoleType getRoleType(String name)
GraknGraphgetRoleType in interface GraknGraphname - A unique name which identifies the Role Type in the graph.public RuleType getRuleType(String name)
GraknGraphgetRuleType in interface GraknGraphname - A unique name 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 Relation getRelation(RelationType relationType, Map<RoleType,Instance> roleMap)
GraknGraphgetRelation in interface GraknGraphrelationType - The Relation Type which we wish to find a Relation instance of.roleMap - A role map specifying the rolePlayers (Instances or Resources) in the relationship and the roles (Role Types) they play.public void rollback()
GraknGraphrollback in interface GraknGraphpublic void clear()
clear in interface GraknGraphprotected void clearGraph()
public void close()
close in interface GraknGraphclose in interface AutoCloseablepublic void closeGraph(String closedReason)
public void closePermanent()
public void commit()
throws GraknValidationException
commit in interface GraknGraphGraknValidationException - when the graph does not conform to the object conceptpublic void commit(boolean submitLogs)
throws GraknValidationException
GraknValidationExceptionprotected void commitTx()
public boolean fixDuplicateCasting(Object castingId)
castingId - The id of the casting to check for duplicatesCopyright © 2016 Grakn Labs Ltd. All rights reserved.