File: sharded_node_store.h

package info (click to toggle)
tilemaker 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 78,284 kB
  • sloc: cpp: 28,715; ansic: 4,052; makefile: 180; ruby: 77; sh: 6
file content (32 lines) | stat: -rw-r--r-- 915 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef _SHARDED_NODE_STORE
#define _SHARDED_NODE_STORE

#include <functional>
#include <memory>
#include "node_store.h"

class ShardedNodeStore : public NodeStore {
public:
	ShardedNodeStore(std::function<std::shared_ptr<NodeStore>()> createNodeStore);
	~ShardedNodeStore();
	void reopen() override;
	void finalize(size_t threadNum) override;
	LatpLon at(NodeID i) const override;
	size_t size() const override;
	void batchStart() override;
	void insert(const std::vector<element_t>& elements) override;
	void clear() override {
		reopen();
	}

	bool contains(size_t shard, NodeID id) const override;
	NodeStore& shard(size_t shard) override { return *stores[shard]; }
	const NodeStore& shard(size_t shard) const override { return *stores[shard]; }
	size_t shards() const override;

private:
	std::function<std::shared_ptr<NodeStore>()> createNodeStore;
	std::vector<std::shared_ptr<NodeStore>> stores;
};

#endif