[Refactor] remove some unused code (#16512)

This commit is contained in:
trueeyu 2023-01-11 19:50:44 +08:00 committed by GitHub
parent b7dc6713a0
commit 9a1d6fa169
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 345 additions and 872 deletions

View File

@ -29,7 +29,6 @@ class ObjectPool;
class Expr;
class ExprContext;
namespace in_const_pred_detail {
template <LogicalType Type, typename Enable = void>
struct PHashSet {

View File

@ -19,9 +19,11 @@
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <vector>
#include "common/logging.h"
namespace starrocks {
@ -41,14 +43,10 @@ public:
// Returns the minimum allocation size that is compatible with
// the free list. The free list uses the allocations to maintain
// its own internal linked list structure.
static int min_size() {
return sizeof(FreeListNode);
}
static int min_size() { return sizeof(FreeListNode); }
// C'tor, initializes the free list to be empty
FreeList() {
reset();
}
FreeList() { reset(); }
// Attempts to allocate a block that is at least the input size
// from the free list.
@ -89,9 +87,7 @@ public:
}
// Empties the free list
void reset() {
bzero(&_head, sizeof(FreeListNode));
}
void reset() { bzero(&_head, sizeof(FreeListNode)); }
private:
struct FreeListNode {
@ -102,4 +98,4 @@ private:
FreeListNode _head;
};
}
} // namespace starrocks

View File

@ -53,9 +53,9 @@
#pragma once
#include <vector>
#include <cstring>
#include <boost/cstdint.hpp>
#include <cstring>
#include <vector>
#include "common/logging.h"
#include "runtime/string_value.h"
@ -65,10 +65,9 @@ namespace starrocks {
// TODO: This can be sped up with SIDD_CMP_EQUAL_ORDERED or at the very least rewritten
// from published algorithms.
class StringSearch {
public:
virtual ~StringSearch() = default;
StringSearch() {}
StringSearch() {}
// Initialize/Precompute a StringSearch object from the pattern
StringSearch(const StringValue* pattern) : _pattern(pattern), _mask(0) {
@ -157,17 +156,13 @@ public:
private:
static const int BLOOM_WIDTH = 64;
void bloom_add(char c) {
_mask |= (1UL << (c & (BLOOM_WIDTH - 1)));
}
void bloom_add(char c) { _mask |= (1UL << (c & (BLOOM_WIDTH - 1))); }
bool bloom_query(char c) const {
return _mask & (1UL << (c & (BLOOM_WIDTH - 1)));
}
bool bloom_query(char c) const { return _mask & (1UL << (c & (BLOOM_WIDTH - 1))); }
const StringValue* _pattern{nullptr};
int64_t _mask{0};
int64_t _skip = 0;
};
}
} // namespace starrocks

View File

@ -1,164 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#pragma once
#include <memory>
#include "util/bitmap.h"
namespace starrocks {
// Bit-vector representing the selection status of each row in a row block.
//
// It is used to scan data with column predicate.
// the bit in the selection vector is used to indicate whether the given row is live.
class SelectionVector {
public:
// Construct a new vector. The bits are initially in an indeterminate state.
// Call set_all_true() if you require all rows to be initially selected.
explicit SelectionVector(size_t row_capacity)
: _n_rows(row_capacity), _n_bytes(BitmapSize(row_capacity)), _bitmap(new uint8_t[_n_bytes]) {
CHECK_GT(_n_bytes, 0);
set_all_false();
}
// returen the number of selected rows.
size_t count_selected() const { return Bits::Count(_bitmap.get(), _n_bytes); }
// Return true if any rows are selected, or false
// This is equivalent to (count_selected() > 0), but faster.
inline bool any_selected() const;
bool is_row_selected(size_t row) const {
DCHECK_LT(row, _n_rows);
return BitmapTest(_bitmap.get(), row);
}
void set_row_selected(size_t row) {
DCHECK_LT(row, _n_rows);
BitmapSet(_bitmap.get(), row);
}
void set_all_true() {
memset(_bitmap.get(), 0xff, _n_bytes);
pad_extra_bits_wit_zeroes();
}
void set_all_false() { memset(_bitmap.get(), 0, _n_bytes); }
void clear_bit(size_t row) {
DCHECK_LT(row, _n_rows);
return BitmapClear(_bitmap.get(), row);
}
uint8_t* mutable_bitmap() { return _bitmap.get(); }
const uint8_t* bitmap() const { return _bitmap.get(); }
size_t nrows() const { return _n_rows; }
std::string to_string() const { return BitmapToString(_bitmap.get(), _n_rows); }
private:
// Pads any non-byte-aligned bits at the end of the SelectionVector with
// zeroes.
//
// To improve performance, CountSelected() and AnySelected() evaluate the
// SelectionVector's bitmap in terms of bytes. As such, they consider all of
// the trailing bits, even if the bitmap's bit length is not byte-aligned and
// some trailing bits aren't part of the bitmap.
//
// To address this without sacrificing performance, we need to zero out all
// trailing bits at construction time, or after any operation that sets all
// bytes in bulk.
void pad_extra_bits_wit_zeroes() {
size_t bits_in_last_byte = _n_rows & 7;
if (bits_in_last_byte > 0) {
BitmapChangeBits(_bitmap.get(), _n_rows, 8 - bits_in_last_byte, false);
}
}
private:
// row capacity
size_t _n_rows;
size_t _n_bytes;
std::unique_ptr<uint8_t[]> _bitmap;
SelectionVector(const SelectionVector&) = delete;
const SelectionVector& operator=(const SelectionVector&) = delete;
};
inline bool SelectionVector::any_selected() const {
size_t rem = _n_bytes;
const auto* p32 = reinterpret_cast<const uint32_t*>(_bitmap.get());
while (rem >= 4) {
if (*p32 != 0) {
return true;
}
++p32;
rem -= 4;
}
const auto* p8 = reinterpret_cast<const uint8_t*>(p32);
while (rem > 0) {
if (*p8 != 0) {
return true;
}
++p8;
--rem;
}
return false;
}
// A SelectionVectorView keeps track of where in the selection vector a given
// batch will start from. After processing a batch, Advance() should be called
// and the view will move forward by the appropriate amount. In this way, the
// underlying selection vector can easily be updated batch-by-batch.
class SelectionVectorView {
public:
// Constructs a new SelectionVectorView.
//
// The 'sel_vec' object must outlive this SelectionVectorView.
explicit SelectionVectorView(SelectionVector* sel_vec) : _sel_vec(sel_vec) {}
void advance(size_t skip) {
DCHECK_LE(skip, _sel_vec->nrows() - _row_offset);
_row_offset += skip;
}
void set_bit(size_t row_idx) {
DCHECK_LE(row_idx, _sel_vec->nrows() - _row_offset);
BitmapSet(_sel_vec->mutable_bitmap(), _row_offset + row_idx);
}
void clear_bit(size_t row_idx) {
DCHECK_LE(row_idx, _sel_vec->nrows() - _row_offset);
BitmapClear(_sel_vec->mutable_bitmap(), _row_offset + row_idx);
}
bool test_bit(size_t row_idx) {
DCHECK_LE(row_idx, _sel_vec->nrows() - _row_offset);
return BitmapTest(_sel_vec->bitmap(), _row_offset + row_idx);
}
void clear_bits(size_t nrows) {
DCHECK_LE(nrows, _sel_vec->nrows() - _row_offset);
BitmapChangeBits(_sel_vec->mutable_bitmap(), _row_offset, nrows, false);
}
private:
SelectionVector* _sel_vec;
size_t _row_offset{0};
};
} // namespace starrocks

View File

@ -186,54 +186,9 @@ public:
return h1;
}
static const int MURMUR_R = 47;
// Murmur2 hash implementation returning 64-bit hashes.
static uint64_t murmur_hash2_64(const void* input, int len, uint64_t seed) {
uint64_t h = seed ^ (len * MURMUR_PRIME);
const uint64_t* data = reinterpret_cast<const uint64_t*>(input);
const uint64_t* end = data + (len / sizeof(uint64_t));
while (data != end) {
uint64_t k = *data++;
k *= MURMUR_PRIME;
k ^= k >> MURMUR_R;
k *= MURMUR_PRIME;
h ^= k;
h *= MURMUR_PRIME;
}
const uint8_t* data2 = reinterpret_cast<const uint8_t*>(data);
switch (len & 7) {
case 7:
h ^= uint64_t(data2[6]) << 48;
case 6:
h ^= uint64_t(data2[5]) << 40;
case 5:
h ^= uint64_t(data2[4]) << 32;
case 4:
h ^= uint64_t(data2[3]) << 24;
case 3:
h ^= uint64_t(data2[2]) << 16;
case 2:
h ^= uint64_t(data2[1]) << 8;
case 1:
h ^= uint64_t(data2[0]);
h *= MURMUR_PRIME;
}
h ^= h >> MURMUR_R;
h *= MURMUR_PRIME;
h ^= h >> MURMUR_R;
return h;
}
// default values recommended by http://isthe.com/chongo/tech/comp/fnv/
static const uint32_t FNV_PRIME = 0x01000193; // 16777619
static constexpr uint32_t FNV_SEED = 0x811C9DC5; // 2166136261
static const uint64_t FNV64_PRIME = 1099511628211UL;
static const uint64_t FNV64_SEED = 14695981039346656037UL;
static const uint64_t MURMUR_PRIME = 0xc6a4a7935bd1e995ULL;
static const uint32_t MURMUR_SEED = 0xadc83b19ULL;
// Implementation of the Fowler-Noll-Vo hash function. This is not as performant
@ -253,17 +208,6 @@ public:
return hash;
}
static uint64_t fnv_hash64(const void* data, int32_t bytes, uint64_t hash) {
const uint8_t* ptr = reinterpret_cast<const uint8_t*>(data);
while (bytes--) {
hash = (*ptr ^ hash) * FNV64_PRIME;
++ptr;
}
return hash;
}
// Our hash function is MurmurHash2, 64 bit version.
// It was modified in order to provide the same result in
// big and little endian archs (endian neutral).
@ -370,63 +314,6 @@ public:
return t;
}
// Modify from https://github.com/martinus/robin-hood-hashing/blob/master/src/include/robin_hood.h
// Hash an arbitrary amount of bytes. This is basically Murmur2 hash without caring about big
// endianness. TODO(martinus) add a fallback for very large strings?
static size_t hash_bytes(void const* ptr, size_t const len) noexcept {
static constexpr uint64_t m = UINT64_C(0xc6a4a7935bd1e995);
static constexpr uint64_t seed = UINT64_C(0xe17a1465);
static constexpr unsigned int r = 47;
auto const data64 = static_cast<uint64_t const*>(ptr);
uint64_t h = seed ^ (len * m);
size_t const n_blocks = len / 8;
for (size_t i = 0; i < n_blocks; ++i) {
auto k = unaligned_load<uint64_t>(data64 + i);
k *= m;
k ^= k >> r;
k *= m;
h ^= k;
h *= m;
}
auto const data8 = reinterpret_cast<uint8_t const*>(data64 + n_blocks);
switch (len & 7U) {
case 7:
h ^= static_cast<uint64_t>(data8[6]) << 48U;
break;
case 6:
h ^= static_cast<uint64_t>(data8[5]) << 40U;
break;
case 5:
h ^= static_cast<uint64_t>(data8[4]) << 32U;
break;
case 4:
h ^= static_cast<uint64_t>(data8[3]) << 24U;
break;
case 3:
h ^= static_cast<uint64_t>(data8[2]) << 16U;
break;
case 2:
h ^= static_cast<uint64_t>(data8[1]) << 8U;
break;
case 1:
h ^= static_cast<uint64_t>(data8[0]);
h *= m;
break;
default:
break;
}
h ^= h >> r;
h *= m;
h ^= h >> r;
return static_cast<size_t>(h);
}
// Xorshift is a pseudorandom number generator, which is an implementation of
// linear-feedback shift registers (LFSRs). It generates next pseudorandom state from
// the current state, which can be easily repurposed as hash functions.

View File

@ -21,7 +21,7 @@
namespace starrocks {
template<const size_t N>
template <const size_t N>
inline void fixed_size_memory_copy(void* dst, const void* src) {
struct X {
uint8_t byte[N];
@ -30,590 +30,569 @@ inline void fixed_size_memory_copy(void* dst, const void* src) {
*(reinterpret_cast<X*>(dst)) = *(reinterpret_cast<const X*>(src));
}
template<> inline void fixed_size_memory_copy<0>(void*, const void*) {}
template <>
inline void fixed_size_memory_copy<0>(void*, const void*) {}
template<> inline void fixed_size_memory_copy<1>(void* dst, const void* src) {
*(reinterpret_cast<uint8_t*>(dst)) = * (reinterpret_cast<const uint8_t*>(src));
template <>
inline void fixed_size_memory_copy<1>(void* dst, const void* src) {
*(reinterpret_cast<uint8_t*>(dst)) = *(reinterpret_cast<const uint8_t*>(src));
}
template<> inline void fixed_size_memory_copy<2>(void* dst, const void* src) {
*(reinterpret_cast<uint16_t*>(dst)) = * (reinterpret_cast<const uint16_t*>(src));
template <>
inline void fixed_size_memory_copy<2>(void* dst, const void* src) {
*(reinterpret_cast<uint16_t*>(dst)) = *(reinterpret_cast<const uint16_t*>(src));
}
template<> inline void fixed_size_memory_copy<4>(void* dst, const void* src) {
*(reinterpret_cast<uint32_t*>(dst)) = * (reinterpret_cast<const uint32_t*>(src));
template <>
inline void fixed_size_memory_copy<4>(void* dst, const void* src) {
*(reinterpret_cast<uint32_t*>(dst)) = *(reinterpret_cast<const uint32_t*>(src));
}
template<> inline void fixed_size_memory_copy<8>(void* dst, const void* src) {
*(reinterpret_cast<uint64_t*>(dst)) = * (reinterpret_cast<const uint64_t*>(src));
template <>
inline void fixed_size_memory_copy<8>(void* dst, const void* src) {
*(reinterpret_cast<uint64_t*>(dst)) = *(reinterpret_cast<const uint64_t*>(src));
}
inline void memory_copy(void* dst, const void* src, size_t size) {
// Function fixed_size_memory_copy will report a stack-use-after-scope error in ASAN mode.
#if !defined(ADDRESS_SANITIZER)
static const void* addrs[] = {
&&B0, &&B1, &&B2, &&B3, &&B4, &&B5, &&B6,
&&B7, &&B8, &&B9, &&B10, &&B11, &&B12, &&B13,
&&B14, &&B15, &&B16, &&B17, &&B18, &&B19,
&&B20, &&B21, &&B22, &&B23, &&B24, &&B25,
&&B26, &&B27, &&B28, &&B29, &&B30, &&B31,
&&B32, &&B33, &&B34, &&B35, &&B36, &&B37,
&&B38, &&B39, &&B40, &&B41, &&B42, &&B43,
&&B44, &&B45, &&B46, &&B47, &&B48, &&B49,
&&B50, &&B51, &&B52, &&B53, &&B54, &&B55,
&&B56, &&B57, &&B58, &&B59, &&B60, &&B61,
&&B62, &&B63, &&B64, &&B65, &&B66, &&B67,
&&B68, &&B69, &&B70, &&B71, &&B72, &&B73,
&&B74, &&B75, &&B76, &&B77, &&B78, &&B79,
&&B80, &&B81, &&B82, &&B83, &&B84, &&B85,
&&B86, &&B87, &&B88, &&B89, &&B90, &&B91,
&&B92, &&B93, &&B94, &&B95, &&B96, &&B97,
&&B98, &&B99, &&B100, &&B101, &&B102, &&B103,
&&B104, &&B105, &&B106, &&B107, &&B108,
&&B109, &&B110, &&B111, &&B112, &&B113,
&&B114, &&B115, &&B116, &&B117, &&B118,
&&B119, &&B120, &&B121, &&B122, &&B123,
&&B124, &&B125, &&B126, &&B127, &&B128,
&&B129, &&B130, &&B131, &&B132, &&B133,
&&B134, &&B135, &&B136, &&B137, &&B138,
&&B139, &&B140, &&B141, &&B142, &&B143,
&&B144, &&B145, &&B146, &&B147, &&B148,
&&B149, &&B150, &&B151, &&B152, &&B153,
&&B154, &&B155, &&B156, &&B157, &&B158,
&&B159, &&B160, &&B161, &&B162, &&B163,
&&B164, &&B165, &&B166, &&B167, &&B168,
&&B169, &&B170, &&B171, &&B172, &&B173, &&B174,
&&B175, &&B176, &&B177, &&B178, &&B179, &&B180,
&&B181, &&B182, &&B183, &&B184, &&B185,
&&B186, &&B187, &&B188, &&B189, &&B190, &&B191,
&&B192, &&B193, &&B194, &&B195, &&B196,
&&B197, &&B198, &&B199, &&B200, &&B201, &&B202,
&&B203, &&B204, &&B205, &&B206, &&B207,
&&B208, &&B209, &&B210, &&B211, &&B212, &&B213,
&&B214, &&B215, &&B216, &&B217, &&B218,
&&B219, &&B220, &&B221, &&B222, &&B223, &&B224,
&&B225, &&B226, &&B227, &&B228, &&B229,
&&B230, &&B231, &&B232, &&B233, &&B234, &&B235,
&&B236, &&B237, &&B238, &&B239, &&B240,
&&B241, &&B242, &&B243, &&B244, &&B245, &&B246,
&&B247, &&B248, &&B249, &&B250, &&B251,
&&B252, &&B253, &&B254, &&B255,
&&B0, &&B1, &&B2, &&B3, &&B4, &&B5, &&B6, &&B7, &&B8, &&B9, &&B10, &&B11, &&B12,
&&B13, &&B14, &&B15, &&B16, &&B17, &&B18, &&B19, &&B20, &&B21, &&B22, &&B23, &&B24, &&B25,
&&B26, &&B27, &&B28, &&B29, &&B30, &&B31, &&B32, &&B33, &&B34, &&B35, &&B36, &&B37, &&B38,
&&B39, &&B40, &&B41, &&B42, &&B43, &&B44, &&B45, &&B46, &&B47, &&B48, &&B49, &&B50, &&B51,
&&B52, &&B53, &&B54, &&B55, &&B56, &&B57, &&B58, &&B59, &&B60, &&B61, &&B62, &&B63, &&B64,
&&B65, &&B66, &&B67, &&B68, &&B69, &&B70, &&B71, &&B72, &&B73, &&B74, &&B75, &&B76, &&B77,
&&B78, &&B79, &&B80, &&B81, &&B82, &&B83, &&B84, &&B85, &&B86, &&B87, &&B88, &&B89, &&B90,
&&B91, &&B92, &&B93, &&B94, &&B95, &&B96, &&B97, &&B98, &&B99, &&B100, &&B101, &&B102, &&B103,
&&B104, &&B105, &&B106, &&B107, &&B108, &&B109, &&B110, &&B111, &&B112, &&B113, &&B114, &&B115, &&B116,
&&B117, &&B118, &&B119, &&B120, &&B121, &&B122, &&B123, &&B124, &&B125, &&B126, &&B127, &&B128, &&B129,
&&B130, &&B131, &&B132, &&B133, &&B134, &&B135, &&B136, &&B137, &&B138, &&B139, &&B140, &&B141, &&B142,
&&B143, &&B144, &&B145, &&B146, &&B147, &&B148, &&B149, &&B150, &&B151, &&B152, &&B153, &&B154, &&B155,
&&B156, &&B157, &&B158, &&B159, &&B160, &&B161, &&B162, &&B163, &&B164, &&B165, &&B166, &&B167, &&B168,
&&B169, &&B170, &&B171, &&B172, &&B173, &&B174, &&B175, &&B176, &&B177, &&B178, &&B179, &&B180, &&B181,
&&B182, &&B183, &&B184, &&B185, &&B186, &&B187, &&B188, &&B189, &&B190, &&B191, &&B192, &&B193, &&B194,
&&B195, &&B196, &&B197, &&B198, &&B199, &&B200, &&B201, &&B202, &&B203, &&B204, &&B205, &&B206, &&B207,
&&B208, &&B209, &&B210, &&B211, &&B212, &&B213, &&B214, &&B215, &&B216, &&B217, &&B218, &&B219, &&B220,
&&B221, &&B222, &&B223, &&B224, &&B225, &&B226, &&B227, &&B228, &&B229, &&B230, &&B231, &&B232, &&B233,
&&B234, &&B235, &&B236, &&B237, &&B238, &&B239, &&B240, &&B241, &&B242, &&B243, &&B244, &&B245, &&B246,
&&B247, &&B248, &&B249, &&B250, &&B251, &&B252, &&B253, &&B254, &&B255,
};
if (size <= 255) {
// Using 'goto' to get high performance
goto* addrs[size];
B0:
B0:
return fixed_size_memory_copy<0>(dst, src);
B1:
B1:
return fixed_size_memory_copy<1>(dst, src);
B2:
B2:
return fixed_size_memory_copy<2>(dst, src);
B3:
B3:
return fixed_size_memory_copy<3>(dst, src);
B4:
B4:
return fixed_size_memory_copy<4>(dst, src);
B5:
B5:
return fixed_size_memory_copy<5>(dst, src);
B6:
B6:
return fixed_size_memory_copy<6>(dst, src);
B7:
B7:
return fixed_size_memory_copy<7>(dst, src);
B8:
B8:
return fixed_size_memory_copy<8>(dst, src);
B9:
B9:
return fixed_size_memory_copy<9>(dst, src);
B10:
B10:
return fixed_size_memory_copy<10>(dst, src);
B11:
B11:
return fixed_size_memory_copy<11>(dst, src);
B12:
B12:
return fixed_size_memory_copy<12>(dst, src);
B13:
B13:
return fixed_size_memory_copy<13>(dst, src);
B14:
B14:
return fixed_size_memory_copy<14>(dst, src);
B15:
B15:
return fixed_size_memory_copy<15>(dst, src);
B16:
B16:
return fixed_size_memory_copy<16>(dst, src);
B17:
B17:
return fixed_size_memory_copy<17>(dst, src);
B18:
B18:
return fixed_size_memory_copy<18>(dst, src);
B19:
B19:
return fixed_size_memory_copy<19>(dst, src);
B20:
B20:
return fixed_size_memory_copy<20>(dst, src);
B21:
B21:
return fixed_size_memory_copy<21>(dst, src);
B22:
B22:
return fixed_size_memory_copy<22>(dst, src);
B23:
B23:
return fixed_size_memory_copy<23>(dst, src);
B24:
B24:
return fixed_size_memory_copy<24>(dst, src);
B25:
B25:
return fixed_size_memory_copy<25>(dst, src);
B26:
B26:
return fixed_size_memory_copy<26>(dst, src);
B27:
B27:
return fixed_size_memory_copy<27>(dst, src);
B28:
B28:
return fixed_size_memory_copy<28>(dst, src);
B29:
B29:
return fixed_size_memory_copy<29>(dst, src);
B30:
B30:
return fixed_size_memory_copy<30>(dst, src);
B31:
B31:
return fixed_size_memory_copy<31>(dst, src);
B32:
B32:
return fixed_size_memory_copy<32>(dst, src);
B33:
B33:
return fixed_size_memory_copy<33>(dst, src);
B34:
B34:
return fixed_size_memory_copy<34>(dst, src);
B35:
B35:
return fixed_size_memory_copy<35>(dst, src);
B36:
B36:
return fixed_size_memory_copy<36>(dst, src);
B37:
B37:
return fixed_size_memory_copy<37>(dst, src);
B38:
B38:
return fixed_size_memory_copy<38>(dst, src);
B39:
B39:
return fixed_size_memory_copy<39>(dst, src);
B40:
B40:
return fixed_size_memory_copy<40>(dst, src);
B41:
B41:
return fixed_size_memory_copy<41>(dst, src);
B42:
B42:
return fixed_size_memory_copy<42>(dst, src);
B43:
B43:
return fixed_size_memory_copy<43>(dst, src);
B44:
B44:
return fixed_size_memory_copy<44>(dst, src);
B45:
B45:
return fixed_size_memory_copy<45>(dst, src);
B46:
B46:
return fixed_size_memory_copy<46>(dst, src);
B47:
B47:
return fixed_size_memory_copy<47>(dst, src);
B48:
B48:
return fixed_size_memory_copy<48>(dst, src);
B49:
B49:
return fixed_size_memory_copy<49>(dst, src);
B50:
B50:
return fixed_size_memory_copy<50>(dst, src);
B51:
B51:
return fixed_size_memory_copy<51>(dst, src);
B52:
B52:
return fixed_size_memory_copy<52>(dst, src);
B53:
B53:
return fixed_size_memory_copy<53>(dst, src);
B54:
B54:
return fixed_size_memory_copy<54>(dst, src);
B55:
B55:
return fixed_size_memory_copy<55>(dst, src);
B56:
B56:
return fixed_size_memory_copy<56>(dst, src);
B57:
B57:
return fixed_size_memory_copy<57>(dst, src);
B58:
B58:
return fixed_size_memory_copy<58>(dst, src);
B59:
B59:
return fixed_size_memory_copy<59>(dst, src);
B60:
B60:
return fixed_size_memory_copy<60>(dst, src);
B61:
B61:
return fixed_size_memory_copy<61>(dst, src);
B62:
B62:
return fixed_size_memory_copy<62>(dst, src);
B63:
B63:
return fixed_size_memory_copy<63>(dst, src);
B64:
B64:
return fixed_size_memory_copy<64>(dst, src);
B65:
B65:
return fixed_size_memory_copy<65>(dst, src);
B66:
B66:
return fixed_size_memory_copy<66>(dst, src);
B67:
B67:
return fixed_size_memory_copy<67>(dst, src);
B68:
B68:
return fixed_size_memory_copy<68>(dst, src);
B69:
B69:
return fixed_size_memory_copy<69>(dst, src);
B70:
B70:
return fixed_size_memory_copy<70>(dst, src);
B71:
B71:
return fixed_size_memory_copy<71>(dst, src);
B72:
B72:
return fixed_size_memory_copy<72>(dst, src);
B73:
B73:
return fixed_size_memory_copy<73>(dst, src);
B74:
B74:
return fixed_size_memory_copy<74>(dst, src);
B75:
B75:
return fixed_size_memory_copy<75>(dst, src);
B76:
B76:
return fixed_size_memory_copy<76>(dst, src);
B77:
B77:
return fixed_size_memory_copy<77>(dst, src);
B78:
B78:
return fixed_size_memory_copy<78>(dst, src);
B79:
B79:
return fixed_size_memory_copy<79>(dst, src);
B80:
B80:
return fixed_size_memory_copy<80>(dst, src);
B81:
B81:
return fixed_size_memory_copy<81>(dst, src);
B82:
B82:
return fixed_size_memory_copy<82>(dst, src);
B83:
B83:
return fixed_size_memory_copy<83>(dst, src);
B84:
B84:
return fixed_size_memory_copy<84>(dst, src);
B85:
B85:
return fixed_size_memory_copy<85>(dst, src);
B86:
B86:
return fixed_size_memory_copy<86>(dst, src);
B87:
B87:
return fixed_size_memory_copy<87>(dst, src);
B88:
B88:
return fixed_size_memory_copy<88>(dst, src);
B89:
B89:
return fixed_size_memory_copy<89>(dst, src);
B90:
B90:
return fixed_size_memory_copy<90>(dst, src);
B91:
B91:
return fixed_size_memory_copy<91>(dst, src);
B92:
B92:
return fixed_size_memory_copy<92>(dst, src);
B93:
B93:
return fixed_size_memory_copy<93>(dst, src);
B94:
B94:
return fixed_size_memory_copy<94>(dst, src);
B95:
B95:
return fixed_size_memory_copy<95>(dst, src);
B96:
B96:
return fixed_size_memory_copy<96>(dst, src);
B97:
B97:
return fixed_size_memory_copy<97>(dst, src);
B98:
B98:
return fixed_size_memory_copy<98>(dst, src);
B99:
B99:
return fixed_size_memory_copy<99>(dst, src);
B100:
B100:
return fixed_size_memory_copy<100>(dst, src);
B101:
B101:
return fixed_size_memory_copy<101>(dst, src);
B102:
B102:
return fixed_size_memory_copy<102>(dst, src);
B103:
B103:
return fixed_size_memory_copy<103>(dst, src);
B104:
B104:
return fixed_size_memory_copy<104>(dst, src);
B105:
B105:
return fixed_size_memory_copy<105>(dst, src);
B106:
B106:
return fixed_size_memory_copy<106>(dst, src);
B107:
B107:
return fixed_size_memory_copy<107>(dst, src);
B108:
B108:
return fixed_size_memory_copy<108>(dst, src);
B109:
B109:
return fixed_size_memory_copy<109>(dst, src);
B110:
B110:
return fixed_size_memory_copy<110>(dst, src);
B111:
B111:
return fixed_size_memory_copy<111>(dst, src);
B112:
B112:
return fixed_size_memory_copy<112>(dst, src);
B113:
B113:
return fixed_size_memory_copy<113>(dst, src);
B114:
B114:
return fixed_size_memory_copy<114>(dst, src);
B115:
B115:
return fixed_size_memory_copy<115>(dst, src);
B116:
B116:
return fixed_size_memory_copy<116>(dst, src);
B117:
B117:
return fixed_size_memory_copy<117>(dst, src);
B118:
B118:
return fixed_size_memory_copy<118>(dst, src);
B119:
B119:
return fixed_size_memory_copy<119>(dst, src);
B120:
B120:
return fixed_size_memory_copy<120>(dst, src);
B121:
B121:
return fixed_size_memory_copy<121>(dst, src);
B122:
B122:
return fixed_size_memory_copy<122>(dst, src);
B123:
B123:
return fixed_size_memory_copy<123>(dst, src);
B124:
B124:
return fixed_size_memory_copy<124>(dst, src);
B125:
B125:
return fixed_size_memory_copy<125>(dst, src);
B126:
B126:
return fixed_size_memory_copy<126>(dst, src);
B127:
B127:
return fixed_size_memory_copy<127>(dst, src);
B128:
B128:
return fixed_size_memory_copy<128>(dst, src);
B129:
B129:
return fixed_size_memory_copy<129>(dst, src);
B130:
B130:
return fixed_size_memory_copy<130>(dst, src);
B131:
B131:
return fixed_size_memory_copy<131>(dst, src);
B132:
B132:
return fixed_size_memory_copy<132>(dst, src);
B133:
B133:
return fixed_size_memory_copy<133>(dst, src);
B134:
B134:
return fixed_size_memory_copy<134>(dst, src);
B135:
B135:
return fixed_size_memory_copy<135>(dst, src);
B136:
B136:
return fixed_size_memory_copy<136>(dst, src);
B137:
B137:
return fixed_size_memory_copy<137>(dst, src);
B138:
B138:
return fixed_size_memory_copy<138>(dst, src);
B139:
B139:
return fixed_size_memory_copy<139>(dst, src);
B140:
B140:
return fixed_size_memory_copy<140>(dst, src);
B141:
B141:
return fixed_size_memory_copy<141>(dst, src);
B142:
B142:
return fixed_size_memory_copy<142>(dst, src);
B143:
B143:
return fixed_size_memory_copy<143>(dst, src);
B144:
B144:
return fixed_size_memory_copy<144>(dst, src);
B145:
B145:
return fixed_size_memory_copy<145>(dst, src);
B146:
B146:
return fixed_size_memory_copy<146>(dst, src);
B147:
B147:
return fixed_size_memory_copy<147>(dst, src);
B148:
B148:
return fixed_size_memory_copy<148>(dst, src);
B149:
B149:
return fixed_size_memory_copy<149>(dst, src);
B150:
B150:
return fixed_size_memory_copy<150>(dst, src);
B151:
B151:
return fixed_size_memory_copy<151>(dst, src);
B152:
B152:
return fixed_size_memory_copy<152>(dst, src);
B153:
B153:
return fixed_size_memory_copy<153>(dst, src);
B154:
B154:
return fixed_size_memory_copy<154>(dst, src);
B155:
B155:
return fixed_size_memory_copy<155>(dst, src);
B156:
B156:
return fixed_size_memory_copy<156>(dst, src);
B157:
B157:
return fixed_size_memory_copy<157>(dst, src);
B158:
B158:
return fixed_size_memory_copy<158>(dst, src);
B159:
B159:
return fixed_size_memory_copy<159>(dst, src);
B160:
B160:
return fixed_size_memory_copy<160>(dst, src);
B161:
B161:
return fixed_size_memory_copy<161>(dst, src);
B162:
B162:
return fixed_size_memory_copy<162>(dst, src);
B163:
B163:
return fixed_size_memory_copy<163>(dst, src);
B164:
B164:
return fixed_size_memory_copy<164>(dst, src);
B165:
B165:
return fixed_size_memory_copy<165>(dst, src);
B166:
B166:
return fixed_size_memory_copy<166>(dst, src);
B167:
B167:
return fixed_size_memory_copy<167>(dst, src);
B168:
B168:
return fixed_size_memory_copy<168>(dst, src);
B169:
B169:
return fixed_size_memory_copy<169>(dst, src);
B170:
B170:
return fixed_size_memory_copy<170>(dst, src);
B171:
B171:
return fixed_size_memory_copy<171>(dst, src);
B172:
B172:
return fixed_size_memory_copy<172>(dst, src);
B173:
B173:
return fixed_size_memory_copy<173>(dst, src);
B174:
B174:
return fixed_size_memory_copy<174>(dst, src);
B175:
B175:
return fixed_size_memory_copy<175>(dst, src);
B176:
B176:
return fixed_size_memory_copy<176>(dst, src);
B177:
B177:
return fixed_size_memory_copy<177>(dst, src);
B178:
B178:
return fixed_size_memory_copy<178>(dst, src);
B179:
B179:
return fixed_size_memory_copy<179>(dst, src);
B180:
B180:
return fixed_size_memory_copy<180>(dst, src);
B181:
B181:
return fixed_size_memory_copy<181>(dst, src);
B182:
B182:
return fixed_size_memory_copy<182>(dst, src);
B183:
B183:
return fixed_size_memory_copy<183>(dst, src);
B184:
B184:
return fixed_size_memory_copy<184>(dst, src);
B185:
B185:
return fixed_size_memory_copy<185>(dst, src);
B186:
B186:
return fixed_size_memory_copy<186>(dst, src);
B187:
B187:
return fixed_size_memory_copy<187>(dst, src);
B188:
B188:
return fixed_size_memory_copy<188>(dst, src);
B189:
B189:
return fixed_size_memory_copy<189>(dst, src);
B190:
B190:
return fixed_size_memory_copy<190>(dst, src);
B191:
B191:
return fixed_size_memory_copy<191>(dst, src);
B192:
B192:
return fixed_size_memory_copy<192>(dst, src);
B193:
B193:
return fixed_size_memory_copy<193>(dst, src);
B194:
B194:
return fixed_size_memory_copy<194>(dst, src);
B195:
B195:
return fixed_size_memory_copy<195>(dst, src);
B196:
B196:
return fixed_size_memory_copy<196>(dst, src);
B197:
B197:
return fixed_size_memory_copy<197>(dst, src);
B198:
B198:
return fixed_size_memory_copy<198>(dst, src);
B199:
B199:
return fixed_size_memory_copy<199>(dst, src);
B200:
B200:
return fixed_size_memory_copy<200>(dst, src);
B201:
B201:
return fixed_size_memory_copy<201>(dst, src);
B202:
B202:
return fixed_size_memory_copy<202>(dst, src);
B203:
B203:
return fixed_size_memory_copy<203>(dst, src);
B204:
B204:
return fixed_size_memory_copy<204>(dst, src);
B205:
B205:
return fixed_size_memory_copy<205>(dst, src);
B206:
B206:
return fixed_size_memory_copy<206>(dst, src);
B207:
B207:
return fixed_size_memory_copy<207>(dst, src);
B208:
B208:
return fixed_size_memory_copy<208>(dst, src);
B209:
B209:
return fixed_size_memory_copy<209>(dst, src);
B210:
B210:
return fixed_size_memory_copy<210>(dst, src);
B211:
B211:
return fixed_size_memory_copy<211>(dst, src);
B212:
B212:
return fixed_size_memory_copy<212>(dst, src);
B213:
B213:
return fixed_size_memory_copy<213>(dst, src);
B214:
B214:
return fixed_size_memory_copy<214>(dst, src);
B215:
B215:
return fixed_size_memory_copy<215>(dst, src);
B216:
B216:
return fixed_size_memory_copy<216>(dst, src);
B217:
B217:
return fixed_size_memory_copy<217>(dst, src);
B218:
B218:
return fixed_size_memory_copy<218>(dst, src);
B219:
B219:
return fixed_size_memory_copy<219>(dst, src);
B220:
B220:
return fixed_size_memory_copy<220>(dst, src);
B221:
B221:
return fixed_size_memory_copy<221>(dst, src);
B222:
B222:
return fixed_size_memory_copy<222>(dst, src);
B223:
B223:
return fixed_size_memory_copy<223>(dst, src);
B224:
B224:
return fixed_size_memory_copy<224>(dst, src);
B225:
B225:
return fixed_size_memory_copy<225>(dst, src);
B226:
B226:
return fixed_size_memory_copy<226>(dst, src);
B227:
B227:
return fixed_size_memory_copy<227>(dst, src);
B228:
B228:
return fixed_size_memory_copy<228>(dst, src);
B229:
B229:
return fixed_size_memory_copy<229>(dst, src);
B230:
B230:
return fixed_size_memory_copy<230>(dst, src);
B231:
B231:
return fixed_size_memory_copy<231>(dst, src);
B232:
B232:
return fixed_size_memory_copy<232>(dst, src);
B233:
B233:
return fixed_size_memory_copy<233>(dst, src);
B234:
B234:
return fixed_size_memory_copy<234>(dst, src);
B235:
B235:
return fixed_size_memory_copy<235>(dst, src);
B236:
B236:
return fixed_size_memory_copy<236>(dst, src);
B237:
B237:
return fixed_size_memory_copy<237>(dst, src);
B238:
B238:
return fixed_size_memory_copy<238>(dst, src);
B239:
B239:
return fixed_size_memory_copy<239>(dst, src);
B240:
B240:
return fixed_size_memory_copy<240>(dst, src);
B241:
B241:
return fixed_size_memory_copy<241>(dst, src);
B242:
B242:
return fixed_size_memory_copy<242>(dst, src);
B243:
B243:
return fixed_size_memory_copy<243>(dst, src);
B244:
B244:
return fixed_size_memory_copy<244>(dst, src);
B245:
B245:
return fixed_size_memory_copy<245>(dst, src);
B246:
B246:
return fixed_size_memory_copy<246>(dst, src);
B247:
B247:
return fixed_size_memory_copy<247>(dst, src);
B248:
B248:
return fixed_size_memory_copy<248>(dst, src);
B249:
B249:
return fixed_size_memory_copy<249>(dst, src);
B250:
B250:
return fixed_size_memory_copy<250>(dst, src);
B251:
B251:
return fixed_size_memory_copy<251>(dst, src);
B252:
B252:
return fixed_size_memory_copy<252>(dst, src);
B253:
B253:
return fixed_size_memory_copy<253>(dst, src);
B254:
B254:
return fixed_size_memory_copy<254>(dst, src);
B255:
B255:
return fixed_size_memory_copy<255>(dst, src);
}
#endif
@ -621,6 +600,6 @@ B255:
memcpy(dst, src, size);
}
}
} // namespace starrocks
/* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */

View File

@ -26,14 +26,10 @@
namespace starrocks {
// This tree is usd for manage restful api path.
template<class T>
template <class T>
class PathTrie {
public:
PathTrie() :
_root("/", "*"),
_root_value(nullptr)
{
};
PathTrie() : _root("/", "*"), _root_value(nullptr){};
~PathTrie() {
if (_root_value != nullptr) {
@ -44,17 +40,14 @@ public:
class TrieNode {
public:
TrieNode(const std::string& key, std::string wildcard) :
_value(nullptr),
_wildcard(std::move(wildcard)) {
TrieNode(const std::string& key, std::string wildcard) : _value(nullptr), _wildcard(std::move(wildcard)) {
if (is_named_wildcard(key)) {
_named_wildcard = extract_template(key);
}
}
TrieNode(const std::string& key, const T& value, std::string wildcard) :
_value(nullptr),
_wildcard(std::move(wildcard)) {
TrieNode(const std::string& key, const T& value, std::string wildcard)
: _value(nullptr), _wildcard(std::move(wildcard)) {
_value = _allocator.allocate(1);
_allocator.construct(_value, value);
if (is_named_wildcard(key)) {
@ -101,8 +94,7 @@ public:
// If this is a template, set this to the node
if (is_named_wildcard(token)) {
std::string temp = extract_template(token);
if (node->_named_wildcard.empty()
|| node->_named_wildcard.compare(temp) == 0) {
if (node->_named_wildcard.empty() || node->_named_wildcard.compare(temp) == 0) {
node->_named_wildcard = temp;
} else {
// Duplicated
@ -122,8 +114,8 @@ public:
return node->insert(path, index + 1, value);
}
bool retrieve(const std::vector<std::string> path, int index,
T* value, std::map<std::string, std::string>* params) {
bool retrieve(const std::vector<std::string> path, int index, T* value,
std::map<std::string, std::string>* params) {
// check max index
if (index >= path.size()) {
return false;
@ -133,15 +125,13 @@ public:
TrieNode* node = get_child(token);
if (node == nullptr) {
node = get_child(_wildcard);
if (node == nullptr) {
if (node == nullptr) {
return false;
}
use_wildcard = true;
} else {
// If we the last one, but we have no value, check wildcard
if (index == path.size() - 1
&& node->_value == nullptr
&& get_child(_wildcard) != nullptr) {
if (index == path.size() - 1 && node->_value == nullptr && get_child(_wildcard) != nullptr) {
node = get_child(_wildcard);
use_wildcard = true;
} else {
@ -174,10 +164,10 @@ public:
}
return false;
}
private:
bool is_named_wildcard(const std::string& key) {
if (key.find('{') != std::string::npos
&& key.find('}') != std::string::npos) {
if (key.find('{') != std::string::npos && key.find('}') != std::string::npos) {
return true;
}
return false;
@ -197,8 +187,7 @@ public:
return pair->second;
}
void put(std::map<std::string, std::string>* params,
TrieNode* node, const std::string& token) {
void put(std::map<std::string, std::string>* params, TrieNode* node, const std::string& token) {
if (params != nullptr && !node->_named_wildcard.empty()) {
params->insert(std::make_pair(node->_named_wildcard, token));
}
@ -230,12 +219,9 @@ public:
return _root.insert(path_array, index, value);
}
bool retrieve(const std::string& path, T* value) {
return retrieve(path, value, nullptr);
}
bool retrieve(const std::string& path, T* value) { return retrieve(path, value, nullptr); }
bool retrieve(const std::string& path, T* value,
std::map<std::string, std::string>* params) {
bool retrieve(const std::string& path, T* value, std::map<std::string, std::string>* params) {
if (path.empty()) {
if (_root_value == nullptr) {
return false;
@ -285,4 +271,4 @@ private:
std::allocator<T> _allocator;
};
}
} // namespace starrocks

View File

@ -17,34 +17,33 @@
#pragma once
#include <mutex>
#include <condition_variable>
#include <mutex>
namespace {
class Semaphore {
public:
explicit Semaphore(int count = 0) : _count(count) {
}
public:
explicit Semaphore(int count = 0) : _count(count) {}
void set_count(int count) { _count = count; }
void set_count(int count) { _count = count; }
void signal() {
std::unique_lock<std::mutex> lock(_mutex);
++_count;
_cv.notify_one();
}
void signal() {
std::unique_lock<std::mutex> lock(_mutex);
++_count;
_cv.notify_one();
}
void wait() {
std::unique_lock<std::mutex> lock(_mutex);
_cv.wait(lock, [=] { return _count > 0; });
--_count;
}
void wait() {
std::unique_lock<std::mutex> lock(_mutex);
_cv.wait(lock, [=] { return _count > 0; });
--_count;
}
private:
std::mutex _mutex;
std::condition_variable _cv;
int _count;
private:
std::mutex _mutex;
std::condition_variable _cv;
int _count;
};
} // end namespace

View File

@ -45,28 +45,13 @@ static const int STRCHR_MODE = _SIDD_CMP_EQUAL_ANY | _SIDD_UBYTE_OPS;
// In this mode, sse text processing functions will return the number of bytes that match
// consecutively from the beginning.
static const int STRCMP_MODE = _SIDD_CMP_EQUAL_EACH | _SIDD_UBYTE_OPS
| _SIDD_NEGATIVE_POLARITY;
static const int STRCMP_MODE = _SIDD_CMP_EQUAL_EACH | _SIDD_UBYTE_OPS | _SIDD_NEGATIVE_POLARITY;
// Precomputed mask values up to 16 bits.
static const int SSE_BITMASK[CHARS_PER_128_BIT_REGISTER] = {
1 << 0,
1 << 1,
1 << 2,
1 << 3,
1 << 4,
1 << 5,
1 << 6,
1 << 7,
1 << 8,
1 << 9,
1 << 10,
1 << 11,
1 << 12,
1 << 13,
1 << 14,
1 << 15,
1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7,
1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15,
};
}
}
} // namespace sse_util
} // namespace starrocks

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <cctz/time_zone.h>

View File

@ -20,72 +20,8 @@
#include <cmath>
#include <exception>
#include <memory>
#include <sstream>
namespace starrocks {
static inline void url_encode(const char* in, int in_len, std::string* out) {
(*out).reserve(in_len);
std::stringstream ss;
for (int i = 0; i < in_len; ++i) {
const char ch = in[i];
// Escape the character iff a) we are in Hive-compat mode and the
// character is in the Hive whitelist or b) we are not in
// Hive-compat mode, and the character is not alphanumeric or one
// of the four commonly excluded characters.
ss << ch;
}
(*out) = ss.str();
}
void url_encode(const std::vector<uint8_t>& in, std::string* out) {
if (in.empty()) {
*out = "";
} else {
url_encode(reinterpret_cast<const char*>(&in[0]), in.size(), out);
}
}
void url_encode(const std::string& in, std::string* out) {
url_encode(in.c_str(), in.size(), out);
}
// Adapted from
// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/
// example/http/server3/request_handler.cpp
// See http://www.boost.org/LICENSE_1_0.txt for license for this method.
bool url_decode(const std::string& in, std::string* out) {
out->clear();
out->reserve(in.size());
for (size_t i = 0; i < in.size(); ++i) {
if (in[i] == '%') {
if (i + 3 <= in.size()) {
int value = 0;
std::istringstream is(in.substr(i + 1, 2));
if (is >> std::hex >> value) {
(*out) += static_cast<char>(value);
i += 2;
} else {
return false;
}
} else {
return false;
}
} else if (in[i] == '+') {
(*out) += ' ';
} else {
(*out) += in[i];
}
}
return true;
}
static void encode_base64_internal(const std::string& in, std::string* out, const unsigned char* basis, bool padding) {
size_t len = in.size();
// Every 3 source bytes will be encoded into 4 bytes.
@ -119,21 +55,11 @@ static void encode_base64_internal(const std::string& in, std::string* out, cons
out->assign((char*)buf.get(), d - buf.get());
}
void base64url_encode(const std::string& in, std::string* out) {
static unsigned char basis64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
encode_base64_internal(in, out, basis64, false);
}
void base64_encode(const std::string& in, std::string* out) {
static unsigned char basis64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
encode_base64_internal(in, out, basis64, true);
}
static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
static const char base64_pad = '=';
static short decoding_table[256] = {
@ -148,34 +74,6 @@ static short decoding_table[256] = {
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2};
static int mod_table[] = {0, 2, 1};
size_t base64_encode(const unsigned char* data, size_t length, unsigned char* encoded_data) {
auto output_length = (size_t)(4.0 * ceil((double)length / 3.0));
if (encoded_data == nullptr) {
return 0;
}
for (uint32_t i = 0, j = 0; i < length;) {
uint32_t octet_a = i < length ? data[i++] : 0;
uint32_t octet_b = i < length ? data[i++] : 0;
uint32_t octet_c = i < length ? data[i++] : 0;
uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 1 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 0 * 6) & 0x3F];
}
for (int i = 0; i < mod_table[length % 3]; i++) {
encoded_data[output_length - 1 - i] = '=';
}
return output_length;
}
static inline int64_t base64_decode(const char* data, size_t length, char* decoded_data) {
const char* current = data;
int ch = 0;
@ -255,25 +153,4 @@ bool base64_decode(const std::string& in, std::string* out) {
return true;
}
void escape_for_html(const std::string& in, std::stringstream* out) {
for (auto& c : in) {
switch (c) {
case '<':
(*out) << "&lt;";
break;
case '>':
(*out) << "&gt;";
break;
case '&':
(*out) << "&amp;";
break;
default:
(*out) << c;
}
}
}
} // namespace starrocks

View File

@ -22,23 +22,6 @@
#include <vector>
namespace starrocks {
// Utility method to URL-encode a string (that is, replace special
// characters with %<hex value in ascii>).
// The optional parameter hive_compat controls whether we mimic Hive's
// behaviour when encoding a string, which is only to encode certain
// characters (excluding, e.g., ' ')
void url_encode(const std::string& in, std::string* out);
void url_encode(const std::vector<uint8_t>& in, std::string* out);
// Utility method to decode a string that was URL-encoded. Returns
// true unless the string could not be correctly decoded.
// The optional parameter hive_compat controls whether or not we treat
// the strings as encoded by Hive, which means selectively ignoring
// certain characters like ' '.
bool url_decode(const std::string& in, std::string* out);
void base64url_encode(const std::string& in, std::string* out);
void base64_encode(const std::string& in, std::string* out);
// Utility method to decode base64 encoded strings. Also not extremely
@ -46,11 +29,4 @@ void base64_encode(const std::string& in, std::string* out);
// Returns true unless the string could not be correctly decoded.
bool base64_decode(const std::string& in, std::string* out);
// Replaces &, < and > with &amp;, &lt; and &gt; respectively. This is
// not the full set of required encodings, but one that should be
// added to on a case-by-case basis. Slow, since it necessarily
// inspects each character in turn, and copies them all to *out; use
// judiciously.
void escape_for_html(const std::string& in, std::stringstream* out);
} // namespace starrocks

View File

@ -210,7 +210,6 @@ set(EXEC_FILES
./storage/rowset/unique_rowset_id_generator_test.cpp
./storage/rowset/default_value_column_iterator_test.cpp
./storage/rowset/index_page_test.cpp
./storage/selection_vector_test.cpp
./storage/snapshot_meta_test.cpp
./storage/short_key_index_test.cpp
./storage/storage_types_test.cpp

View File

@ -1,41 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "storage/selection_vector.h"
#include <gtest/gtest.h>
namespace starrocks {
class SelectionVectorTest : public testing::Test {};
TEST_F(SelectionVectorTest, Normal) {
SelectionVector sel_vel(10);
ASSERT_EQ(10, sel_vel.nrows());
sel_vel.set_all_true();
ASSERT_EQ(" 0: 11111111 11 \n", sel_vel.to_string());
sel_vel.set_all_false();
ASSERT_EQ(" 0: 00000000 00 \n", sel_vel.to_string());
sel_vel.set_row_selected(7);
ASSERT_TRUE(sel_vel.is_row_selected(7));
ASSERT_TRUE(sel_vel.any_selected());
ASSERT_EQ(" 0: 00000001 00 \n", sel_vel.to_string());
sel_vel.clear_bit(7);
ASSERT_EQ(" 0: 00000000 00 \n", sel_vel.to_string());
}
} // namespace starrocks

View File

@ -71,6 +71,7 @@ _source_extensions = '''
.cpp
.tpp
.hh
.hpp
'''.split()