You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/07/15 13:19:10 UTC

[doris] branch master updated: array column support read by rowids (#10886)

This is an automated email from the ASF dual-hosted git repository.

yiguolei 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 7be2ef79ed array column support read by rowids (#10886)
7be2ef79ed is described below

commit 7be2ef79ed174ef36585deb57188a077c8e473af
Author: camby <10...@qq.com>
AuthorDate: Fri Jul 15 21:19:02 2022 +0800

    array column support read by rowids (#10886)
    
    Co-authored-by: cambyzju <zh...@baidu.com>
---
 be/src/olap/rowset/segment_v2/column_reader.cpp    | 12 ++++++
 be/src/olap/rowset/segment_v2/column_reader.h      |  7 +++-
 .../data/compaction/test_compaction_array.out      | 13 ++++++
 .../suites/compaction/test_compaction_array.groovy | 46 ++++++++++++++++++++++
 4 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/column_reader.cpp b/be/src/olap/rowset/segment_v2/column_reader.cpp
index e2aef4e2d8..57da4e3e41 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/column_reader.cpp
@@ -505,6 +505,18 @@ Status ArrayFileColumnIterator::next_batch(size_t* n, vectorized::MutableColumnP
     return Status::OK();
 }
 
+Status ArrayFileColumnIterator::read_by_rowids(const rowid_t* rowids, const size_t count,
+                                               vectorized::MutableColumnPtr& dst) {
+    for (size_t i = 0; i < count; ++i) {
+        // TODO(cambyzju): now read array one by one, need optimize later
+        RETURN_IF_ERROR(seek_to_ordinal(rowids[i]));
+        size_t num_read = 1;
+        RETURN_IF_ERROR(next_batch(&num_read, dst, nullptr));
+        DCHECK(num_read == 1);
+    }
+    return Status::OK();
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 
 FileColumnIterator::FileColumnIterator(ColumnReader* reader) : _reader(reader) {}
diff --git a/be/src/olap/rowset/segment_v2/column_reader.h b/be/src/olap/rowset/segment_v2/column_reader.h
index 9fe37bdae8..83f1c699cf 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.h
+++ b/be/src/olap/rowset/segment_v2/column_reader.h
@@ -247,12 +247,12 @@ public:
     virtual Status next_batch(size_t* n, ColumnBlockView* dst, bool* has_null) = 0;
 
     virtual Status next_batch(size_t* n, vectorized::MutableColumnPtr& dst, bool* has_null) {
-        return Status::NotSupported("not implement");
+        return Status::NotSupported("next_batch not implement");
     }
 
     virtual Status read_by_rowids(const rowid_t* rowids, const size_t count,
                                   vectorized::MutableColumnPtr& dst) {
-        return Status::NotSupported("not implement");
+        return Status::NotSupported("read_by_rowids not implement");
     }
 
     virtual ordinal_t get_current_ordinal() const = 0;
@@ -368,6 +368,9 @@ public:
 
     Status next_batch(size_t* n, vectorized::MutableColumnPtr& dst, bool* has_null) override;
 
+    Status read_by_rowids(const rowid_t* rowids, const size_t count,
+                          vectorized::MutableColumnPtr& dst) override;
+
     Status seek_to_first() override {
         RETURN_IF_ERROR(_length_iterator->seek_to_first());
         RETURN_IF_ERROR(_item_iterator->seek_to_first()); // lazy???
diff --git a/regression-test/data/compaction/test_compaction_array.out b/regression-test/data/compaction/test_compaction_array.out
new file mode 100644
index 0000000000..b21d69a4fe
--- /dev/null
+++ b/regression-test/data/compaction/test_compaction_array.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql --
+1	[1, 2, 3]
+2	[4]
+3	[]
+
+-- !sql --
+0
+
+-- !sql --
+1	[1, 2, 3]
+3	[]
+
diff --git a/regression-test/suites/compaction/test_compaction_array.groovy b/regression-test/suites/compaction/test_compaction_array.groovy
new file mode 100644
index 0000000000..2acc89d684
--- /dev/null
+++ b/regression-test/suites/compaction/test_compaction_array.groovy
@@ -0,0 +1,46 @@
+// 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.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite("test_array_compaction") {
+    def tableName = "tbl_test_array_compaction"
+
+    // open enable_array_type
+    sql """ set enable_array_type = true """
+    // array functions only supported in vectorized engine
+    sql """ set enable_vectorized_engine = true """
+
+    sql """DROP TABLE IF EXISTS ${tableName}"""
+    sql """ 
+            CREATE TABLE IF NOT EXISTS ${tableName} (
+              `k1` int(11) NULL COMMENT "",
+              `k2` ARRAY<int(11)> NOT NULL COMMENT ""
+            ) ENGINE=OLAP
+            DUPLICATE KEY(`k1`)
+            DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+            PROPERTIES (
+              "replication_allocation" = "tag.location.default: 1",
+              "storage_format" = "V2"
+            )
+        """
+    sql """ INSERT INTO ${tableName} VALUES(1, [1, 2, 3]), (2, [4]), (3, [])"""
+    qt_sql "SELECT * FROM ${tableName} ORDER BY k1"
+
+    qt_sql "DELETE FROM ${tableName} WHERE k1=2"
+    qt_sql "SELECT * FROM ${tableName} ORDER BY k1"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org