Browse Source

Add basic versioning to bulkdata table format file.

tags/nilmdb-0.1
Jim Paris 11 years ago
parent
commit
d321058b48
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      nilmdb/bulkdata.py

+ 7
- 1
nilmdb/bulkdata.py View File

@@ -184,7 +184,8 @@ class Table(object):

format = { "rows_per_file": rows_per_file,
"files_per_dir": files_per_dir,
"struct_fmt": struct_fmt }
"struct_fmt": struct_fmt,
"version": 1 }
with open(os.path.join(root, "_format"), "wb") as f:
pickle.dump(format, f, 2)

@@ -196,6 +197,11 @@ class Table(object):
# Load the format and build packer
with open(os.path.join(self.root, "_format"), "rb") as f:
format = pickle.load(f)

if format["version"] != 1: # pragma: no cover (just future proofing)
raise NotImplementedError("version " + format["version"] +
" bulk data store not supported")

self.rows_per_file = format["rows_per_file"]
self.files_per_dir = format["files_per_dir"]
self.packer = struct.Struct(format["struct_fmt"])


Loading…
Cancel
Save