lordgamez commented on code in PR #1866: URL: https://github.com/apache/nifi-minifi-cpp/pull/1866#discussion_r1842192376
########## extensions/standard-processors/processors/SplitRecord.cpp: ########## @@ -0,0 +1,119 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "SplitRecord.h" + +#include "core/Resource.h" +#include "nonstd/expected.hpp" +#include "utils/GeneralUtils.h" + +namespace org::apache::nifi::minifi::processors { +namespace { +template<typename RecordSetIO> +std::shared_ptr<RecordSetIO> getRecordSetIO(core::ProcessContext& context, const core::PropertyReference& property) { + std::string service_name; + if (context.getProperty(property, service_name) && !IsNullOrEmpty(service_name)) { + auto record_set_io = std::dynamic_pointer_cast<RecordSetIO>(context.getControllerService(service_name)); + if (!record_set_io) + return nullptr; + return record_set_io; + } + return nullptr; +} +} // namespace + +void SplitRecord::onSchedule(core::ProcessContext& context, core::ProcessSessionFactory&) { + record_set_reader_ = getRecordSetIO<core::RecordSetReader>(context, RecordReader); + if (!record_set_reader_) { + throw Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION, "Record Reader set is missing or invalid"); + } + record_set_writer_ = getRecordSetIO<core::RecordSetWriter>(context, RecordWriter); + if (!record_set_writer_) { + throw Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION, "Record Writer set is missing or invalid"); Review Comment: Fixed in https://github.com/apache/nifi-minifi-cpp/pull/1866/commits/b9de420231ec51690b584cab09189236bfe2eabd ########## PROCESSORS.md: ########## @@ -2875,6 +2877,41 @@ In the list below, the names of required properties appear in bold. Any other pr | segment.original.filename | | The filename of the parent FlowFile | +## SplitRecord + +### Description + +Splits up an input FlowFile that is in a record-oriented data format into multiple smaller FlowFiles + +### Properties + +In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language. + +| Name | Default Value | Allowable Values | Description | +|-----------------------|---------------|------------------|-------------------------------------------------------------------------------------------------------------------------------| +| **Record Reader** | | | Specifies the Controller Service to use for reading incoming data | +| **Record Writer** | | | Specifies the Controller Service to use for writing out the records | +| **Records Per Split** | | | Specifies how many records should be written to each 'split' or 'segment' FlowFile<br/>**Supports Expression Language: true** | + +### Relationships + +| Name | Description | +|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| failure | If a FlowFile cannot be transformed from the configured input format to the configured output format, the unchanged FlowFile will be routed to this relationship. | +| original | Upon successfully splitting an input FlowFile, the original FlowFile will be sent to this relationship. | +| splits | The individual 'segments' of the original FlowFile will be routed to this relationship. | + +### Output Attributes + +| Attribute | Relationship | Description | +|---------------------------|--------------|--------------------------------------------------------------------------------------------------------------------------------| +| record.count | | The number of records in the FlowFile. This is added to FlowFiles that are routed to the 'splits' Relationship. | +| fragment.identifier | | All split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute | Review Comment: Good point, updated in https://github.com/apache/nifi-minifi-cpp/pull/1866/commits/b9de420231ec51690b584cab09189236bfe2eabd -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
