OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ForeignStorageBuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "DataMgr/AbstractBuffer.h"
20 
21 using namespace Data_Namespace;
22 
23 namespace foreign_storage {
25  public:
27 
28  void read(int8_t* const destination,
29  const size_t num_bytes,
30  const size_t offset = 0,
31  const MemoryLevel destination_buffer_type = CPU_LEVEL,
32  const int destination_device_id = -1) override;
33 
34  void write(int8_t* source,
35  const size_t num_bytes,
36  const size_t offset = 0,
37  const MemoryLevel source_buffer_type = CPU_LEVEL,
38  const int source_device_id = -1) override;
39 
40  void reserve(size_t additional_num_bytes) override;
41 
42  void append(int8_t* source,
43  const size_t num_bytes,
44  const MemoryLevel source_buffer_type = CPU_LEVEL,
45  const int device_id = -1) override;
46 
47  int8_t* getMemoryPtr() override;
48  size_t pageCount() const override;
49  size_t pageSize() const override;
50  size_t reservedSize() const override;
51  MemoryLevel getType() const override;
52 
53  private:
54  std::unique_ptr<int8_t[]> buffer_;
56 };
57 } // namespace foreign_storage
size_t append(FILE *f, const size_t size, const int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
Definition: File.cpp:158
size_t write(FILE *f, const size_t offset, const size_t size, const int8_t *buf)
Writes the specified number of bytes to the offset position in file f from buf.
Definition: File.cpp:143
An AbstractBuffer is a unit of data management for a data manager.
size_t read(FILE *f, const size_t offset, const size_t size, int8_t *buf, const std::string &file_path)
Reads the specified number of bytes from the offset position in file f into buf.
Definition: File.cpp:125