| 2063 | |
| 2064 | template <class TColumn> |
| 2065 | static void CheckFeaturesByType( |
| 2066 | EFeatureType featureType, |
| 2067 | // not TConstArrayRef to allow template parameter deduction |
| 2068 | const TVector<THolder<TColumn>>& data, |
| 2069 | const TExclusiveFeatureBundlesData& exclusiveFeatureBundlesData, |
| 2070 | const TPackedBinaryFeaturesData& packedBinaryFeaturesData, |
| 2071 | const TFeatureGroupsData& featuresGroupsData, |
| 2072 | const TStringBuf featureTypeName |
| 2073 | ) { |
| 2074 | const auto& packedBinaryToSrcIndex = packedBinaryFeaturesData.PackedBinaryToSrcIndex; |
| 2075 | const auto& bundlesMetaData = exclusiveFeatureBundlesData.MetaData; |
| 2076 | const auto& featuresGroupsMetaData = featuresGroupsData.MetaData; |
| 2077 | |
| 2078 | for (auto featureIdx : xrange(data.size())) { |
| 2079 | auto* dataPtr = data[featureIdx].Get(); |
| 2080 | if (!dataPtr) { |
| 2081 | continue; |
| 2082 | } |
| 2083 | |
| 2084 | auto maybePackedBinaryIndex |
| 2085 | = packedBinaryFeaturesData.FlatFeatureIndexToPackedBinaryIndex[dataPtr->GetId()]; |
| 2086 | auto maybeBundlePart |
| 2087 | = exclusiveFeatureBundlesData.FlatFeatureIndexToBundlePart[dataPtr->GetId()]; |
| 2088 | auto maybeGroupPart |
| 2089 | = featuresGroupsData.FlatFeatureIndexToGroupPart[dataPtr->GetId()]; |
| 2090 | |
| 2091 | CB_ENSURE_INTERNAL( |
| 2092 | maybePackedBinaryIndex.Defined() + maybeBundlePart.Defined() + maybeGroupPart.Defined() <= 1, |
| 2093 | "Data." << featureType << "Features[" << featureIdx |
| 2094 | << "] was mis-included into more than one aggregated column" |
| 2095 | ); |
| 2096 | |
| 2097 | if (maybePackedBinaryIndex) { |
| 2098 | auto requiredTypePtr |
| 2099 | = dynamic_cast<TPackedBinaryValuesHolderImpl<TColumn>*>(dataPtr); |
| 2100 | CB_ENSURE_INTERNAL( |
| 2101 | requiredTypePtr, |
| 2102 | "Data." << featureType << "Features[" << featureIdx << "] is not of type " |
| 2103 | "TPackedBinaryValuesHolderImpl" |
| 2104 | ); |
| 2105 | |
| 2106 | auto linearPackedBinaryFeatureIdx = maybePackedBinaryIndex->GetLinearIdx(); |
| 2107 | CB_ENSURE_INTERNAL( |
| 2108 | linearPackedBinaryFeatureIdx < packedBinaryToSrcIndex.size(), |
| 2109 | "linearPackedBinaryFeatureIdx (" << linearPackedBinaryFeatureIdx << ") is greater than " |
| 2110 | "packedBinaryToSrcIndex.size (" << packedBinaryToSrcIndex.size() << ')' |
| 2111 | ); |
| 2112 | auto srcFeature = packedBinaryToSrcIndex[linearPackedBinaryFeatureIdx]; |
| 2113 | CB_ENSURE_INTERNAL( |
| 2114 | srcFeature.FeatureType == featureType, |
| 2115 | "packedBinaryToSrcIndex[" << linearPackedBinaryFeatureIdx << "] type is not " |
| 2116 | << featureType |
| 2117 | ); |
| 2118 | CB_ENSURE_INTERNAL( |
| 2119 | srcFeature.FeatureIdx == featureIdx, |
| 2120 | "packedBinaryToSrcIndex[" << linearPackedBinaryFeatureIdx << "] feature index is not " |
| 2121 | << featureIdx |
| 2122 | ); |
no test coverage detected