array.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "numeric.h"
  3. namespace NClickHouse {
  4. /**
  5. * Represents column of Array(T).
  6. */
  7. class TColumnArray: public TColumn {
  8. public:
  9. static TIntrusivePtr<TColumnArray> Create(TColumnRef data);
  10. static TIntrusivePtr<TColumnArray> Create(TColumnRef data, TVector<ui64>&& offsets);
  11. /// Converts input column to array and appends
  12. /// as one row to the current column.
  13. void AppendAsColumn(TColumnRef array);
  14. /// Convets array at pos n to column.
  15. /// Type of element of result column same as type of array element.
  16. TColumnRef GetAsColumn(size_t n) const;
  17. public:
  18. /// Appends content of given column to the end of current one.
  19. void Append(TColumnRef) override;
  20. /// Loads column data from input stream.
  21. bool Load(TCodedInputStream* input, size_t rows) override;
  22. /// Saves column data to output stream.
  23. void Save(TCodedOutputStream* output) override;
  24. /// Returns count of rows in the column.
  25. size_t Size() const override;
  26. /// Makes slice of the current column.
  27. TColumnRef Slice(size_t, size_t) override {
  28. return TColumnRef();
  29. }
  30. private:
  31. TColumnArray(TColumnRef data);
  32. TColumnArray(TColumnRef data, TVector<ui64>&& offsets);
  33. size_t GetOffset(size_t n) const;
  34. size_t GetSize(size_t n) const;
  35. private:
  36. TColumnRef Data_;
  37. TIntrusivePtr<TColumnUInt64> Offsets_;
  38. };
  39. }