public AbstractLabel getAbstractLabel() { if (this.abstractLabel == null) { return this.parentPartition.getAbstractLabel(); } else { return this.abstractLabel; } }
public AbstractLabel getAbstractLabel() { if (this.abstractLabel == null) { return this.parentPartition.getAbstractLabel(); } else { return this.abstractLabel; } }
void afterRollback() { Preconditions.checkState(this.getAbstractLabel().getSchema().getTopology().isSqlWriteLockHeldByCurrentThread(), "Partition.afterCommit must hold the write lock"); this.uncommittedRemovedPartitions.clear(); for (Iterator<Map.Entry<String, Partition>> it = this.partitions.entrySet().iterator(); it.hasNext(); ) { Map.Entry<String, Partition> entry = it.next(); entry.getValue().afterRollback(); } }
void afterRollback() { Preconditions.checkState(this.getAbstractLabel().getSchema().getTopology().isSqlWriteLockHeldByCurrentThread(), "Partition.afterCommit must hold the write lock"); this.uncommittedRemovedPartitions.clear(); for (Iterator<Map.Entry<String, Partition>> it = this.partitions.entrySet().iterator(); it.hasNext(); ) { Map.Entry<String, Partition> entry = it.next(); entry.getValue().afterRollback(); } }
public Map<String, Partition> getPartitions() { Map<String, Partition> result = new HashMap<>(this.partitions); if (this.getAbstractLabel().getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()) { result.putAll(this.uncommittedPartitions); for (String s : this.uncommittedRemovedPartitions) { result.remove(s); } } return result; }
public Map<String, Partition> getPartitions() { Map<String, Partition> result = new HashMap<>(this.partitions); if (this.getAbstractLabel().getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()) { result.putAll(this.uncommittedPartitions); for (String s : this.uncommittedRemovedPartitions) { result.remove(s); } } return result; }
private Partition createRangePartition(String name, String from, String to) { Preconditions.checkState(!this.getAbstractLabel().getSchema().isSqlgSchema(), "createSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); this.uncommittedPartitions.remove(name); Partition partition = Partition.createRangeSubPartition(this.sqlgGraph, this, name, from, to); this.uncommittedPartitions.put(name, partition); this.getAbstractLabel().getSchema().getTopology().fire(partition, "", TopologyChangeAction.CREATE); return partition; }
private Partition createListPartition(String name, String in) { Preconditions.checkState(!this.getAbstractLabel().getSchema().isSqlgSchema(), "createSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); this.uncommittedPartitions.remove(name); Partition partition = Partition.createListSubPartition(this.sqlgGraph, this, name, in); this.uncommittedPartitions.put(name, partition); this.getAbstractLabel().getSchema().getTopology().fire(partition, "", TopologyChangeAction.CREATE); return partition; }
private Partition createRangePartition(String name, String from, String to) { Preconditions.checkState(!this.getAbstractLabel().getSchema().isSqlgSchema(), "createSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); this.uncommittedPartitions.remove(name); Partition partition = Partition.createRangeSubPartition(this.sqlgGraph, this, name, from, to); this.uncommittedPartitions.put(name, partition); this.getAbstractLabel().getSchema().getTopology().fire(partition, "", TopologyChangeAction.CREATE); return partition; }
private Partition createListPartition(String name, String in) { Preconditions.checkState(!this.getAbstractLabel().getSchema().isSqlgSchema(), "createSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); this.uncommittedPartitions.remove(name); Partition partition = Partition.createListSubPartition(this.sqlgGraph, this, name, in); this.uncommittedPartitions.put(name, partition); this.getAbstractLabel().getSchema().getTopology().fire(partition, "", TopologyChangeAction.CREATE); return partition; }
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 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(); } }
private static Partition createListSubPartitionWithPartition( SqlgGraph sqlgGraph, Partition parentPartition, String name, String in, PartitionType partitionType, String partitionExpression) { Preconditions.checkArgument(!parentPartition.getAbstractLabel().getSchema().isSqlgSchema(), "createRangeSubPartitionWithPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); Partition partition = new Partition(sqlgGraph, parentPartition, name, in, partitionType, partitionExpression); partition.createListPartitionOnDb(); TopologyManager.addSubPartition(sqlgGraph, partition); partition.committed = false; return partition; }
private static Partition createListSubPartitionWithPartition( SqlgGraph sqlgGraph, Partition parentPartition, String name, String in, PartitionType partitionType, String partitionExpression) { Preconditions.checkArgument(!parentPartition.getAbstractLabel().getSchema().isSqlgSchema(), "createRangeSubPartitionWithPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); Partition partition = new Partition(sqlgGraph, parentPartition, name, in, partitionType, partitionExpression); partition.createListPartitionOnDb(); TopologyManager.addSubPartition(sqlgGraph, partition); partition.committed = false; return partition; }
/** * Create a list partition on an existing {@link Partition} * * @param sqlgGraph * @param parentPartition * @param name * @param in * @return */ private static Partition createListSubPartition(SqlgGraph sqlgGraph, Partition parentPartition, String name, String in) { Preconditions.checkArgument(!parentPartition.getAbstractLabel().getSchema().isSqlgSchema(), "createPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); Partition partition = new Partition(sqlgGraph, parentPartition, name, in, PartitionType.NONE, null); partition.createListPartitionOnDb(); TopologyManager.addSubPartition(sqlgGraph, partition); partition.committed = false; return partition; }
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); } }
public void createIndexOnLeafPartitions(Index index) { if (this.partitionType.isNone()) { //Append the partition name to the index name. String indexName = index.getName() + "_" + this.getName(); if (indexName.length() > this.sqlgGraph.getSqlDialect().getMaximumIndexNameLength()) { indexName = Index.generateName(this.sqlgGraph.getSqlDialect()); } index.createIndex(this.sqlgGraph, SchemaTable.of(getAbstractLabel().getSchema().getName(), this.getName()), indexName); } else { for (Partition partition : this.partitions.values()) { partition.createIndexOnLeafPartitions(index); } } }
public void createIndexOnLeafPartitions(Index index) { if (this.partitionType.isNone()) { //Append the partition name to the index name. String indexName = index.getName() + "_" + this.getName(); if (indexName.length() > this.sqlgGraph.getSqlDialect().getMaximumIndexNameLength()) { indexName = Index.generateName(this.sqlgGraph.getSqlDialect()); } index.createIndex(this.sqlgGraph, SchemaTable.of(getAbstractLabel().getSchema().getName(), this.getName()), indexName); } else { for (Partition partition : this.partitions.values()) { partition.createIndexOnLeafPartitions(index); } } }