• Stars
    star
    194
  • Rank 193,479 (Top 4 %)
  • Language
    Clojure
  • License
    MIT License
  • Created about 2 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

zero dependency efficient read/write of json and csv data.

Charred

Efficient character-based file parsing for csv and json formats.

Clojars Project

Usage

user> (require '[charred.api :as charred])
nil
user> (charred/read-json "{\"a\": 1, \"b\": 2}")
{"a" 1, "b" 2}
user> (charred/read-json "{\"a\": 1, \"b\": 2}" :key-fn keyword)
{:a 1, :b 2}
user> (println (charred/write-json-str *1))
{
  "a": 1,
  "b": 2
}

A Note About Efficiency

If you are reading or writing a lot of small JSON objects the best option is to create a specialized parse fn to exactly the options that you need and pass in strings or char[] data. A similar pathway exists for high performance writing of json objects. The returned functions are safe to use in multithreaded contexts.

The system is overall tuned for large files. Small files or input streams should be setup with :async? false and smaller :bufsize arguments such as 8192 as there is no gain for async loading when the file/stream is smaller than 1MB. For smaller streams slurping into strings in an offline threadpool will lead to the highest performance. For a particular file size if you know you are going to parse many of these then you should gridsearch :bufsize and :async? as that is a tuning pathway that I haven't put a ton of time into. In general the system is tuned towards larger files as that is when performance really does matter.

All the parsing systems have mutable options. These can be somewhat faster and it is interesting to look at the tradeoffs involved. Parsing a csv using the raw supplier interface is a bit faster than using the Clojure sequence pathway into persistent vectors and it probably doesn't really change your consume pathway so it may be worth trying it.

Development

Before running a REPL you must compile the java files into target/classes. This directory will then be on your classpath.

scripts/compile

Tests can be run with scripts/run-tests which will compile the java and then run the tests.

Lies, Damn Lies, and Benchmarks!

See the fast-json project. These times are for parsing a 100k json document using keywords for map keys - :key-fn keyword.

Intel JDK-8

method performance Β΅s
data.json 4275
jsonista 754
charred 638
charred-hamf 486

Intel JDK-19

method performance Β΅s
data.json 5608
jsonista 856
charred 673
charred-hamf 531

Mac m-1 JDK-19

method performance Β΅s
data.json 3164
jsonista 285
charred 249
charred-hamf 227

License

MIT license.

More Repositories

1

dtype-next

A Clojure library designed to aid in the implementation of high performance algorithms and systems.
Clojure
310
star
2

ham-fisted

High performance HAMT
Clojure
147
star
3

libjulia-clj

Julia bindings for Clojure -- Currently somewhat unstable --
Clojure
103
star
4

tmdjs

High Performance Data Processing for ClojureScript
Clojure
98
star
5

avclj

libavcodec pathways for Clojure.
Clojure
57
star
6

cljs-lambda-gateway-example

Simple bare-bones example of launching a full website using API gateway and AWS lambda
Clojure
53
star
7

facial-rec

Facial rec tech
Python
31
star
8

depsviz

Graphiz visualization for deps.edn
Clojure
22
star
9

streams

Simple monte carlo simulation system based on lazy non-caching streams.
Clojure
20
star
10

ames-house-prices

exploring aimes house prices comp
Jupyter Notebook
20
star
11

lambinator

Clojure 3d graphics editing platform
Clojure
10
star
12

ds-graal

Example of tech.ml.dataset and graalvm reading a CSV and writing Parquet.
Shell
9
star
13

berger-emacs

clean emacs setup for clojure
Emacs Lisp
8
star
14

fast-json

Clojure
7
star
15

ham-scripted

High performance js primitives
JavaScript
7
star
16

simpledata

A simple example project with a few datasets and sql bindings
Clojure
6
star
17

kmeans-mnist

An example of Clojure/Julia integration.
Clojure
6
star
18

mkl

Basic mkl bindings based on dtype-next's ffi system
Clojure
3
star
19

garmin-fit-clj

Clojure parser for garmin fit files
Clojure
2
star
20

thinksm

Thinktopic state machine implementation.
Clojure
1
star
21

siemplify-graal-native-example

Shell
1
star
22

d3meetup

Working through a bunch of garmin/strava data for d3 meetup vega demonstration
Jupyter Notebook
1
star
23

benchmark

Simple benchmarking tools
Clojure
1
star
24

difftest

Comparison of diff-1d algorithms
Clojure
1
star