def load(cls, io, iosize): # read fileheader fileheader = FileHeaderSerializer.deserialize(io.read(length=FileHeaderSerializer.SERIALIZED_LENGTH)) txchunk_file = TransactionalChunkFile.load(io, iosize) outpoint_io = TransactionalIO.from_chunkname(txchunk_file, OUTPOINTS_NAME) outpoint_dict = SerializedDict.load(outpoint_io, outpoint_io.size, serializer=OutpointIndexSerializer) return cls(fileheader, txchunk_file, outpoint_dict)
def load(cls, io, iosize): # read fileheader fileheader = FileHeaderSerializer.deserialize( io.read(length=FileHeaderSerializer.SERIALIZED_LENGTH)) txchunk_file = TransactionalChunkFile.load(io, iosize) outpoint_io = TransactionalIO.from_chunkname(txchunk_file, OUTPOINTS_NAME) outpoint_dict = SerializedDict.load(outpoint_io, outpoint_io.size, serializer=OutpointIndexSerializer) return cls(fileheader, txchunk_file, outpoint_dict)
def new(cls, io, fileheader=FileHeader(), INDEX_COUNT=50, BUFFER_SIZE=10000, OUTPOINTS_SIZE=1000): fileheader = io.write(data=FileHeaderSerializer.serialize(fileheader)) txchunk_file = TransactionalChunkFile.new(io, INDEX_COUNT=INDEX_COUNT, BUFFER_SIZE=BUFFER_SIZE) chunkfile = txchunk_file.chunkfile # Appending/format other chunks (Not done transactionally) chunkfile.append_chunk( OUTPOINTS_NAME, OUTPOINTS_SIZE ) outpointsio = ChunkIO.from_name(chunkfile, OUTPOINTS_NAME) outpoint_dict = SerializedDict.new(outpointsio, outpointsio.size, serializer=OutpointIndexSerializer) # re-open them transactionally outpoint_io = TransactionalIO.from_chunkname(txchunk_file, OUTPOINTS_NAME) outpoint_dict = SerializedDict.load(outpoint_io, OUTPOINTS_SIZE, OutpointIndexSerializer) return cls(fileheader, txchunk_file, outpoint_dict)
def new(cls, io, fileheader=FileHeader(), INDEX_COUNT=50, BUFFER_SIZE=10000, OUTPOINTS_SIZE=1000): fileheader = io.write(data=FileHeaderSerializer.serialize(fileheader)) txchunk_file = TransactionalChunkFile.new(io, INDEX_COUNT=INDEX_COUNT, BUFFER_SIZE=BUFFER_SIZE) chunkfile = txchunk_file.chunkfile # Appending/format other chunks (Not done transactionally) chunkfile.append_chunk(OUTPOINTS_NAME, OUTPOINTS_SIZE) outpointsio = ChunkIO.from_name(chunkfile, OUTPOINTS_NAME) outpoint_dict = SerializedDict.new(outpointsio, outpointsio.size, serializer=OutpointIndexSerializer) # re-open them transactionally outpoint_io = TransactionalIO.from_chunkname(txchunk_file, OUTPOINTS_NAME) outpoint_dict = SerializedDict.load(outpoint_io, OUTPOINTS_SIZE, OutpointIndexSerializer) return cls(fileheader, txchunk_file, outpoint_dict)