Definition at line 138 of file DistributedAccessRepositoryInFile.h. References Impala::Core::Matrix::DistributedAccess::AddFeature(), GetDir(), Impala::Persistency::KernelMatrixLocator::GetFeature(), Impala::Persistency::RepositoryInFileSystem::GetFile(), Impala::Persistency::File::ReadNative(), Impala::Persistency::File::ReadStrings(), RepFS(), Impala::Core::Matrix::DistributedAccess::SetHasOwnAverages(), and Impala::Persistency::File::Valid(). Referenced by Get(). 00139 { 00140 String dir = GetDir(loc); 00141 String filename = loc.GetFeature() + ".input.txt"; 00142 File file = RepFS().GetFile(loc, dir, filename, false, true); 00143 if (!file.Valid()) 00144 return; 00145 std::vector<String> lines; 00146 file.ReadStrings(std::back_inserter(lines)); 00147 00148 std::vector<double> weights; 00149 std::vector<String> features; 00150 for (int i=0 ; i<lines.size() ; i++) 00151 { 00152 Util::StringParser p(lines[i]); 00153 Real64 weight = p.GetDouble(); 00154 String feature = p.GetString(' ', false); 00155 if ((weight == 0) || (feature.empty())) 00156 { 00157 ILOG_ERROR_HEADNODE("LoadFeatures: parse error in .input.txt"); 00158 return; 00159 } 00160 weights.push_back(weight); 00161 features.push_back(feature); 00162 } 00163 if (features.size() == 0) 00164 { 00165 ILOG_ERROR_HEADNODE("LoadFeatures: no features found"); 00166 return; 00167 } 00168 00169 filename = loc.GetFeature() + ".averages.raw"; 00170 file = RepFS().GetFile(loc, dir, filename, false, true); 00171 std::vector<double> averages; 00172 if (file.Valid()) 00173 { 00174 file.ReadNative(std::back_inserter(averages)); 00175 if (features.size() != averages.size()) 00176 { 00177 ILOG_ERROR_HEADNODE("LoadFeatures: averages do not match"); 00178 return; 00179 } 00180 } 00181 00182 for (int i=0 ; i<features.size() ; i++) 00183 { 00184 if (averages.size() == 0) 00185 da->AddFeature(features[i], weights[i], -1); 00186 else 00187 da->AddFeature(features[i], weights[i], averages[i]); 00188 } 00189 if (averages.size() != 0) 00190 da->SetHasOwnAverages(true); 00191 }
Here is the call graph for this function: ![]()
|