From f96ede475a21f1f7e22cf74dc24a0d88a12e6c25 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 19:11:26 +0100
Subject: [PATCH] add options to varlenseries

---
 README.md          |  3 ++-
 setup.py           |  2 +-
 tempsdb/varlen.pxd |  8 ++++----
 tempsdb/varlen.pyx | 15 +++++++++++++++
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index bfe477b..4bbc04b 100644
--- a/README.md
+++ b/README.md
@@ -51,9 +51,10 @@ python setup.py bdist_wheel
 Then copy your resulting wheel and install it via pip on the target system.
 
 # Changelog
+
 ## v0.5.2
 
-* _TBA_
+* added multiple properties and attributes to `VarlenSeries`
 
 ## v0.5.1
 
diff --git a/setup.py b/setup.py
index 9265f8c..b1aaad9 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.2a1',
+      version='0.5.2a2',
       packages=find_packages(include=['tempsdb', 'tempsdb.*']),
       install_requires=['satella>=2.14.24', 'ujson'],
       ext_modules=ext_modules,
diff --git a/tempsdb/varlen.pxd b/tempsdb/varlen.pxd
index f5bef0b..b3ee95c 100644
--- a/tempsdb/varlen.pxd
+++ b/tempsdb/varlen.pxd
@@ -7,12 +7,12 @@ cdef class VarlenSeries:
         int size_field
         int references
         object size_struct
-        str path
-        str name
+        readonly str path
+        readonly str name
         TimeSeries root_series
         readonly list series
-        list length_profile
-        int max_entries_per_chunk
+        readonly list length_profile
+        readonly int max_entries_per_chunk
         int current_maximum_length
         object mpm
         int gzip_level
diff --git a/tempsdb/varlen.pyx b/tempsdb/varlen.pyx
index 25997cb..d60c05d 100644
--- a/tempsdb/varlen.pyx
+++ b/tempsdb/varlen.pyx
@@ -296,6 +296,11 @@ cdef class VarlenIterator:
         :class:`~tempsdb.varlen.VarlenEntry`. Note that setting this to True
         will result in a performance drop, since it will copy, but it should
         be faster if your typical entry is less than 20 bytes.
+
+    :ivar name: series' name (str)
+    :ivar path: path to series' directory (str)
+    :ivar max_entries_per_chunk: maximum entries per chunk (int)
+    :ivar length_profile: length profile (tp.List[int])
     """
     def __init__(self, parent: VarlenSeries, start: int, stop: int,
                  direct_bytes: bool = False):
@@ -438,6 +443,16 @@ cdef class VarlenSeries:
             series.close_chunks()
         return 0
 
+    @property
+    cpdef unsigned long long last_entry_ts(self):
+        """
+        :return: last entry's timestamp, or barring that a 0
+        """
+        try:
+            return self.get_current_value()[0]
+        except ValueError:
+            return 0
+
     cpdef VarlenIterator iterate_range(self, unsigned long long start, unsigned long long stop,
                                        bint direct_bytes=False):
         """
-- 
GitLab