public function batchGet(Context\BatchGet $context)
    {
        if (null !== $this->logger) {
            $this->log('BatchGet');
        }

        if (0 === count($context)) {
            $message = "BatchGet context doesn't contain any key to get";
            if (null !== $this->logger) {
                $this->log($message, Logger::ERROR);
            }
            throw new Exception\AttributesException($message);
        }

        $parameters = $context->getForDynamoDB();

        if (null !== $this->logger) {
            $this->log('BatchGet request paramaters : '.print_r($parameters, true), Logger::DEBUG);
        }

        $response = $this->connector->batchGetItem($parameters);

        if (null !== $this->logger) {
            $this->log('BatchGet request response : '.print_r($response, true), Logger::DEBUG);
        }

        // UnprocessedKeys
        if (count((array)$response['UnprocessedKeys'])) {
            $unprocessKeyContext = new Context\BatchGet();
            foreach ($response['UnprocessedKeys'] as $table => $tableParameters) {
                foreach ($tableParameters->Keys as $key) {
                    $unprocessKeyContext->addKey($table, current($key->HashKeyElement), current($key->RangeKeyElement));
                }
                if (!empty($tableParameters->AttributesToGet)) {
                    $unprocessKeyContext->setAttributesToGet($table, $tableParameters->AttributesToGet);
                }
            }
        } else {
            $unprocessKeyContext = null;
        }

        $collection = new Batch\BatchCollection($unprocessKeyContext);

        foreach ($response['Responses'] as $table => $responseItems) {
            $this->addConsumedReadUnits($table, floatval($responseItems['ConsumedCapacityUnits']));

            $items = new Collection();
            foreach ($responseItems['Items'] as $responseItem) {
                $item = new Item($table);
                $item->populateFromDynamoDB($responseItem);
                $items->add($item);
            }

            if (null !== $this->logger) {
                $this->log('Find '.count($items).' Items on table '.$table);
            }

            $collection->setItems($table, $items);
        }

        return $collection;
    }
public function batchGet(Context\BatchGet $context)
    {
        if (null !== $this->logger) {
            $this->log('BatchGet');
        }

        if (0 === count($context)) {
            $message = "BatchGet context doesn't contain any key to get";
            if (null !== $this->logger) {
                $this->log($message, Logger::ERROR);
            }
            throw new Exception\AttributesException($message);
        }

        $parameters = $context->getForDynamoDB();

        if (null !== $this->logger) {
            $this->log('BatchGet request paramaters : '.print_r($parameters, true), Logger::DEBUG);
        }

        $response = $this->connector->batchGetItem($parameters);

        if (null !== $this->logger) {
            $this->log('BatchGet request response : '.print_r($response, true), Logger::DEBUG);
        }

        // UnprocessedKeys
        if (count((array)$response['UnprocessedKeys'])) {
            $unprocessKeyContext = new Context\BatchGet();
            foreach ($response['UnprocessedKeys'] as $table => $tableParameters) {
                foreach ($tableParameters->Keys as $key) {
                    $unprocessKeyContext->addKey($table, current($key->HashKeyElement), current($key->RangeKeyElement));
                }
                if (!empty($tableParameters->AttributesToGet)) {
                    $unprocessKeyContext->setAttributesToGet($table, $tableParameters->AttributesToGet);
                }
            }
        } else {
            $unprocessKeyContext = null;
        }

        $collection = new Batch\BatchCollection($unprocessKeyContext);

        foreach ($response['Responses'] as $table => $responseItems) {
            $this->addConsumedReadUnits($table, floatval($responseItems['ConsumedCapacityUnits']));

            $items = new Collection();
            foreach ($responseItems['Items'] as $responseItem) {
                $item = new Item($table);
                $item->populateFromDynamoDB($responseItem);
                $items->add($item);
            }

            if (null !== $this->logger) {
                $this->log('Find '.count($items).' Items on table '.$table);
            }

            $collection->setItems($table, $items);
        }

        return $collection;
    }
public function batchGet ( Context \ BatchGet $ context ) { if ( null !== $ this -> logger ) { $ this -> log ( 'BatchGet' ) ; } if ( 0 === count ( $ context ) ) { $ message = "BatchGet context doesn't contain any key to get" ; if ( null !== $ this -> logger ) { $ this -> log ( $ message , Logger :: ERROR ) ; } throw new Exception \ AttributesException ( $ message ) ; } $ parameters = $ context -> getForDynamoDB ( ) ; if ( null !== $ this -> logger ) { $ this -> log ( 'BatchGet request paramaters : ' . print_r ( $ parameters , true ) , Logger :: DEBUG ) ; } $ response = $ this -> connector -> batchGetItem ( $ parameters ) ; if ( null !== $ this -> logger ) { $ this -> log ( 'BatchGet request response : ' . print_r ( $ response , true ) , Logger :: DEBUG ) ; } // UnprocessedKeys if ( count ( ( array ) $ response [ 'UnprocessedKeys' ] ) ) { $ unprocessKeyContext = new Context \ BatchGet ( ) ; foreach ( $ response [ 'UnprocessedKeys' ] as $ table => $ tableParameters ) { foreach ( $ tableParameters -> Keys as $ key ) { $ unprocessKeyContext -> addKey ( $ table , current ( $ key -> HashKeyElement ) , current ( $ key -> RangeKeyElement ) ) ; } if ( ! empty ( $ tableParameters -> AttributesToGet ) ) { $ unprocessKeyContext -> setAttributesToGet ( $ table , $ tableParameters -> AttributesToGet ) ; } } } else { $ unprocessKeyContext = null ; } $ collection = new Batch \ BatchCollection ( $ unprocessKeyContext ) ; foreach ( $ response [ 'Responses' ] as $ table => $ responseItems ) { $ this -> addConsumedReadUnits ( $ table , floatval ( $ responseItems [ 'ConsumedCapacityUnits' ] ) ) ; $ items = new Collection ( ) ; foreach ( $ responseItems [ 'Items' ] as $ responseItem ) { $ item = new Item ( $ table ) ; $ item -> populateFromDynamoDB ( $ responseItem ) ; $ items -> add ( $ item ) ; } if ( null !== $ this -> logger ) { $ this -> log ( 'Find ' . count ( $ items ) . ' Items on table ' . $ table ) ; } $ collection -> setItems ( $ table , $ items ) ; } return $ collection ; }
Get a batch of items
@param Context\BatchGet $context
@throws \Riverline\DynamoDB\Exception\AttributesException
@return \Riverline\DynamoDB\Batch\BatchCollection
Get a batch of items