2015-01-21 11:39:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Core/Field.h>
|
2015-02-03 17:03:35 +00:00
|
|
|
#include <DB/Core/StringRef.h>
|
2015-01-22 14:32:38 +00:00
|
|
|
#include <Poco/Util/XMLConfiguration.h>
|
2015-02-19 14:51:39 +00:00
|
|
|
#include <DB/Common/PODArray.h>
|
2015-03-24 17:02:56 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <chrono>
|
2015-01-21 11:39:48 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2015-01-29 15:47:21 +00:00
|
|
|
class IDictionarySource;
|
|
|
|
|
2015-01-30 13:43:16 +00:00
|
|
|
class IDictionary;
|
|
|
|
using DictionaryPtr = std::unique_ptr<IDictionary>;
|
|
|
|
|
2015-01-30 15:18:13 +00:00
|
|
|
class DictionaryLifetime;
|
2015-03-24 13:59:19 +00:00
|
|
|
class DictionaryStructure;
|
2015-02-19 14:51:39 +00:00
|
|
|
class ColumnString;
|
2015-01-30 15:18:13 +00:00
|
|
|
|
2015-01-21 11:39:48 +00:00
|
|
|
class IDictionary
|
|
|
|
{
|
|
|
|
public:
|
2015-02-10 14:50:43 +00:00
|
|
|
using id_t = std::uint64_t;
|
2015-01-21 11:39:48 +00:00
|
|
|
|
2015-01-29 15:47:21 +00:00
|
|
|
virtual std::string getName() const = 0;
|
|
|
|
|
2015-01-29 14:46:15 +00:00
|
|
|
virtual std::string getTypeName() const = 0;
|
|
|
|
|
2015-03-24 11:30:16 +00:00
|
|
|
virtual std::size_t getBytesAllocated() const = 0;
|
|
|
|
|
2015-05-08 12:31:00 +00:00
|
|
|
virtual std::size_t getQueryCount() const = 0;
|
|
|
|
|
2015-03-24 17:02:56 +00:00
|
|
|
virtual double getHitRate() const = 0;
|
|
|
|
|
|
|
|
virtual std::size_t getElementCount() const = 0;
|
|
|
|
|
|
|
|
virtual double getLoadFactor() const = 0;
|
|
|
|
|
2015-01-29 15:47:21 +00:00
|
|
|
virtual bool isCached() const = 0;
|
2015-01-30 13:43:16 +00:00
|
|
|
virtual DictionaryPtr clone() const = 0;
|
2015-01-29 15:47:21 +00:00
|
|
|
|
2015-02-10 13:23:37 +00:00
|
|
|
virtual const IDictionarySource * getSource() const = 0;
|
2015-01-29 15:47:21 +00:00
|
|
|
|
2015-01-30 15:18:13 +00:00
|
|
|
virtual const DictionaryLifetime & getLifetime() const = 0;
|
|
|
|
|
2015-03-24 13:59:19 +00:00
|
|
|
virtual const DictionaryStructure & getStructure() const = 0;
|
|
|
|
|
2015-03-24 17:02:56 +00:00
|
|
|
virtual std::chrono::time_point<std::chrono::system_clock> getCreationTime() const = 0;
|
|
|
|
|
2015-05-13 16:11:07 +00:00
|
|
|
virtual bool isInjective(const std::string & attribute_name) const = 0;
|
|
|
|
|
2015-01-28 13:20:20 +00:00
|
|
|
virtual bool hasHierarchy() const = 0;
|
2015-01-21 11:39:48 +00:00
|
|
|
|
2015-01-28 13:20:20 +00:00
|
|
|
/// do not call unless you ensure that hasHierarchy() returns true
|
|
|
|
virtual id_t toParent(id_t id) const = 0;
|
2015-02-27 11:57:14 +00:00
|
|
|
virtual void toParent(const PODArray<id_t> & ids, PODArray<id_t> & out) const = 0;
|
2015-01-28 13:20:20 +00:00
|
|
|
|
|
|
|
bool in(id_t child_id, const id_t ancestor_id) const
|
|
|
|
{
|
|
|
|
while (child_id != 0 && child_id != ancestor_id)
|
|
|
|
child_id = toParent(child_id);
|
|
|
|
|
|
|
|
return child_id != 0;
|
|
|
|
}
|
|
|
|
|
2015-02-19 14:51:39 +00:00
|
|
|
/// functions for individual access
|
2015-01-28 15:02:05 +00:00
|
|
|
virtual UInt8 getUInt8(const std::string & attribute_name, id_t id) const = 0;
|
|
|
|
virtual UInt16 getUInt16(const std::string & attribute_name, id_t id) const = 0;
|
|
|
|
virtual UInt32 getUInt32(const std::string & attribute_name, id_t id) const = 0;
|
2015-01-28 13:20:20 +00:00
|
|
|
virtual UInt64 getUInt64(const std::string & attribute_name, id_t id) const = 0;
|
2015-01-28 15:02:05 +00:00
|
|
|
virtual Int8 getInt8(const std::string & attribute_name, id_t id) const = 0;
|
|
|
|
virtual Int16 getInt16(const std::string & attribute_name, id_t id) const = 0;
|
|
|
|
virtual Int32 getInt32(const std::string & attribute_name, id_t id) const = 0;
|
|
|
|
virtual Int64 getInt64(const std::string & attribute_name, id_t id) const = 0;
|
|
|
|
virtual Float32 getFloat32(const std::string & attribute_name, id_t id) const = 0;
|
|
|
|
virtual Float64 getFloat64(const std::string & attribute_name, id_t id) const = 0;
|
2015-02-26 14:53:33 +00:00
|
|
|
virtual String getString(const std::string & attribute_name, id_t id) const = 0;
|
2015-01-28 13:20:20 +00:00
|
|
|
|
2015-02-19 14:51:39 +00:00
|
|
|
/// functions for multiple access
|
2015-02-20 10:57:30 +00:00
|
|
|
virtual void getUInt8(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<UInt8> & out) const = 0;
|
|
|
|
virtual void getUInt16(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<UInt16> & out) const = 0;
|
|
|
|
virtual void getUInt32(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<UInt32> & out) const = 0;
|
|
|
|
virtual void getUInt64(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<UInt64> & out) const = 0;
|
|
|
|
virtual void getInt8(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<Int8> & out) const = 0;
|
|
|
|
virtual void getInt16(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<Int16> & out) const = 0;
|
|
|
|
virtual void getInt32(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<Int32> & out) const = 0;
|
|
|
|
virtual void getInt64(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<Int64> & out) const = 0;
|
|
|
|
virtual void getFloat32(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<Float32> & out) const = 0;
|
|
|
|
virtual void getFloat64(const std::string & attr_name, const PODArray<id_t> & ids, PODArray<Float64> & out) const = 0;
|
|
|
|
virtual void getString(const std::string & attr_name, const PODArray<id_t> & ids, ColumnString * out) const = 0;
|
2015-01-28 13:20:20 +00:00
|
|
|
|
2015-02-10 14:50:43 +00:00
|
|
|
virtual ~IDictionary() = default;
|
2015-01-21 11:39:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|