Skip to content

Commit

Permalink
v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmaslanka committed Jun 24, 2021
1 parent 9d56f17 commit 24bb224
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding: utf-8
[metadata]
name = tempsdb
version = 0.6a5
version = 0.6
long-description = file: README.md
long-description-content-type = text/markdown; charset=UTF-8
license_files = LICENSE
Expand Down
10 changes: 1 addition & 9 deletions tempsdb/chunks/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import mmap
import warnings

from .gzip cimport ReadWriteGzipFile
from ..exceptions import Corruption, InvalidState, AlreadyExists, StillOpen
from ..exceptions import Corruption, StillOpen
from ..series cimport TimeSeries


Expand Down Expand Up @@ -167,12 +167,6 @@ cdef class Chunk:
self.pointer = self.entries*(self.block_size+TIMESTAMP_SIZE)+HEADER_SIZE
self.max_ts = self.get_timestamp_at(self.entries-1)

print('Readed',self.path, 'entries=', self.entries, 'max ts=', self.max_ts,
'file size=', self.file_size, 'pointer=', self.pointer, 'page size=', self.page_size)

if self.entries == 3867:
print('last record of 3867: ', repr(self.mmap[69592:69610]))

if self.pointer >= self.page_size:
# Inform the OS that we don't need the header anymore
self.mmap.madvise(mmap.MADV_DONTNEED, 0, HEADER_SIZE+TIMESTAMP_SIZE)
Expand Down Expand Up @@ -274,7 +268,6 @@ cdef class Chunk:
cdef:
unsigned long starting_index = HEADER_SIZE + index * (self.block_size + TIMESTAMP_SIZE)
unsigned long stopping_index = starting_index + TIMESTAMP_SIZE
print('reading timestamp from', starting_index, 'to', stopping_index)
return STRUCT_Q.unpack(self.mmap[starting_index:stopping_index])[0]

cpdef unsigned int find_left(self, unsigned long long timestamp):
Expand Down Expand Up @@ -434,7 +427,6 @@ cdef class Chunk:
self.sync()
self.mmap.close()
self.file.close()
print('closing', self.path)
return 0

def __del__(self) -> None:
Expand Down
7 changes: 3 additions & 4 deletions tempsdb/chunks/normal.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ cdef class NormalChunk(Chunk):
if self.file_lock_object:
self.file_lock_object.acquire()
try:
self.sync()
self.file_size += self.page_size
self.file.seek(0, io.SEEK_END)
ba = bytearray(self.page_size)
ba[-FOOTER_SIZE:] = STRUCT_L.pack(self.entries)
self.file.write(ba)
self.file.flush()
try:
self.mmap.resize(self.file_size)
except OSError as e:
if e.errno == 12: # ENOMEM
self.switch_to_descriptor_based_access()
else:
raise
self.sync()
finally:
if self.file_lock_object:
self.file_lock_object.release()
Expand All @@ -78,12 +79,10 @@ cdef class NormalChunk(Chunk):
if self.closed:
raise InvalidState('chunk is closed')

if self.pointer >= self.file_size-FOOTER_SIZE-self.block_size-TIMESTAMP_SIZE:
if self.pointer > self.file_size-FOOTER_SIZE-self.block_size-TIMESTAMP_SIZE:
self.extend()
cdef unsigned long long ptr_end = self.pointer + TIMESTAMP_SIZE
# Append entry
if self.entries > 4090:
print('writing %s to %s@%s ec=%s' % (repr(data), self.path, self.pointer, self.entries))
self.mmap[self.pointer:ptr_end] = STRUCT_Q.pack(timestamp)
self.mmap[ptr_end:ptr_end+self.block_size] = data
self.entries += 1
Expand Down
2 changes: 0 additions & 2 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class TestSeries(unittest.TestCase):

@unittest.skip('bug')
def test_write_series_append_after_close(self):
from tempsdb.series import create_series, TimeSeries
series = create_series('test6', 'test6', 10, 4096)
Expand All @@ -26,7 +25,6 @@ def test_write_series_append_after_close(self):

series.close()

@unittest.skip('because of reasons')
def test_write_series_with_interim_close(self):
from tempsdb.series import create_series, TimeSeries
series = create_series('test4', 'test4', 10, 4096)
Expand Down

0 comments on commit 24bb224

Please sign in to comment.