コード例 #1
0
class MongoTest(BaseTest, unittest.TestCase):
    '''Test the Mongo client'''
    def setUp(self):
        self.client = Client('mongo', 'testing', 6, 3, host='localhost',
                             weeks=3)

    def tearDown(self):
        self.client.delete()
コード例 #2
0
ファイル: bench.py プロジェクト: rlcyf/simhash-db-py
def query():
    '''Run the timing numbers for each of the provided seeds for query all'''
    seeds = make_seeds()
    client = Client(args.backend, args.name, args.num_blocks, args.num_bits,
        **kwargs)
    for i in range(1000):
        if i % 25 == 0:
            print 'Querying batch %i' % i
        # We want to get a relatively good mix each time we insert data
        hashes = [(start + i * interval) for start, interval in seeds]
        try:
            results = client.find_all(hashes)
        except GeneralException as exc:
            print '---> Client exception: %s' % repr(exc)
コード例 #3
0
ファイル: bench.py プロジェクト: rlcyf/simhash-db-py
def insert():
    '''Run the timing numbers for each of the provided seeds for insertion'''
    seeds = make_seeds()
    client = Client(args.backend, args.name, args.num_blocks, args.num_bits,
        **kwargs)
    for i in range(1000):
        if i % 25 == 0:
            print 'Inserting batch %i' % i
        # We want to get a relatively good mix each time we insert data
        hashes = [(start + i * interval) for start, interval in seeds]
        try:
            results = client.insert(hashes)
        except GeneralException as exc:
            print '---> Client exception: %s' % repr(exc)

    # Since this is meant to be run in a subprocess...
    exit(0)
コード例 #4
0
def find_duplicates(bithash_corpus, table_name, ntables, nmatchbits):

    try:
        redis_client = Client('redis', table_name, ntables, nmatchbits)
        redis_client.delete()
    except ConnectionError:
        print 'Connection error. Is redis running? Execute:\n>> redis-server'
        return -1

    # insert the first 20k documents
    redis_client.insert(bithash_corpus[:20000])

    # Find duplicates of the remaining ~2k documents
    dup_lists = redis_client.find_all(bithash_corpus[20001:])
    idxs_and_simhashs = [(20001 + idx, dup_lists[idx])
                         for idx, val in enumerate(dup_lists) if len(val) > 0]

    return idxs_and_simhashs
コード例 #5
0
ファイル: test_mongo.py プロジェクト: zanachka/simhash-db-py
 def make_client(self, name, num_blocks, num_bits):
     return Client('mongo', name, num_blocks, num_bits, ['localhost'])
コード例 #6
0
 def make_client(self, name, num_blocks, num_bits):
     return Client('cassandra', name, num_blocks, num_bits)
コード例 #7
0
 def make_client(self, name, num_blocks, num_bits):
     return Client('riak', name, num_blocks, num_bits)
コード例 #8
0
 def make_client(self, name, num_blocks, num_bits):
     return Client('hbase', name, num_blocks, num_bits, ['localhost'],
                   ttl=3600)
コード例 #9
0
 def setUp(self):
     self.client = Client('mongo', 'testing', 6, 3, host='localhost',
                          weeks=3)
コード例 #10
0
    def make_client(self, name, num_blocks, num_bits):

        return Client('es', name, num_blocks, num_bits,
                      hosts=['elasticsearch'])