title: Index a list of GroovyRowResult into a Map
body: <p>Suppose I have a list of GroovyRowResult entries, as a result of an SQL query against a database:</p>
  
  <pre><code>def myQueryResults = [
      {COLUMN0 = 'VALUE0', COLUMN1 = 'COMMONVALUE0'}, 
      {COLUMN0 = 'VALUE1', COLUMN1 = 'COMMONVALUE0'}, 
      {COLUMN0 = 'VALUE2', COLUMN1 = 'COMMONVALUE0'}, 
      {COLUMN0 = 'VALUE3', COLUMN1 = 'COMMONVALUE1'}, 
      {COLUMN0 = 'VALUE4', COLUMN1 = 'COMMONVALUE1'}, 
      {COLUMN0 = 'VALUE5', COLUMN1 = 'COMMONVALUE1'}
  ]
  </code></pre>
  
  <p>I'd like to transform this list of entries into this map structure:</p>
  
  <pre><code>def result = {
      COMMONVALUE0 : ['VALUE0', 'VALUE1', 'VALUE2'],
      COMMONVALUE1 : ['VALUE3', 'VALUE4', 'VALUE5']
  }
  </code></pre>
  
  <p>I know that in Java, this can be done with Guava, using <code>Maps::uniqueIndex</code>.</p>
  
  <p>What is the Groovy way to accomplish this? Thanks!</p>
  
  <p><strong>UPDATE:</strong> OK I came up with this:</p>
  
  <pre><code>def rows = db.rows(myQuery)
  def result = [:]
  rows.each {
      if (!result[it.COLUMN1]) {
          result[it.COLUMN1] = []
      }
      result[it.COLUMN1] &lt;&lt; it.COLUMN0
  }
  </code></pre>
  
  <p>I'm sure there must be a Groovier way to do it right?</p>