/**
  * @param \Riak\Client\Core\Query\Crdt\Op\MapOp $op
  *
  * @return array
  */
 private function convertMap(MapOp $op)
 {
     $updates = [];
     $removes = [];
     $values = [];
     foreach ($op->getMapUpdates() as $key => $value) {
         $updates["{$key}_map"] = $this->convertMap($value);
     }
     foreach ($op->getSetUpdates() as $key => $value) {
         $updates["{$key}_set"] = $this->convertSet($value);
     }
     foreach ($op->getFlagUpdates() as $key => $value) {
         $updates["{$key}_flag"] = $this->convertFlag($value);
     }
     foreach ($op->getCounterUpdates() as $key => $value) {
         $updates["{$key}_counter"] = $this->convertCounter($value);
     }
     foreach ($op->getRegisterUpdates() as $key => $value) {
         $updates["{$key}_register"] = $this->convertRegister($value);
     }
     foreach ($op->getMapRemoves() as $key => $value) {
         $removes["{$key}_map"] = $key;
     }
     foreach ($op->getSetRemoves() as $key => $value) {
         $removes["{$key}_set"] = $key;
     }
     foreach ($op->getFlagRemoves() as $key => $value) {
         $removes["{$key}_flag"] = $key;
     }
     foreach ($op->getCounterRemoves() as $key => $value) {
         $removes["{$key}_counter"] = $key;
     }
     foreach ($op->getRegisterRemoves() as $key => $value) {
         $removes["{$key}_register"] = $key;
     }
     if (!empty($updates)) {
         $values['update'] = $updates;
     }
     if (!empty($removes)) {
         $values['remove'] = array_keys($removes);
     }
     return $values;
 }
 /**
  * @param \Riak\Client\Core\Query\Crdt\Op\MapOp $op
  *
  * @return \Riak\Client\ProtoBuf\MapOp
  */
 protected function convertMap(Op\MapOp $op)
 {
     $mapOp = new ProtoBuf\MapOp();
     $updates = [];
     $removes = [];
     foreach ($op->getMapUpdates() as $key => $value) {
         $map = $this->convertMap($value);
         $update = $this->createMapUpdate($key, MapFieldType::MAP, $map);
         $updates[] = $update;
     }
     foreach ($op->getSetUpdates() as $key => $value) {
         $set = $this->convertSet($value);
         $update = $this->createMapUpdate($key, MapFieldType::SET, $set);
         $updates[] = $update;
     }
     foreach ($op->getFlagUpdates() as $key => $value) {
         $flag = $this->convertFlag($value);
         $update = $this->createMapUpdate($key, MapFieldType::FLAG, $flag);
         $updates[] = $update;
     }
     foreach ($op->getCounterUpdates() as $key => $value) {
         $counter = $this->convertCounter($value);
         $update = $this->createMapUpdate($key, MapFieldType::COUNTER, $counter);
         $updates[] = $update;
     }
     foreach ($op->getRegisterUpdates() as $key => $value) {
         $register = $value->getValue();
         $update = $this->createMapUpdate($key, MapFieldType::REGISTER, $register);
         $updates[] = $update;
     }
     foreach ($op->getMapRemoves() as $key => $value) {
         $removes[] = $this->createMapField($key, MapFieldType::MAP);
     }
     foreach ($op->getSetRemoves() as $key => $value) {
         $removes[] = $this->createMapField($key, MapFieldType::SET);
     }
     foreach ($op->getFlagRemoves() as $key => $value) {
         $removes[] = $this->createMapField($key, MapFieldType::FLAG);
     }
     foreach ($op->getCounterRemoves() as $key => $value) {
         $removes[] = $this->createMapField($key, MapFieldType::COUNTER);
     }
     foreach ($op->getRegisterRemoves() as $key => $value) {
         $removes[] = $this->createMapField($key, MapFieldType::REGISTER);
     }
     $mapOp->setUpdates($updates);
     $mapOp->setRemoves($removes);
     return $mapOp;
 }