taco-db  0.1.0
datum.h
Go to the documentation of this file.
1 
28 namespace taco {
29 
34 namespace datum_impl {
35 
36 typedef uintptr_t DatumRep;
37 static_assert(sizeof(DatumRep) == 8, "Pointers are not 64-bit.");
38 
46  int32_t int32_v;
47  float float_v;
48 };
49 
57  int64_t int64_v;
58  double double_v;
59 };
60 
61 template<class DatumImpl>
63 public:
68  constexpr const char*
69  GetFixedlenBytes() const {
70  return (const char*) &val();
71  }
72 
76  constexpr bool
77  GetBool() const {
78  return ((bool) ((val()) != 0));
79  }
80 
84  constexpr char
85  GetChar() const {
86  return ((char) (val()));
87  }
88 
92  constexpr int8_t
93  GetInt8() const {
94  return ((int8_t) (val()));
95  }
96 
100  constexpr uint8_t
101  GetUInt8() const {
102  return ((uint8_t) (val()));
103  }
104 
108  constexpr int16_t
109  GetInt16() const {
110  return ((int16_t) (val()));
111  }
112 
116  constexpr uint16_t
117  GetUInt16() const {
118  return ((uint16_t) (val()));
119  }
120 
124  constexpr int32_t
125  GetInt32() const {
126  return ((int32_t) (val()));
127  }
128 
132  constexpr uint32_t
133  GetUInt32() const {
134  return ((uint32_t) (val()));
135  }
136 
140  constexpr Oid
141  GetOid() const {
142  return ((Oid) (val()));
143  }
144 
148  constexpr int64_t
149  GetInt64() const {
150  return (int64_t) val();
151  }
152 
156  constexpr uint64_t
157  GetUInt64() const {
158  return (uint64_t) val();
159  }
160 
164  constexpr float
165  GetFloat() const {
167  }
168 
172  constexpr double
173  GetDouble() const {
175  }
176 
180  constexpr void*
181  GetPointer() const {
182  return ((void*) (val()));
183  }
184 
188  template<class T>
189  constexpr T*
190  GetPointerAs() const {
191  return reinterpret_cast<T* const>(val());
192  }
193 
194 protected:
195  constexpr const DatumRep&
196  val() const {
197  return static_cast<const DatumImpl&>(*this).m_val;
198  }
199 };
200 
201 template<class DatumImpl>
202 class DatumRefVarlenGetters;
203 
204 } // namespace datum_impl
205 
250 class Datum: public datum_impl::NonVarlenGetters<Datum> {
251 public:
252  ~Datum() {
253  if (m_isowned) {
254  free(GetPointer());
255  }
256  }
257 
262  Datum(Datum &&d) {
263  memcpy(this, &d, sizeof(Datum));
264 
265  // GCC >=8 complains about clearing an object with no trivial
266  // copy-assignment. It should be Ok here, since we are transferring
267  // the ownership from d to this.
268 #if __GNUC__ >= 8
269 #pragma GCC diagnostic push
270 #pragma GCC diagnostic ignored "-Wclass-memaccess"
271 #endif
272  memset(&d, 0, sizeof(Datum));
273 #if __GNUC__ >= 8
274 #pragma GCC diagnostic pop
275 #endif
276  d.m_isnull = true;
277  }
278 
284  memcpy(this, &d, sizeof(Datum));
285 
286  // same as above in Datum(Datum&&)
287 #if __GNUC__ >= 8
288 #pragma GCC diagnostic push
289 #pragma GCC diagnostic ignored "-Wclass-memaccess"
290 #endif
291  memset(&d, 0, sizeof(Datum));
292 #if __GNUC__ >= 8
293 #pragma GCC diagnostic pop
294 #endif
295  d.m_isnull = true;
296  return *this;
297  }
298 
299  bool
300  isnull() const {
301  return m_isnull;
302  }
303 
307  const char*
308  GetVarlenBytes() const {
309  return (const char *) m_val;
310  }
311 
315  uint32_t
316  GetVarlenSize() const {
317  return m_size;
318  }
319 
320  /*
321  * Returns the variable-length value of a datum as an absl::string_view.
322  *
323  * This is equivalent to absl::string_view(GetVarlenBytes(),
324  * GetVarlenSize()).
325  */
326  absl::string_view
328  return absl::string_view((const char *) m_val, m_size);
329  }
330 
334  const Datum&
335  GetThis() const {
336  return *this;
337  }
338 
339  /*
340  * Returns datum representation of a null value.
341  */
342  static Datum
344  return Datum();
345  }
346 
350  static Datum
351  From(bool X) {
352  return Datum((datum_impl::DatumRep) ((X) ? 1 : 0));
353  }
354 
358  static Datum
359  From(char X) {
360  return Datum((datum_impl::DatumRep) (X));
361  }
362 
366  static Datum
367  From(int8_t X) {
368  return Datum((datum_impl::DatumRep) (X));
369  }
370 
374  static Datum
375  From(uint8_t X) {
376  return Datum((datum_impl::DatumRep) (X));
377  }
378 
382  static Datum
383  From(int16_t X) {
384  return Datum((datum_impl::DatumRep) (X));
385  }
386 
390  static Datum
391  From(uint16_t X) {
392  return Datum((datum_impl::DatumRep) (X));
393  }
394 
398  static Datum
399  From(int32_t X) {
400  return Datum((datum_impl::DatumRep) (X));
401  }
402 
409  static Datum
410  From(uint32_t X) {
411  return Datum((datum_impl::DatumRep) (X));
412  }
413 
417  static Datum
418  From(void *X) {
419  return Datum((datum_impl::DatumRep) (X));
420  }
421 
426  static Datum
427  From(int64_t X) {
428  return Datum((datum_impl::DatumRep) X);
429  }
430 
435  static Datum
436  From(uint64_t X) {
437  return Datum((datum_impl::DatumRep) X);
438  }
439 
440 
445  static Datum
446  From(float X) {
447  return datum_impl::DatumFloatConversion{.float_v=X}.int32_v;
448  }
449 
454  static Datum
455  From(double X) {
456  return datum_impl::DatumDoubleConversion{.double_v=X}.int64_v;
457  }
458 
466  static Datum
467  FromCString(const char *str) {
468  size_t len = std::strlen(str);
469  if (len > std::numeric_limits<uint32_t>::max()) {
470  LOG(kFatal, "cstring is too long: %lu", len);
471  }
472  return FromVarlenBytes(str, len);
473  }
474 
475  /*
476  * Returns datum representation of a null-terminated string that is not
477  * owned by this datum if isnull is false, or otherwise, returns a datum of
478  * a null value. A null-terminated string is always treated as
479  * a variable-length datum so you have to call GetVarlenAsStringView() to
480  * convert it back to a string (though there is no guarantee that the
481  * returned string_view has a pointer to a null-terminated string).
482  */
483  static Datum
484  FromCString(const char *str, bool isnull) {
485  return isnull ? Datum() : FromCString(str);
486  }
487 
501  static Datum
502  FromCString(std::unique_ptr<char[]> str, bool isnull = false) {
503  if (isnull || !str.get())
504  return Datum();
505  size_t len = std::strlen(str.get());
506  if (len > std::numeric_limits<uint32_t>::max()) {
507  LOG(kFatal, "cstring is too long: %lu", len);
508  }
509  return Datum((datum_impl::DatumRep) str.release(), true, len);
510  }
511 
516  static Datum
517  FromVarlenBytes(const char *bytes, uint32_t size) {
518  return Datum((datum_impl::DatumRep) bytes, false, size);
519  }
520 
526  static Datum
527  FromVarlenBytes(const char *bytes, uint32_t size, bool isnull) {
528  return isnull ? Datum() : FromVarlenBytes(bytes, size);
529  }
530 
549  static Datum
550  FromVarlenBytes(unique_malloced_ptr bytes, uint32_t size,
551  bool isnull = false) {
552  if (!bytes.get() || isnull) {
553  return Datum();
554  }
555  return Datum((datum_impl::DatumRep) bytes.release(), true, size);
556  }
557 
562  static Datum
563  FromVarlenAsStringView(absl::string_view bytes) {
564  if (!bytes.data())
565  return Datum();
566  return FromVarlenBytes(bytes.data(), bytes.size());
567  }
568 
575  template<class T>
576  static Datum
577  From(T&& X, bool isnull) {
578  return isnull ? Datum() : From(std::forward<T>(X));
579  }
580 
585  static Datum
586  FromFixedlenBytes(const char *bytes, uint32_t size) {
587  //ASSERT(TYPEALIGN(size, (uintptr_t) bytes) == (uintptr_t) bytes);
588 
589  switch (size) {
590  case 1:
591  return Datum((datum_impl::DatumRep)*(uint8_t*)bytes);
592  case 2:
593  return Datum((datum_impl::DatumRep)*(uint16_t*)bytes);
594  case 4:
595  return Datum((datum_impl::DatumRep)*(uint32_t*)bytes);
596  case 8:
597  return Datum((datum_impl::DatumRep)*(uint64_t*)bytes);
598  }
599 
600  LOG(kError, "unexpected pass-by-value data length %u", size);
601  return Datum();
602  }
603 
611  bool
612  HasExternalRef() const {
613  return m_isvarlen && !m_isowned;
614  }
615 
620  Datum
621  DeepCopy() const {
622  if (m_isvarlen) {
623  const char *bytes = GetVarlenBytes();
624  size_t size = GetVarlenSize();
625  // We don't know what exactly the alignment requirement is, so
626  // make it the maximum a type might need.
627  unique_malloced_ptr bytes_copy = unique_aligned_alloc(8, size);
628  memcpy(bytes_copy.get(), bytes, size);
629  return Datum::FromVarlenBytes(std::move(bytes_copy), size);
630  }
631  return Copy();
632  }
633 
639  Datum
640  Copy() const {
641  if (m_isvarlen && m_isowned) {
642  // make sure it is not owned in the shallow copy.
644  }
645  return Datum(*this);
646  }
647 
648 private:
652  Datum():
653  m_isowned(false),
654  m_isnull(true),
655  m_isvarlen(false),
656  m_size(0),
657  m_val(0) {}
658 
660  m_isowned(false),
661  m_isnull(false),
662  m_isvarlen(false),
663  m_size(0),
664  m_val(value) {}
665 
670  /*Datum(datum_impl::DatumRep value, bool isowned):
671  m_isowned(isowned),
672  m_isnull(false),
673  m_isvarlen(false),
674  m_size(0),
675  m_val(value) {} */
676 
678  bool isowned,
679  uint32_t size):
680  m_isowned(isowned),
681  m_isnull(false),
682  m_isvarlen(true),
683  m_size(size),
684  m_val(value) {}
685 
686  // The default constructor and copy assignment should not be used outside
687  // the Datum class.
688  Datum(const Datum&) = default;
689  Datum &operator=(const Datum&) = default;
690 
696  bool m_isowned : 1;
697 
701  bool m_isnull : 1;
702 
707  bool m_isvarlen : 1;
708 
713  uint32_t m_size;
714 
719 
720  template<class DatumImpl>
722  template<class DatumImpl>
724  friend class DatumRef;
725  friend class NullableDatumRef;
726  friend struct DataArray;
727 };
728 
729 namespace datum_impl {
730 
731 template<class DatumImpl>
732 class DatumRefVarlenGetters: public NonVarlenGetters<DatumImpl> {
733 public:
734 
738  constexpr const char*
739  GetVarlenBytes() const {
740  return NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>()
741  ->GetVarlenBytes();
742  }
743 
747  constexpr uint32_t
748  GetVarlenSize() const {
749  return NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>()
750  ->GetVarlenSize();
751  }
752 
753  /*
754  * Returns the variable-length value of a datum as an absl::string_view.
755  *
756  * This is equivalent to
757  * absl::string_view(GetVarlenBytes(), GetVarlenSize()).
758  *
759  * This is also used for returning a string value but the string is not
760  * guaranteed to be null-terminated -- see FromCString() for additional
761  * notes.
762  */
763  constexpr absl::string_view
765  return NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>()
766  ->GetVarlenAsStringView();
767  }
768 
776  constexpr Datum&
777  GetDatum() const {
778  return *NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>();
779  }
780 
794  Datum
795  DeepCopy(bool isbyref) const {
796  if (((DatumImpl&)(*this)).isnull()) {
797  return Datum();
798  }
799  if (isbyref) {
800  return GetDatum().DeepCopy();
801  } else {
803  }
804  }
805 };
806 
807 } // namespace datum_impl
808 
824 public:
825  DatumRef(const Datum &d):
826  m_val(d.m_isvarlen? ((datum_impl::DatumRep) &d) : d.m_val) {}
827  // DatumRef must not have a non-trivial destructor.
828 
829  DatumRef(const DatumRef &) = default;
830  DatumRef &operator=(const DatumRef&) = default;
831 
832  constexpr bool
833  isnull() const {
834  return false;
835  }
836 
837 protected:
839  m_val(val) {}
840 
842 
844  friend class NullableDatumRef;
845 };
846 
847 /* Make sure that DatumRef may be passed in a register whenever possible. */
848 static_assert(sizeof(DatumRef) == sizeof(datum_impl::DatumRep));
849 
850 /*
851  * NullableDatumRef additionally stores whether an object is null or not.
852  * In some cases, we want to pass the nullness of an object as well, e.g., as
853  * arguments to a fmgr-managed function. NullableDatumRef allows for that.
854  *
855  * Different from DatumRef, the only reason that NullableDatumRef does not just
856  * wrap a pointer to a Datum is that we want to have implicit conversion from a
857  * DatamRef to a NullableDatumRef, and DatumRef may not be a pointer to a
858  * Datum in all cases.
859  */
861  public datum_impl::DatumRefVarlenGetters<NullableDatumRef> {
862 public:
864  m_isnull(d.m_isnull),
865  m_val(d.m_isvarlen? ((datum_impl::DatumRep) &d) : d.m_val) {}
866 
868  m_isnull(false),
869  m_val(d.m_val) {}
870 
873 
874  operator DatumRef() const {
875  if (m_isnull)
876  LOG(kFatal, "casting NULL datum to a DatumRef");
877  return DatumRef(m_val);
878  }
879 
880  constexpr bool
881  isnull() const {
882  return m_isnull;
883  }
884 
885 private:
886  bool m_isnull;
888 
890 };
891 
903 struct DataArray {
904  constexpr static uint32_t VARLEN_MASK = 1u << 31;
905 
912  static Datum
913  From(const Datum *data, uint32_t n) {
914  uint32_t total_sz = MAXALIGN(n * sizeof(uint32_t));
915  for (size_t i = 0; i < n; ++i) {
916  total_sz += data[i].m_isvarlen ? MAXALIGN(data[i].m_size) :
917  (data[i].m_isnull ? 0 :
918  (uint32_t) sizeof(datum_impl::DatumRep));
919  }
920  unique_malloced_ptr bytes = unique_aligned_alloc(8, total_sz);
921  auto off = reinterpret_cast<uint32_t*>(bytes.get());
922  off[0] = n;
923  uint32_t cur_off = MAXALIGN(n * sizeof(uint32_t));
924  auto payload = reinterpret_cast<char*>(bytes.get());
925  for (size_t i = 0; i < n; ++i) {
926  if (data[i].m_isvarlen) {
927  memcpy(payload + cur_off, (const char*) data[i].m_val,
928  data[i].m_size);
929  cur_off += MAXALIGN(data[i].m_size);
930  } else if (!data[i].m_isnull) {
931  *reinterpret_cast<datum_impl::DatumRep*>(payload + cur_off)
932  = data[i].m_val;
933  cur_off += sizeof(datum_impl::DatumRep);
934  }
935  if (i + 1 != n) {
936  off[i + 1] = cur_off;
937  }
938  if (data[i].m_isvarlen) {
939  off[i] |= VARLEN_MASK;
940  }
941  }
942  ASSERT(cur_off == total_sz);
943  return Datum::FromVarlenBytes(std::move(bytes), total_sz);
944  }
945 
949  template<class SomeDatum>
950  static size_t
951  GetArrayLength(SomeDatum &&d) {
952  return *reinterpret_cast<const uint32_t*>(d.GetVarlenBytes())
953  & ~VARLEN_MASK;
954  }
955 
960  template<class SomeDatum>
961  static Datum
962  GetDatum(SomeDatum &&d, size_t i) {
963  uint32_t n = GetArrayLength(d);
964  uint32_t off;
965  uint32_t end_off;
966  if (i == 0) {
967  off = MAXALIGN(n * sizeof(uint32_t));
968  } else {
969  off = reinterpret_cast<const uint32_t*>(d.GetVarlenBytes())[i]
970  & ~VARLEN_MASK;
971  }
972 
973  if (i + 1 == n) {
974  end_off = d.GetVarlenSize();
975  } else {
976  end_off = reinterpret_cast<const uint32_t*>(
977  d.GetVarlenBytes())[i + 1] & ~VARLEN_MASK;
978  }
979  if (end_off == off) {
980  return Datum::FromNull();
981  }
982 
983  if (VARLEN_MASK &
984  reinterpret_cast<const uint32_t*>(d.GetVarlenBytes())[i]) {
985  // varlen-value
986  return Datum::FromVarlenBytes(d.GetVarlenBytes() + off,
987  end_off - off);
988  } else {
989  // fixed-len value
990  return Datum::FromFixedlenBytes(d.GetVarlenBytes() + off,
991  sizeof(datum_impl::DatumRep));
992  }
993  }
994 };
995 
996 } // namespace taco
A DatumRef object is a read-only reference to an C++ object of a supported runtime type.
Definition: datum.h:823
DatumRef(datum_impl::DatumRep val)
Definition: datum.h:838
DatumRef(const Datum &d)
Definition: datum.h:825
datum_impl::DatumRep m_val
Definition: datum.h:841
constexpr bool isnull() const
Definition: datum.h:833
DatumRef(const DatumRef &)=default
DatumRef & operator=(const DatumRef &)=default
A Datum stores and possibly manage the memory resource of a read-only value of a plain fixed-length C...
Definition: datum.h:250
static Datum From(int32_t X)
Returns datum representation for a 32-bit integer.
Definition: datum.h:399
uint32_t m_size
The length of the variable-length value of the datum.
Definition: datum.h:713
const Datum & GetThis() const
Returns a constant reference to ‘*this’.
Definition: datum.h:335
Datum(datum_impl::DatumRep value)
Definition: datum.h:659
static Datum FromCString(const char *str, bool isnull)
Definition: datum.h:484
Datum(const Datum &)=default
~Datum()
Definition: datum.h:252
static Datum FromVarlenAsStringView(absl::string_view bytes)
Returns datum representation of a variable-length object stored as an absl::string_view that is not o...
Definition: datum.h:563
static Datum FromVarlenBytes(const char *bytes, uint32_t size)
Returns datum representation of a variable-length object that is not owned by this datum.
Definition: datum.h:517
static Datum FromCString(std::unique_ptr< char[]> str, bool isnull=false)
Returns datum representation of a null-terminated string that is owned by this datum.
Definition: datum.h:502
static Datum From(int16_t X)
Returns datum representation for a 16-bit integer.
Definition: datum.h:383
Datum & operator=(Datum &&d)
Move assignment operator of Datum.
Definition: datum.h:283
static Datum From(void *X)
Returns datum representation for a pointer.
Definition: datum.h:418
uint32_t GetVarlenSize() const
Returns the size of the variable-length value of a datum.
Definition: datum.h:316
static Datum From(double X)
Returns datum representation for a double-precision floating point number.
Definition: datum.h:455
static Datum From(char X)
Returns datum representation for a character.
Definition: datum.h:359
bool m_isvarlen
Whether the managed object is a variable-length object that is not a null-terminated string.
Definition: datum.h:707
static Datum From(int8_t X)
Returns datum representation for an 8-bit integer.
Definition: datum.h:367
static Datum From(bool X)
Returns datum representation for a boolean.
Definition: datum.h:351
static Datum From(uint64_t X)
Returns datum representation for an unsigned 64-bit integer.
Definition: datum.h:436
bool m_isowned
Whether the managed object is owned by this Datum.
Definition: datum.h:696
static Datum From(uint8_t X)
Returns datum representation for an 8-bit unsigned integer.
Definition: datum.h:375
datum_impl::DatumRep m_val
The actual value storage.
Definition: datum.h:718
bool HasExternalRef() const
Whether this datum is variable-length but does not own its byte array.
Definition: datum.h:612
absl::string_view GetVarlenAsStringView() const
Definition: datum.h:327
bool isnull() const
Definition: datum.h:300
const char * GetVarlenBytes() const
Returns the variable-length value of a datum as an array of bytes.
Definition: datum.h:308
Datum(datum_impl::DatumRep value, bool isowned, uint32_t size)
Constructs a Datum with a non-null and non-variable-length value (except for CString).
Definition: datum.h:677
static Datum FromNull()
Definition: datum.h:343
Datum Copy() const
Makes a shallow copy of this datum.
Definition: datum.h:640
Datum & operator=(const Datum &)=default
Datum DeepCopy() const
Returns a deep copy of this datum so that HasExternalRef() == false and the owned value is a copy of ...
Definition: datum.h:621
static Datum From(uint16_t X)
Returns datum representation for a 16-bit unsigned integer.
Definition: datum.h:391
static Datum FromVarlenBytes(const char *bytes, uint32_t size, bool isnull)
Returns datum representation of a variable-length object that is not owned by this datum if isnull is...
Definition: datum.h:527
Datum(Datum &&d)
Move constructor of Datum.
Definition: datum.h:262
static Datum From(T &&X, bool isnull)
This template version of From accepts a second argument isnull and returns a Datum with a null value ...
Definition: datum.h:577
Datum()
Constructs a Datum with a null value.
Definition: datum.h:652
static Datum From(float X)
Returns datum representation for a single-precision floating point number.
Definition: datum.h:446
bool m_isnull
Whether the value is null.
Definition: datum.h:701
static Datum From(uint32_t X)
Returns datum representation for a 32-bit unsigned integer.
Definition: datum.h:410
static Datum FromVarlenBytes(unique_malloced_ptr bytes, uint32_t size, bool isnull=false)
Returns datum representation of a variable-length object that is owned by this datum.
Definition: datum.h:550
static Datum FromCString(const char *str)
Returns datum representation of a null-terminated string that is not owned by this datum.
Definition: datum.h:467
static Datum FromFixedlenBytes(const char *bytes, uint32_t size)
Returns a fixed-length datum that is passed by value by copying its binary representation.
Definition: datum.h:586
static Datum From(int64_t X)
Returns datum representation for a signed 64-bit integer.
Definition: datum.h:427
Definition: datum.h:861
NullableDatumRef(const NullableDatumRef &)=default
NullableDatumRef(const DatumRef &d)
Definition: datum.h:867
NullableDatumRef & operator=(const NullableDatumRef &)=default
datum_impl::DatumRep m_val
Definition: datum.h:887
NullableDatumRef(const Datum &d)
Definition: datum.h:863
bool m_isnull
Definition: datum.h:886
constexpr bool isnull() const
Definition: datum.h:881
Datum DeepCopy(bool isbyref) const
Returns a new Datum that is a deep copy of the underlying datum.
Definition: datum.h:795
constexpr const char * GetVarlenBytes() const
Returns the variable-length value of a datum as an array of bytes.
Definition: datum.h:739
constexpr absl::string_view GetVarlenAsStringView() const
Definition: datum.h:764
constexpr uint32_t GetVarlenSize() const
Returns the length of the variable-length value of a datum.
Definition: datum.h:748
constexpr Datum & GetDatum() const
Returns a reference to the underlying datum if this references one with a variable-length value.
Definition: datum.h:777
constexpr uint32_t GetUInt32() const
Returns 32-bit unsigned integer value of a datum.
Definition: datum.h:133
constexpr int32_t GetInt32() const
Returns 32-bit integer value of a datum.
Definition: datum.h:125
constexpr float GetFloat() const
Returns single-precision floating point value of a datum.
Definition: datum.h:165
constexpr bool GetBool() const
Returns boolean value of a datum.
Definition: datum.h:77
constexpr double GetDouble() const
Returns double-precision floating point value of a datum.
Definition: datum.h:173
constexpr const DatumRep & val() const
Definition: datum.h:196
constexpr int8_t GetInt8() const
Returns 8-bit integer value of a datum.
Definition: datum.h:93
constexpr uint8_t GetUInt8() const
Returns 8-bit unsigned integer value of a datum.
Definition: datum.h:101
constexpr int64_t GetInt64() const
Returns 64-bit integer value of a datum.
Definition: datum.h:149
constexpr T * GetPointerAs() const
Returns the pointer value of a datum as const T*.
Definition: datum.h:190
constexpr int16_t GetInt16() const
Returns 16-bit integer value of a datum.
Definition: datum.h:109
constexpr uint64_t GetUInt64() const
Returns 64-bit unsigned integer value of a datum.
Definition: datum.h:157
constexpr const char * GetFixedlenBytes() const
Return the pointer to the binary representation of a fixed-length datum that is passed by value.
Definition: datum.h:69
constexpr void * GetPointer() const
Returns pointer value of a datum.
Definition: datum.h:181
constexpr uint16_t GetUInt16() const
Returns 16-bit unsigned integer value of a datum.
Definition: datum.h:117
constexpr char GetChar() const
Returns character value of a datum.
Definition: datum.h:85
constexpr Oid GetOid() const
Returns object identifier value of a datum.
Definition: datum.h:141
#define LOG(level,...)
LOG(LogSeverity level, const char *fmt, ...)
Definition: logging.h:116
uintptr_t DatumRep
Definition: datum.h:36
Definition: datum.h:28
constexpr LogSeverity kFatal
Definition: logging.h:22
constexpr LogSeverity kError
Definition: logging.h:21
uint32_t Oid
Definition: tdb_base.h:210
DataArray is a plain byte array that can be stored as a Datum itself and stores the data of a few dat...
Definition: datum.h:903
static Datum From(const Datum *data, uint32_t n)
Makes a deep copy of the data and stores them in a data array.
Definition: datum.h:913
constexpr static uint32_t VARLEN_MASK
Definition: datum.h:904
static Datum GetDatum(SomeDatum &&d, size_t i)
Returns the ith Datum of the DataArray stored in d.
Definition: datum.h:962
static size_t GetArrayLength(SomeDatum &&d)
Returns the array length of the DataArray stored in d.
Definition: datum.h:951
#define MAXALIGN(LEN)
Definition: tdb_base.h:327
unique_malloced_ptr unique_aligned_alloc(size_t alignment, size_t size)
Wraps an aligned_alloced'd memory space in a std::unique_ptr.
Definition: tdb_base.h:101
#define ASSERT(...)
Definition: tdb_base.h:190
std::unique_ptr< void, AlignedAllocImpl::FreeMem > unique_malloced_ptr
Definition: tdb_base.h:94
Note from PostgreSQL: Float <-> Datum conversions.
Definition: datum.h:56
double double_v
Definition: datum.h:58
int64_t int64_v
Definition: datum.h:57
Note from PostgreSQL: Float <-> Datum conversions.
Definition: datum.h:45
int32_t int32_v
Definition: datum.h:46
float float_v
Definition: datum.h:47