GithubHelp home page GithubHelp logo

bnclabs / gson Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 8.0 6.81 MB

Algorithms on data formats - JSON, CBOR, Collation.

Home Page: http://prataprc.github.io/jsonsort.io

License: MIT License

Go 97.03% Makefile 0.19% Shell 1.16% CSS 1.62%
cbor collation golang json json-pointer sort

gson's People

Contributors

prataprc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gson's Issues

Improvise docs/gettingstarted.md

Let it be a step by step approach highlighting common use case. The challenge though, would be to figure out the common use cases.

Run gson-tools as part of travis-ci

travis-ci might bail out if gson-tools is going to randomly thrash gson functions for a long time, find a reasonable time slot and execute gson-tools/make check as part of travis-ci

Support for json.Number

If golang type json.Number is encounter while transforming
value -> {JSON, CBOR, Binary-collate} treat them in the following manner:

While transforming to JSON:

Do nothing, json.Number is just a string and encode them as JSON string.

While transforming to CBOR:

Check if json.Number is negative by checking for a leading - . If so encode it as CBOR-int64, else encode it as CBOR-uint64.

While transforming to Binary-collate:

Check if json.Number is negative by checking for a leading -. Either case, eventually it gets encoded as float64.

Note that collate algorithm transparently treats int, uint, float as
number and make it comparable as same type, as number.

Investigate Benchmarks

BenchmarkVal2CollMap 50000 26696 ns/op 16416 B/op 2 allocs/op
BenchmarkVal2CollTyp 10000 174548 ns/op 49250 B/op 6 allocs/op

BenchmarkJson2CollStr 2000 635015 ns/op 1048647 B/op 5 allocs/op

BenchmarkCbor2CollMap 2000 787087 ns/op 1089654 B/op 8 allocs/op
BenchmarkCbor2CollTyp 500 2500523 ns/op 3269067 B/op 25 allocs/op

JSON: Extending JSON for Query specification.

When key used in a kv storage is shaped as JSON string, then we need some additional support besides what is available in JSON spec

  • Min-Unbounded, to denote that we want to iterate from the first item.
  • Max-Unbounded, to denote that we want to iterate till the last item.
  • -Infinity, to denote smallest number.
  • +Infinity, to denote largest number.
  • NaN, since it is included in IEEE 754 spec.
  • Missing, what is the sort position for missing in the supported list of types.

JSONPTR: Document about JSON pointer.

JSON-pointer is relative new compared to JSON, so it is good to have an introductory page on JSON-pointer and have references to advanced materials.

Binary collation: transparently handle int64, uint64 and float64.

Values in int64, uint64 and float64 should be comparable as if they belong to the same type -Number. Like suggested elsewhere, sorting is a human perception.

Also while converting Binary-collate back to Value, or CBOR, or JSON make sure that precision and accuracy is not lost.

Finally, add test cases to validate them same.

COLLATE: UTF8 collation of strings.

Collating strings is a complex affair. To describe some cases where gson's collation algorthim might fail are:

Refer: collation

Convert map[string]uint64 values to json.

Right now val.Tojson() supports the following types:

  • map[string]interface{}
  • [][2]interface{}

Both of them are converted to JSON property object. Support for:

  • map[string]uint64.

CBOR: Test cases for cbor_json.go:tag2json()

As of now, Gson supports following CBOR tagged data types:

tagDateTime, tagEpoch, tagPosBignum, tagNegBignum,
tagDecimalFraction, tagBigFloat, tagCborEnc, tagRegexp,
tagCborPrefix

I don't think JSON supports any of them in its present form. If we
can find some innovative way to still represent these tagged data
types within the limited set of JSON types, we can explore further.

Benchmark with jsoniter and alternates.

Make this repeatable with future version of gson, and alternate tools similar to gson. Collate the details and numbers that can be consumed via slides, wiki et al.

Optimize sync.Pool and defer() calls.

(a) Replace sync.Pool for objects with simple linked list of objects.
(b) Remove defer() calls that can happen in tight loops.

(a) will have to be tested and benchmarked for

  • Converting map objects form CBOR to collation format.
  • Converting collated string to JSON format.
  • Converting JSON string data to Collation formation.
  • Converting map objects from golang value to collation format.
  • Converting map objects from golang value to JSON format.
  • Converting map[string]uint64 from golang value to JSON format.
  • Converting map objects from golang value to CBOR format.
  • List JSON pointers in a given golang value map..

(b) will have to be tested and benchmarked for

  • Converting CBOR array to Collation format (both definite and indefinite CBOR variant).
  • Converting CBOR map to Collation format (both definite and indefinite CBOR variant).
  • List JSON pointers in a given golang value map.
  • Converting map objects from golang value to CBOR.
  • Converting map objects and map[string]uint64 golang value to JSON format.
  • Converting map objects from golang value to Collation format.
  • Converting string and map objects from JSON to Collation format.
  • Converting string and map objects from JSON to golang value.
  • Converting from Collated string to JSON format.
  • Converting from Collated string to CBOR format.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.