2121#include < wchar.h>
2222#include < unistd.h> // for access()
2323
24+ #include < unordered_map>
25+
2426#include " univ.i"
2527#include " ut0byte.h"
2628#include " ut0rbt.h"
@@ -218,6 +220,12 @@ typedef struct __pmem_recv_line PMEM_RECV_LINE;
218220struct __pmem_space_t ;
219221typedef struct __pmem_space_t PMEM_SPACE;
220222
223+ // typedef std::map<uint64_t, PMEM_PAGE_LOG_BLOCK*, std::less<uint64_t>, ut_allocator<std::pair<uint64_t, PMEM_PAGE_LOG_BLOCK*>>> OFFSET_MAP;
224+ // typedef std::map<uint64_t, PMEM_PAGE_LOG_BLOCK*> OFFSET_MAP;
225+
226+ // typedef std::unordered_map<uint64_t, PMEM_PAGE_LOG_BLOCK*, std::hash<uint64_t>, std::equal_to<uint64_t>> KEY_MAP;
227+ // typedef std::unordered_map<uint64_t, PMEM_PAGE_LOG_BLOCK*> KEY_MAP;
228+
221229// End Per-Page Logging
222230
223231// ////////////////////////////////////////////////
@@ -578,6 +586,14 @@ struct plog_hash_t {
578586 hash_node_t addr_hash;/* !< hash node in the hash bucket chain */
579587};
580588
589+ using OFFSET_MAP =
590+ std::map<uint64_t , PMEM_PAGE_LOG_BLOCK*, std::less<uint64_t >,
591+ ut_allocator<std::pair<uint64_t , PMEM_PAGE_LOG_BLOCK*>>>;
592+ //
593+ using KEY_MAP =
594+ std::unordered_map<uint64_t , PMEM_PAGE_LOG_BLOCK*, std::hash<uint64_t >, std::equal_to<uint64_t >,
595+ ut_allocator<std::pair<uint64_t , PMEM_PAGE_LOG_BLOCK*>>>;
596+
581597/*
582598 * A hashed line has array of log blocks share the same hashed value and log buffer
583599 * */
@@ -597,7 +613,7 @@ struct __pmem_page_log_hashed_line {
597613 uint64_t write_diskaddr; // diskaddr that log recs are durable write write_diskaddr < diskaddr
598614
599615 /* for checkpoint*/
600- uint32_t oldest_block_off ;// offset of the block has min (start_diskaddr + start_off)
616+ uint32_t oldest_block_id ;// offset of the oldest block (start_diskaddr + start_off)
601617 uint64_t ckpt_lsn;
602618 bool is_req_checkpoint;
603619
@@ -615,10 +631,17 @@ struct __pmem_page_log_hashed_line {
615631 long long * bit_arr; // bit array to manage free slots
616632 uint16_t n_bit_blocks; // number of block in bit_arr
617633
618- /* Hash table*/
619- hash_table_t * addr_hash; // hash the log block in this line
620-
621- std::map<uint64_t , uint32_t >* offset_map;
634+ /* DRAM data structures: (1) hashtables and (2) recovery objects.
635+ * */
636+ KEY_MAP* key_map; // hash the log block in this line
637+ // std::unordered_map<uint64_t, PMEM_PAGE_LOG_BLOCK*>* key_map;
638+ // std::map<uint64_t, PMEM_PAGE_LOG_BLOCK*>* key_map;
639+
640+ OFFSET_MAP* offset_map;
641+ // std::map<uint64_t, PMEM_PAGE_LOG_BLOCK*> * offset_map;
642+ // /*Hash table*/
643+ // hash_table_t* addr_hash; //hash the log block in this line
644+ // std::map<uint64_t, uint32_t>* offset_map;
622645
623646 /* PART 3: recovery*/
624647 // Alternative to recv_sys_t in InnoDB, allocate in DRAM when recovery
@@ -1151,7 +1174,8 @@ pm_page_part_log_hash_free(
11511174 PMEMobjpool* pop,
11521175 PMEM_PAGE_PART_LOG* ppl);
11531176
1154- plog_hash_t *
1177+ // plog_hash_t*
1178+ PMEM_PAGE_LOG_BLOCK*
11551179pm_ppl_hash_get (
11561180 PMEMobjpool* pop,
11571181 PMEM_PAGE_PART_LOG* ppl,
@@ -1167,24 +1191,25 @@ pm_ppl_hash_get(
11671191 * @param[in] idx index of the block on the line
11681192 * @return: the hash item added
11691193 * */
1170- static inline void
1171- pm_ppl_hash_add (
1172- PMEM_PAGE_LOG_HASHED_LINE* pline,
1173- PMEM_PAGE_LOG_BLOCK* plog_block,
1174- uint32_t idx
1175- )
1176- {
1177-
1178- plog_hash_t * item;
1179-
1180- item = (plog_hash_t *) malloc (sizeof (plog_hash_t ));
1181- item->key = plog_block->key ;
1182- item->block_off = idx;
1183- HASH_INSERT (plog_hash_t , addr_hash, pline->addr_hash , plog_block->key , item);
1184-
1185- }
1186-
1187- plog_hash_t *
1194+ // static inline void
1195+ // pm_ppl_hash_add(
1196+ // PMEM_PAGE_LOG_HASHED_LINE* pline,
1197+ // PMEM_PAGE_LOG_BLOCK* plog_block,
1198+ // uint32_t idx
1199+ // )
1200+ // {
1201+ //
1202+ // plog_hash_t* item;
1203+ //
1204+ // item = (plog_hash_t*) malloc(sizeof(plog_hash_t));
1205+ // item->key = plog_block->key;
1206+ // item->block_off = idx;
1207+ // HASH_INSERT(plog_hash_t, addr_hash, pline->addr_hash, plog_block->key, item);
1208+ //
1209+ // }
1210+
1211+ // plog_hash_t*
1212+ PMEM_PAGE_LOG_BLOCK*
11881213pm_ppl_hash_check_and_add (
11891214 PMEMobjpool* pop,
11901215 PMEM_PAGE_PART_LOG* ppl,
0 commit comments