I'm not in a position to give you advice on the database pa
is very application-specific, but your JSON parsing can be
quite straightforwardly with custom decoders in CL-JSON:
(in-package json)
(defvar *default-decoder*
(current-decoder))
(defun dispose-of-big-data (obj)
(format *trace-output* "Disposing of ~S~%" obj))
(setf *big-data-decoder*
(custom-decoder
:beginning-of-array (constantly nil)
:array-member #'dispose-of-big-data
:end-of-array (constantly '#:big-data-array)
:internal-decoder *default-decoder*))
(defun decode-big-data-container (json)
(let ((kh *object-key-handler*))
(with-shadowed-custom-vars
(set-custom-vars
:object-key (lambda (key)
(setf *internal-decoder*
(if (equal key "foo")
*big-data-decoder*
*default-decoder*))
(funcall kh key)))
(decode-json-from-source json))))
(decode-big-data-container
"{
\"foo\": [
{
\"a\": \"lorem ipsum...\",
\"b\": { \"aa\": 6, \"bb\": 4 },
\"c\": [1, 2, 3, 4]
},
{
\"a\": \"the quick brown fox...\",
\"b\": { \"zz\": 66, \"yy\": 44 },
\"c\": [1, 1, 2, 3, 5]
}
],
\"bar\": 7,
\"baz\": 8
}")
This evaluates to ((:FOO . #:BIG-DATA-ARRAY) (:BAR . 7) (:BAZ . 8))
and prints out the trace for the big data elements:
Disposing of ((:A . "lorem ipsum...") (:B (:AA . 6) (:BB . 4))
(:C 1 2 3 4))
Disposing of ((:A . "the quick brown fox...") (:B (:ZZ . 66) (:YY . 44))
(:C 1 1 2 3 5))
You can see that *BIG-DATA-DECODER* installs its own array handlers.
They replace the standard array handlers which accumulate the array
elements; so, *BIG-DATA-DECODER* doesn't do any accumulation.
Hope this helps.
Yours,
– B. Sm.