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<char, EColumnType::kChar>>(nullptr);
36 return std::make_unique<RColumnElement<std::uint8_t, EColumnType::kByte>>(nullptr);
38 return std::make_unique<RColumnElement<std::int8_t, EColumnType::kInt8>>(nullptr);
40 return std::make_unique<RColumnElement<std::int16_t, EColumnType::kInt16>>(nullptr);
42 return std::make_unique<RColumnElement<std::int32_t, EColumnType::kInt32>>(nullptr);
44 return std::make_unique<RColumnElement<std::int64_t, EColumnType::kInt64>>(nullptr);
46 return std::make_unique<RColumnElement<bool, EColumnType::kBit>>(nullptr);
48 return std::make_unique<RColumnElement<ClusterSize_t, EColumnType::kIndex>>(nullptr);
50 return std::make_unique<RColumnElement<RColumnSwitch, EColumnType::kSwitch>>(nullptr);
51 default:
52 R__ASSERT(false);
53 }
54 // never here
55 return nullptr;
56}
57
59 switch (type) {
61 return 32;
63 return 64;
65 return 8;
67 return 8;
69 return 8;
71 return 16;
73 return 32;
75 return 64;
77 return 1;
79 return 32;
81 return 64;
82 default:
83 R__ASSERT(false);
84 }
85 // never here
86 return 0;
87}
88
90 switch (type) {
92 return "Real32";
94 return "Real64";
96 return "Char";
98 return "Byte";
100 return "Int8";
102 return "Int16";
104 return "Int32";
106 return "Int64";
108 return "Bit";
110 return "Index";
112 return "Switch";
113 default:
114 return "UNKNOWN";
115 }
116}
117
119 void *dst, void *src, std::size_t count) const
120{
121 bool *boolArray = reinterpret_cast<bool *>(src);
122 char *charArray = reinterpret_cast<char *>(dst);
123 std::bitset<8> bitSet;
124 std::size_t i = 0;
125 for (; i < count; ++i) {
126 bitSet.set(i % 8, boolArray[i]);
127 if (i % 8 == 7) {
128 char packed = bitSet.to_ulong();
129 charArray[i / 8] = packed;
130 }
131 }
132 if (i % 8 != 0) {
133 char packed = bitSet.to_ulong();
134 charArray[i / 8] = packed;
135 }
136}
137
139 void *dst, void *src, std::size_t count) const
140{
141 bool *boolArray = reinterpret_cast<bool *>(dst);
142 char *charArray = reinterpret_cast<char *>(src);
143 std::bitset<8> bitSet;
144 for (std::size_t i = 0; i < count; i += 8) {
145 bitSet = charArray[i / 8];
146 for (std::size_t j = i; j < std::min(count, i + 8); ++j) {
147 boolArray[j] = bitSet[j % 8];
148 }
149 }
150}
151
152
154 void *dst, void *src, std::size_t count) const
155{
156 std::int64_t *int64Array = reinterpret_cast<std::int64_t *>(src);
157 std::int32_t *int32Array = reinterpret_cast<std::int32_t *>(dst);
158 for (std::size_t i = 0; i < count; ++i) {
159 int32Array[i] = int64Array[i];
160 }
161}
162
164 void *dst, void *src, std::size_t count) const
165{
166 std::int32_t *int32Array = reinterpret_cast<std::int32_t *>(src);
167 std::int64_t *int64Array = reinterpret_cast<std::int64_t *>(dst);
168 for (std::size_t i = 0; i < count; ++i) {
169 int64Array[i] = int32Array[i];
170 }
171}
#define R__ASSERT(e)
Definition TError.h:118
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)
static std::string GetTypeName(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-...