Exemplo n.º 1
0
    def test_frequency_table_import_export_destination_estimators(self):
        client = self.db.cluster.get_local_client_for_key("key")

        parameters = [64, 5, 5]

        CountMinScript(
            ["1:i", "1:e"],
            ["INCR"] + parameters + [
                1,
                "alpha",
                2,
                "beta",
                3,
                "gamma",
                4,
                "delta",
                5,
                "epsilon",
                6,
                "zeta",
                7,
                "eta",
                8,
                "theta",
                9,
                "iota",
            ],
            client=client,
        )

        CountMinScript(["2:i", "2:e"],
                       ["INCR"] + parameters + [5, "foo", 7, "bar", 9, "baz"],
                       client=client)

        assert client.exists("1:i")
        assert client.exists("1:e")
        assert client.exists("2:i")
        assert not client.exists("2:e")

        exports = CountMinScript(["2:i", "2:e"], ["EXPORT"] + parameters,
                                 client=client)

        assert len(exports) == 1

        CountMinScript(["1:i", "1:e"], ["IMPORT"] + parameters + [exports[0]],
                       client=client)

        assert client.exists("1:i")
        assert client.exists("1:e")

        assert CountMinScript(["1:i", "1:e"], ["RANKED"] + parameters,
                              client=client) == [
                                  [b"iota", b"9"],
                                  [b"baz", b"9"],
                                  [b"theta", b"8"],
                                  [b"eta", b"7"],
                                  [b"bar", b"7"],
                              ]
Exemplo n.º 2
0
    def test_frequency_table_import_export_no_estimators(self):
        client = self.db.cluster.get_local_client_for_key('key')

        parameters = [64, 5, 10]

        CountMinScript(
            ['1:i', '1:e'],
            ['INCR'] + parameters + [
                1, 'foo',
                2, 'bar',
                3, 'baz',
            ],
            client=client,
        )

        CountMinScript(
            ['2:i', '2:e'],
            ['INCR'] + parameters + [
                1, 'alpha',
                2, 'beta',
                3, 'gamma',
                4, 'delta',
                5, 'epsilon',
                6, 'zeta',
                7, 'eta',
                8, 'theta',
                9, 'iota',
            ],
            client=client,
        )

        assert client.exists('1:i')
        assert not client.exists('1:e')
        assert client.exists('2:i')
        assert not client.exists('2:e')

        exports = CountMinScript(
            ['2:i', '2:e'],
            ['EXPORT'] + parameters,
            client=client,
        )

        assert len(exports) == 1

        CountMinScript(
            ['1:i', '1:e'],
            ['IMPORT'] + parameters + [exports[0]],
            client=client,
        )

        assert client.exists('1:i')
        assert client.exists('1:e')