User: Password:
|
|
Subscribe / Log in / New account

Awesome!

Awesome!

Posted May 15, 2012 13:03 UTC (Tue) by ringerc (subscriber, #3071)
In reply to: Awesome! by Cyberax
Parent article: Highlights from the PostgreSQL 9.2 beta

The trouble with that is that custom Hibernate types seem to be difficult to use through JPA. Or am I just misinformed? (Please be so).

Hacking the driver to lie about the type and auto cast to/from text is ugly, but preserves the ability to use server validation etc with no changes higher in the client.

I would really love to be able to use JSON to store a serialized tree that got unpacked into an object graph using JAXB and jaxxon or similar, so instead of a 'json' entity field in the mapping you could use the root of (or a collection of) your custom jaxb annotated objects. That would take a lot more brains on the ORM though.


(Log in to post comments)

Awesome!

Posted May 15, 2012 13:17 UTC (Tue) by jberkus (subscriber, #55561) [Link]

The current PostgreSQL JSON type is a varlena rather than a binary type. So you'd need to go through a conversion anyway.

We discussed having a binary JSON type as well, but without a protocol to transmit binary values (BSON isn't at all a standard, and has some serious glitches), there didn't seem to be any point.

If you're interested in working on binary JSON support for PostgreSQL, we'd be interested in having you help out ...

Awesome!

Posted May 15, 2012 13:54 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

Right now I probably have the world's fastest JSON parser. It uses SSE instructions and bitslicing and is ridiculously fast - on the order of strlen speed. Of course, it's totally ridiculous but it was fun to write.

I was thinking about binary serializing JSON (I definitely don't like BSON). Simply tagging strings with length and not bothering about escaping helps greatly and simplifies parsing greatly. It also can be easily plugged into existing parsers. Type-specific tagging (int4, int8, bigint, float, string, map) would also be welcomed, but there are some fine points with it.

Awesome!

Posted May 15, 2012 14:42 UTC (Tue) by nteon (subscriber, #53899) [Link]

is the source for that online somewhere? I'd love to see it :)

Awesome!

Posted May 15, 2012 15:03 UTC (Tue) by jberkus (subscriber, #55561) [Link]

Cyberax,

What's the license of the parser?

Awesome!

Posted May 16, 2012 12:23 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link]

Right now it's "no way in hell I'm going to release it in this state". It'll be BSD once I refactor it into something generally usable.

Awesome!

Posted May 22, 2012 5:34 UTC (Tue) by ringerc (subscriber, #3071) [Link]

Portability is an issue for Pg, particularly where intrinsics or inline asm are used. Pg is built with gcc, llvm/clang, icc, mingw/gcc-win32, and many other compilers. It runs on x86, x64, ppc32, ppc64, sparc64, mips, s390, and more. It is expected to support a wide set of platforms as per the buildfarm (http://buildfarm.postgresql.org/).

Of course, not all those need fancy fast asm/intrinsics based speedy parsers. A portable, safe implementation in plain old C does the job fine for most platforms; Pg's build system is designed to selectively build files depending on target platform so optimised versions can be used where available and a general fallback implementation where not.

A big concern to me with using a new JSON optimised/complex implementation would be the need to maintain it, ensuring it was secure, reliable, and stable. Especially in "fast" code it's hard to ensure that everything is checked and safe. Pg users expect bad input to cause a polite error message not a backend crash, so any kind of horrible corrupt JSON you can imagine must be coped with cleanly.

Of course, Pg already has a roll-your-own JSON implementation, so it'd be cool to have something faster so long as it still focused on safety first.

Awesome!

Posted May 15, 2012 13:48 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

Adding custom types to JPA is not hard. It's just implementation-specific so you have to do it for Hibernate (EclipseLink, whatever) separately.

Basically, for the application programmer it'd look like:
>@Column(type='json')
>public JSON getColumn() {...}


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds