1
0
Fork 0

changes for Visual Studio

This commit is contained in:
Mark 2016-08-19 17:22:57 +02:00
parent e1e7e2da0b
commit 3bd5c27c0c
12 changed files with 47 additions and 26 deletions

View File

@ -456,7 +456,7 @@ bool config_t::merge(VPackSlice const& conf) {
ss << "Min RAFT interval: "; ss << "Min RAFT interval: ";
if (_minPing == 0) { // Command line beats persistence if (_minPing == 0) { // Command line beats persistence
if (conf.hasKey(minPingStr)) { if (conf.hasKey(minPingStr)) {
_minPing = conf.get(minPingStr).getUInt(); _minPing = conf.get(minPingStr).getNumericValue<double>();
ss << _minPing << " (persisted)"; ss << _minPing << " (persisted)";
} else { } else {
_minPing = 0.5; _minPing = 0.5;
@ -471,7 +471,7 @@ bool config_t::merge(VPackSlice const& conf) {
ss << "Max RAFT interval: "; ss << "Max RAFT interval: ";
if (_maxPing == 0) { // Command line beats persistence if (_maxPing == 0) { // Command line beats persistence
if (conf.hasKey(maxPingStr)) { if (conf.hasKey(maxPingStr)) {
_maxPing = conf.get(maxPingStr).getUInt(); _maxPing = conf.get(maxPingStr).getNumericValue<double>();
ss << _maxPing << " (persisted)"; ss << _maxPing << " (persisted)";
} else { } else {
_maxPing = 2.5; _maxPing = 2.5;
@ -519,7 +519,7 @@ bool config_t::merge(VPackSlice const& conf) {
_compactionStepSize = conf.get(compactionStepSizeStr).getUInt(); _compactionStepSize = conf.get(compactionStepSizeStr).getUInt();
ss << _compactionStepSize << " (persisted)"; ss << _compactionStepSize << " (persisted)";
} else { } else {
_compactionStepSize = 2.5; _compactionStepSize = 1000;
ss << _compactionStepSize << " (default)"; ss << _compactionStepSize << " (default)";
} }
} else { } else {

View File

@ -705,7 +705,7 @@ static void JS_GetCollectionInfoClusterInfo(
result->Set(TRI_V8_ASCII_STRING("waitForSync"), result->Set(TRI_V8_ASCII_STRING("waitForSync"),
v8::Boolean::New(isolate, ci->waitForSync())); v8::Boolean::New(isolate, ci->waitForSync()));
result->Set(TRI_V8_ASCII_STRING("journalSize"), result->Set(TRI_V8_ASCII_STRING("journalSize"),
v8::Number::New(isolate, ci->journalSize())); v8::Number::New(isolate, static_cast<double>(ci->journalSize())));
result->Set(TRI_V8_ASCII_STRING("replicationFactor"), result->Set(TRI_V8_ASCII_STRING("replicationFactor"),
v8::Number::New(isolate, ci->replicationFactor())); v8::Number::New(isolate, ci->replicationFactor()));

View File

@ -92,7 +92,8 @@ std::unique_ptr<basics::StringBuffer> createChunkForNetworkDetail(
// get the lenght of VPack data // get the lenght of VPack data
uint32_t dataLength = 0; uint32_t dataLength = 0;
for (auto& slice : slices) { for (auto& slice : slices) {
dataLength += slice.byteSize(); // TODO: is a 32bit value sufficient for all Slices here?
dataLength += static_cast<uint32_t>(slice.byteSize());
} }
// calculate length of current chunk // calculate length of current chunk
@ -320,7 +321,8 @@ bool VppCommTask::processRead() {
"messages"); "messages");
} }
IncompleteVPackMessage message(chunkHeader._messageLength, // TODO: is a 32bit value sufficient for the messageLength here?
IncompleteVPackMessage message(static_cast<uint32_t>(chunkHeader._messageLength),
chunkHeader._chunk /*number of chunks*/); chunkHeader._chunk /*number of chunks*/);
message._buffer.append(vpackBegin, std::distance(vpackBegin, chunkEnd)); message._buffer.append(vpackBegin, std::distance(vpackBegin, chunkEnd));
auto insertPair = _incompleteMessages.emplace( auto insertPair = _incompleteMessages.emplace(
@ -406,7 +408,7 @@ bool VppCommTask::processRead() {
std::unique_ptr<VppRequest> request(new VppRequest( std::unique_ptr<VppRequest> request(new VppRequest(
_connectionInfo, std::move(message), chunkHeader._messageID)); _connectionInfo, std::move(message), chunkHeader._messageID));
GeneralServerFeature::HANDLER_FACTORY->setRequestContext(request.get()); GeneralServerFeature::HANDLER_FACTORY->setRequestContext(request.get());
// make sure we have a dabase // make sure we have a database
if (request->requestContext() == nullptr) { if (request->requestContext() == nullptr) {
handleSimpleError(GeneralResponse::ResponseCode::NOT_FOUND, handleSimpleError(GeneralResponse::ResponseCode::NOT_FOUND,
TRI_ERROR_ARANGO_DATABASE_NOT_FOUND, TRI_ERROR_ARANGO_DATABASE_NOT_FOUND,

View File

@ -76,7 +76,7 @@ RevisionReader GlobalRevisionCacheChunk::storeAndLease(uint64_t collectionId, ui
// the collection id is prepended to the actual data in order to quickly access // the collection id is prepended to the actual data in order to quickly access
// the shard-local hash for the revision when cleaning up the chunk // the shard-local hash for the revision when cleaning up the chunk
uint32_t GlobalRevisionCacheChunk::store(uint64_t collectionId, uint8_t const* data, size_t length) { uint32_t GlobalRevisionCacheChunk::store(uint64_t collectionId, uint8_t const* data, size_t length) {
uint32_t const offset = adjustWritePosition(physicalSize(length)); uint32_t const offset = adjustWritePosition(static_cast<uint32_t>(physicalSize(length)));
// we can copy the data into the chunk without the lock // we can copy the data into the chunk without the lock
storeAtOffset(offset, collectionId, data, length); storeAtOffset(offset, collectionId, data, length);
@ -86,7 +86,7 @@ uint32_t GlobalRevisionCacheChunk::store(uint64_t collectionId, uint8_t const* d
// return the physical size for a piece of data // return the physical size for a piece of data
// this adds required padding plus the required size for the collection id // this adds required padding plus the required size for the collection id
size_t GlobalRevisionCacheChunk::physicalSize(size_t dataLength) noexcept { size_t GlobalRevisionCacheChunk::physicalSize(size_t dataLength) noexcept {
return AlignSize(sizeof(uint64_t) + dataLength); return AlignSize(static_cast<uint32_t>(sizeof(uint64_t) + dataLength));
} }
// garbage collects a chunk // garbage collects a chunk
@ -109,7 +109,7 @@ void GlobalRevisionCacheChunk::garbageCollect(GarbageCollectionCallback const& c
arangodb::velocypack::Slice slice(ptr + sizeof(uint64_t)); arangodb::velocypack::Slice slice(ptr + sizeof(uint64_t));
callback(collectionId, slice); callback(collectionId, slice);
ptr += AlignSize(sizeof(uint64_t) + slice.byteSize()); ptr += AlignSize(static_cast<uint32_t>(sizeof(uint64_t) + slice.byteSize()));
} }
// done collecting. now reset the cache and reset the write position // done collecting. now reset the cache and reset the write position

View File

@ -479,8 +479,8 @@ int Syncer::createCollection(VPackSlice const& slice, arangodb::LogicalCollectio
return TRI_ERROR_REPLICATION_INVALID_RESPONSE; return TRI_ERROR_REPLICATION_INVALID_RESPONSE;
} }
TRI_col_type_e const type = VelocyPackHelper::getNumericValue<TRI_col_type_e>( TRI_col_type_e const type = static_cast<TRI_col_type_e>(VelocyPackHelper::getNumericValue<int>(
slice, "type", TRI_COL_TYPE_DOCUMENT); slice, "type", TRI_COL_TYPE_DOCUMENT));
arangodb::LogicalCollection* col = getCollectionByIdOrName(cid, name); arangodb::LogicalCollection* col = getCollectionByIdOrName(cid, name);
@ -552,7 +552,7 @@ int Syncer::createIndex(VPackSlice const& slice) {
} }
try { try {
CollectionGuard guard(_vocbase, cid, cname); CollectionGuard guard(_vocbase, cid, std::string(cname));
if (guard.collection() == nullptr) { if (guard.collection() == nullptr) {
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
@ -610,7 +610,7 @@ int Syncer::dropIndex(arangodb::velocypack::Slice const& slice) {
} }
try { try {
CollectionGuard guard(_vocbase, cid, cname); CollectionGuard guard(_vocbase, cid, std::string(cname));
if (guard.collection() == nullptr) { if (guard.collection() == nullptr) {
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;

View File

@ -1286,7 +1286,7 @@ static void JS_PropertiesVocbaseCol(
result->Set(DoCompactKey, v8::Boolean::New(isolate, info->doCompact())); result->Set(DoCompactKey, v8::Boolean::New(isolate, info->doCompact()));
result->Set(IsSystemKey, v8::Boolean::New(isolate, info->isSystem())); result->Set(IsSystemKey, v8::Boolean::New(isolate, info->isSystem()));
result->Set(IsVolatileKey, v8::Boolean::New(isolate, info->isVolatile())); result->Set(IsVolatileKey, v8::Boolean::New(isolate, info->isVolatile()));
result->Set(JournalSizeKey, v8::Number::New(isolate, info->journalSize())); result->Set(JournalSizeKey, v8::Number::New(isolate, static_cast<double>(info->journalSize())));
result->Set(WaitForSyncKey, v8::Boolean::New(isolate, info->waitForSync())); result->Set(WaitForSyncKey, v8::Boolean::New(isolate, info->waitForSync()));
result->Set(TRI_V8_ASCII_STRING("indexBuckets"), result->Set(TRI_V8_ASCII_STRING("indexBuckets"),
v8::Number::New(isolate, info->indexBuckets())); v8::Number::New(isolate, info->indexBuckets()));

View File

@ -48,6 +48,15 @@ static T ReadNumericValue(VPackSlice info, std::string const& name, T def) {
return Helper::getNumericValue<T>(info, name.c_str(), def); return Helper::getNumericValue<T>(info, name.c_str(), def);
} }
template <typename T, typename BaseType>
static T ReadNumericValue(VPackSlice info, std::string const& name, T def) {
if (!info.isObject()) {
return def;
}
// nice extra conversion required for Visual Studio pickyness
return static_cast<T>(Helper::getNumericValue<BaseType>(info, name.c_str(), static_cast<BaseType>(def)));
}
static bool ReadBooleanValue(VPackSlice info, std::string const& name, static bool ReadBooleanValue(VPackSlice info, std::string const& name,
bool def) { bool def) {
if (!info.isObject()) { if (!info.isObject()) {
@ -180,9 +189,9 @@ LogicalCollection::LogicalCollection(TRI_vocbase_t* vocbase, VPackSlice info)
_cid(ReadCid(info)), _cid(ReadCid(info)),
_planId(_cid), _planId(_cid),
_type( _type(
ReadNumericValue<TRI_col_type_e>(info, "type", TRI_COL_TYPE_UNKNOWN)), ReadNumericValue<TRI_col_type_e, int>(info, "type", TRI_COL_TYPE_UNKNOWN)),
_name(ReadStringValue(info, "name", "")), _name(ReadStringValue(info, "name", "")),
_status(ReadNumericValue<TRI_vocbase_col_status_e>( _status(ReadNumericValue<TRI_vocbase_col_status_e, int>(
info, "status", TRI_VOC_COL_STATUS_CORRUPTED)), info, "status", TRI_VOC_COL_STATUS_CORRUPTED)),
_isLocal(false), _isLocal(false),
_isDeleted(ReadBooleanValue(info, "deleted", false)), _isDeleted(ReadBooleanValue(info, "deleted", false)),

View File

@ -1287,7 +1287,7 @@ VocbaseCollectionInfo::VocbaseCollectionInfo(TRI_vocbase_t* vocbase,
_waitForSync(false) { _waitForSync(false) {
auto database = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database"); auto database = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database");
_maximalSize = database->maximalJournalSize(); _maximalSize = static_cast<TRI_voc_size_t>(database->maximalJournalSize());
_waitForSync = database->waitForSync(); _waitForSync = database->waitForSync();
size_t pageSize = PageSizeFeature::getPageSize(); size_t pageSize = PageSizeFeature::getPageSize();
@ -1333,7 +1333,7 @@ VocbaseCollectionInfo::VocbaseCollectionInfo(TRI_vocbase_t* vocbase,
_waitForSync(false) { _waitForSync(false) {
auto database = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database"); auto database = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database");
_maximalSize = database->maximalJournalSize(); _maximalSize = static_cast<TRI_voc_size_t>(database->maximalJournalSize());
_waitForSync = database->waitForSync(); _waitForSync = database->waitForSync();
memset(_name, 0, sizeof(_name)); memset(_name, 0, sizeof(_name));
@ -1566,11 +1566,11 @@ void VocbaseCollectionInfo::update(VPackSlice const& slice, bool preferDefaults,
_waitForSync = arangodb::basics::VelocyPackHelper::getBooleanValue( _waitForSync = arangodb::basics::VelocyPackHelper::getBooleanValue(
slice, "waitForSync", database->waitForSync()); slice, "waitForSync", database->waitForSync());
if (slice.hasKey("journalSize")) { if (slice.hasKey("journalSize")) {
_maximalSize = arangodb::basics::VelocyPackHelper::getNumericValue<int>( _maximalSize = arangodb::basics::VelocyPackHelper::getNumericValue<TRI_voc_size_t>(
slice, "journalSize", database->maximalJournalSize()); slice, "journalSize", static_cast<TRI_voc_size_t>(database->maximalJournalSize()));
} else { } else {
_maximalSize = arangodb::basics::VelocyPackHelper::getNumericValue<int>( _maximalSize = arangodb::basics::VelocyPackHelper::getNumericValue<TRI_voc_size_t>(
slice, "maximalSize", database->maximalJournalSize()); slice, "maximalSize", static_cast<TRI_voc_size_t>(database->maximalJournalSize()));
} }
} else { } else {
_doCompact = arangodb::basics::VelocyPackHelper::getBooleanValue( _doCompact = arangodb::basics::VelocyPackHelper::getBooleanValue(

View File

@ -109,7 +109,7 @@ constexpr char TRI_INDEX_HANDLE_SEPARATOR_CHR = '/';
constexpr auto TRI_INDEX_HANDLE_SEPARATOR_STR = "/"; constexpr auto TRI_INDEX_HANDLE_SEPARATOR_STR = "/";
/// @brief collection enum /// @brief collection enum
enum TRI_col_type_e : uint32_t{ enum TRI_col_type_e : uint32_t {
TRI_COL_TYPE_UNKNOWN = 0, // only used to signal an invalid collection type TRI_COL_TYPE_UNKNOWN = 0, // only used to signal an invalid collection type
TRI_COL_TYPE_DOCUMENT = 2, TRI_COL_TYPE_DOCUMENT = 2,
TRI_COL_TYPE_EDGE = 3 TRI_COL_TYPE_EDGE = 3
@ -124,7 +124,7 @@ enum TRI_vocbase_type_e {
/// @brief status of a collection /// @brief status of a collection
/// note: the NEW_BORN status is not used in ArangoDB 1.3 anymore, but is left /// note: the NEW_BORN status is not used in ArangoDB 1.3 anymore, but is left
/// in this enum for compatibility with earlier versions /// in this enum for compatibility with earlier versions
enum TRI_vocbase_col_status_e { enum TRI_vocbase_col_status_e : int {
TRI_VOC_COL_STATUS_CORRUPTED = 0, TRI_VOC_COL_STATUS_CORRUPTED = 0,
TRI_VOC_COL_STATUS_NEW_BORN = 1, // DEPRECATED, and shouldn't be used anymore TRI_VOC_COL_STATUS_NEW_BORN = 1, // DEPRECATED, and shouldn't be used anymore
TRI_VOC_COL_STATUS_UNLOADED = 2, TRI_VOC_COL_STATUS_UNLOADED = 2,

View File

@ -70,7 +70,11 @@ namespace basics {
// TODO: Make this a template again once everybody has gcc >= 4.9.2 // TODO: Make this a template again once everybody has gcc >= 4.9.2
// template<int Nr> // template<int Nr>
class DataProtector { class DataProtector {
struct alignas(64) Entry { // 64 is the size of a cache line, #ifdef _WIN32
struct Entry { // 64 is the size of a cache line,
#else
struct alignas(64) Entry { // 64 is the size of a cache line,
#endif
// it is important that different list entries lie in different // it is important that different list entries lie in different
// cache lines. // cache lines.
std::atomic<int> _count; std::atomic<int> _count;

View File

@ -191,6 +191,8 @@ GeneralRequest::~GeneralRequest() {
void GeneralRequest::setRequestContext(RequestContext* requestContext, void GeneralRequest::setRequestContext(RequestContext* requestContext,
bool isRequestContextOwner) { bool isRequestContextOwner) {
TRI_ASSERT(requestContext != nullptr);
if (_requestContext) { if (_requestContext) {
// if we have a shared context, we should not have got here // if we have a shared context, we should not have got here
TRI_ASSERT(isRequestContextOwner); TRI_ASSERT(isRequestContextOwner);

View File

@ -205,7 +205,11 @@ class ConnectionManager {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// We keep connections to servers open: // We keep connections to servers open:
#ifdef _WIN32
struct ConnectionsBucket {
#else
struct alignas(64) ConnectionsBucket { struct alignas(64) ConnectionsBucket {
#endif
std::unordered_map<std::string, ServerConnections*> _connections; std::unordered_map<std::string, ServerConnections*> _connections;
arangodb::basics::ReadWriteLock _lock; arangodb::basics::ReadWriteLock _lock;