|
| 1 | +/** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +/** |
| 20 | + * File format description for the redfile file format |
| 21 | + */ |
| 22 | +namespace cpp redfile |
| 23 | +namespace java com.apache.redfile |
| 24 | + |
| 25 | +/** |
| 26 | + * Types supported by redfile. These types are intended to be for the storage |
| 27 | + * format, and in particular how they interact with different encodings. |
| 28 | + */ |
| 29 | +enum Type { |
| 30 | + BOOLEAN = 0; |
| 31 | + INT32 = 1; |
| 32 | + INT64 = 2; |
| 33 | + INT96 = 3; |
| 34 | + FLOAT = 4; |
| 35 | + DOUBLE = 5; |
| 36 | + BYTE_ARRAY = 6; |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * Encodings supported by redfile. Not all encodings are valid for all types. |
| 41 | + */ |
| 42 | +enum Encoding { |
| 43 | + /** Default encoding. |
| 44 | + * BOOLEAN - 1 bit per value. |
| 45 | + * INT32 - 4 bytes per value. Stored as little-endian. |
| 46 | + * INT64 - 8 bytes per value. Stored as little-endian. |
| 47 | + * FLOAT - 4 bytes per value. IEEE. Stored as little-endian. |
| 48 | + * DOUBLE - 8 bytes per value. IEEE. Stored as little-endian. |
| 49 | + * BYTE_ARRAY - 4 byte length stored as little endian, followed by bytes. |
| 50 | + */ |
| 51 | + PLAIN = 0; |
| 52 | + |
| 53 | + /** Group VarInt encoding for INT32/INT64. **/ |
| 54 | + GROUP_VAR_INT = 1; |
| 55 | +} |
| 56 | + |
| 57 | +/** |
| 58 | + * Supported compression algorithms. |
| 59 | + */ |
| 60 | +enum Compression { |
| 61 | + UNCOMPRESSED = 0; |
| 62 | + SNAPPY = 1; |
| 63 | + GZIP = 2; |
| 64 | + LZO = 3; |
| 65 | +} |
| 66 | + |
| 67 | +enum PageType { |
| 68 | + DATA_PAGE = 0; |
| 69 | + INDEX_PAGE = 1; |
| 70 | +} |
| 71 | + |
| 72 | +/** Data page header **/ |
| 73 | +struct DataPageHeader { |
| 74 | + 1: required i32 num_values |
| 75 | + |
| 76 | + /** Encoding used for this data page **/ |
| 77 | + 2: required Encoding encoding |
| 78 | +} |
| 79 | + |
| 80 | +struct IndexPageHeader { |
| 81 | + /** TODO: **/ |
| 82 | +} |
| 83 | + |
| 84 | +struct PageHeader { |
| 85 | + 1: required PageType type |
| 86 | + |
| 87 | + /** Uncompressed page size in bytes **/ |
| 88 | + 2: required i32 uncompressed_page_size |
| 89 | + |
| 90 | + /** Compressed page size in bytes **/ |
| 91 | + 3: required i32 compressed_page_size |
| 92 | + |
| 93 | + /** 32bit crc for the data below. This allows for disabling checksumming in |
| 94 | + * if only a few pages needs to be read |
| 95 | + **/ |
| 96 | + 4: required i32 crc |
| 97 | + |
| 98 | + 5: optional DataPageHeader data_page; |
| 99 | + 6: optional IndexPageHeader index_page; |
| 100 | +} |
| 101 | + |
| 102 | +/** |
| 103 | + * Wrapper struct to store key values |
| 104 | + */ |
| 105 | + struct KeyValue { |
| 106 | + 1: required string key |
| 107 | + 2: optional string value |
| 108 | + } |
| 109 | + |
| 110 | +/** |
| 111 | + * Description for column metadata |
| 112 | + */ |
| 113 | +struct ColumnMetaData { |
| 114 | + /** Type of this column **/ |
| 115 | + 1: required Type type |
| 116 | + |
| 117 | + /** Set of all encodings used for this column **/ |
| 118 | + 2: required list<Encoding> encodings |
| 119 | + |
| 120 | + /** Path in schema **/ |
| 121 | + 3: required list<string> path_in_schema |
| 122 | + |
| 123 | + /** Compression codec **/ |
| 124 | + 4: required Compression codec |
| 125 | + |
| 126 | + /** Number of values in this column **/ |
| 127 | + 5: required i64 num_values |
| 128 | + |
| 129 | + /** Max defintion and repetition levels **/ |
| 130 | + 6: required i32 max_definition_level |
| 131 | + 7: required i32 max_repetition_level |
| 132 | + |
| 133 | + /** Byte offset from beginning of file to first data page **/ |
| 134 | + 8: optional i64 data_page_offset |
| 135 | + |
| 136 | + /** Byte offset from beginning of file to root index page **/ |
| 137 | + 9: optional i64 index_page_offset |
| 138 | + |
| 139 | + /** Optional key/value metadata **/ |
| 140 | + 10: list<KeyValue> key_value_metadata |
| 141 | +} |
| 142 | + |
| 143 | +struct ColumnStart { |
| 144 | + /** File where column data is stored. If not set, assumed to be same file as |
| 145 | + * metadata |
| 146 | + **/ |
| 147 | + 1: optional string file_path |
| 148 | + |
| 149 | + /** Byte offset in file_path to the ColumnMetaData **/ |
| 150 | + 2: required i64 file_offset |
| 151 | +} |
| 152 | + |
| 153 | +struct RowGroup { |
| 154 | + 1: required list<ColumnStart> columns |
| 155 | + /** Total byte size of all the uncompressed column data in this row group **/ |
| 156 | + 2: required i64 total_byte_size |
| 157 | +} |
| 158 | + |
| 159 | +/** |
| 160 | + * Description for file metadata |
| 161 | + */ |
| 162 | +struct FileMetaData { |
| 163 | + /** Version of this file **/ |
| 164 | + 1: required i32 version |
| 165 | + |
| 166 | + /** Number of rows in this file **/ |
| 167 | + 2: required i64 num_rows |
| 168 | + |
| 169 | + /** Number of cols in the schema for this file **/ |
| 170 | + 3: required i32 num_cols |
| 171 | + |
| 172 | + /** Row groups in this file **/ |
| 173 | + 4: list<RowGroup> row_groups |
| 174 | + |
| 175 | + /** Optional key/value metadata **/ |
| 176 | + 5: list<KeyValue> key_value_metadata |
| 177 | + |
| 178 | + /** 32bit crc for the file metadata **/ |
| 179 | + 6: optional i32 meta_data_crc |
| 180 | +} |
0 commit comments