From cbab647b330b8cf44449003d4dee604e4dd48f0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Wed, 16 Dec 2020 20:39:51 +0100
Subject: [PATCH] 0.5.3

---
 README.md            |  2 +-
 setup.py             |  2 +-
 tempsdb/database.pyx |  2 ++
 tempsdb/varlen.pxd   |  1 +
 tempsdb/varlen.pyx   | 11 +++++++++++
 5 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index c1d9c38..9a15da9 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ Then copy your resulting wheel and install it via pip on the target system.
 
 ## v0.5.3
 
-* added `disable_mmap` and `enable_mmap` into `VarlenSeries`
+* added `disable_mmap`, `enable_mmap` and `open_chunks_mmap_size` into `VarlenSeries`
 
 ## v0.5.2
 
diff --git a/setup.py b/setup.py
index 6382a8a..1ed60fa 100644
--- a/setup.py
+++ b/setup.py
@@ -41,7 +41,7 @@ ext_modules = build([Multibuild('tempsdb', find_pyx('tempsdb'), **ext_kwargs), ]
                      **cythonize_kwargs)
 
 setup(name='tempsdb',
-      version='0.5.3a1',
+      version='0.5.3',
       packages=find_packages(include=['tempsdb', 'tempsdb.*']),
       install_requires=['satella>=2.14.24', 'ujson'],
       ext_modules=ext_modules,
diff --git a/tempsdb/database.pyx b/tempsdb/database.pyx
index 62c340c..c74171d 100644
--- a/tempsdb/database.pyx
+++ b/tempsdb/database.pyx
@@ -230,6 +230,8 @@ cdef class Database:
         :return: new variable length series
         :raises AlreadyExists: series with given name already exists
         """
+        from .varlen import create_varlen_series
+
         cdef:
             VarlenSeries series
             str path = os.path.join(self.path, 'varlen', name)
diff --git a/tempsdb/varlen.pxd b/tempsdb/varlen.pxd
index ac2feb9..1b12527 100644
--- a/tempsdb/varlen.pxd
+++ b/tempsdb/varlen.pxd
@@ -20,6 +20,7 @@ cdef class VarlenSeries:
 
     cpdef int enable_mmap(self) except -1
     cpdef int disable_mmap(self) except -1
+    cpdef unsigned long open_chunks_mmap_size(self)
     cpdef int mark_synced_up_to(self, unsigned long long timestamp) except -1
     cpdef int close(self, bint force=*) except -1
     cpdef int delete(self) except -1
diff --git a/tempsdb/varlen.pyx b/tempsdb/varlen.pyx
index f381b95..046fccc 100644
--- a/tempsdb/varlen.pyx
+++ b/tempsdb/varlen.pyx
@@ -651,6 +651,17 @@ cdef class VarlenSeries:
         """
         return self.length_profile[-1 if index >= len(self.length_profile) else index]
 
+    cpdef unsigned long open_chunks_mmap_size(self):
+        """
+        :return: total area of memory taken by mmaps, in bytes
+        """
+        cdef:
+            unsigned long long total = 0
+            TimeSeries series
+        for series in self.series:
+            total += series.open_chunks_mmap_size()
+        return total
+
     cpdef int close(self, bint force=False) except -1:
         """
         Close this series.
-- 
GitLab