1
0
Fork 0

small optimization for reading _rev values

This commit is contained in:
Jan Steemann 2016-05-31 12:26:41 +02:00
parent 8c0307becb
commit dfaefd2a01
3 changed files with 12 additions and 17 deletions

View File

@ -938,7 +938,11 @@ void Transaction::extractKeyAndRevFromDocument(VPackSlice slice,
} else if (*p == basics::VelocyPackHelper::RevAttribute) {
VPackSlice revSlice(p + 1);
if (revSlice.isString()) {
revisionId = basics::StringUtils::uint64(revSlice.copyString());
// use specialized conversion method for trusted input, that also
// does not create a temporary std::string
VPackValueLength revLength;
char const* rev = revSlice.getString(revLength);
revisionId = basics::StringUtils::uint64_trusted(rev, revLength);
} else if (revSlice.isNumber()) {
revisionId = revSlice.getNumericValue<TRI_voc_rid_t>();
}

View File

@ -475,10 +475,14 @@ static bool CalculateSize(TRI_df_marker_t const* marker, void* data,
// new or updated document
if (type == TRI_DF_MARKER_VPACK_DOCUMENT) {
VPackSlice const slice(reinterpret_cast<char const*>(marker) + DatafileHelper::VPackOffset(type));
VPackSlice slice(reinterpret_cast<char const*>(marker) + DatafileHelper::VPackOffset(type));
TRI_ASSERT(slice.isObject());
VPackSlice const keySlice(Transaction::extractKeyFromDocument(slice));
TRI_voc_rid_t const rid = std::stoull(slice.get(StaticStrings::RevString).copyString());
// use specialized conversion method for trusted input that does not
// create a temporary std::string
VPackSlice keySlice;
TRI_voc_rid_t rid;
Transaction::extractKeyAndRevFromDocument(slice, keySlice, rid);
// check if the document is still active
auto primaryIndex = document->primaryIndex();

View File

@ -49,19 +49,6 @@
using namespace arangodb;
using namespace arangodb::wal;
/// @brief convert a slice value into its numeric equivalent
template <typename T>
static inline T NumericValue(VPackSlice const& slice, char const* attribute) {
VPackSlice v = slice.get(attribute);
if (v.isString()) {
return static_cast<T>(std::stoull(v.copyString()));
}
if (v.isNumber()) {
return v.getNumber<T>();
}
return 0;
}
/// @brief return a reference to an existing datafile statistics struct
static inline DatafileStatisticsContainer& getDfi(CollectorCache* cache,
TRI_voc_fid_t fid) {