static PropertyColumn fromNotifyJson(AbstractLabel abstractLabel, JsonNode jsonNode) { String pt = jsonNode.get("propertyType").asText(); if (pt.equals("VARCHAR")) { //This is not ideal, however Sqlg only uses VARCHAR when creating the column. //For the rest is is considered the same as STRING return new PropertyColumn( abstractLabel, jsonNode.get("name").asText(), PropertyType.STRING); } else { return new PropertyColumn( abstractLabel, jsonNode.get("name").asText(), PropertyType.valueOf(pt)); } }
static PropertyColumn fromNotifyJson(AbstractLabel abstractLabel, JsonNode jsonNode) { String pt = jsonNode.get("propertyType").asText(); if (pt.equals("VARCHAR")) { //This is not ideal, however Sqlg only uses VARCHAR when creating the column. //For the rest is is considered the same as STRING return new PropertyColumn( abstractLabel, jsonNode.get("name").asText(), PropertyType.STRING); } else { return new PropertyColumn( abstractLabel, jsonNode.get("name").asText(), PropertyType.valueOf(pt)); } }
static VertexLabel createSqlgSchemaVertexLabel(Schema schema, String label, Map<String, PropertyType> columns) { Preconditions.checkArgument(schema.isSqlgSchema(), "createSqlgSchemaVertexLabel may only be called for \"%s\"", SQLG_SCHEMA); VertexLabel vertexLabel = new VertexLabel(schema, label); //Add the properties directly. As they are pre-created do not add them to uncommittedProperties. for (Map.Entry<String, PropertyType> propertyEntry : columns.entrySet()) { PropertyColumn property = new PropertyColumn(vertexLabel, propertyEntry.getKey(), propertyEntry.getValue()); vertexLabel.properties.put(propertyEntry.getKey(), property); } return vertexLabel; }
static VertexLabel createSqlgSchemaVertexLabel(Schema schema, String label, Map<String, PropertyType> columns) { Preconditions.checkArgument(schema.isSqlgSchema(), "createSqlgSchemaVertexLabel may only be called for \"%s\"", SQLG_SCHEMA); VertexLabel vertexLabel = new VertexLabel(schema, label); //Add the properties directly. As they are pre-created do not add them to uncommittedProperties. for (Map.Entry<String, PropertyType> propertyEntry : columns.entrySet()) { PropertyColumn property = new PropertyColumn(vertexLabel, propertyEntry.getKey(), propertyEntry.getValue()); vertexLabel.properties.put(propertyEntry.getKey(), property); } return vertexLabel; }
/** * Only called for a new vertex/edge label being added. * * @param label The vertex or edge's label. * @param properties The vertex's properties. * @param identifiers The vertex or edge's identifiers */ AbstractLabel(SqlgGraph sqlgGraph, String label, Map<String, PropertyType> properties, ListOrderedSet<String> identifiers) { this.sqlgGraph = sqlgGraph; this.label = label; for (Map.Entry<String, PropertyType> propertyEntry : properties.entrySet()) { PropertyColumn property = new PropertyColumn(this, propertyEntry.getKey(), propertyEntry.getValue()); property.setCommitted(false); this.uncommittedProperties.put(propertyEntry.getKey(), property); } this.uncommittedIdentifiers.addAll(identifiers); }
/** * Only called for a new vertex/edge label being added. * * @param label The vertex or edge's label. * @param properties The vertex's properties. * @param identifiers The vertex or edge's identifiers */ AbstractLabel(SqlgGraph sqlgGraph, String label, Map<String, PropertyType> properties, ListOrderedSet<String> identifiers) { this.sqlgGraph = sqlgGraph; this.label = label; for (Map.Entry<String, PropertyType> propertyEntry : properties.entrySet()) { PropertyColumn property = new PropertyColumn(this, propertyEntry.getKey(), propertyEntry.getValue()); property.setCommitted(false); this.uncommittedProperties.put(propertyEntry.getKey(), property); } this.uncommittedIdentifiers.addAll(identifiers); }
/** * Only called for a new partitioned vertex/edge label being added. * * @param label The vertex or edge's label. * @param properties The element's properties. * @param identifiers The element's identifiers. * @param partitionType The partition type. i.e. RANGE or LIST. * @param partitionExpression The sql fragment to express the partition column or expression. */ AbstractLabel(SqlgGraph sqlgGraph, String label, Map<String, PropertyType> properties, ListOrderedSet<String> identifiers, PartitionType partitionType, String partitionExpression) { Preconditions.checkArgument(partitionType == PartitionType.RANGE || partitionType == PartitionType.LIST, "Only RANGE and LIST partitions are supported. Found %s", partitionType.name()); Preconditions.checkArgument(!partitionExpression.isEmpty(), "partitionExpression may not be an empty string."); Preconditions.checkArgument(!identifiers.isEmpty(), "Partitioned labels must have at least one identifier."); this.sqlgGraph = sqlgGraph; this.label = label; for (Map.Entry<String, PropertyType> propertyEntry : properties.entrySet()) { PropertyColumn property = new PropertyColumn(this, propertyEntry.getKey(), propertyEntry.getValue()); property.setCommitted(false); this.uncommittedProperties.put(propertyEntry.getKey(), property); } this.uncommittedIdentifiers.addAll(identifiers); this.partitionType = partitionType; this.partitionExpression = partitionExpression; }
/** * Only called for a new partitioned vertex/edge label being added. * * @param label The vertex or edge's label. * @param properties The element's properties. * @param identifiers The element's identifiers. * @param partitionType The partition type. i.e. RANGE or LIST. * @param partitionExpression The sql fragment to express the partition column or expression. */ AbstractLabel(SqlgGraph sqlgGraph, String label, Map<String, PropertyType> properties, ListOrderedSet<String> identifiers, PartitionType partitionType, String partitionExpression) { Preconditions.checkArgument(partitionType == PartitionType.RANGE || partitionType == PartitionType.LIST, "Only RANGE and LIST partitions are supported. Found %s", partitionType.name()); Preconditions.checkArgument(!partitionExpression.isEmpty(), "partitionExpression may not be an empty string."); Preconditions.checkArgument(!identifiers.isEmpty(), "Partitioned labels must have at least one identifier."); this.sqlgGraph = sqlgGraph; this.label = label; for (Map.Entry<String, PropertyType> propertyEntry : properties.entrySet()) { PropertyColumn property = new PropertyColumn(this, propertyEntry.getKey(), propertyEntry.getValue()); property.setCommitted(false); this.uncommittedProperties.put(propertyEntry.getKey(), property); } this.uncommittedIdentifiers.addAll(identifiers); this.partitionType = partitionType; this.partitionExpression = partitionExpression; }
public void ensurePropertiesExist(Map<String, PropertyType> columns) { for (Map.Entry<String, PropertyType> column : columns.entrySet()) { if (!this.properties.containsKey(column.getKey())) { Preconditions.checkState(!this.schema.isSqlgSchema(), "schema may not be %s", SQLG_SCHEMA); if (!this.uncommittedProperties.containsKey(column.getKey())) { this.schema.getTopology().lock(); if (!getProperty(column.getKey()).isPresent()) { TopologyManager.addVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), column); addColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), ImmutablePair.of(column.getKey(), column.getValue())); PropertyColumn propertyColumn = new PropertyColumn(this, column.getKey(), column.getValue()); propertyColumn.setCommitted(false); this.uncommittedProperties.put(column.getKey(), propertyColumn); this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.CREATE); } } } } }
public void ensurePropertiesExist(Map<String, PropertyType> columns) { for (Map.Entry<String, PropertyType> column : columns.entrySet()) { if (!this.properties.containsKey(column.getKey())) { Preconditions.checkState(!this.schema.isSqlgSchema(), "schema may not be %s", SQLG_SCHEMA); if (!this.uncommittedProperties.containsKey(column.getKey())) { this.schema.getTopology().lock(); if (!getProperty(column.getKey()).isPresent()) { TopologyManager.addVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), column); addColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), ImmutablePair.of(column.getKey(), column.getValue())); PropertyColumn propertyColumn = new PropertyColumn(this, column.getKey(), column.getValue()); propertyColumn.setCommitted(false); this.uncommittedProperties.put(column.getKey(), propertyColumn); this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.CREATE); } } } } }
void addProperty(Vertex propertyVertex) { Preconditions.checkState(this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()); PropertyColumn property = new PropertyColumn(this, propertyVertex.value(SQLG_SCHEMA_PROPERTY_NAME), PropertyType.valueOf(propertyVertex.value(SQLG_SCHEMA_PROPERTY_TYPE))); this.properties.put(propertyVertex.value(SQLG_SCHEMA_PROPERTY_NAME), property); }
public void ensurePropertiesExist(Map<String, PropertyType> columns) { for (Map.Entry<String, PropertyType> column : columns.entrySet()) { if (!this.properties.containsKey(column.getKey())) { Preconditions.checkState(!this.getSchema().isSqlgSchema(), "schema may not be %s", SQLG_SCHEMA); if (!this.uncommittedProperties.containsKey(column.getKey())) { this.getSchema().getTopology().lock(); if (!getProperty(column.getKey()).isPresent()) { TopologyManager.addEdgeColumn(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), column, new ListOrderedSet<>()); addColumn(this.getSchema().getName(), EDGE_PREFIX + getLabel(), ImmutablePair.of(column.getKey(), column.getValue())); PropertyColumn propertyColumn = new PropertyColumn(this, column.getKey(), column.getValue()); propertyColumn.setCommitted(false); this.uncommittedProperties.put(column.getKey(), propertyColumn); this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.CREATE); } } } } }
void addProperty(Vertex propertyVertex) { Preconditions.checkState(this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()); PropertyColumn property = new PropertyColumn(this, propertyVertex.value(SQLG_SCHEMA_PROPERTY_NAME), PropertyType.valueOf(propertyVertex.value(SQLG_SCHEMA_PROPERTY_TYPE))); this.properties.put(propertyVertex.value(SQLG_SCHEMA_PROPERTY_NAME), property); }
public void ensurePropertiesExist(Map<String, PropertyType> columns) { for (Map.Entry<String, PropertyType> column : columns.entrySet()) { if (!this.properties.containsKey(column.getKey())) { Preconditions.checkState(!this.getSchema().isSqlgSchema(), "schema may not be %s", SQLG_SCHEMA); if (!this.uncommittedProperties.containsKey(column.getKey())) { this.getSchema().getTopology().lock(); if (!getProperty(column.getKey()).isPresent()) { TopologyManager.addEdgeColumn(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), column, new ListOrderedSet<>()); addColumn(this.getSchema().getName(), EDGE_PREFIX + getLabel(), ImmutablePair.of(column.getKey(), column.getValue())); PropertyColumn propertyColumn = new PropertyColumn(this, column.getKey(), column.getValue()); propertyColumn.setCommitted(false); this.uncommittedProperties.put(column.getKey(), propertyColumn); this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.CREATE); } } } } }
void addDistributionProperty(Vertex distributionProperty) { Preconditions.checkState(this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()); this.distributionPropertyColumn = new PropertyColumn(this, distributionProperty.value(SQLG_SCHEMA_PROPERTY_NAME), PropertyType.valueOf(distributionProperty.value(SQLG_SCHEMA_PROPERTY_TYPE))); }
void addDistributionProperty(Vertex distributionProperty) { Preconditions.checkState(this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()); this.distributionPropertyColumn = new PropertyColumn(this, distributionProperty.value(SQLG_SCHEMA_PROPERTY_NAME), PropertyType.valueOf(distributionProperty.value(SQLG_SCHEMA_PROPERTY_TYPE))); }