lib/dynamoid/adapter/aws_sdk.rb
def batch_get_item(options)
        hash = Hash.new{|h, k| h[k] = []}
        return hash if options.all?{|k, v| v.empty?}
        options.each do |t, ids|
          Array(ids).in_groups_of(100, false) do |group|
            batch = AWS::DynamoDB::BatchGet.new(:config => @@connection.config)
            batch.table(t, :all, Array(group)) unless group.nil? || group.empty?
            batch.each do |table_name, attributes|
              hash[table_name] << attributes.symbolize_keys!
            end
          end
        end
        hash
      end
# Get many items at once from DynamoDB. More efficient than getting each item individually.
#
# @example Retrieve IDs 1 and 2 from the table testtable
#   Dynamoid::Adapter::AwsSdk.batch_get_item('table1' => ['1', '2'])
#
# @param [Hash] options the hash of tables and IDs to retrieve
#
# @return [Hash] a hash where keys are the table names and the values are the retrieved items
#
# @since 0.2.0
Get many items at once from DynamoDB. More efficient than getting each item individually.
Get many items at once from DynamoDB . More efficient than getting each item individually .
def batch_get_item(options)
        hash = Hash.new{|h, k| h[k] = []}
        return hash if options.all?{|k, v| v.empty?}
        options.each do |t, ids|
          Array(ids).in_groups_of(100, false) do |group|
            batch = AWS::DynamoDB::BatchGet.new(:config => @@connection.config)
            batch.table(t, :all, Array(group)) unless group.nil? || group.empty?
            batch.each do |table_name, attributes|
              hash[table_name] << attributes.symbolize_keys!
            end
          end
        end
        hash
      end
def batch_get_item ( options ) hash = Hash . new { | h , k | h [ k ] = [ ] } return hash if options . all? { | k , v | v . empty? } options . each do | t , ids | Array ( ids ) . in_groups_of ( 100 , false ) do | group | batch = AWS :: DynamoDB :: BatchGet . new ( :config => @@connection . config ) batch . table ( t , :all , Array ( group ) ) unless group . nil? || group . empty? batch . each do | table_name , attributes | hash [ table_name ] << attributes . symbolize_keys! end end end hash end
Get many items at once from DynamoDB.
Get many items at once from DynamoDB .
a hash where keys are the table names and the values are the retrieved items
a hash where keys are the table names and the values are the retrieved items
Hash
options
options the hash of tables and IDs to retrieve
options the hash of tables and IDs to retrieve
example
Retrieve IDs 1 and 2 from the table testtable Dynamoid::Adapter::AwsSdk.batch_get_item('table1' => ['1', '2'])
Retrieve IDs 1 and 2 from the table testtable Dynamoid :: Adapter :: AwsSdk . batch_get_item ( ' table1 ' = > [ ' 1 ' ' 2 ' ] )
since
None