def __path2index(self, path):
        if not hasattr(self, '__path_cache'):
            self.__path_cache = {}
            for x in xrange(len(self._specs)):
                spec = self._specs[x]
                self.__path_cache[spec[1]] = x

        return self.__path_cache[path]
Exemple #2
0
    def __path2index(self, path):
        if not hasattr(self, '__path_cache'):
            self.__path_cache = {}
            for x in xrange(len(self._specs)):
                spec = self._specs[x]
                self.__path_cache[spec[1]] = x

        return self.__path_cache[path]
    def test_long_uri(self):
        qobj = Query()
        qobj.mapkey_multi = [ str(x) for x in xrange(MAX_URI_LENGTH) ]
        ret = self.cb.query("beer", "brewery_beers", query=qobj)
        # No assertions, just make sure it didn't break
        for row in ret:
            raise Exception("...")

        # Apparently only the "keys" parameter is supposed to be in POST.
        # Let's fetch 100 items now
        keys = [r.key for r in self.cb.query("beer", "brewery_beers", limit=100)]
        self.assertEqual(100, len(keys))

        kslice = keys[90:]
        self.assertEqual(10, len(kslice))
        rows = [x for x in self.cb.query("beer", "brewery_beers", mapkey_multi=kslice, limit=5)]
        self.assertEqual(5, len(rows))
        for row in rows:
            self.assertTrue(row.key in kslice)
    def _mutinfo(self):
        pp = ffi.new('void**')
        kb = ffi.new('lcb_KEYBUF*')

        rc = C.lcb_cntl(self._lcbh, C.LCB_CNTL_GET, C.LCB_CNTL_VBCONFIG, pp)
        if rc:
            pycbc_exc_lcb(rc, "Couldn't get vBucket config")
        nvb = C.vbucket_config_get_num_vbuckets(pp[0])
        ll = []
        kb.type = C.LCB_KV_VBID

        for vbid in xrange(nvb):
            kb.contig.nbytes = vbid
            mt = C.lcb_get_mutation_token(self._lcbh, kb, ffi.NULL)
            if not mt:
                continue
            ll.append((C.CBFFI_mt_vb(mt), C.CBFFI_mt_uuid(mt), C.CBFFI_mt_seq(mt)))

        return ll
Exemple #5
0
    def test_long_uri(self):
        qobj = Query()
        qobj.mapkey_multi = [ str(x) for x in xrange(MAX_URI_LENGTH) ]
        ret = self.cb.query("beer", "brewery_beers", query=qobj)
        # No assertions, just make sure it didn't break
        for row in ret:
            raise Exception("...")

        # Apparently only the "keys" parameter is supposed to be in POST.
        # Let's fetch 100 items now
        keys = [r.key for r in self.cb.query("beer", "brewery_beers", limit=100)]
        self.assertEqual(100, len(keys))

        kslice = keys[90:]
        self.assertEqual(10, len(kslice))
        rows = [x for x in self.cb.query("beer", "brewery_beers", mapkey_multi=kslice, limit=5)]
        self.assertEqual(5, len(rows))
        for row in rows:
            self.assertTrue(row.key in kslice)
    def submit_single(self, c_key, c_len, value, item, key_options, global_options, mres):
        if item:
            raise ArgumentError.pyexc('Item not allowed for subdoc')

        # Allocate the subdoc array
        if not isinstance(value, tuple):
            raise ArgumentError.pyexc('Value must be a tuple!')
        if not len(value):
            raise ArgumentError.pyexc('Need one or more commands')

        speclist = ffi.new('lcb_SDSPEC[{0}]'.format(len(value)))

        self.c_command.specs = speclist
        self.c_command.nspecs = len(value)
        self.c_command.cas = get_cas(key_options, global_options, item)
        C.CBFFI_set_key(self.c_command, c_key, c_len)

        bm = BufManager(ffi)

        for i in xrange(len(speclist)):
            pyspec = value[i]
            cspec = speclist + i
            self._process_spec(pyspec, cspec, bm)
        return C.lcb_subdoc3(self.instance, mres._cdata, self.c_command)