partitionNode.get("from").asText(), partitionNode.get("to").asText(), PartitionType.from(partitionNode.get("partitionType").asText()), partitionNode.get("partitionExpression").asText().equals("null") ? null : partitionNode.get("partitionExpression").asText() ); partitionNode.get("name").asText(), partitionNode.get("in").asText(), PartitionType.from(partitionNode.get("partitionType").asText()), partitionNode.get("partitionExpression").asText().equals("null") ? null : partitionNode.get("partitionExpression").asText() );
private PartitionTree( String schemaAndName, String schema, String name, String partitionType, String partitionExpression1, String partitionExpression2, String fromToIn) { this.schemaAndName = schemaAndName; this.schema = schema; this.name = StringUtils.removeEnd(StringUtils.removeFirst(name, "\""), "\""); this.partitionExpression1 = partitionExpression1; this.partitionExpression2 = partitionExpression2; this.fromToIn = fromToIn; if (partitionType == null) { this.partitionType = PartitionType.NONE; } else { this.partitionType = PartitionType.fromPostgresPartStrat(partitionType); } }
@SuppressWarnings("unused") public boolean isListPartition() { return partitionType.isList(); }
/** * 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; }
sql.append(this.in); sql.append(")"); if (!this.partitionType.isNone()) { sql.append("\nPARTITION BY "); sql.append(this.partitionType.name()); sql.append("("); sql.append(this.partitionExpression); if (this.partitionType.isNone()) { AbstractLabel abstractLabel = getAbstractLabel(); if (abstractLabel instanceof EdgeLabel) {
public boolean isRangePartition() { return partitionType.isRange(); }
Preconditions.checkState(!in.isPresent()); if (partitionExpression.isPresent()) { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(!partitionType1.isNone()); partition = new Partition( this.sqlgGraph, partitionExpression.value()); } else { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(partitionType1.isNone()); partition = new Partition( this.sqlgGraph, Preconditions.checkState(!from.isPresent()); if (partitionExpression.isPresent()) { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(!partitionType1.isNone()); partition = new Partition( this.sqlgGraph, partitionExpression.value()); } else { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(partitionType1.isNone()); partition = new Partition( this.sqlgGraph,
public boolean isPartition() { return !partitionType.isNone(); }
/** * 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; }
sql.append(this.in); sql.append(")"); if (!this.partitionType.isNone()) { sql.append("\nPARTITION BY "); sql.append(this.partitionType.name()); sql.append("("); sql.append(this.partitionExpression); if (this.partitionType.isNone()) { AbstractLabel abstractLabel = getAbstractLabel(); if (abstractLabel instanceof EdgeLabel) {
public boolean isRangePartition() { return partitionType.isRange(); }
Preconditions.checkState(!in.isPresent()); if (partitionExpression.isPresent()) { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(!partitionType1.isNone()); partition = new Partition( this.sqlgGraph, partitionExpression.value()); } else { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(partitionType1.isNone()); partition = new Partition( this.sqlgGraph, Preconditions.checkState(!from.isPresent()); if (partitionExpression.isPresent()) { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(!partitionType1.isNone()); partition = new Partition( this.sqlgGraph, partitionExpression.value()); } else { PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(partitionType1.isNone()); partition = new Partition( this.sqlgGraph,
public boolean isPartition() { return !partitionType.isNone(); }
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(); } }
sql.append(this.to); sql.append(")"); if (!this.partitionType.isNone()) { sql.append("\nPARTITION BY "); sql.append(this.partitionType.name()); sql.append("("); sql.append(this.partitionExpression); if (this.partitionType.isNone()) { AbstractLabel abstractLabel = getAbstractLabel(); if (abstractLabel instanceof EdgeLabel) { throw new RuntimeException(e); if (this.partitionType.isNone()) { for (Index index : getAbstractLabel().getIndexes().values()) {
private String fromExpression() { if (this.fromToIn != null && this.parentPartitionTree.partitionType.isRange()) { String tmp = this.fromToIn.substring("FOR VALUES FROM (".length()); String fromTo[] = tmp.split(" TO "); String from = fromTo[0].trim(); from = StringUtils.removeStart(from, "("); from = StringUtils.removeEnd(from, ")"); return from; } else { return null; } }
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); } } }