1#ifndef IMMUTABLE_STRING_H
2#define IMMUTABLE_STRING_H
50#include <google/protobuf/io/coded_stream.h>
53#include "template_utils.h"
67 inline std::string_view
Decode()
const;
75 size_t length,
char **dst);
80 static constexpr int kMaxVarintBytes = 10;
81 return kMaxVarintBytes +
length;
95 return (
static_cast<uint64_t
>(
n) << 1) ^
static_cast<uint64_t
>(
n >> 63);
101 return static_cast<int64_t
>((
n >> 1) ^ (~(
n & 1) + 1));
112 auto ptr = pointer_cast<const uint8_t *>(
p);
113 uint32_t res = ptr[0];
132 return {data,
static_cast<size_t>(size)};
138 using google::protobuf::io::CodedOutputStream;
140 const char *base = *dst;
141 uint8_t *ptr = CodedOutputStream::WriteVarint64ToArray(
142 length, pointer_cast<uint8_t *>(*dst));
144 memcpy(ptr, data,
length);
146 *dst = pointer_cast<char *>(ptr +
length);
180 inline Decoded
Decode()
const;
197 static constexpr int kMaxVarintBytes = 10;
198 return kMaxVarintBytes +
length;
228 using google::protobuf::io::CodedOutputStream;
230 const char *base = *dst;
231 uint8_t *ptr = pointer_cast<uint8_t *>(*dst);
232 if (next.
m_ptr ==
nullptr) {
235 ptr = CodedOutputStream::WriteVarint64ToArray(
238 *dst = pointer_cast<char *>(ptr);
The variant with length (ImmutableStringWithLength) stores the length as a Varint128 (similar to prot...
Definition: immutable_string.h:62
ImmutableStringWithLength(const char *encoded)
Definition: immutable_string.h:65
const char * m_ptr
Definition: immutable_string.h:88
bool operator==(ImmutableStringWithLength other) const
Compares full contents (data/size).
Definition: immutable_string.h:151
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:135
ImmutableStringWithLength()=default
std::string_view Decode() const
Definition: immutable_string.h:129
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:79
LinkedImmutableString is designed for storing rows (values) in hash join.
Definition: immutable_string.h:172
Decoded Decode() const
Definition: immutable_string.h:213
bool operator!=(std::nullptr_t) const
Definition: immutable_string.h:202
bool operator==(std::nullptr_t) const
Definition: immutable_string.h:201
const char * m_ptr
Definition: immutable_string.h:205
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:196
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:178
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:226
const char * p
Definition: ctype-mb.cc:1234
const char * VarintParse64(const char *p, uint64_t *out)
Definition: immutable_string.h:111
int64_t ZigZagDecode64(uint64_t n)
Definition: immutable_string.h:99
std::pair< const char *, uint64_t > VarintParseSlow64(const char *p, uint32_t res32)
Definition: hash_join_buffer.cc:279
uint64_t ZigZagEncode64(int64_t n)
Definition: immutable_string.h:92
Header for compiler-dependent features.
#define MY_COMPILER_GCC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:249
#define MY_COMPILER_MSVC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:254
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:284
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:285
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:75
MY_COMPILER_CLANG_DIAGNOSTIC_IGNORE("-Winconsistent-missing-destructor-override") extern "C"
Definition: protobuf_plugin.cc:31
Definition: immutable_string.h:208
const char * data
Definition: immutable_string.h:209
LinkedImmutableString next
Definition: immutable_string.h:210
int n
Definition: xcom_base.cc:508