Example #1
0
def db_pair_test():
    print 'create database with capacity 100000 test is started..\n'
    open(os.getcwd() + '/storage/student.txt', 'wb').close()
    db = Table(filename=os.getcwd() + '/storage/student.txt',
               type=student,
               index_attrs=['name'],
               key_sizes=[26])
    # studs = get_shuffled_dataset()

    print('loading dataset')
    pairs = []
    size = 1000
    for i in range(size):
        p = pair(id=i, id1=i, id2=i)
        pairs.append(p)
    i = 0
    for p in pairs:
        with Profiler() as p:
            db.put(p.get_key(), p)
            i += 1
            if i % 50 == 0:
                print('#', i)
    # print(db.get('581200', 1))
    # print(db.trees['name']['Matthew Cervantes'])
    db.save()
Example #2
0
def db_test():
    print 'create database with capacity 100000 test is started..\n'
    open(os.getcwd() + '/storage/student.txt', 'wb').close()
    open(os.getcwd() + '/times.txt', 'wb').close()
    db = Table(filename=os.getcwd() + '/storage/student.txt',
               type=student,
               index_attrs=['name'],
               key_sizes=[26])
    # studs = get_shuffled_dataset()

    print('loading dataset')
    studs = get_shuffled_million()
    i = 0
    for stud in studs[:10000]:
        with Profiler() as p:
            db.put(stud.get_key(), stud)
            i += 1
            if i % 50 == 0:
                print('#', i)
    db.b_index()
    for index in db.index_attrs:
        tree = db.trees[index]
    # print(db.get('581200', 1))
    # print(db.trees['name']['Matthew Cervantes'])
    db.save()
Example #3
0
def db_pair_test():
    print 'create database with capacity 100000 test is started..\n'
    open(os.getcwd() + '/storage/student.txt', 'wb').close()
    db = Table(filename=os.getcwd() + '/storage/student.txt', type=student, index_attrs=['name'], key_sizes=[26])
    # studs = get_shuffled_dataset()

    print('loading dataset')
    pairs = []
    size = 1000
    for i in range(size):
        p = pair(id = i, id1 = i, id2 = i)
        pairs.append(p)
    i = 0
    for p in pairs:
        with Profiler() as p:
            db.put(p.get_key(), p)
            i += 1
            if i % 50 == 0:
                print('#', i)
    # print(db.get('581200', 1))
    # print(db.trees['name']['Matthew Cervantes'])
    db.save()
Example #4
0
def db_test():
    print 'create database with capacity 100000 test is started..\n'
    open(os.getcwd() + '/storage/student.txt', 'wb').close()
    open(os.getcwd() + '/times.txt', 'wb').close()
    db = Table(filename=os.getcwd() + '/storage/student.txt', type=student, index_attrs=['name'], key_sizes=[26])
    # studs = get_shuffled_dataset()

    print('loading dataset')
    studs = get_shuffled_million()
    i = 0
    for stud in studs[:10000]:
        with Profiler() as p:
            db.put(stud.get_key(), stud)
            i += 1
            if i % 50 == 0:
                print('#', i)
    db.b_index()
    for index in db.index_attrs:
        tree = db.trees[index]
    # print(db.get('581200', 1))
    # print(db.trees['name']['Matthew Cervantes'])
    db.save()
Example #5
0
def load_author_names():
    conn = psycopg2.connect(
        "dbname='citadel' user='******' host='localhost' password=''")
    cur = conn.cursor()
    cur.execute("select * from author_names")
    rows = cur.fetchall()
    print("\nShow me the databases:\n")
    from relations.edges import edge
    open(os.getcwd() + '/storage/edge.txt', 'wb').close()
    db = Table(filename=os.getcwd() + '/storage/author_names.txt',
               type=edge,
               index_attrs=['name'],
               key_sizes=[26])
    i = 1
    for row in rows:
        el = author_name(id=row[0], name=row[1])
        db.put(el.get_key(), el)
        i += 1
        if i % 1000 == 0:
            print("i=", i)
    print("storing records is done, b_index started..")
    db.b_index()
    db.save()
    print("database created and saved")