array column support read by rowids (#10886)
Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
This commit is contained in:
@ -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) {}
|
||||
|
||||
@ -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???
|
||||
|
||||
13
regression-test/data/compaction/test_compaction_array.out
Normal file
13
regression-test/data/compaction/test_compaction_array.out
Normal file
@ -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 []
|
||||
|
||||
@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user