20 #include "../Catalog/Catalog.h"
23 namespace Fragmenter_Namespace {
27 std::vector<T> new_buffer;
28 new_buffer.reserve(indexes.size());
29 for (
const auto i : indexes) {
30 new_buffer.push_back(buffer[i]);
32 std::memcpy(buffer, new_buffer.data(), indexes.size() *
sizeof(
T));
37 std::vector<T> new_buffer;
38 new_buffer.reserve(indexes.size());
39 for (
const auto i : indexes) {
40 new_buffer.push_back(buffer[i]);
42 buffer.swap(new_buffer);
46 const std::vector<size_t>& indexes,
49 switch (ti.get_type()) {
79 switch (ti.get_size()) {
115 template <
typename T>
118 std::sort(indexes.begin(), indexes.end(), [&](
const auto a,
const auto b) {
119 return buffer[
a] < buffer[b];
124 const std::vector<std::string>& buffer) {
125 std::sort(indexes.begin(), indexes.end(), [&](
const auto a,
const auto b) {
126 return buffer[
a].size() < buffer[b].size() ||
127 (buffer[
a].size() == buffer[b].size() && buffer[
a] < buffer[b]);
132 const std::vector<ArrayDatum>& buffer) {
133 std::sort(indexes.begin(), indexes.end(), [&](
const auto a,
const auto b) {
134 return buffer[
a].is_null || buffer[
a].length < buffer[b].length ||
135 (!buffer[b].is_null && buffer[
a].length == buffer[b].length &&
136 memcmp(buffer[
a].pointer, buffer[b].pointer, buffer[
a].length) < 0);
141 std::vector<size_t>& indexes,
144 switch (ti.get_type()) {
171 if (ti.is_varlen()) {
174 switch (ti.get_size()) {
198 CHECK(
false) <<
"invalid type '" << ti.get_type() <<
"' to sort";
206 CHECK_GT(table_desc->sortedColumnId, 0);
207 const auto logical_cd =
212 table_desc->sortedColumnId + (logical_cd->columnType.is_geometry() ? 1 : 0));
213 const auto it = std::find(insertDataStruct.
columnIds.begin(),
215 physical_cd->columnId);
218 const auto dist = std::distance(insertDataStruct.
columnIds.begin(), it);
220 std::vector<size_t> indexes(insertDataStruct.
numRows);
221 std::iota(indexes.begin(), indexes.end(), 0);
222 CHECK_LT(static_cast<size_t>(dist), insertDataStruct.
data.size());
225 for (
size_t i = 0; i < insertDataStruct.
columnIds.size(); ++i) {
Catalog_Namespace::Catalog * catalog_
std::vector< std::string > * stringsPtr
std::vector< ArrayDatum > * arraysPtr
DEVICE void sort(ARGS &&...args)
std::vector< bool > is_default
void sortIndexesImpl(std::vector< size_t > &indexes, const T *buffer)
void shuffleByIndexes(const ColumnDescriptor *cd, const std::vector< size_t > &indexes, DataBlockPtr &data)
const int physicalTableId_
virtual void sortData(InsertData &insertDataStruct)
size_t numRows
a vector of column ids for the row(s) being inserted
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
specifies the content in-memory of a row in the column metadata table
void sortIndexes(const ColumnDescriptor *cd, std::vector< size_t > &indexes, const DataBlockPtr &data)
std::vector< DataBlockPtr > data
the number of rows being inserted
DEVICE void iota(ARGS &&...args)
The data to be inserted using the fragment manager.
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
std::vector< int > columnIds
identifies the table into which the data is being inserted
void shuffleByIndexesImpl(const std::vector< size_t > &indexes, T *buffer)