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

refactor the code

parent ec969ace
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ if 'CI' in os.environ: ...@@ -28,7 +28,7 @@ if 'CI' in os.environ:
setup(name='tempsdb', setup(name='tempsdb',
version='0.5a1', version='0.5a2',
packages=['tempsdb'], packages=['tempsdb'],
install_requires=['satella>=2.14.24', 'ujson'], install_requires=['satella>=2.14.24', 'ujson'],
ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb')), ], ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb')), ],
......
...@@ -140,8 +140,8 @@ cdef class Chunk: ...@@ -140,8 +140,8 @@ cdef class Chunk:
cdef int decref(self) except -1: cdef int decref(self) except -1:
if self.parent is not None: if self.parent is not None:
self.parent.decref_chunk(self.min_ts) self.parent.decref_chunk(self.name())
if self.parent.refs_chunks[self.name()] < 0: if self.parent.get_references_for(self.name()) < 0:
raise ValueError('reference of chunk fell below zero!') raise ValueError('reference of chunk fell below zero!')
return 0 return 0
...@@ -407,7 +407,7 @@ cdef class Chunk: ...@@ -407,7 +407,7 @@ cdef class Chunk:
cdef unsigned long long name = self.name() cdef unsigned long long name = self.name()
if self.parent: if self.parent:
with self.parent.open_lock: with self.parent.open_lock:
if not force and self.parent.refs_chunks.get(name, 0) > 0: if not force and self.parent.get_references_for(name) > 0:
raise StillOpen('this chunk is opened') raise StillOpen('this chunk is opened')
del self.parent.refs_chunks[name] del self.parent.refs_chunks[name]
del self.parent.open_chunks[name] del self.parent.open_chunks[name]
......
...@@ -204,7 +204,7 @@ cdef class TimeSeries: ...@@ -204,7 +204,7 @@ cdef class TimeSeries:
while len(self.chunks) >= 2 and timestamp > self.chunks[1]: while len(self.chunks) >= 2 and timestamp > self.chunks[1]:
chunk_to_delete = self.chunks[0] chunk_to_delete = self.chunks[0]
if chunk_to_delete in self.open_chunks: if chunk_to_delete in self.open_chunks:
refs = self.refs_chunks.get(chunk_to_delete, 0) refs = self.get_references_for(chunk_to_delete)
if not refs: if not refs:
self.open_chunks[chunk_to_delete].delete() self.open_chunks[chunk_to_delete].delete()
else: else:
...@@ -378,7 +378,7 @@ cdef class TimeSeries: ...@@ -378,7 +378,7 @@ cdef class TimeSeries:
for chunk_name in chunks: for chunk_name in chunks:
if chunk_name == last_chunk_name: if chunk_name == last_chunk_name:
continue continue
elif not self.refs_chunks.get(chunk_name, 0): elif not self.get_references_for(chunk_name):
self.open_chunks[chunk_name].close() self.open_chunks[chunk_name].close()
try: try:
del self.refs_chunks[chunk_name] del self.refs_chunks[chunk_name]
......
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