Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
17
18#include <TError.h>
19
20#include <algorithm>
21#include <bitset>
22#include <cstdint>
23#include <memory>
24#include <utility>
25
26std::unique_ptr<ROOT::Experimental::Detail::RColumnElementBase>
28 switch (type) {
30 return std::make_unique<RColumnElement<float, EColumnType::kReal32>>(nullptr);
32 return std::make_unique<RColumnElement<double, EColumnType::kReal64>>(nullptr);
34 return std::make_unique<RColumnElement<std::uint8_t, EColumnType::kByte>>(nullptr);
36 return std::make_unique<RColumnElement<std::int32_t, EColumnType::kInt32>>(nullptr);
38 return std::make_unique<RColumnElement<std::int64_t, EColumnType::kInt64>>(nullptr);
40 return std::make_unique<RColumnElement<bool, EColumnType::kBit>>(nullptr);
42 return std::make_unique<RColumnElement<ClusterSize_t, EColumnType::kIndex>>(nullptr);
44 return std::make_unique<RColumnElement<RColumnSwitch, EColumnType::kSwitch>>(nullptr);
45 default:
46 R__ASSERT(false);
47 }
48 // never here
49 return nullptr;
50}
51
53 switch (type) {
55 return 32;
57 return 64;
59 return 8;
61 return 32;
63 return 64;
65 return 1;
67 return 32;
69 return 64;
70 default:
71 R__ASSERT(false);
72 }
73 // never here
74 return 0;
75}
76
78 void *dst, void *src, std::size_t count) const
79{
80 bool *boolArray = reinterpret_cast<bool *>(src);
81 char *charArray = reinterpret_cast<char *>(dst);
82 std::bitset<8> bitSet;
83 std::size_t i = 0;
84 for (; i < count; ++i) {
85 bitSet.set(i % 8, boolArray[i]);
86 if (i % 8 == 7) {
87 char packed = bitSet.to_ulong();
88 charArray[i / 8] = packed;
89 }
90 }
91 if (i % 8 != 0) {
92 char packed = bitSet.to_ulong();
93 charArray[i / 8] = packed;
94 }
95}
96
98 void *dst, void *src, std::size_t count) const
99{
100 bool *boolArray = reinterpret_cast<bool *>(dst);
101 char *charArray = reinterpret_cast<char *>(src);
102 std::bitset<8> bitSet;
103 for (std::size_t i = 0; i < count; i += 8) {
104 bitSet = charArray[i / 8];
105 for (std::size_t j = i; j < std::min(count, i + 8); ++j) {
106 boolArray[j] = bitSet[j % 8];
107 }
108 }
109}
#define R__ASSERT(e)
Definition TError.h:120
int type
Definition TGX11.cxx:121
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-...
static std::unique_ptr< RColumnElementBase > Generate(EColumnType type)
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-...