1#ifndef IMMUTABLE_STRING_H
2#define IMMUTABLE_STRING_H
51#include <google/protobuf/io/coded_stream.h>
54#include "template_utils.h"
68 inline std::string_view
Decode()
const;
76 size_t length,
char **dst);
81 static constexpr int kMaxVarintBytes = 10;
82 return kMaxVarintBytes +
length;
96 return (
static_cast<uint64_t
>(
n) << 1) ^
static_cast<uint64_t
>(
n >> 63);
102 return static_cast<int64_t
>((
n >> 1) ^ (~(
n & 1) + 1));
113 auto ptr = pointer_cast<const uint8_t *>(
p);
114 uint32_t res = ptr[0];
133 return {data,
static_cast<size_t>(
size)};
139 using google::protobuf::io::CodedOutputStream;
141 const char *base = *dst;
142 uint8_t *ptr = CodedOutputStream::WriteVarint64ToArray(
143 length, pointer_cast<uint8_t *>(*dst));
145 memcpy(ptr, data,
length);
147 *dst = pointer_cast<char *>(ptr +
length);
181 inline Decoded
Decode()
const;
198 static constexpr int kMaxVarintBytes = 10;
199 return kMaxVarintBytes +
length;
229 using google::protobuf::io::CodedOutputStream;
231 const char *base = *dst;
232 uint8_t *ptr = pointer_cast<uint8_t *>(*dst);
233 if (next.
m_ptr ==
nullptr) {
236 ptr = CodedOutputStream::WriteVarint64ToArray(
239 *dst = pointer_cast<char *>(ptr);
The variant with length (ImmutableStringWithLength) stores the length as a Varint128 (similar to prot...
Definition: immutable_string.h:63
ImmutableStringWithLength(const char *encoded)
Definition: immutable_string.h:66
const char * m_ptr
Definition: immutable_string.h:89
bool operator==(ImmutableStringWithLength other) const
Compares full contents (data/size).
Definition: immutable_string.h:152
static ImmutableStringWithLength Encode(const char *data, size_t length, char **dst)
Encode the given string as an ImmutableStringWithLength, and returns a new object pointing to it.
Definition: immutable_string.h:136
ImmutableStringWithLength()=default
std::string_view Decode() const
Definition: immutable_string.h:130
static size_t RequiredBytesForEncode(size_t length)
Calculates an upper bound on the space required for encoding a string of the given length.
Definition: immutable_string.h:80
LinkedImmutableString is designed for storing rows (values) in hash join.
Definition: immutable_string.h:173
Decoded Decode() const
Definition: immutable_string.h:214
bool operator!=(std::nullptr_t) const
Definition: immutable_string.h:203
bool operator==(std::nullptr_t) const
Definition: immutable_string.h:202
const char * m_ptr
Definition: immutable_string.h:206
static size_t RequiredBytesForEncode(size_t length)
Calculates an upper bound on the space required for encoding a string of the given length.
Definition: immutable_string.h:197
LinkedImmutableString(const char *encoded)
NOTE: nullptr is a legal value for encoded, and signals the same thing as nullptr would on a const ch...
Definition: immutable_string.h:179
static LinkedImmutableString EncodeHeader(LinkedImmutableString next, char **dst)
Encode the given string and “next” pointer as a header for LinkedImmutableString, and returns a new o...
Definition: immutable_string.h:227
const char * p
Definition: ctype-mb.cc:1225
const char * VarintParse64(const char *p, uint64_t *out)
Definition: immutable_string.h:112
int64_t ZigZagDecode64(uint64_t n)
Definition: immutable_string.h:100
std::pair< const char *, uint64_t > VarintParseSlow64(const char *p, uint32_t res32)
Definition: hash_join_buffer.cc:351
uint64_t ZigZagEncode64(int64_t n)
Definition: immutable_string.h:93
Header for compiler-dependent features.
#define MY_COMPILER_GCC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:250
#define MY_COMPILER_MSVC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:255
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:285
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:286
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
size_t size(const char *const c)
Definition: base64.h:46
MY_COMPILER_CLANG_DIAGNOSTIC_IGNORE("-Winconsistent-missing-destructor-override") static Scope_guard static_guard([]()
Definition: protobuf_plugin.cc:33
Definition: immutable_string.h:209
const char * data
Definition: immutable_string.h:210
LinkedImmutableString next
Definition: immutable_string.h:211
int n
Definition: xcom_base.cc:509