Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
98e6178
Add logical types. Minor improvements.
siilike Jun 24, 2019
26c170f
revert Buffer changes
siilike Jun 27, 2019
122ef80
updates
siilike Sep 3, 2019
e8ed9f2
Merge remote-tracking branch 'upstream/master' into siilike
siilike Sep 3, 2019
5885e6f
updates
siilike Sep 3, 2019
29cef2d
fix indentation
siilike Sep 3, 2019
c6b9b74
minor fixes and updates
siilike Sep 3, 2019
bf91354
Apply suggestions from code review
siilike Sep 4, 2019
fae2814
third take on tags
siilike Sep 15, 2019
cd02250
Slice.hasTag()
siilike Sep 15, 2019
d77555b
Add Slice::booleanSlice and fix Builder::addInternal
siilike Sep 19, 2019
b960ad4
Dumper: add double NaN and Infinity as string and single-line pretty …
siilike Oct 7, 2019
ec84518
BCD base implementation
siilike Oct 8, 2019
2f7ef5d
fix Dumper
siilike Oct 8, 2019
d7bb557
Builder.addBCD fix
siilike Oct 8, 2019
3cadedd
updates
siilike Oct 9, 2019
fbaeb5d
Merge branch 'master' of github.com:arangodb/velocypack into siilike
siilike Oct 9, 2019
4b962f1
add first tests for tags
siilike Oct 9, 2019
2e5eabc
make malloc/realloc/free customizable compile-time
siilike Oct 9, 2019
a2e9d07
add Dumper tests
siilike Oct 9, 2019
1c91539
add Collection tests
siilike Oct 11, 2019
e9637d0
Slice tags tests
siilike Oct 11, 2019
ae702c0
add full 32-bit hash support to Slice
siilike Oct 11, 2019
a26d9a7
add ValueSlice tests and fixes
siilike Oct 11, 2019
5d6f711
remove ValueSlice
siilike Nov 10, 2019
a3756f3
Merge remote-tracking branch 'upstream/master' into siilike
siilike Nov 10, 2019
bf5137d
make xxHash use vmalloc & vfree
siilike Nov 10, 2019
2e201be
more fixes and improvements
siilike Nov 17, 2019
aeb673e
fix memory management override
siilike Nov 18, 2019
6cd9b16
make thread_locals optional
siilike Nov 18, 2019
ee220ba
fix disabling threadlocals
siilike Nov 19, 2019
858468b
change BCD exponent to signed
siilike Dec 9, 2019
ac70e54
add velocypack prefixes and fix dumping timestamps
siilike Dec 12, 2019
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(VELOCYPACK_URL_INFO_ABOUT "https://github.com/arangodb/velocypack")
set(VELOCYPACK_CONTACT "hackers@arangodb.org")
set(VELOCYPACK_FRIENDLY_STRING "VelocyPack - A fast & compact serialization format")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

#Compiler Setting
include(AR_CompilerSettings)
Expand Down
37 changes: 36 additions & 1 deletion VelocyPack.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ reference, for arrays and objects see below for details:
follow that encode in a little endian way the length of
the mantissa in bytes. After that, same as positive long
packed BCD-encoded float above.
- 0xd8-0xef : reserved
- 0xd8-0xed : reserved
- 0xee-0xef : value tagging for logical types
- 0xf0-0xff : custom types


Expand Down Expand Up @@ -556,6 +557,40 @@ There for the unholy nibble problem is solved and parsing (and indeed
dumping) can be efficient.


## Tagging

Types 0xee-0xef are used for tagging of values to implement logical
types.

For example, if type 0x1c did not exist, the database driver could
serialize a timestamp object (Date in JavaScript, Instant in Java, etc)
into a Unix timestamp, a 64-bit integer. Assuming the lack of schema,
upon deserialization it would not be possible to tell an integer from
a timestamp and deserialize the value accordingly.

Type tagging resolves this by attaching an integer tag to values that
can then be read when deserializing the value, e.g. that tag=1 is a
timestamp and the relevant timestamp class should be used.

The tag values are specified separately and applications can also
specify their own to have the database driver deserialize their specific
data types into the appropriate classes (including models).

Essentially this is object-relational mapping for parts of documents.

The format of the type is:

0xee
TAG number in 1 byte
sub VPack value

or

0xef
TAG number in 8 bytes, little-endian encoding
sub VPack value


## Custom types

Note that custom types should usually not be used for data exchange but
Expand Down
16 changes: 8 additions & 8 deletions include/velocypack/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Buffer {
Buffer(Buffer const& that) : Buffer() {
if (that._size > 0) {
if (that._size > sizeof(that._local)) {
_buffer = static_cast<T*>(malloc(checkOverflow(that._size)));
_buffer = static_cast<T*>(velocypack_malloc(checkOverflow(that._size)));
ensureValidPointer(_buffer);
_capacity = that._size;
} else {
Expand All @@ -76,13 +76,13 @@ class Buffer {
memcpy(_buffer, that._buffer, checkOverflow(that._size));
} else {
// our own buffer is not big enough to hold the data
T* buffer = static_cast<T*>(malloc(checkOverflow(that._size)));
T* buffer = static_cast<T*>(velocypack_malloc(checkOverflow(that._size)));
ensureValidPointer(buffer);
buffer[0] = '\x00';
memcpy(buffer, that._buffer, checkOverflow(that._size));

if (_buffer != _local) {
free(_buffer);
velocypack_free(_buffer);
}
_buffer = buffer;
_capacity = that._size;
Expand Down Expand Up @@ -113,7 +113,7 @@ class Buffer {
Buffer& operator=(Buffer&& that) noexcept {
if (this != &that) {
if (_buffer != _local) {
free(_buffer);
velocypack_free(_buffer);
}
if (that._buffer == that._local) {
_buffer = _local;
Expand All @@ -135,7 +135,7 @@ class Buffer {

~Buffer() {
if (_buffer != _local) {
free(_buffer);
velocypack_free(_buffer);
}
}

Expand Down Expand Up @@ -187,7 +187,7 @@ class Buffer {
void clear() noexcept {
_size = 0;
if (_buffer != _local) {
free(_buffer);
velocypack_free(_buffer);
_buffer = _local;
_capacity = sizeof(_local);
poison(_buffer, _capacity);
Expand Down Expand Up @@ -289,11 +289,11 @@ class Buffer {
VELOCYPACK_ASSERT(newLen > 0);
T* p;
if (_buffer != _local) {
p = static_cast<T*>(realloc(_buffer, checkOverflow(newLen)));
p = static_cast<T*>(velocypack_realloc(_buffer, checkOverflow(newLen)));
ensureValidPointer(p);
// realloc will have copied the old data
} else {
p = static_cast<T*>(malloc(checkOverflow(newLen)));
p = static_cast<T*>(velocypack_malloc(checkOverflow(newLen)));
ensureValidPointer(p);
// copy existing data into buffer
memcpy(p, _buffer, checkOverflow(_size));
Expand Down
Loading