mirror of https://gitee.com/bigwinds/arangodb
Merge branch '1.1' of github.com:triAGENS/ArangoDB into 1.1
This commit is contained in:
commit
02d02cd457
|
@ -125,7 +125,7 @@
|
||||||
///
|
///
|
||||||
/// @GE{Edge}: Edges in ArangoDB are special documents. In addition to the
|
/// @GE{Edge}: Edges in ArangoDB are special documents. In addition to the
|
||||||
/// internal attributes @LIT{_id} and @LIT{_rev}, they have two attributes
|
/// internal attributes @LIT{_id} and @LIT{_rev}, they have two attributes
|
||||||
/// @LIT{_form} and @LIT{_to}, which contain document handles namely the
|
/// @LIT{_from} and @LIT{_to}, which contain document handles namely the
|
||||||
/// start-point and the end-point of the edge.
|
/// start-point and the end-point of the edge.
|
||||||
///
|
///
|
||||||
/// @page GlossaryEdgeCollection
|
/// @page GlossaryEdgeCollection
|
||||||
|
|
|
@ -482,7 +482,7 @@ TRI_json_t* RestImportHandler::parseJsonLine (const string& line) {
|
||||||
|
|
||||||
if (errmsg != 0) {
|
if (errmsg != 0) {
|
||||||
// must free this error message, otherwise we'll have a memleak
|
// must free this error message, otherwise we'll have a memleak
|
||||||
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, errmsg);
|
TRI_FreeString(TRI_CORE_MEM_ZONE, errmsg);
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -721,7 +721,7 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// run console
|
// run script
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
case OperationMode::MODE_SCRIPT: {
|
case OperationMode::MODE_SCRIPT: {
|
||||||
|
@ -787,15 +787,15 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
|
||||||
case OperationMode::MODE_CONSOLE: {
|
case OperationMode::MODE_CONSOLE: {
|
||||||
context->_context->Global()->Set(v8::String::New("DATABASEPATH"), v8::String::New(_databasePath.c_str()), v8::ReadOnly);
|
context->_context->Global()->Set(v8::String::New("DATABASEPATH"), v8::String::New(_databasePath.c_str()), v8::ReadOnly);
|
||||||
context->_context->Global()->Set(v8::String::New("VALGRIND"), _runningOnValgrind ? v8::True() : v8::False(), v8::ReadOnly);
|
context->_context->Global()->Set(v8::String::New("VALGRIND"), _runningOnValgrind ? v8::True() : v8::False(), v8::ReadOnly);
|
||||||
V8LineEditor* console = new V8LineEditor(context->_context, ".arango");
|
V8LineEditor console(context->_context, ".arango");
|
||||||
|
|
||||||
console->open(true);
|
console.open(true);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
while(! v8::V8::IdleNotification()) {
|
while(! v8::V8::IdleNotification()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char* input = console->prompt("arangod> ");
|
char* input = console.prompt("arangod> ");
|
||||||
|
|
||||||
if (input == 0) {
|
if (input == 0) {
|
||||||
printf("<ctrl-D>\n%s\n", TRI_BYE_MESSAGE);
|
printf("<ctrl-D>\n%s\n", TRI_BYE_MESSAGE);
|
||||||
|
@ -807,7 +807,7 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console->addHistory(input);
|
console.addHistory(input);
|
||||||
|
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::TryCatch tryCatch;
|
v8::TryCatch tryCatch;
|
||||||
|
@ -820,10 +820,6 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console->close();
|
|
||||||
|
|
||||||
delete console;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,12 +958,12 @@ int ArangoServer::executeRubyConsole () {
|
||||||
// create a line editor
|
// create a line editor
|
||||||
printf("ArangoDB MRuby shell [DB version %s]\n", TRIAGENS_VERSION);
|
printf("ArangoDB MRuby shell [DB version %s]\n", TRIAGENS_VERSION);
|
||||||
|
|
||||||
MRLineEditor* console = new MRLineEditor(context->_mrb, ".arango-mrb");
|
MRLineEditor console(context->_mrb, ".arango-mrb");
|
||||||
|
|
||||||
console->open(false);
|
console.open(false);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char* input = console->prompt("arangod> ");
|
char* input = console.prompt("arangod> ");
|
||||||
|
|
||||||
if (input == 0) {
|
if (input == 0) {
|
||||||
printf("<ctrl-D>\n" TRI_BYE_MESSAGE "\n");
|
printf("<ctrl-D>\n" TRI_BYE_MESSAGE "\n");
|
||||||
|
@ -979,7 +975,7 @@ int ArangoServer::executeRubyConsole () {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console->addHistory(input);
|
console.addHistory(input);
|
||||||
|
|
||||||
struct mrb_parser_state* p = mrb_parse_string(context->_mrb, input, NULL);
|
struct mrb_parser_state* p = mrb_parse_string(context->_mrb, input, NULL);
|
||||||
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, input);
|
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, input);
|
||||||
|
@ -1011,8 +1007,7 @@ int ArangoServer::executeRubyConsole () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// close the console
|
// close the console
|
||||||
console->close();
|
console.close();
|
||||||
delete console;
|
|
||||||
|
|
||||||
// close the database
|
// close the database
|
||||||
closeDatabase();
|
closeDatabase();
|
||||||
|
|
|
@ -400,6 +400,7 @@ void TRI_InitSkipList (TRI_skiplist_t* skiplist, size_t elementSize,
|
||||||
// do it here once off.
|
// do it here once off.
|
||||||
// ..........................................................................
|
// ..........................................................................
|
||||||
skiplist->_base._random = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(uint32_t) * skiplist->_base._numRandom, false);
|
skiplist->_base._random = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(uint32_t) * skiplist->_base._numRandom, false);
|
||||||
|
// TODO: memory allocation might fail
|
||||||
|
|
||||||
// ..........................................................................
|
// ..........................................................................
|
||||||
// Assign the element size
|
// Assign the element size
|
||||||
|
|
|
@ -2528,22 +2528,22 @@ void TRI_InitV8Queries (v8::Handle<v8::Context> context) {
|
||||||
rt = v8g->VocbaseColTempl;
|
rt = v8g->VocbaseColTempl;
|
||||||
|
|
||||||
rt->Set(AllFuncName, v8::FunctionTemplate::New(JS_AllQuery));
|
rt->Set(AllFuncName, v8::FunctionTemplate::New(JS_AllQuery));
|
||||||
rt->Set(AllNLFuncName, v8::FunctionTemplate::New(JS_AllNLQuery));
|
rt->Set(AllNLFuncName, v8::FunctionTemplate::New(JS_AllNLQuery), v8::DontEnum);
|
||||||
rt->Set(ByConditionBitarrayFuncName, v8::FunctionTemplate::New(JS_ByConditionBitarray));
|
rt->Set(ByConditionBitarrayFuncName, v8::FunctionTemplate::New(JS_ByConditionBitarray));
|
||||||
rt->Set(ByConditionBitarrayNLFuncName, v8::FunctionTemplate::New(JS_ByConditionNLBitarray));
|
rt->Set(ByConditionBitarrayNLFuncName, v8::FunctionTemplate::New(JS_ByConditionNLBitarray), v8::DontEnum);
|
||||||
rt->Set(ByConditionSkiplistFuncName, v8::FunctionTemplate::New(JS_ByConditionSkiplist));
|
rt->Set(ByConditionSkiplistFuncName, v8::FunctionTemplate::New(JS_ByConditionSkiplist));
|
||||||
rt->Set(ByConditionSkiplistNLFuncName, v8::FunctionTemplate::New(JS_ByConditionNLSkiplist));
|
rt->Set(ByConditionSkiplistNLFuncName, v8::FunctionTemplate::New(JS_ByConditionNLSkiplist), v8::DontEnum);
|
||||||
rt->Set(ByExampleBitarrayFuncName, v8::FunctionTemplate::New(JS_ByExampleBitarray));
|
rt->Set(ByExampleBitarrayFuncName, v8::FunctionTemplate::New(JS_ByExampleBitarray));
|
||||||
rt->Set(ByExampleBitarrayNLFuncName, v8::FunctionTemplate::New(JS_ByExampleNLBitarray));
|
rt->Set(ByExampleBitarrayNLFuncName, v8::FunctionTemplate::New(JS_ByExampleNLBitarray), v8::DontEnum);
|
||||||
rt->Set(ByExampleFuncName, v8::FunctionTemplate::New(JS_ByExampleQuery));
|
rt->Set(ByExampleFuncName, v8::FunctionTemplate::New(JS_ByExampleQuery));
|
||||||
rt->Set(ByExampleHashFuncName, v8::FunctionTemplate::New(JS_ByExampleHashIndex));
|
rt->Set(ByExampleHashFuncName, v8::FunctionTemplate::New(JS_ByExampleHashIndex));
|
||||||
rt->Set(ByExampleHashNLFuncName, v8::FunctionTemplate::New(JS_ByExampleNLHashIndex));
|
rt->Set(ByExampleHashNLFuncName, v8::FunctionTemplate::New(JS_ByExampleNLHashIndex), v8::DontEnum);
|
||||||
rt->Set(ByExampleSkiplistFuncName, v8::FunctionTemplate::New(JS_ByExampleSkiplist));
|
rt->Set(ByExampleSkiplistFuncName, v8::FunctionTemplate::New(JS_ByExampleSkiplist));
|
||||||
rt->Set(ByExampleSkiplistNLFuncName, v8::FunctionTemplate::New(JS_ByExampleNLSkiplist));
|
rt->Set(ByExampleSkiplistNLFuncName, v8::FunctionTemplate::New(JS_ByExampleNLSkiplist), v8::DontEnum);
|
||||||
rt->Set(NearFuncName, v8::FunctionTemplate::New(JS_NearQuery));
|
rt->Set(NearFuncName, v8::FunctionTemplate::New(JS_NearQuery));
|
||||||
rt->Set(NearNLFuncName, v8::FunctionTemplate::New(JS_NearNLQuery));
|
rt->Set(NearNLFuncName, v8::FunctionTemplate::New(JS_NearNLQuery), v8::DontEnum);
|
||||||
rt->Set(WithinFuncName, v8::FunctionTemplate::New(JS_WithinQuery));
|
rt->Set(WithinFuncName, v8::FunctionTemplate::New(JS_WithinQuery));
|
||||||
rt->Set(WithinNLFuncName, v8::FunctionTemplate::New(JS_WithinNLQuery));
|
rt->Set(WithinNLFuncName, v8::FunctionTemplate::New(JS_WithinNLQuery), v8::DontEnum);
|
||||||
rt->Set(EdgesFuncName, v8::FunctionTemplate::New(JS_EdgesQuery));
|
rt->Set(EdgesFuncName, v8::FunctionTemplate::New(JS_EdgesQuery));
|
||||||
rt->Set(InEdgesFuncName, v8::FunctionTemplate::New(JS_InEdgesQuery));
|
rt->Set(InEdgesFuncName, v8::FunctionTemplate::New(JS_InEdgesQuery));
|
||||||
rt->Set(OutEdgesFuncName, v8::FunctionTemplate::New(JS_OutEdgesQuery));
|
rt->Set(OutEdgesFuncName, v8::FunctionTemplate::New(JS_OutEdgesQuery));
|
||||||
|
|
|
@ -1011,8 +1011,10 @@ static TRI_doc_mptr_t CreateShapedJson (TRI_primary_collection_t* primary,
|
||||||
marker._shape = json->_sid;
|
marker._shape = json->_sid;
|
||||||
|
|
||||||
return CreateDocument(collection,
|
return CreateDocument(collection,
|
||||||
&marker, sizeof(marker),
|
&marker,
|
||||||
json->_data.data, json->_data.length,
|
sizeof(marker),
|
||||||
|
json->_data.data,
|
||||||
|
json->_data.length,
|
||||||
&result,
|
&result,
|
||||||
data,
|
data,
|
||||||
did,
|
did,
|
||||||
|
@ -1128,8 +1130,10 @@ static TRI_doc_mptr_t UpdateShapedJson (TRI_primary_collection_t* primary,
|
||||||
|
|
||||||
return UpdateDocument(collection,
|
return UpdateDocument(collection,
|
||||||
header,
|
header,
|
||||||
&marker, sizeof(marker),
|
&marker,
|
||||||
json->_data.data, json->_data.length,
|
sizeof(marker),
|
||||||
|
json->_data.data,
|
||||||
|
json->_data.length,
|
||||||
rid,
|
rid,
|
||||||
oldRid,
|
oldRid,
|
||||||
policy,
|
policy,
|
||||||
|
|
|
@ -91,7 +91,7 @@ static TRI_doc_mptr_t* RequestSimpleHeaders (TRI_headers_t* h) {
|
||||||
begin = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, NUMBER_HEADERS_PER_BLOCK * headers->_headerSize, false);
|
begin = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, NUMBER_HEADERS_PER_BLOCK * headers->_headerSize, false);
|
||||||
|
|
||||||
// out of memory
|
// out of memory
|
||||||
if (!begin) {
|
if (begin == NULL) {
|
||||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,12 +244,12 @@ static void InitMRClientConnection (mrb_state* mrb, MRubyClientConnection* conne
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static void RunShell (mrb_state* mrb) {
|
static void RunShell (mrb_state* mrb) {
|
||||||
MRLineEditor* console = new MRLineEditor(mrb, ".arango-mrb");
|
MRLineEditor* console(mrb, ".arango-mrb");
|
||||||
|
|
||||||
console->open(false /*! NoAutoComplete*/);
|
console.open(false /*! NoAutoComplete*/);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char* input = console->prompt("arangoirb> ");
|
char* input = console.prompt("arangoirb> ");
|
||||||
|
|
||||||
if (input == 0) {
|
if (input == 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -260,7 +260,7 @@ static void RunShell (mrb_state* mrb) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console->addHistory(input);
|
console.addHistory(input);
|
||||||
|
|
||||||
struct mrb_parser_state* p = mrb_parse_nstring(mrb, input, strlen(input), NULL);
|
struct mrb_parser_state* p = mrb_parse_nstring(mrb, input, strlen(input), NULL);
|
||||||
TRI_FreeString(TRI_CORE_MEM_ZONE, input);
|
TRI_FreeString(TRI_CORE_MEM_ZONE, input);
|
||||||
|
@ -291,7 +291,7 @@ static void RunShell (mrb_state* mrb) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console->close();
|
console.close();
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
|
|
|
@ -809,15 +809,15 @@ static void RunShell (v8::Handle<v8::Context> context) {
|
||||||
v8::Context::Scope contextScope(context);
|
v8::Context::Scope contextScope(context);
|
||||||
v8::Local<v8::String> name(v8::String::New("(shell)"));
|
v8::Local<v8::String> name(v8::String::New("(shell)"));
|
||||||
|
|
||||||
V8LineEditor* console = new V8LineEditor(context, ".arangosh");
|
V8LineEditor console(context, ".arangosh");
|
||||||
|
|
||||||
console->open(BaseClient.autoComplete());
|
console.open(BaseClient.autoComplete());
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
while (! v8::V8::IdleNotification()) {
|
while (! v8::V8::IdleNotification()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char* input = console->prompt("arangosh> ");
|
char* input = console.prompt("arangosh> ");
|
||||||
|
|
||||||
if (input == 0) {
|
if (input == 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -839,7 +839,7 @@ static void RunShell (v8::Handle<v8::Context> context) {
|
||||||
input = TRI_DuplicateString("help()");
|
input = TRI_DuplicateString("help()");
|
||||||
}
|
}
|
||||||
|
|
||||||
console->addHistory(input);
|
console.addHistory(input);
|
||||||
|
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::TryCatch tryCatch;
|
v8::TryCatch tryCatch;
|
||||||
|
@ -856,9 +856,7 @@ static void RunShell (v8::Handle<v8::Context> context) {
|
||||||
BaseClient.stopPager();
|
BaseClient.stopPager();
|
||||||
}
|
}
|
||||||
|
|
||||||
console->close();
|
console.close();
|
||||||
|
|
||||||
delete console;
|
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ bool SocketTask::fillReadBuffer (bool& closed) {
|
||||||
else if (nr == 0) {
|
else if (nr == 0) {
|
||||||
closed = true;
|
closed = true;
|
||||||
|
|
||||||
LOGGER_TRACE << "read return 0 with " << errno << " (" << strerror(errno) << ")";
|
LOGGER_TRACE << "read returned 0";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ using namespace std;
|
||||||
|
|
||||||
LineEditor::LineEditor (std::string const& history)
|
LineEditor::LineEditor (std::string const& history)
|
||||||
: _current(),
|
: _current(),
|
||||||
_historyFilename(history) {
|
_historyFilename(history),
|
||||||
|
_state(STATE_NONE) {
|
||||||
rl_initialize();
|
rl_initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ LineEditor::LineEditor (std::string const& history)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LineEditor::~LineEditor () {
|
LineEditor::~LineEditor () {
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -85,6 +87,8 @@ bool LineEditor::open (bool) {
|
||||||
using_history();
|
using_history();
|
||||||
stifle_history(MAX_HISTORY_ENTRIES);
|
stifle_history(MAX_HISTORY_ENTRIES);
|
||||||
|
|
||||||
|
_state = STATE_OPENED;
|
||||||
|
|
||||||
return read_history(historyPath().c_str()) == 0;
|
return read_history(historyPath().c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +97,13 @@ bool LineEditor::open (bool) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool LineEditor::close () {
|
bool LineEditor::close () {
|
||||||
|
if (_state != STATE_OPENED) {
|
||||||
|
// avoid duplicate saving of history
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_state = STATE_CLOSED;
|
||||||
|
|
||||||
return (write_history(historyPath().c_str()) == 0);
|
return (write_history(historyPath().c_str()) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,33 @@ class LineEditor {
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- private types
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup LineEditor
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief state of the console
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
STATE_NONE = 0,
|
||||||
|
STATE_OPENED,
|
||||||
|
STATE_CLOSED,
|
||||||
|
}
|
||||||
|
console_state_e;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- protected variables
|
// --SECTION-- protected variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -188,6 +215,12 @@ class LineEditor {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string _historyFilename;
|
std::string _historyFilename;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief current console state
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
console_state_e _state;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue