Sha256: 33b14fb0421932463eb174d6632fb23a7638b8abbef6dd9ad2e71d4f58b2bb5f

Contents?: true

Size: 1.05 KB

Versions: 27

Compression:

Stored size: 1.05 KB

Contents

module ETL #:nodoc:
  module Processor #:nodoc:
    # Row processor that checks whether or not the row has already passed 
    # through the ETL processor, using the key fields provided as the keys
    # to check.
    class CheckUniqueProcessor < ETL::Processor::RowProcessor

      # The keys to check
      attr_accessor :keys
      
      # Initialize the processor
      # Configuration options:
      # * <tt>:keys</tt>: An array of keys to check against
      def initialize(control, configuration)
        super
        @keys = configuration[:keys]
      end

      # A Hash of keys that have already been processed.
      def compound_key_constraints
        @compound_key_constraints ||= {}
      end
      
      # Process the row. This implementation will only return a row if it
      # it's key combination has not already been seen.
      def process(row)
        key = (keys.collect { |k| row[k] }).join('|')
        unless compound_key_constraints[key]
          compound_key_constraints[key] = 1
          return row
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 7 rubygems

Version Path
aeden-activewarehouse-etl-0.9.1 etl/lib/etl/processor/check_unique_processor.rb
colincasey-activewarehouse-etl-0.9.4 lib/etl/processor/check_unique_processor.rb
colincasey-activewarehouse-etl-0.9.5 lib/etl/processor/check_unique_processor.rb
factorylabs-activewarehouse-etl-0.9.1.2 lib/etl/processor/check_unique_processor.rb
factorylabs-activewarehouse-etl-0.9.1.3 lib/etl/processor/check_unique_processor.rb
factorylabs-activewarehouse-etl-0.9.1.4 lib/etl/processor/check_unique_processor.rb
factorylabs-activewarehouse-etl-0.9.1.5 lib/etl/processor/check_unique_processor.rb
factorylabs-activewarehouse-etl-0.9.1.6 lib/etl/processor/check_unique_processor.rb
factorylabs-activewarehouse-etl-0.9.1.7 lib/etl/processor/check_unique_processor.rb
jayzes-activewarehouse-etl-0.9.1.1 lib/etl/processor/check_unique_processor.rb
jayzes-activewarehouse-etl-0.9.1.2 lib/etl/processor/check_unique_processor.rb
jayzes-activewarehouse-etl-0.9.1 lib/etl/processor/check_unique_processor.rb
activewarehouse-etl-0.9.5.rc1 lib/etl/processor/check_unique_processor.rb
darrell-activewarehouse-etl-0.9.1.6 lib/etl/processor/check_unique_processor.rb
darrell-activewarehouse-etl-0.9.1.4 lib/etl/processor/check_unique_processor.rb
factorylabs-activewarehouse-etl-0.9.1.8 lib/etl/processor/check_unique_processor.rb
balinterdi-activewarehouse-etl-0.9.2 lib/etl/processor/check_unique_processor.rb
activewarehouse-etl-0.7.0 lib/etl/processor/check_unique_processor.rb
activewarehouse-etl-0.8.0 lib/etl/processor/check_unique_processor.rb
activewarehouse-etl-0.7.2 lib/etl/processor/check_unique_processor.rb