1
0
Fork 0

Merge branch '1.1' of github.com:triAGENS/ArangoDB into 1.1

This commit is contained in:
a-brandt 2012-10-16 17:24:18 +02:00
commit 02d02cd457
12 changed files with 87 additions and 45 deletions

View File

@ -125,7 +125,7 @@
///
/// @GE{Edge}: Edges in ArangoDB are special documents. In addition to the
/// 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.
///
/// @page GlossaryEdgeCollection

View File

@ -482,7 +482,7 @@ TRI_json_t* RestImportHandler::parseJsonLine (const string& line) {
if (errmsg != 0) {
// 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;
}

View File

@ -721,7 +721,7 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
}
// .............................................................................
// run console
// run script
// .............................................................................
case OperationMode::MODE_SCRIPT: {
@ -787,15 +787,15 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
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("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(! v8::V8::IdleNotification()) {
}
char* input = console->prompt("arangod> ");
char* input = console.prompt("arangod> ");
if (input == 0) {
printf("<ctrl-D>\n%s\n", TRI_BYE_MESSAGE);
@ -807,7 +807,7 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
continue;
}
console->addHistory(input);
console.addHistory(input);
v8::HandleScope scope;
v8::TryCatch tryCatch;
@ -820,10 +820,6 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
}
}
console->close();
delete console;
break;
}
@ -962,12 +958,12 @@ int ArangoServer::executeRubyConsole () {
// create a line editor
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) {
char* input = console->prompt("arangod> ");
char* input = console.prompt("arangod> ");
if (input == 0) {
printf("<ctrl-D>\n" TRI_BYE_MESSAGE "\n");
@ -979,7 +975,7 @@ int ArangoServer::executeRubyConsole () {
continue;
}
console->addHistory(input);
console.addHistory(input);
struct mrb_parser_state* p = mrb_parse_string(context->_mrb, input, NULL);
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, input);
@ -1011,8 +1007,7 @@ int ArangoServer::executeRubyConsole () {
}
// close the console
console->close();
delete console;
console.close();
// close the database
closeDatabase();

View File

@ -400,6 +400,7 @@ void TRI_InitSkipList (TRI_skiplist_t* skiplist, size_t elementSize,
// do it here once off.
// ..........................................................................
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

View File

@ -2528,22 +2528,22 @@ void TRI_InitV8Queries (v8::Handle<v8::Context> context) {
rt = v8g->VocbaseColTempl;
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(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(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(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(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(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(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(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(InEdgesFuncName, v8::FunctionTemplate::New(JS_InEdgesQuery));
rt->Set(OutEdgesFuncName, v8::FunctionTemplate::New(JS_OutEdgesQuery));

View File

@ -1011,8 +1011,10 @@ static TRI_doc_mptr_t CreateShapedJson (TRI_primary_collection_t* primary,
marker._shape = json->_sid;
return CreateDocument(collection,
&marker, sizeof(marker),
json->_data.data, json->_data.length,
&marker,
sizeof(marker),
json->_data.data,
json->_data.length,
&result,
data,
did,
@ -1128,8 +1130,10 @@ static TRI_doc_mptr_t UpdateShapedJson (TRI_primary_collection_t* primary,
return UpdateDocument(collection,
header,
&marker, sizeof(marker),
json->_data.data, json->_data.length,
&marker,
sizeof(marker),
json->_data.data,
json->_data.length,
rid,
oldRid,
policy,

View File

@ -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);
// out of memory
if (!begin) {
if (begin == NULL) {
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
return NULL;
}

View File

@ -244,12 +244,12 @@ static void InitMRClientConnection (mrb_state* mrb, MRubyClientConnection* conne
////////////////////////////////////////////////////////////////////////////////
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) {
char* input = console->prompt("arangoirb> ");
char* input = console.prompt("arangoirb> ");
if (input == 0) {
break;
@ -260,7 +260,7 @@ static void RunShell (mrb_state* mrb) {
continue;
}
console->addHistory(input);
console.addHistory(input);
struct mrb_parser_state* p = mrb_parse_nstring(mrb, input, strlen(input), NULL);
TRI_FreeString(TRI_CORE_MEM_ZONE, input);
@ -291,7 +291,7 @@ static void RunShell (mrb_state* mrb) {
}
}
console->close();
console.close();
cout << endl;

View File

@ -809,15 +809,15 @@ static void RunShell (v8::Handle<v8::Context> context) {
v8::Context::Scope contextScope(context);
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 (! v8::V8::IdleNotification()) {
}
char* input = console->prompt("arangosh> ");
char* input = console.prompt("arangosh> ");
if (input == 0) {
break;
@ -839,7 +839,7 @@ static void RunShell (v8::Handle<v8::Context> context) {
input = TRI_DuplicateString("help()");
}
console->addHistory(input);
console.addHistory(input);
v8::HandleScope scope;
v8::TryCatch tryCatch;
@ -856,9 +856,7 @@ static void RunShell (v8::Handle<v8::Context> context) {
BaseClient.stopPager();
}
console->close();
delete console;
console.close();
cout << endl;

View File

@ -159,7 +159,7 @@ bool SocketTask::fillReadBuffer (bool& closed) {
else if (nr == 0) {
closed = true;
LOGGER_TRACE << "read return 0 with " << errno << " (" << strerror(errno) << ")";
LOGGER_TRACE << "read returned 0";
return false;
}

View File

@ -53,7 +53,8 @@ using namespace std;
LineEditor::LineEditor (std::string const& history)
: _current(),
_historyFilename(history) {
_historyFilename(history),
_state(STATE_NONE) {
rl_initialize();
}
@ -62,6 +63,7 @@ LineEditor::LineEditor (std::string const& history)
////////////////////////////////////////////////////////////////////////////////
LineEditor::~LineEditor () {
close();
}
////////////////////////////////////////////////////////////////////////////////
@ -85,6 +87,8 @@ bool LineEditor::open (bool) {
using_history();
stifle_history(MAX_HISTORY_ENTRIES);
_state = STATE_OPENED;
return read_history(historyPath().c_str()) == 0;
}
@ -93,6 +97,13 @@ bool LineEditor::open (bool) {
////////////////////////////////////////////////////////////////////////////////
bool LineEditor::close () {
if (_state != STATE_OPENED) {
// avoid duplicate saving of history
return true;
}
_state = STATE_CLOSED;
return (write_history(historyPath().c_str()) == 0);
}

View File

@ -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
// -----------------------------------------------------------------------------
@ -188,6 +215,12 @@ class LineEditor {
////////////////////////////////////////////////////////////////////////////////
std::string _historyFilename;
////////////////////////////////////////////////////////////////////////////////
/// @brief current console state
////////////////////////////////////////////////////////////////////////////////
console_state_e _state;
};
////////////////////////////////////////////////////////////////////////////////