node-haystack Episode 6: Data Structure And Constants
2016-09-10 13:47
573 查看
The structure of block could be(data field not included):
And the element of index hash looks like:
Some crucial constants:
#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 numbers static 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.
相关文章推荐
- node-haystack Episode 3: Callback model in C++
- node-haystack Episode 12: problem of C++ closure
- node-haystack Episode - 12 : A Better Random Generator
- node-haystack Episode-4: Wrapper of libuv
- node-haystack Episode 10: Node.js add-on
- node-haystack Episode 1: What is it and why
- node-haystack Episode 5: Volume
- node-haystack Episode 11: node object of Volume
- node-haystack Episode 2: Asynchronous and Threading
- node-haystack Episode 7: Asynchronously manipulate blocks
- node-haystack Episode 8: Simple Recovery And Verification
- node-haystack Episode 9: Manipulate Volume
- NodeJS+Node Inspector简单使用
- JumpNode递归和非递归访问
- node.js微信公众平台开发教程
- node.js版本管理工具n无效的原理和解决方法
- node.js操作MySQL
- IntelliJ IDEA中Android项目node-sass cannot download ***binding.node
- 从零开始node.js入门项目(二)
- ajax请求node.js接口时出现 No 'Access-Control-Allow-Origin' header is present on the requested resource错误