Ejemplo n.º 1
0
    def setup(self, request, as_connection):
        self.test_ns = 'test'
        self.test_set = 'demo'

        HLL_ops = [
            hll_operations.hll_add('hll_bin',
                                   ['key%s' % str(i) for i in range(10000)],
                                   15, 49),
            hll_operations.hll_add(
                'hll_bin2', ['key%s' % str(i) for i in range(5000, 15000)], 15,
                49),
            hll_operations.hll_add(
                'hll_bin3', ['key%s' % str(i) for i in range(20000, 30000)],
                15, 49)
        ]

        for i in range(_NUM_RECORDS):
            _, _, _ = self.as_connection.operate(
                (self.test_ns, self.test_set, i), HLL_ops)

        def teardown():
            for i in range(_NUM_RECORDS):
                key = (self.test_ns, self.test_set, i)
                as_connection.remove(key)

        request.addfinalizer(teardown)
    def test_neg_hll_add(self, policy, expected_result):
        """
        Invoke hll_add() creating with expected failures.
        """
        ops = [
            hll_operations.hll_add('new_bin', ['key1', 'key2', 'key3'], index_bit_count=8, policy=policy)
        ]

        with pytest.raises(expected_result):
            self.as_connection.operate(self.test_keys[0], ops)
    def test_neg_hll_update(self, bin, policy, expected_result):
        """
        Invoke hll_update() with errors.
        """
        ops = [
            hll_operations.hll_add(bin, ['key1', 'key2', 'key3'], policy=policy)
        ]

        with pytest.raises(expected_result):
            self.as_connection.operate(self.test_keys[0], ops, policy)
    def test_neg_hll_add_mh(self, policy, expected_result):
        """
        Invoke hll_add() failing to creating a new min hash HLL.
        """
        ops = [
            hll_operations.hll_add('hll_binl', ['key101', 'key102', 'key103'], 6, 8, policy)
        ]

        with pytest.raises(expected_result):
            self.as_connection.operate(self.test_keys[0], ops)
    def test_pos_hll_add(self, policy, expected_result):
        """
        Invoke hll_add() creating a new HLL.
        """
        ops = [
            hll_operations.hll_add('new_bin', ['key1', 'key2', 'key3'], index_bit_count=8, policy=policy)
        ]

        _, _, res = self.as_connection.operate(self.test_keys[0], ops)

        assert res['new_bin'] == expected_result
    def test_pos_hll_update(self):
        """
        Invoke hll_update() creating a new HLL.
        """
        ops = [
            hll_operations.hll_add('hll_bine', ['key1', 'key2', 'key3'])
        ]

        _, _, res = self.as_connection.operate(self.test_keys[0], ops)

        assert res['hll_bine'] == 3
    def test_pos_hll_add_mh(self):
        """
        Invoke hll_add() creating a new min hash HLL.
        """
        ops = [
            hll_operations.hll_add('new_bin', ['key1', 'key2', 'key3'], 6, 8)
        ]

        _, _, res = self.as_connection.operate(self.test_keys[0], ops)

        assert res['new_bin'] == 3
Ejemplo n.º 8
0
def ingest_month(client, start, end, month):
    # We don't need to initialise HLL bins; performing a HLL add to an empty bin will initialise it.
    print "Ingest ids %d-%d month %d" % (start, end, month)

    for i in range(start, end):
        profile = generator.get_profile(i, month)
        # print("Profile %d: %s" % (i, profile))
        for tag in profile:
            ops = [hll_operations.hll_add(HLL_BIN, [str(i)], HLL_INDEX_BITS)]

            _, _, result = client.operate(getkey(tag, month), ops)
    def setup(self, request, as_connection):
        self.test_keys = []
        for x in range(5):

            key = ('test', 'demo', x)
            record = {'label': x}

            as_connection.put(key, record)

            ops = [
                hll_operations.hll_init('hll_bine', 10),
                hll_operations.hll_add('hll_bin', ['key%s' % str(i) for i in range(x + 1)], 8),
                hll_operations.hll_add('mh_bin', ['key%s' % str(i) for i in range(x + 1)], 6, 12),
                hll_operations.hll_add('hll_binl', ['key%s' % str(i) for i in range(100)], 8),
                hll_operations.hll_add('hll_binlh', ['key%s' % str(i) for i in range(50)], 8),
                hll_operations.hll_add('hll_bin_big', ['key%s' % str(i) for i in range(1000)], 10),
                hll_operations.hll_add('hll_binu', ['key6', 'key7', 'key8', 'key9', 'key10'], 10),
            ]

            self.test_keys.append(key)
            _, _, _ = as_connection.operate(key, ops)

        def teardown():
            """
            Teardown method.
            """
            for key in self.test_keys:
                try:
                    as_connection.remove(key)
                except e.RecordNotFound:
                    pass

        request.addfinalizer(teardown)