(data: &[u8])
| 50 | |
| 51 | impl TreeDeserialization for InvertedIndexItem { |
| 52 | fn deserialize(data: &[u8]) -> Self { |
| 53 | let mut offset = 0; |
| 54 | |
| 55 | let indices_len = u64::from_le_bytes(data[offset..offset + 8].try_into().unwrap()) as usize; |
| 56 | offset += 8; |
| 57 | // let mut indices = Vec::new(); |
| 58 | let len_of_index_bytes = usize::from_le_bytes(data[offset..offset + 8].try_into().unwrap()); |
| 59 | offset += 8; |
| 60 | |
| 61 | let start = offset; |
| 62 | let end = start + indices_len * len_of_index_bytes; |
| 63 | |
| 64 | let indices_bytes = &data[start..end]; |
| 65 | |
| 66 | let indices_chunks = indices_bytes.chunks(len_of_index_bytes); |
| 67 | |
| 68 | // for chunk in indices_chunks { |
| 69 | // let index = usize::from_le_bytes(chunk.try_into().unwrap()); |
| 70 | // indices.push(index); |
| 71 | // } |
| 72 | |
| 73 | let indices = indices_chunks |
| 74 | .map(|chunk| usize::from_le_bytes(chunk.try_into().unwrap())) |
| 75 | .collect(); |
| 76 | |
| 77 | offset = end; |
| 78 | |
| 79 | let ids_len = u64::from_le_bytes(data[offset..offset + 8].try_into().unwrap()) as usize; |
| 80 | offset += 8; |
| 81 | // let mut ids = Vec::new(); |
| 82 | let len_of_id_bytes = usize::from_le_bytes(data[offset..offset + 8].try_into().unwrap()); |
| 83 | offset += 8; |
| 84 | |
| 85 | // get them all and split the bytes into chunks |
| 86 | |
| 87 | let start = offset; |
| 88 | let end = start + ids_len * len_of_id_bytes; |
| 89 | let ids_bytes = &data[start..end]; |
| 90 | |
| 91 | let ids_chunks = ids_bytes.chunks(len_of_id_bytes); |
| 92 | |
| 93 | // for chunk in ids_chunks { |
| 94 | // let id = String::from_utf8(chunk.to_vec()).unwrap(); |
| 95 | // ids.push(id); |
| 96 | // } |
| 97 | let ids = ids_chunks |
| 98 | .map(|chunk| u128::from_le_bytes(chunk.try_into().unwrap())) |
| 99 | .collect(); |
| 100 | |
| 101 | InvertedIndexItem { indices, ids } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | pub struct InvertedIndex { |
nothing calls this directly
no outgoing calls
no test coverage detected