imay commented on a change in pull request #1695: Refactor alter job
URL: https://github.com/apache/incubator-doris/pull/1695#discussion_r319369421
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/alter/RollupJobV2.java
 ##########
 @@ -0,0 +1,744 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.alter;
+
+import org.apache.doris.catalog.Catalog;
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.KeysType;
+import org.apache.doris.catalog.MaterializedIndex;
+import org.apache.doris.catalog.MaterializedIndex.IndexState;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.OlapTable.OlapTableState;
+import org.apache.doris.catalog.Partition;
+import org.apache.doris.catalog.Replica;
+import org.apache.doris.catalog.Replica.ReplicaState;
+import org.apache.doris.catalog.Tablet;
+import org.apache.doris.catalog.TabletInvertedIndex;
+import org.apache.doris.catalog.TabletMeta;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.FeConstants;
+import org.apache.doris.common.MarkedCountDownLatch;
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.util.TimeUtils;
+import org.apache.doris.task.AgentBatchTask;
+import org.apache.doris.task.AgentTask;
+import org.apache.doris.task.AgentTaskExecutor;
+import org.apache.doris.task.AgentTaskQueue;
+import org.apache.doris.task.AlterReplicaTask;
+import org.apache.doris.task.CreateReplicaTask;
+import org.apache.doris.thrift.TStorageMedium;
+import org.apache.doris.thrift.TStorageType;
+import org.apache.doris.thrift.TTaskType;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * Author: Chenmingyu
+ * Date: Jul 8, 2019
+ */
+
+/*
+ * Version 2 of RollupJob.
+ * This is for replacing the old RollupJob
+ * https://github.com/apache/incubator-doris/issues/1429
+ */
+public class RollupJobV2 extends AlterJobV2 {
+    private static final Logger LOG = LogManager.getLogger(RollupJobV2.class);
+
+    // partition id -> (rollup tablet id -> base tablet id)
+    private Map<Long, Map<Long, Long>> partitionIdToBaseRollupTabletIdMap = 
Maps.newHashMap();
+    private Map<Long, MaterializedIndex> partitionIdToRollupIndex = 
Maps.newHashMap();
+
+    // rollup and base schema info
+    private long baseIndexId;
+    private long rollupIndexId;
+    private String baseIndexName;
+    private String rollupIndexName;
+
+    private List<Column> rollupSchema = Lists.newArrayList();
+    private int baseSchemaHash;
+    private int rollupSchemaHash;
+
+    private KeysType rollupKeysType;
+    private short rollupShortKeyColumnCount;
+
+    // The rollup job will wait all transactions before this txn id finished, 
then send the rollup tasks.
+    protected long watershedTxnId = -1;
+
+    // save all create rollup tasks
+    private AgentBatchTask rollupBatchTask = new AgentBatchTask();
+
+    public RollupJobV2(long jobId, long dbId, long tableId, String tableName, 
long timeoutMs,
+            long baseIndexId, long rollupIndexId, String baseIndexName, String 
rollupIndexName,
+            List<Column> rollupSchema, int baseSchemaHash, int 
rollupSchemaHash,
+            KeysType rollupKeysType, short rollupShortKeyColumnCount) {
+        super(jobId, JobType.ROLLUP, dbId, tableId, tableName, timeoutMs);
+
+        this.baseIndexId = baseIndexId;
+        this.rollupIndexId = rollupIndexId;
+        this.baseIndexName = baseIndexName;
+        this.rollupIndexName = rollupIndexName;
+
+        this.rollupSchema = rollupSchema;
+        this.baseSchemaHash = baseSchemaHash;
+        this.rollupSchemaHash = rollupSchemaHash;
+        this.rollupKeysType = rollupKeysType;
+        this.rollupShortKeyColumnCount = rollupShortKeyColumnCount;
+    }
+
+    private RollupJobV2() {
+        super(JobType.ROLLUP);
+    }
+
+    public void addTabletIdMap(long partitionId, long rollupTabletId, long 
baseTabletId) {
 
 Review comment:
   does it need thread safe?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to