Skip to content

Commit

Permalink
added an analyzer fastpath when all table values pass the filter
Browse files Browse the repository at this point in the history
  • Loading branch information
glookka committed Aug 19, 2023
1 parent 4c90bc0 commit fea449a
Showing 1 changed file with 58 additions and 11 deletions.
69 changes: 58 additions & 11 deletions columnar/accessor/accessorint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ class AnalyzerBlock_Int_Table_c : public AnalyzerBlock_c
template <typename T, typename RANGE_EVAL>
FORCE_INLINE bool SetupNextBlock ( const StoredBlock_Int_Table_T<T> & tBlock, bool bEq );

template <typename T>
FORCE_INLINE bool AllPassFilter ( const StoredBlock_Int_Table_T<T> & tBlock ) const;

private:
int m_iTableValueId = -1;
std::vector<uint8_t> m_dTableValues;
Expand Down Expand Up @@ -697,6 +700,39 @@ bool AnalyzerBlock_Int_Table_c::SetupNextBlock ( const StoredBlock_Int_Table_T<T
return true;
}

template <typename T>
bool AnalyzerBlock_Int_Table_c::AllPassFilter ( const StoredBlock_Int_Table_T<T> & tBlock ) const
{
switch ( m_eType )
{
case FilterType_e::VALUES:
if ( m_dValues.size()==1 )
{
if ( tBlock.GetTableSize()==1 && m_iTableValueId!=-1 )
return true;
}
else
{
if ( m_dTableValues.size()==tBlock.GetTableSize() )
return true;
}
break;

case FilterType_e::RANGE:
case FilterType_e::FLOATRANGE:
{
bool bAllPass = true;
for ( int i = 0; i < tBlock.GetTableSize(); i++ )
bAllPass &= m_dRangeMap[i];
return bAllPass;
}

default: break;
}

return false;
}

//////////////////////////////////////////////////////////////////////////

template<typename VALUES, typename ACCESSOR_VALUES>
Expand Down Expand Up @@ -1099,30 +1135,41 @@ bool Analyzer_INT_T<VALUES,ACCESSOR_VALUES,RANGE_EVAL,HAVE_MATCHING_BLOCKS>::Get
template<typename VALUES, typename ACCESSOR_VALUES, typename RANGE_EVAL, bool HAVE_MATCHING_BLOCKS>
bool Analyzer_INT_T<VALUES,ACCESSOR_VALUES,RANGE_EVAL,HAVE_MATCHING_BLOCKS>::MoveToBlock ( int iNextBlock )
{
// can be different from block packing
IntPacking_e ePackingForProcessingFunc = IntPacking_e::CONST;

while(true)
{
ANALYZER::m_iCurBlockId = iNextBlock;
ACCESSOR::SetCurBlock ( ANALYZER::m_iCurBlockId );

if ( ACCESSOR::m_ePacking!=IntPacking_e::CONST && ACCESSOR::m_ePacking!=IntPacking_e::TABLE )
break;
ePackingForProcessingFunc = ACCESSOR::m_ePacking;

if ( ACCESSOR::m_ePacking==IntPacking_e::CONST )
{
if ( m_tBlockConst.SetupNextBlock<ACCESSOR_VALUES,RANGE_EVAL> ( ACCESSOR::m_tBlockConst, !m_tSettings.m_bExclude ) )
break;
}
else
bool bProcessBlock = true;
switch ( ACCESSOR::m_ePacking )
{
if ( m_tBlockTable.SetupNextBlock<ACCESSOR_VALUES,RANGE_EVAL> ( ACCESSOR::m_tBlockTable, !m_tSettings.m_bExclude ) )
break;
case IntPacking_e::CONST:
bProcessBlock = m_tBlockConst.SetupNextBlock<ACCESSOR_VALUES,RANGE_EVAL> ( ACCESSOR::m_tBlockConst, !m_tSettings.m_bExclude );
break;

case IntPacking_e::TABLE:
bProcessBlock = m_tBlockTable.SetupNextBlock<ACCESSOR_VALUES,RANGE_EVAL> ( ACCESSOR::m_tBlockTable, !m_tSettings.m_bExclude );
if ( bProcessBlock && m_tBlockTable.AllPassFilter ( ACCESSOR::m_tBlockTable ) )
ePackingForProcessingFunc = IntPacking_e::CONST;
break;

default:
break;
}

if ( bProcessBlock )
break;

if ( !ANALYZER::RewindToNextBlock ( (ACCESSOR&)*this, iNextBlock ) )
return false;
}

m_fnProcessSubblock = m_dProcessingFuncs [ to_underlying ( ACCESSOR::m_ePacking ) ];
m_fnProcessSubblock = m_dProcessingFuncs [ to_underlying ( ePackingForProcessingFunc ) ];
assert ( m_fnProcessSubblock );

return true;
Expand Down

0 comments on commit fea449a

Please sign in to comment.