mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
2441b2f700
|
@ -489,6 +489,12 @@ class Slice {
|
|||
return Slice(current);
|
||||
}
|
||||
|
||||
// tests whether the Slice is an empty array
|
||||
bool isEmptyArray() const noexcept { return head() == 0x01; }
|
||||
|
||||
// tests whether the Slice is an empty object
|
||||
bool isEmptyObject() const noexcept { return head() == 0x0a; }
|
||||
|
||||
// translates an integer key into a string
|
||||
Slice translate() const;
|
||||
|
||||
|
|
|
@ -761,6 +761,10 @@ VPackSlice Transaction::extractKeyFromDocument(VPackSlice slice) {
|
|||
slice = slice.resolveExternal();
|
||||
}
|
||||
TRI_ASSERT(slice.isObject());
|
||||
|
||||
if (slice.isEmptyObject()) {
|
||||
return VPackSlice();
|
||||
}
|
||||
// a regular document must have at least the three attributes
|
||||
// _key, _id and _rev (in this order). _key must be the first attribute
|
||||
// however this method may also be called for remove markers, which only
|
||||
|
@ -791,9 +795,12 @@ VPackSlice Transaction::extractIdFromDocument(VPackSlice slice) {
|
|||
slice = slice.resolveExternal();
|
||||
}
|
||||
TRI_ASSERT(slice.isObject());
|
||||
|
||||
if (slice.isEmptyObject()) {
|
||||
return VPackSlice();
|
||||
}
|
||||
// a regular document must have at least the three attributes
|
||||
// _key, _id and _rev (in this order). _id must be the second attribute
|
||||
TRI_ASSERT(slice.length() >= 2);
|
||||
|
||||
uint8_t const* p = slice.begin() + slice.findDataOffset(slice.head());
|
||||
|
||||
|
@ -824,9 +831,12 @@ VPackSlice Transaction::extractFromFromDocument(VPackSlice slice) {
|
|||
slice = slice.resolveExternal();
|
||||
}
|
||||
TRI_ASSERT(slice.isObject());
|
||||
|
||||
if (slice.isEmptyObject()) {
|
||||
return VPackSlice();
|
||||
}
|
||||
// this method must only be called on edges
|
||||
// this means we must have at least the attributes _key, _id, _from, _to and _rev
|
||||
TRI_ASSERT(slice.length() >= 5);
|
||||
|
||||
uint8_t const* p = slice.begin() + slice.findDataOffset(slice.head());
|
||||
VPackValueLength count = 0;
|
||||
|
@ -857,9 +867,12 @@ VPackSlice Transaction::extractToFromDocument(VPackSlice slice) {
|
|||
if (slice.isExternal()) {
|
||||
slice = slice.resolveExternal();
|
||||
}
|
||||
|
||||
if (slice.isEmptyObject()) {
|
||||
return VPackSlice();
|
||||
}
|
||||
// this method must only be called on edges
|
||||
// this means we must have at least the attributes _key, _id, _from, _to and _rev
|
||||
TRI_ASSERT(slice.length() >= 5);
|
||||
|
||||
uint8_t const* p = slice.begin() + slice.findDataOffset(slice.head());
|
||||
VPackValueLength count = 0;
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
'click #downloadPNG': 'downloadSVG'
|
||||
},
|
||||
|
||||
cursorX: 0,
|
||||
cursorY: 0,
|
||||
|
||||
initSigma: function () {
|
||||
// init sigma
|
||||
try {
|
||||
|
@ -70,7 +73,10 @@
|
|||
$('#content').append(
|
||||
'<div id="calculatingGraph" style="position: absolute; left: 25px; top: 130px;">' +
|
||||
'<i class="fa fa-circle-o-notch fa-spin" style="margin-right: 10px;"></i>' +
|
||||
'<span id="calcText">Fetching graph data. Please wait ... </span></div>'
|
||||
'<span id="calcText">Fetching graph data. Please wait ... </span></br></br></br>' +
|
||||
'<span style="font-weight: 100; opacity: 0.6; font-size: 9pt;">If it`s taking too much time to draw the graph, please go to: </br>' +
|
||||
'<a href="' + window.location.href + '/settings">' + window.location.href + '/settings </a></br> and adjust your settings.' +
|
||||
'It is possible that the graph is too big to be handled by the browser.</span></div>'
|
||||
);
|
||||
|
||||
var continueFetchGraph = function () {
|
||||
|
@ -158,23 +164,78 @@
|
|||
});
|
||||
}
|
||||
|
||||
// clear events
|
||||
var c = document.getElementsByClassName('sigma-mouse')[0];
|
||||
c.removeEventListener('mousemove', self.drawLine.bind(this), false);
|
||||
|
||||
// clear info div
|
||||
},
|
||||
|
||||
trackCursorPosition: function (e) {
|
||||
this.cursorX = e.x;
|
||||
this.cursorY = e.y;
|
||||
},
|
||||
|
||||
createContextMenu: function (e) {
|
||||
var x = e.data.captor.clientX;
|
||||
var y = e.data.captor.clientX;
|
||||
console.log('Context menu');
|
||||
console.log(x);
|
||||
console.log(y);
|
||||
var self = this;
|
||||
var x = self.cursorX - 50;
|
||||
var y = self.cursorY - 50;
|
||||
console.log(e);
|
||||
this.clearOldContextMenu();
|
||||
|
||||
var generateMenu = function (e) {
|
||||
var hotaru = ['#364C4A', '#497C7F', '#92C5C0', '#858168', '#CCBCA5'];
|
||||
|
||||
var Wheelnav = wheelnav;
|
||||
|
||||
var wheel = new Wheelnav('nodeContextMenu');
|
||||
wheel.maxPercent = 1.0;
|
||||
wheel.wheelRadius = 50;
|
||||
wheel.clockwise = false;
|
||||
wheel.colors = hotaru;
|
||||
wheel.multiSelect = true;
|
||||
wheel.clickModeRotate = false;
|
||||
wheel.slicePathFunction = slicePath().DonutSlice;
|
||||
wheel.createWheel([icon.plus, icon.trash]);
|
||||
|
||||
wheel.navItems[0].selected = false;
|
||||
wheel.navItems[0].hovered = false;
|
||||
// add menu events
|
||||
|
||||
// function 0: edit
|
||||
wheel.navItems[0].navigateFunction = function (e) {
|
||||
self.clearOldContextMenu();
|
||||
};
|
||||
|
||||
// function 1: delete
|
||||
wheel.navItems[1].navigateFunction = function (e) {
|
||||
self.clearOldContextMenu();
|
||||
};
|
||||
|
||||
// deselect active default entry
|
||||
wheel.navItems[0].selected = false;
|
||||
wheel.navItems[0].hovered = false;
|
||||
};
|
||||
|
||||
$('#nodeContextMenu').css('position', 'fixed');
|
||||
$('#nodeContextMenu').css('left', x);
|
||||
$('#nodeContextMenu').css('top', y);
|
||||
$('#nodeContextMenu').width(100);
|
||||
$('#nodeContextMenu').height(100);
|
||||
|
||||
generateMenu(e);
|
||||
},
|
||||
|
||||
createNodeContextMenu: function (nodeId, e) {
|
||||
var self = this;
|
||||
|
||||
var x = e.data.node['renderer1:x'];
|
||||
var y = e.data.node['renderer1:y'];
|
||||
// var x = e.data.node['renderer1:x'];
|
||||
// var y = e.data.node['renderer1:y'];
|
||||
// better to use x,y from top, but sometimes values are not correct ...
|
||||
console.log(e);
|
||||
var x = e.data.captor.clientX - 52;
|
||||
var y = e.data.captor.clientY - 52;
|
||||
console.log(e.data);
|
||||
|
||||
this.clearOldContextMenu();
|
||||
|
||||
|
@ -233,8 +294,8 @@
|
|||
wheel.navItems[0].hovered = false;
|
||||
};
|
||||
|
||||
$('#nodeContextMenu').css('left', x + 115);
|
||||
$('#nodeContextMenu').css('top', y + 72);
|
||||
$('#nodeContextMenu').css('left', x);
|
||||
$('#nodeContextMenu').css('top', y);
|
||||
$('#nodeContextMenu').width(100);
|
||||
$('#nodeContextMenu').height(100);
|
||||
|
||||
|
@ -498,6 +559,11 @@
|
|||
}
|
||||
console.log(dragListener);
|
||||
|
||||
// add listener to keep track of cursor position
|
||||
var c = document.getElementsByClassName('sigma-mouse')[0];
|
||||
c.addEventListener('mousemove', self.trackCursorPosition.bind(this), false);
|
||||
|
||||
// clear up info div
|
||||
$('#calculatingGraph').remove();
|
||||
}
|
||||
|
||||
|
|
|
@ -226,6 +226,216 @@ function optimizerIndexesTestSuite () {
|
|||
assertEqual(0, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _key
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeKey : function () {
|
||||
var query = "LET t = { _key: 'test12' } FOR i IN " + c.name() + " FILTER i._key == t._key RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _key
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeKeyNonConst : function () {
|
||||
var query = "LET t = NOOPT({ _key: 'test12' }) FOR i IN " + c.name() + " FILTER i._key == t._key RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeId : function () {
|
||||
var query = "LET t = { _id: 'test12' } FOR i IN " + c.name() + " FILTER i._key == t._id RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeIdNonConst : function () {
|
||||
var query = "LET t = NOOPT({ _id: 'test12' }) FOR i IN " + c.name() + " FILTER i._key == t._id RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _rev
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeRev : function () {
|
||||
var query = "LET t = { _rev: 'test12' } FOR i IN " + c.name() + " FILTER i._key == t._rev RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _rev
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeRevNonConst : function () {
|
||||
var query = "LET t = NOOPT({ _rev: 'test12' }) FOR i IN " + c.name() + " FILTER i._key == t._rev RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _from
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeFrom : function () {
|
||||
var query = "LET t = { _from: 'test12' } FOR i IN " + c.name() + " FILTER i._key == t._from RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _from
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeFromNonConst : function () {
|
||||
var query = "LET t = NOOPT({ _from: 'test12' }) FOR i IN " + c.name() + " FILTER i._key == t._from RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _to
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeTo : function () {
|
||||
var query = "LET t = { _to: 'test12' } FOR i IN " + c.name() + " FILTER i._key == t._to RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test fake _to
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testFakeToNonConst : function () {
|
||||
var query = "LET t = NOOPT({ _to: 'test12' }) FOR i IN " + c.name() + " FILTER i._key == t._to RETURN i.value";
|
||||
|
||||
var plan = AQL_EXPLAIN(query).plan;
|
||||
var nodeTypes = plan.nodes.map(function(node) {
|
||||
return node.type;
|
||||
});
|
||||
|
||||
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual([ 12 ], results.json, query);
|
||||
assertEqual(0, results.stats.scannedFull);
|
||||
assertEqual(1, results.stats.scannedIndex);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test index usage
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue