Sha256: bd6240ea6ef0cc681c224cd931e37b848a31621de7d58da1e2836a86d88a6b51

Contents?: true

Size: 997 Bytes

Versions: 26

Compression:

Stored size: 997 Bytes

Contents

module Pacer::Pipes
  class IsUniquePipe < RubyPipe
    import java.util.ArrayList
    import com.tinkerpop.pipes.sideeffect.SideEffectPipe
    import com.tinkerpop.pipes.util.iterators.ExpandableIterator
    import com.tinkerpop.pipes.filter.DuplicateFilterPipe

    include SideEffectPipe

    def initialize
      super()
      prepare_state
    end

    def processNextStart
      value = starts.next
      check_uniqueness value if @unique
      value
    end

    def reset
      super()
      prepare_state
    end

    def unique?
      @unique
    end

    def getSideEffect
      @unique
    end

    protected

    def check_uniqueness(value)
      @expando.add value
      @unique_pipe.next
    rescue EmptyPipe, java.util.NoSuchElementException
      @unique = false
    end

    def prepare_state
      @unique = true
      @expando = ExpandableIterator.new ArrayList.new.iterator
      @unique_pipe = DuplicateFilterPipe.new
      @unique_pipe.setStarts @expando
    end

  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pacer-2.0.10-java lib/pacer/pipe/is_unique_pipe.rb
pacer-2.0.10.pre-java lib/pacer/pipe/is_unique_pipe.rb
pacer-2.0.8-java lib/pacer/pipe/is_unique_pipe.rb
pacer-2.0.6-java lib/pacer/pipe/is_unique_pipe.rb
pacer-2.0.4.pre-java lib/pacer/pipe/is_unique_pipe.rb
pacer-2.0.0.pre-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.6.0-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.5.4-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.5.3-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.5.2-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.5.1-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.4.2-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.4.1-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.4.0-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.3.5-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.3.4-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.3.3-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.3.2-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.3.1-java lib/pacer/pipe/is_unique_pipe.rb
pacer-1.2.0-java lib/pacer/pipe/is_unique_pipe.rb