mirror of https://gitee.com/bigwinds/arangodb
Added a velocyPackFromFile to the VelocyPackHelper
This commit is contained in:
parent
1af985003d
commit
b492b154d8
|
@ -1368,17 +1368,6 @@ static bool FilenameStringComparator (std::string const& lhs, std::string const&
|
|||
return numLeft < numRight;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
///// @brief parses a json file to VelocyPack
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static std::shared_ptr<VPackBuilder> TRI_VelocyPackFile (char const* path) {
|
||||
size_t length;
|
||||
char* content = TRI_SlurpFile(TRI_UNKNOWN_MEM_ZONE, path, &length);
|
||||
// The Parser might THROW
|
||||
return VPackParser::fromJson(reinterpret_cast<uint8_t const*>(content), length);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class TRI_vocbase_col_t
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -1388,8 +1377,9 @@ void TRI_vocbase_col_t::toVelocyPack (VPackBuilder& builder,
|
|||
TRI_voc_tick_t maxTick) {
|
||||
TRI_ASSERT(! builder.isClosed());
|
||||
char* filename = TRI_Concatenate2File(_path, TRI_VOC_PARAMETER_FILE);
|
||||
std::string path = std::string(filename, strlen(filename));
|
||||
|
||||
std::shared_ptr<VPackBuilder> fileInfoBuilder = TRI_VelocyPackFile(filename);
|
||||
std::shared_ptr<VPackBuilder> fileInfoBuilder = triagens::basics::VelocyPackHelper::velocyPackFromFile(path);
|
||||
builder.add("parameters", fileInfoBuilder->slice());
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);
|
||||
|
||||
|
@ -1430,7 +1420,8 @@ void TRI_vocbase_col_t::toVelocyPackIndexes (VPackBuilder& builder,
|
|||
for (auto const& file : files) {
|
||||
if (regexec(&re, file.c_str(), (size_t) 0, nullptr, 0) == 0) {
|
||||
char* fqn = TRI_Concatenate2File(_path, file.c_str());
|
||||
std::shared_ptr<VPackBuilder> indexVPack = TRI_VelocyPackFile(fqn);
|
||||
std::string path = std::string(fqn, strlen(fqn));
|
||||
std::shared_ptr<VPackBuilder> indexVPack = triagens::basics::VelocyPackHelper::velocyPackFromFile(path);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, fqn);
|
||||
|
||||
VPackSlice const indexSlice = indexVPack->slice();
|
||||
|
|
|
@ -567,17 +567,6 @@ static bool SortCollections (VPackSlice const& l,
|
|||
return strcasecmp(leftName.c_str(), rightName.c_str()) < 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
///// @brief parses a json file to VelocyPack
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static std::shared_ptr<VPackBuilder> readVelocyPackFile (std::string path) {
|
||||
size_t length;
|
||||
char* content = TRI_SlurpFile(TRI_UNKNOWN_MEM_ZONE, path.c_str(), &length);
|
||||
// The Parser might THROW
|
||||
return VPackParser::fromJson(reinterpret_cast<uint8_t const*>(content), length);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief process all files from the input directory
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -615,7 +604,7 @@ static int ProcessInputDirectory (std::string& errorMsg) {
|
|||
}
|
||||
|
||||
const string fqn = InputDirectory + TRI_DIR_SEPARATOR_STR + file;
|
||||
std::shared_ptr<VPackBuilder> fileContentBuilder = readVelocyPackFile(fqn);
|
||||
std::shared_ptr<VPackBuilder> fileContentBuilder = triagens::basics::VelocyPackHelper::velocyPackFromFile(fqn);
|
||||
VPackSlice const fileContent = fileContentBuilder->slice();
|
||||
|
||||
if (! fileContent.isObject()) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/files.h"
|
||||
|
||||
using VelocyPackHelper = triagens::basics::VelocyPackHelper;
|
||||
|
||||
|
@ -91,6 +92,17 @@ TRI_json_t* VelocyPackHelper::velocyPackToJson (VPackSlice const& slice) {
|
|||
return JsonHelper::fromString(slice.toJson());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief parses a json file to VelocyPack
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::shared_ptr<VPackBuilder> VelocyPackHelper::velocyPackFromFile (std::string const& path) {
|
||||
size_t length;
|
||||
char* content = TRI_SlurpFile(TRI_UNKNOWN_MEM_ZONE, path.c_str(), &length);
|
||||
// The Parser might THROW
|
||||
return VPackParser::fromJson(reinterpret_cast<uint8_t const*>(content), length);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -113,6 +113,12 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static TRI_json_t* velocyPackToJson (VPackSlice const&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief parses a json file to VelocyPack
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static std::shared_ptr<VPackBuilder> velocyPackFromFile (std::string const& path);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue