1
1
#include " arrow_filter.h"
2
2
#include " switch_type.h"
3
+ #include " common/container.h"
4
+ #include " common/adapter.h"
5
+
3
6
#include < contrib/libs/apache/arrow/cpp/src/arrow/array/builder_primitive.h>
4
7
#include < contrib/libs/apache/arrow/cpp/src/arrow/chunked_array.h>
5
8
#include < contrib/libs/apache/arrow/cpp/src/arrow/compute/api_vector.h>
@@ -307,7 +310,7 @@ NKikimr::NArrow::TColumnFilter TColumnFilter::MakePredicateFilter(const arrow::D
307
310
return NArrow::TColumnFilter (std::move (bits));
308
311
}
309
312
310
- template <arrow::Datum::Kind kindExpected, class TData >
313
+ template <class TData >
311
314
bool ApplyImpl (const TColumnFilter& filter, std::shared_ptr<TData>& batch, const std::optional<ui32> startPos, const std::optional<ui32> count) {
312
315
if (!batch || !batch->num_rows ()) {
313
316
return false ;
@@ -322,33 +325,26 @@ bool ApplyImpl(const TColumnFilter& filter, std::shared_ptr<TData>& batch, const
322
325
}
323
326
}
324
327
if (filter.IsTotalDenyFilter ()) {
325
- batch = batch-> Slice ( 0 , 0 );
328
+ batch = NAdapter::TDataBuilderPolicy<TData>:: GetEmptySame (batch );
326
329
return true ;
327
330
}
328
331
if (filter.IsTotalAllowFilter ()) {
329
332
return true ;
330
333
}
331
- auto res = arrow::compute::Filter (batch, filter.BuildArrowFilter (batch->num_rows (), startPos, count));
332
- Y_VERIFY_S (res.ok (), res.status ().message ());
333
- Y_ABORT_UNLESS ((*res).kind () == kindExpected);
334
- if constexpr (kindExpected == arrow::Datum::TABLE) {
335
- batch = (*res).table ();
336
- return batch->num_rows ();
337
- }
338
- if constexpr (kindExpected == arrow::Datum::RECORD_BATCH) {
339
- batch = (*res).record_batch ();
340
- return batch->num_rows ();
341
- }
342
- AFL_VERIFY (false );
343
- return false ;
334
+ batch = NAdapter::TDataBuilderPolicy<TData>::ApplyArrowFilter (batch, filter.BuildArrowFilter (batch->num_rows (), startPos, count));
335
+ return batch->num_rows ();
336
+ }
337
+
338
+ bool TColumnFilter::Apply (std::shared_ptr<TGeneralContainer>& batch, const std::optional<ui32> startPos, const std::optional<ui32> count) const {
339
+ return ApplyImpl (*this , batch, startPos, count);
344
340
}
345
341
346
342
bool TColumnFilter::Apply (std::shared_ptr<arrow::Table>& batch, const std::optional<ui32> startPos, const std::optional<ui32> count) const {
347
- return ApplyImpl<arrow::Datum::TABLE> (*this , batch, startPos, count);
343
+ return ApplyImpl (*this , batch, startPos, count);
348
344
}
349
345
350
346
bool TColumnFilter::Apply (std::shared_ptr<arrow::RecordBatch>& batch, const std::optional<ui32> startPos, const std::optional<ui32> count) const {
351
- return ApplyImpl<arrow::Datum::RECORD_BATCH> (*this , batch, startPos, count);
347
+ return ApplyImpl (*this , batch, startPos, count);
352
348
}
353
349
354
350
void TColumnFilter::Apply (const ui32 expectedRecordsCount, std::vector<arrow::Datum*>& datums) const {
0 commit comments