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  if (m_isowned) {
285  free(GetPointer());
286  }
287  memcpy(this, &d, sizeof(Datum));
288 
289  // same as above in Datum(Datum&&)
290 #if __GNUC__ >= 8
291 #pragma GCC diagnostic push
292 #pragma GCC diagnostic ignored "-Wclass-memaccess"
293 #endif
294  memset(&d, 0, sizeof(Datum));
295 #if __GNUC__ >= 8
296 #pragma GCC diagnostic pop
297 #endif
298  d.m_isnull = true;
299  return *this;
300  }
301 
302  bool
303  isnull() const {
304  return m_isnull;
305  }
306 
310  char*
311  GetVarlenBytes() const {
312  return (char *) m_val;
313  }
314 
318  uint32_t
319  GetVarlenSize() const {
320  return m_size;
321  }
322 
323  /*
324  * Returns the variable-length value of a datum as an absl::string_view.
325  *
326  * This is equivalent to absl::string_view(GetVarlenBytes(),
327  * GetVarlenSize()).
328  */
329  absl::string_view
331  return absl::string_view((const char *) m_val, m_size);
332  }
333 
337  const Datum&
338  GetThis() const {
339  return *this;
340  }
341 
342  /*
343  * Returns datum representation of a null value.
344  */
345  static Datum
347  return Datum();
348  }
349 
353  static Datum
354  From(bool X) {
355  return Datum((datum_impl::DatumRep) ((X) ? 1 : 0));
356  }
357 
361  static Datum
362  From(char X) {
363  return Datum((datum_impl::DatumRep) (X));
364  }
365 
369  static Datum
370  From(int8_t X) {
371  return Datum((datum_impl::DatumRep) (X));
372  }
373 
377  static Datum
378  From(uint8_t X) {
379  return Datum((datum_impl::DatumRep) (X));
380  }
381 
385  static Datum
386  From(int16_t X) {
387  return Datum((datum_impl::DatumRep) (X));
388  }
389 
393  static Datum
394  From(uint16_t X) {
395  return Datum((datum_impl::DatumRep) (X));
396  }
397 
401  static Datum
402  From(int32_t X) {
403  return Datum((datum_impl::DatumRep) (X));
404  }
405 
412  static Datum
413  From(uint32_t X) {
414  return Datum((datum_impl::DatumRep) (X));
415  }
416 
420  static Datum
421  From(void *X) {
422  return Datum((datum_impl::DatumRep) (X));
423  }
424 
429  static Datum
430  From(int64_t X) {
431  return Datum((datum_impl::DatumRep) X);
432  }
433 
438  static Datum
439  From(uint64_t X) {
440  return Datum((datum_impl::DatumRep) X);
441  }
442 
443 
448  static Datum
449  From(float X) {
450  return datum_impl::DatumFloatConversion{.float_v=X}.int32_v;
451  }
452 
457  static Datum
458  From(double X) {
459  return datum_impl::DatumDoubleConversion{.double_v=X}.int64_v;
460  }
461 
469  static Datum
470  FromCString(const char *str) {
471  size_t len = std::strlen(str);
472  if (len > std::numeric_limits<uint32_t>::max()) {
473  LOG(kFatal, "cstring is too long: %lu", len);
474  }
475  return FromVarlenBytes(str, len);
476  }
477 
478  /*
479  * Returns datum representation of a null-terminated string that is not
480  * owned by this datum if isnull is false, or otherwise, returns a datum of
481  * a null value. A null-terminated string is always treated as
482  * a variable-length datum so you have to call GetVarlenAsStringView() to
483  * convert it back to a string (though there is no guarantee that the
484  * returned string_view has a pointer to a null-terminated string).
485  */
486  static Datum
487  FromCString(const char *str, bool isnull) {
488  return isnull ? Datum() : FromCString(str);
489  }
490 
504  static Datum
505  FromCString(std::unique_ptr<char[]> str, bool isnull = false) {
506  if (isnull || !str.get())
507  return Datum();
508  size_t len = std::strlen(str.get());
509  if (len > std::numeric_limits<uint32_t>::max()) {
510  LOG(kFatal, "cstring is too long: %lu", len);
511  }
512  return Datum((datum_impl::DatumRep) str.release(), true, len);
513  }
514 
519  static Datum
520  FromVarlenBytes(const char *bytes, uint32_t size) {
521  return Datum((datum_impl::DatumRep) bytes, false, size);
522  }
523 
529  static Datum
530  FromVarlenBytes(const char *bytes, uint32_t size, bool isnull) {
531  return isnull ? Datum() : FromVarlenBytes(bytes, size);
532  }
533 
552  static Datum
553  FromVarlenBytes(unique_malloced_ptr bytes, uint32_t size,
554  bool isnull = false) {
555  if (!bytes.get() || isnull) {
556  return Datum();
557  }
558  return Datum((datum_impl::DatumRep) bytes.release(), true, size);
559  }
560 
565  static Datum
566  FromVarlenAsStringView(absl::string_view bytes) {
567  if (!bytes.data())
568  return Datum();
569  return FromVarlenBytes(bytes.data(), bytes.size());
570  }
571 
578  template<class T>
579  static Datum
580  From(T&& X, bool isnull) {
581  return isnull ? Datum() : From(std::forward<T>(X));
582  }
583 
588  static Datum
589  FromFixedlenBytes(const char *bytes, uint32_t size) {
590  //ASSERT(TYPEALIGN(size, (uintptr_t) bytes) == (uintptr_t) bytes);
591 
592  switch (size) {
593  case 1:
594  return Datum((datum_impl::DatumRep)*(uint8_t*)bytes);
595  case 2:
596  return Datum((datum_impl::DatumRep)*(uint16_t*)bytes);
597  case 4:
598  return Datum((datum_impl::DatumRep)*(uint32_t*)bytes);
599  case 8:
600  return Datum((datum_impl::DatumRep)*(uint64_t*)bytes);
601  }
602 
603  LOG(kError, "unexpected pass-by-value data length %u", size);
604  return Datum();
605  }
606 
614  bool
615  HasExternalRef() const {
616  return m_isvarlen && !m_isowned;
617  }
618 
623  Datum
624  DeepCopy() const {
625  if (m_isvarlen) {
626  const char *bytes = GetVarlenBytes();
627  size_t size = GetVarlenSize();
628  // We don't know what exactly the alignment requirement is, so
629  // make it the maximum a type might need.
630  unique_malloced_ptr bytes_copy = unique_aligned_alloc(8, size);
631  memcpy(bytes_copy.get(), bytes, size);
632  return Datum::FromVarlenBytes(std::move(bytes_copy), size);
633  }
634  return Copy();
635  }
636 
642  Datum
643  Copy() const {
644  if (m_isvarlen && m_isowned) {
645  // make sure it is not owned in the shallow copy.
647  }
648  return Datum(*this);
649  }
650 
651 private:
655  Datum():
656  m_isowned(false),
657  m_isnull(true),
658  m_isvarlen(false),
659  m_size(0),
660  m_val(0) {}
661 
663  m_isowned(false),
664  m_isnull(false),
665  m_isvarlen(false),
666  m_size(0),
667  m_val(value) {}
668 
673  /*Datum(datum_impl::DatumRep value, bool isowned):
674  m_isowned(isowned),
675  m_isnull(false),
676  m_isvarlen(false),
677  m_size(0),
678  m_val(value) {} */
679 
681  bool isowned,
682  uint32_t size):
683  m_isowned(isowned),
684  m_isnull(false),
685  m_isvarlen(true),
686  m_size(size),
687  m_val(value) {}
688 
689  // The default constructor and copy assignment should not be used outside
690  // the Datum class.
691  Datum(const Datum&) = default;
692  Datum &operator=(const Datum&) = default;
693 
699  bool m_isowned : 1;
700 
704  bool m_isnull : 1;
705 
710  bool m_isvarlen : 1;
711 
716  uint32_t m_size;
717 
722 
723  template<class DatumImpl>
725  template<class DatumImpl>
727  friend class DatumRef;
728  friend class NullableDatumRef;
729  friend struct DataArray;
730 };
731 
732 namespace datum_impl {
733 
734 template<class DatumImpl>
735 class DatumRefVarlenGetters: public NonVarlenGetters<DatumImpl> {
736 public:
737 
741  constexpr char*
742  GetVarlenBytes() const {
743  return NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>()
744  ->GetVarlenBytes();
745  }
746 
750  constexpr uint32_t
751  GetVarlenSize() const {
752  return NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>()
753  ->GetVarlenSize();
754  }
755 
756  /*
757  * Returns the variable-length value of a datum as an absl::string_view.
758  *
759  * This is equivalent to
760  * absl::string_view(GetVarlenBytes(), GetVarlenSize()).
761  *
762  * This is also used for returning a string value but the string is not
763  * guaranteed to be null-terminated -- see FromCString() for additional
764  * notes.
765  */
766  constexpr absl::string_view
768  return NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>()
769  ->GetVarlenAsStringView();
770  }
771 
779  constexpr Datum&
780  GetDatum() const {
781  return *NonVarlenGetters<DatumImpl>::template GetPointerAs<Datum>();
782  }
783 
797  Datum
798  DeepCopy(bool isbyref) const {
799  if (((DatumImpl&)(*this)).isnull()) {
800  return Datum();
801  }
802  if (isbyref) {
803  return GetDatum().DeepCopy();
804  } else {
806  }
807  }
808 };
809 
810 } // namespace datum_impl
811 
827 public:
828  DatumRef(const Datum &d):
829  m_val(d.m_isvarlen? ((datum_impl::DatumRep) &d) : d.m_val) {}
830  // DatumRef must not have a non-trivial destructor.
831 
832  DatumRef(const DatumRef &) = default;
833  DatumRef &operator=(const DatumRef&) = default;
834 
835  constexpr bool
836  isnull() const {
837  return false;
838  }
839 
840 protected:
842  m_val(val) {}
843 
845 
847  friend class NullableDatumRef;
848 };
849 
850 /* Make sure that DatumRef may be passed in a register whenever possible. */
851 static_assert(sizeof(DatumRef) == sizeof(datum_impl::DatumRep));
852 
853 /*
854  * NullableDatumRef additionally stores whether an object is null or not.
855  * In some cases, we want to pass the nullness of an object as well, e.g., as
856  * arguments to a fmgr-managed function. NullableDatumRef allows for that.
857  *
858  * Different from DatumRef, the only reason that NullableDatumRef does not just
859  * wrap a pointer to a Datum is that we want to have implicit conversion from a
860  * DatamRef to a NullableDatumRef, and DatumRef may not be a pointer to a
861  * Datum in all cases.
862  */
864  public datum_impl::DatumRefVarlenGetters<NullableDatumRef> {
865 public:
867  m_isnull(d.m_isnull),
868  m_val(d.m_isvarlen? ((datum_impl::DatumRep) &d) : d.m_val) {}
869 
871  m_isnull(false),
872  m_val(d.m_val) {}
873 
876 
877  operator DatumRef() const {
878  if (m_isnull)
879  LOG(kFatal, "casting NULL datum to a DatumRef");
880  return DatumRef(m_val);
881  }
882 
883  constexpr bool
884  isnull() const {
885  return m_isnull;
886  }
887 
888 private:
889  bool m_isnull;
891 
893 };
894 
906 struct DataArray {
907  constexpr static uint32_t VARLEN_MASK = 1u << 31;
908 
915  static Datum
916  From(const Datum *data, uint32_t n) {
917  uint32_t total_sz = MAXALIGN(n * sizeof(uint32_t));
918  for (size_t i = 0; i < n; ++i) {
919  total_sz += data[i].m_isvarlen ? MAXALIGN(data[i].m_size) :
920  (data[i].m_isnull ? 0 :
921  (uint32_t) sizeof(datum_impl::DatumRep));
922  }
923  unique_malloced_ptr bytes = unique_aligned_alloc(8, total_sz);
924  auto off = reinterpret_cast<uint32_t*>(bytes.get());
925  off[0] = n;
926  uint32_t cur_off = MAXALIGN(n * sizeof(uint32_t));
927  auto payload = reinterpret_cast<char*>(bytes.get());
928  for (size_t i = 0; i < n; ++i) {
929  if (data[i].m_isvarlen) {
930  memcpy(payload + cur_off, (const char*) data[i].m_val,
931  data[i].m_size);
932  cur_off += MAXALIGN(data[i].m_size);
933  } else if (!data[i].m_isnull) {
934  *reinterpret_cast<datum_impl::DatumRep*>(payload + cur_off)
935  = data[i].m_val;
936  cur_off += sizeof(datum_impl::DatumRep);
937  }
938  if (i + 1 != n) {
939  off[i + 1] = cur_off;
940  }
941  if (data[i].m_isvarlen) {
942  off[i] |= VARLEN_MASK;
943  }
944  }
945  ASSERT(cur_off == total_sz);
946  return Datum::FromVarlenBytes(std::move(bytes), total_sz);
947  }
948 
952  template<class SomeDatum>
953  static size_t
954  GetArrayLength(SomeDatum &&d) {
955  return *reinterpret_cast<const uint32_t*>(d.GetVarlenBytes())
956  & ~VARLEN_MASK;
957  }
958 
963  template<class SomeDatum>
964  static Datum
965  GetDatum(SomeDatum &&d, size_t i) {
966  uint32_t n = GetArrayLength(d);
967  uint32_t off;
968  uint32_t end_off;
969  if (i == 0) {
970  off = MAXALIGN(n * sizeof(uint32_t));
971  } else {
972  off = reinterpret_cast<const uint32_t*>(d.GetVarlenBytes())[i]
973  & ~VARLEN_MASK;
974  }
975 
976  if (i + 1 == n) {
977  end_off = d.GetVarlenSize();
978  } else {
979  end_off = reinterpret_cast<const uint32_t*>(
980  d.GetVarlenBytes())[i + 1] & ~VARLEN_MASK;
981  }
982  if (end_off == off) {
983  return Datum::FromNull();
984  }
985 
986  if (VARLEN_MASK &
987  reinterpret_cast<const uint32_t*>(d.GetVarlenBytes())[i]) {
988  // varlen-value
989  return Datum::FromVarlenBytes(d.GetVarlenBytes() + off,
990  end_off - off);
991  } else {
992  // fixed-len value
993  return Datum::FromFixedlenBytes(d.GetVarlenBytes() + off,
994  sizeof(datum_impl::DatumRep));
995  }
996  }
997 };
998 
999 } // namespace taco
A DatumRef object is a read-only reference to an C++ object of a supported runtime type.
Definition: datum.h:826
DatumRef(datum_impl::DatumRep val)
Definition: datum.h:841
DatumRef(const Datum &d)
Definition: datum.h:828
datum_impl::DatumRep m_val
Definition: datum.h:844
constexpr bool isnull() const
Definition: datum.h:836
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:402
uint32_t m_size
The length of the variable-length value of the datum.
Definition: datum.h:716
const Datum & GetThis() const
Returns a constant reference to ‘*this’.
Definition: datum.h:338
Datum(datum_impl::DatumRep value)
Definition: datum.h:662
static Datum FromCString(const char *str, bool isnull)
Definition: datum.h:487
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:566
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:520
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:505
static Datum From(int16_t X)
Returns datum representation for a 16-bit integer.
Definition: datum.h:386
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:421
uint32_t GetVarlenSize() const
Returns the size of the variable-length value of a datum.
Definition: datum.h:319
static Datum From(double X)
Returns datum representation for a double-precision floating point number.
Definition: datum.h:458
static Datum From(char X)
Returns datum representation for a character.
Definition: datum.h:362
bool m_isvarlen
Whether the managed object is a variable-length object that is not a null-terminated string.
Definition: datum.h:710
static Datum From(int8_t X)
Returns datum representation for an 8-bit integer.
Definition: datum.h:370
static Datum From(bool X)
Returns datum representation for a boolean.
Definition: datum.h:354
static Datum From(uint64_t X)
Returns datum representation for an unsigned 64-bit integer.
Definition: datum.h:439
bool m_isowned
Whether the managed object is owned by this Datum.
Definition: datum.h:699
static Datum From(uint8_t X)
Returns datum representation for an 8-bit unsigned integer.
Definition: datum.h:378
datum_impl::DatumRep m_val
The actual value storage.
Definition: datum.h:721
bool HasExternalRef() const
Whether this datum is variable-length but does not own its byte array.
Definition: datum.h:615
absl::string_view GetVarlenAsStringView() const
Definition: datum.h:330
bool isnull() const
Definition: datum.h:303
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:680
static Datum FromNull()
Definition: datum.h:346
Datum Copy() const
Makes a shallow copy of this datum.
Definition: datum.h:643
Datum & operator=(const Datum &)=default
char * GetVarlenBytes() const
Returns the variable-length value of a datum as an array of bytes.
Definition: datum.h:311
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:624
static Datum From(uint16_t X)
Returns datum representation for a 16-bit unsigned integer.
Definition: datum.h:394
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:530
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:580
Datum()
Constructs a Datum with a null value.
Definition: datum.h:655
static Datum From(float X)
Returns datum representation for a single-precision floating point number.
Definition: datum.h:449
bool m_isnull
Whether the value is null.
Definition: datum.h:704
static Datum From(uint32_t X)
Returns datum representation for a 32-bit unsigned integer.
Definition: datum.h:413
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:553
static Datum FromCString(const char *str)
Returns datum representation of a null-terminated string that is not owned by this datum.
Definition: datum.h:470
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:589
static Datum From(int64_t X)
Returns datum representation for a signed 64-bit integer.
Definition: datum.h:430
Definition: datum.h:864
NullableDatumRef(const NullableDatumRef &)=default
NullableDatumRef(const DatumRef &d)
Definition: datum.h:870
NullableDatumRef & operator=(const NullableDatumRef &)=default
datum_impl::DatumRep m_val
Definition: datum.h:890
NullableDatumRef(const Datum &d)
Definition: datum.h:866
bool m_isnull
Definition: datum.h:889
constexpr bool isnull() const
Definition: datum.h:884
Datum DeepCopy(bool isbyref) const
Returns a new Datum that is a deep copy of the underlying datum.
Definition: datum.h:798
constexpr absl::string_view GetVarlenAsStringView() const
Definition: datum.h:767
constexpr char * GetVarlenBytes() const
Returns the variable-length value of a datum as an array of bytes.
Definition: datum.h:742
constexpr uint32_t GetVarlenSize() const
Returns the length of the variable-length value of a datum.
Definition: datum.h:751
constexpr Datum & GetDatum() const
Returns a reference to the underlying datum if this references one with a variable-length value.
Definition: datum.h:780
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:217
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:906
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:916
constexpr static uint32_t VARLEN_MASK
Definition: datum.h:907
static Datum GetDatum(SomeDatum &&d, size_t i)
Returns the ith Datum of the DataArray stored in d.
Definition: datum.h:965
static size_t GetArrayLength(SomeDatum &&d)
Returns the array length of the DataArray stored in d.
Definition: datum.h:954
#define MAXALIGN(LEN)
Definition: tdb_base.h:334
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:107
#define ASSERT(...)
Definition: tdb_base.h:197
std::unique_ptr< void, AlignedAllocImpl::FreeMem > unique_malloced_ptr
Definition: tdb_base.h:100
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