node-haystack Episode 6: Data Structure And Constants
来源:互联网 发布:蓝桥物流软件 编辑:程序博客网 时间:2024/05/15 04:07
The structure of block could be(data field not included):
#pragma pack(push)#pragma pack(2) // Make sure the data aligning at 2bytes boundary typedef struct { u128 key; u32 cookie; u16 tag; u16 flag; u32 size; u32 checkSum; } block_info_t;#pragma pack(pop)
And the element of index hash looks like:
typedef struct { u128 key; u32 cookie; u16 tag; u16 flag; u32 size; u64 pos;} block_index_value_t;using blk_idx_val_t = block_index_value_t;using block_index_map_t = unordered_map<std::string, blk_idx_val_t>;using bidx_map_t = block_index_map_t;
Some crucial constants:
const u32 MAX_ERROR = 128; /*!< Max errors can be tolerated. */const size_t PARSE_QUEUE_LEN = 8192; /*!< Quele length for paseing blocks. */const size_t READ_BUFFER_SIZE = 128 * 1024 * 1024; /*!< Read buffer size. */const static bfs::fstream::openmode FILE_MODE= bfs::fstream::in | bfs::fstream::out | bfs::fstream::binary; /*!< Default open mode for volume. */// File magic numbersstatic const u64 MAGIC_NUM_VOLUME = 0x6b63617453796148; //!< Magic number of volume, equals { 'H', 'a', 'y', 'S', 't', 'a', 'c', 'k' };static const u32 MAGIC_NUM_HEADER = 0x53796148; //!< Magic number of block header, equals { 'H', 'a', 'y', 'S' };static const u32 MAGIC_NUM_FOOTER = 0x6b636174; //!< Magic number of block footer, equals { 't', 'a', 'c', 'k' };const u16 FLAG_NORMAL = 0x0000; //!< Flag value for normal block.const u16 FLAG_REMOVE = 0x0001; //!< Falg value for deleted block.const u8 PADDING_VALUE[7] = { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC }; //!< Bytes for padding filling.
0 0
- node-haystack Episode 6: Data Structure And Constants
- node-haystack Episode 2: Asynchronous and Threading
- node-haystack Episode 1: What is it and why
- node-haystack Episode 8: Simple Recovery And Verification
- node-haystack Episode 5: Volume
- node-haystack Episode-4: Wrapper of libuv
- node-haystack Episode 7: Asynchronously manipulate blocks
- node-haystack Episode 9: Manipulate Volume
- node-haystack Episode 10: Node.js add-on
- node-haystack Episode 11: node object of Volume
- node-haystack Episode 3: Callback model in C++
- node-haystack Episode 12: problem of C++ closure
- node-haystack Episode - 12 : A Better Random Generator
- algorithm and data structure
- algorithm and data structure
- Data Structure and Algorithm
- android data structure And algorithm
- Algorithm and Data Structure Review
- Android网络状态之----ConnectivityManager
- C语言中类型转换问题
- Mac Intellij IDEA修改maven配置
- 网教10. 琪露诺的完美算数教室——⑨的统计I
- 无符号数除以2的幂
- node-haystack Episode 6: Data Structure And Constants
- SSM框架+Log4j框架搭建
- iOS 中Touch ID(指纹识别技术) 的使用
- Android安全加密:非对称加密
- 神经概率语言模型--吴立德教授深度学习课程笔记(十)
- React+Webpack快速上手指南
- 51nod1066Bash游戏
- vc++指定区域截屏
- 為Raspberry Pi 安裝Raspbian系統的詳細步驟 (Mac OS版本)