On this page:
2.1 Type System
2.1.1 Core Types
type?
type-stop
type-void
type-bool
type-byte
type-int8
type-double
type-int16
type-int32
type-int64
type-string
type-binary
type-utf-7
type-struct
type-map
type-list
type-set
type-utf-8
type-utf-16
integer->type
type/  decode
type/  names
2.1.2 Field Type Information
required-type?
required-type-required
required-type-optional
required-type-default
integer->required-type
required-type/  decode
required-type/  names
container-type?
container-type-list-of
container-type-set-of
container-type-map-of
container-type-none
integer->container-type
container-type/  decode
container-type/  names
thrift-field
2.2 IDL Language
define-thrift-namespace
define-thrift-enum
define-thrift-struct
2.3 Code Generator
process-file
2.3.1 Command-Line Launcher
7.4

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

 (require thrift/idl/common) package: thrift

2.1.1 Core Types

procedure

(type? v)  boolean?

  v : any/c

value

type-stop : type?

value

type-void : type?

value

type-bool : type?

value

type-byte : type?

value

type-int8 : type?

value

type-double : type?

value

type-int16 : type?

value

type-int32 : type?

value

type-int64 : type?

value

type-string : type?

value

type-binary : type?

value

type-utf-7 : type?

value

type-struct : type?

value

type-map : type?

value

type-list : type?

value

type-set : type?

value

type-utf-8 : type?

value

type-utf-16 : type?

TBD

procedure

(integer->type n)  type?

  n : exact-nonnegative-integer?

procedure

(type/decode d)  type?

  d : decoder?

procedure

(type/names)  (listof string?)

TBD

2.1.2 Field Type Information

procedure

(required-type? v)  boolean?

  v : any/c

TBD

TBD

procedure

(container-type? v)  boolean?

  v : any/c

TBD

TBD

struct

(struct thrift-field (id
    name
    required
    container
    major-type
    minor-type
    position)
    #:mutable)
  id : identifier?
  name : string?
  required : symbol?
  container : symbol?
  major-type : symbol?
  minor-type : symbol?
  position : exact-nonnegative-integer?
TBD

2.2 IDL Language

 (require thrift/idl/language) package: thrift

syntax

(define-thrift-namespace namespace)

 
  namespace : string?
TBD

syntax

(define-thrift-enum id maybe-start value ...)

 
id = string?
     
maybe-start = 
  | exact-nonnegative-integer?
     
value-expr = identifier?
  | [identifier? exact-nonnegative-integer?]
TBD

syntax

(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

 (require thrift/idl/generator) package: thrift

procedure

(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, rthrift that wraps process-file to generate bindings for an IDL file from a Racket description.

rthrift [ <option> ... ] <file-path>

 where <option> is one of

  -v, --verbose : Compile with verbose messages

  -V, --very-verbose : Compile with very verbose messages

  -o <path>, --output-path <path> : Directory to write the output into

  -m <module>, --module-prefix <module> : 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.