1 module hunt.sql.ast.SQLPartitionBy; 2 3 import hunt.sql.ast.SQLDataType; 4 import hunt.sql.ast.SQLObjectImpl; 5 import hunt.sql.ast.SQLExpr; 6 import hunt.sql.ast.SQLName; 7 import hunt.sql.ast.SQLPartition; 8 import hunt.sql.ast.SQLSubPartitionBy; 9 import hunt.sql.visitor.SQLASTVisitor; 10 import hunt.collection; 11 12 13 public abstract class SQLPartitionBy : SQLObjectImpl { 14 protected SQLSubPartitionBy subPartitionBy; 15 protected SQLExpr partitionsCount; 16 protected bool linear; 17 protected List!SQLPartition partitions; 18 protected List!SQLName storeIn; 19 protected List!SQLExpr columns; 20 21 this() 22 { 23 partitions = new ArrayList!SQLPartition(); 24 storeIn = new ArrayList!SQLName(); 25 columns = new ArrayList!SQLExpr(); 26 } 27 28 public List!SQLPartition getPartitions() { 29 return partitions; 30 } 31 32 public void addPartition(SQLPartition partition) { 33 if (partition !is null) { 34 partition.setParent(this); 35 } 36 this.partitions.add(partition); 37 } 38 39 public SQLSubPartitionBy getSubPartitionBy() { 40 return subPartitionBy; 41 } 42 43 public void setSubPartitionBy(SQLSubPartitionBy subPartitionBy) { 44 if (subPartitionBy !is null) { 45 subPartitionBy.setParent(this); 46 } 47 this.subPartitionBy = subPartitionBy; 48 } 49 50 public SQLExpr getPartitionsCount() { 51 return partitionsCount; 52 } 53 54 public void setPartitionsCount(SQLExpr partitionsCount) { 55 if (partitionsCount !is null) { 56 partitionsCount.setParent(this); 57 } 58 this.partitionsCount = partitionsCount; 59 } 60 61 public bool isLinear() { 62 return linear; 63 } 64 65 public void setLinear(bool linear) { 66 this.linear = linear; 67 } 68 69 public List!SQLName getStoreIn() { 70 return storeIn; 71 } 72 73 public List!SQLExpr getColumns() { 74 return columns; 75 } 76 77 public void addColumn(SQLExpr column) { 78 if (column !is null) { 79 column.setParent(this); 80 } 81 this.columns.add(column); 82 } 83 84 public void cloneTo(SQLPartitionBy x) { 85 if (subPartitionBy !is null) { 86 x.setSubPartitionBy(subPartitionBy.clone()); 87 } 88 if (partitionsCount !is null) { 89 x.setPartitionsCount(partitionsCount.clone()); 90 } 91 x.linear = linear; 92 foreach (SQLPartition p ; partitions) { 93 SQLPartition p2 = p.clone(); 94 p2.setParent(x); 95 x.partitions.add(p2); 96 } 97 foreach (SQLName name ; storeIn) { 98 SQLName name2 = name.clone(); 99 name2.setParent(x); 100 x.storeIn.add(name2); 101 } 102 } 103 104 public override abstract SQLPartitionBy clone(); 105 }