/root/doris/be/src/util/crc32c.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #include "util/crc32c.h" |
19 | | |
20 | | #include <crc32c/crc32c.h> |
21 | | |
22 | | namespace doris { |
23 | | namespace crc32c { |
24 | | |
25 | 7.66k | uint32_t Extend(uint32_t crc, const char* data, size_t n) { |
26 | 7.66k | return crc32c_extend(crc, (const uint8_t*)data, n); |
27 | 7.66k | } |
28 | | |
29 | 35.6k | uint32_t Value(const char* data, size_t n) { |
30 | 35.6k | return crc32c_value((const uint8_t*)data, n); |
31 | 35.6k | } |
32 | | |
33 | 48.6k | uint32_t Value(const std::vector<Slice>& slices) { |
34 | 48.6k | uint32_t crc = 0; |
35 | 116k | for (const auto& slice : slices) { |
36 | 116k | crc = crc32c_extend(crc, (const uint8_t*)slice.get_data(), slice.get_size()); |
37 | 116k | } |
38 | 48.6k | return crc; |
39 | 48.6k | } |
40 | | |
41 | | } // namespace crc32c |
42 | | } // namespace doris |