Package org.umlg.sqlg.structure.topology
Class Topology
java.lang.Object
org.umlg.sqlg.structure.topology.Topology
Date: 2016/09/04
Time: 8:49 AM
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final com.fasterxml.jackson.databind.ObjectMapper
static final String
static final String
static final String
static final String
Rdbms schema that holds sqlg topology.static final String
Edge table for the edge's colocate label.static final String
Edge table for the edge's distribution column.static final String
Edge table for the edge's identifier properties.static final String
Indicates the primary key order.static final String
Edge table for the EdgeLabel to Index.static final String
Table storing the graphs edge labels.static final String
Edge's shard_count property.static final String
EdgeLabel's name property.static final String
EdgeLabel's partition expression.static final String
EdgeLabel's partition type.static final String
Edge table for the edge's partitions.static final String
Edge table for the edge's properties.static final String
Table storing the graph's graph meta data.static final String
graph's database version.static final String
graph's sqlg version.static final String
Edge table for the vertices in edges.static final String
static final String
static final String
static final String
static final String
Table storing the graphs indexes.static final String
Index table's index_type propertystatic final String
Index table's name propertystatic final String
Edge table for Index to Propertystatic final String
static final String
Table storing the logs.static final String
static final String
static final String
static final String
Edge table for the vertices out edges.static final String
static final String
static final String
static final String
static final String
Table storing the partition.static final String
static final String
The Partition's from spec.static final String
The Partition's in spec.static final String
The Partition's modulus spec.static final String
The Partition's name.static final String
Partition table for the partition's partitions.static final String
The Partition's sub-partition's partitionExpression.static final String
The Partition's sub-partition's PartitionType.static final String
The Partition's remainder spec.static final String
static final String
The Partition's to spec.static final String
Table storing the graphs element properties.static final String
A check constraint for the property.static final String
The default value for the property.static final String
Lower multiplicity of the property.static final String
Upper multiplicity of the property.static final String
Property table's name propertystatic final String
Property table's type propertystatic final String
Table storing the graph's schemas.static final String
Schema's name.static final String
Edge table for the schema to vertex edge.static final String
Edge table for the vertex's colocate label.static final String
Edge table for the vertex's distribution column.static final String
Edge table for the vertex's identifier properties.static final String
Indicates the primary key order.static final String
Edge table for the VertexLabel to Index.static final String
Table storing the graphs vertex labels.static final String
vertex's shard_count property.static final String
VertexLabel's name property.static final String
VertexLabel's partition expression.static final String
VertexLabel's partition type.static final String
Edge table for the vertex's partitions.static final String
Edge table for the vertex's properties.static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
clearForeignSchemas
(Set<String> schemasToClear) void
close()
void
ensureEdgeLabelExist
(String edgeLabelName, SchemaTable foreignKeyOut, SchemaTable foreignKeyIn, Map<String, PropertyDefinition> properties) Ensures that the edge table with out and in foreign keys and property columns exists.ensureEdgeLabelExist
(String edgeLabelName, VertexLabel outVertexLabel, VertexLabel inVertexLabel, Map<String, PropertyDefinition> properties) Ensures that the edge table with out and inVertexLabel
s and property columns exists.ensureEdgeLabelExist
(String edgeLabelName, VertexLabel outVertexLabel, VertexLabel inVertexLabel, Map<String, PropertyDefinition> properties, org.apache.commons.collections4.set.ListOrderedSet<String> identifiers) Ensures that the edge table with out and inVertexLabel
s and property columns exists.void
ensureEdgePropertiesExist
(String schemaName, String label, Map<String, PropertyDefinition> properties) Ensures that the edge's table has the required columns.void
ensureEdgePropertiesExist
(String label, Map<String, PropertyDefinition> properties) Ensures that the edge's table has the required columns.ensureSchemaExist
(String schemaName) Ensures that the schema exists.void
ensureTemporaryVertexTableExist
(String schema, String label, Map<String, PropertyDefinition> properties) ensureVertexLabelExist
(String label) Ensures that the vertex table exist in the db.ensureVertexLabelExist
(String schemaName, String label) Ensures that the schema, vertex table exist in the db.ensureVertexLabelExist
(String schemaName, String label, Map<String, PropertyDefinition> properties) Ensures that the schema, vertex table and property columns exist in the db.ensureVertexLabelExist
(String schemaName, String label, Map<String, PropertyDefinition> properties, org.apache.commons.collections4.set.ListOrderedSet<String> identifiers) Ensures that the schema, vertex table and property columns exist in the db.ensureVertexLabelExist
(String label, Map<String, PropertyDefinition> columns) Ensures that the vertex table and property columns exist in the db.ensureVertexLabelExist
(String label, Map<String, PropertyDefinition> columns, org.apache.commons.collections4.set.ListOrderedSet<String> identifiers) void
ensureVertexLabelPropertiesExist
(String schemaName, String label, Map<String, PropertyDefinition> properties) Ensures that the vertex's table has the required columns.void
ensureVertexLabelPropertiesExist
(String label, Map<String, PropertyDefinition> properties) Ensures that the vertex's table has the required columns.boolean
void
fromNotifyJson
(int pid, LocalDateTime notifyTimestamp) get all tables by schema, with their properties does not return schema tablesgetAllTables
(boolean sqlgSchema) get all tables by schema, with their propertiesgetEdgeLabel
(String schemaName, String edgeLabelName) getPropertiesFor
(SchemaTable schemaTable) getTableFor
(SchemaTable schemaTable) Map<SchemaTable,
org.apache.commons.lang3.tuple.Pair<Set<SchemaTable>, Set<SchemaTable>>> org.apache.commons.lang3.tuple.Pair<Set<SchemaTable>,
Set<SchemaTable>> getTableLabels
(SchemaTable schemaTable) Returns all the in and out SchemaTables that schemaTable has edges to.getVertexLabel
(String schemaName, String label) void
importForeignSchemas
(Set<Schema> originalSchemas) Import the foreign schema into the local graph's meta data.void
importForeignVertexEdgeLabels
(Schema importIntoSchema, Set<VertexLabel> vertexLabels, Set<EdgeLabel> edgeLabels) boolean
boolean
isLocked()
void
lock()
void
void
registerListener
(TopologyListener topologyListener) void
com.fasterxml.jackson.databind.JsonNode
toJson()
toString()
void
unlock()
void
-
Field Details
-
GRAPH
- See Also:
-
VERTEX_PREFIX
- See Also:
-
EDGE_PREFIX
- See Also:
-
VERTICES
- See Also:
-
ID
- See Also:
-
VERTEX_SCHEMA
- See Also:
-
VERTEX_TABLE
- See Also:
-
LABEL_SEPARATOR
- See Also:
-
IN_VERTEX_COLUMN_END
- See Also:
-
OUT_VERTEX_COLUMN_END
- See Also:
-
ZONEID
- See Also:
-
MONTHS
- See Also:
-
DAYS
- See Also:
-
DURATION_NANOS
- See Also:
-
BULK_TEMP_EDGE
- See Also:
-
OBJECT_MAPPER
public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER -
SQLG_NOTIFICATION_CHANNEL
- See Also:
-
CREATED_ON
- See Also:
-
UPDATED_ON
- See Also:
-
SCHEMA_VERTEX_DISPLAY
- See Also:
-
SQLG_SCHEMA
Rdbms schema that holds sqlg topology.- See Also:
-
SQLG_SCHEMA_GRAPH
Table storing the graph's graph meta data.- See Also:
-
SQLG_SCHEMA_GRAPH_VERSION
graph's sqlg version.- See Also:
-
SQLG_SCHEMA_GRAPH_DB_VERSION
graph's database version. This is sourced fromDatabaseMetaData.getDatabaseProductVersion()
- See Also:
-
SQLG_SCHEMA_SCHEMA
Table storing the graph's schemas.- See Also:
-
SQLG_SCHEMA_SCHEMA_NAME
Schema's name.- See Also:
-
SQLG_SCHEMA_VERTEX_LABEL
Table storing the graphs vertex labels.- See Also:
-
SQLG_SCHEMA_VERTEX_LABEL_NAME
VertexLabel's name property.- See Also:
-
SQLG_SCHEMA_VERTEX_LABEL_PARTITION_TYPE
VertexLabel's partition type.PartitionType
- See Also:
-
SQLG_SCHEMA_VERTEX_LABEL_PARTITION_EXPRESSION
VertexLabel's partition expression.- See Also:
-
SQLG_SCHEMA_EDGE_LABEL
Table storing the graphs edge labels.- See Also:
-
SQLG_SCHEMA_EDGE_LABEL_NAME
EdgeLabel's name property.- See Also:
-
SQLG_SCHEMA_EDGE_LABEL_PARTITION_TYPE
EdgeLabel's partition type.PartitionType
- See Also:
-
SQLG_SCHEMA_EDGE_LABEL_PARTITION_EXPRESSION
EdgeLabel's partition expression.- See Also:
-
SQLG_SCHEMA_PARTITION
Table storing the partition.- See Also:
-
SQLG_SCHEMA_PARTITION_NAME
The Partition's name.- See Also:
-
SQLG_SCHEMA_PARTITION_SCHEMA_NAME
- See Also:
-
SQLG_SCHEMA_PARTITION_ABSTRACT_LABEL_NAME
- See Also:
-
SQLG_SCHEMA_PARTITION_FROM
The Partition's from spec.- See Also:
-
SQLG_SCHEMA_PARTITION_TO
The Partition's to spec.- See Also:
-
SQLG_SCHEMA_PARTITION_IN
The Partition's in spec. i.e. CREATE TABLE "public"."TEST1" PARTITION OF "public"."V_RealWorkspaceElement" FOR VALUES IN ('TEST1');- See Also:
-
SQLG_SCHEMA_PARTITION_MODULUS
The Partition's modulus spec. i.e. CREATE TABLE "public"."TEST1" PARTITION OF "public"."V_RealWorkspaceElement" FOR VALUES (MODULUS m, REMAINDER r);- See Also:
-
SQLG_SCHEMA_PARTITION_REMAINDER
The Partition's remainder spec. i.e. CREATE TABLE "public"."TEST1" PARTITION OF "public"."V_RealWorkspaceElement" FOR VALUES (MODULUS m, REMAINDER r);- See Also:
-
SQLG_SCHEMA_PARTITION_PARTITION_TYPE
The Partition's sub-partition's PartitionType.- See Also:
-
SQLG_SCHEMA_PARTITION_PARTITION_EXPRESSION
The Partition's sub-partition's partitionExpression.- See Also:
-
SQLG_SCHEMA_VERTEX_PARTITION_EDGE
Edge table for the vertex's partitions.- See Also:
-
SQLG_SCHEMA_EDGE_PARTITION_EDGE
Edge table for the edge's partitions.- See Also:
-
SQLG_SCHEMA_PARTITION_PARTITION_EDGE
Partition table for the partition's partitions.- See Also:
-
SQLG_SCHEMA_VERTEX_DISTRIBUTION_COLUMN_EDGE
Edge table for the vertex's distribution column.- See Also:
-
SQLG_SCHEMA_VERTEX_DISTRIBUTION_COLOCATE_EDGE
Edge table for the vertex's colocate label.- See Also:
-
SQLG_SCHEMA_VERTEX_LABEL_DISTRIBUTION_SHARD_COUNT
vertex's shard_count property.- See Also:
-
SQLG_SCHEMA_EDGE_DISTRIBUTION_COLUMN_EDGE
Edge table for the edge's distribution column.- See Also:
-
SQLG_SCHEMA_EDGE_DISTRIBUTION_COLOCATE_EDGE
Edge table for the edge's colocate label. The edge's colocate will always be to its incoming vertex label.- See Also:
-
SQLG_SCHEMA_EDGE_LABEL_DISTRIBUTION_SHARD_COUNT
Edge's shard_count property.- See Also:
-
SQLG_SCHEMA_PROPERTY
Table storing the graphs element properties.- See Also:
-
SQLG_SCHEMA_SCHEMA_VERTEX_EDGE
Edge table for the schema to vertex edge.- See Also:
-
SQLG_SCHEMA_IN_EDGES_EDGE
Edge table for the vertices in edges.- See Also:
-
SQLG_SCHEMA_OUT_EDGES_EDGE
Edge table for the vertices out edges.- See Also:
-
SQLG_SCHEMA_IN_EDGES_LOWER_MULTIPLICITY
- See Also:
-
SQLG_SCHEMA_IN_EDGES_UPPER_MULTIPLICITY
- See Also:
-
SQLG_SCHEMA_IN_EDGES_UNIQUE
- See Also:
-
SQLG_SCHEMA_IN_EDGES_ORDERED
- See Also:
-
SQLG_SCHEMA_OUT_EDGES_LOWER_MULTIPLICITY
- See Also:
-
SQLG_SCHEMA_OUT_EDGES_UPPER_MULTIPLICITY
- See Also:
-
SQLG_SCHEMA_OUT_EDGES_UNIQUE
- See Also:
-
SQLG_SCHEMA_OUT_EDGES_ORDERED
- See Also:
-
SQLG_SCHEMA_VERTEX_PROPERTIES_EDGE
Edge table for the vertex's properties.- See Also:
-
SQLG_SCHEMA_EDGE_PROPERTIES_EDGE
Edge table for the edge's properties.- See Also:
-
SQLG_SCHEMA_VERTEX_IDENTIFIER_EDGE
Edge table for the vertex's identifier properties. i.e. user defined primary key columns- See Also:
-
SQLG_SCHEMA_VERTEX_IDENTIFIER_INDEX_EDGE
Indicates the primary key order.- See Also:
-
SQLG_SCHEMA_EDGE_IDENTIFIER_EDGE
Edge table for the edge's identifier properties. i.e. user defined primary key columns- See Also:
-
SQLG_SCHEMA_EDGE_IDENTIFIER_INDEX_EDGE
Indicates the primary key order.- See Also:
-
SQLG_SCHEMA_PROPERTY_NAME
Property table's name property- See Also:
-
SQLG_SCHEMA_INDEX
Table storing the graphs indexes.- See Also:
-
SQLG_SCHEMA_INDEX_NAME
Index table's name property- See Also:
-
SQLG_SCHEMA_INDEX_INDEX_TYPE
Index table's index_type property- See Also:
-
SQLG_SCHEMA_VERTEX_INDEX_EDGE
Edge table for the VertexLabel to Index.- See Also:
-
SQLG_SCHEMA_EDGE_INDEX_EDGE
Edge table for the EdgeLabel to Index.- See Also:
-
SQLG_SCHEMA_INDEX_PROPERTY_EDGE
Edge table for Index to Property- See Also:
-
SQLG_SCHEMA_INDEX_PROPERTY_EDGE_SEQUENCE
- See Also:
-
SQLG_SCHEMA_LOG
Table storing the logs.- See Also:
-
SQLG_SCHEMA_LOG_TIMESTAMP
- See Also:
-
SQLG_SCHEMA_LOG_LOG
- See Also:
-
SQLG_SCHEMA_LOG_PID
- See Also:
-
SQLG_SCHEMA_PROPERTY_TYPE
Property table's type property- See Also:
-
SQLG_SCHEMA_PROPERTY_MULTIPLICITY_LOWER
Lower multiplicity of the property. > 0 indicates the property is required- See Also:
-
SQLG_SCHEMA_PROPERTY_MULTIPLICITY_UPPER
Upper multiplicity of the property. -1 indicates the property has no upper limit- See Also:
-
SQLG_SCHEMA_PROPERTY_DEFAULT_LITERAL
The default value for the property. The value gets passed straight into the db without inspection.- See Also:
-
SQLG_SCHEMA_PROPERTY_CHECK_CONSTRAINT
A check constraint for the property. The value gets passed straight into the db without inspection.- See Also:
-
-
Constructor Details
-
Topology
Topology is a singleton created when theSqlgGraph
is opened. As the topology, i.e. sqlg_schema is created upfront the meta topology is pre-loaded.- Parameters:
sqlgGraph
- The graph.
-
-
Method Details
-
getSqlgGraph
-
close
public void close() -
getValidationErrors
-
isImplementingForeignKeys
public boolean isImplementingForeignKeys() -
threadWriteLock
public void threadWriteLock() -
lock
public void lock() -
unlock
public void unlock() -
isLocked
public boolean isLocked() -
ensureSchemaExist
Ensures that the schema exists.- Parameters:
schemaName
- The schema to create if it does not exist.
-
importForeignSchemas
Import the foreign schema into the local graph's meta data.- Parameters:
originalSchemas
- The foreign schemas to import.
-
clearForeignSchemas
-
clearForeignSchemas
public void clearForeignSchemas() -
importForeignVertexEdgeLabels
public void importForeignVertexEdgeLabels(Schema importIntoSchema, Set<VertexLabel> vertexLabels, Set<EdgeLabel> edgeLabels) -
ensureVertexLabelExist
Ensures that the vertex table exist in the db. The default schema is assumed. @SeeSqlDialect.getPublicSchema()
If any element does not exist the a lock is first obtained. After the lock is obtained the maps are rechecked to see if the element has not been added in the mean time.- Parameters:
label
- The vertex's label. Translates to a table prepended with 'V_' and the table's name being the label.
-
ensureVertexLabelExist
Ensures that the vertex table and property columns exist in the db. The default schema is assumed. @SeeSqlDialect.getPublicSchema()
If any element does not exist the a lock is first obtained. After the lock is obtained the maps are rechecked to see if the element has not been added in the mean time.- Parameters:
label
- The vertex's label. Translates to a table prepended with 'V_' and the table's name being the label.columns
- The properties with their types.- See Also:
-
ensureVertexLabelExist
public VertexLabel ensureVertexLabelExist(String label, Map<String, PropertyDefinition> columns, org.apache.commons.collections4.set.ListOrderedSet<String> identifiers) -
ensureVertexLabelExist
Ensures that the schema, vertex table exist in the db. If any element does not exist the a lock is first obtained. After the lock is obtained the maps are rechecked to see if the element has not been added in the mean time.- Parameters:
schemaName
- The schema the vertex is in.label
- The vertex's label. Translates to a table prepended with 'V_' and the table's name being the label.
-
ensureVertexLabelExist
public VertexLabel ensureVertexLabelExist(String schemaName, String label, Map<String, PropertyDefinition> properties) Ensures that the schema, vertex table and property columns exist in the db. If any element does not exist the a lock is first obtained. After the lock is obtained the maps are rechecked to see if the element has not been added in the mean time.- Parameters:
schemaName
- The schema the vertex is in.label
- The vertex's label. Translates to a table prepended with 'V_' and the table's name being the label.properties
- The properties with their types.- See Also:
-
ensureVertexLabelExist
public VertexLabel ensureVertexLabelExist(String schemaName, String label, Map<String, PropertyDefinition> properties, org.apache.commons.collections4.set.ListOrderedSet<String> identifiers) Ensures that the schema, vertex table and property columns exist in the db. If any element does not exist the a lock is first obtained. After the lock is obtained the maps are rechecked to see if the element has not been added in the mean time.- Parameters:
schemaName
- The schema the vertex is in.label
- The vertex's label. Translates to a table prepended with 'V_' and the table's name being the label.properties
- The properties with their types.identifiers
- The Vertex's identifiers. i.e. it will be the primary key.- See Also:
-
ensureTemporaryVertexTableExist
public void ensureTemporaryVertexTableExist(String schema, String label, Map<String, PropertyDefinition> properties) -
ensureEdgeLabelExist
public EdgeLabel ensureEdgeLabelExist(String edgeLabelName, VertexLabel outVertexLabel, VertexLabel inVertexLabel, Map<String, PropertyDefinition> properties) Ensures that the edge table with out and inVertexLabel
s and property columns exists. The edge table will reside in the out vertex's schema. If a table, a foreign key or a column needs to be created a lock is first obtained.- Parameters:
edgeLabelName
- The label of the edge for which a table will be created.outVertexLabel
- The edge's outVertexLabel
inVertexLabel
- The edge's inVertexLabel
properties
- The edge's properties with their type.- Returns:
- The
EdgeLabel
-
ensureEdgeLabelExist
public EdgeLabel ensureEdgeLabelExist(String edgeLabelName, VertexLabel outVertexLabel, VertexLabel inVertexLabel, Map<String, PropertyDefinition> properties, org.apache.commons.collections4.set.ListOrderedSet<String> identifiers) Ensures that the edge table with out and inVertexLabel
s and property columns exists. The edge table will reside in the out vertex's schema. If a table, a foreign key or a column needs to be created a lock is first obtained.- Parameters:
edgeLabelName
- The label of the edge for which a table will be created.outVertexLabel
- The edge's outVertexLabel
inVertexLabel
- The edge's inVertexLabel
properties
- The edge's properties with their type.identifiers
- The edge's user supplied identifiers. They will make up the edge's primary key.- Returns:
- The
EdgeLabel
-
ensureEdgeLabelExist
public void ensureEdgeLabelExist(String edgeLabelName, SchemaTable foreignKeyOut, SchemaTable foreignKeyIn, Map<String, PropertyDefinition> properties) Ensures that the edge table with out and in foreign keys and property columns exists. The edge table will reside in the out vertex's schema. If a table, a foreign key or a column needs to be created a lock is first obtained.- Parameters:
edgeLabelName
- The label for the edge.foreignKeyOut
- TheSchemaTable
that represents the out vertex.foreignKeyIn
- TheSchemaTable
that represents the in vertex.properties
- The edge's properties with their type.
-
ensureVertexLabelPropertiesExist
public void ensureVertexLabelPropertiesExist(String label, Map<String, PropertyDefinition> properties) Ensures that the vertex's table has the required columns. If a columns needs to be created a lock will be obtained. The vertex's schema and table must already exists. The default "public" schema will be used.SqlDialect.getPublicSchema()
- Parameters:
label
- The vertex's label.properties
- The properties to create if they do not exist.
-
ensureVertexLabelPropertiesExist
public void ensureVertexLabelPropertiesExist(String schemaName, String label, Map<String, PropertyDefinition> properties) Ensures that the vertex's table has the required columns. If a columns needs to be created a lock will be obtained. The vertex's schema and table must already exists.- Parameters:
schemaName
- The schema the vertex resides in.label
- The vertex's label.properties
- The properties to create if they do not exist.
-
ensureEdgePropertiesExist
Ensures that the edge's table has the required columns. The default schema is assumed. @seeSqlDialect.getPublicSchema()
If a columns needs to be created a lock will be obtained. The edge's schema and table must already exists.- Parameters:
label
- The edge's label.properties
- The properties to create if they do not exist.
-
ensureEdgePropertiesExist
public void ensureEdgePropertiesExist(String schemaName, String label, Map<String, PropertyDefinition> properties) Ensures that the edge's table has the required columns. If a columns needs to be created a lock will be obtained. The edge's schema and table must already exists.- Parameters:
schemaName
- The schema the edge resides in.label
- The edge's label.properties
- The properties to create if they do not exist.
-
cacheTopology
public void cacheTopology() -
validateTopology
public void validateTopology() -
toJson
public com.fasterxml.jackson.databind.JsonNode toJson() -
toString
-
fromNotifyJson
-
equals
-
getSchemas
-
getPublicSchema
-
getSchema
-
getVertexLabel
-
getEdgeLabel
-
getAllTables
get all tables by schema, with their properties does not return schema tables- Returns:
- the map of all tables.
-
getAllTables
get all tables by schema, with their properties- Parameters:
sqlgSchema
- do we want the sqlg_schema tables?- Returns:
- a map of all tables and their properties.
-
getPropertiesFor
-
getTableFor
-
getTableLabels
public Map<SchemaTable,org.apache.commons.lang3.tuple.Pair<Set<SchemaTable>, getTableLabels()Set<SchemaTable>>> -
getTableLabels
public org.apache.commons.lang3.tuple.Pair<Set<SchemaTable>,Set<SchemaTable>> getTableLabels(SchemaTable schemaTable) Returns all the in and out SchemaTables that schemaTable has edges to.- Parameters:
schemaTable
- The schemaTable for whom we want the in and out SchemaTables- Returns:
- a Pair of in and out SchemaTables.
-
getEdgeForeignKeys
-
registerListener
-
markAsDistributed
public void markAsDistributed()
-