-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added data_type and array_data structures (#18)
- Loading branch information
1 parent
e13b837
commit 709f48a
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2024 Man Group Operations Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include "sparrow/buffer.hpp" | ||
#include "sparrow/data_type.hpp" | ||
#include "sparrow/dynamic_bitset.hpp" | ||
|
||
namespace sparrow | ||
{ | ||
struct array_data | ||
{ | ||
using block_type = std::uint8_t; | ||
using bitmap_type = dynamic_bitset<block_type>; | ||
using buffer_type = buffer<block_type>; | ||
|
||
data_descriptor type; | ||
std::int64_t length = 0; | ||
std::int64_t offset = 0; | ||
// bitmap buffer and null_count | ||
bitmap_type bitmap; | ||
// Other buffers | ||
std::vector<buffer_type> buffers; | ||
std::vector<array_data> child_data; | ||
}; | ||
|
||
struct null_type | ||
{ | ||
}; | ||
constexpr null_type null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2024 Man Group Operations Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
namespace sparrow | ||
{ | ||
// TODO: does not support all types specified by the Arrow specification | ||
// yet | ||
enum class data_type | ||
{ | ||
NA = 0, | ||
BOOL, | ||
UINT8, | ||
INT8, | ||
UINT16, | ||
INT16, | ||
UINT32, | ||
INT32, | ||
UINT64, | ||
INT64, | ||
HALF_FLOAT, | ||
FLOAT, | ||
DOUBLE, | ||
// UTF8 variable-length string | ||
STRING, | ||
// Variable-length bytes (no guarantee of UTF8-ness) | ||
BINARY, | ||
// Fixed-size binary. Each value occupies the same number of bytes | ||
FIXED_SIZE_BINARY | ||
}; | ||
|
||
// For now, a tiny wrapper around data_type | ||
// More data and functions to come | ||
class data_descriptor | ||
{ | ||
public: | ||
|
||
constexpr data_descriptor() | ||
: data_descriptor(data_type::UINT8) | ||
{ | ||
} | ||
|
||
constexpr explicit data_descriptor(data_type id) | ||
: m_id(id) | ||
{ | ||
} | ||
|
||
constexpr data_type id() const { return m_id; } | ||
|
||
private: | ||
|
||
data_type m_id; | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters