this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactor next_forward

garrison 97d1e6f5 ea778c64

+40 -31
+40 -31
lib/btree/iterator.ex
··· 186 186 current_i = current_i + 1 187 187 case type_byte do 188 188 0x00 -> 189 - page_size = byte_size(current_page) 190 - pointer_count = pair_count 191 - key_count = pointer_count - 1 192 - slots_start = page_size - (key_count * c_page_slot_entry_bytes()) - c_page_trailer_bytes() 193 - pointers_start = slots_start - (pointer_count * c_inner_pointer_bytes()) 194 - 195 - << 196 - _::binary-size(pointers_start + (current_i * c_inner_pointer_bytes())), 197 - child_index::integer-64, 198 - child_checksum::binary-16, 199 - _::binary, 200 - >> = current_page 189 + child_page = inner_child_page_at(it.btree.page_store, current_page, pair_count, current_i) 201 190 202 - child_page = BTree.read_page(it.btree.page_store, child_index, child_checksum) 203 191 it = %{it | 204 192 page_stack: [{current_i, current_page} | it.page_stack], 205 193 current_page: child_page, ··· 209 197 next_forward(it) 210 198 211 199 0x01 -> 212 - page_size = byte_size(current_page) 213 - slots_start = page_size - (pair_count * c_page_slot_entry_bytes()) - c_page_trailer_bytes() 214 - 215 - << 216 - _prefix::binary-size(slots_start + (current_i * c_page_slot_entry_bytes())), 217 - pair_offset::integer-16, 218 - _rest::binary, 219 - >> = current_page 220 - 221 - << 222 - _prefix::binary-size(pair_offset), 223 - key_size::integer-16, 224 - value_size::integer-16, 225 - key::binary-size(key_size), 226 - value::binary-size(value_size), 227 - _rest::binary, 228 - >> = current_page 229 - current_pair = {key, value} 200 + current_pair = leaf_pair_at(current_page, pair_count, current_i) 230 201 231 202 %{it | 232 203 current_i: current_i, ··· 250 221 next_forward(it) 251 222 end 252 223 end 224 + end 225 + 226 + defp inner_child_page_at(page_store, page_data, pointer_count, i) do 227 + page_size = byte_size(page_data) 228 + key_count = pointer_count - 1 229 + slots_start = page_size - (key_count * c_page_slot_entry_bytes()) - c_page_trailer_bytes() 230 + pointers_start = slots_start - (pointer_count * c_inner_pointer_bytes()) 231 + 232 + << 233 + _::binary-size(pointers_start + (i * c_inner_pointer_bytes())), 234 + child_index::integer-64, 235 + child_checksum::binary-16, 236 + _::binary, 237 + >> = page_data 238 + 239 + BTree.read_page(page_store, child_index, child_checksum) 240 + end 241 + 242 + defp leaf_pair_at(page_data, pair_count, i) do 243 + page_size = byte_size(page_data) 244 + slots_start = page_size - (pair_count * c_page_slot_entry_bytes()) - c_page_trailer_bytes() 245 + 246 + << 247 + _prefix::binary-size(slots_start + (i * c_page_slot_entry_bytes())), 248 + pair_offset::integer-16, 249 + _rest::binary, 250 + >> = page_data 251 + 252 + << 253 + _prefix::binary-size(pair_offset), 254 + key_size::integer-16, 255 + value_size::integer-16, 256 + key::binary-size(key_size), 257 + value::binary-size(value_size), 258 + _rest::binary, 259 + >> = page_data 260 + 261 + {key, value} 253 262 end 254 263 end