예제 #1
0
def run(path, tid):
    f = open(path, "rb")
    f.seek(0, 2)

    th = prev_txn(f)
    while (str(TimeStamp(th.tid)) != tid):
        th = th.prev_txn()

    reader = Reader()
    iterator = FileIterator(path, pos=th._pos)
    header = TxnHeader(f, th._pos)
    for i in iterator:
        if (str(TimeStamp(i.tid)) == tid):
            print "\nTRANSACTION: ", TimeStamp(
                i.tid), i.user, i.description, pretty_size(header.length), "\n"
            header = header.next_txn()
            object_types = {}
            for o in i:
                ot = reader.getIdentity(o.data)
                print " - ", ot, pretty_size(len(o.data))
                ob = cPickle.loads(o.data)
                # Not sure why some objects are stored as tuple (object, ())
                if type(ob) == tuple and len(ob) == 2:
                    ob = ob[0]
                if hasattr(ob, "__dict__"):
                    for i in ob.__dict__.items():
                        if str(i[0]) == "__doc__":
                            print "\t('__doc__',", i[1], ")"
                        elif not callable(i[1]):
                            print "\t", i
                else:
                    print "can't extract:" + str(ob)
            break
    f.close()
예제 #2
0
def run(path, tid):
    f = open(path, "rb")
    f.seek(0, 2)

    th = prev_txn(f)
    while (str(TimeStamp(th.tid)) != tid):
        th = th.prev_txn()

    reader = Reader()
    iterator = FileIterator(path, pos=th._pos)
    header = TxnHeader(f,th._pos)
    for i in iterator:
        if(str(TimeStamp(i.tid)) == tid):
            print "\nTRANSACTION: ", TimeStamp(i.tid), i.user, i.description, pretty_size(header.length),"\n"
            header = header.next_txn()
            object_types = {}
            for o in i:
                ot = reader.getIdentity(o.data)
                print " - ", ot, pretty_size(len(o.data))
                ob = cPickle.loads(o.data)
                # Not sure why some objects are stored as tuple (object, ())
                if type(ob) == tuple and len(ob) == 2:
                    ob = ob[0]
                if hasattr(ob, "__dict__"):
                    for i in ob.__dict__.items():
                        if str(i[0]) == "__doc__":
                            print "\t('__doc__',", i[1],")"
                        elif not callable(i[1]):
                            print "\t",i
                else:
                    print "can't extract:" + str(ob)
            break
    f.close()
예제 #3
0
def run(path, ntxn, orderTransactions):
    f = open(path, "rb")
    f.seek(0, 2)

    th = prev_txn(f)
    for i in range(ntxn - 1):
        th = th.prev_txn()

    reader = Reader()
    iterator = FileIterator(path, pos=th._pos)
    header = TxnHeader(f, th._pos)
    transactions = []

    for i in iterator:
        transactions.append({
            "tid": TimeStamp(i.tid),
            "user": i.user,
            "desc": i.description,
            "len": header.length,
            "objs": None
        })

        header = header.next_txn()

        object_types = {}
        for o in i:
            ot = reader.getIdentity(o.data)
            if ot in object_types:
                size, count = object_types[ot]
                object_types[ot] = (size + len(o.data), count + 1)
            else:
                object_types[ot] = (len(o.data), 1)

        keys = object_types.keys()
        transactions[-1]["objs"] = object_types

    f.close()
    if orderTransactions:
        transactions = sorted(transactions,
                              key=lambda (d): d["len"],
                              reverse=True)
    for tr in transactions:
        print "\n\nTRANSACTION: ", tr["tid"], tr["user"], tr[
            "desc"], pretty_size(tr["len"])
        object_types = tr["objs"]
        keys = object_types.keys()
        for k in sorted(keys, key=lambda (k): object_types[k][0],
                        reverse=True):
            # count, class, size (aggregate)
            print " - ", object_types[k][1], k, pretty_size(object_types[k][0])
예제 #4
0
def run(path, ntxn, orderTransactions):
    f = open(path, "rb")
    f.seek(0, 2)

    th = prev_txn(f)
    for i in range(ntxn - 1):
        th = th.prev_txn()

    reader = Reader()
    iterator = FileIterator(path, pos=th._pos)
    header = TxnHeader(f, th._pos)
    transactions = []

    for i in iterator:
        transactions.append(
            {"tid": TimeStamp(i.tid), "user": i.user, "desc": i.description, "len": header.length, "objs": None}
        )

        header = header.next_txn()

        object_types = {}
        for o in i:
            ot = reader.getIdentity(o.data)
            if ot in object_types:
                size, count = object_types[ot]
                object_types[ot] = (size + len(o.data), count + 1)
            else:
                object_types[ot] = (len(o.data), 1)

        keys = object_types.keys()
        transactions[-1]["objs"] = object_types

    f.close()
    if orderTransactions:
        transactions = sorted(transactions, key=lambda (d): d["len"], reverse=True)
    for tr in transactions:
        print "\n\nTRANSACTION: ", tr["tid"], tr["user"], tr["desc"], pretty_size(tr["len"])
        object_types = tr["objs"]
        keys = object_types.keys()
        for k in sorted(keys, key=lambda (k): object_types[k][0], reverse=True):
            # count, class, size (aggregate)
            print " - ", object_types[k][1], k, pretty_size(object_types[k][0])