Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tempsdb
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
tempsdb
Commits
01539b3b
Commit
01539b3b
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
use mmap for writes too
parent
e3ad397d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
docs/chunks.rst
+8
-0
8 additions, 0 deletions
docs/chunks.rst
docs/index.rst
+2
-1
2 additions, 1 deletion
docs/index.rst
docs/usage.rst
+0
-1
0 additions, 1 deletion
docs/usage.rst
tempsdb/chunks.pxd
+1
-0
1 addition, 0 deletions
tempsdb/chunks.pxd
tempsdb/chunks.pyx
+12
-8
12 additions, 8 deletions
tempsdb/chunks.pyx
with
23 additions
and
10 deletions
docs/chunks.rst
0 → 100644
+
8
−
0
View file @
01539b3b
Chunk
=====
For your convenience the class :class:`~tempsdb.chunks.Chunk` was also documented, but don't use
it directly:
.. autoclass:: tempsdb.chunks.Chunk
:members:
This diff is collapsed.
Click to expand it.
docs/index.rst
+
2
−
1
View file @
01539b3b
...
@@ -12,8 +12,9 @@ Welcome to tempsdb's documentation!
...
@@ -12,8 +12,9 @@ Welcome to tempsdb's documentation!
usage
usage
exceptions
exceptions
chunks
It tries to use mmap for reads
where possible
, and in general
be
as zero-copy as possible (ie. the
It tries to use mmap for reads
and writes
, and in general
is
as zero-copy as possible (ie. the
only time data is unserialized is when a particular entry is read).
only time data is unserialized is when a particular entry is read).
Stored time series with a 8-bit timestamp and a fixed length of data.
Stored time series with a 8-bit timestamp and a fixed length of data.
...
...
This diff is collapsed.
Click to expand it.
docs/usage.rst
+
0
−
1
View file @
01539b3b
...
@@ -14,4 +14,3 @@ Then you can create and retrieve particular series:
...
@@ -14,4 +14,3 @@ Then you can create and retrieve particular series:
.. autoclass:: tempsdb.series.TimeSeries
.. autoclass:: tempsdb.series.TimeSeries
:members:
:members:
This diff is collapsed.
Click to expand it.
tempsdb/chunks.pxd
+
1
−
0
View file @
01539b3b
...
@@ -18,6 +18,7 @@ cdef class Chunk:
...
@@ -18,6 +18,7 @@ cdef class Chunk:
cpdef
void
close
(
self
)
cpdef
void
close
(
self
)
cpdef
tuple
get_piece_at
(
self
,
unsigned
int
index
)
cpdef
tuple
get_piece_at
(
self
,
unsigned
int
index
)
cpdef
int
put
(
self
,
unsigned
long
long
timestamp
,
bytes
data
)
except
-
1
cpdef
int
put
(
self
,
unsigned
long
long
timestamp
,
bytes
data
)
except
-
1
cpdef
int
sync
(
self
)
except
-
1
cdef
inline
int
length
(
self
):
cdef
inline
int
length
(
self
):
return
self
.
entries
return
self
.
entries
...
...
This diff is collapsed.
Click to expand it.
tempsdb/chunks.pyx
+
12
−
8
View file @
01539b3b
...
@@ -56,6 +56,13 @@ cdef class Chunk:
...
@@ -56,6 +56,13 @@ cdef class Chunk:
self
.
max_ts
,
=
STRUCT_Q
.
unpack
(
self
.
mmap
[
-
TIMESTAMP_SIZE
-
self
.
block_size
:
-
self
.
block_size
])
self
.
max_ts
,
=
STRUCT_Q
.
unpack
(
self
.
mmap
[
-
TIMESTAMP_SIZE
-
self
.
block_size
:
-
self
.
block_size
])
self
.
min_ts
,
=
STRUCT_Q
.
unpack
(
self
.
mmap
[
HEADER_SIZE
:
HEADER_SIZE
+
TIMESTAMP_SIZE
])
self
.
min_ts
,
=
STRUCT_Q
.
unpack
(
self
.
mmap
[
HEADER_SIZE
:
HEADER_SIZE
+
TIMESTAMP_SIZE
])
cpdef
int
sync
(
self
)
except
-
1
:
"""
Synchronize the mmap
"""
self
.
mmap
.
flush
()
return
0
cpdef
int
put
(
self
,
unsigned
long
long
timestamp
,
bytes
data
)
except
-
1
:
cpdef
int
put
(
self
,
unsigned
long
long
timestamp
,
bytes
data
)
except
-
1
:
"""
"""
Append a record to this chunk
Append a record to this chunk
...
@@ -73,14 +80,11 @@ cdef class Chunk:
...
@@ -73,14 +80,11 @@ cdef class Chunk:
raise
ValueError
(
'
data not equal in length to block size!
'
)
raise
ValueError
(
'
data not equal in length to block size!
'
)
if
timestamp
<=
self
.
max_ts
:
if
timestamp
<=
self
.
max_ts
:
raise
ValueError
(
'
invalid timestamp
'
)
raise
ValueError
(
'
invalid timestamp
'
)
cdef
unsigned
long
long
pointer_at_end
=
(
self
.
entries
+
1
)
*
(
TIMESTAMP_SIZE
+
self
.
block_size
)
+
HEADER_SIZE
cdef
bytearray
data_to_write
=
bytearray
(
TIMESTAMP_SIZE
+
self
.
block_size
)
data_to_write
[
0
:
TIMESTAMP_SIZE
]
=
STRUCT_Q
.
pack
(
timestamp
)
data_to_write
[
TIMESTAMP_SIZE
:]
=
data
with
self
.
write_lock
:
with
self
.
write_lock
:
self
.
file
.
seek
(
0
,
2
)
self
.
mmap
.
resize
(
pointer_at_end
)
self
.
file
.
write
(
data_to_write
)
self
.
mmap
[
pointer_at_end
-
self
.
block_size
-
TIMESTAMP_SIZE
:
pointer_at_end
-
self
.
block_size
]
=
STRUCT_Q
.
pack
(
timestamp
)
self
.
mmap
.
resize
((
self
.
entries
+
1
)
*
(
8
+
self
.
block_size
)
+
HEADER_SIZE
)
self
.
mmap
[
pointer_at_end
-
self
.
block_size
:
pointer_at_end
]
=
data
self
.
entries
+=
1
self
.
entries
+=
1
self
.
max_ts
=
timestamp
self
.
max_ts
=
timestamp
return
0
return
0
...
@@ -104,7 +108,7 @@ cdef class Chunk:
...
@@ -104,7 +108,7 @@ cdef class Chunk:
yield
self
.
get_piece_at
(
i
)
yield
self
.
get_piece_at
(
i
)
def
__iter__
(
self
)
->
tp
.
Iterator
[
tp
.
Tuple
[
int
,
bytes
]]:
def
__iter__
(
self
)
->
tp
.
Iterator
[
tp
.
Tuple
[
int
,
bytes
]]:
cdef
unsigned
long
i
=
0
cdef
int
i
for
i
in
range
(
self
.
entries
):
for
i
in
range
(
self
.
entries
):
yield
self
.
get_piece_at
(
i
)
yield
self
.
get_piece_at
(
i
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment