diff --git a/secondary/blockreader.cpp b/secondary/blockreader.cpp index 6a397d10..31f251fc 100644 --- a/secondary/blockreader.cpp +++ b/secondary/blockreader.cpp @@ -36,6 +36,10 @@ void ColumnInfo_t::Load ( util::FileReader_c & tReader ) m_sName = tReader.Read_string(); m_eType = (AttrType_e)tReader.Unpack_uint32(); m_uCountDistinct = tReader.Unpack_uint32(); + + auto iJsonFieldPos = m_sName.find ( "['" ); + if ( iJsonFieldPos!=std::string::npos ) + m_sJsonParentName = m_sName.substr ( 0, iJsonFieldPos ); } diff --git a/secondary/blockreader.h b/secondary/blockreader.h index 45fa9532..2dc71ccd 100644 --- a/secondary/blockreader.h +++ b/secondary/blockreader.h @@ -80,6 +80,7 @@ struct ColumnInfo_t { common::AttrType_e m_eType = common::AttrType_e::NONE; std::string m_sName; + std::string m_sJsonParentName; uint32_t m_uCountDistinct = 0; bool m_bEnabled = true; diff --git a/secondary/secondary.cpp b/secondary/secondary.cpp index c2956a26..2b77e08d 100644 --- a/secondary/secondary.cpp +++ b/secondary/secondary.cpp @@ -205,6 +205,8 @@ bool SecondaryIndex_c::Setup ( const std::string & sFile, std::string & sError ) } m_hAttrs.insert ( { tCol.m_sName, i } ); + if ( !tCol.m_sJsonParentName.empty() ) + m_hAttrs.emplace ( tCol.m_sJsonParentName, i ); } m_iBlocksBase = m_tReader.GetPos(); @@ -276,13 +278,24 @@ bool SecondaryIndex_c::SaveMeta ( std::string & sError ) void SecondaryIndex_c::ColumnUpdated ( const char * sName ) { - auto tIt = m_hAttrs.find ( sName ); - if ( tIt==m_hAttrs.end() ) + int iAttr = GetColumnId ( sName ); + if ( iAttr==-1 ) return; - ColumnInfo_t & tCol = m_dAttrs[tIt->second]; + ColumnInfo_t & tCol = m_dAttrs[iAttr]; m_bUpdated |= tCol.m_bEnabled; // already disabled indexes should not cause flush + bool bWasUpdated = tCol.m_bEnabled; tCol.m_bEnabled = false; + + // need to disable all fields at this JSON attribute + if ( bWasUpdated && !tCol.m_sJsonParentName.empty() ) + { + for ( auto & tSibling : m_dAttrs ) + { + if ( tSibling.m_sJsonParentName==tCol.m_sJsonParentName ) + tSibling.m_bEnabled = false; + } + } }