-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved SignExtend into src/include and added bitpacking chunk size con…
…stant
- Loading branch information
1 parent
2a04d85
commit 95da515
Showing
8 changed files
with
66 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
/* Adapted from | ||
https://github.com/duckdb/duckdb/blob/312b9954507386305544a42c4f43c2bd410a64cb/src/include/duckdb/common/bitpacking.hpp#L190-L199 | ||
* Copyright 2018-2023 Stichting DuckDB Foundation | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
associated documentation files (the "Software"), to deal in the Software without restriction, | ||
including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial | ||
portions of the Software. | ||
*/ | ||
|
||
#include <string.h> | ||
|
||
#include <cstdint> | ||
#include <limits> | ||
#include <type_traits> | ||
|
||
namespace kuzu { | ||
namespace storage { | ||
|
||
template<typename T> | ||
void Store(const T& val, uint8_t* ptr) { | ||
memcpy(ptr, (void*)&val, sizeof(val)); | ||
} | ||
|
||
template<typename T> | ||
const T Load(const uint8_t* ptr) { | ||
T ret; | ||
memcpy(&ret, ptr, sizeof(ret)); | ||
return ret; | ||
} | ||
|
||
// Sign bit extension | ||
template<class T, class T_U = typename std::make_unsigned<T>::type, uint64_t CHUNK_SIZE> | ||
static void SignExtend(uint8_t* dst, uint8_t width) { | ||
T const mask = T_U(1) << (width - 1); | ||
for (uint64_t i = 0; i < CHUNK_SIZE; ++i) { | ||
T value = Load<T>(dst + i * sizeof(T)); | ||
value = value & ((T_U(1) << width) - T_U(1)); | ||
T result = (value ^ mask) - mask; | ||
Store(result, dst + i * sizeof(T)); | ||
} | ||
} | ||
} // namespace storage | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.