1
0
Fork 0

Merge branch 'devel' of github.com:arangodb/ArangoDB into devel

This commit is contained in:
Wilfried Goesgens 2016-11-08 10:27:43 +01:00
commit c086eaf3d8
2 changed files with 50 additions and 1 deletions

View File

@ -41,6 +41,7 @@
#include "Aql/QueryCache.h" #include "Aql/QueryCache.h"
#include "Aql/QueryList.h" #include "Aql/QueryList.h"
#include "Aql/QueryRegistry.h" #include "Aql/QueryRegistry.h"
#include "Basics/HybridLogicalClock.h"
#include "Basics/MutexLocker.h" #include "Basics/MutexLocker.h"
#include "Basics/ScopeGuard.h" #include "Basics/ScopeGuard.h"
#include "Basics/StaticStrings.h" #include "Basics/StaticStrings.h"
@ -2690,6 +2691,10 @@ void TRI_V8ReloadRouting(v8::Isolate* isolate) {
} }
////////////////////////////////////////////////////////////////////////////////
/// @brief check if we are in the enterprise edition
////////////////////////////////////////////////////////////////////////////////
static void JS_IsEnterprise(v8::FunctionCallbackInfo<v8::Value> const& args) { static void JS_IsEnterprise(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate); TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
@ -2701,6 +2706,45 @@ static void JS_IsEnterprise(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_TRY_CATCH_END TRI_V8_TRY_CATCH_END
} }
////////////////////////////////////////////////////////////////////////////////
/// @brief decode a _rev time stamp
////////////////////////////////////////////////////////////////////////////////
static void JS_DecodeRev(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1 || !args[0]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("DECODE_REV(<string>)");
}
std::string rev = TRI_ObjectToString(args[0]);
uint64_t revInt = HybridLogicalClock::decodeTimeStamp(rev);
uint64_t timeMilli = HybridLogicalClock::extractTime(revInt);
uint64_t count = HybridLogicalClock::extractCount(revInt);
time_t timeSeconds = timeMilli / 1000;
uint64_t millis = timeMilli % 1000;
struct tm date;
gmtime_r(&timeSeconds, &date);
char buffer[32];
strftime(buffer, 32, "%Y-%m-%dT%H:%M:%S.000Z", &date);
buffer[20] = (millis / 100) + '0';
buffer[21] = ((millis / 10) % 10) + '0';
buffer[22] = (millis % 10) + '0';
buffer[23] = 0;
v8::Handle<v8::Object> result = v8::Object::New(isolate);
result->Set(TRI_V8_ASCII_STRING("date"),
TRI_V8_ASCII_STRING(buffer));
result->Set(TRI_V8_ASCII_STRING("count"),
v8::Number::New(isolate, count));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief creates a TRI_vocbase_t global context /// @brief creates a TRI_vocbase_t global context
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -2892,6 +2936,11 @@ void TRI_InitV8VocBridge(v8::Isolate* isolate, v8::Handle<v8::Context> context,
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_AddGlobalFunctionVocbase(isolate, context,
TRI_V8_ASCII_STRING("SYS_IS_ENTERPRISE"), TRI_V8_ASCII_STRING("SYS_IS_ENTERPRISE"),
JS_IsEnterprise); JS_IsEnterprise);
TRI_AddGlobalFunctionVocbase(isolate, context,
TRI_V8_ASCII_STRING("DECODE_REV"),
JS_DecodeRev);
// ............................................................................. // .............................................................................
// create global variables // create global variables
// ............................................................................. // .............................................................................

View File

@ -154,7 +154,6 @@ class HybridLogicalClock {
return ms; return ms;
} }
private:
// helper to compute the offset between epoch and 1970 // helper to compute the offset between epoch and 1970
uint64_t computeOffset1970(); uint64_t computeOffset1970();
@ -166,6 +165,7 @@ class HybridLogicalClock {
return (time << 20) + count; return (time << 20) + count;
} }
private:
static char encodeTable[65]; static char encodeTable[65];
static signed char decodeTable[256]; static signed char decodeTable[256];