#include "components/zucchini/equivalence_map.h"
#include <deque>
#include <tuple>
#include <utility>
#include <vector>
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "components/zucchini/encoded_view.h"
#include "components/zucchini/patch_reader.h"
#include "components/zucchini/suffix_array.h"
namespace zucchini {
namespace {
constexpr uint64_t kSeedSelectionTotalVisitLengthQuota = …;
constexpr offset_t kBackwardsExtendLimit = …;
}
double GetTokenSimilarity(
const ImageIndex& old_image_index,
const ImageIndex& new_image_index,
const std::vector<TargetsAffinity>& targets_affinities,
offset_t src,
offset_t dst) { … }
double GetEquivalenceSimilarity(
const ImageIndex& old_image_index,
const ImageIndex& new_image_index,
const std::vector<TargetsAffinity>& targets_affinities,
const Equivalence& equivalence) { … }
EquivalenceCandidate ExtendEquivalenceForward(
const ImageIndex& old_image_index,
const ImageIndex& new_image_index,
const std::vector<TargetsAffinity>& targets_affinities,
const EquivalenceCandidate& candidate,
double min_similarity) { … }
EquivalenceCandidate ExtendEquivalenceBackward(
const ImageIndex& old_image_index,
const ImageIndex& new_image_index,
const std::vector<TargetsAffinity>& targets_affinities,
const EquivalenceCandidate& candidate,
double min_similarity) { … }
EquivalenceCandidate VisitEquivalenceSeed(
const ImageIndex& old_image_index,
const ImageIndex& new_image_index,
const std::vector<TargetsAffinity>& targets_affinities,
offset_t src,
offset_t dst,
double min_similarity) { … }
OffsetMapper::OffsetMapper(std::deque<Equivalence>&& equivalences,
offset_t old_image_size,
offset_t new_image_size)
: … { … }
OffsetMapper::OffsetMapper(EquivalenceSource&& equivalence_source,
offset_t old_image_size,
offset_t new_image_size)
: … { … }
OffsetMapper::OffsetMapper(const EquivalenceMap& equivalence_map,
offset_t old_image_size,
offset_t new_image_size)
: … { … }
OffsetMapper::~OffsetMapper() = default;
offset_t OffsetMapper::NaiveExtendedForwardProject(const Equivalence& unit,
offset_t offset) const { … }
offset_t OffsetMapper::ExtendedForwardProject(offset_t offset) const { … }
void OffsetMapper::ForwardProjectAll(std::deque<offset_t>* offsets) const { … }
void OffsetMapper::PruneEquivalencesAndSortBySource(
std::deque<Equivalence>* equivalences) { … }
EquivalenceMap::EquivalenceMap() = default;
EquivalenceMap::EquivalenceMap(std::vector<EquivalenceCandidate>&& equivalences)
: … { … }
EquivalenceMap::EquivalenceMap(EquivalenceMap&&) = default;
EquivalenceMap::~EquivalenceMap() = default;
void EquivalenceMap::Build(
const std::vector<offset_t>& old_sa,
const EncodedView& old_view,
const EncodedView& new_view,
const std::vector<TargetsAffinity>& targets_affinities,
double min_similarity) { … }
void EquivalenceMap::CreateCandidates(
const std::vector<offset_t>& old_sa,
const EncodedView& old_view,
const EncodedView& new_view,
const std::vector<TargetsAffinity>& targets_affinities,
double min_similarity) { … }
void EquivalenceMap::SortByDestination() { … }
void EquivalenceMap::Prune(
const EncodedView& old_view,
const EncodedView& new_view,
const std::vector<TargetsAffinity>& target_affinities,
double min_similarity) { … }
}