@param \Riak\Client\Core\Query\Crdt\Op\MapOp $op

@return \Riak\Client\ProtoBuf\MapOp
960807
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;
    }
560886
public function execute(RiakOperation $operation)
    {
        if (empty($this->nodes)) {
            throw new RiakException('There are no nodes in the cluster.');
        }

        $size  = count($this->nodes);
        $index = mt_rand(0, $size - 1);
        $node  = $this->nodes[$index];

        return $node->execute($operation);
    }
912720
public static PolygonExpression<Polygon> polygonOperation(Operator op, Expression<?>... args) {
        return new PolygonOperation<Polygon>(Polygon.class, op, args);
    }
100313
public function having($field, $op = null, $value = null) {
        return $this->_modifyPredicate($this->_having, Predicate::ALSO, $field, $op, $value);
    }
356829
public function mod($op)
  {
    $dst = clone $this;
    $op = $this->same($op, $this->prec)->truncate();
    if($op->eq(0)) throw new ArithmeticException(sprintf('Division by zero (%s)', json_encode($op)));
    $dst->value = $this->_fix($this->_mod($op));
    return $dst;
  }
349868
private function convertSet(SetOp $op)
    {
        $value  = [];
        $add    = $op->getAdds();
        $remove = $op->getRemoves();

        if ( ! empty($add)) {
            $value['add_all'] = $add;
        }

        if ( ! empty($remove)) {
            //$remove is always array so we need remove_all
            $value['remove_all'] = $remove;
        }

        return $value;
    }
155389
private function mapOperator($operator)
    {
        if (array_key_exists($operator, $this->shortOperators)) {
            $operator = $this->shortOperators[$operator];
        }

        if (!in_array($operator, $this->allowedOperators)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid operator `%s` given. Valid operators are %s.',
                $operator,
                implode(', ', $this->allowedOperators)
            ));
        }

        return $operator;
    }
1279976
function mod($data, $op = null) {
		if (!($this->data instanceof Expr)) {
			$this->data = new Expr($this->name);
		}
		
		if ($data instanceof Expr) {
			$this->data->add($data);
		} elseif (!isset($op) && is_numeric($data)) {
			$this->data->add(new Expr("+ $data"));
		} else {
			$this->data->add(new Expr("%s %s", isset($op) ? $op : "||", $data));
		}
		
		return $this;
	}
376846
private function beginBracket($op) {
        $this->currentWhere[] = [$op => []];
        $this->whereStack[] = &$this->currentWhere;
        end($this->currentWhere);
        $this->currentWhere = &$this->currentWhere[key($this->currentWhere)][$op];

        return $this;
    }
992336
public function having(string $query, array $queryParams = null, string $op = ''): self
    {
        if ($query instanceof Builder) {
            $query = $query->toString();
        }

        if ($queryParams != null) {
            $query = $this->agent->prepare($query, $queryParams);
        }

        // add and/or operator
        if (!empty($this->query['having'])) {
            $query = sprintf('%s %s', $op, $query);
        }

        return $this->push('having', $query);
    }
550166
public function orHaving($field, $op = null, $value = null) {
        return $this->_modifyPredicate($this->_having, Predicate::EITHER, $field, $op, $value);
    }
253128
public function whereId(string $field, $id, string $op = ''): self
    {
        return $this->where('?? = ?', [$field, $id], $op);
    }
1236837
public function orderBy($field, string $op = null): self
    {
        // check operator is valid
        if ($op == null) {
            return $this->push('orderBy', $this->prepareField($field));
        }

        $op = strtoupper($op);
        if ($op != self::OP_ASC && $op != self::OP_DESC) {
            throw new BuilderException('Available ops: ASC, DESC');
        }

        return $this->push('orderBy', $this->prepareField($field) .' '. $op);
    }
562811
public function createCollection($operator = Query::OP_AND)
    {
        $statement = new CollectionQuery();
        $statement->setOperator($operator);

        $this->add($statement);

        return $statement;
    }
579378
public function or_on($c1, $op, $c2)
	{
		$this->_on[] = array($c1, $op, $c2, 'OR');

		return $this;
	}
621867
public function aggregate(array $pipeline, array $op = [])
    {
        if (! TypeConverter::isNumericArray($pipeline)) {
            $operators = func_get_args();
            $pipeline = [];
            $options = [];

            $i = 0;
            foreach ($operators as $operator) {
                $i++;
                if (! is_array($operator)) {
                    trigger_error("Argument $i is not an array", E_USER_WARNING);
                    return;
                }

                $pipeline[] = $operator;
            }
        } else {
            $options = $op;
        }

        if (isset($options['cursor'])) {
            $options['useCursor'] = true;

            if (isset($options['cursor']['batchSize'])) {
                $options['batchSize'] = $options['cursor']['batchSize'];
            }

            unset($options['cursor']);
        } else {
            $options['useCursor'] = false;
        }

        try {
            $cursor = $this->collection->aggregate(TypeConverter::fromLegacy($pipeline), $options);

            return [
                'ok' => 1.0,
                'result' => TypeConverter::toLegacy($cursor),
                'waitedMS' => 0,
            ];
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e, 'MongoResultException');
        }
    }
1045053
public function addOperation(Operation $operation)
    {
        $this->operations[$operation->name] = $operation;
        ksort($this->operations);
    }