/** * Ensures that a RANGE partition exists. * * @param name The partition's name * @param from The RANGE partition's start clause. * @param to The RANGE partition's end clause. * @param partitionType The partition's {@link PartitionType} if is is going to be sub-partitioned. * @param partitionExpression The partition's partitionExpression if is is going to be sub-partitioned. * @return The {@link Partition} */ public Partition ensureRangePartitionWithSubPartitionExists(String name, String from, String to, PartitionType partitionType, String partitionExpression) { Preconditions.checkState(this.sqlgGraph.getSqlDialect().supportsPartitioning()); Objects.requireNonNull(name, "RANGE Partition's \"name\" must not be null"); Objects.requireNonNull(from, "RANGE Partition's \"from\" must not be null"); Objects.requireNonNull(to, "RANGE Partition's \"to\" must not be null"); Objects.requireNonNull(partitionType, "Sub-partition's \"partitionType\" must not be null"); Objects.requireNonNull(partitionExpression, "Sub-partition's \"partitionExpression\" must not be null"); Preconditions.checkState(this.partitionType == PartitionType.RANGE, "ensureRangePartitionExists(String name, String from, String to, PartitionType partitionType, String partitionExpression) can only be called for a RANGE partitioned VertexLabel. Found %s", this.partitionType.name()); Optional<Partition> partitionOptional = this.getPartition(name); if (!partitionOptional.isPresent()) { getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); return partitionOptional.orElseGet(() -> this.createRangePartitionWithSubPartition(name, from, to, partitionType, partitionExpression)); } else { return partitionOptional.get(); } }
/** * Ensures that a RANGE partition exists. * * @param name The partition's name * @param from The RANGE partition's start clause. * @param to The RANGE partition's end clause. * @param partitionType The partition's {@link PartitionType} if is is going to be sub-partitioned. * @param partitionExpression The partition's partitionExpression if is is going to be sub-partitioned. * @return The {@link Partition} */ public Partition ensureRangePartitionWithSubPartitionExists(String name, String from, String to, PartitionType partitionType, String partitionExpression) { Preconditions.checkState(this.sqlgGraph.getSqlDialect().supportsPartitioning()); Objects.requireNonNull(name, "RANGE Partition's \"name\" must not be null"); Objects.requireNonNull(from, "RANGE Partition's \"from\" must not be null"); Objects.requireNonNull(to, "RANGE Partition's \"to\" must not be null"); Objects.requireNonNull(partitionType, "Sub-partition's \"partitionType\" must not be null"); Objects.requireNonNull(partitionExpression, "Sub-partition's \"partitionExpression\" must not be null"); Preconditions.checkState(this.partitionType == PartitionType.RANGE, "ensureRangePartitionExists(String name, String from, String to, PartitionType partitionType, String partitionExpression) can only be called for a RANGE partitioned VertexLabel. Found %s", this.partitionType.name()); Optional<Partition> partitionOptional = this.getPartition(name); if (!partitionOptional.isPresent()) { getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); return partitionOptional.orElseGet(() -> this.createRangePartitionWithSubPartition(name, from, to, partitionType, partitionExpression)); } else { return partitionOptional.get(); } }