Sha256: 0051e594f66578a87e508d0028a410ae0bd8bcfedafe2c4c4467afdd3a86c971

Contents?: true

Size: 754 Bytes

Versions: 26

Compression:

Stored size: 754 Bytes

Contents

class ExplainResult
  def initialize(rows)
    @rows = rows
  end
  
  def ast
    by_section[:abstract_syntax_tree].first
  end
  
  def stage_count
    stage_dependencies.length
  end
  
  def stage_dependencies
    by_section[:stage_dependencies] || []
  end
  
  def to_tsv
    @rows.join("\n")
  end
  
  def raw
    @rows
  end
  
  def to_s
    to_tsv
  end
  
  private
  
  def by_section
    current_section = nil
    @rows.inject({}) do |sections, row|
      if row.match(/^[A-Z]/)
        current_section = row.chomp(':').downcase.gsub(' ', '_').to_sym
        sections[current_section] = []
      elsif row.length == 0
        next sections
      else
        sections[current_section] << row.strip
      end
      sections
    end
  end
end

Version data entries

26 entries across 26 versions & 4 rubygems

Version Path
rbhive-u2i-1.0.2 lib/rbhive/explain_result.rb
rbhive-u2i-1.0.1 lib/rbhive/explain_result.rb
rbhive-1.0.0 lib/rbhive/explain_result.rb
sequel-impala-1.0.1 lib/rbhive/explain_result.rb
rbhive-u2i-1.0.0 lib/rbhive/explain_result.rb
rbhive-1.0.3.pre lib/rbhive/explain_result.rb
rbhive-vidma-1.0.2.pre1.pre.thrift0.9.1 lib/rbhive/explain_result.rb
rbhive-vidma-1.0.2.pre.pre.thrift0.9.1 lib/rbhive/explain_result.rb
rbhive-1.0.2.pre lib/rbhive/explain_result.rb
rbhive-1.0.1.pre lib/rbhive/explain_result.rb
rbhive-1.0.0.pre lib/rbhive/explain_result.rb
rbhive-0.6.0 lib/rbhive/explain_result.rb
rbhive-0.5.3 lib/rbhive/explain_result.rb
rbhive-0.5.2 lib/rbhive/explain_result.rb
rbhive-0.5.1 lib/rbhive/explain_result.rb
rbhive-0.5.0 lib/rbhive/explain_result.rb
rbhive-0.2.95 lib/rbhive/explain_result.rb
rbhive-0.2.94 lib/rbhive/explain_result.rb
rbhive-0.2.93 lib/rbhive/explain_result.rb
rbhive-0.2.92 lib/rbhive/explain_result.rb