| 191 | } |
| 192 | |
| 193 | void TCBDsvDataLoader::ProcessBlock(IRawObjectsOrderDataVisitor* visitor) { |
| 194 | visitor->StartNextBlock(AsyncRowProcessor.GetParseBufferSize()); |
| 195 | |
| 196 | auto& columnsDescription = DataMetaInfo.ColumnsInfo->Columns; |
| 197 | |
| 198 | auto parseLine = [&](TString& line, int lineIdx) { |
| 199 | const auto& featuresLayout = *DataMetaInfo.FeaturesLayout; |
| 200 | bool storeStringColumns = DataMetaInfo.StoreStringColumns; |
| 201 | |
| 202 | ui32 featureId = 0; |
| 203 | ui32 targetId = 0; |
| 204 | ui32 baselineIdx = 0; |
| 205 | |
| 206 | TVector<float> floatFeatures; |
| 207 | floatFeatures.resize(featuresLayout.GetFloatFeatureCount()); |
| 208 | |
| 209 | TVector<ui32> catFeatures; |
| 210 | catFeatures.resize(featuresLayout.GetCatFeatureCount()); |
| 211 | |
| 212 | TVector<TString> textFeatures; |
| 213 | textFeatures.resize(featuresLayout.GetTextFeatureCount()); |
| 214 | |
| 215 | TVector<TVector<float>> embeddingFeatures; |
| 216 | embeddingFeatures.resize(featuresLayout.GetEmbeddingFeatureCount()); |
| 217 | |
| 218 | size_t tokenIdx = 0; |
| 219 | try { |
| 220 | const bool floatFeaturesOnly = catFeatures.empty() && textFeatures.empty(); |
| 221 | auto splitter = NCsvFormat::CsvSplitter( |
| 222 | line, |
| 223 | FieldDelimiter, |
| 224 | floatFeaturesOnly ? '\0' : CsvSplitterQuote |
| 225 | ); |
| 226 | do { |
| 227 | TStringBuf token = splitter.Consume(); |
| 228 | CB_ENSURE( |
| 229 | tokenIdx < columnsDescription.size(), |
| 230 | "wrong column count: found token " << token << " with id more than " |
| 231 | << columnsDescription.ysize() << " values:\n" << line |
| 232 | ); |
| 233 | try { |
| 234 | switch (columnsDescription[tokenIdx].Type) { |
| 235 | case EColumn::Categ: { |
| 236 | if (!FeatureIgnored[featureId]) { |
| 237 | const ui32 catFeatureIdx = featuresLayout.GetInternalFeatureIdx(featureId); |
| 238 | catFeatures[catFeatureIdx] = visitor->GetCatFeatureValue(lineIdx, featureId, token); |
| 239 | } |
| 240 | ++featureId; |
| 241 | break; |
| 242 | } |
| 243 | case EColumn::HashedCateg: { |
| 244 | if (!FeatureIgnored[featureId]) { |
| 245 | if (!TryFromString<ui32>( |
| 246 | token, |
| 247 | catFeatures[featuresLayout.GetInternalFeatureIdx(featureId)] |
| 248 | )) |
| 249 | { |
| 250 | CB_ENSURE( |
nothing calls this directly
no test coverage detected