Skip to content

Instantly share code, notes, and snippets.

@ernestas-poskus
Created June 13, 2017 07:24
Show Gist options
  • Select an option

  • Save ernestas-poskus/8830471689b257af6c386af85549f852 to your computer and use it in GitHub Desktop.

Select an option

Save ernestas-poskus/8830471689b257af6c386af85549f852 to your computer and use it in GitHub Desktop.

Revisions

  1. ernestas-poskus created this gist Jun 13, 2017.
    22 changes: 22 additions & 0 deletions elasticsearch_shards_matrix.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    m = []

    size = 15

    def shards(s, r)
    s * r + s
    end

    size.times { |y| m << Array(0..size).map { |x| shards(y, x) }.join(' | ') }

    print '| '
    size.times { |header| print "| #{header} " }
    puts '|'

    size.times { |header| print "| - " }
    puts '| - |'

    m.each_with_index do |row, index|
    next if index == 0
    print "| #{index} | #{row} |"
    puts
    end