You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2024/03/22 06:27:47 UTC
(doris) branch master updated: [improvement](schema) indexes belong to base index (#32527)
This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 296696fff6f [improvement](schema) indexes belong to base index (#32527)
296696fff6f is described below
commit 296696fff6f29d3592b571368edfff1186abbc37
Author: Yongqiang YANG <98...@users.noreply.github.com>
AuthorDate: Fri Mar 22 14:27:41 2024 +0800
[improvement](schema) indexes belong to base index (#32527)
---
.../main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java | 4 +++-
.../src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java | 4 +++-
fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java | 5 ++++-
.../org/apache/doris/cloud/datasource/CloudInternalCatalog.java | 8 +++++++-
.../main/java/org/apache/doris/datasource/InternalCatalog.java | 3 ++-
.../src/main/java/org/apache/doris/master/ReportHandler.java | 5 ++++-
6 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java
index 848653ca6ac..0739da03642 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java
@@ -20,6 +20,7 @@ package org.apache.doris.alter;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.Index;
import org.apache.doris.catalog.KeysType;
import org.apache.doris.catalog.MaterializedIndex;
import org.apache.doris.catalog.OlapTable;
@@ -182,6 +183,7 @@ public class CloudSchemaChangeJobV2 extends SchemaChangeJobV2 {
int shadowSchemaVersion = indexSchemaVersionAndHashMap.get(shadowIdxId).schemaVersion;
long originIndexId = indexIdMap.get(shadowIdxId);
KeysType originKeysType = tbl.getKeysTypeByIndexId(originIndexId);
+ List<Index> tabletIndexes = originIndexId == tbl.getBaseIndexId() ? indexes : null;
Cloud.CreateTabletsRequest.Builder requestBuilder =
Cloud.CreateTabletsRequest.newBuilder();
@@ -191,7 +193,7 @@ public class CloudSchemaChangeJobV2 extends SchemaChangeJobV2 {
.createTabletMetaBuilder(tableId, shadowIdxId,
partitionId, shadowTablet, tbl.getPartitionInfo().getTabletType(partitionId),
shadowSchemaHash, originKeysType, shadowShortKeyColumnCount, bfColumns,
- bfFpp, indexes, shadowSchema, tbl.getDataSortInfo(), tbl.getCompressionType(),
+ bfFpp, tabletIndexes, shadowSchema, tbl.getDataSortInfo(), tbl.getCompressionType(),
tbl.getStoragePolicy(), tbl.isInMemory(), true,
tbl.getName(), tbl.getTTLSeconds(),
tbl.getEnableUniqueKeyMergeOnWrite(), tbl.storeRowColumn(),
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java
index 8c80321521b..fccc517f7a9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java
@@ -247,6 +247,8 @@ public class SchemaChangeJobV2 extends AlterJobV2 {
int originSchemaHash = tbl.getSchemaHashByIndexId(originIndexId);
KeysType originKeysType = tbl.getKeysTypeByIndexId(originIndexId);
+ List<Index> tabletIndexes = originIndexId == tbl.getBaseIndexId() ? indexes : null;
+
for (Tablet shadowTablet : shadowIdx.getTablets()) {
long shadowTabletId = shadowTablet.getId();
List<Replica> shadowReplicas = shadowTablet.getReplicas();
@@ -259,7 +261,7 @@ public class SchemaChangeJobV2 extends AlterJobV2 {
shadowReplicaId, shadowShortKeyColumnCount, shadowSchemaHash,
Partition.PARTITION_INIT_VERSION,
originKeysType, TStorageType.COLUMN, storageMedium,
- shadowSchema, bfColumns, bfFpp, countDownLatch, indexes,
+ shadowSchema, bfColumns, bfFpp, countDownLatch, tabletIndexes,
tbl.isInMemory(),
tbl.getPartitionInfo().getTabletType(partitionId),
null,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
index ea0f2b5100f..eab7dc51119 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
@@ -30,6 +30,7 @@ import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.EnvFactory;
import org.apache.doris.catalog.FsBroker;
+import org.apache.doris.catalog.Index;
import org.apache.doris.catalog.MaterializedIndex;
import org.apache.doris.catalog.MaterializedIndex.IndexExtState;
import org.apache.doris.catalog.MaterializedIndexMeta;
@@ -1058,6 +1059,8 @@ public class RestoreJob extends AbstractJob {
}
for (MaterializedIndex restoredIdx : restorePart.getMaterializedIndices(IndexExtState.VISIBLE)) {
MaterializedIndexMeta indexMeta = localTbl.getIndexMetaByIndexId(restoredIdx.getId());
+ List<Index> indexes = restoredIdx.getId() == localTbl.getBaseIndexId()
+ ? localTbl.getCopiedIndexes() : null;
for (Tablet restoreTablet : restoredIdx.getTablets()) {
TabletMeta tabletMeta = new TabletMeta(db.getId(), localTbl.getId(), restorePart.getId(),
restoredIdx.getId(), indexMeta.getSchemaHash(), TStorageMedium.HDD);
@@ -1071,7 +1074,7 @@ public class RestoreJob extends AbstractJob {
indexMeta.getKeysType(), TStorageType.COLUMN,
TStorageMedium.HDD /* all restored replicas will be saved to HDD */,
indexMeta.getSchema(), bfColumns, bfFpp, null,
- localTbl.getCopiedIndexes(),
+ indexes,
localTbl.isInMemory(),
localTbl.getPartitionInfo().getTabletType(restorePart.getId()),
null,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java
index 03256b291e5..d04ea878f36 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java
@@ -143,11 +143,17 @@ public class CloudInternalCatalog extends InternalCatalog {
List<Column> columns = indexMeta.getSchema();
KeysType keysType = indexMeta.getKeysType();
+ List<Index> indexes;
+ if (index.getId() == tbl.getBaseIndexId()) {
+ indexes = tbl.getIndexes();
+ } else {
+ indexes = Lists.newArrayList();
+ }
Cloud.CreateTabletsRequest.Builder requestBuilder = Cloud.CreateTabletsRequest.newBuilder();
for (Tablet tablet : index.getTablets()) {
OlapFile.TabletMetaCloudPB.Builder builder = createTabletMetaBuilder(tbl.getId(), indexId,
partitionId, tablet, tabletType, schemaHash, keysType, shortKeyColumnCount,
- bfColumns, tbl.getBfFpp(), tbl.getIndexes(), columns, tbl.getDataSortInfo(),
+ bfColumns, tbl.getBfFpp(), indexes, columns, tbl.getDataSortInfo(),
tbl.getCompressionType(), storagePolicy, isInMemory, false, tbl.getName(), tbl.getTTLSeconds(),
tbl.getEnableUniqueKeyMergeOnWrite(), tbl.storeRowColumn(), indexMeta.getSchemaVersion());
requestBuilder.addTabletMetas(builder);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index 42a350163f6..91c919af3f8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -1928,6 +1928,7 @@ public class InternalCatalog implements CatalogIf<Database> {
TStorageType storageType = indexMeta.getStorageType();
List<Column> schema = indexMeta.getSchema();
KeysType keysType = indexMeta.getKeysType();
+ List<Index> indexes = indexId == tbl.getBaseIndexId() ? tbl.getCopiedIndexes() : null;
int totalTaskNum = index.getTablets().size() * totalReplicaNum;
MarkedCountDownLatch<Long, Long> countDownLatch = new MarkedCountDownLatch<Long, Long>(totalTaskNum);
AgentBatchTask batchTask = new AgentBatchTask();
@@ -1940,7 +1941,7 @@ public class InternalCatalog implements CatalogIf<Database> {
CreateReplicaTask task = new CreateReplicaTask(backendId, dbId, tbl.getId(), partitionId, indexId,
tabletId, replicaId, shortKeyColumnCount, schemaHash, version, keysType, storageType,
realStorageMedium, schema, bfColumns, tbl.getBfFpp(), countDownLatch,
- tbl.getCopiedIndexes(), tbl.isInMemory(), tabletType,
+ indexes, tbl.isInMemory(), tabletType,
tbl.getDataSortInfo(), tbl.getCompressionType(),
tbl.getEnableUniqueKeyMergeOnWrite(), storagePolicy, tbl.disableAutoCompaction(),
tbl.enableSingleReplicaCompaction(), tbl.skipWriteIndexOnLoad(),
diff --git a/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java b/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java
index 6b24bea1ed5..485763fdff2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java
@@ -23,6 +23,7 @@ import org.apache.doris.catalog.ColocateGroupSchema;
import org.apache.doris.catalog.ColocateTableIndex;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.Index;
import org.apache.doris.catalog.MaterializedIndex;
import org.apache.doris.catalog.MaterializedIndex.IndexState;
import org.apache.doris.catalog.MaterializedIndexMeta;
@@ -829,6 +830,8 @@ public class ReportHandler extends Daemon {
MaterializedIndexMeta indexMeta = olapTable.getIndexMetaByIndexId(indexId);
Set<String> bfColumns = olapTable.getCopiedBfColumns();
double bfFpp = olapTable.getBfFpp();
+ List<Index> indexes = indexId == olapTable.getBaseIndexId()
+ ? olapTable.getCopiedIndexes() : null;
CreateReplicaTask createReplicaTask = new CreateReplicaTask(backendId, dbId,
tableId, partitionId, indexId, tabletId, replica.getId(),
indexMeta.getShortKeyColumnCount(),
@@ -836,7 +839,7 @@ public class ReportHandler extends Daemon {
indexMeta.getKeysType(),
TStorageType.COLUMN,
TStorageMedium.HDD, indexMeta.getSchema(), bfColumns, bfFpp, null,
- olapTable.getCopiedIndexes(),
+ indexes,
olapTable.isInMemory(),
olapTable.getPartitionInfo().getTabletType(partitionId),
null,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org