Class PartitionRecord
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.PartitionRecord
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SupportsBatching
@InputRequirement(INPUT_REQUIRED)
@CapabilityDescription("Splits, or partitions, record-oriented data based on the configured fields in the data. One or more properties must be added. The name of the property is the name of an attribute to add. The value of the property is a RecordPath to evaluate against each Record. Two records will go to the same outbound FlowFile only if they have the same value for each of the given RecordPaths. Because we know that all records in a given output FlowFile have the same value for the fields that are specified by the RecordPath, an attribute is added for each field. See Additional Details on the Usage page for more information and examples.")
@DynamicProperty(name="The name given to the dynamic property is the name of the attribute that will be used to denote the value of the associated RecordPath.",
value="A RecordPath that points to a field in the Record.",
description="Each dynamic property represents a RecordPath that will be evaluated against each record in an incoming FlowFile. When the value of the RecordPath is determined for a Record, an attribute is added to the outgoing FlowFile. The name of the attribute is the same as the name of this property. The value of the attribute is the same as the value of the field in the Record that the RecordPath points to. Note that no attribute will be added if the value returned for the RecordPath is null or is not a scalar value (i.e., the value is an Array, Map, or Record).",
expressionLanguageScope=FLOWFILE_ATTRIBUTES)
@WritesAttribute(attribute="record.count",description="The number of records in an outgoing FlowFile") @WritesAttribute(attribute="mime.type",description="The MIME Type that the configured Record Writer indicates is appropriate") @WritesAttribute(attribute="fragment.identifier",description="All partitioned FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute") @WritesAttribute(attribute="fragment.index",description="A one-up number that indicates the ordering of the partitioned FlowFiles that were created from a single parent FlowFile") @WritesAttribute(attribute="fragment.count",description="The number of partitioned FlowFiles generated from the parent FlowFile") @WritesAttribute(attribute="segment.original.filename ",description="The filename of the parent FlowFile") @WritesAttribute(attribute="<dynamic property name>",description="For each dynamic property that is added, an attribute may be added to the FlowFile. See the description for Dynamic Properties for more information.")
@Tags({"record","partition","recordpath","rpath","segment","split","group","bin","organize"})
@SeeAlso({ConvertRecord.class,SplitRecord.class,UpdateRecord.class,QueryRecord.class})
@UseCase(description="Separate records into separate FlowFiles so that all of the records in a FlowFile have the same value for a given field or set of fields.",keywords={"separate","split","partition","break apart","colocate","segregate","record","field","recordpath"},configuration="Choose a RecordReader that is appropriate based on the format of the incoming data.\nChoose a RecordWriter that writes the data in the desired output format.\n\nAdd a single additional property. The name of the property should describe the type of data that is being used to partition the data. The property\'s value should be a RecordPath that specifies which output FlowFile the Record belongs to.\n\nFor example, if we want to separate records based on their `transactionType` field, we could add a new property named `transactionType`. The value of the property might be `/transaction/type`. An input FlowFile will then be separated into as few FlowFiles as possible such that each output FlowFile has the same value for the `transactionType` field.\n") @UseCase(description="Separate records based on whether or not they adhere to a specific criteria",keywords={"separate","split","partition","break apart","segregate","record","field","recordpath","criteria"},configuration="Choose a RecordReader that is appropriate based on the format of the incoming data.\nChoose a RecordWriter that writes the data in the desired output format.\n\nAdd a single additional property. The name of the property should describe the criteria. The property\'s value should be a RecordPath that returns `true` if the Record meets the criteria or `false` otherwise.\n\nFor example, if we want to separate records based on whether or not they have a transaction total of more than $1,000 we could add a new property named `largeTransaction` with a value of `/transaction/total > 1000`. This will create two FlowFiles. In the first, all records will have a total over `1000`. In the second, all records will have a transaction less than or equal to 1000. Each FlowFile will have an attribute named `largeTransaction` with a value of `true` or `false`.\n")
public class PartitionRecord
extends org.apache.nifi.processor.AbstractProcessor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class(package private) static classWe have this ValueWrapper class here because we want to use it as part of the key to a Map and we want two values that may or may not be arrays. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final List<org.apache.nifi.components.PropertyDescriptor> (package private) static final org.apache.nifi.components.PropertyDescriptor(package private) static final org.apache.nifi.components.PropertyDescriptorprivate final RecordPathCache(package private) static final org.apache.nifi.processor.Relationship(package private) static final org.apache.nifi.processor.Relationship(package private) static final org.apache.nifi.processor.Relationshipprivate static final Set<org.apache.nifi.processor.Relationship> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) private RecordPathgetRecordPath(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.components.PropertyDescriptor prop, org.apache.nifi.flowfile.FlowFile flowFile) Set<org.apache.nifi.processor.Relationship> protected org.apache.nifi.components.PropertyDescriptorgetSupportedDynamicPropertyDescriptor(String propertyDescriptorName) protected List<org.apache.nifi.components.PropertyDescriptor> voidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) Methods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateProperties, migrateRelationships
-
Field Details
-
recordPathCache
-
RECORD_READER
static final org.apache.nifi.components.PropertyDescriptor RECORD_READER -
RECORD_WRITER
static final org.apache.nifi.components.PropertyDescriptor RECORD_WRITER -
PROPERTY_DESCRIPTORS
-
REL_SUCCESS
static final org.apache.nifi.processor.Relationship REL_SUCCESS -
REL_ORIGINAL
static final org.apache.nifi.processor.Relationship REL_ORIGINAL -
REL_FAILURE
static final org.apache.nifi.processor.Relationship REL_FAILURE -
RELATIONSHIPS
-
-
Constructor Details
-
PartitionRecord
public PartitionRecord()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) - Overrides:
customValidatein classorg.apache.nifi.components.AbstractConfigurableComponent
-
getSupportedDynamicPropertyDescriptor
protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) - Overrides:
getSupportedDynamicPropertyDescriptorin classorg.apache.nifi.components.AbstractConfigurableComponent
-
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor- Throws:
org.apache.nifi.processor.exception.ProcessException
-
getRecordPath
private RecordPath getRecordPath(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.components.PropertyDescriptor prop, org.apache.nifi.flowfile.FlowFile flowFile)
-