<commit_before>// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "fieldupdate.h"
#include <vespa/document/base/exceptions.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/datatype/documenttype.h>

namespace document {

typedef std::vector<ValueUpdate::CP> ValueUpdateList;

FieldUpdate::FieldUpdate(const Field& field)
    : Printable(),
      _field(field),
      _updates()
{
}

namespace {

    int readInt(ByteBuffer & buffer) {
        int fieldId;
        buffer.getIntNetwork(fieldId);
        return fieldId;
    }
}

FieldUpdate::FieldUpdate(const DocumentTypeRepo& repo, const DocumentType& type, ByteBuffer& buffer, int16_t version)
    : Printable(),
      _field(type.getField(readInt(buffer))),
      _updates()
{
    int numUpdates = readInt(buffer);
    _updates.reserve(numUpdates);
    const DataType& dataType = _field.getDataType();
    for(int i(0); i < numUpdates; i++) {
        _updates.emplace_back(ValueUpdate::createInstance(repo, dataType, buffer, version).release());
    }
}

FieldUpdate::FieldUpdate(const FieldUpdate &) = default;
FieldUpdate & FieldUpdate::operator = (const FieldUpdate &) = default;
FieldUpdate::~FieldUpdate() = default;

bool
FieldUpdate::operator==(const FieldUpdate& other) const
{
    if (_field != other._field) return false;
    if (_updates.size() != other._updates.size()) return false;
    for (uint32_t i=0, n=_updates.size(); i<n; ++i) {
        if (*_updates[i] != *other._updates[i]) return false;
    }<commit_msg>Better naming<commit_after>// Copyright 2017 <NAME>. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "fieldupdate.h"
#include <vespa/document/base/exceptions.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/datatype/documenttype.h>

namespace document {

typedef std::vector<ValueUpdate::CP> ValueUpdateList;

FieldUpdate::FieldUpdate(const Field& field)
    : Printable(),
      _field(field),
      _updates()
{
}

namespace {

int readInt(ByteBuffer & buffer) {
    int tmp;
    buffer.getIntNetwork(tmp);
    return tmp;
}

}

FieldUpdate::FieldUpdate(const DocumentTypeRepo& repo, const DocumentType& type, ByteBuffer& buffer, int16_t version)
    : Printable(),
      _field(type.getField(readInt(buffer))),
      _updates()
{
    int numUpdates = readInt(buffer);
    _updates.reserve(numUpdates);
    const DataType& dataType = _field.getDataType();
    for(int i(0); i < numUpdates; i++) {
        _updates.emplace_back(ValueUpdate::createInstance(repo, dataType, buffer, version).release());
    }
}

FieldUpdate::FieldUpdate(const FieldUpdate &) = default;
FieldUpdate & FieldUpdate::operator = (const FieldUpdate &) = default;
FieldUpdate::~FieldUpdate() = default;

bool
FieldUpdate::operator==(const FieldUpdate& other) const
{
    if (_field != other._field) return false;
    if (_updates.size() != other._updates.size()) return false;
    for (uint32_t i=0, n=_updates.size(); i<n; ++i) {
        if (*_updates[i] != *other._updates[i]) return false;
    }
{'fraction_non_alphanumeric': 0.13597191190552185, 'fraction_numerical': 0.007660389403127992, 'mean_word_length': 4.403448275862069, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '129336', 'n_tokens_mistral': 1012, 'n_tokens_neox': 993, 'n_words': 228}