def create_compound_file(self, storage): segfiles = self.list_files(storage) assert not any(name.endswith(self.COMPOUND_EXT) for name in segfiles) cfile = self.create_file(storage, self.COMPOUND_EXT) CompoundStorage.assemble(cfile, storage, segfiles) for name in segfiles: storage.delete_file(name)
def _test_simple_compound(st): alist = [1, 2, 3, 5, -5, -4, -3, -2] blist = [1, 12, 67, 8, 2, 1023] clist = [100, -100, 200, -200] with st.create_file("a") as af: for x in alist: af.write_int(x) with st.create_file("b") as bf: for x in blist: bf.write_varint(x) with st.create_file("c") as cf: for x in clist: cf.write_int(x) f = st.create_file("f") CompoundStorage.assemble(f, st, ["a", "b", "c"]) f = CompoundStorage(st, "f") with f.open_file("a") as af: for x in alist: assert_equal(x, af.read_int()) assert_equal(af.read(), b('')) with f.open_file("b") as bf: for x in blist: assert_equal(x, bf.read_varint()) assert_equal(bf.read(), b('')) with f.open_file("c") as cf: for x in clist: assert_equal(x, cf.read_int()) assert_equal(cf.read(), b(''))
def _test_simple_compound(st): alist = [1, 2, 3, 5, -5, -4, -3, -2] blist = [1, 12, 67, 8, 2, 1023] clist = [100, -100, 200, -200] with st.create_file("a") as af: for x in alist: af.write_int(x) with st.create_file("b") as bf: for x in blist: bf.write_varint(x) with st.create_file("c") as cf: for x in clist: cf.write_int(x) f = st.create_file("f") CompoundStorage.assemble(f, st, ["a", "b", "c"]) f = CompoundStorage(st.open_file("f")) with f.open_file("a") as af: for x in alist: assert x == af.read_int() assert af.read() == b('') with f.open_file("b") as bf: for x in blist: assert x == bf.read_varint() assert bf.read() == b('') with f.open_file("c") as cf: for x in clist: assert x == cf.read_int() assert cf.read() == b('')
def open_compound_file(self, storage): name = self.make_filename(self.COMPOUND_EXT) dbfile = storage.open_file(name) return CompoundStorage(dbfile, use_mmap=storage.supports_mmap)
def open_compound_file(self, storage): name = self.make_filename(self.COMPOUND_EXT) return CompoundStorage(storage, name)