kazarena / json-gold

A JSON-LD processor for Go
Apache License 2.0
114 stars 17 forks source link

N-Quads deserialize from Reader, serialize to Writer #8

Closed dennwc closed 9 years ago

dennwc commented 9 years ago

Changed N-Quads code a bit:

  1. Deserializer works with bufio.Scanner interface for line splitting, allowing to pass io.Reader as input to Parse. This should also reduce GC pressure on large datasets, because deserializer processes lines on the fly without a need to store them in a separate slice. Performance impact is minimal, as newScannerFor switches Scanner interface to custom implementation for []byte and string to bypass copy operations in original bufio.Scanner. There is also a benchmark for that.
  2. Serializers can implement an optional RDFSerializerTo interface advertising it's ability to write serialized RDF directly into io.Writer without a need of temporary string representation. N-Quads serializer implements such behavior now.

All changes are backward-compatible.

kazarena commented 9 years ago

Looks great, thank you!