TightCompaction_v2.cpp 889 B

1234567891011121314151617181920212223242526
  1. #include "TightCompaction_v2.hpp"
  2. void compute_LS_distances(uint64_t N, unsigned char *buffer_start,
  3. size_t block_size, bool *selected_list, uint64_t *LS_distance){
  4. //rp_end = index in the bucket where the current last real packet is mapped to
  5. uint64_t rp_end = 0;
  6. unsigned char *buffer_ptr = buffer_start;
  7. // Linear scan over packets of input bucket while updating LS_distance with distance to left shift
  8. FOAV_SAFE2_CNTXT(TC_compute_LS_distances, N, block_size)
  9. for(uint64_t k=0; k<N; k++) {
  10. uint8_t real_flag = (selected_list[k]==1);
  11. uint64_t shift_distance = k-rp_end;
  12. // Oblivious: If real_flag: ls_distance[k]=shift_distance
  13. // rp_end=rp_end+1
  14. oset_value(&(LS_distance[k]), shift_distance, real_flag);
  15. rp_end+=real_flag;
  16. buffer_ptr+=block_size;
  17. FOAV_SAFE2_CNTXT(TC_compute_LS_distances, N, k)
  18. }
  19. }