Skip to content

Commit

Permalink
add exclude filters to CalcCount
Browse files Browse the repository at this point in the history
  • Loading branch information
glookka committed Apr 13, 2023
1 parent b64d9ea commit 86b3af3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions secondary/secondary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SecondaryIndex_c : public Index_i
bool Setup ( const std::string & sFile, std::string & sError );

bool CreateIterators ( std::vector<BlockIterator_i *> & 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;
Expand Down Expand Up @@ -485,7 +485,7 @@ bool SecondaryIndex_c::CreateIterators ( std::vector<BlockIterator_i *> & 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;

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions secondary/secondary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,7 +69,7 @@ class Index_i
virtual ~Index_i() = default;

virtual bool CreateIterators ( std::vector<common::BlockIterator_i *> & 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;
Expand Down

0 comments on commit 86b3af3

Please sign in to comment.