From 86b3af30afe00d0244d6c1536164a0e2848003c6 Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Thu, 13 Apr 2023 15:38:06 +0200 Subject: [PATCH] add exclude filters to CalcCount --- secondary/secondary.cpp | 11 +++++++++-- secondary/secondary.h | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/secondary/secondary.cpp b/secondary/secondary.cpp index e1e8e9f3..7c3aeb69 100644 --- a/secondary/secondary.cpp +++ b/secondary/secondary.cpp @@ -69,7 +69,7 @@ class SecondaryIndex_c : public Index_i bool Setup ( const std::string & sFile, std::string & sError ); bool CreateIterators ( std::vector & dIterators, const Filter_t & tFilter, const RowidRange_t * pBounds, uint32_t uMaxValues, int64_t iRsetSize, int iCutoff, std::string & sError ) const override; - bool CalcCount ( uint32_t & uCount, const common::Filter_t & tFilter, std::string & sError ) const override; + bool CalcCount ( uint32_t & uCount, const common::Filter_t & tFilter, uint32_t uMaxValues, std::string & sError ) const override; uint32_t GetNumIterators ( const common::Filter_t & tFilter ) const override; bool IsEnabled ( const std::string & sName ) const override; int64_t GetCountDistinct ( const std::string & sName ) const override; @@ -485,7 +485,7 @@ bool SecondaryIndex_c::CreateIterators ( std::vector & dItera } -bool SecondaryIndex_c::CalcCount ( uint32_t & uCount, const common::Filter_t & tFilter, std::string & sError ) const +bool SecondaryIndex_c::CalcCount ( uint32_t & uCount, const common::Filter_t & tFilter, uint32_t uMaxValues, std::string & sError ) const { uCount = 0; @@ -500,15 +500,22 @@ bool SecondaryIndex_c::CalcCount ( uint32_t & uCount, const common::Filter_t & t if ( !FixupFilter ( tFixedFilter, tFilter, *pCol ) ) return false; + bool bExclude = tFixedFilter.m_bExclude; + tFixedFilter.m_bExclude = false; + switch ( tFixedFilter.m_eType ) { case FilterType_e::VALUES: uCount = CalcValsRows ( tFixedFilter ); + if ( bExclude ) + uCount = uMaxValues - uCount; return true; case FilterType_e::RANGE: case FilterType_e::FLOATRANGE: uCount = CalcRangeRows ( tFixedFilter ); + if ( bExclude ) + uCount = uMaxValues - uCount; return true; default: diff --git a/secondary/secondary.h b/secondary/secondary.h index 5d2c1161..8edd1684 100644 --- a/secondary/secondary.h +++ b/secondary/secondary.h @@ -38,7 +38,7 @@ namespace common namespace SI { -static const int LIB_VERSION = 8; +static const int LIB_VERSION = 9; static const uint32_t STORAGE_VERSION = 7; struct ColumnInfo_t @@ -69,7 +69,7 @@ class Index_i virtual ~Index_i() = default; virtual bool CreateIterators ( std::vector & dIterators, const common::Filter_t & tFilter, const common::RowidRange_t * pBounds, uint32_t uMaxValues, int64_t iRsetSize, int iCutoff, std::string & sError ) const = 0; - virtual bool CalcCount ( uint32_t & uCount, const common::Filter_t & tFilter, std::string & sError ) const = 0; + virtual bool CalcCount ( uint32_t & uCount, const common::Filter_t & tFilter, uint32_t uMaxValues, std::string & sError ) const = 0; virtual uint32_t GetNumIterators ( const common::Filter_t & tFilter ) const = 0; virtual bool IsEnabled ( const std::string & sName ) const = 0; virtual int64_t GetCountDistinct ( const std::string & sName ) const = 0;