Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 committed Jan 8, 2025
1 parent dbae825 commit 19bd6f5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 47 deletions.
93 changes: 47 additions & 46 deletions ydb/core/formats/arrow/process_columns.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,12 @@ class TOrderedColumnIndexesImpl {
public:
TOrderedColumnIndexesImpl() = default;

TOrderedColumnIndexesImpl(const ui32 columnsCount);
TOrderedColumnIndexesImpl(const std::vector<ui32>& columnIndexes);
TOrderedColumnIndexesImpl(std::vector<ui32>&& columnIndexes);
};
explicit TOrderedColumnIndexesImpl(const ui32 columnsCount);
explicit TOrderedColumnIndexesImpl(const std::vector<ui32>& columnIndexes);
explicit TOrderedColumnIndexesImpl(std::vector<ui32>&& columnIndexes);

template <class TDataContainer>
class TContainerWithIndexes: public TOrderedColumnIndexesImpl {
private:
using TBase = TOrderedColumnIndexesImpl;
YDB_ACCESSOR_DEF(std::shared_ptr<TDataContainer>, Container);

public:
TContainerWithIndexes() = default;

TContainerWithIndexes(const std::vector<ui32>& columnIndexes, const std::shared_ptr<TDataContainer>& container)
: TBase(columnIndexes)
, Container(container) {
if (Container) {
Y_ABORT_UNLESS((ui32)Container->num_columns() == columnIndexes.size());
} else {
Y_ABORT_UNLESS(!columnIndexes.size());
}
}

TContainerWithIndexes(const std::shared_ptr<TDataContainer>& container)
: TBase(TSimpleValidator::CheckNotNull(container)->num_columns())
, Container(container) {
}

TContainerWithIndexes<TDataContainer> BuildWithAnotherContainer(const std::shared_ptr<TDataContainer>& container) const {
return TContainerWithIndexes<TDataContainer>(GetColumnIndexes(), container);
}

bool operator!() const {
return !HasContainer();
}

bool HasContainer() const {
return !!Container;
}

const TDataContainer* operator->() const {
return Container.get();
}

template <class TDataContainerMerge>
static std::vector<ui32> MergeColumnIdxs(const std::vector<TContainerWithIndexes<TDataContainerMerge>>& sources) {
template <class TContainerWithIndexes>
static std::vector<ui32> MergeColumnIdxs(const std::vector<TContainerWithIndexes>& sources) {
class TIterator {
private:
std::vector<ui32>::const_iterator ItCurrent;
Expand Down Expand Up @@ -119,6 +78,48 @@ class TContainerWithIndexes: public TOrderedColumnIndexesImpl {
}
};

template <class TDataContainer>
class TContainerWithIndexes: public TOrderedColumnIndexesImpl {
private:
using TBase = TOrderedColumnIndexesImpl;
YDB_ACCESSOR_DEF(std::shared_ptr<TDataContainer>, Container);

public:
TContainerWithIndexes() = default;

TContainerWithIndexes(const std::vector<ui32>& columnIndexes, const std::shared_ptr<TDataContainer>& container)
: TBase(columnIndexes)
, Container(container) {
if (Container) {
Y_ABORT_UNLESS((ui32)Container->num_columns() == columnIndexes.size());
} else {
Y_ABORT_UNLESS(!columnIndexes.size());
}
}

explicit TContainerWithIndexes(const std::shared_ptr<TDataContainer>& container)
: TBase(TSimpleValidator::CheckNotNull(container)->num_columns())
, Container(container) {
}

TContainerWithIndexes<TDataContainer> BuildWithAnotherContainer(const std::shared_ptr<TDataContainer>& container) const {
return TContainerWithIndexes<TDataContainer>(GetColumnIndexes(), container);
}

bool operator!() const {
return !HasContainer();
}

bool HasContainer() const {
return !!Container;
}

const TDataContainer* operator->() const {
return Container.get();
}

};

class TColumnOperator {
public:
enum class EAbsentFieldPolicy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TSliceToMerge {
ui32 idx = 0;
std::vector<std::shared_ptr<NArrow::TGeneralContainer>> containers;
ui32 recordsCountSum = 0;
auto indexes = NArrow::TContainerWithIndexes<arrow::RecordBatch>::MergeColumnIdxs(Batches);
auto indexes = NArrow::TOrderedColumnIndexesImpl::MergeColumnIdxs(Batches);
std::shared_ptr<arrow::Schema> dataSchema;
const auto& indexInfo = context.GetActualSchema()->GetIndexInfo();
for (auto&& i : Batches) {
Expand Down

0 comments on commit 19bd6f5

Please sign in to comment.