| 30 | using ::deepx_core::InstanceReaderImpl; |
| 31 | |
| 32 | class EmbedInstanceReader : public InstanceReaderImpl { |
| 33 | protected: |
| 34 | const GraphClient* graph_client_ = nullptr; |
| 35 | const DeepClient* deep_client_ = nullptr; |
| 36 | |
| 37 | LineParser line_parser_; |
| 38 | |
| 39 | public: |
| 40 | virtual bool InitGraphClient(const GraphClient* graph_client); |
| 41 | virtual bool InitDeepClient(const DeepClient* deep_client); |
| 42 | virtual void PostInit(const std::string& /*node_config*/) {} |
| 43 | |
| 44 | bool Open(const std::string& file) override { |
| 45 | return line_parser_.Open(file); |
| 46 | } |
| 47 | |
| 48 | protected: |
| 49 | template <typename ValueType> |
| 50 | bool NextInstanceBatch(Instance* inst, int batch, |
| 51 | std::vector<ValueType>* values) { |
| 52 | if (!line_parser_.NextBatch<ValueType>(batch, values)) { |
| 53 | line_parser_.Close(); |
| 54 | inst->clear_batch(); |
| 55 | return false; |
| 56 | } |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | // InstanceReaderImpl |
| 61 | void InitX(Instance* /* inst */) override {} |
| 62 | void InitXBatch(Instance* /*inst*/) override {} |
| 63 | bool ParseLine() override { return true; } |
| 64 | }; |
| 65 | |
| 66 | std::unique_ptr<EmbedInstanceReader> NewEmbedInstanceReader( |
| 67 | const std::string& name); |
nothing calls this directly
no outgoing calls
no test coverage detected