Class CalculateRecordStats

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.CalculateRecordStats
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@SideEffectFree @SupportsBatching @Tags({"record","stats","metrics"}) @CapabilityDescription("Counts the number of Records in a record set, optionally counting the number of elements per category, where the categories are defined by user-defined properties.") @InputRequirement(INPUT_REQUIRED) @DynamicProperty(name="The name of the category. For example, sport", value="The RecordPath that points to the value of the category. For example /sport", expressionLanguageScope=FLOWFILE_ATTRIBUTES, description="Specifies a category that should be counted. For example, if the property name is \'sport\' and the value is \'/sport\', the processor will count how many records have a value of \'soccer\' for the /sport field, how many have a value of \'baseball\' for the /sport, and so on. These counts be added as attributes named recordStats.sport.soccer, recordStats.sport.baseball.") @WritesAttribute(attribute="record.count",description="A count of the records in the record set in the FlowFile.") @WritesAttribute(attribute="recordStats.<User Defined Property Name>.count",description="A count of the records that contain a value for the user defined property.") @WritesAttribute(attribute="recordStats.<User Defined Property Name>.<value>.count",description="Each value discovered for the user defined property will have its own count attribute. Total number of top N value counts to be added is defined by the limit configuration.") public class CalculateRecordStats extends org.apache.nifi.processor.AbstractProcessor
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final List<org.apache.nifi.components.PropertyDescriptor>
     
    (package private) static final String
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.processor.Relationship
     
    (package private) static final org.apache.nifi.processor.Relationship
     
    (package private) static final Set<org.apache.nifi.processor.Relationship>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Map<String,String>
    calculateStats(org.apache.nifi.flowfile.FlowFile flowFile, Map<String,RecordPath> paths, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     
    protected Map<String,Integer>
    filterBySize(Map<String,Integer> values, int limit, Collection<String> baseKeys)
     
    protected Map<String,RecordPath>
    getRecordPaths(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile)
     
    Set<org.apache.nifi.processor.Relationship>
     
    protected org.apache.nifi.components.PropertyDescriptor
     
    protected List<org.apache.nifi.components.PropertyDescriptor>
     
    void
    onEnabled(org.apache.nifi.processor.ProcessContext context)
     
    void
    onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     

    Methods inherited from class org.apache.nifi.processor.AbstractProcessor

    onTrigger

    Methods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor

    getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue

    Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent

    customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.nifi.components.ConfigurableComponent

    getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate

    Methods inherited from interface org.apache.nifi.processor.Processor

    isStateful, migrateProperties, migrateRelationships
  • Field Details

    • RECORD_COUNT_ATTR

      static final String RECORD_COUNT_ATTR
      See Also:
    • RECORD_READER

      static final org.apache.nifi.components.PropertyDescriptor RECORD_READER
    • LIMIT

      static final org.apache.nifi.components.PropertyDescriptor LIMIT
    • PROPERTY_DESCRIPTORS

      static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • REL_SUCCESS

      static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • REL_FAILURE

      static final org.apache.nifi.processor.Relationship REL_FAILURE
    • RELATIONSHIPS

      static final Set<org.apache.nifi.processor.Relationship> RELATIONSHIPS
    • cache

      private RecordPathCache cache
  • Constructor Details

    • CalculateRecordStats

      public CalculateRecordStats()
  • Method Details

    • getSupportedDynamicPropertyDescriptor

      protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
      Overrides:
      getSupportedDynamicPropertyDescriptor in class org.apache.nifi.components.AbstractConfigurableComponent
    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • onEnabled

      @OnScheduled public void onEnabled(org.apache.nifi.processor.ProcessContext context)
    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • 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:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • getRecordPaths

      protected Map<String,RecordPath> getRecordPaths(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile)
    • calculateStats

      protected Map<String,String> calculateStats(org.apache.nifi.flowfile.FlowFile flowFile, Map<String,RecordPath> paths, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws IOException, SchemaNotFoundException, MalformedRecordException
      Throws:
      IOException
      SchemaNotFoundException
      MalformedRecordException
    • filterBySize

      protected Map<String,Integer> filterBySize(Map<String,Integer> values, int limit, Collection<String> baseKeys)