|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.apache.iotdb.confignode.consensus.request.write.database; |
| 21 | + |
| 22 | +import org.apache.iotdb.commons.utils.BasicStructureSerDeUtil; |
| 23 | +import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; |
| 24 | +import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType; |
| 25 | + |
| 26 | +import java.io.DataOutputStream; |
| 27 | +import java.io.IOException; |
| 28 | +import java.nio.ByteBuffer; |
| 29 | +import java.util.Objects; |
| 30 | + |
| 31 | +public class SetTimePartitionOriginPlan extends ConfigPhysicalPlan { |
| 32 | + |
| 33 | + private String storageGroup; |
| 34 | + |
| 35 | + private long timePartitionOrigin; |
| 36 | + |
| 37 | + public SetTimePartitionOriginPlan() { |
| 38 | + super(ConfigPhysicalPlanType.SetTimePartitionOrigin); |
| 39 | + } |
| 40 | + |
| 41 | + public SetTimePartitionOriginPlan(String storageGroup, long timePartitionOrigin) { |
| 42 | + this(); |
| 43 | + this.storageGroup = storageGroup; |
| 44 | + this.timePartitionOrigin = timePartitionOrigin; |
| 45 | + } |
| 46 | + |
| 47 | + public String getDatabase() { |
| 48 | + return storageGroup; |
| 49 | + } |
| 50 | + |
| 51 | + public long getTimePartitionOrigin() { |
| 52 | + return timePartitionOrigin; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + protected void serializeImpl(DataOutputStream stream) throws IOException { |
| 57 | + stream.writeShort(getType().getPlanType()); |
| 58 | + |
| 59 | + BasicStructureSerDeUtil.write(storageGroup, stream); |
| 60 | + stream.writeLong(timePartitionOrigin); |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + protected void deserializeImpl(ByteBuffer buffer) throws IOException { |
| 65 | + storageGroup = BasicStructureSerDeUtil.readString(buffer); |
| 66 | + timePartitionOrigin = buffer.getLong(); |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + public boolean equals(Object o) { |
| 71 | + if (this == o) { |
| 72 | + return true; |
| 73 | + } |
| 74 | + if (o == null || getClass() != o.getClass()) { |
| 75 | + return false; |
| 76 | + } |
| 77 | + SetTimePartitionOriginPlan that = (SetTimePartitionOriginPlan) o; |
| 78 | + return timePartitionOrigin == that.timePartitionOrigin |
| 79 | + && storageGroup.equals(that.storageGroup); |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public int hashCode() { |
| 84 | + return Objects.hash(storageGroup, timePartitionOrigin); |
| 85 | + } |
| 86 | +} |
0 commit comments