Skip to content

Commit 0f2c6da

Browse files
authored
Merge pull request #6 from nsone/3.0.5
3.0.5
2 parents fed96ef + f9f4e72 commit 0f2c6da

32 files changed

+2134
-1102
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef _COMMON_DEFS_HPP_
21+
#define _COMMON_DEFS_HPP_
22+
23+
#include <cstdint>
24+
25+
namespace datasketches {
26+
27+
static const uint64_t DEFAULT_SEED = 9001;
28+
29+
} // namespace
30+
31+
#endif // _COMMON_DEFS_HPP_
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef _COUNT_ZEROS_HPP_
21+
#define _COUNT_ZEROS_HPP_
22+
23+
#include <cstdint>
24+
25+
#include <stdio.h>
26+
27+
namespace datasketches {
28+
29+
static const uint8_t byte_leading_zeros_table[256] = {
30+
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
31+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
32+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
33+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
34+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
35+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
36+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
39+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
40+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
43+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
46+
};
47+
48+
static const uint8_t byte_trailing_zeros_table[256] = {
49+
8, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
50+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
51+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
52+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
53+
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
54+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
55+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
56+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
57+
7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
58+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
59+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
60+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
61+
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
62+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
63+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
64+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
65+
};
66+
67+
static const uint64_t FCLZ_MASK_56 = 0x00ffffffffffffff;
68+
static const uint64_t FCLZ_MASK_48 = 0x0000ffffffffffff;
69+
static const uint64_t FCLZ_MASK_40 = 0x000000ffffffffff;
70+
static const uint64_t FCLZ_MASK_32 = 0x00000000ffffffff;
71+
static const uint64_t FCLZ_MASK_24 = 0x0000000000ffffff;
72+
static const uint64_t FCLZ_MASK_16 = 0x000000000000ffff;
73+
static const uint64_t FCLZ_MASK_08 = 0x00000000000000ff;
74+
75+
static inline uint8_t count_leading_zeros_in_u64(uint64_t input) {
76+
if (input > FCLZ_MASK_56)
77+
return byte_leading_zeros_table[(input >> 56) & FCLZ_MASK_08];
78+
if (input > FCLZ_MASK_48)
79+
return 8 + byte_leading_zeros_table[(input >> 48) & FCLZ_MASK_08];
80+
if (input > FCLZ_MASK_40)
81+
return 16 + byte_leading_zeros_table[(input >> 40) & FCLZ_MASK_08];
82+
if (input > FCLZ_MASK_32)
83+
return 24 + byte_leading_zeros_table[(input >> 32) & FCLZ_MASK_08];
84+
if (input > FCLZ_MASK_24)
85+
return 32 + byte_leading_zeros_table[(input >> 24) & FCLZ_MASK_08];
86+
if (input > FCLZ_MASK_16)
87+
return 40 + byte_leading_zeros_table[(input >> 16) & FCLZ_MASK_08];
88+
if (input > FCLZ_MASK_08)
89+
return 48 + byte_leading_zeros_table[(input >> 8) & FCLZ_MASK_08];
90+
if (true)
91+
return 56 + byte_leading_zeros_table[(input ) & FCLZ_MASK_08];
92+
}
93+
94+
static inline uint8_t count_trailing_zeros_in_u32(uint32_t input) {
95+
for (int i = 0; i < 4; i++) {
96+
const int byte = input & 0xff;
97+
if (byte != 0) return (i << 3) + byte_trailing_zeros_table[byte];
98+
input >>= 8;
99+
}
100+
return 32;
101+
}
102+
103+
static inline uint8_t count_trailing_zeros_in_u64(uint64_t input) {
104+
for (int i = 0; i < 8; i++) {
105+
const int byte = input & 0xff;
106+
if (byte != 0) return (i << 3) + byte_trailing_zeros_table[byte];
107+
input >>= 8;
108+
}
109+
return 64;
110+
}
111+
112+
} /* namespace datasketches */
113+
114+
#endif // _COUNT_ZEROS_HPP_

3rd/datasketches/datasketches/cpc/cpc_common.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ namespace datasketches {
2929
static const uint8_t CPC_MIN_LG_K = 4;
3030
static const uint8_t CPC_MAX_LG_K = 26;
3131
static const uint8_t CPC_DEFAULT_LG_K = 11;
32-
static const uint64_t DEFAULT_SEED = 9001;
3332

3433
template<typename A> using AllocU8 = typename std::allocator_traits<A>::template rebind_alloc<uint8_t>;
3534
template<typename A> using AllocU16 = typename std::allocator_traits<A>::template rebind_alloc<uint16_t>;

3rd/datasketches/datasketches/cpc/cpc_compressor_impl.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
#include <memory>
2626

2727
#include "compression_data.hpp"
28-
#include "counter_of_zeros.hpp"
2928
#include "cpc_util.hpp"
30-
3129
#include "cpc_common.hpp"
30+
#include "count_zeros.hpp"
3231

3332
namespace datasketches {
3433

@@ -438,7 +437,7 @@ uint8_t cpc_compressor<A>::determine_pseudo_phase(uint8_t lg_k, uint64_t c) {
438437
if (lg_k < 4) throw std::logic_error("lgK < 4");
439438
const size_t tmp = c >> (lg_k - 4);
440439
const uint8_t phase = tmp & 15;
441-
if (phase < 0 or phase >= 16) throw std::out_of_range("wrong phase");
440+
if (phase < 0 || phase >= 16) throw std::out_of_range("wrong phase");
442441
return phase;
443442
}
444443
}

0 commit comments

Comments
 (0)