Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Refactor JsonQueryFactory so that parameters are not expanded as text in the query string. #146
No worries for the delay!
A bit more context to what led me to this change: I store time series in a structure that looks like this
The purpose is to have a single document containing a large number of values, and fill it with partial updates of the arrays. This reduces database size by storing values in chunks by time ranges and increases transfer speed. Time series are well suited for that since individual values are rarely read in isolation.
An important point here is that when a new chunk is created, its arrays are pre-filled with typed zeros (long for timestamp and double for values) so that document structure and size don't change over time when values are added. This allows the database to update documents in place since the BSON layout hasn't changed.
This means just a few bytes are updated rather than rewriting the whole document, possibly with a different size that would require to relocate it on disk.
With the current QueryFactory implementation, update instructions are serialized as text before being parsed as json. The consequence is that numbers are converted to the smallest representation that can fit them, e.g. a value of "0.0" will result in an int32 rather than a double, thus changing the document layout.
My refactoring fixes this by avoiding the roundtrip through a textual representation, thus keeping the original number types.
This pull request has been included into an early release.
<dependencies> <dependency> <groupId>org.jongo</groupId> <artifactId>jongo</artifactId> <version>0.5-early-20130912-1506</version> </dependency> </dependencies> ... <repositories> <repository> <id>cloudbees-jongo-early-release</id> <url>http://repository-jongo.forge.cloudbees.com/release</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>