blob: 0f11825ce89d1524763125e565b6532ade007f79 [file]
// 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.
#pragma once
#include <gen_cpp/PlanNodes_types.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "common/status.h"
#include "format/orc/vorc_reader.h"
#include "format/parquet/vparquet_reader.h"
#include "format/table/deletion_vector.h"
#include "format/table/table_schema_change_helper.h"
namespace doris {
class ShardedKVCache;
std::string build_paimon_deletion_vector_cache_key(const TPaimonDeletionFileDesc& deletion_file);
Status decode_paimon_deletion_vector_buffer(const char* buf, size_t buffer_size,
DeletionVector* deletion_vector);
// PaimonOrcReader: directly inherits OrcReader (no composition wrapping).
// Schema mapping in on_before_init_reader, deletion vector reading in on_after_init_reader.
class PaimonOrcReader final : public OrcReader, public TableSchemaChangeHelper {
public:
ENABLE_FACTORY_CREATOR(PaimonOrcReader);
PaimonOrcReader(RuntimeProfile* profile, RuntimeState* state,
const TFileScanRangeParams& params, const TFileRangeDesc& range,
size_t batch_size, const std::string& ctz, ShardedKVCache* kv_cache,
io::IOContext* io_ctx, FileMetaCache* meta_cache = nullptr,
bool enable_lazy_mat = true)
: OrcReader(profile, state, params, range, batch_size, ctz, io_ctx, meta_cache,
enable_lazy_mat),
_kv_cache(kv_cache) {
_init_paimon_profile();
}
PaimonOrcReader(RuntimeProfile* profile, RuntimeState* state,
const TFileScanRangeParams& params, const TFileRangeDesc& range,
size_t batch_size, const std::string& ctz, ShardedKVCache* kv_cache,
std::shared_ptr<io::IOContext> io_ctx_holder,
FileMetaCache* meta_cache = nullptr, bool enable_lazy_mat = true)
: OrcReader(profile, state, params, range, batch_size, ctz, std::move(io_ctx_holder),
meta_cache, enable_lazy_mat),
_kv_cache(kv_cache) {
_init_paimon_profile();
}
~PaimonOrcReader() final = default;
Status TEST_init_deletion_vector() { return _init_deletion_vector(); }
protected:
Status on_before_init_reader(ReaderInitContext* ctx) override;
Status on_after_init_reader(ReaderInitContext* /*ctx*/) override;
private:
void _init_paimon_profile();
Status _init_deletion_vector();
struct PaimonProfile {
RuntimeProfile::Counter* num_delete_rows = nullptr;
RuntimeProfile::Counter* delete_files_read_time = nullptr;
RuntimeProfile::Counter* parse_deletion_vector_time = nullptr;
RuntimeProfile::Counter* decoded_cache_hit_count = nullptr;
RuntimeProfile::Counter* decoded_cache_miss_count = nullptr;
RuntimeProfile::Counter* file_cache_hit_count = nullptr;
RuntimeProfile::Counter* file_cache_miss_count = nullptr;
RuntimeProfile::Counter* file_cache_peer_read_count = nullptr;
};
const DeletionVector* _deletion_vector = nullptr;
ShardedKVCache* _kv_cache;
PaimonProfile _paimon_profile;
};
// PaimonParquetReader: directly inherits ParquetReader (no composition wrapping).
class PaimonParquetReader final : public ParquetReader, public TableSchemaChangeHelper {
public:
ENABLE_FACTORY_CREATOR(PaimonParquetReader);
PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params,
const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz,
ShardedKVCache* kv_cache, io::IOContext* io_ctx, RuntimeState* state,
FileMetaCache* meta_cache = nullptr, bool enable_lazy_mat = true)
: ParquetReader(profile, params, range, batch_size, ctz, io_ctx, state, meta_cache,
enable_lazy_mat),
_kv_cache(kv_cache) {
_init_paimon_profile();
}
PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params,
const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz,
ShardedKVCache* kv_cache, std::shared_ptr<io::IOContext> io_ctx_holder,
RuntimeState* state, FileMetaCache* meta_cache = nullptr,
bool enable_lazy_mat = true)
: ParquetReader(profile, params, range, batch_size, ctz, std::move(io_ctx_holder),
state, meta_cache, enable_lazy_mat),
_kv_cache(kv_cache) {
_init_paimon_profile();
}
~PaimonParquetReader() final = default;
Status TEST_init_deletion_vector() { return _init_deletion_vector(); }
protected:
Status on_before_init_reader(ReaderInitContext* ctx) override;
Status on_after_init_reader(ReaderInitContext* /*ctx*/) override;
private:
void _init_paimon_profile();
Status _init_deletion_vector();
struct PaimonProfile {
RuntimeProfile::Counter* num_delete_rows = nullptr;
RuntimeProfile::Counter* delete_files_read_time = nullptr;
RuntimeProfile::Counter* parse_deletion_vector_time = nullptr;
RuntimeProfile::Counter* decoded_cache_hit_count = nullptr;
RuntimeProfile::Counter* decoded_cache_miss_count = nullptr;
RuntimeProfile::Counter* file_cache_hit_count = nullptr;
RuntimeProfile::Counter* file_cache_miss_count = nullptr;
RuntimeProfile::Counter* file_cache_peer_read_count = nullptr;
};
const DeletionVector* _deletion_vector = nullptr;
ShardedKVCache* _kv_cache;
PaimonProfile _paimon_profile;
};
} // namespace doris