OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PassThroughBuffer.cpp
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 #include "PassThroughBuffer.h"
18 
19 namespace foreign_storage {
20 
21 PassThroughBuffer::PassThroughBuffer(const int8_t* data, const size_t data_byte_size)
22  : AbstractBuffer(0)
23  , data_ptr_(const_cast<int8_t*>(data))
24  , data_byte_size_(data_byte_size) {
26 }
27 
28 void PassThroughBuffer::read(int8_t* const destination,
29  const size_t num_bytes,
30  const size_t offset,
31  const MemoryLevel destination_buffer_type,
32  const int destination_device_id) {
33  memcpy(destination, data_ptr_ + offset, num_bytes);
34 }
35 
36 void PassThroughBuffer::reserve(size_t additional_num_bytes) {
37  UNREACHABLE() << " unexpected call to purposefully unimplemented function in "
38  "PassThroughBuffer";
39 }
40 
41 void PassThroughBuffer::append(int8_t* source,
42  const size_t num_bytes,
43  const MemoryLevel source_buffer_type,
44  const int device_id) {
45  UNREACHABLE() << " unexpected call to purposefully unimplemented function in "
46  "PassThroughBuffer";
47 }
48 
50  return data_ptr_;
51 }
52 
54  UNREACHABLE() << " unexpected call to purposefully unimplemented function in "
55  "PassThroughBuffer";
56  return 0;
57 }
58 
60  return CPU_LEVEL;
61 }
62 
63 void PassThroughBuffer::write(int8_t* source,
64  const size_t num_bytes,
65  const size_t offset,
66  const MemoryLevel source_buffer_type,
67  const int source_device_id) {
68  UNREACHABLE() << " unexpected call to purposefully unimplemented function in "
69  "PassThroughBuffer";
70 }
71 
73  UNREACHABLE() << " unexpected call to purposefully unimplemented function in "
74  "PassThroughBuffer";
75  return 0; // Added to avoid "no return statement" compiler warning
76 }
77 
79  UNREACHABLE() << " unexpected call to purposefully unimplemented function in "
80  "PassThroughBuffer";
81  return 0; // Added to avoid "no return statement" compiler warning
82 }
83 } // namespace foreign_storage
MemoryLevel getType() const override
void append(int8_t *source, const size_t num_bytes, const MemoryLevel source_buffer_type=CPU_LEVEL, const int device_id=-1) override
#define UNREACHABLE()
Definition: Logger.h:266
void write(int8_t *source, const size_t num_bytes, const size_t offset=0, const MemoryLevel source_buffer_type=CPU_LEVEL, const int source_device_id=-1) override
void read(int8_t *const destination, const size_t num_bytes, const size_t offset=0, const MemoryLevel destination_buffer_type=CPU_LEVEL, const int destination_device_id=-1) override
An AbstractBuffer is a unit of data management for a data manager.
void setSize(const size_t size)
size_t reservedSize() const override
void reserve(size_t additional_num_bytes) override