Commit 43a399f3 authored by Romain Courteaud's avatar Romain Courteaud Committed by Sebastien Robin

Rename file.

parent b25c0dc8
import transaction import transaction
from cStringIO import StringIO from cStringIO import StringIO
from BTrees.IOBTree import IOBTree from BTrees.LOBTree import LOBTree
from persistent import Persistent
class PersistentString(persistent.Persistent): class PersistentString(Persistent):
def __init__(self, value): def __init__(self, value):
self.value = value self.value = value
def __str__(self): def __str__(self):
return self.value return self.value
class BTreeData2(persistent.Persistent): class BTreeData(Persistent):
def __init__(self): def __init__(self):
self.tree = IOBTree() self.tree = LOBTree()
def write(self, buf, offset): def write(self, buf, offset):
# TODO: auto-aggregation of continuous keys when overwriting # TODO: auto-aggregation of continuous keys when overwriting
offset = int(offset) # offset = long(offset)
assert not isinstance(offset, long), 'Offset is too big for int ' \ # assert not isinstance(offset, long), 'Offset is too big for int ' \
'type: %s' % (offset, ) # 'type: %s' % (offset, )
tree = self.tree tree = self.tree
buf_len = len(buf) buf_len = len(buf)
try: try:
...@@ -60,9 +61,10 @@ class BTreeData2(persistent.Persistent): ...@@ -60,9 +61,10 @@ class BTreeData2(persistent.Persistent):
def read(self, offset, size): def read(self, offset, size):
#print 'read', hex(offset), hex(size) #print 'read', hex(offset), hex(size)
start_offset = offset = int(offset) start_offset = offset
assert not isinstance(offset, long), 'Offset is too big for int ' \ # start_offset = offset = int(offset)
'type: %s' % (offset, ) # assert not isinstance(offset, long), 'Offset is too big for int ' \
# 'type: %s' % (offset, )
tree = self.tree tree = self.tree
result = StringIO() result = StringIO()
write = result.write write = result.write
...@@ -96,9 +98,9 @@ class BTreeData2(persistent.Persistent): ...@@ -96,9 +98,9 @@ class BTreeData2(persistent.Persistent):
return result.getvalue() return result.getvalue()
def truncate(self, offset): def truncate(self, offset):
offset = int(offset) # offset = int(offset)
assert not isinstance(offset, long), 'Offset is too big for int ' \ # assert not isinstance(offset, long), 'Offset is too big for int ' \
'type: %s' % (offset, ) # 'type: %s' % (offset, )
tree = self.tree tree = self.tree
try: try:
key = tree.maxKey(offset) key = tree.maxKey(offset)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment