21
21
#include < wchar.h>
22
22
#include < unistd.h> // for access()
23
23
24
+ #include < unordered_map>
25
+
24
26
#include " univ.i"
25
27
#include " ut0byte.h"
26
28
#include " ut0rbt.h"
@@ -218,6 +220,12 @@ typedef struct __pmem_recv_line PMEM_RECV_LINE;
218
220
struct __pmem_space_t ;
219
221
typedef struct __pmem_space_t PMEM_SPACE;
220
222
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
+
221
229
// End Per-Page Logging
222
230
223
231
// ////////////////////////////////////////////////
@@ -578,6 +586,14 @@ struct plog_hash_t {
578
586
hash_node_t addr_hash;/* !< hash node in the hash bucket chain */
579
587
};
580
588
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
+
581
597
/*
582
598
* A hashed line has array of log blocks share the same hashed value and log buffer
583
599
* */
@@ -597,7 +613,7 @@ struct __pmem_page_log_hashed_line {
597
613
uint64_t write_diskaddr; // diskaddr that log recs are durable write write_diskaddr < diskaddr
598
614
599
615
/* 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)
601
617
uint64_t ckpt_lsn;
602
618
bool is_req_checkpoint;
603
619
@@ -615,10 +631,17 @@ struct __pmem_page_log_hashed_line {
615
631
long long * bit_arr; // bit array to manage free slots
616
632
uint16_t n_bit_blocks; // number of block in bit_arr
617
633
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;
622
645
623
646
/* PART 3: recovery*/
624
647
// Alternative to recv_sys_t in InnoDB, allocate in DRAM when recovery
@@ -1151,7 +1174,8 @@ pm_page_part_log_hash_free(
1151
1174
PMEMobjpool* pop,
1152
1175
PMEM_PAGE_PART_LOG* ppl);
1153
1176
1154
- plog_hash_t *
1177
+ // plog_hash_t*
1178
+ PMEM_PAGE_LOG_BLOCK*
1155
1179
pm_ppl_hash_get (
1156
1180
PMEMobjpool* pop,
1157
1181
PMEM_PAGE_PART_LOG* ppl,
@@ -1167,24 +1191,25 @@ pm_ppl_hash_get(
1167
1191
* @param[in] idx index of the block on the line
1168
1192
* @return: the hash item added
1169
1193
* */
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*
1188
1213
pm_ppl_hash_check_and_add (
1189
1214
PMEMobjpool* pop,
1190
1215
PMEM_PAGE_PART_LOG* ppl,
0 commit comments