Returns distinct values of the property
@param  array $p Hash of properties (offset, limit, opts, key, col, where)
@param  callable $cb Callback called when response received
@callback $cb ( )
@return void
330264
public function distinct($p, $cb)
    {
        $this->_params($p);
        $e = explode('.', $p['col'], 2);

        $query = [
            'distinct' => $e[1],
            'key' => $p['key'],
        ];

        if (isset($p[$k = 'rp'])) {
            $v = $p[$k];
            if (is_string($v)) {
                $v = ['mode' => $v];
            }
            $query['$readPreference'] = $v;
        }

        if (isset($p['where'])) {
            $query['query'] = $p['where'];
        }
        $cb = CallbackWrapper::wrap($cb);
        $this->request(
            self::OP_QUERY,
            pack('V', $p['opts']) . $e[0] . '.$cmd' . "\x00"
            . pack('VV', $p['offset'], $p['limit']) . bson_encode($query)
            . (isset($p['fields']) ? bson_encode($p['fields']) : ''),
            true,
            null,
            function ($conn, $reqId = null) use ($p, $cb) {
                if (!$conn) {
                    !$cb || $cb(['$err' => 'Connection error.']);
                    return;
                }
                $conn->requests[$reqId] = [$p['col'], $cb, true];
            }
        );
    }
876282
public function findOne($p, $cb)
    {
        if (isset($p['cachekey'])) {
            $db = $this;
            $this->cache->get($p['cachekey'], function ($r) use ($db, $p, $cb) {
                if ($r->result !== null) {
                    $cb(bson_decode($r->result));
                } else {
                    unset($p['cachekey']);
                    $db->findOne($p, $cb);
                }
            });

            return;
        }
        if (!isset($p['where'])) {
            $p['where'] = [];
        }

        $this->_params($p);

        $o = [];
        $s = false;

        foreach ($p as $k => $v) {
            if (($k === 'sort') || ($k === 'hint') || ($k === 'explain') || ($k === 'snapshot')) {
                if (!$s) {
                    $s = true;
                }

                if ($k === 'sort') {
                    $o['orderby'] = $v;
                } elseif ($k === 'parse_oplog') {
                } elseif ($k === 'rp') {
                    $o['$readPreference'] = $v;
                } else {
                    $o[$k] = $v;
                }
            }
        }
        if (empty($o['orderby'])) {
            unset($o['orderby']);
        }

        if ($s) {
            $o['query'] = $p['where'];
        } else {
            $o = $p['where'];
        }
        $cb = CallbackWrapper::wrap($cb);
        if ($this->safeMode) {
            static::safeModeEnc($o);
        }
        try {
            $this->request(
                self::OP_QUERY,
                pack('V', $p['opts']) . $p['col'] . "\x00" . pack('VV', $p['offset'], -1)
                . bson_encode($o) . (isset($p['fields']) ? bson_encode($p['fields']) : ''),
                true,
                null,
                function ($conn, $reqId = null) use ($p, $cb) {
                    if (!$conn) {
                        !$cb || $cb(['$err' => 'Connection error.']);
                        return;
                    }
                    $conn->requests[$reqId] = [$p['col'], $cb, true];
                }
            );
        } catch (\MongoException $e) {
            Daemon::log('MongoClient exception: ' . $e->getMessage() . ': ' . $e->getTraceAsString());
            if ($cb !== null) {
                $cb([
                    '$err' => $e->getMessage(),
                    '$query' => $o,
                    '$fields' => isset($p['fields']) ? $p['fields'] : null
                ]);
            }
        }
    }
638264
protected function renderValueField($p_value)
    {
        self::$uniqid = self::$uniqid + 1;
        return [
            'id'    => ':i' . rand(10, 99) . '_' . self::$uniqid,
            'value' => $p_value,
            'type'  => false
        ];
    }
495034
public function uSort($cmp_function)
    {
        if (!is_callable($cmp_function)) {
            throw new \InvalidArgumentException(
                'Callback is not callable.',
                E_USER_ERROR
            );
        }

        return usort($this->storedData, $cmp_function);
    }
1001990
public function pluck($key, $unique = false)
    {
        $results = [];
        foreach ($this as $item) {
            $value = is_object($item) ? $item->$key : $item[$key];
            if ($unique) {
                $results[$value] = $value;
            } else {
                $results[] = $value;
            }
        }
        $collection = new static($results);
        return $collection->resetKeys();
    }
74102
public function map(callable $cb)
    {
        $count = count($this);
        $sfa = new SplFixedArray($count);
        for ($i = 0; $i < $count; $i++) {
            $sfa[$i] = $cb($this->sfa[$i], $i, $this);
        }
        return new static($sfa);
    }
1315166
public static function getFiltersSettings(Paragraph $p) {
    if ($p->field_prgf_repeat_schedule_filt->isEmpty()) {
      return [];
    }

    $filters = [];
    foreach ($p->field_prgf_repeat_schedule_filt->getValue() as $f) {
      $filters[$f['value']] = $f['value'];
    }

    return $filters;
  }
38359
public function setkey($key, $value, $cb = null)
    {
        $this->redis->set($this->config->redisprefix->value . $key, $value, $cb);
    }
837192
public static function load($pk){
    $table = static::persistenceOptions('table');
    $cb    = static::persistenceLoad();
    $op    = static::persistenceOptions();

    // Use standard persistence on DB layer
    return ( false == is_callable($cb) ) ?
      static::persistenceLoadDefault($pk,$table,$op) : $cb($pk,$table,$op);
  }
887747
public static function getByte(&$p)
    {
        $r = static::bytes2int($p{0});
        $p = mb_orig_substr($p, 1);
        return (int)$r;
    }
16969
protected function heapSort(callable $cb)
    {
        $h = new CallbackHeap($cb);
        foreach ($this as $el) {
            $h->insert($el);
        }

        return static::fromItems($h);
    }
943315
public function distinct($column = null)
    {
        if ($column) {
            $column = ['index' => $column];
        }

        $this->query = $this->query->distinct($column);

        return $this;
    }
1154266
def pks(self, limit=None, page=None):
        """"""
        self.fields_set.reset()
        return self.select_pk().values(limit, page)
4279
public function get($key = null, $cache_cb = null, &$cas_token = null)
    {

        if (isset($this->cacheListing [$key])) {
            return parent::get($key, $cache_cb, $cas_token);
        }

        return false;
    }
549412
public function distinct($key, $query = [])
    {
        if ($query instanceof Closure) {
            // Store the callback
            $callback = $query;

            // Create a new Where filter.
            $query = new Query\Where();

            // trigger callback
            $callback($query);
        }

        if ($query instanceof Query\Where) {
            // Get the filter.
            $query = $query->getWhere();
        }

        return $this->collection->distinct($key, $query);
    }
942380
public static function ensureUsableKey($p)
    {
        if (((gmp_cmp($p, 0)) == 0) || (gmp_cmp($p, Curve::generator()->getOrder()) >= 0)) {
            throw new \RuntimeException('The extended key at this index is invalid');
        }
    }
1192888
public function setnx($key, $value, $cb = null)
    {
        $this->redis->setnx($this->config->redisprefix->value . $key, $value, $cb);
    }