• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

arangodb / velocypack / 3998645281

pending completion
3998645281

Pull #148

github

GitHub
Merge b1e3c924b into 5a28b6413
Pull Request #148: use separate namespace for xxh functions

0 of 5107 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/AttributeTranslator.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
/// DISCLAIMER
3
///
4
/// Copyright 2014-2020 ArangoDB GmbH, Cologne, Germany
5
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
6
///
7
/// Licensed under the Apache License, Version 2.0 (the "License");
8
/// you may not use this file except in compliance with the License.
9
/// You may obtain a copy of the License at
10
///
11
///     http://www.apache.org/licenses/LICENSE-2.0
12
///
13
/// Unless required by applicable law or agreed to in writing, software
14
/// distributed under the License is distributed on an "AS IS" BASIS,
15
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
/// See the License for the specific language governing permissions and
17
/// limitations under the License.
18
///
19
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
20
///
21
/// @author Max Neunhoeffer
22
/// @author Jan Steemann
23
////////////////////////////////////////////////////////////////////////////////
24

25
#include "velocypack/AttributeTranslator.h"
26
#include "velocypack/Builder.h"
27
#include "velocypack/Iterator.h"
28
#include "velocypack/Options.h"
29
#include "velocypack/Slice.h"
30
#include "velocypack/Value.h"
31

32
using namespace arangodb::velocypack;
33

34
AttributeTranslator::AttributeTranslator() : _count(0) {}
×
35

36
AttributeTranslator::~AttributeTranslator() {}
×
37

38
void AttributeTranslator::add(std::string_view key, uint64_t id) {
×
39
  if (_builder == nullptr) {
×
40
    _builder = std::make_unique<Builder>();
×
41
    _builder->add(Value(ValueType::Object));
×
42
  }
43

44
  _builder->add(key, Value(id));
×
45
  _count++;
×
46
}
×
47

48
void AttributeTranslator::seal() {
×
49
  if (_builder == nullptr) {
×
50
    return;
×
51
  }
52

53
  _builder->close();
×
54

55
  Slice s(_builder->slice());
×
56

57
  ObjectIterator it(s, /*useSequentialIteration*/ true);
×
58

59
  while (it.valid()) {
×
60
    Slice key(it.key(false));
×
61
    VELOCYPACK_ASSERT(key.isString());
×
62

63
    // insert into string and char lookup maps
64
    _keyToId.emplace(key.stringView(), it.value().begin());
×
65
    // insert into id to slice lookup map
66
    _idToKey.emplace(it.value().getUInt(), key.begin());
×
67
    it.next();
×
68
  }
69
}
70

71
AttributeTranslatorScope::AttributeTranslatorScope(
×
72
    AttributeTranslator* translator)
×
73
    : _old(Options::Defaults.attributeTranslator) {
×
74
  Options::Defaults.attributeTranslator = translator;
×
75
}
×
76

77
AttributeTranslatorScope::~AttributeTranslatorScope() { revert(); }
×
78

79
// prematurely revert the change
80
void AttributeTranslatorScope::revert() noexcept {
×
81
  Options::Defaults.attributeTranslator = _old;
×
82
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc