be/src/io/fs/file_meta_cache.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 "io/fs/file_meta_cache.h" |
19 | | |
20 | | namespace doris { |
21 | | |
22 | | std::string FileMetaCache::get_key(const std::string file_name, int64_t modification_time, |
23 | 289 | int64_t file_size) { |
24 | 289 | std::string meta_cache_key; |
25 | 289 | meta_cache_key.resize(file_name.size() + sizeof(int64_t)); |
26 | | |
27 | 289 | memcpy(meta_cache_key.data(), file_name.data(), file_name.size()); |
28 | 289 | if (modification_time != 0) { |
29 | 205 | memcpy(meta_cache_key.data() + file_name.size(), &modification_time, sizeof(int64_t)); |
30 | 205 | } else { |
31 | 84 | memcpy(meta_cache_key.data() + file_name.size(), &file_size, sizeof(int64_t)); |
32 | 84 | } |
33 | 289 | return meta_cache_key; |
34 | 289 | } |
35 | | |
36 | | std::string FileMetaCache::get_key(io::FileReaderSPtr file_reader, |
37 | 279 | const io::FileDescription& _file_description) { |
38 | 279 | return FileMetaCache::get_key( |
39 | 279 | file_reader->path().native(), _file_description.mtime, |
40 | 279 | _file_description.file_size == -1 ? file_reader->size() : _file_description.file_size); |
41 | 279 | } |
42 | | |
43 | | } // namespace doris |