From 552a2cd751bf00dffe233888f075f2b66ebf7c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Fri, 11 Dec 2020 23:49:00 +0100 Subject: [PATCH] refactor the code --- setup.py | 2 +- tempsdb/chunks.pyx | 6 +++--- tempsdb/series.pyx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 826957f..ad95479 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ if 'CI' in os.environ: setup(name='tempsdb', - version='0.5a1', + version='0.5a2', packages=['tempsdb'], install_requires=['satella>=2.14.24', 'ujson'], ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb')), ], diff --git a/tempsdb/chunks.pyx b/tempsdb/chunks.pyx index 3d3066a..31f2a23 100644 --- a/tempsdb/chunks.pyx +++ b/tempsdb/chunks.pyx @@ -140,8 +140,8 @@ cdef class Chunk: cdef int decref(self) except -1: if self.parent is not None: - self.parent.decref_chunk(self.min_ts) - if self.parent.refs_chunks[self.name()] < 0: + self.parent.decref_chunk(self.name()) + if self.parent.get_references_for(self.name()) < 0: raise ValueError('reference of chunk fell below zero!') return 0 @@ -407,7 +407,7 @@ cdef class Chunk: cdef unsigned long long name = self.name() if self.parent: 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') del self.parent.refs_chunks[name] del self.parent.open_chunks[name] diff --git a/tempsdb/series.pyx b/tempsdb/series.pyx index a6905e8..fced5ea 100644 --- a/tempsdb/series.pyx +++ b/tempsdb/series.pyx @@ -204,7 +204,7 @@ cdef class TimeSeries: while len(self.chunks) >= 2 and timestamp > self.chunks[1]: chunk_to_delete = self.chunks[0] 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: self.open_chunks[chunk_to_delete].delete() else: @@ -378,7 +378,7 @@ cdef class TimeSeries: for chunk_name in chunks: if chunk_name == last_chunk_name: continue - elif not self.refs_chunks.get(chunk_name, 0): + elif not self.get_references_for(chunk_name): self.open_chunks[chunk_name].close() try: del self.refs_chunks[chunk_name] -- GitLab