Use memorymapped file
@@ -80,14 +80,11 @@ ConstantTensorLoader::create(const vespalib::string &path, const vespalib::strin
return std::make_unique<SimpleConstantValue>(_engine.from_spec(TensorSpec("double")));
}
if (ends_with(path, ".tbf")) {
- vespalib::File file(path);
- file.open(File::READONLY);
- std::vector<char> content(file.stat()._size);
- file.read(&content[0], content.size(), 0);
- vespalib::nbostream_longlivedbuf stream(&content[0], content.size());
+ vespalib::MappedFileInput file(path);
+ vespalib::Memory content = file.get();
+ vespalib::nbostream stream(content.data, content.size);
return std::make_unique<SimpleConstantValue>(_engine.decode(stream));
}
- else {
Slime slime;
decode_json(path, slime);
std::set<vespalib::string> indexed;
@@ -106,7 +103,6 @@ ConstantTensorLoader::create(const vespalib::string &path, const vespalib::strin
}
return std::make_unique<SimpleConstantValue>(_engine.from_spec(spec));
}
-}
} // namespace vespalib::eval
} // namespace vespalib
