/** * Ensures that a LIST partition exists. * * @param name The partition's name. * @param in The LIST partition's 'in' 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 ensureListPartitionWithSubPartitionExists(String name, String in, PartitionType partitionType, String partitionExpression) { Preconditions.checkState(this.sqlgGraph.getSqlDialect().supportsPartitioning()); Objects.requireNonNull(name, "LIST Partition's \"name\" must not be null"); Objects.requireNonNull(in, "LIST Partition's \"in\" 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.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()) { getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); return partitionOptional.orElseGet(() -> this.createListPartitionWithSubPartition(name, in, partitionType, partitionExpression)); } else { return partitionOptional.get(); } }
/** * Ensures that a LIST partition exists. * * @param name The partition's name. * @param in The LIST partition's 'in' 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 ensureListPartitionWithSubPartitionExists(String name, String in, PartitionType partitionType, String partitionExpression) { Preconditions.checkState(this.sqlgGraph.getSqlDialect().supportsPartitioning()); Objects.requireNonNull(name, "LIST Partition's \"name\" must not be null"); Objects.requireNonNull(in, "LIST Partition's \"in\" 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.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()) { getSchema().getTopology().lock(); partitionOptional = this.getPartition(name); return partitionOptional.orElseGet(() -> this.createListPartitionWithSubPartition(name, in, partitionType, partitionExpression)); } else { return partitionOptional.get(); } }