Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MBkkt committed Aug 4, 2023
1 parent 57c9a92 commit be29264
Show file tree
Hide file tree
Showing 48 changed files with 455 additions and 466 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checks: '*,
Checks: '-*,
-altera-*,
-android-*,
-google-objc-*,
Expand Down
26 changes: 13 additions & 13 deletions core/formats/columnstore2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ doc_iterator::ptr dense_fixed_length_column::iterator(ColumnHint hint) const {

class fixed_length_column : public column_base {
public:
using Blocks = std::vector<uint64_t, ManagedTypedAllocator<uint64_t>>;
using Blocks = ManagedVector<uint64_t>;

static column_ptr read(std::optional<std::string>&& name,
IResourceManager& rm_r, IResourceManager& rm_c,
Expand Down Expand Up @@ -1004,12 +1004,13 @@ class sparse_column : public column_base {
std::move(blocks));
}

sparse_column(
std::optional<std::string>&& name, IResourceManager& resource_manager,
bstring&& payload, column_header&& hdr, column_index&& index,
const index_input& data_in, compression::decompressor::ptr&& inflater,
encryption::stream* cipher,
std::vector<column_block, ManagedTypedAllocator<column_block>>&& blocks)
sparse_column(std::optional<std::string>&& name,
IResourceManager& resource_manager, bstring&& payload,
column_header&& hdr, column_index&& index,
const index_input& data_in,
compression::decompressor::ptr&& inflater,
encryption::stream* cipher,
ManagedVector<column_block>&& blocks)
: column_base{std::move(name), resource_manager, std::move(payload),
std::move(hdr), std::move(index), data_in,
cipher},
Expand Down Expand Up @@ -1054,9 +1055,9 @@ class sparse_column : public column_base {
}

private:
static std::vector<column_block, ManagedTypedAllocator<column_block>>
read_blocks_sparse(const column_header& hdr, index_input& in,
IResourceManager& resource_manager);
static ManagedVector<column_block> read_blocks_sparse(
const column_header& hdr, index_input& in,
IResourceManager& resource_manager);

template<typename ValueReader>
class payload_reader : private ValueReader {
Expand All @@ -1073,8 +1074,7 @@ class sparse_column : public column_base {

template<bool encrypted>
bool make_buffered_data(
column_header& hdr, index_input& in,
std::vector<column_block, ManagedTypedAllocator<column_block>>& blocks,
column_header& hdr, index_input& in, ManagedVector<column_block>& blocks,
std::vector<byte_type>& column_data,
std::span<memory::managed_ptr<column_reader>> next_sorted_columns,
remapped_bytes_view_input::mapping* mapping) {
Expand Down Expand Up @@ -1168,7 +1168,7 @@ class sparse_column : public column_base {
return true;
}

std::vector<column_block, ManagedTypedAllocator<column_block>> blocks_;
ManagedVector<column_block> blocks_;
compression::decompressor::ptr inflater_;
};

Expand Down
3 changes: 1 addition & 2 deletions core/formats/columnstore2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ class column final : public irs::column_output {
irs::type_info compression_;
compression::compressor::ptr deflater_;
columnstore_writer::column_finalizer_f finalizer_;
std::vector<column_block, ManagedTypedAllocator<column_block>>
blocks_; // at most 65536 blocks
ManagedVector<column_block> blocks_; // at most 65536 blocks
memory_output data_;
memory_output docs_;
sparse_bitmap_writer docs_writer_{docs_.stream, ctx_.version};
Expand Down
2 changes: 1 addition & 1 deletion core/formats/formats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ using DocumentMask =
absl::container_internal::hash_default_hash<doc_id_t>,
absl::container_internal::hash_default_eq<doc_id_t>,
ManagedTypedAllocator<doc_id_t>>;
using DocMap = std::vector<doc_id_t, ManagedTypedAllocator<doc_id_t>>;
using DocMap = ManagedVector<doc_id_t>;
using DocMapView = std::span<const doc_id_t>;
using callback_f = std::function<bool(doc_iterator&)>;

Expand Down
4 changes: 2 additions & 2 deletions core/formats/formats_burst_trie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ const fst::FstReadOptions& fst_read_options() {
// mininum size of string weight we store in FST
[[maybe_unused]] constexpr const size_t MIN_WEIGHT_SIZE = 2;

using Blocks = std::vector<entry, ManagedTypedAllocator<entry>>;
using Blocks = ManagedVector<entry>;

void MergeBlocks(Blocks& blocks, OutputBuffer& buffer) {
IRS_ASSERT(!blocks.empty());
Expand Down Expand Up @@ -1028,7 +1028,7 @@ class field_writer final : public irs::field_writer {
encryption::stream::ptr index_out_cipher_;
index_output::ptr index_out_; // output stream for indexes
postings_writer::ptr pw_; // postings writer
std::vector<entry, ManagedTypedAllocator<entry>> stack_;
ManagedVector<entry> stack_;
fst_buffer* fst_buf_; // pimpl buffer used for building FST for fields
volatile_byte_ref last_term_; // last pushed term
std::vector<size_t> prefixes_;
Expand Down
2 changes: 1 addition & 1 deletion core/formats/skip_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SkipWriter : util::noncopyable {
void Skip(doc_id_t count, Writer&& write);

protected:
std::vector<memory_output, ManagedTypedAllocator<memory_output>> levels_;
ManagedVector<memory_output> levels_;
size_t max_levels_;
doc_id_t skip_0_; // skip interval for 0 level
doc_id_t skip_n_; // skip interval for 1..n levels
Expand Down
3 changes: 1 addition & 2 deletions core/index/buffered_column.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ struct BufferedValue {

class BufferedColumn final : public column_output, private util::noncopyable {
public:
using BufferedValues =
std::vector<BufferedValue, ManagedTypedAllocator<BufferedValue>>;
using BufferedValues = ManagedVector<BufferedValue>;
using Buffer = irs::basic_string<irs::byte_type,
irs::ManagedTypedAllocator<irs::byte_type>>;
explicit BufferedColumn(const ColumnInfo& info, IResourceManager& rm)
Expand Down
8 changes: 3 additions & 5 deletions core/index/index_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,14 @@ class IndexWriter : private util::noncopyable {
RefTrackingDirectory dir_;

// sequential list of pending modification
std::vector<QueryContext, ManagedTypedAllocator<QueryContext>> queries_;
ManagedVector<QueryContext> queries_;
// all of the previously flushed versions of this segment
std::vector<FlushedSegment, ManagedTypedAllocator<FlushedSegment>> flushed_;
ManagedVector<FlushedSegment> flushed_;
// update_contexts to use with 'flushed_'
// sequentially increasing through all offsets
// (sequential doc_id in 'flushed_' == offset + doc_limits::min(), size()
// == sum of all 'flushed_'.'docs_count')
std::vector<segment_writer::DocContext,
ManagedTypedAllocator<segment_writer::DocContext>>
flushed_docs_;
ManagedVector<segment_writer::DocContext> flushed_docs_;

// function to get new SegmentMeta from
segment_meta_generator_t meta_generator_;
Expand Down
2 changes: 1 addition & 1 deletion core/index/merge_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void AccumulateFeatures(feature_set_t& accum, const feature_map_t& features) {

// mapping of old doc_id to new doc_id (reader doc_ids are sequential 0 based)
// masked doc_ids have value of MASKED_DOC_ID
using doc_id_map_t = std::vector<doc_id_t, ManagedTypedAllocator<doc_id_t>>;
using doc_id_map_t = ManagedVector<doc_id_t>;

// document mapping function
using doc_map_f = std::function<doc_id_t(doc_id_t)>;
Expand Down
7 changes: 3 additions & 4 deletions core/index/merge_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ class MergeWriter : public util::noncopyable {
ReaderCtx(const SubReader& reader, IResourceManager& rm) noexcept
: ReaderCtx{&reader, rm} {}

const SubReader* reader; // segment reader
std::vector<doc_id_t, ManagedTypedAllocator<doc_id_t>>
doc_id_map; // FIXME use bitpacking vector
const SubReader* reader; // segment reader
ManagedVector<doc_id_t> doc_id_map; // FIXME use bitpacking vector
std::function<doc_id_t(doc_id_t)> doc_map; // mapping function
};

Expand Down Expand Up @@ -98,7 +97,7 @@ class MergeWriter : public util::noncopyable {
const FlushProgress& progress);

directory& dir_;
std::vector<ReaderCtx, ManagedTypedAllocator<ReaderCtx>> readers_;
ManagedVector<ReaderCtx> readers_;
const ColumnInfoProvider* column_info_{};
const FeatureInfoProvider* feature_info_{};
ScorersView scorers_;
Expand Down
2 changes: 1 addition & 1 deletion core/index/segment_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class segment_writer : public ColumnProvider, util::noncopyable {
cached_columns_; // pointers remain valid
absl::flat_hash_map<field_id, cached_column*> column_ids_;
sorted_column sort_;
std::vector<DocContext, ManagedTypedAllocator<DocContext>> docs_context_;
ManagedVector<DocContext> docs_context_;
// invalid/removed doc_ids (e.g. partially indexed due to indexing failure)
DocsMask docs_mask_;
fields_data fields_;
Expand Down
6 changes: 6 additions & 0 deletions core/resource_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@

#pragma once

#include <vector>

#include "shared.hpp"
#include "utils/managed_allocator.hpp"

namespace irs {

struct IResourceManager {
static IResourceManager kNoop;
#ifdef IRESEARCH_DEBUG
Expand Down Expand Up @@ -81,4 +84,7 @@ struct ManagedTypedAllocator
using Base::Base;
};

template<typename T>
using ManagedVector = std::vector<T, ManagedTypedAllocator<T>>;

} // namespace irs
3 changes: 2 additions & 1 deletion core/search/all_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ filter::prepared::ptr all::prepare(const PrepareContext& ctx) const {

PrepareCollectors(ctx.scorers.buckets(), stats_buf);

return memory::make_managed<all_query>(std::move(stats), ctx.boost * boost());
return memory::make_tracked_managed<all_query>(ctx.memory, std::move(stats),
ctx.boost * boost());
}

} // namespace irs
11 changes: 6 additions & 5 deletions core/search/boolean_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ filter::prepared::ptr And::PrepareBoolean(std::vector<const filter*>& incl,
// single node case
return incl.front()->prepare(sub_ctx);
}
auto q = memory::make_managed<AndQuery>();
auto q = memory::make_tracked_managed<AndQuery>(ctx.memory);
q->prepare(sub_ctx, merge_type(), incl, excl);
return q;
}
Expand Down Expand Up @@ -596,11 +596,12 @@ filter::prepared::ptr Or::PrepareBoolean(std::vector<const filter*>& incl,

memory::managed_ptr<BooleanQuery> q;
if (adjusted_min_match_count == incl.size()) {
q = memory::make_managed<AndQuery>();
q = memory::make_tracked_managed<AndQuery>(ctx.memory);
} else if (1 == adjusted_min_match_count) {
q = memory::make_managed<OrQuery>();
q = memory::make_tracked_managed<OrQuery>(ctx.memory);
} else { // min_match_count > 1 && min_match_count < incl.size()
q = memory::make_managed<MinMatchQuery>(adjusted_min_match_count);
q = memory::make_tracked_managed<MinMatchQuery>(ctx.memory,
adjusted_min_match_count);
}

q->prepare(sub_ctx, merge_type(), incl, excl);
Expand All @@ -627,7 +628,7 @@ filter::prepared::ptr Not::prepare(const PrepareContext& ctx) const {
const std::array<const irs::filter*, 1> incl{all_docs.get()};
const std::array<const irs::filter*, 1> excl{res.first};

auto q = memory::make_managed<AndQuery>();
auto q = memory::make_tracked_managed<AndQuery>(sub_ctx.memory);
q->prepare(sub_ctx, ScoreMergeType::kSum, incl, excl);
return q;
}
Expand Down
9 changes: 5 additions & 4 deletions core/search/column_existence_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ filter::prepared::ptr by_column_existence::prepare(

auto& acceptor = options().acceptor;

return acceptor ? memory::make_managed<column_prefix_existence_query>(
field(), std::move(stats), acceptor, filter_boost)
: memory::make_managed<column_existence_query>(
field(), std::move(stats), filter_boost);
return acceptor
? memory::make_tracked_managed<column_prefix_existence_query>(
ctx.memory, field(), std::move(stats), acceptor, filter_boost)
: memory::make_tracked_managed<column_existence_query>(
ctx.memory, field(), std::move(stats), filter_boost);
}

} // namespace irs
Loading

0 comments on commit be29264

Please sign in to comment.