本文整理汇总了Python中transaction.Transaction.load方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.load方法的具体用法?Python Transaction.load怎么用?Python Transaction.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transaction.Transaction
的用法示例。
在下文中一共展示了Transaction.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_current
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import load [as 别名]
def get_current(self):
trans = self.find_new_transactions()
for i in trans:
t = Transaction.load(self.data_path, i)
try:
self.commit_transaction(t, is_replay=True)
except:
import traceback
traceback.print_exc()
print 'Failed Commit: %s' % t
self.revision += len(trans)
return len(trans)
示例2: collect_statements_for
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import load [as 别名]
def collect_statements_for(self, key, previous_rev, future_rev):
statements = []
cur = [self.get_revision(key, future_rev)]
running = 1
while running:
for doc in cur:
if doc.hashed_data() == previous_rev:
running = 0
break;
else:
t = Transaction.load(self.data_path, doc.result_of)
for s in t.statements:
if key == s.target_key:
statements.append(s)
new_cur = []
for doc in cur:
for par in self.get_parents(doc):
new_cur.append(par)
cur = new_cur
statements.reverse()
return statements
示例3: compact
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import load [as 别名]
def compact(self):
data = []
count = 0
f = open(self.data_path + "/compact/%i" % (self.revision), 'w')
for i in self.transactions:
if Transaction.exists(self.data_path, i):
i = Transaction.load(self.data_path, i)
f.write("begin %s\n" % i.path())
for j in i.statements:
f.write(j.as_json() + '\n')
os.remove(self.data_path + "/transaction/%s" % i.path())
f.close()
f = open(self.data_path + "/checkpoints/%i" % self.revision, 'w')
for i in self:
for j in i:
f.write( json.dumps([j.key, j.get_data()]) + "\n")
subdir = j.hashed_key()[:2]
all_revs = self.get_all_parent_revs(j)
for rev in all_revs:
if os.path.exists(self.data_path + "/data/%s/%s_%s" % (subdir, j.hashed_key(), rev)):
os.remove(self.data_path + "/data/%s/%s_%s" % (subdir, j.hashed_key(), rev))
f.close()