1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_CORE_LIB_IO_TABLE_OPTIONS_H_ 17 #define TENSORFLOW_CORE_LIB_IO_TABLE_OPTIONS_H_ 18 19 #include <stddef.h> 20 21 namespace tensorflow { 22 namespace table { 23 24 // DB contents are stored in a set of blocks, each of which holds a 25 // sequence of key,value pairs. Each block may be compressed before 26 // being stored in a file. The following enum describes which 27 // compression method (if any) is used to compress a block. 28 enum CompressionType { 29 // NOTE: do not change the values of existing entries, as these are 30 // part of the persistent format on disk. 31 kNoCompression = 0x0, 32 kSnappyCompression = 0x1 33 }; 34 35 // Options to control the behavior of a table (passed to Table::Open) 36 struct Options { 37 // Approximate size of user data packed per block. Note that the 38 // block size specified here corresponds to uncompressed data. The 39 // actual size of the unit read from disk may be smaller if 40 // compression is enabled. This parameter can be changed dynamically. 41 size_t block_size = 262144; 42 43 // Number of keys between restart points for delta encoding of keys. 44 // This parameter can be changed dynamically. Most clients should 45 // leave this parameter alone. 46 int block_restart_interval = 16; 47 48 // Compress blocks using the specified compression algorithm. This 49 // parameter can be changed dynamically. 50 // 51 // Default: kSnappyCompression, which gives lightweight but fast 52 // compression. 53 // 54 // Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz: 55 // ~200-500MB/s compression 56 // ~400-800MB/s decompression 57 // Note that these speeds are significantly faster than most 58 // persistent storage speeds, and therefore it is typically never 59 // worth switching to kNoCompression. Even if the input data is 60 // incompressible, the kSnappyCompression implementation will 61 // efficiently detect that and will switch to uncompressed mode. 62 CompressionType compression = kSnappyCompression; 63 }; 64 65 } // namespace table 66 } // namespace tensorflow 67 68 #endif // TENSORFLOW_CORE_LIB_IO_TABLE_OPTIONS_H_ 69