25 namespace foreign_storage {
28 const std::map<
ChunkKey, std::shared_ptr<ChunkMetadata>>& chunk_metadata_map,
29 const std::map<ChunkKey, AbstractBuffer*>& buffers,
42 const size_t items_per_thread = (items.size() + (max_threads - 1)) / max_threads;
43 std::list<std::set<T>> items_by_thread;
45 for (
auto item : items) {
46 if (i++ % items_per_thread == 0) {
47 items_by_thread.emplace_back(std::set<T>{});
49 items_by_thread.back().emplace(item);
51 return items_by_thread;
61 const size_t items_per_thread = (items.size() + (max_threads - 1)) / max_threads;
62 std::list<std::vector<T>> items_by_thread;
64 for (
auto item : items) {
65 if (i++ % items_per_thread == 0) {
66 items_by_thread.emplace_back(std::vector<T>{});
68 items_by_thread.back().emplace_back(item);
70 return items_by_thread;
73 template <
typename Container>
75 const Container& items,
77 std::function<
void(
const Container&)> lambda) {
79 std::vector<std::future<void>> futures;
80 for (
const auto& items : items_per_thread) {
std::vector< int > ChunkKey
bool is_system_table_chunk_key(const ChunkKey &chunk_key)
auto partition_for_threads(const std::set< T > &items, size_t max_threads)
bool is_append_table_chunk_key(const ChunkKey &chunk_key)
bool is_replicated_table_chunk_key(const ChunkKey &chunk_key)
bool key_does_not_shard_to_leaf(const ChunkKey &key)
std::shared_ptr< ChunkMetadata > get_placeholder_metadata(const SQLTypeInfo &type, size_t num_elements)
future< Result > async(Fn &&fn, Args &&...args)
std::vector< std::future< void > > create_futures_for_workers(const Container &items, size_t max_threads, std::function< void(const Container &)> lambda)
void init_chunk_for_column(const ChunkKey &chunk_key, const std::map< ChunkKey, std::shared_ptr< ChunkMetadata >> &chunk_metadata_map, const std::map< ChunkKey, AbstractBuffer * > &buffers, Chunk_NS::Chunk &chunk)
bool fragment_maps_to_leaf(const ChunkKey &key)
bool is_shardable_key(const ChunkKey &key)
const foreign_storage::ForeignTable & get_foreign_table_for_key(const ChunkKey &key)