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
26template <>
27std::unique_ptr<ROOT::Experimental::Detail::RColumnElementBase>
28ROOT::Experimental::Detail::RColumnElementBase::Generate<void>(EColumnType type)
29{
30 switch (type) {
31 case EColumnType::kIndex64: return std::make_unique<RColumnElement<ClusterSize_t, EColumnType::kIndex64>>();
32 case EColumnType::kIndex32: return std::make_unique<RColumnElement<ClusterSize_t, EColumnType::kIndex32>>();
33 case EColumnType::kSwitch: return std::make_unique<RColumnElement<RColumnSwitch, EColumnType::kSwitch>>();
34 case EColumnType::kByte: return std::make_unique<RColumnElement<std::uint8_t, EColumnType::kByte>>();
35 case EColumnType::kChar: return std::make_unique<RColumnElement<char, EColumnType::kChar>>();
36 case EColumnType::kBit: return std::make_unique<RColumnElement<bool, EColumnType::kBit>>();
37 case EColumnType::kReal64: return std::make_unique<RColumnElement<double, EColumnType::kReal64>>();
38 case EColumnType::kReal32: return std::make_unique<RColumnElement<float, EColumnType::kReal32>>();
39 case EColumnType::kInt64: return std::make_unique<RColumnElement<std::int64_t, EColumnType::kInt64>>();
40 case EColumnType::kUInt64: return std::make_unique<RColumnElement<std::uint64_t, EColumnType::kUInt64>>();
41 case EColumnType::kInt32: return std::make_unique<RColumnElement<std::int32_t, EColumnType::kInt32>>();
42 case EColumnType::kUInt32: return std::make_unique<RColumnElement<std::uint32_t, EColumnType::kUInt32>>();
43 case EColumnType::kInt16: return std::make_unique<RColumnElement<std::int16_t, EColumnType::kInt16>>();
44 case EColumnType::kUInt16: return std::make_unique<RColumnElement<std::uint16_t, EColumnType::kUInt16>>();
45 case EColumnType::kInt8: return std::make_unique<RColumnElement<std::int8_t, EColumnType::kInt8>>();
46 case EColumnType::kUInt8: return std::make_unique<RColumnElement<std::uint8_t, EColumnType::kUInt8>>();
48 return std::make_unique<RColumnElement<ClusterSize_t, EColumnType::kSplitIndex64>>();
50 return std::make_unique<RColumnElement<ClusterSize_t, EColumnType::kSplitIndex32>>();
51 case EColumnType::kSplitReal64: return std::make_unique<RColumnElement<double, EColumnType::kSplitReal64>>();
52 case EColumnType::kSplitReal32: return std::make_unique<RColumnElement<float, EColumnType::kSplitReal32>>();
53 case EColumnType::kSplitInt64: return std::make_unique<RColumnElement<std::int64_t, EColumnType::kSplitInt64>>();
54 case EColumnType::kSplitUInt64: return std::make_unique<RColumnElement<std::uint64_t, EColumnType::kSplitUInt64>>();
55 case EColumnType::kSplitInt32: return std::make_unique<RColumnElement<std::int32_t, EColumnType::kSplitInt32>>();
56 case EColumnType::kSplitUInt32: return std::make_unique<RColumnElement<std::uint32_t, EColumnType::kSplitUInt32>>();
57 case EColumnType::kSplitInt16: return std::make_unique<RColumnElement<std::int16_t, EColumnType::kSplitInt16>>();
58 case EColumnType::kSplitUInt16: return std::make_unique<RColumnElement<std::uint16_t, EColumnType::kSplitUInt16>>();
59 default: R__ASSERT(false);
60 }
61 // never here
62 return nullptr;
63}
64
66 switch (type) {
67 case EColumnType::kIndex64: return 64;
68 case EColumnType::kIndex32: return 32;
69 case EColumnType::kSwitch: return 64;
70 case EColumnType::kByte: return 8;
71 case EColumnType::kChar: return 8;
72 case EColumnType::kBit: return 1;
73 case EColumnType::kReal64: return 64;
74 case EColumnType::kReal32: return 32;
75 case EColumnType::kInt64: return 64;
76 case EColumnType::kUInt64: return 64;
77 case EColumnType::kInt32: return 32;
78 case EColumnType::kUInt32: return 32;
79 case EColumnType::kInt16: return 16;
80 case EColumnType::kUInt16: return 16;
81 case EColumnType::kInt8: return 8;
82 case EColumnType::kUInt8: return 8;
83 case EColumnType::kSplitIndex64: return 64;
84 case EColumnType::kSplitIndex32: return 32;
85 case EColumnType::kSplitReal64: return 64;
86 case EColumnType::kSplitReal32: return 32;
87 case EColumnType::kSplitInt64: return 64;
88 case EColumnType::kSplitUInt64: return 64;
89 case EColumnType::kSplitInt32: return 32;
90 case EColumnType::kSplitUInt32: return 32;
91 case EColumnType::kSplitInt16: return 16;
92 case EColumnType::kSplitUInt16: return 16;
93 default: R__ASSERT(false);
94 }
95 // never here
96 return 0;
97}
98
100 switch (type) {
101 case EColumnType::kIndex64: return "Index64";
102 case EColumnType::kIndex32: return "Index32";
103 case EColumnType::kSwitch: return "Switch";
104 case EColumnType::kByte: return "Byte";
105 case EColumnType::kChar: return "Char";
106 case EColumnType::kBit: return "Bit";
107 case EColumnType::kReal64: return "Real64";
108 case EColumnType::kReal32: return "Real32";
109 case EColumnType::kInt64: return "Int64";
110 case EColumnType::kUInt64: return "UInt64";
111 case EColumnType::kInt32: return "Int32";
112 case EColumnType::kUInt32: return "UInt32";
113 case EColumnType::kInt16: return "Int16";
114 case EColumnType::kUInt16: return "UInt16";
115 case EColumnType::kInt8: return "Int8";
116 case EColumnType::kUInt8: return "UInt8";
117 case EColumnType::kSplitIndex64: return "SplitIndex64";
118 case EColumnType::kSplitIndex32: return "SplitIndex32";
119 case EColumnType::kSplitReal64: return "SplitReal64";
120 case EColumnType::kSplitReal32: return "SplitReal32";
121 case EColumnType::kSplitInt64: return "SplitInt64";
122 case EColumnType::kSplitUInt64: return "SplitUInt64";
123 case EColumnType::kSplitInt32: return "SplitInt32";
124 case EColumnType::kSplitUInt32: return "SplitUInt32";
125 case EColumnType::kSplitInt16: return "SplitInt16";
126 case EColumnType::kSplitUInt16: return "SplitUInt16";
127 default: return "UNKNOWN";
128 }
129}
130
132 void *dst, void *src, std::size_t count) const
133{
134 bool *boolArray = reinterpret_cast<bool *>(src);
135 char *charArray = reinterpret_cast<char *>(dst);
136 std::bitset<8> bitSet;
137 std::size_t i = 0;
138 for (; i < count; ++i) {
139 bitSet.set(i % 8, boolArray[i]);
140 if (i % 8 == 7) {
141 char packed = bitSet.to_ulong();
142 charArray[i / 8] = packed;
143 }
144 }
145 if (i % 8 != 0) {
146 char packed = bitSet.to_ulong();
147 charArray[i / 8] = packed;
148 }
149}
150
152 void *dst, void *src, std::size_t count) const
153{
154 bool *boolArray = reinterpret_cast<bool *>(dst);
155 char *charArray = reinterpret_cast<char *>(src);
156 std::bitset<8> bitSet;
157 for (std::size_t i = 0; i < count; i += 8) {
158 bitSet = charArray[i / 8];
159 for (std::size_t j = i; j < std::min(count, i + 8); ++j) {
160 boolArray[j] = bitSet[j % 8];
161 }
162 }
163}
#define R__ASSERT(e)
Definition TError.h:118
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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::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-...