Logo ROOT  
Reference Guide
RColumnElement.cxx
Go to the documentation of this file.
1 /// \file RColumnElement.cxx
2 /// \ingroup NTuple ROOT7
3 /// \author Jakob Blomer <jblomer@cern.ch>
4 /// \date 2019-08-11
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #include <ROOT/RColumnElement.hxx>
17 
18 #include <TError.h>
19 
20 #include <algorithm>
21 #include <bitset>
22 #include <cstdint>
23 
26  switch (type) {
31  case EColumnType::kByte:
37  case EColumnType::kBit:
43  default:
44  R__ASSERT(false);
45  }
46  // never here
47  return RColumnElementBase();
48 }
49 
51  void *dst, void *src, std::size_t count) const
52 {
53  bool *boolArray = reinterpret_cast<bool *>(src);
54  char *charArray = reinterpret_cast<char *>(dst);
55  std::bitset<8> bitSet;
56  std::size_t i = 0;
57  for (; i < count; ++i) {
58  bitSet.set(i % 8, boolArray[i]);
59  if (i % 8 == 7) {
60  char packed = bitSet.to_ulong();
61  charArray[i / 8] = packed;
62  }
63  }
64  if (i % 8 != 0) {
65  char packed = bitSet.to_ulong();
66  charArray[i / 8] = packed;
67  }
68 }
69 
71  void *dst, void *src, std::size_t count) const
72 {
73  bool *boolArray = reinterpret_cast<bool *>(dst);
74  char *charArray = reinterpret_cast<char *>(src);
75  std::bitset<8> bitSet;
76  for (std::size_t i = 0; i < count; i += 8) {
77  bitSet = charArray[i / 8];
78  for (std::size_t j = i; j < std::min(count, i + 8); ++j) {
79  boolArray[j] = bitSet[j % 8];
80  }
81  }
82 }
ROOT::Experimental::EColumnType::kReal64
@ kReal64
ROOT::Experimental::EColumnType::kIndex
@ kIndex
ROOT::Experimental::Detail::RColumnElementBase::RColumnElementBase
RColumnElementBase()
Definition: RColumnElement.hxx:55
ROOT::Experimental::EColumnType::kSwitch
@ kSwitch
ROOT::Experimental::Detail::RColumnElement< bool, EColumnType::kBit >
Definition: RColumnElement.hxx:229
ROOT::Experimental::Detail::RColumnElementBase::Pack
virtual void Pack(void *destination, void *source, std::size_t count) const
If the on-storage layout and the in-memory layout differ, packing creates an on-disk page from an in-...
Definition: RColumnElement.hxx:88
ROOT::Experimental::EColumnType::kInt64
@ kInt64
ROOT::Experimental::EColumnType::kInt32
@ kInt32
ROOT::Experimental::EColumnType::kBit
@ kBit
ROOT::Experimental::EColumnType::kReal32
@ kReal32
ROOT::Experimental::Detail::RColumnElement
Pairs of C++ type and column type, like float and EColumnType::kReal32.
Definition: RColumnElement.hxx:107
ROOT::Experimental::EColumnType
EColumnType
Definition: RColumnModel.hxx:35
ROOT::Experimental::EColumnType::kByte
@ kByte
RColumnElement.hxx
R__ASSERT
#define R__ASSERT(e)
Definition: TError.h:120
ROOT::Experimental::Detail::RColumnElementBase::Unpack
virtual void Unpack(void *destination, void *source, std::size_t count) const
If the on-storage layout and the in-memory layout differ, unpacking creates a memory page from an on-...
Definition: RColumnElement.hxx:94
ROOT::Experimental::Detail::RColumnElementBase::Generate
static RColumnElementBase Generate(EColumnType type)
Definition: RColumnElement.cxx:25
ROOT::Experimental::Detail::RColumnElement< double, EColumnType::kReal64 >
Definition: RColumnElement.hxx:130
ROOT::Experimental::Detail::RColumnElement< RColumnSwitch, EColumnType::kSwitch >
Definition: RColumnElement.hxx:207
type
int type
Definition: TGX11.cxx:121
ROOT::Experimental::Detail::RColumnElementBase
Definition: RColumnElement.hxx:47
ROOT::Experimental::Detail::RColumnElement< float, EColumnType::kReal32 >
Definition: RColumnElement.hxx:119
ROOT::Experimental::Detail::RColumnElement< ClusterSize_t, EColumnType::kIndex >
Definition: RColumnElement.hxx:196
TError.h