-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
searchlib/src/vespa/searchlib/bitcompression/raw_features_collector.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
|
||
#pragma once | ||
|
||
#include "compression.h" | ||
|
||
namespace search::bitcompression { | ||
|
||
class RawFeaturesCollector { | ||
uint64_t _start_offset; | ||
const uint64_t* _raw_features; | ||
|
||
void collect(search::index::DocIdAndFeatures& features, const uint64_t* compr) { | ||
auto& blob = features.blob(); | ||
auto* raw_features = _raw_features; | ||
while (raw_features < compr) { | ||
blob.emplace_back(*raw_features); | ||
++raw_features; | ||
} | ||
} | ||
|
||
public: | ||
RawFeaturesCollector(const DecodeContext64Base& dc, search::index::DocIdAndFeatures& features) | ||
: _start_offset(dc.getReadOffset()), | ||
_raw_features(dc.getCompr()) | ||
{ | ||
features.clear_features(dc.getBitOffset()); | ||
features.set_has_raw_data(true); | ||
} | ||
|
||
void collect_before_read_compr_buffer(const DecodeContext64Base& dc, search::index::DocIdAndFeatures& features) { | ||
collect(features, dc._valI); | ||
} | ||
|
||
void fixup_after_read_compr_buffer(const DecodeContext64Base& dc) { | ||
_raw_features = dc._valI; | ||
} | ||
|
||
void finish(const DecodeContext64Base& dc, search::index::DocIdAndFeatures& features) { | ||
collect(features, dc._valI); | ||
auto end_offset = dc.getReadOffset(); | ||
features.set_bit_length( end_offset - _start_offset); | ||
} | ||
}; | ||
|
||
} |