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; }
void afterCommit() { Preconditions.checkState(this.getAbstractLabel().getSchema().getTopology().isSqlWriteLockHeldByCurrentThread(), "Partition.afterCommit must hold the write lock"); for (Iterator<Map.Entry<String, Partition>> it = this.uncommittedPartitions.entrySet().iterator(); it.hasNext(); ) { Map.Entry<String, Partition> entry = it.next(); this.partitions.put(entry.getKey(), entry.getValue()); entry.getValue().afterCommit(); it.remove(); } for (Iterator<String> it = this.uncommittedRemovedPartitions.iterator(); it.hasNext(); ) { String prop = it.next(); this.partitions.remove(prop); it.remove(); } for (Iterator<Map.Entry<String, Partition>> it = this.partitions.entrySet().iterator(); it.hasNext(); ) { Map.Entry<String, Partition> entry = it.next(); entry.getValue().afterCommit(); } }
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 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(); } }
/** * Create a range partition on an existing {@link Partition} * * @param sqlgGraph * @param parentPartition * @param name * @param from * @param to * @return */ private static Partition createRangeSubPartition(SqlgGraph sqlgGraph, Partition parentPartition, String name, String from, String to) { Preconditions.checkArgument(!parentPartition.getAbstractLabel().getSchema().isSqlgSchema(), "createRangeSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); Partition partition = new Partition(sqlgGraph, parentPartition, name, from, to, PartitionType.NONE, null); partition.createRangePartitionOnDb(); TopologyManager.addSubPartition(sqlgGraph, partition); partition.committed = false; return partition; }
Preconditions.checkState(!partitionNode.get("to").asText().equals("null")); Preconditions.checkState(partitionNode.get("in").asText().equals("null")); p = new Partition( this.sqlgGraph, this, Preconditions.checkState(partitionNode.get("to").asText().equals("null")); Preconditions.checkState(!partitionNode.get("in").asText().equals("null")); p = new Partition( this.sqlgGraph, this, ); this.partitions.put(p.getName(), p); p.fromUncommittedPartitionNotifyJson(uncommittedPartition); p.fromNotifyJsonRemove(removedPartitions);
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 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(); } }
Preconditions.checkState(!partitionNode.get("to").asText().equals("null")); Preconditions.checkState(partitionNode.get("in").asText().equals("null")); p = new Partition( abstractLabel.getSchema().getSqlgGraph(), abstractLabel, Preconditions.checkState(partitionNode.get("to").asText().equals("null")); Preconditions.checkState(!partitionNode.get("in").asText().equals("null")); p = new Partition( abstractLabel.getSchema().getSqlgGraph(), abstractLabel, if (uncommittedPartitions != null) { for (JsonNode uncommittedPartition : uncommittedPartitions) { p.fromUncommittedPartitionNotifyJson(uncommittedPartition); p.fromNotifyJsonRemove(removedPartitions);
/** * Create a list partition on an {@link AbstractLabel} * * @param sqlgGraph * @param abstractLabel * @param name * @param in * @return */ static Partition createListPartition(SqlgGraph sqlgGraph, AbstractLabel abstractLabel, String name, String in) { Preconditions.checkArgument(!abstractLabel.getSchema().isSqlgSchema(), "createListPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); Partition partition = new Partition(sqlgGraph, abstractLabel, name, in, PartitionType.NONE, null); partition.createListPartitionOnDb(); if (abstractLabel instanceof VertexLabel) { TopologyManager.addVertexLabelPartition( sqlgGraph, abstractLabel.getSchema().getName(), abstractLabel.getName(), name, in, PartitionType.NONE, null); } else { TopologyManager.addEdgeLabelPartition(sqlgGraph, abstractLabel, name, in, PartitionType.NONE, null); } partition.committed = false; return partition; }
/** * Create a range partition on an {@link AbstractLabel} * * @param sqlgGraph * @param abstractLabel * @param name * @param from * @param to * @return */ static Partition createRangePartition(SqlgGraph sqlgGraph, AbstractLabel abstractLabel, String name, String from, String to) { Preconditions.checkArgument(!abstractLabel.getSchema().isSqlgSchema(), "createRangePartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); Partition partition = new Partition(sqlgGraph, abstractLabel, name, from, to, PartitionType.NONE, null); partition.createRangePartitionOnDb(); if (abstractLabel instanceof VertexLabel) { TopologyManager.addVertexLabelPartition( sqlgGraph, abstractLabel.getSchema().getName(), abstractLabel.getName(), name, from, to, PartitionType.NONE, null); } else { TopologyManager.addEdgeLabelPartition(sqlgGraph, abstractLabel, name, from, to, PartitionType.NONE, null); } partition.committed = false; 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 createListPartitionWithSubPartition( String name, String in, PartitionType partitionType, String partitionExpression) { Preconditions.checkState(!this.getAbstractLabel().getSchema().isSqlgSchema(), "createListPartitionWithSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA); this.uncommittedPartitions.remove(name); Partition partition = Partition.createListSubPartitionWithPartition( this.sqlgGraph, this, name, in, partitionType, partitionExpression); this.uncommittedPartitions.put(name, partition); this.getAbstractLabel().getSchema().getTopology().fire(partition, "", TopologyChangeAction.CREATE); return partition; }
Partition addPartition(Vertex partitionVertex) { Preconditions.checkState(this.getAbstractLabel().getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()); VertexProperty<String> from = partitionVertex.property(SQLG_SCHEMA_PARTITION_FROM); VertexProperty<String> to = partitionVertex.property(SQLG_SCHEMA_PARTITION_TO); PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(!partitionType1.isNone()); partition = new Partition( this.sqlgGraph, this, PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(partitionType1.isNone()); partition = new Partition( this.sqlgGraph, this, PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(!partitionType1.isNone()); partition = new Partition( this.sqlgGraph, this, PartitionType partitionType1 = PartitionType.from(partitionType.value()); Preconditions.checkState(partitionType1.isNone()); partition = new Partition( this.sqlgGraph, this,
} else if (!partitionMap.containsKey(vertexPropertyPartitionVertex.<String>value(SQLG_SCHEMA_PARTITION_NAME)) && (partitionParentParentElement == null || partitionParentParentElement.label().equals("vertex_partition"))) { Partition partition = vertexLabel.addPartition(vertexPropertyPartitionVertex); partitionMap.put(partition.getName(), partition); Partition partition = partitionMap.get(partitionParentVertex.<String>value(SQLG_SCHEMA_PARTITION_NAME)); Preconditions.checkState(partition != null, "Partition %s not found", partitionParentVertex.<String>value(SQLG_SCHEMA_PARTITION_NAME)); Partition partition1 = partition.addPartition(subPartition); partitionMap.put(partition1.getName(), partition1); } else if (!partitionMap.containsKey(edgePropertyPartitionVertex.<String>value(SQLG_SCHEMA_PARTITION_NAME)) && (partitionParentParentElement == null || partitionParentParentElement.label().equals("edge_partition"))) { Partition partition = edgeLabel.addPartition(edgePropertyPartitionVertex); partitionMap.put(partition.getName(), partition); Partition partition = partitionMap.get(partitionParentVertex.<String>value(SQLG_SCHEMA_PARTITION_NAME)); Preconditions.checkState(partition != null, "Partition %s not found", partitionParentVertex.<String>value(SQLG_SCHEMA_PARTITION_NAME)); Partition partition1 = partition.addPartition(subPartition); partitionMap.put(partition1.getName(), partition1);
private Partition createListPartitionWithSubPartition(String name, String in, PartitionType partitionType, String partitionExpression) { Preconditions.checkState(!this.getSchema().isSqlgSchema(), "createListPartitionWithSubPartition may not be called for \"%s\"", SQLG_SCHEMA); this.uncommittedPartitions.remove(name); Partition partition = Partition.createListPartitionWithSubPartition(this.sqlgGraph, this, name, in, partitionType, partitionExpression); this.uncommittedPartitions.put(name, partition); this.getSchema().getTopology().fire(partition, "", TopologyChangeAction.CREATE); return partition; }
private Partition createListPartition(String name, String in) { Preconditions.checkState(!this.getSchema().isSqlgSchema(), "createListPartition may not be called for \"%s\"", SQLG_SCHEMA); this.uncommittedPartitions.remove(name); Partition partition = Partition.createListPartition(this.sqlgGraph, this, name, in); this.uncommittedPartitions.put(name, partition); this.getSchema().getTopology().fire(partition, "", TopologyChangeAction.CREATE); return partition; }
static Index createIndex(SqlgGraph sqlgGraph, AbstractLabel abstractLabel, String indexName, IndexType indexType, List<PropertyColumn> properties) { Index index = new Index(indexName, indexType, abstractLabel, properties); SchemaTable schemaTable = SchemaTable.of(abstractLabel.getSchema().getName(), abstractLabel.getLabel()); //For partitioned tables the index is on each partition. //It is created when the partition is created. if (!abstractLabel.isPartition()) { String prefix = abstractLabel instanceof VertexLabel ? VERTEX_PREFIX : EDGE_PREFIX; index.createIndex(sqlgGraph, schemaTable.withPrefix(prefix), index.getName()); } else { for (Partition partition : abstractLabel.getPartitions().values()) { partition.createIndexOnLeafPartitions(index); } } TopologyManager.addIndex(sqlgGraph, index); index.committed = false; return index; }
for (Iterator<Map.Entry<String, Partition>> it = this.partitions.entrySet().iterator(); it.hasNext(); ) { Map.Entry<String, Partition> entry = it.next(); entry.getValue().afterRollback();