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 class Cache; 25 26 // DB contents are stored in a set of blocks, each of which holds a 27 // sequence of key,value pairs. Each block may be compressed before 28 // being stored in a file. The following enum describes which 29 // compression method (if any) is used to compress a block. 30 enum CompressionType { 31 // NOTE: do not change the values of existing entries, as these are 32 // part of the persistent format on disk. 33 kNoCompression = 0x0, 34 kSnappyCompression = 0x1 35 }; 36 37 // Options to control the behavior of a table (passed to Table::Open) 38 struct Options { 39 // Approximate size of user data packed per block. Note that the 40 // block size specified here corresponds to uncompressed data. The 41 // actual size of the unit read from disk may be smaller if 42 // compression is enabled. This parameter can be changed dynamically. 43 size_t block_size = 262144; 44 45 // Number of keys between restart points for delta encoding of keys. 46 // This parameter can be changed dynamically. Most clients should 47 // leave this parameter alone. 48 int block_restart_interval = 16; 49 50 // Compress blocks using the specified compression algorithm. This 51 // parameter can be changed dynamically. 52 // 53 // Default: kSnappyCompression, which gives lightweight but fast 54 // compression. 55 // 56 // Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz: 57 // ~200-500MB/s compression 58 // ~400-800MB/s decompression 59 // Note that these speeds are significantly faster than most 60 // persistent storage speeds, and therefore it is typically never 61 // worth switching to kNoCompression. Even if the input data is 62 // incompressible, the kSnappyCompression implementation will 63 // efficiently detect that and will switch to uncompressed mode. 64 CompressionType compression = kSnappyCompression; 65 66 // Control over blocks (user data is stored in a set of blocks, and 67 // a block is the unit of reading from disk). 68 69 // If non-null, use the specified cache for blocks. 70 Cache* block_cache = nullptr; 71 }; 72 73 } // namespace table 74 } // namespace tensorflow 75 76 #endif // TENSORFLOW_CORE_LIB_IO_TABLE_OPTIONS_H_ 77