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

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

        $parameters = $context->getForDynamoDB();

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

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

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

        // UnprocessedKeys
        if (count((array)$response['UnprocessedItems'])) {
            $newContext = new Context\BatchWrite();
            foreach ($response['UnprocessedItems'] as $table => $tableParameters) {
                foreach ($tableParameters as $request) {
                    if (isset($request['DeleteRequest'])) {
                        $keys = $request['DeleteRequest']['Key'];
                        $newContext->addKeyToDelete(
                            $table,
                            current($keys['HashKeyElement']),
                            (isset($keys['RangeKeyElement'])?current($keys['RangeKeyElement']):null)
                        );
                    } elseif (isset($request['PutRequest'])) {
                        $item = new Item($table);
                        $item->populateFromDynamoDB($request['PutRequest']['Item']);
                        $newContext->addItemToPut($item);
                    }
                }
            }

            if (null !== $this->logger) {
                $this->log('More unprocessed Items');
            }
        } else {
            $newContext = null;
        }

        // Write Unit
        foreach ($response['Responses'] as $table => $responseItems) {
            $this->addConsumedWriteUnits($table, floatval($responseItems['ConsumedCapacityUnits']));
        }

        return $newContext;
    }