public interface GraknGraph extends AutoCloseable
A Grakn Graph
This is produced by Grakn.factory(String, String) and allows the user to construct and perform
basic look ups to a Grakn Graph. This also allows the execution of Graql queries.
| Modifier and Type | Method and Description |
|---|---|
GraknAdmin |
admin()
Returns access to the low-level details of the graph via GraknAdmin
|
void |
clear()
Closes and clears the current graph.
|
void |
close()
Closes the current transaction.
|
void |
commit()
Validates and attempts to commit the graph.
|
<T extends Concept> |
getConcept(ConceptId id)
Get the
Concept with identifier provided, if it exists. |
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.
|
Relation |
getRelation(RelationType relationType,
Map<RoleType,Instance> roleMap)
Get a Relation that has 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 all 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.
|
<T extends Type> |
getType(TypeName name)
Get the
Type with the name provided, if it exists. |
QueryBuilder |
graql()
Returns a QueryBuilder
|
boolean |
implicitConceptsVisible()
Utility function to specify whether implicit concepts should be exposed.
|
boolean |
isClosed()
Utility function to determine whether the graph has been closed.
|
void |
open()
Opens the graph.
|
EntityType |
putEntityType(String name)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified name. |
EntityType |
putEntityType(TypeName name)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified name. |
RelationType |
putRelationType(String name)
Create a
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified name. |
RelationType |
putRelationType(TypeName name)
Create a
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified name. |
<V> ResourceType<V> |
putResourceType(String name,
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 name and data type. |
<V> ResourceType<V> |
putResourceType(TypeName name,
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 name and data type. |
<V> ResourceType<V> |
putResourceTypeUnique(String name,
ResourceType.DataType<V> dataType)
Create a unique
ResourceType with super-type resource, or return a pre-existing
unique ResourceType, with the specified name and data type. |
<V> ResourceType<V> |
putResourceTypeUnique(TypeName name,
ResourceType.DataType<V> dataType)
Create a unique
ResourceType with super-type resource, or return a pre-existing
unique ResourceType, with the specified name and data type. |
RoleType |
putRoleType(String name)
|
RoleType |
putRoleType(TypeName name)
|
RuleType |
putRuleType(String name)
|
RuleType |
putRuleType(TypeName 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.
|
EntityType putEntityType(String name)
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified name.name - A unique name for the EntityTypeEntityType with the provided nameGraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-EntityType.EntityType putEntityType(TypeName name)
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified name.name - A unique name for the EntityTypeEntityType with the provided nameGraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-EntityType.<V> ResourceType<V> putResourceType(String name, ResourceType.DataType<V> dataType)
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified name and data type.V - 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 ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided name and data type.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-ResourceType.ConceptException - if the is already in use by an existing ResourceType which is
unique or has a different datatype.<V> ResourceType<V> putResourceType(TypeName name, ResourceType.DataType<V> dataType)
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified name and data type.V - 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 ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided name and data type.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-ResourceType.ConceptException - if the is already in use by an existing ResourceType which is
unique or has a different datatype.<V> ResourceType<V> putResourceTypeUnique(String name, ResourceType.DataType<V> dataType)
ResourceType with super-type resource, or return a pre-existing
unique ResourceType, with the specified name and data type.
The ResourceType is guaranteed to be unique, in that its instances can be connected to one entity.V - 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 ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided name.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-ResourceType.ConceptException - if the is already in use by an existing ResourceType which is
not unique or has a different datatype.<V> ResourceType<V> putResourceTypeUnique(TypeName name, ResourceType.DataType<V> dataType)
ResourceType with super-type resource, or return a pre-existing
unique ResourceType, with the specified name and data type.
The ResourceType is guaranteed to be unique, in that its instances can be connected to one entity.V - 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 ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided name.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-ResourceType.ConceptException - if the is already in use by an existing ResourceType which is
not unique or has a different datatype.RuleType putRuleType(String name)
name - A unique name for the RuleTypeRuleType with the provided name.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RuleType.RuleType putRuleType(TypeName name)
name - A unique name for the RuleTypeRuleType with the provided name.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RuleType.RelationType putRelationType(String name)
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified name.name - A unique name for the RelationTypeRelationType with the provided name.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RelationType.RelationType putRelationType(TypeName name)
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified name.name - A unique name for the RelationTypeRelationType with the provided name.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RelationType.RoleType putRoleType(String name)
name - A unique name for the RoleTypeRoleType with the provided Id.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RoleType.RoleType putRoleType(TypeName name)
name - A unique name for the RoleTypeRoleType with the provided Id.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RoleType.<T extends Concept> T getConcept(ConceptId id)
Concept with identifier provided, if it exists.id - A unique identifier for the Concept in the graph.Concept with the provided id or null if no such Concept exists.GraphRuntimeException - if the graph is closedClassCastException - if the concept is not an instance of T<T extends Type> T getType(TypeName name)
Type with the name provided, if it exists.name - A unique name which identifies the Type in the graph.Type with the provided name or null if no such Type exists.GraphRuntimeException - if the graph is closedClassCastException - if the type is not an instance of T<V> Collection<Resource<V>> getResourcesByValue(V value)
V - 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.GraphRuntimeException - if the graph is closedEntityType getEntityType(String name)
name - A unique name which identifies the Entity Type in the graph.GraphRuntimeException - if the graph is closedRelationType getRelationType(String name)
name - A unique name which identifies the Relation Type in the graph.GraphRuntimeException - if the graph is closed<V> ResourceType<V> getResourceType(String name)
V - 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.GraphRuntimeException - if the graph is closedRoleType getRoleType(String name)
name - A unique name which identifies the Role Type in the graph.GraphRuntimeException - if the graph is closedRuleType getRuleType(String name)
name - A unique name which identifies the Rule Type in the graph.GraphRuntimeException - if the graph is closedRelation getRelation(RelationType relationType, Map<RoleType,Instance> roleMap)
null.
Caller specifies a Relation Type and a role map, which lists the Instances or Resources in the relationship, and the roles each play.relationType - 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.null if no relationship exists fulfilling the above requirements.GraphRuntimeException - if the graph is closedGraknAdmin admin()
GraknAdminvoid showImplicitConcepts(boolean flag)
flag - Specifies if implicit and system-generated types should be returned.boolean implicitConceptsVisible()
void clear()
GraphRuntimeException - if the graph is closedString getKeyspace()
boolean isClosed()
QueryBuilder graql()
QueryBuildervoid rollback()
GraphRuntimeException - if the graph is closedvoid close()
GraknGraphFactory must be used to get a new connection.close in interface AutoCloseablevoid open()
void commit()
throws GraknValidationException
GraknValidationException - is thrown when a structural validation fails.Copyright © 2017 Grakn Labs Ltd. All rights reserved.