示例#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
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
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
 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)
    def make_client(self, name, num_blocks, num_bits):

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