1
0
Fork 0

changed other index APIs

This commit is contained in:
Jan Steemann 2015-11-25 15:05:02 +01:00
parent 0ee556d07d
commit 981c578812
8 changed files with 16 additions and 78 deletions

View File

@ -2565,6 +2565,7 @@ AqlValue Functions::Near (triagens::aql::Query* query,
}
GeoCoordinates* cors = static_cast<triagens::arango::GeoIndex2*>(index)->nearQuery(
trx,
latitude.json()->_value._number,
longitude.json()->_value._number,
limitValue
@ -2733,6 +2734,7 @@ AqlValue Functions::Within (triagens::aql::Query* query,
}
GeoCoordinates* cors = static_cast<triagens::arango::GeoIndex2*>(index)->withinQuery(
trx,
latitude.json()->_value._number,
longitude.json()->_value._number,
radius.json()->_value._number

View File

@ -541,62 +541,6 @@ int EdgeIndex::batchInsert (triagens::arango::Transaction*,
return TRI_ERROR_NO_ERROR;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief looks up edges using the index, restarting at the edge pointed at
/// by next
////////////////////////////////////////////////////////////////////////////////
void EdgeIndex::lookup (TRI_edge_index_iterator_t const* edgeIndexIterator,
std::vector<TRI_doc_mptr_copy_t>& result,
TRI_doc_mptr_copy_t*& next,
size_t batchSize) {
auto callback = [&result] (TRI_doc_mptr_t* data) -> void {
result.emplace_back(*(data));
};
std::vector<TRI_doc_mptr_t*>* found = nullptr;
if (next == nullptr) {
if (edgeIndexIterator->_direction == TRI_EDGE_OUT) {
found = _edgesFrom->lookupByKey(&(edgeIndexIterator->_edge), batchSize);
}
else if (edgeIndexIterator->_direction == TRI_EDGE_IN) {
found = _edgesTo->lookupByKey(&(edgeIndexIterator->_edge), batchSize);
}
else {
TRI_ASSERT(false);
}
if (found != nullptr && found->size() != 0) {
next = static_cast<TRI_doc_mptr_copy_t*>(found->back());
}
}
else {
if (edgeIndexIterator->_direction == TRI_EDGE_OUT) {
found = _edgesFrom->lookupByKeyContinue(next, batchSize);
}
else if (edgeIndexIterator->_direction == TRI_EDGE_IN) {
found = _edgesTo->lookupByKeyContinue(next, batchSize);
}
else {
TRI_ASSERT(false);
}
if (found != nullptr && found->size() != 0) {
next = static_cast<TRI_doc_mptr_copy_t*>(found->back());
}
else {
next = nullptr;
}
}
if (found != nullptr) {
for (auto& v : *found) {
callback(v);
}
delete found;
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief provides a size hint for the edge index
////////////////////////////////////////////////////////////////////////////////

View File

@ -158,16 +158,6 @@ namespace triagens {
std::vector<TRI_doc_mptr_t const*> const*,
size_t) override final;
////////////////////////////////////////////////////////////////////////////////
/// @brief looks up edges using the index, restarting at the edge pointed at
/// by next
////////////////////////////////////////////////////////////////////////////////
void lookup (TRI_edge_index_iterator_t const*,
std::vector<TRI_doc_mptr_copy_t>&,
TRI_doc_mptr_copy_t*&,
size_t);
int sizeHint (triagens::arango::Transaction*, size_t) override final;
bool hasBatchInsert () const override final {

View File

@ -276,7 +276,8 @@ int GeoIndex2::remove (triagens::arango::Transaction*,
/// @brief looks up all points within a given radius
////////////////////////////////////////////////////////////////////////////////
GeoCoordinates* GeoIndex2::withinQuery (double lat,
GeoCoordinates* GeoIndex2::withinQuery (triagens::arango::Transaction* trx,
double lat,
double lon,
double radius) const {
GeoCoordinate gc;
@ -290,7 +291,8 @@ GeoCoordinates* GeoIndex2::withinQuery (double lat,
/// @brief looks up the nearest points
////////////////////////////////////////////////////////////////////////////////
GeoCoordinates* GeoIndex2::nearQuery (double lat,
GeoCoordinates* GeoIndex2::nearQuery (triagens::arango::Transaction* trx,
double lat,
double lon,
size_t count) const {
GeoCoordinate gc;
@ -300,7 +302,6 @@ GeoCoordinates* GeoIndex2::nearQuery (double lat,
return GeoIndex_NearestCountPoints(_geoIndex, &gc, static_cast<int>(count));
}
// -----------------------------------------------------------------------------
// --SECTION-- private methods
// -----------------------------------------------------------------------------

View File

@ -126,13 +126,13 @@ namespace triagens {
/// @brief looks up all points within a given radius
////////////////////////////////////////////////////////////////////////////////
GeoCoordinates* withinQuery (double, double, double) const;
GeoCoordinates* withinQuery (triagens::arango::Transaction*, double, double, double) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief looks up the nearest points
////////////////////////////////////////////////////////////////////////////////
GeoCoordinates* nearQuery (double, double, size_t) const;
GeoCoordinates* nearQuery (triagens::arango::Transaction*, double, double, size_t) const;
bool isSame (TRI_shape_pid_t location, bool geoJson) const {
return (_location != 0 && _location == location && _geoJson == geoJson);

View File

@ -745,7 +745,7 @@ TRI_doc_mptr_t* SkiplistIndexIterator::next () {
return nullptr;
}
// We restart the lookup
_iterator = _index->lookup(_operators[_currentOperator], _reverse);
_iterator = _index->lookup(_trx, _operators[_currentOperator], _reverse);
if (_iterator == nullptr) {
// This iterator was not created.
_currentOperator++;
@ -762,7 +762,7 @@ TRI_doc_mptr_t* SkiplistIndexIterator::next () {
}
// Free the former iterator and get the next one
delete _iterator;
_iterator = _index->lookup(_operators[_currentOperator], _reverse);
_iterator = _index->lookup(_trx, _operators[_currentOperator], _reverse);
res = _iterator->next();
}
return res->document();
@ -937,7 +937,8 @@ int SkiplistIndex::remove (triagens::arango::Transaction*,
/// the TRI_index_operator_t* and the SkiplistIterator* results
////////////////////////////////////////////////////////////////////////////////
SkiplistIterator* SkiplistIndex::lookup (TRI_index_operator_t* slOperator,
SkiplistIterator* SkiplistIndex::lookup (triagens::arango::Transaction* trx,
TRI_index_operator_t* slOperator,
bool reverse) const {
TRI_ASSERT(slOperator != nullptr);

View File

@ -306,7 +306,7 @@ namespace triagens {
/// the TRI_index_operator_t* and the TRI_skiplist_iterator_t* results
////////////////////////////////////////////////////////////////////////////////
SkiplistIterator* lookup (TRI_index_operator_t*, bool) const;
SkiplistIterator* lookup (triagens::arango::Transaction*, TRI_index_operator_t*, bool) const;
bool supportsFilterCondition (triagens::aql::AstNode const*,
triagens::aql::Variable const*,

View File

@ -590,7 +590,7 @@ static void ExecuteSkiplistQuery (const v8::FunctionCallbackInfo<v8::Value>& arg
TRI_V8_THROW_EXCEPTION(TRI_ERROR_BAD_PARAMETER);
}
std::unique_ptr<SkiplistIterator> skiplistIterator(static_cast<triagens::arango::SkiplistIndex*>(idx)->lookup(skiplistOperator, reverse));
std::unique_ptr<SkiplistIterator> skiplistIterator(static_cast<triagens::arango::SkiplistIndex*>(idx)->lookup(&trx, skiplistOperator, reverse));
delete skiplistOperator;
if (! skiplistIterator) {
@ -1988,7 +1988,7 @@ static void NearQuery (SingleCollectionReadOnlyTransaction& trx,
v8::Handle<v8::Array> distances = v8::Array::New(isolate);
result->Set(TRI_V8_ASCII_STRING("distances"), distances);
GeoCoordinates* cors = static_cast<triagens::arango::GeoIndex2*>(idx)->nearQuery(latitude, longitude, limit);
GeoCoordinates* cors = static_cast<triagens::arango::GeoIndex2*>(idx)->nearQuery(&trx, latitude, longitude, limit);
if (cors != nullptr) {
int res = StoreGeoResult(isolate, trx, collection, cors, documents, distances);
@ -2084,7 +2084,7 @@ static void WithinQuery (SingleCollectionReadOnlyTransaction& trx,
v8::Handle<v8::Array> distances = v8::Array::New(isolate);
result->Set(TRI_V8_ASCII_STRING("distances"), distances);
GeoCoordinates* cors = static_cast<triagens::arango::GeoIndex2*>(idx)->withinQuery(latitude, longitude, radius);
GeoCoordinates* cors = static_cast<triagens::arango::GeoIndex2*>(idx)->withinQuery(&trx, latitude, longitude, radius);
if (cors != nullptr) {
int res = StoreGeoResult(isolate, trx, collection, cors, documents, distances);