1.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2+++ b/lisp/lib/dat/parquet/proto.lisp Sat Jul 13 18:18:01 2024 -0400
1.3@@ -0,0 +1,32 @@
1.4+;;; proto.lisp --- Parquet Data Protocol
1.5+
1.6+;;
1.7+
1.8+;;; Code:
1.9+(in-package :dat/parquet)
1.10+
1.11+(defgeneric parquet-read (value &optional stream))
1.12+(defgeneric parquet-write (value &optional stream))
1.13+
1.14+(defmethod parquet-write ((value (eql t)) &optional stream)
1.15+ "Encode a parquet boolean true value."
1.16+ (declare (ignore value))
1.17+ (write-byte 1 stream))
1.18+
1.19+(defmethod parquet-write ((value (eql nil)) &optional stream)
1.20+ "Encode a parquet boolean false value."
1.21+ (declare (ignore value))
1.22+ (write-byte 0 stream))
1.23+
1.24+(defmethod parquet-write ((value string) &optional stream))
1.25+
1.26+;;; Encode/Decode
1.27+(defun parquet-encode (value &optional stream)
1.28+ "Encode a Lisp value and write it to a parquet stream."
1.29+ (parquet-write value stream))
1.30+
1.31+(defun parquet-decode (string &key (start 0) end)
1.32+ "Convert a PARQUET string into a Lisp object."
1.33+ (with-input-from-string (stream string :start start :end end)
1.34+ (values (parquet-read stream)
1.35+ (file-position stream))))