MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / read

Method read

libminifi/src/core/ProcessSession.cpp:281–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281int ProcessSession::read(const std::shared_ptr<core::FlowFile> &flow, InputStreamCallback *callback) {
282 try {
283 std::shared_ptr<ResourceClaim> claim = nullptr;
284
285 if (flow->getResourceClaim() == nullptr) {
286 // No existed claim for read, we throw exception
287 logger_->log_debug("For %s, no resource claim but size is %d", flow->getUUIDStr(), flow->getSize());
288 if (flow->getSize() == 0) {
289 return 0;
290 }
291 throw Exception(FILE_OPERATION_EXCEPTION, "No Content Claim existed for read");
292 }
293
294 claim = flow->getResourceClaim();
295
296 std::shared_ptr<io::BaseStream> stream = content_session_->read(claim);
297
298 if (nullptr == stream) {
299 throw Exception(FILE_OPERATION_EXCEPTION, "Failed to open flowfile content for read");
300 }
301
302 stream->seek(flow->getOffset());
303
304 auto ret = callback->process(stream);
305 if (ret < 0) {
306 throw Exception(FILE_OPERATION_EXCEPTION, "Failed to process flowfile content");
307 }
308 return gsl::narrow<int>(ret);
309 } catch (std::exception &exception) {
310 logger_->log_debug("Caught Exception %s", exception.what());
311 throw;
312 } catch (...) {
313 logger_->log_debug("Caught Exception during process session read");
314 throw;
315 }
316}
317
318void ProcessSession::importFrom(io::InputStream&& stream, const std::shared_ptr<core::FlowFile> &flow) {
319 importFrom(stream, flow);

Callers 2

importFromMethod · 0.45
importMethod · 0.45

Calls 9

ExceptionClass · 0.85
getResourceClaimMethod · 0.80
log_debugMethod · 0.80
getOffsetMethod · 0.80
getUUIDStrMethod · 0.45
getSizeMethod · 0.45
seekMethod · 0.45
processMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected