123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #pragma once
- #include <yql/essentials/minikql/mkql_node.h>
- #include <yql/essentials/public/udf/udf_value.h>
- #include <util/generic/vector.h>
- namespace NKikimr {
- namespace NMiniKQL {
- class TPresortCodec {
- public:
- TPresortCodec() = default;
- struct TTypeInfo {
- NUdf::EDataSlot Slot;
- bool IsOptional;
- bool IsDesc;
- };
- void AddType(NUdf::EDataSlot slot, bool isOptional = false, bool isDesc = false);
- protected:
- size_t Current = 0;
- TVector<TTypeInfo> Types;
- };
- class TPresortEncoder : public TPresortCodec {
- public:
- TPresortEncoder() = default;
- void Start();
- void Start(TStringBuf prefix);
- void Encode(const NUdf::TUnboxedValuePod& value);
- TStringBuf Finish(); // user must copy
- private:
- TVector<ui8> Output;
- };
- class TPresortDecoder : public TPresortCodec {
- public:
- TPresortDecoder() = default;
- void Start(TStringBuf input);
- NUdf::TUnboxedValue Decode();
- void Finish();
- private:
- TVector<ui8> Buffer;
- TStringBuf Input;
- };
- class THolderFactory;
- class TGenericPresortEncoder {
- public:
- TGenericPresortEncoder(TType* type);
- TStringBuf Encode(const NUdf::TUnboxedValue& value, bool desc); // user must copy
- NUdf::TUnboxedValue Decode(TStringBuf buf, bool desc, const THolderFactory& factory);
- private:
- TType* Type;
- TVector<ui8> Output;
- TVector<ui8> Buffer;
- };
- } // NMiniKQL
- } // NKikimr
|