); this.partitions.put(p.getName(), p);
); this.partitions.put(p.getName(), p);
void fromNotifyJson(JsonNode partitionNode, boolean fire) { ArrayNode partitionsNode = (ArrayNode) partitionNode.get("partitions"); if (partitionsNode != null) { for (JsonNode jsonNode : partitionsNode) { Optional<Partition> optionalPartition = getPartition(jsonNode.get("name").asText()); Preconditions.checkState(optionalPartition.isPresent(), "committed partition %s on partition %s must be present", jsonNode.get("name").asText(), this.getName()); Partition committedPartition = optionalPartition.get(); committedPartition.fromNotifyJson(jsonNode, fire); } } ArrayNode uncommittedPartitionsNode = (ArrayNode) partitionNode.get("uncommittedPartitions"); if (uncommittedPartitionsNode != null) { for (JsonNode jsonNode : uncommittedPartitionsNode) { this.fromUncommittedPartitionNotifyJson(jsonNode); } } ArrayNode uncommittedRemovedPartitions = (ArrayNode) partitionNode.get("uncommittedRemovedPartitions"); if (uncommittedRemovedPartitions != null) { for (JsonNode jsonNode : uncommittedRemovedPartitions) { String pName = jsonNode.asText(); Partition old = this.partitions.remove(pName); if (fire && old != null) { this.getAbstractLabel().getSchema().getTopology().fire(old, "", TopologyChangeAction.DELETE); } } } }
void fromNotifyJson(JsonNode partitionNode, boolean fire) { ArrayNode partitionsNode = (ArrayNode) partitionNode.get("partitions"); if (partitionsNode != null) { for (JsonNode jsonNode : partitionsNode) { Optional<Partition> optionalPartition = getPartition(jsonNode.get("name").asText()); Preconditions.checkState(optionalPartition.isPresent(), "committed partition %s on partition %s must be present", jsonNode.get("name").asText(), this.getName()); Partition committedPartition = optionalPartition.get(); committedPartition.fromNotifyJson(jsonNode, fire); } } ArrayNode uncommittedPartitionsNode = (ArrayNode) partitionNode.get("uncommittedPartitions"); if (uncommittedPartitionsNode != null) { for (JsonNode jsonNode : uncommittedPartitionsNode) { this.fromUncommittedPartitionNotifyJson(jsonNode); } } ArrayNode uncommittedRemovedPartitions = (ArrayNode) partitionNode.get("uncommittedRemovedPartitions"); if (uncommittedRemovedPartitions != null) { for (JsonNode jsonNode : uncommittedRemovedPartitions) { String pName = jsonNode.asText(); Partition old = this.partitions.remove(pName); if (fire && old != null) { this.getAbstractLabel().getSchema().getTopology().fire(old, "", TopologyChangeAction.DELETE); } } } }
if (!this.uncommittedRemovedPartitions.contains(partition.getName())) { Optional<ObjectNode> json = partition.toNotifyJson(true); if (json.isPresent()) {
if (!this.uncommittedRemovedPartitions.contains(partition.getName())) { Optional<ObjectNode> json = partition.toNotifyJson(true); if (json.isPresent()) {
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); } } }
for (Index index : getAbstractLabel().getIndexes().values()) { 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);
public void removePartition(Partition partition, boolean preserveData) { this.getSchema().getTopology().lock(); for (Partition partition1 : partition.getPartitions().values()) { partition1.remove(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.getSchema().getTopology().fire(partition, "", TopologyChangeAction.DELETE); } }
public void removePartition(Partition partition, boolean preserveData) { this.getSchema().getTopology().lock(); for (Partition partition1 : partition.getPartitions().values()) { partition1.remove(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.getSchema().getTopology().fire(partition, "", TopologyChangeAction.DELETE); } }
for (Index index : getAbstractLabel().getIndexes().values()) { 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);
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); } }
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); } }
/** * Adds the partition to a partition. A new Vertex with label Partition is added and in linked to its parent with * the SQLG_SCHEMA_PARTITION_PARTITION_EDGE edge label. * * @param sqlgGraph */ public static void addSubPartition(SqlgGraph sqlgGraph, Partition partition) { AbstractLabel abstractLabel = partition.getAbstractLabel(); addSubPartition( sqlgGraph, partition.getParentPartition().getParentPartition() != null, abstractLabel instanceof VertexLabel, abstractLabel.getSchema().getName(), abstractLabel.getName(), partition.getParentPartition().getName(), partition.getName(), partition.getPartitionType(), partition.getPartitionExpression(), partition.getFrom(), partition.getTo(), partition.getIn() ); }
/** * Adds the partition to a partition. A new Vertex with label Partition is added and in linked to its parent with * the SQLG_SCHEMA_PARTITION_PARTITION_EDGE edge label. * * @param sqlgGraph */ public static void addSubPartition(SqlgGraph sqlgGraph, Partition partition) { AbstractLabel abstractLabel = partition.getAbstractLabel(); addSubPartition( sqlgGraph, partition.getParentPartition().getParentPartition() != null, abstractLabel instanceof VertexLabel, abstractLabel.getSchema().getName(), abstractLabel.getName(), partition.getParentPartition().getName(), partition.getName(), partition.getPartitionType(), partition.getPartitionExpression(), partition.getFrom(), partition.getTo(), partition.getIn() ); }
SqlDialect sqlDialect = this.sqlgGraph.getSqlDialect(); String schema = this.getAbstractLabel().getSchema().getName(); String tableName = this.getName(); EdgeLabel edgeLabel = (EdgeLabel) this.getAbstractLabel(); StringBuilder sql = new StringBuilder();
SqlDialect sqlDialect = this.sqlgGraph.getSqlDialect(); String schema = this.getAbstractLabel().getSchema().getName(); String tableName = this.getName(); EdgeLabel edgeLabel = (EdgeLabel) this.getAbstractLabel(); StringBuilder sql = new StringBuilder();
.has(SQLG_SCHEMA_VERTEX_LABEL_NAME, abstractLabel.getName()) .repeat(__.out(SQLG_SCHEMA_VERTEX_PARTITION_EDGE, SQLG_SCHEMA_PARTITION_PARTITION_EDGE)) .until(__.has(SQLG_SCHEMA_PARTITION_NAME, partition.getName())) .toList(); .has(SQLG_SCHEMA_EDGE_LABEL_NAME, abstractLabel.getName()) .repeat(__.out(SQLG_SCHEMA_EDGE_PARTITION_EDGE, SQLG_SCHEMA_PARTITION_PARTITION_EDGE)) .until(__.has(SQLG_SCHEMA_PARTITION_NAME, partition.getName())) .toList();
.has(SQLG_SCHEMA_VERTEX_LABEL_NAME, abstractLabel.getName()) .repeat(__.out(SQLG_SCHEMA_VERTEX_PARTITION_EDGE, SQLG_SCHEMA_PARTITION_PARTITION_EDGE)) .until(__.has(SQLG_SCHEMA_PARTITION_NAME, partition.getName())) .toList(); .has(SQLG_SCHEMA_EDGE_LABEL_NAME, abstractLabel.getName()) .repeat(__.out(SQLG_SCHEMA_EDGE_PARTITION_EDGE, SQLG_SCHEMA_PARTITION_PARTITION_EDGE)) .until(__.has(SQLG_SCHEMA_PARTITION_NAME, partition.getName())) .toList();