Sha256: f3a61a1566c3645d70fe909607ae557cebd26ac596f321ad129b5548bf61a1d5

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
module Alf
  module Operator::Relational
    describe Summarize::HashBased do
        
      let(:input) {[
        {:a => "via_method", :time => 1},
        {:a => "via_reader", :time => 4},
        {:a => "via_method", :time => 2},
        {:a => "via_reader", :time => 2},
        {:a => "via_method", :time => 1},
      ]}
  
      let(:expected) {[
        {:a => "via_method", :time_sum => 4, :time_max => 2},
        {:a => "via_reader", :time_sum => 6, :time_max => 4},
      ]}
  
      let(:aggs){{:time_sum => Aggregator.sum(:time),
                  :time_max => Aggregator.max(:time)}} 
      let(:operator){ Summarize::HashBased.new(by_key, aggs) }

      before{ operator.pipe(input) }
      subject{ operator.to_a.sort{|t1,t2| t1[:a] <=> t2[:a]} }
  
      describe "when allbut is not set" do
        let(:by_key){ Tools::ProjectionKey.new([:a], false) }
        it { should == expected }
      end
  
      describe "when allbut is set" do
        let(:by_key){ Tools::ProjectionKey.new([:time], true) }
        it { should == expected }
      end
  
    end 
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alf-0.9.3 spec/unit/operator/relational/summarize/test_hash_based.rb
alf-0.9.2 spec/unit/operator/relational/summarize/test_hash_based.rb
alf-0.9.1 spec/unit/operator/relational/summarize/test_hash_based.rb