mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
30a1389426
|
@ -195,6 +195,7 @@ static void refreshPage(const struct linenoiseCompletions * lc, struct current *
|
|||
static void initLinenoiseLine(struct current *current);
|
||||
static size_t new_line_numbers(size_t pos, int cols, size_t pchars);
|
||||
static int next_allowed_x(size_t pos, int cols, int pchars);
|
||||
static void setCursorPosXY(struct current *current, int x, int y);
|
||||
|
||||
void linenoiseHistoryFree(void) {
|
||||
if (history) {
|
||||
|
@ -354,7 +355,7 @@ static void eraseEol(struct current *current)
|
|||
*/
|
||||
size_t number_lines = new_line_numbers(current->chars, current->cols, pchars);
|
||||
|
||||
int i;
|
||||
size_t i;
|
||||
/**
|
||||
* save original cursor position
|
||||
*/
|
||||
|
@ -956,8 +957,8 @@ static int get_char(struct current *current, size_t pos)
|
|||
static void displayItems(const struct linenoiseCompletions * lc, struct current *current, int max_len)
|
||||
{
|
||||
size_t wcols = current->cols;
|
||||
int cols = max_len > wcols ? 1 : wcols/(max_len+2);
|
||||
int rows = (int)ceil((float)lc->len/cols);
|
||||
size_t cols = max_len > wcols ? 1 : wcols/(max_len+2);
|
||||
size_t rows = (int)ceil((float)lc->len/cols);
|
||||
int i, j;
|
||||
size_t idx;
|
||||
const char * row_content;
|
||||
|
@ -1124,6 +1125,8 @@ refreshMultiLine(prompt, current);return;
|
|||
static void showBuffer(struct current * current, size_t pchars) {
|
||||
const char *buf = current->buf;
|
||||
size_t buf_len = strlen(buf);
|
||||
outputChars(current, buf, buf_len);
|
||||
return;
|
||||
/**
|
||||
* number of additional lines for displaying
|
||||
* the complete buffer
|
||||
|
@ -1165,21 +1168,26 @@ static void refreshMultiLine(const char *prompt, struct current *current)
|
|||
/* Cursor to left edge, then the prompt */
|
||||
// cursorToLeft(current);
|
||||
setCursorPos(current, 0);
|
||||
fd_printf(current->fd, "\x1b[s");
|
||||
outputChars(current, prompt, plen);
|
||||
|
||||
/**
|
||||
* show the buffer
|
||||
*/
|
||||
showBuffer(current, pchars);
|
||||
fd_printf(current->fd, "\x1b[u");
|
||||
|
||||
int x = next_allowed_x(current->pos, current->cols, pchars);
|
||||
/**
|
||||
* y is the relative position of the line
|
||||
*/
|
||||
int y = new_line_numbers(current->pos, current->cols, pchars);
|
||||
/* move cursor to: */
|
||||
if(x == current->cols-1) {
|
||||
/* next line */
|
||||
fd_printf(current->fd, "\x1b[1E");
|
||||
if(x == 0) {
|
||||
setCursorPosXY(current, x, y);
|
||||
} else {
|
||||
/* next next character after current->pos */
|
||||
setCursorPos(current, x+1);
|
||||
setCursorPosXY(current, x+1, y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1205,6 +1213,8 @@ static int next_allowed_x(size_t pos, int cols, int pchars)
|
|||
return (pos - (cols - pchars)) % (cols);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_WINCONSOLE
|
||||
static void setCursorPosXY(struct current *current, int x, int y)
|
||||
{
|
||||
|
@ -1303,6 +1313,14 @@ static void refreshLine(const char *prompt, struct current *current)
|
|||
|
||||
setCursorPosXY(current, new_x, new_y);
|
||||
}
|
||||
#else
|
||||
static void setCursorPosXY(struct current *current, int x, int y) {
|
||||
if(y>0) {
|
||||
fd_printf(current->fd, "\x1b[%dG\x1b[%dB", x, y);
|
||||
} else {
|
||||
fd_printf(current->fd, "\x1b[%dG", x);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void set_current(struct current *current, const char *str)
|
||||
|
@ -1566,10 +1584,7 @@ static void moveCursorToRight(struct current * current) {
|
|||
#else
|
||||
static void moveCursorToLeft(struct current * current) {
|
||||
size_t pchars = 20;
|
||||
int x = next_allowed_x(current->pos, current->cols, pchars);
|
||||
if(current->pos==0) {
|
||||
return;
|
||||
}
|
||||
int x = next_allowed_x(current->pos + 1, current->cols, pchars);
|
||||
if(x==0) {
|
||||
fd_printf(current->fd, "\x1b[1A\x1b[%dG", current->cols);
|
||||
} else {
|
||||
|
@ -1578,8 +1593,8 @@ static void moveCursorToLeft(struct current * current) {
|
|||
}
|
||||
static void moveCursorToRight(struct current * current) {
|
||||
size_t pchars = 20;
|
||||
int x = next_allowed_x(current->pos, current->cols, pchars);
|
||||
if(current->pos>=current->chars) {
|
||||
int x = next_allowed_x(current->pos-1, current->cols, pchars);
|
||||
if(current->pos>current->chars) {
|
||||
return;
|
||||
}
|
||||
if(x==current->cols-1) {
|
||||
|
@ -1636,9 +1651,10 @@ process_char:
|
|||
case 127: /* backspace */
|
||||
case ctrl('H'):
|
||||
eraseEol(current);
|
||||
if (remove_char(current, current->pos - 1) == 1) {
|
||||
// if (remove_char(current, current->pos - 1) == 1) {
|
||||
remove_char(current, current->pos - 1);
|
||||
refreshLine(current->prompt, current);
|
||||
}
|
||||
// }
|
||||
break;
|
||||
case ctrl('D'): /* ctrl-d */
|
||||
if (current->len == 0) {
|
||||
|
@ -1661,9 +1677,9 @@ process_char:
|
|||
case ctrl('W'): /* ctrl-w, delete word at left. save deleted chars */
|
||||
/* eat any spaces on the left */
|
||||
{
|
||||
eraseEol(current);
|
||||
size_t pos = current->pos;
|
||||
current->pos = current->chars;
|
||||
eraseEol(current);
|
||||
current->pos = pos;
|
||||
while (pos > 0 && get_char(current, pos - 1) == ' ') {
|
||||
pos--;
|
||||
|
@ -1858,19 +1874,20 @@ history_navigation:
|
|||
break;
|
||||
case ctrl('A'): /* Ctrl+a, go to the start of the line */
|
||||
case SPECIAL_HOME:
|
||||
eraseEol(current);
|
||||
current->pos = 0;
|
||||
refreshLine(current->prompt, current);
|
||||
break;
|
||||
case ctrl('E'): /* ctrl+e, go to the end of the line */
|
||||
case SPECIAL_END:
|
||||
eraseEol(current);
|
||||
current->pos = current->chars;
|
||||
refreshLine(current->prompt, current);
|
||||
break;
|
||||
case ctrl('U'): /* Ctrl+u, delete to beginning of line, save deleted chars. */
|
||||
eraseEol(current);
|
||||
if (remove_chars(current, 0, current->pos)) {
|
||||
refreshLine(current->prompt, current);
|
||||
}
|
||||
remove_chars(current, 0, current->pos);
|
||||
refreshLine(current->prompt, current);
|
||||
break;
|
||||
case ctrl('K'): /* Ctrl+k, delete from current to end of line, save deleted chars. */
|
||||
eraseEol(current);
|
||||
|
@ -1894,9 +1911,10 @@ history_navigation:
|
|||
/* Only tab is allowed without ^V */
|
||||
if (c == '\t' || c >= ' ') {
|
||||
eraseEol(current);
|
||||
if (insert_char(current, current->pos, c) == 1) {
|
||||
refreshLine(current->prompt, current);
|
||||
}
|
||||
// if (insert_char(current, current->pos, c) == 1) {
|
||||
insert_char(current, current->pos, c);
|
||||
refreshLine(current->prompt, current);
|
||||
// }
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2,494 +2,492 @@
|
|||
/*global window, $, Backbone, document, arangoCollectionModel*/
|
||||
/*global arangoHelper,dashboardView,arangoDatabase*/
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
window.Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
"" : "dashboard",
|
||||
"dashboard" : "dashboard",
|
||||
"collection/:colid" : "collection",
|
||||
"collections" : "collections",
|
||||
"collectionInfo/:colid" : "collectionInfo",
|
||||
"new" : "newCollection",
|
||||
"login" : "login",
|
||||
"collection/:colid/documents/:pageid" : "documents",
|
||||
"collection/:colid/:docid" : "document",
|
||||
"shell" : "shell",
|
||||
"query" : "query",
|
||||
"logs" : "logs",
|
||||
"api" : "api",
|
||||
"databases" : "databases",
|
||||
"application/installed/:key" : "applicationEdit",
|
||||
"application/available/:key" : "applicationInstall",
|
||||
"applications" : "applications",
|
||||
"application/documentation/:key" : "appDocumentation",
|
||||
"graph" : "graph",
|
||||
"graphManagement" : "graphManagement",
|
||||
"graphManagement/add" : "graphAddNew",
|
||||
"graphManagement/delete/:name" : "graphDelete",
|
||||
"userManagement" : "userManagement",
|
||||
"userProfile" : "userProfile",
|
||||
"testing" : "testview"
|
||||
},
|
||||
window.Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
"": "dashboard",
|
||||
"dashboard": "dashboard",
|
||||
"collection/:colid": "collection",
|
||||
"collections": "collections",
|
||||
"collectionInfo/:colid": "collectionInfo",
|
||||
"new": "newCollection",
|
||||
"login": "login",
|
||||
"collection/:colid/documents/:pageid": "documents",
|
||||
"collection/:colid/:docid": "document",
|
||||
"shell": "shell",
|
||||
"query": "query",
|
||||
"logs": "logs",
|
||||
"api": "api",
|
||||
"databases": "databases",
|
||||
"application/installed/:key": "applicationEdit",
|
||||
"application/available/:key": "applicationInstall",
|
||||
"applications": "applications",
|
||||
"application/documentation/:key": "appDocumentation",
|
||||
"graph": "graph",
|
||||
"graphManagement": "graphManagement",
|
||||
"graphManagement/add": "graphAddNew",
|
||||
"graphManagement/delete/:name": "graphDelete",
|
||||
"userManagement": "userManagement",
|
||||
"userProfile": "userProfile",
|
||||
"testing": "testview"
|
||||
},
|
||||
|
||||
testview: function() {
|
||||
this.testView = new window.testView();
|
||||
this.testView.render();
|
||||
},
|
||||
testview: function () {
|
||||
this.testView = new window.testView();
|
||||
this.testView.render();
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.bind('all', function(trigger, args) {
|
||||
var routeData = trigger.split(":");
|
||||
if (trigger === "route") {
|
||||
if (this.currentRoute === "dashboard" && this.dashboardView) {
|
||||
this.dashboardView.stopUpdating();
|
||||
} else if (args === "dashboard") {
|
||||
delete this.dashboardView;
|
||||
}
|
||||
this.currentRoute = args;
|
||||
}
|
||||
});
|
||||
this.graphs = new window.GraphCollection();
|
||||
this.notificationList = new window.NotificationCollection();
|
||||
|
||||
window.currentDB = new window.CurrentDatabase();
|
||||
window.currentDB.fetch({
|
||||
async: false
|
||||
});
|
||||
|
||||
window.userCollection = new window.ArangoUsers();
|
||||
|
||||
window.arangoDatabase = new window.ArangoDatabase();
|
||||
|
||||
window.arangoCollectionsStore = new window.arangoCollections();
|
||||
window.arangoDocumentsStore = new window.arangoDocuments();
|
||||
window.arangoDocumentStore = new window.arangoDocument();
|
||||
|
||||
window.collectionsView = new window.CollectionsView({
|
||||
collection: window.arangoCollectionsStore
|
||||
});
|
||||
window.arangoCollectionsStore.fetch();
|
||||
window.documentsView = new window.DocumentsView();
|
||||
window.documentView = new window.DocumentView({
|
||||
collection: window.arangoDocumentStore
|
||||
});
|
||||
window.arangoLogsStore = new window.ArangoLogs();
|
||||
window.arangoLogsStore.fetch({
|
||||
success: function () {
|
||||
window.logsView = new window.LogsView({
|
||||
collection: window.arangoLogsStore
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.foxxList = new window.FoxxCollection();
|
||||
|
||||
this.footerView = new window.FooterView();
|
||||
this.naviView = new window.NavigationView({
|
||||
notificationCollection: this.notificationList,
|
||||
userCollection: window.userCollection
|
||||
});
|
||||
this.footerView.render();
|
||||
this.naviView.render();
|
||||
this.graphView = new window.GraphView({
|
||||
graphs: this.graphs,
|
||||
collection: window.arangoCollectionsStore
|
||||
});
|
||||
|
||||
this.initVersionCheck();
|
||||
|
||||
var self = this;
|
||||
$(window).resize(function() {
|
||||
self.handleResize();
|
||||
});
|
||||
//this.handleResize();
|
||||
},
|
||||
|
||||
initVersionCheck: function () {
|
||||
// this checks for version updates
|
||||
|
||||
var self = this;
|
||||
var versionCheck = function () {
|
||||
$.ajax({
|
||||
async: true,
|
||||
crossDomain: true,
|
||||
dataType: "jsonp",
|
||||
url: "https://www.arangodb.org/repositories/versions.php?callback=parseVersions",
|
||||
success: function (json) {
|
||||
if (typeof json !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
// turn our own version string into a version object
|
||||
var currentVersion = window.versionHelper.fromString(self.footerView.system.version);
|
||||
|
||||
// get our mainline version
|
||||
var mainLine = window.versionHelper.toStringMainLine(currentVersion);
|
||||
|
||||
var mainLines = Object.keys(json).sort(window.versionHelper.compareVersionStrings);
|
||||
var latestMainLine;
|
||||
mainLines.forEach(function (l) {
|
||||
if (json[l].stable) {
|
||||
if (window.versionHelper.compareVersionStrings(l, mainLine) > 0) {
|
||||
latestMainLine = json[l];
|
||||
}
|
||||
}
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.bind('all', function (trigger, args) {
|
||||
var routeData = trigger.split(":");
|
||||
if (trigger === "route") {
|
||||
if (self.currentRoute === "dashboard" && self.dashboardView) {
|
||||
self.dashboardView.stopUpdating();
|
||||
} else if (args === "dashboard") {
|
||||
delete self.dashboardView;
|
||||
}
|
||||
self.currentRoute = args;
|
||||
}
|
||||
});
|
||||
|
||||
var update;
|
||||
var mainLineVersions;
|
||||
var latest;
|
||||
if (latestMainLine !== undefined &&
|
||||
Object.keys(latestMainLine.versions.length > 0)) {
|
||||
mainLineVersions = Object.keys(latestMainLine.versions);
|
||||
mainLineVersions = mainLineVersions.sort(window.versionHelper.compareVersionStrings);
|
||||
latest = mainLineVersions[mainLineVersions.length - 1];
|
||||
this.graphs = new window.GraphCollection();
|
||||
this.notificationList = new window.NotificationCollection();
|
||||
|
||||
update = {
|
||||
type: "major",
|
||||
version: latest,
|
||||
changes: latestMainLine.versions[latest].changes
|
||||
};
|
||||
window.currentDB = new window.CurrentDatabase();
|
||||
window.currentDB.fetch({
|
||||
async: false
|
||||
});
|
||||
|
||||
window.userCollection = new window.ArangoUsers();
|
||||
|
||||
window.arangoDatabase = new window.ArangoDatabase();
|
||||
|
||||
window.arangoCollectionsStore = new window.arangoCollections();
|
||||
window.arangoDocumentsStore = new window.arangoDocuments();
|
||||
window.arangoDocumentStore = new window.arangoDocument();
|
||||
|
||||
window.collectionsView = new window.CollectionsView({
|
||||
collection: window.arangoCollectionsStore
|
||||
});
|
||||
window.arangoCollectionsStore.fetch();
|
||||
window.documentsView = new window.DocumentsView();
|
||||
window.documentView = new window.DocumentView({
|
||||
collection: window.arangoDocumentStore
|
||||
});
|
||||
window.arangoLogsStore = new window.ArangoLogs();
|
||||
window.arangoLogsStore.fetch({
|
||||
success: function () {
|
||||
window.logsView = new window.LogsView({
|
||||
collection: window.arangoLogsStore
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.foxxList = new window.FoxxCollection();
|
||||
|
||||
this.footerView = new window.FooterView();
|
||||
this.naviView = new window.NavigationView({
|
||||
notificationCollection: this.notificationList,
|
||||
userCollection: window.userCollection
|
||||
});
|
||||
this.footerView.render();
|
||||
this.naviView.render();
|
||||
this.graphView = new window.GraphView({
|
||||
graphs: this.graphs,
|
||||
collection: window.arangoCollectionsStore
|
||||
});
|
||||
|
||||
this.initVersionCheck();
|
||||
|
||||
$(window).resize(function () {
|
||||
self.handleResize();
|
||||
});
|
||||
//this.handleResize();
|
||||
},
|
||||
|
||||
initVersionCheck: function () {
|
||||
// this checks for version updates
|
||||
|
||||
var self = this;
|
||||
var versionCheck = function () {
|
||||
$.ajax({
|
||||
async: true,
|
||||
crossDomain: true,
|
||||
dataType: "jsonp",
|
||||
url: "https://www.arangodb.org/repositories/versions.php" +
|
||||
"?callback=parseVersions",
|
||||
success: function (json) {
|
||||
if (typeof json !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
// turn our own version string into a version object
|
||||
var currentVersion =
|
||||
window.versionHelper.fromString(self.footerView.system.version);
|
||||
|
||||
// get our mainline version
|
||||
var mainLine = window.versionHelper.toStringMainLine(currentVersion);
|
||||
|
||||
var mainLines = Object.keys(json).
|
||||
sort(window.versionHelper.compareVersionStrings);
|
||||
var latestMainLine;
|
||||
mainLines.forEach(function (l) {
|
||||
if (json[l].stable) {
|
||||
if (window.versionHelper.compareVersionStrings(l, mainLine) > 0) {
|
||||
latestMainLine = json[l];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var update;
|
||||
var mainLineVersions;
|
||||
var latest;
|
||||
if (latestMainLine !== undefined &&
|
||||
Object.keys(latestMainLine.versions).length > 0) {
|
||||
mainLineVersions = Object.keys(latestMainLine.versions);
|
||||
mainLineVersions = mainLineVersions.
|
||||
sort(window.versionHelper.compareVersionStrings);
|
||||
latest = mainLineVersions[mainLineVersions.length - 1];
|
||||
|
||||
update = {
|
||||
type: "major",
|
||||
version: latest,
|
||||
changes: latestMainLine.versions[latest].changes
|
||||
};
|
||||
}
|
||||
|
||||
// check which stable mainline versions are available remotely
|
||||
if (update === undefined &&
|
||||
json.hasOwnProperty(mainLine) &&
|
||||
json[mainLine].stable &&
|
||||
json[mainLine].hasOwnProperty("versions") &&
|
||||
Object.keys(json[mainLine].versions).length > 0) {
|
||||
// sort by version numbers
|
||||
mainLineVersions = Object.keys(json[mainLine].versions);
|
||||
mainLineVersions = mainLineVersions.
|
||||
sort(window.versionHelper.compareVersionStrings);
|
||||
latest = mainLineVersions[mainLineVersions.length - 1];
|
||||
|
||||
var result = window.versionHelper.compareVersions(
|
||||
currentVersion,
|
||||
window.versionHelper.fromString(latest)
|
||||
);
|
||||
if (result < 0) {
|
||||
update = {
|
||||
type: "minor",
|
||||
version: latest,
|
||||
changes: json[mainLine].versions[latest].changes
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (update !== undefined) {
|
||||
var msg = "A newer version of ArangoDB (" + update.version +
|
||||
") has become available. You may want to check the " +
|
||||
"changelog at <a href=\"" + update.changes + "\">" +
|
||||
update.changes + "</a>";
|
||||
arangoHelper.arangoNotification(msg, 15000);
|
||||
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
// re-schedule the version check
|
||||
window.setTimeout(versionCheck, 60000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
window.setTimeout(versionCheck, 5000);
|
||||
},
|
||||
|
||||
logsAllowed: function () {
|
||||
return (window.currentDB.get('name') === '_system');
|
||||
},
|
||||
|
||||
checkUser: function () {
|
||||
if (window.userCollection.models.length === 0) {
|
||||
this.navigate("login", {trigger: true});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
login: function () {
|
||||
if (!this.loginView) {
|
||||
this.loginView = new window.loginView({
|
||||
collection: window.userCollection
|
||||
});
|
||||
}
|
||||
this.loginView.render();
|
||||
this.naviView.selectMenuItem('');
|
||||
},
|
||||
|
||||
collections: function () {
|
||||
var naviView = this.naviView;
|
||||
window.arangoCollectionsStore.fetch({
|
||||
success: function () {
|
||||
window.collectionsView.render();
|
||||
naviView.selectMenuItem('collections-menu');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
collection: function (colid) {
|
||||
if (!this.collectionView) {
|
||||
this.collectionView = new window.CollectionView();
|
||||
}
|
||||
this.collectionView.setColId(colid);
|
||||
this.collectionView.render();
|
||||
this.naviView.selectMenuItem('collections-menu');
|
||||
},
|
||||
collectionInfo: function (colid) {
|
||||
if (!this.collectionInfoView) {
|
||||
this.collectionInfoView = new window.CollectionInfoView();
|
||||
}
|
||||
this.collectionInfoView.setColId(colid);
|
||||
this.collectionInfoView.render();
|
||||
this.naviView.selectMenuItem('collections-menu');
|
||||
},
|
||||
newCollection: function () {
|
||||
if (!this.newCollectionView) {
|
||||
this.newCollectionView = new window.newCollectionView({});
|
||||
}
|
||||
this.newCollectionView.render();
|
||||
this.naviView.selectMenuItem('collections-menu');
|
||||
},
|
||||
|
||||
documents: function (colid, pageid) {
|
||||
if (!window.documentsView) {
|
||||
window.documentsView.initTable(colid, pageid);
|
||||
}
|
||||
window.documentsView.collectionID = colid;
|
||||
var type = arangoHelper.collectionApiType(colid);
|
||||
window.documentsView.colid = colid;
|
||||
window.documentsView.pageid = pageid;
|
||||
window.documentsView.type = type;
|
||||
window.documentsView.render();
|
||||
window.arangoDocumentsStore.getDocuments(colid, pageid);
|
||||
},
|
||||
|
||||
document: function (colid, docid) {
|
||||
window.documentView.colid = colid;
|
||||
window.documentView.docid = docid;
|
||||
window.documentView.render();
|
||||
var type = arangoHelper.collectionApiType(colid);
|
||||
window.documentView.type = type;
|
||||
window.documentView.typeCheck(type);
|
||||
},
|
||||
|
||||
shell: function () {
|
||||
if (!this.shellView) {
|
||||
this.shellView = new window.shellView();
|
||||
}
|
||||
this.shellView.render();
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
query: function () {
|
||||
if (!this.queryView) {
|
||||
this.queryView = new window.queryView();
|
||||
}
|
||||
this.queryView.render();
|
||||
this.naviView.selectMenuItem('query-menu');
|
||||
},
|
||||
|
||||
api: function () {
|
||||
if (!this.apiView) {
|
||||
this.apiView = new window.apiView();
|
||||
}
|
||||
this.apiView.render();
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
databases: function () {
|
||||
if (arangoHelper.databaseAllowed() === true) {
|
||||
if (!this.databaseView) {
|
||||
this.databaseView = new window.databaseView({
|
||||
collection: arangoDatabase
|
||||
});
|
||||
}
|
||||
this.databaseView.render();
|
||||
this.naviView.selectMenuItem('databases-menu');
|
||||
}
|
||||
else {
|
||||
this.navigate("#", {trigger: true});
|
||||
this.naviView.selectMenuItem('dashboard-menu');
|
||||
$('#databaseNavi').css('display', 'none');
|
||||
$('#databaseNaviSelect').css('display', 'none');
|
||||
}
|
||||
},
|
||||
|
||||
logs: function () {
|
||||
if (!this.logsAllowed()) {
|
||||
this.navigate('', { trigger: true });
|
||||
return;
|
||||
}
|
||||
|
||||
// check which stable mainline versions are available remotely
|
||||
if (update === undefined &&
|
||||
json.hasOwnProperty(mainLine) &&
|
||||
json[mainLine].stable &&
|
||||
json[mainLine].hasOwnProperty("versions") &&
|
||||
Object.keys(json[mainLine].versions).length > 0) {
|
||||
// sort by version numbers
|
||||
mainLineVersions = Object.keys(json[mainLine].versions);
|
||||
mainLineVersions = mainLineVersions.sort(window.versionHelper.compareVersionStrings);
|
||||
latest = mainLineVersions[mainLineVersions.length - 1];
|
||||
window.arangoLogsStore.fetch({
|
||||
success: function () {
|
||||
window.logsView.render();
|
||||
$('#logNav a[href="#all"]').tab('show');
|
||||
window.logsView.initLogTables();
|
||||
window.logsView.drawTable();
|
||||
$('#all-switch').click();
|
||||
}
|
||||
});
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
var result = window.versionHelper.compareVersions(
|
||||
currentVersion,
|
||||
window.versionHelper.fromString(latest)
|
||||
);
|
||||
if (result < 0) {
|
||||
update = {
|
||||
type: "minor",
|
||||
version: latest,
|
||||
changes: json[mainLine].versions[latest].changes
|
||||
};
|
||||
}
|
||||
dashboard: function () {
|
||||
this.naviView.selectMenuItem('dashboard-menu');
|
||||
if (this.statisticsDescriptionCollection === undefined) {
|
||||
this.statisticsDescriptionCollection = new window.StatisticsDescriptionCollection();
|
||||
this.statisticsDescriptionCollection.fetch({
|
||||
async: false
|
||||
});
|
||||
}
|
||||
|
||||
if (update !== undefined) {
|
||||
var msg = "A newer version of ArangoDB (" + update.version +
|
||||
") has become available. You may want to check the " +
|
||||
"changelog at <a href=\"" + update.changes + "\">" +
|
||||
update.changes + "</a>";
|
||||
// arangoHelper.arangoNotification(msg, 15000);
|
||||
if (this.statistics === undefined) {
|
||||
this.statisticsCollection = new window.StatisticsCollection();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
// re-schedule the version check
|
||||
window.setTimeout(versionCheck, 60000);
|
||||
}
|
||||
});
|
||||
};
|
||||
if (this.dashboardView === undefined) {
|
||||
this.dashboardView = new dashboardView({
|
||||
collection: this.statisticsCollection,
|
||||
description: this.statisticsDescriptionCollection,
|
||||
documentStore: window.arangoDocumentsStore,
|
||||
dygraphConfig: window.dygraphConfig
|
||||
});
|
||||
}
|
||||
this.dashboardView.render();
|
||||
},
|
||||
|
||||
window.setTimeout(versionCheck, 5000);
|
||||
},
|
||||
graph: function () {
|
||||
var self = this;
|
||||
window.arangoCollectionsStore.fetch({
|
||||
success: function () {
|
||||
self.graphView.render();
|
||||
self.naviView.selectMenuItem('graphviewer-menu');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
logsAllowed: function () {
|
||||
return (window.currentDB.get('name') === '_system');
|
||||
},
|
||||
graphManagement: function () {
|
||||
if (!this.graphManagementView) {
|
||||
this.graphManagementView =
|
||||
new window.GraphManagementView({collection: this.graphs});
|
||||
}
|
||||
this.graphManagementView.render();
|
||||
this.naviView.selectMenuItem('graphviewer-menu');
|
||||
},
|
||||
|
||||
checkUser: function () {
|
||||
if (window.userCollection.models.length === 0) {
|
||||
this.navigate("login", {trigger: true});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
graphAddNew: function () {
|
||||
if (!this.addNewGraphView) {
|
||||
this.addNewGraphView = new window.AddNewGraphView({
|
||||
collection: window.arangoCollectionsStore,
|
||||
graphs: this.graphs
|
||||
});
|
||||
}
|
||||
this.addNewGraphView.render();
|
||||
this.naviView.selectMenuItem('graphviewer-menu');
|
||||
},
|
||||
|
||||
login: function () {
|
||||
if (!this.loginView) {
|
||||
this.loginView = new window.loginView({
|
||||
collection: window.userCollection
|
||||
});
|
||||
}
|
||||
this.loginView.render();
|
||||
this.naviView.selectMenuItem('');
|
||||
},
|
||||
graphDelete: function (name) {
|
||||
if (!this.deleteGraphView) {
|
||||
this.deleteGraphView = new window.DeleteGraphView({
|
||||
collection: this.graphs
|
||||
});
|
||||
}
|
||||
this.deleteGraphView.render(name);
|
||||
this.naviView.selectMenuItem('graphviewer-menu');
|
||||
},
|
||||
|
||||
collections: function() {
|
||||
var naviView = this.naviView;
|
||||
window.arangoCollectionsStore.fetch({
|
||||
success: function () {
|
||||
window.collectionsView.render();
|
||||
naviView.selectMenuItem('collections-menu');
|
||||
applications: function () {
|
||||
if (this.applicationsView === undefined) {
|
||||
this.applicationsView = new window.ApplicationsView({
|
||||
collection: this.foxxList
|
||||
});
|
||||
}
|
||||
this.applicationsView.reload();
|
||||
this.naviView.selectMenuItem('applications-menu');
|
||||
},
|
||||
|
||||
applicationEdit: function (appkey) {
|
||||
this.foxxList.fetch({
|
||||
async: false
|
||||
});
|
||||
var editAppView = new window.foxxEditView(
|
||||
{model: this.foxxList.findWhere({_key: appkey})}
|
||||
);
|
||||
editAppView.render();
|
||||
},
|
||||
|
||||
applicationInstall: function (appkey) {
|
||||
this.foxxList.fetch({
|
||||
async: false
|
||||
});
|
||||
if (!this.installAppView) {
|
||||
this.installAppView = new window.foxxMountView({
|
||||
collection: this.foxxList
|
||||
});
|
||||
}
|
||||
this.installAppView.render(appkey);
|
||||
},
|
||||
|
||||
appDocumentation: function (key) {
|
||||
var docuView = new window.AppDocumentationView({key: key});
|
||||
docuView.render();
|
||||
this.naviView.selectMenuItem('applications-menu');
|
||||
},
|
||||
|
||||
handleSelectDatabase: function () {
|
||||
this.naviView.handleSelectDatabase();
|
||||
},
|
||||
|
||||
handleResize: function () {
|
||||
if (this.dashboardView) {
|
||||
this.dashboardView.resize();
|
||||
}
|
||||
var oldWidth = $('#content').width();
|
||||
var containerWidth = $(window).width() - 70;
|
||||
/*var spanWidth = 242;*/
|
||||
var spanWidth = 243;
|
||||
var divider = containerWidth / spanWidth;
|
||||
var roundDiv = parseInt(divider, 10);
|
||||
var newWidth = roundDiv * spanWidth - 2;
|
||||
var marginWidth = ((containerWidth + 30) - newWidth) / 2;
|
||||
/*
|
||||
$('#content').width(newWidth)
|
||||
.css('margin-left', marginWidth)
|
||||
.css('margin-right', marginWidth);
|
||||
*/
|
||||
// $('.footer-right p').css('margin-right', marginWidth + 20);
|
||||
// $('.footer-left p').css('margin-left', marginWidth + 20);
|
||||
if (newWidth !== oldWidth) {
|
||||
this.graphView.handleResize(newWidth);
|
||||
}
|
||||
},
|
||||
|
||||
userManagement: function () {
|
||||
if (!this.userManagementView) {
|
||||
this.userManagementView = new window.userManagementView({
|
||||
collection: window.userCollection
|
||||
});
|
||||
}
|
||||
this.userManagementView.render();
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
userProfile: function () {
|
||||
if (!this.userProfileView) {
|
||||
this.userProfileView = new window.userProfileView({
|
||||
collection: window.userCollection
|
||||
});
|
||||
}
|
||||
this.userProfileView.render();
|
||||
this.naviView.selectMenuItem('user-menu');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
collection: function(colid) {
|
||||
if (!this.collectionView) {
|
||||
this.collectionView = new window.CollectionView();
|
||||
}
|
||||
this.collectionView.setColId(colid);
|
||||
this.collectionView.render();
|
||||
this.naviView.selectMenuItem('collections-menu');
|
||||
},
|
||||
collectionInfo: function(colid) {
|
||||
if (!this.collectionInfoView) {
|
||||
this.collectionInfoView = new window.CollectionInfoView();
|
||||
}
|
||||
this.collectionInfoView.setColId(colid);
|
||||
this.collectionInfoView.render();
|
||||
this.naviView.selectMenuItem('collections-menu');
|
||||
},
|
||||
newCollection: function() {
|
||||
if (!this.newCollectionView) {
|
||||
this.newCollectionView = new window.newCollectionView({});
|
||||
}
|
||||
this.newCollectionView.render();
|
||||
this.naviView.selectMenuItem('collections-menu');
|
||||
},
|
||||
|
||||
documents: function(colid, pageid) {
|
||||
if (!window.documentsView) {
|
||||
window.documentsView.initTable(colid, pageid);
|
||||
}
|
||||
window.documentsView.collectionID = colid;
|
||||
var type = arangoHelper.collectionApiType(colid);
|
||||
window.documentsView.colid = colid;
|
||||
window.documentsView.pageid = pageid;
|
||||
window.documentsView.type = type;
|
||||
window.documentsView.render();
|
||||
window.arangoDocumentsStore.getDocuments(colid, pageid);
|
||||
},
|
||||
|
||||
document: function(colid, docid) {
|
||||
window.documentView.colid = colid;
|
||||
window.documentView.docid = docid;
|
||||
window.documentView.render();
|
||||
var type = arangoHelper.collectionApiType(colid);
|
||||
window.documentView.type = type;
|
||||
window.documentView.typeCheck(type);
|
||||
},
|
||||
|
||||
shell: function() {
|
||||
if (!this.shellView) {
|
||||
this.shellView = new window.shellView();
|
||||
}
|
||||
this.shellView.render();
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
query: function() {
|
||||
if (!this.queryView) {
|
||||
this.queryView = new window.queryView();
|
||||
}
|
||||
this.queryView.render();
|
||||
this.naviView.selectMenuItem('query-menu');
|
||||
},
|
||||
|
||||
api: function() {
|
||||
if (!this.apiView) {
|
||||
this.apiView = new window.apiView();
|
||||
}
|
||||
this.apiView.render();
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
databases: function() {
|
||||
if (arangoHelper.databaseAllowed() === true) {
|
||||
if (!this.databaseView) {
|
||||
this.databaseView = new window.databaseView({
|
||||
collection: arangoDatabase
|
||||
});
|
||||
}
|
||||
this.databaseView.render();
|
||||
this.naviView.selectMenuItem('databases-menu');
|
||||
}
|
||||
else {
|
||||
this.navigate("#", {trigger: true});
|
||||
this.naviView.selectMenuItem('dashboard-menu');
|
||||
$('#databaseNavi').css('display','none');
|
||||
$('#databaseNaviSelect').css('display','none');
|
||||
}
|
||||
},
|
||||
|
||||
logs: function() {
|
||||
if (! this.logsAllowed()) {
|
||||
this.navigate('', { trigger: true });
|
||||
return;
|
||||
}
|
||||
|
||||
window.arangoLogsStore.fetch({
|
||||
success: function () {
|
||||
window.logsView.render();
|
||||
$('#logNav a[href="#all"]').tab('show');
|
||||
window.logsView.initLogTables();
|
||||
window.logsView.drawTable();
|
||||
$('#all-switch').click();
|
||||
}
|
||||
});
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
dashboard: function() {
|
||||
this.naviView.selectMenuItem('dashboard-menu');
|
||||
if (this.statisticsDescriptionCollection === undefined) {
|
||||
this.statisticsDescriptionCollection = new window.StatisticsDescriptionCollection();
|
||||
this.statisticsDescriptionCollection.fetch({
|
||||
async:false
|
||||
});
|
||||
}
|
||||
if (this.statistics === undefined) {
|
||||
this.statisticsCollection = new window.StatisticsCollection();
|
||||
}
|
||||
if (this.dashboardView === undefined) {
|
||||
this.dashboardView = new dashboardView({
|
||||
collection: this.statisticsCollection,
|
||||
description: this.statisticsDescriptionCollection,
|
||||
documentStore: window.arangoDocumentsStore,
|
||||
dygraphConfig : window.dygraphConfig
|
||||
});
|
||||
}
|
||||
this.dashboardView.render();
|
||||
},
|
||||
|
||||
graph: function() {
|
||||
var self = this;
|
||||
window.arangoCollectionsStore.fetch({
|
||||
success: function () {
|
||||
self.graphView.render();
|
||||
self.naviView.selectMenuItem('graphviewer-menu');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
graphManagement: function() {
|
||||
if (!this.graphManagementView) {
|
||||
this.graphManagementView = new window.GraphManagementView({collection: this.graphs});
|
||||
}
|
||||
this.graphManagementView.render();
|
||||
this.naviView.selectMenuItem('graphviewer-menu');
|
||||
},
|
||||
|
||||
graphAddNew: function() {
|
||||
if (!this.addNewGraphView) {
|
||||
this.addNewGraphView = new window.AddNewGraphView({
|
||||
collection: window.arangoCollectionsStore,
|
||||
graphs: this.graphs
|
||||
});
|
||||
}
|
||||
this.addNewGraphView.render();
|
||||
this.naviView.selectMenuItem('graphviewer-menu');
|
||||
},
|
||||
|
||||
graphDelete: function(name) {
|
||||
if (!this.deleteGraphView) {
|
||||
this.deleteGraphView = new window.DeleteGraphView({
|
||||
collection: this.graphs
|
||||
});
|
||||
}
|
||||
this.deleteGraphView.render(name);
|
||||
this.naviView.selectMenuItem('graphviewer-menu');
|
||||
},
|
||||
|
||||
applications: function() {
|
||||
if (this.applicationsView === undefined) {
|
||||
this.applicationsView = new window.ApplicationsView({
|
||||
collection: this.foxxList
|
||||
});
|
||||
}
|
||||
this.applicationsView.reload();
|
||||
this.naviView.selectMenuItem('applications-menu');
|
||||
},
|
||||
|
||||
applicationEdit: function(appkey) {
|
||||
this.foxxList.fetch({
|
||||
async: false
|
||||
});
|
||||
var editAppView = new window.foxxEditView({model: this.foxxList.findWhere({_key: appkey})});
|
||||
editAppView.render();
|
||||
},
|
||||
|
||||
applicationInstall: function(appkey) {
|
||||
this.foxxList.fetch({
|
||||
async: false
|
||||
});
|
||||
if (!this.installAppView) {
|
||||
this.installAppView = new window.foxxMountView({
|
||||
collection: this.foxxList
|
||||
});
|
||||
}
|
||||
this.installAppView.render(appkey);
|
||||
},
|
||||
|
||||
appDocumentation: function(key) {
|
||||
var docuView = new window.AppDocumentationView({key: key});
|
||||
docuView.render();
|
||||
this.naviView.selectMenuItem('applications-menu');
|
||||
},
|
||||
|
||||
handleSelectDatabase: function () {
|
||||
this.naviView.handleSelectDatabase();
|
||||
},
|
||||
|
||||
handleResize: function () {
|
||||
if (this.dashboardView) {
|
||||
this.dashboardView.resize();
|
||||
}
|
||||
var oldWidth = $('#content').width();
|
||||
var containerWidth = $(window).width() - 70;
|
||||
/*var spanWidth = 242;*/
|
||||
var spanWidth = 243;
|
||||
var divider = containerWidth / spanWidth;
|
||||
var roundDiv = parseInt(divider, 10);
|
||||
var newWidth = roundDiv*spanWidth -2;
|
||||
var marginWidth = ((containerWidth+30) - newWidth)/2;
|
||||
/*
|
||||
$('#content').width(newWidth)
|
||||
.css('margin-left', marginWidth)
|
||||
.css('margin-right', marginWidth);
|
||||
*/
|
||||
// $('.footer-right p').css('margin-right', marginWidth + 20);
|
||||
// $('.footer-left p').css('margin-left', marginWidth + 20);
|
||||
if (newWidth !== oldWidth) {
|
||||
this.graphView.handleResize(newWidth);
|
||||
}
|
||||
},
|
||||
|
||||
userManagement: function() {
|
||||
if (!this.userManagementView) {
|
||||
this.userManagementView = new window.userManagementView({
|
||||
collection: window.userCollection
|
||||
});
|
||||
}
|
||||
this.userManagementView.render(false);
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
userProfile: function() {
|
||||
if (!this.userManagementView) {
|
||||
this.userManagementView = new window.userManagementView({
|
||||
collection: window.userCollection
|
||||
});
|
||||
}
|
||||
this.userManagementView.render(true);
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
}
|
||||
/*
|
||||
userProfile: function() {
|
||||
if (!this.userProfileView) {
|
||||
this.userProfileView = new window.userProfileView({
|
||||
collection: window.userCollection
|
||||
});
|
||||
}
|
||||
this.userProfileView.render();
|
||||
this.naviView.selectMenuItem('user-menu');
|
||||
}
|
||||
*/
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -143,7 +143,9 @@
|
|||
"frontend/js/views/foxxActiveView.js",
|
||||
"frontend/js/views/foxxInstalledView.js",
|
||||
"frontend/js/views/foxxEditView.js",
|
||||
"frontend/js/views/databaseView.js",
|
||||
"frontend/js/views/foxxMountView.js",
|
||||
"frontend/js/views/testView.js",
|
||||
"frontend/js/views/appDocumentationView.js",
|
||||
"frontend/js/views/graphView.js",
|
||||
"frontend/js/views/graphManagementView.js",
|
||||
|
@ -159,6 +161,9 @@
|
|||
"frontend/js/views/clusterDatabaseView.js",
|
||||
"frontend/js/views/clusterCollectionView.js",
|
||||
"frontend/js/views/clusterShardsView.js",
|
||||
"frontend/js/views/userManagementView.js",
|
||||
"frontend/js/views/userProfileView.js",
|
||||
"frontend/js/views/userBarView.js",
|
||||
|
||||
"frontend/js/views/statisticBarView.js",
|
||||
"frontend/js/views/userBarView.js",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,10 +91,9 @@ int TRI_InitMultiPointer (TRI_multi_pointer_t* array,
|
|||
array->_nrAdds = 0;
|
||||
array->_nrRems = 0;
|
||||
array->_nrResizes = 0;
|
||||
array->_nrProbes = 0;
|
||||
array->_nrProbesF = 0;
|
||||
array->_nrProbesA = 0;
|
||||
array->_nrProbesD = 0;
|
||||
array->_nrProbesR = 0;
|
||||
#endif
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
@ -123,9 +122,6 @@ void TRI_FreeMultiPointer (TRI_memory_zone_t* zone, TRI_multi_pointer_t* array)
|
|||
// --SECTION-- private functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//uint64_t ALL_HASH_ADDS = 0;
|
||||
//uint64_t ALL_HASH_COLLS = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief find an element or its place using the element hash function
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -151,9 +147,8 @@ static inline uint64_t FindElementPlace (TRI_multi_pointer_t* array,
|
|||
! array->isEqualElementElement(array, element,
|
||||
array->_table[i].ptr, false))) {
|
||||
i = TRI_IncModU64(i, array->_nrAlloc);
|
||||
//ALL_HASH_COLLS++;
|
||||
#ifdef TRI_INTERNAL_STATS
|
||||
array->_nrProbesA++;
|
||||
array->_nrProbes++;
|
||||
#endif
|
||||
}
|
||||
return i;
|
||||
|
@ -183,9 +178,8 @@ static uint64_t LookupByElement (TRI_multi_pointer_t* array,
|
|||
array->_table[i].ptr, true))) {
|
||||
i = TRI_IncModU64(i, array->_nrAlloc);
|
||||
#ifdef TRI_INTERNAL_STATS
|
||||
array->_nrProbesF++;
|
||||
array->_nrProbes++;
|
||||
#endif
|
||||
//ALL_HASH_COLLS++;
|
||||
}
|
||||
|
||||
if (array->_table[i].ptr != NULL) {
|
||||
|
@ -271,6 +265,9 @@ static void HealHole (TRI_multi_pointer_t* array, uint64_t i) {
|
|||
i = j; // Now heal this hole at j, j will be incremented right away
|
||||
}
|
||||
j = TRI_IncModU64(j, array->_nrAlloc);
|
||||
#ifdef TRI_INTERNAL_STATS
|
||||
array->_nrProbesD++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +294,10 @@ void* TRI_InsertElementMultiPointer (TRI_multi_pointer_t* array,
|
|||
uint64_t i, j;
|
||||
void* old;
|
||||
|
||||
//ALL_HASH_ADDS++;
|
||||
// if we were adding and the table is more than half full, extend it
|
||||
if (array->_nrAlloc < 2 * array->_nrUsed) {
|
||||
ResizeMultiPointer(array, 2 * array->_nrAlloc + 1);
|
||||
}
|
||||
|
||||
#ifdef TRI_INTERNAL_STATS
|
||||
// update statistics
|
||||
|
@ -324,7 +324,11 @@ void* TRI_InsertElementMultiPointer (TRI_multi_pointer_t* array,
|
|||
array->_table[i].ptr,true) ||
|
||||
array->_table[i].prev != TRI_MULTI_POINTER_INVALID_INDEX)) {
|
||||
i = TRI_IncModU64(i, array->_nrAlloc);
|
||||
//ALL_HASH_COLLS++;
|
||||
#ifdef TRI_INTERNAL_STATS
|
||||
// update statistics
|
||||
array->_ProbesA++;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// If this is free, we are the first with this key:
|
||||
|
@ -372,11 +376,6 @@ void* TRI_InsertElementMultiPointer (TRI_multi_pointer_t* array,
|
|||
}
|
||||
array->_nrUsed++;
|
||||
|
||||
// if we were adding and the table is more than half full, extend it
|
||||
if (array->_nrAlloc < 2 * array->_nrUsed) {
|
||||
ResizeMultiPointer(array, 2 * array->_nrAlloc + 1);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -509,13 +508,14 @@ static int ResizeMultiPointer (TRI_multi_pointer_t* array, size_t size) {
|
|||
|
||||
array->_nrAlloc = TRI_NextPrime((uint64_t) size);
|
||||
array->_table_alloc = TRI_Allocate(array->_memoryZone,
|
||||
array->_nrAlloc * sizeof(TRI_multi_pointer_entry_t), true);
|
||||
array->_nrAlloc * sizeof(TRI_multi_pointer_entry_t) + 64,true);
|
||||
array->_table = (TRI_multi_pointer_entry_t*)
|
||||
(((uint64_t) array->_table_alloc + 63) & ~((uint64_t)63));
|
||||
|
||||
if (array->_table == NULL) {
|
||||
array->_nrAlloc = oldAlloc;
|
||||
array->_table = oldTable;
|
||||
array->_table_alloc = oldTable_alloc;
|
||||
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -123,10 +123,11 @@ typedef struct TRI_multi_pointer_s {
|
|||
uint64_t _nrRems; // statistics: number of remove calls
|
||||
uint64_t _nrResizes; // statistics: number of resizes
|
||||
|
||||
uint64_t _nrProbes; // statistics: number of misses in FindElementPlace
|
||||
// and LookupByElement, used by insert, lookup and
|
||||
// remove
|
||||
uint64_t _nrProbesF; // statistics: number of misses while looking up
|
||||
uint64_t _nrProbesA; // statistics: number of misses while inserting
|
||||
uint64_t _nrProbesD; // statistics: number of misses while removing
|
||||
uint64_t _nrProbesR; // statistics: number of misses while adding
|
||||
#endif
|
||||
|
||||
TRI_memory_zone_t* _memoryZone;
|
||||
|
@ -216,33 +217,35 @@ int TRI_ResizeMultiPointer (TRI_multi_pointer_t*, size_t);
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief associative multi array of pointers with multiple keys
|
||||
///
|
||||
/// This is a data structure that can store pairs (p,k) where p is a
|
||||
/// pointer to an object and k is a pointer to one of the keys of the
|
||||
/// object. Each object has one ore more keys (for example multiple
|
||||
/// values in a list in a certain attribute) and multiple objects in the
|
||||
/// associative array can have the same key. Every pair (p,k) can be at
|
||||
/// most once in the array.
|
||||
/// This is a data structure that can store pairs (p,h) where p is a
|
||||
/// pointer to an object and h is a pointer to something identifying
|
||||
/// one of the keys of the object. Each object has one ore more keys
|
||||
/// (for example multiple values in a list in a certain attribute) and
|
||||
/// multiple objects in the associative array can have the same key.
|
||||
/// Every pair (p,h) can be at most once in the array.
|
||||
/// We want to offer constant time complexity for the following
|
||||
/// operations:
|
||||
/// - insert a pair into the array
|
||||
/// - delete a pair from the array
|
||||
/// - find one pair (p,k) with a given key k
|
||||
/// - find one pair (p,h) with a given key k
|
||||
/// Furthermore, we want to offer O(n) complexity for the following
|
||||
/// operation:
|
||||
/// - find the list of pointers p for which there is at least one pair
|
||||
/// (p,k) in the array, where n is the number of objects in the array
|
||||
/// with this key
|
||||
/// (p,h) in the array, where n is the number of objects in the array
|
||||
/// with the given key k
|
||||
/// To this end, we use a hash table and ask the user to provide the following:
|
||||
/// - a way to hash a pair (p,k)
|
||||
/// - a way to hash a key k
|
||||
/// - a way to compare two keys
|
||||
/// - a way to compare two elements
|
||||
/// - a way to hash a pair (p,h) by its full identity
|
||||
/// - a way to hash a pair (p,h) but only with respect to its key k
|
||||
/// - a way to hash a given key k
|
||||
/// - a way to compare the key of a pair (p,h) with an external key k
|
||||
/// - a way to compare the keys of two pairs (p,h) and (p',h')
|
||||
/// - a way to compare two pairs (p,h) and (p',h')
|
||||
/// To avoid unnecessary comparisons the user can guarantee that s/he will
|
||||
/// only try to store non-identical pairs into the array. This enables
|
||||
/// the code to skip comparisons which would otherwise be necessary to
|
||||
/// ensure uniqueness.
|
||||
/// The idea of the algorithm is as follows: Each slot in the hash table
|
||||
/// contains a pointer to the actual object, a pointer to its key, as
|
||||
/// contains a pointer to the actual object, a pointer to its key helper, as
|
||||
/// well as two unsigned integers "prev" and "next" (being indices in
|
||||
/// the hash table) to organise a linked list of entries, *within the
|
||||
/// same hash table*. All pairs with the same key are kept in a doubly
|
||||
|
@ -256,28 +259,36 @@ int TRI_ResizeMultiPointer (TRI_multi_pointer_t*, size_t);
|
|||
///
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_multi_pointer_key_entry_s {
|
||||
typedef struct TRI_multi_pair_entry_s {
|
||||
void* ptr; // a pointer to the data stored in this slot
|
||||
void* key; // a pointer to the key stored in this slot
|
||||
void* key; // a pointer to the helper to find the key stored in this slot
|
||||
TRI_multi_pointer_index_t next; // index of the data following in the linked
|
||||
// list of all items with the same key
|
||||
TRI_multi_pointer_index_t prev; // index of the data preceding in the linked
|
||||
// list of all items with the same key
|
||||
} TRI_multi_pointer_key_entry_t;
|
||||
} TRI_multi_pair_entry_t;
|
||||
|
||||
typedef struct TRI_multi_pointer_key_s {
|
||||
uint64_t (*hashKey) (struct TRI_multi_pointer_s*, void const* key);
|
||||
uint64_t (*hashElement) (struct TRI_multi_pointer_s*, void const* element);
|
||||
typedef struct TRI_multi_pair_s {
|
||||
uint64_t (*hashKeyKey) (struct TRI_multi_pair_s*, void const* key);
|
||||
uint64_t (*hashKeyPair) (struct TRI_multi_pair_s*,
|
||||
void const* element, void const* keyhelper);
|
||||
uint64_t (*hashPair) (struct TRI_multi_pair_s*,
|
||||
void const* element, void const* keyhelper);
|
||||
|
||||
bool (*isEqualKeyKey) (struct TRI_multi_pointer_s*, void const* key1,
|
||||
void const* key2);
|
||||
bool (*isEqualElementElement) (struct TRI_multi_pointer_s*,
|
||||
void const* el1, void const* el2);
|
||||
bool (*isEqualKeyPairKey) (struct TRI_multi_pair_s*,
|
||||
void const* element, void const* keyhelper,
|
||||
void const* key);
|
||||
bool (*isEqualKeyPairPair) (struct TRI_multi_pair_s*,
|
||||
void const* element1, void const* keyhelper1,
|
||||
void const* element2, void const* keyhelper2);
|
||||
bool (*isEqualPairPair) (struct TRI_multi_pair_s*,
|
||||
void const* element1, void const* keyhelper1,
|
||||
void const* element2, void const* keyhelper2);
|
||||
|
||||
uint64_t _nrAlloc; // the size of the table
|
||||
uint64_t _nrUsed; // the number of used entries
|
||||
|
||||
TRI_multi_pointer_key_entry_t* _table; // the table itself
|
||||
TRI_multi_pair_entry_t* _table; // the table itself
|
||||
|
||||
#ifdef TRI_INTERNAL_STATS
|
||||
uint64_t _nrFinds; // statistics: number of lookup calls
|
||||
|
@ -285,15 +296,16 @@ typedef struct TRI_multi_pointer_key_s {
|
|||
uint64_t _nrRems; // statistics: number of remove calls
|
||||
uint64_t _nrResizes; // statistics: number of resizes
|
||||
|
||||
uint64_t _nrProbes; // statistics: number of misses in FindPairPlace
|
||||
// and LookupByPair, used by insert, lookup and
|
||||
// remove
|
||||
uint64_t _nrProbesF; // statistics: number of misses while looking up
|
||||
uint64_t _nrProbesA; // statistics: number of misses while inserting
|
||||
uint64_t _nrProbesD; // statistics: number of misses while removing
|
||||
uint64_t _nrProbesR; // statistics: number of misses while adding
|
||||
#endif
|
||||
|
||||
TRI_memory_zone_t* _memoryZone;
|
||||
}
|
||||
TRI_multi_pointer_key_t;
|
||||
TRI_multi_pair_t;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
|
@ -303,31 +315,35 @@ TRI_multi_pointer_key_t;
|
|||
/// @brief initialises an array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_InitMultiPointerKey (
|
||||
TRI_multi_pointer_key_t* array,
|
||||
TRI_memory_zone_t*,
|
||||
uint64_t (*hashKey) (TRI_multi_pointer_key_t*,
|
||||
void const*),
|
||||
uint64_t (*hashElement) (TRI_multi_pointer_key_t*,
|
||||
void const*),
|
||||
bool (*isEqualKeyKey) (TRI_multi_pointer_key_t*,
|
||||
void const*, void const*),
|
||||
bool (*isEqualElementElement) (
|
||||
TRI_multi_pointer_key_t*,
|
||||
void const*,
|
||||
void const*));
|
||||
int TRI_InitMultiPair (
|
||||
TRI_multi_pair_t* array,
|
||||
TRI_memory_zone_t*,
|
||||
uint64_t (*hashKeyKey) (struct TRI_multi_pair_s*, void const* key),
|
||||
uint64_t (*hashKeyPair) (struct TRI_multi_pair_s*,
|
||||
void const* element, void const* keyhelper),
|
||||
uint64_t (*hashPair) (struct TRI_multi_pair_s*,
|
||||
void const* element, void const* keyhelper),
|
||||
bool (*isEqualKeyPairKey) (struct TRI_multi_pair_s*,
|
||||
void const* element, void const* keyhelper,
|
||||
void const* key),
|
||||
bool (*isEqualKeyPairPair) (struct TRI_multi_pair_s*,
|
||||
void const* element1, void const* keyhelper1,
|
||||
void const* element2, void const* keyhelper2),
|
||||
bool (*isEqualPairPair) (struct TRI_multi_pair_s*,
|
||||
void const* element1, void const* keyhelper1,
|
||||
void const* element2, void const* keyhelper2));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys an array, but does not free the pointer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_DestroyMultiPointerKey (TRI_multi_pointer_key_t*);
|
||||
void TRI_DestroyMultiPair (TRI_multi_pair_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys an array and frees the pointer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeMultiPointerKey (TRI_memory_zone_t*, TRI_multi_pointer_key_t*);
|
||||
void TRI_FreeMultiPair (TRI_memory_zone_t*, TRI_multi_pair_t*);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
|
@ -337,34 +353,41 @@ void TRI_FreeMultiPointerKey (TRI_memory_zone_t*, TRI_multi_pointer_key_t*);
|
|||
/// @brief lookups an element given a key
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_vector_pointer_t TRI_LookupByKeyMultiPointerKey (
|
||||
TRI_memory_zone_t*,
|
||||
TRI_multi_pointer_key_t*,
|
||||
void const* key);
|
||||
TRI_vector_pointer_t TRI_LookupByKeyMultiPair (TRI_memory_zone_t*,
|
||||
TRI_multi_pair_t*,
|
||||
void const* key);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds a key/element to the array
|
||||
/// @brief adds a pair to the array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* TRI_InsertElementMultiPointerKey (TRI_multi_pointer_key_t*,
|
||||
void* element,
|
||||
void* key,
|
||||
bool const overwrite,
|
||||
bool const checkEquality);
|
||||
void* TRI_InsertPairMultiPair (TRI_multi_pair_t*,
|
||||
void* element,
|
||||
void* keyhelper,
|
||||
bool const overwrite,
|
||||
bool const checkEquality);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief removes an element from the array
|
||||
/// @brief looks up a pair in the array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* TRI_RemoveElementMultiPointerKey (TRI_multi_pointer_key_t*,
|
||||
void const* element,
|
||||
void const* key);
|
||||
void* TRI_LookupPairMultiPair (TRI_multi_pair_t*,
|
||||
void* element,
|
||||
void* keyhelper);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief removes pair from the array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* TRI_RemovePairMultiPair (TRI_multi_pair_t*,
|
||||
void const* element,
|
||||
void const* keyhelper);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief resize the array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_ResizeMultiPointerKey (TRI_multi_pointer_key_t*, size_t);
|
||||
int TRI_ResizeMultiPair (TRI_multi_pair_t*, size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue