2 Thrift IDL Support. (original) (raw)

8.15

2 Thrift IDL Support.🔗

Support for Thrift format definitions

Examples:

> (require thrift thrift/idl/language)
> (define-thrift-namespace parquet)
> (define-thrift-enum parquet-type 0 (boolean int32 int64 int96 float double byte-array fixed-len-byte-arrary))
> (define-thrift-struct file-metadata ([1 version required type-int32] [2 schema required list-of schema-element] [3 num-rows required type-int64] [4 row-groups required list-of row-group] [5 key-value-metadata optional list-of key-value] [6 created-by optional type-string] [7 column-orders optional list-of column-order]))

2.1 Type System🔗

2.1.1 Core Types🔗

TBD

TBD

2.1.2 Field Type Information🔗

TBD

TBD

TBD

TBD

TBD

2.2 IDL Language🔗

(define-thrift-namespace namespace)
namespace : string?

TBD

(define-thrift-enum id maybe-start value ...)
id = string? maybe-start = | exact-nonnegative-integer? value-expr = identifier? [identifier? exact-nonnegative-integer?]

TBD

(define-thrift-struct [id string?] field ...)
field = (index name maybe-req maybe-con elem-type) | (index name maybe-req map-of elem-type key-type) maybe-required = required-type? maybe-container = container-type?
index : exact-nonnegative-integer? name : identifier? elem-type : identifier? key-type : identifier?

TBD

2.3 Code Generator🔗

(process-file [file-path module-prefix over-write?]) → void?
file-path : string? = "."
module-prefix : string? = ""
over-write? : boolean? = #f

TBD

2.3.1 Command-Line Launcher🔗

The parquet/idl/generator module is also used to create a launcher, rthriftthat wraps process-file to generate bindings for an IDL file from a Racket description.

rthrift [
where
-v, --verbose : Compile with verbose messages
-V, --very-verbose : Compile with very verbose messages
-o , --output-path : Directory to write the output into
-m , --module-prefix : Prefix generated modules with a module path
-f, --force-overwrite : Over-write any existing files
--help, -h : Show this help
-- : Do not treat any remaining argument as a switch (at this level)
Multiple single-letter switches can be combined after one `-'; for
example: `-h-' is the same as `-h --'

To generate the files used in the module parquet, we use the following command.

$ rthrift -o parquet/generated -m parquet/generated parquet/format.rkt

This generates the following files, in the parquet/generated directory.