Skip to content
Snippets Groups Projects
Commit 68bbc105 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

add sync

parent 74bf22f4
No related branches found
No related tags found
No related merge requests found
# coding: utf-8
[metadata]
name = tempsdb
version = 0.6.4a3
version = 0.6.4a6
long-description = file: README.md
long-description-content-type = text/markdown; charset=UTF-8
license_files = LICENSE
......
......@@ -32,6 +32,7 @@ cdef class TimeSeries:
cdef void decref_chunk(self, unsigned long long name)
cdef Chunk open_chunk(self, unsigned long long name, bint is_direct, bint is_gzip)
cdef int sync_metadata(self) except -1
cpdef int sync(self) except -1
cpdef int mark_synced_up_to(self, unsigned long long timestamp) except -1
cpdef int append(self, unsigned long long timestamp, bytes data) except -1
cpdef int append_padded(self, unsigned long long timestamp, bytes data) except -1
......
......@@ -267,6 +267,13 @@ cdef class TimeSeries:
pass
return 0
cpdef int sync(self) except -1:
"""
Make sure that all data written up to this point is persisted on disk.
"""
self.last_chunk.sync()
return 0
cpdef int close(self) except -1:
"""
Close the series.
......
......@@ -568,6 +568,16 @@ cdef class VarlenSeries:
self.current_maximum_length = tot_length
cpdef int sync(self) except -1:
"""
Make sure that all data written up to this point is persisted on disk.
"""
self.root_series.sync()
cdef TimeSeries series
for series in self.series:
series.sync()
return 0
cpdef int enable_mmap(self) except -1:
"""
Enable using mmap for these series
......
......@@ -30,6 +30,7 @@ class TestSeries(unittest.TestCase):
for i in range(0, 16000):
series.append(i, b'\x00'*10)
series.sync()
series.close()
series = TimeSeries('test8', 'test8')
series.trim(4000)
......
......@@ -14,7 +14,7 @@ class TestVarlen(unittest.TestCase):
varlen.append(*series[1])
self.assertEqual(len(os.listdir('test_dir')), 3)
varlen.sync()
it = varlen.iterate_range(0, 20)
lst = [(ts, v.to_bytes()) for ts, v in it]
it.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment