62 return std::make_pair(32, 32);
66 return std::make_pair(0, 0);
103 return "TestFutureType";
109std::unique_ptr<ROOT::Internal::RColumnElementBase>
113 switch (onDiskType) {
146 return std::make_unique<RColumnElement<Internal::RTestFutureColumn, kTestFutureColumnType>>();
154std::unique_ptr<ROOT::Internal::RColumnElementBase>
157 if (inMemoryType == std::type_index(
typeid(
char))) {
158 return GenerateColumnElementInternal<char>(onDiskType);
159 }
else if (inMemoryType == std::type_index(
typeid(
bool))) {
160 return GenerateColumnElementInternal<bool>(onDiskType);
161 }
else if (inMemoryType == std::type_index(
typeid(std::byte))) {
162 return GenerateColumnElementInternal<std::byte>(onDiskType);
163 }
else if (inMemoryType == std::type_index(
typeid(std::uint8_t))) {
164 return GenerateColumnElementInternal<std::uint8_t>(onDiskType);
165 }
else if (inMemoryType == std::type_index(
typeid(std::uint16_t))) {
166 return GenerateColumnElementInternal<std::uint16_t>(onDiskType);
167 }
else if (inMemoryType == std::type_index(
typeid(std::uint32_t))) {
168 return GenerateColumnElementInternal<std::uint32_t>(onDiskType);
169 }
else if (inMemoryType == std::type_index(
typeid(std::uint64_t))) {
170 return GenerateColumnElementInternal<std::uint64_t>(onDiskType);
171 }
else if (inMemoryType == std::type_index(
typeid(std::int8_t))) {
172 return GenerateColumnElementInternal<std::int8_t>(onDiskType);
173 }
else if (inMemoryType == std::type_index(
typeid(std::int16_t))) {
174 return GenerateColumnElementInternal<std::int16_t>(onDiskType);
175 }
else if (inMemoryType == std::type_index(
typeid(std::int32_t))) {
176 return GenerateColumnElementInternal<std::int32_t>(onDiskType);
177 }
else if (inMemoryType == std::type_index(
typeid(std::int64_t))) {
178 return GenerateColumnElementInternal<std::int64_t>(onDiskType);
179 }
else if (inMemoryType == std::type_index(
typeid(
float))) {
180 return GenerateColumnElementInternal<float>(onDiskType);
181 }
else if (inMemoryType == std::type_index(
typeid(
double))) {
182 return GenerateColumnElementInternal<double>(onDiskType);
183 }
else if (inMemoryType == std::type_index(
typeid(
RColumnIndex))) {
184 return GenerateColumnElementInternal<RColumnIndex>(onDiskType);
185 }
else if (inMemoryType == std::type_index(
typeid(
RColumnSwitch))) {
186 return GenerateColumnElementInternal<RColumnSwitch>(onDiskType);
188 return GenerateColumnElementInternal<RTestFutureColumn>(onDiskType);
190 R__ASSERT(!
"Invalid memory type in GenerateColumnElement");
196std::unique_ptr<ROOT::Internal::RColumnElementBase>
203 std::size_t nDstBits)
205 assert(sizeofSrc <=
sizeof(
Word_t));
206 assert(0 < nDstBits && nDstBits <= sizeofSrc * 8);
208 const unsigned char *srcArray =
reinterpret_cast<const unsigned char *
>(src);
211 std::size_t bitsUsed = 0;
212 std::size_t dstIdx = 0;
213 for (std::size_t i = 0; i < count; ++i) {
215 memcpy(&packedWord, srcArray + i * sizeofSrc, sizeofSrc);
217 packedWord >>= sizeofSrc * 8 - nDstBits;
220 if (bitsRem >= nDstBits) {
222 accum |= (packedWord << bitsUsed);
223 bitsUsed += nDstBits;
228 Word_t packedWordLsb = packedWord;
231 accum |= (packedWordLsb << bitsUsed);
234 memcpy(&dstArray[dstIdx++], &accum,
sizeof(accum));
239 Word_t packedWordMsb = packedWord;
240 packedWordMsb >>= bitsRem;
241 accum |= packedWordMsb;
242 bitsUsed += nDstBits - bitsRem;
246 bitsUsed += nDstBits;
252 memcpy(&dstArray[dstIdx++], &accum, (bitsUsed + 7) / 8);
255 assert(dstIdx == expDstCount);
259 std::size_t nSrcBits)
261 assert(sizeofDst <=
sizeof(
Word_t));
262 assert(0 < nSrcBits && nSrcBits <= sizeofDst * 8);
264 unsigned char *dstArray =
reinterpret_cast<unsigned char *
>(dst);
265 const Word_t *srcArray =
reinterpret_cast<const Word_t *
>(src);
270 std::size_t dstIdx = 0;
272 std::size_t remBytesToLoad = (count * nSrcBits + 7) / 8;
273 for (std::size_t i = 0; i < nWordsToLoad; ++i) {
274 assert(dstIdx < count);
278 std::size_t bytesLoaded = std::min(remBytesToLoad,
sizeof(
Word_t));
279 memcpy(&packedBytes, &srcArray[i], bytesLoaded);
281 assert(remBytesToLoad >= bytesLoaded);
282 remBytesToLoad -= bytesLoaded;
287 std::size_t nMsb = nSrcBits + offInWord;
288 std::uint32_t msb = packedBytes << (8 * sizeofDst - nMsb);
289 Word_t packedWord = msb | prevWordLsb;
291 memcpy(dstArray + dstIdx * sizeofDst, &packedWord, sizeofDst);
297 while (dstIdx < count) {
299 if (offInWord >
static_cast<int>(
kBitsPerWord - nSrcBits)) {
304 prevWordLsb = (packedBytes >> offInWord) << (8 * sizeofDst - nSrcBits);
309 Word_t packedWord = packedBytes;
311 packedWord >>= offInWord;
312 packedWord <<= 8 * sizeofDst - nSrcBits;
313 memcpy(dstArray + dstIdx * sizeofDst, &packedWord, sizeofDst);
315 offInWord += nSrcBits;
319 assert(prevWordLsb == 0);
320 assert(dstIdx == count);
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
The available trivial, native content types of a column.
static const char * GetColumnTypeName(ROOT::ENTupleColumnType type)
static std::unique_ptr< RColumnElementBase > Generate(ROOT::ENTupleColumnType type)
If CppT == void, use the default C++ type for the given column type.
static std::pair< std::uint16_t, std::uint16_t > GetValidBitRange(ROOT::ENTupleColumnType type)
Most types have a fixed on-disk bit width.
The in-memory representation of a 32bit or 64bit on-disk index column.
Holds the index and the tag of a kSwitch column.
void PackBits(void *dst, const void *src, std::size_t count, std::size_t sizeofSrc, std::size_t nDstBits)
Tightly packs count items of size sizeofSrc contained in src into dst using nDstBits per item.
void UnpackBits(void *dst, const void *src, std::size_t count, std::size_t sizeofDst, std::size_t nSrcBits)
Undoes the effect of PackBits.
constexpr std::size_t kBitsPerWord
constexpr ENTupleColumnType kTestFutureColumnType
std::unique_ptr< RColumnElementBase > GenerateColumnElement(std::type_index inMemoryType, ROOT::ENTupleColumnType onDiskType)
Every concrete RColumnElement type is identified by its on-disk type (column type) and the in-memory ...
std::type_index fInMemoryType
ROOT::ENTupleColumnType fOnDiskType