void ensureTemporaryVertexTableExist(final String label, final Map<String, PropertyType> columns) { Objects.requireNonNull(label, "Given table must not be null"); Preconditions.checkArgument(!label.startsWith(VERTEX_PREFIX), "label may not be prefixed with %s", VERTEX_PREFIX); final String prefixedTable = VERTEX_PREFIX + label; if (!this.threadLocalTemporaryTables.get().containsKey(prefixedTable)) { this.topology.lock(); if (!this.threadLocalTemporaryTables.get().containsKey(prefixedTable)) { this.threadLocalTemporaryTables.get().put(prefixedTable, columns); createTempTable(prefixedTable, columns); } } }
void ensureTemporaryVertexTableExist(final String label, final Map<String, PropertyType> columns) { Objects.requireNonNull(label, "Given table must not be null"); Preconditions.checkArgument(!label.startsWith(VERTEX_PREFIX), "label may not be prefixed with %s", VERTEX_PREFIX); final String prefixedTable = VERTEX_PREFIX + label; if (!this.threadLocalTemporaryTables.get().containsKey(prefixedTable)) { this.topology.lock(); if (!this.threadLocalTemporaryTables.get().containsKey(prefixedTable)) { this.threadLocalTemporaryTables.get().put(prefixedTable, columns); createTempTable(prefixedTable, columns); } } }
public void ensureListPartitionExists(String name, String in) { Objects.requireNonNull(name, "Sub-partition's \"name\" must not be null"); Objects.requireNonNull(in, "Sub-partition's \"in\" must not be null"); Preconditions.checkState(this.partitionType == PartitionType.LIST, "ensureRangePartitionExists(String name, String in) can only be called for a LIST partitioned VertexLabel. Found %s", this.partitionType.name()); Optional<Partition> partitionOptional = this.getPartition(name); if (!partitionOptional.isPresent()) { this.getAbstractLabel().getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); partitionOptional.orElseGet(() -> this.createListPartition(name, in)); } else { partitionOptional.get(); } }
public void ensureListPartitionExists(String name, String in) { Objects.requireNonNull(name, "Sub-partition's \"name\" must not be null"); Objects.requireNonNull(in, "Sub-partition's \"in\" must not be null"); Preconditions.checkState(this.partitionType == PartitionType.LIST, "ensureRangePartitionExists(String name, String in) can only be called for a LIST partitioned VertexLabel. Found %s", this.partitionType.name()); Optional<Partition> partitionOptional = this.getPartition(name); if (!partitionOptional.isPresent()) { this.getAbstractLabel().getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); partitionOptional.orElseGet(() -> this.createListPartition(name, in)); } else { partitionOptional.get(); } }
public void ensureRangePartitionExists(String name, String from, String to) { Objects.requireNonNull(name, "Sub-partition's \"name\" must not be null"); Objects.requireNonNull(from, "Sub-partition's \"from\" must not be null"); Objects.requireNonNull(to, "Sub-partition's \"to\" must not be null"); Preconditions.checkState(this.partitionType == PartitionType.RANGE, "ensureRangePartitionExists(String name, String from, String to) can only be called for a RANGE partitioned VertexLabel. Found %s", this.partitionType.name()); Optional<Partition> partitionOptional = this.getPartition(name); if (!partitionOptional.isPresent()) { this.getAbstractLabel().getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); partitionOptional.orElseGet(() -> this.createRangePartition(name, from, to)); } else { partitionOptional.get(); } }
public void ensureRangePartitionExists(String name, String from, String to) { Objects.requireNonNull(name, "Sub-partition's \"name\" must not be null"); Objects.requireNonNull(from, "Sub-partition's \"from\" must not be null"); Objects.requireNonNull(to, "Sub-partition's \"to\" must not be null"); Preconditions.checkState(this.partitionType == PartitionType.RANGE, "ensureRangePartitionExists(String name, String from, String to) can only be called for a RANGE partitioned VertexLabel. Found %s", this.partitionType.name()); Optional<Partition> partitionOptional = this.getPartition(name); if (!partitionOptional.isPresent()) { this.getAbstractLabel().getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); partitionOptional.orElseGet(() -> this.createRangePartition(name, from, to)); } else { partitionOptional.get(); } }
public Partition ensureListPartitionWithSubPartitionExists( String name, String in, PartitionType partitionType, String partitionExpression) { Objects.requireNonNull(name, "Sub-partition's \"name\" must not be null"); Objects.requireNonNull(in, "Sub-partition's \"in\" must not be null"); Preconditions.checkState(partitionType == PartitionType.LIST, "ensureListPartitionWithSubPartitionExists(String name, String in, PartitionType partitionType, String partitionExpression) can only be called with a LIST partition. Found %s", partitionType.name()); Objects.requireNonNull(partitionExpression, "Sub-partition's \"partitionExpression\" must not be null"); Optional<Partition> partitionOptional = this.getPartition(name); if (!partitionOptional.isPresent()) { this.getAbstractLabel().getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); return partitionOptional.orElseGet(() -> this.createListPartitionWithSubPartition(name, in, partitionType, partitionExpression)); } else { return partitionOptional.get(); } }
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); } } } } }
public void removePartition(Partition partition, boolean preserveData) { this.getSchema().getTopology().lock(); for (Partition partition1 : partition.getPartitions().values()) { partition1.remove(preserveData); } String fn = partition.getName(); if (!uncommittedRemovedPartitions.contains(fn)) { uncommittedRemovedPartitions.add(fn); TopologyManager.removePartition(this.sqlgGraph, partition); if (!preserveData) { partition.delete(); } else { partition.detach(); } this.getSchema().getTopology().fire(partition, "", TopologyChangeAction.DELETE); } }
/** * remove a given index that was on this label * * @param idx the index * @param preserveData should we keep the SQL data */ void removeIndex(Index idx, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedIndexes.contains(idx.getName())) { uncommittedRemovedIndexes.add(idx.getName()); TopologyManager.removeIndex(this.sqlgGraph, idx); if (!preserveData) { idx.delete(sqlgGraph); } this.getSchema().getTopology().fire(idx, "", TopologyChangeAction.DELETE); } }
/** * remove a given index that was on this label * * @param idx the index * @param preserveData should we keep the SQL data */ void removeIndex(Index idx, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedIndexes.contains(idx.getName())) { uncommittedRemovedIndexes.add(idx.getName()); TopologyManager.removeIndex(this.sqlgGraph, idx); if (!preserveData) { idx.delete(sqlgGraph); } this.getSchema().getTopology().fire(idx, "", TopologyChangeAction.DELETE); } }
public void ensureDistributed(int shardCount, PropertyColumn distributionPropertyColumn, AbstractLabel colocate) { Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).isPresent(), "distributionPropertyColumn \"%s\" not found.", distributionPropertyColumn.getName()); Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).get().equals(distributionPropertyColumn), "distributionPropertyColumn \"%s\" must be a property of \"%s\"", distributionPropertyColumn.getName(), this.getFullName()); Preconditions.checkArgument(getIdentifiers().contains(distributionPropertyColumn.getName()), "The distribution column must be part of the primary key"); if (!this.isDistributed()) { this.getSchema().getTopology().lock(); if (!this.isDistributed()) { TopologyManager.distributeAbstractLabel(this.sqlgGraph, this, shardCount, distributionPropertyColumn, colocate); distribute(shardCount, distributionPropertyColumn, colocate); this.uncommittedDistributionPropertyColumn = distributionPropertyColumn; this.uncommittedDistributionColocateAbstractLabel = colocate; this.uncommittedShardCount = shardCount; } } }
public void ensureDistributed(int shardCount, PropertyColumn distributionPropertyColumn, AbstractLabel colocate) { Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).isPresent(), "distributionPropertyColumn \"%s\" not found.", distributionPropertyColumn.getName()); Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).get().equals(distributionPropertyColumn), "distributionPropertyColumn \"%s\" must be a property of \"%s\"", distributionPropertyColumn.getName(), this.getFullName()); Preconditions.checkArgument(getIdentifiers().contains(distributionPropertyColumn.getName()), "The distribution column must be part of the primary key"); if (!this.isDistributed()) { this.getSchema().getTopology().lock(); if (!this.isDistributed()) { TopologyManager.distributeAbstractLabel(this.sqlgGraph, this, shardCount, distributionPropertyColumn, colocate); distribute(shardCount, distributionPropertyColumn, colocate); this.uncommittedDistributionPropertyColumn = distributionPropertyColumn; this.uncommittedDistributionColocateAbstractLabel = colocate; this.uncommittedShardCount = shardCount; } } }
private void removePartition(Partition partition, boolean preserveData) { this.getAbstractLabel().getSchema().getTopology().lock(); for (Partition partition1 : partition.getPartitions().values()) { partition.removePartition(partition1, preserveData); } String fn = partition.getName(); if (!uncommittedRemovedPartitions.contains(fn)) { uncommittedRemovedPartitions.add(fn); TopologyManager.removePartition(this.sqlgGraph, partition); if (!preserveData) { partition.delete(); } else { partition.detach(); } this.getAbstractLabel().getSchema().getTopology().fire(partition, "", TopologyChangeAction.DELETE); } }
private void removePartition(Partition partition, boolean preserveData) { this.getAbstractLabel().getSchema().getTopology().lock(); for (Partition partition1 : partition.getPartitions().values()) { partition.removePartition(partition1, preserveData); } String fn = partition.getName(); if (!uncommittedRemovedPartitions.contains(fn)) { uncommittedRemovedPartitions.add(fn); TopologyManager.removePartition(this.sqlgGraph, partition); if (!preserveData) { partition.delete(); } else { partition.detach(); } this.getAbstractLabel().getSchema().getTopology().fire(partition, "", TopologyChangeAction.DELETE); } }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeEdgeColumn(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeEdgeColumn(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }