mirror of https://gitee.com/bigwinds/arangodb
Removed TRI_json_t from VocBase/document-collection. YaY
This commit is contained in:
parent
95424f16ca
commit
9f24c7ad2f
|
@ -57,6 +57,10 @@
|
|||
#include "Wal/Marker.h"
|
||||
#include "Wal/Slots.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/Value.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
using namespace triagens::arango;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -613,25 +617,29 @@ int TRI_AddOperationTransaction(TRI_transaction_t*,
|
|||
static int FillIndex(triagens::arango::Transaction*, TRI_document_collection_t*,
|
||||
triagens::arango::Index*);
|
||||
|
||||
static int CapConstraintFromJson(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*, TRI_json_t const*,
|
||||
TRI_idx_iid_t, triagens::arango::Index**);
|
||||
static int CapConstraintFromVelocyPack(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*,
|
||||
VPackSlice const&, TRI_idx_iid_t,
|
||||
triagens::arango::Index**);
|
||||
|
||||
static int GeoIndexFromJson(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*, TRI_json_t const*,
|
||||
TRI_idx_iid_t, triagens::arango::Index**);
|
||||
static int GeoIndexFromVelocyPack(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*, VPackSlice const&,
|
||||
TRI_idx_iid_t, triagens::arango::Index**);
|
||||
|
||||
static int HashIndexFromJson(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*, TRI_json_t const*,
|
||||
TRI_idx_iid_t, triagens::arango::Index**);
|
||||
static int HashIndexFromVelocyPack(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*,
|
||||
VPackSlice const&, TRI_idx_iid_t,
|
||||
triagens::arango::Index**);
|
||||
|
||||
static int SkiplistIndexFromJson(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*, TRI_json_t const*,
|
||||
TRI_idx_iid_t, triagens::arango::Index**);
|
||||
static int SkiplistIndexFromVelocyPack(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*,
|
||||
VPackSlice const&, TRI_idx_iid_t,
|
||||
triagens::arango::Index**);
|
||||
|
||||
static int FulltextIndexFromJson(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*, TRI_json_t const*,
|
||||
TRI_idx_iid_t, triagens::arango::Index**);
|
||||
static int FulltextIndexFromVelocyPack(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*,
|
||||
VPackSlice const&, TRI_idx_iid_t,
|
||||
triagens::arango::Index**);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief hashes a datafile identifier
|
||||
|
@ -2052,8 +2060,8 @@ static bool OpenIndexIterator(char const* filename, void* data) {
|
|||
triagens::arango::Transaction* trx = ctx->trx;
|
||||
TRI_document_collection_t* collection = ctx->collection;
|
||||
|
||||
int res =
|
||||
TRI_FromVelocyPackIndexDocumentCollection(trx, collection, description, nullptr);
|
||||
int res = TRI_FromVelocyPackIndexDocumentCollection(trx, collection,
|
||||
description, nullptr);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// error was already printed if we get here
|
||||
|
@ -2654,43 +2662,29 @@ size_t TRI_DocumentIteratorDocumentCollection(
|
|||
int TRI_FromVelocyPackIndexDocumentCollection(
|
||||
triagens::arango::Transaction* trx, TRI_document_collection_t* document,
|
||||
VPackSlice const& slice, triagens::arango::Index** idx) {
|
||||
std::unique_ptr<TRI_json_t> json(
|
||||
triagens::basics::VelocyPackHelper::velocyPackToJson(slice));
|
||||
return TRI_FromJsonIndexDocumentCollection(trx, document, json.get(), idx);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create an index, based on a JSON description
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_FromJsonIndexDocumentCollection(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_json_t const* json,
|
||||
triagens::arango::Index** idx) {
|
||||
TRI_ASSERT(TRI_IsObjectJson(json));
|
||||
TRI_ASSERT(slice.isObject());
|
||||
|
||||
if (idx != nullptr) {
|
||||
*idx = nullptr;
|
||||
}
|
||||
|
||||
// extract the type
|
||||
TRI_json_t const* type = TRI_LookupObjectJson(json, "type");
|
||||
VPackSlice type = slice.get("type");
|
||||
|
||||
if (!TRI_IsStringJson(type)) {
|
||||
if (!type.isString()) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
char const* typeStr = type->_value._string.data;
|
||||
std::string typeStr = type.copyString();
|
||||
|
||||
// extract the index identifier
|
||||
TRI_json_t const* iis = TRI_LookupObjectJson(json, "id");
|
||||
VPackSlice iis = slice.get("id");
|
||||
|
||||
TRI_idx_iid_t iid;
|
||||
if (TRI_IsNumberJson(iis)) {
|
||||
iid = static_cast<TRI_idx_iid_t>(iis->_value._number);
|
||||
} else if (TRI_IsStringJson(iis)) {
|
||||
iid = (TRI_idx_iid_t)TRI_UInt64String2(iis->_value._string.data,
|
||||
iis->_value._string.length - 1);
|
||||
if (iis.isNumber()) {
|
||||
iid = iis.getNumericValue<TRI_idx_iid_t>();
|
||||
} else if (iis.isString()) {
|
||||
std::string tmp = iis.copyString();
|
||||
iid = static_cast<TRI_idx_iid_t>(TRI_UInt64String(tmp.c_str()));
|
||||
} else {
|
||||
LOG_ERROR("ignoring index, index identifier could not be located");
|
||||
|
||||
|
@ -2702,49 +2696,42 @@ int TRI_FromJsonIndexDocumentCollection(triagens::arango::Transaction* trx,
|
|||
// ...........................................................................
|
||||
// CAP CONSTRAINT
|
||||
// ...........................................................................
|
||||
|
||||
if (TRI_EqualString(typeStr, "cap")) {
|
||||
return CapConstraintFromJson(trx, document, json, iid, idx);
|
||||
if (typeStr == "cap") {
|
||||
return CapConstraintFromVelocyPack(trx, document, slice, iid, idx);
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
// GEO INDEX (list or attribute)
|
||||
// ...........................................................................
|
||||
|
||||
else if (TRI_EqualString(typeStr, "geo1") ||
|
||||
TRI_EqualString(typeStr, "geo2")) {
|
||||
return GeoIndexFromJson(trx, document, json, iid, idx);
|
||||
if (typeStr == "geo1" || typeStr == "geo2") {
|
||||
return GeoIndexFromVelocyPack(trx, document, slice, iid, idx);
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
// HASH INDEX
|
||||
// ...........................................................................
|
||||
|
||||
else if (TRI_EqualString(typeStr, "hash")) {
|
||||
return HashIndexFromJson(trx, document, json, iid, idx);
|
||||
if (typeStr == "hash") {
|
||||
return HashIndexFromVelocyPack(trx, document, slice, iid, idx);
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
// SKIPLIST INDEX
|
||||
// ...........................................................................
|
||||
|
||||
else if (TRI_EqualString(typeStr, "skiplist")) {
|
||||
return SkiplistIndexFromJson(trx, document, json, iid, idx);
|
||||
if (typeStr == "skiplist") {
|
||||
return SkiplistIndexFromVelocyPack(trx, document, slice, iid, idx);
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
// FULLTEXT INDEX
|
||||
// ...........................................................................
|
||||
|
||||
else if (TRI_EqualString(typeStr, "fulltext")) {
|
||||
return FulltextIndexFromJson(trx, document, json, iid, idx);
|
||||
if (typeStr == "fulltext") {
|
||||
return FulltextIndexFromVelocyPack(trx, document, slice, iid, idx);
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
// EDGES INDEX
|
||||
// ...........................................................................
|
||||
|
||||
else if (TRI_EqualString(typeStr, "edge")) {
|
||||
if (typeStr == "edge") {
|
||||
// we should never get here, as users cannot create their own edge indexes
|
||||
LOG_ERROR(
|
||||
"logic error. there should never be a JSON file describing an edges "
|
||||
|
@ -2752,10 +2739,12 @@ int TRI_FromJsonIndexDocumentCollection(triagens::arango::Transaction* trx,
|
|||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
// default:
|
||||
LOG_WARNING(
|
||||
"index type '%s' is not supported in this version of ArangoDB and is "
|
||||
"ignored",
|
||||
typeStr);
|
||||
typeStr.c_str());
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -3077,7 +3066,6 @@ TRI_document_collection_t* TRI_OpenDocumentCollection(TRI_vocbase_t* vocbase,
|
|||
// check if we can generate the key generator
|
||||
std::shared_ptr<arangodb::velocypack::Buffer<uint8_t> const> buffer =
|
||||
collection->_info.keyOptions();
|
||||
std::unique_ptr<TRI_json_t> json;
|
||||
|
||||
VPackSlice slice;
|
||||
if (buffer.get() != nullptr) {
|
||||
|
@ -3180,37 +3168,27 @@ typedef struct pid_name_s {
|
|||
} pid_name_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts extracts a field list from a json object
|
||||
/// @brief converts extracts a field list from a VelocyPack object
|
||||
/// Does not copy any data, caller has to make sure that data
|
||||
/// in slice stays valid until this return value is destroyed.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static TRI_json_t* ExtractFields(TRI_json_t const* json, size_t* fieldCount,
|
||||
TRI_idx_iid_t iid) {
|
||||
TRI_json_t* fld = TRI_LookupObjectJson(json, "fields");
|
||||
|
||||
if (!TRI_IsArrayJson(fld)) {
|
||||
static VPackSlice ExtractFields(VPackSlice const& slice, TRI_idx_iid_t iid) {
|
||||
VPackSlice fld = slice.get("fields");
|
||||
if (!fld.isArray()) {
|
||||
LOG_ERROR("ignoring index %llu, 'fields' must be an array",
|
||||
(unsigned long long)iid);
|
||||
|
||||
TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||
return nullptr;
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
*fieldCount = TRI_LengthArrayJson(fld);
|
||||
|
||||
for (size_t j = 0; j < *fieldCount; ++j) {
|
||||
TRI_json_t* sub =
|
||||
static_cast<TRI_json_t*>(TRI_AtVector(&fld->_value._objects, j));
|
||||
|
||||
if (!TRI_IsStringJson(sub)) {
|
||||
for (auto const& sub : VPackArrayIterator(fld)) {
|
||||
if (!sub.isString()) {
|
||||
LOG_ERROR(
|
||||
"ignoring index %llu, 'fields' must be an array of attribute paths",
|
||||
(unsigned long long)iid);
|
||||
|
||||
TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||
return nullptr;
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
return fld;
|
||||
}
|
||||
|
||||
|
@ -3513,9 +3491,9 @@ static triagens::arango::Index* LookupPathIndexDocumentCollection(
|
|||
/// @brief restores a path based index (template)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int PathBasedIndexFromJson(
|
||||
static int PathBasedIndexFromVelocyPack(
|
||||
triagens::arango::Transaction* trx, TRI_document_collection_t* document,
|
||||
TRI_json_t const* definition, TRI_idx_iid_t iid,
|
||||
VPackSlice const& definition, TRI_idx_iid_t iid,
|
||||
triagens::arango::Index* (*creator)(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*,
|
||||
std::vector<std::string> const&,
|
||||
|
@ -3526,12 +3504,13 @@ static int PathBasedIndexFromJson(
|
|||
}
|
||||
|
||||
// extract fields
|
||||
size_t fieldCount;
|
||||
TRI_json_t const* fld = ExtractFields(definition, &fieldCount, iid);
|
||||
|
||||
if (fld == nullptr) {
|
||||
return TRI_errno();
|
||||
VPackSlice fld;
|
||||
try {
|
||||
fld = ExtractFields(definition, iid);
|
||||
} catch (triagens::basics::Exception const& e) {
|
||||
return TRI_set_errno(e.code());
|
||||
}
|
||||
VPackValueLength fieldCount = fld.length();
|
||||
|
||||
// extract the list of fields
|
||||
if (fieldCount < 1) {
|
||||
|
@ -3542,32 +3521,32 @@ static int PathBasedIndexFromJson(
|
|||
}
|
||||
|
||||
// determine if the index is unique or non-unique
|
||||
TRI_json_t const* bv = TRI_LookupObjectJson(definition, "unique");
|
||||
VPackSlice bv = definition.get("unique");
|
||||
|
||||
if (!TRI_IsBooleanJson(bv)) {
|
||||
if (!bv.isBoolean()) {
|
||||
LOG_ERROR(
|
||||
"ignoring index %llu, could not determine if unique or non-unique",
|
||||
(unsigned long long)iid);
|
||||
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
bool unique = bv->_value._boolean;
|
||||
bool unique = bv.getBoolean();
|
||||
|
||||
// determine sparsity
|
||||
bool sparse = false;
|
||||
|
||||
bv = TRI_LookupObjectJson(definition, "sparse");
|
||||
bv = definition.get("sparse");
|
||||
|
||||
if (TRI_IsBooleanJson(bv)) {
|
||||
sparse = bv->_value._boolean;
|
||||
if (bv.isBoolean()) {
|
||||
sparse = bv.getBoolean();
|
||||
} else {
|
||||
// no sparsity information given for index
|
||||
// now use pre-2.5 defaults: unique hash indexes were sparse, all other
|
||||
// indexes were non-sparse
|
||||
bool isHashIndex = false;
|
||||
TRI_json_t const* typeJson = TRI_LookupObjectJson(definition, "type");
|
||||
if (TRI_IsStringJson(typeJson)) {
|
||||
isHashIndex = (strcmp(typeJson->_value._string.data, "hash") == 0);
|
||||
VPackSlice typeSlice = definition.get("type");
|
||||
if (typeSlice.isString()) {
|
||||
isHashIndex = typeSlice.copyString() == "hash";
|
||||
}
|
||||
|
||||
if (isHashIndex && unique) {
|
||||
|
@ -3581,13 +3560,8 @@ static int PathBasedIndexFromJson(
|
|||
attributes.reserve(fieldCount);
|
||||
|
||||
// find fields
|
||||
for (size_t j = 0; j < fieldCount; ++j) {
|
||||
auto fieldStr =
|
||||
static_cast<TRI_json_t const*>(TRI_AtVector(&fld->_value._objects, j));
|
||||
|
||||
attributes.emplace_back(std::string(fieldStr->_value._string.data,
|
||||
fieldStr->_value._string.length - 1));
|
||||
;
|
||||
for (auto const& fieldStr : VPackArrayIterator(fld)) {
|
||||
attributes.emplace_back(fieldStr.copyString());
|
||||
}
|
||||
|
||||
// create the index
|
||||
|
@ -3934,19 +3908,19 @@ static triagens::arango::Index* CreateCapConstraintDocumentCollection(
|
|||
/// @brief restores an index
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int CapConstraintFromJson(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_json_t const* definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
static int CapConstraintFromVelocyPack(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
VPackSlice const& definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
if (dst != nullptr) {
|
||||
*dst = nullptr;
|
||||
}
|
||||
|
||||
TRI_json_t const* val1 = TRI_LookupObjectJson(definition, "size");
|
||||
TRI_json_t const* val2 = TRI_LookupObjectJson(definition, "byteSize");
|
||||
VPackSlice val1 = definition.get("size");
|
||||
VPackSlice val2 = definition.get("byteSize");
|
||||
|
||||
if (!TRI_IsNumberJson(val1) && !TRI_IsNumberJson(val2)) {
|
||||
if (!val1.isNumber() && !val2.isNumber()) {
|
||||
LOG_ERROR("ignoring cap constraint %llu, 'size' and 'byteSize' missing",
|
||||
(unsigned long long)iid);
|
||||
|
||||
|
@ -3954,15 +3928,30 @@ static int CapConstraintFromJson(triagens::arango::Transaction* trx,
|
|||
}
|
||||
|
||||
size_t count = 0;
|
||||
if (TRI_IsNumberJson(val1) && val1->_value._number > 0.0) {
|
||||
count = static_cast<size_t>(val1->_value._number);
|
||||
if (val1.isNumber()) {
|
||||
if (val1.isDouble()) {
|
||||
double tmp = val1.getDouble();
|
||||
if (tmp > 0.0) {
|
||||
count = static_cast<size_t>(tmp);
|
||||
}
|
||||
} else {
|
||||
count = val1.getNumericValue<size_t>();
|
||||
}
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (TRI_IsNumberJson(val2) &&
|
||||
val2->_value._number >
|
||||
static_cast<double>(triagens::arango::CapConstraint::MinSize)) {
|
||||
size = static_cast<int64_t>(val2->_value._number);
|
||||
if (val2.isNumber()) {
|
||||
if (val2.isDouble()) {
|
||||
double tmp = val2.getDouble();
|
||||
if (tmp > triagens::arango::CapConstraint::MinSize) {
|
||||
size = static_cast<int64_t>(tmp);
|
||||
}
|
||||
} else {
|
||||
int64_t tmp = val2.getNumericValue<int64_t>();
|
||||
if (tmp > triagens::arango::CapConstraint::MinSize) {
|
||||
size = static_cast<int64_t>(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0 && size == 0) {
|
||||
|
@ -4151,52 +4140,48 @@ static triagens::arango::Index* CreateGeoIndexDocumentCollection(
|
|||
/// @brief restores an index
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int GeoIndexFromJson(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_json_t const* definition, TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
static int GeoIndexFromVelocyPack(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
VPackSlice const& definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
if (dst != nullptr) {
|
||||
*dst = nullptr;
|
||||
}
|
||||
|
||||
TRI_json_t const* type = TRI_LookupObjectJson(definition, "type");
|
||||
VPackSlice const type = definition.get("type");
|
||||
|
||||
if (!TRI_IsStringJson(type)) {
|
||||
if (!type.isString()) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
char const* typeStr = type->_value._string.data;
|
||||
std::string typeStr = type.copyString();
|
||||
|
||||
// extract fields
|
||||
size_t fieldCount;
|
||||
TRI_json_t* fld = ExtractFields(definition, &fieldCount, iid);
|
||||
|
||||
if (fld == nullptr) {
|
||||
return TRI_errno();
|
||||
VPackSlice fld;
|
||||
try {
|
||||
fld = ExtractFields(definition, iid);
|
||||
} catch (triagens::basics::Exception const& e) {
|
||||
return TRI_set_errno(e.code());
|
||||
}
|
||||
VPackValueLength fieldCount = fld.length();
|
||||
|
||||
triagens::arango::Index* idx = nullptr;
|
||||
|
||||
// list style
|
||||
if (TRI_EqualString(typeStr, "geo1")) {
|
||||
if (typeStr == "geo1") {
|
||||
// extract geo json
|
||||
bool geoJson = false;
|
||||
TRI_json_t const* bv = TRI_LookupObjectJson(definition, "geoJson");
|
||||
|
||||
if (TRI_IsBooleanJson(bv)) {
|
||||
geoJson = bv->_value._boolean;
|
||||
}
|
||||
bool geoJson = triagens::basics::VelocyPackHelper::getBooleanValue(
|
||||
definition, "geoJson", false);
|
||||
|
||||
// need just one field
|
||||
if (fieldCount == 1) {
|
||||
auto loc = static_cast<TRI_json_t const*>(
|
||||
TRI_AtVector(&fld->_value._objects, 0));
|
||||
VPackSlice loc = fld.at(0);
|
||||
bool created;
|
||||
|
||||
idx = CreateGeoIndexDocumentCollection(
|
||||
trx, document,
|
||||
std::string(loc->_value._string.data, loc->_value._string.length - 1),
|
||||
std::string(), std::string(), geoJson, iid, created);
|
||||
idx = CreateGeoIndexDocumentCollection(trx, document, loc.copyString(),
|
||||
std::string(), std::string(),
|
||||
geoJson, iid, created);
|
||||
|
||||
if (dst != nullptr) {
|
||||
*dst = idx;
|
||||
|
@ -4206,26 +4191,23 @@ static int GeoIndexFromJson(triagens::arango::Transaction* trx,
|
|||
} else {
|
||||
LOG_ERROR(
|
||||
"ignoring %s-index %llu, 'fields' must be a list with 1 entries",
|
||||
typeStr, (unsigned long long)iid);
|
||||
typeStr.c_str(), (unsigned long long)iid);
|
||||
|
||||
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
// attribute style
|
||||
else if (TRI_EqualString(typeStr, "geo2")) {
|
||||
else if (typeStr == "geo2") {
|
||||
if (fieldCount == 2) {
|
||||
auto lat = static_cast<TRI_json_t const*>(
|
||||
TRI_AtVector(&fld->_value._objects, 0));
|
||||
auto lon = static_cast<TRI_json_t const*>(
|
||||
TRI_AtVector(&fld->_value._objects, 1));
|
||||
VPackSlice lat = fld.at(0);
|
||||
VPackSlice lon = fld.at(1);
|
||||
|
||||
bool created;
|
||||
|
||||
idx = CreateGeoIndexDocumentCollection(
|
||||
trx, document, std::string(),
|
||||
std::string(lat->_value._string.data, lat->_value._string.length - 1),
|
||||
std::string(lon->_value._string.data, lon->_value._string.length - 1),
|
||||
false, iid, created);
|
||||
idx = CreateGeoIndexDocumentCollection(trx, document, std::string(),
|
||||
lat.copyString(), lon.copyString(),
|
||||
false, iid, created);
|
||||
|
||||
if (dst != nullptr) {
|
||||
*dst = idx;
|
||||
|
@ -4235,13 +4217,11 @@ static int GeoIndexFromJson(triagens::arango::Transaction* trx,
|
|||
} else {
|
||||
LOG_ERROR(
|
||||
"ignoring %s-index %llu, 'fields' must be a list with 2 entries",
|
||||
typeStr, (unsigned long long)iid);
|
||||
typeStr.c_str(), (unsigned long long)iid);
|
||||
|
||||
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
TRI_ASSERT(false);
|
||||
}
|
||||
|
||||
|
@ -4444,12 +4424,13 @@ static triagens::arango::Index* CreateHashIndexDocumentCollection(
|
|||
/// @brief restores an index
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int HashIndexFromJson(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_json_t const* definition, TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
return PathBasedIndexFromJson(trx, document, definition, iid,
|
||||
CreateHashIndexDocumentCollection, dst);
|
||||
static int HashIndexFromVelocyPack(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
VPackSlice const& definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
return PathBasedIndexFromVelocyPack(trx, document, definition, iid,
|
||||
CreateHashIndexDocumentCollection, dst);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -4583,13 +4564,14 @@ static triagens::arango::Index* CreateSkiplistIndexDocumentCollection(
|
|||
/// @brief restores an index
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int SkiplistIndexFromJson(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_json_t const* definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
return PathBasedIndexFromJson(trx, document, definition, iid,
|
||||
CreateSkiplistIndexDocumentCollection, dst);
|
||||
static int SkiplistIndexFromVelocyPack(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
VPackSlice const& definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
return PathBasedIndexFromVelocyPack(trx, document, definition, iid,
|
||||
CreateSkiplistIndexDocumentCollection,
|
||||
dst);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -4726,22 +4708,23 @@ static triagens::arango::Index* CreateFulltextIndexDocumentCollection(
|
|||
/// @brief restores an index
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int FulltextIndexFromJson(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_json_t const* definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
static int FulltextIndexFromVelocyPack(triagens::arango::Transaction* trx,
|
||||
TRI_document_collection_t* document,
|
||||
VPackSlice const& definition,
|
||||
TRI_idx_iid_t iid,
|
||||
triagens::arango::Index** dst) {
|
||||
if (dst != nullptr) {
|
||||
*dst = nullptr;
|
||||
}
|
||||
|
||||
// extract fields
|
||||
size_t fieldCount;
|
||||
TRI_json_t* fld = ExtractFields(definition, &fieldCount, iid);
|
||||
|
||||
if (fld == nullptr) {
|
||||
return TRI_errno();
|
||||
VPackSlice fld;
|
||||
try {
|
||||
fld = ExtractFields(definition, iid);
|
||||
} catch (triagens::basics::Exception const& e) {
|
||||
return TRI_set_errno(e.code());
|
||||
}
|
||||
VPackValueLength fieldCount = fld.length();
|
||||
|
||||
// extract the list of fields
|
||||
if (fieldCount != 1) {
|
||||
|
@ -4751,26 +4734,20 @@ static int FulltextIndexFromJson(triagens::arango::Transaction* trx,
|
|||
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
auto value =
|
||||
static_cast<TRI_json_t const*>(TRI_AtVector(&fld->_value._objects, 0));
|
||||
VPackSlice value = fld.at(0);
|
||||
|
||||
if (!TRI_IsStringJson(value)) {
|
||||
if (!value.isString()) {
|
||||
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
std::string const attribute(value->_value._string.data,
|
||||
value->_value._string.length - 1);
|
||||
std::string const attribute = value.copyString();
|
||||
|
||||
// 2013-01-17: deactivated substring indexing
|
||||
// indexSubstrings = TRI_LookupObjectJson(definition, "indexSubstrings");
|
||||
|
||||
int minWordLengthValue = TRI_FULLTEXT_MIN_WORD_LENGTH_DEFAULT;
|
||||
TRI_json_t const* minWordLength =
|
||||
TRI_LookupObjectJson(definition, "minLength");
|
||||
|
||||
if (minWordLength != nullptr && minWordLength->_type == TRI_JSON_NUMBER) {
|
||||
minWordLengthValue = (int)minWordLength->_value._number;
|
||||
}
|
||||
int minWordLengthValue =
|
||||
triagens::basics::VelocyPackHelper::getNumericValue<int>(
|
||||
definition, "minLength", TRI_FULLTEXT_MIN_WORD_LENGTH_DEFAULT);
|
||||
|
||||
// create the index
|
||||
auto idx = LookupFulltextIndexDocumentCollection(document, attribute,
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
|
||||
struct TRI_cap_constraint_s;
|
||||
struct TRI_document_edge_s;
|
||||
struct TRI_json_t;
|
||||
class TRI_headers_t;
|
||||
|
||||
class VocShaper;
|
||||
|
@ -780,15 +779,6 @@ int TRI_FromVelocyPackIndexDocumentCollection(triagens::arango::Transaction*,
|
|||
VPackSlice const&,
|
||||
triagens::arango::Index**);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create an index, based on a JSON description
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_FromJsonIndexDocumentCollection(triagens::arango::Transaction*,
|
||||
TRI_document_collection_t*,
|
||||
struct TRI_json_t const*,
|
||||
triagens::arango::Index**);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief rolls back a document operation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue