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;
|
|
|
|
|
2016-03-07 04:31:10 +00:00
|
|
|
struct IDictionaryBase;
|
2015-07-13 17:10:16 +00:00
|
|
|
using DictionaryPtr = std::unique_ptr<IDictionaryBase>;
|
2015-01-30 13:43:16 +00:00
|
|
|
|
2016-03-07 04:31:10 +00:00
|
|
|
struct DictionaryLifetime;
|
|
|
|
struct DictionaryStructure;
|
2015-02-19 14:51:39 +00:00
|
|
|
class ColumnString;
|
2015-01-30 15:18:13 +00:00
|
|
|
|
2016-12-12 21:37:57 +00:00
|
|
|
|
2015-07-13 17:10:16 +00:00
|
|
|
struct IDictionaryBase
|
2015-01-21 11:39:48 +00:00
|
|
|
{
|
2016-10-26 22:27:38 +00:00
|
|
|
using Key = UInt64;
|
2015-01-21 11:39:48 +00:00
|
|
|
|
2015-06-09 16:12:51 +00:00
|
|
|
virtual std::exception_ptr getCreationException() const = 0;
|
|
|
|
|
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-07-13 17:10:16 +00:00
|
|
|
virtual ~IDictionaryBase() = default;
|
|
|
|
};
|
|
|
|
|
2016-12-12 21:37:57 +00:00
|
|
|
|
2015-07-13 17:10:16 +00:00
|
|
|
struct IDictionary : IDictionaryBase
|
|
|
|
{
|
2015-01-28 13:20:20 +00:00
|
|
|
virtual bool hasHierarchy() const = 0;
|
2015-01-21 11:39:48 +00:00
|
|
|
|
2016-08-07 09:09:18 +00:00
|
|
|
virtual void toParent(const PaddedPODArray<Key> & ids, PaddedPODArray<Key> & out) const = 0;
|
2015-11-20 15:53:23 +00:00
|
|
|
|
2016-08-07 09:09:18 +00:00
|
|
|
virtual void has(const PaddedPODArray<Key> & ids, PaddedPODArray<UInt8> & out) const = 0;
|
2015-11-20 15:53:23 +00:00
|
|
|
|
2016-12-12 21:37:57 +00:00
|
|
|
/// Methods for hierarchy.
|
2015-07-10 14:43:49 +00:00
|
|
|
|
2016-12-13 21:15:27 +00:00
|
|
|
virtual void isInVectorVector(const PaddedPODArray<Key> & child_ids, const PaddedPODArray<Key> & ancestor_ids, PaddedPODArray<UInt8> & out) const
|
2016-12-12 21:37:57 +00:00
|
|
|
{
|
|
|
|
throw Exception("Hierarchy is not supported for " + getName() + " dictionary.", ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
2015-07-10 14:43:49 +00:00
|
|
|
|
2016-12-13 21:15:27 +00:00
|
|
|
virtual void isInVectorConstant(const PaddedPODArray<Key> & child_ids, const Key ancestor_id, PaddedPODArray<UInt8> & out) const
|
2016-12-12 21:37:57 +00:00
|
|
|
{
|
|
|
|
throw Exception("Hierarchy is not supported for " + getName() + " dictionary.", ErrorCodes::NOT_IMPLEMENTED);
|
2015-07-10 14:43:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-13 21:15:27 +00:00
|
|
|
virtual void isInConstantVector(const Key child_id, const PaddedPODArray<Key> & ancestor_ids, PaddedPODArray<UInt8> & out) const
|
2015-01-28 13:20:20 +00:00
|
|
|
{
|
2016-12-12 21:37:57 +00:00
|
|
|
throw Exception("Hierarchy is not supported for " + getName() + " dictionary.", ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
2015-01-28 13:20:20 +00:00
|
|
|
|
2016-12-13 21:15:27 +00:00
|
|
|
void isInConstantConstant(const Key child_id, const Key ancestor_id, UInt8 & out) const
|
2016-12-12 21:37:57 +00:00
|
|
|
{
|
|
|
|
PaddedPODArray<UInt8> out_arr(1);
|
2016-12-13 21:15:27 +00:00
|
|
|
isInVectorConstant(PaddedPODArray<Key>(1, child_id), ancestor_id, out_arr);
|
2016-12-12 21:37:57 +00:00
|
|
|
out = out_arr[0];
|
2015-01-28 13:20:20 +00:00
|
|
|
}
|
2015-01-21 11:39:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|