1
0
Fork 0

Visual Studio adjustments

This commit is contained in:
Jan Steemann 2015-04-30 11:46:55 +02:00
parent 84427cb330
commit 8dbcf0e23f
16 changed files with 52 additions and 56 deletions

View File

@ -45,7 +45,7 @@ using Json = triagens::basics::Json;
struct JsonHash {
size_t operator() (TRI_json_t const* value) const {
return TRI_FastHashJson(value);
return static_cast<size_t>(TRI_FastHashJson(value));
}
};

View File

@ -48,10 +48,10 @@ Range::Range (int64_t low,
size_t Range::size () const {
if (_low <= _high) {
// e.g. 1..1, 1..10 etc.
return _high - _low + 1;
return static_cast<size_t>(_high - _low + 1);
}
// e.g. 10..1
return _low - _high + 1;
return static_cast<size_t>(_low - _high + 1);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -708,9 +708,8 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
("code", Json(static_cast<double>(res)));
}
else if (operation == "getSome") {
auto atLeast = JsonHelper::getNumericValue<uint64_t>(queryJson.json(),
"atLeast", 1);
auto atMost = JsonHelper::getNumericValue<uint64_t>(queryJson.json(),
auto atLeast = JsonHelper::getNumericValue<size_t>(queryJson.json(), "atLeast", 1);
auto atMost = JsonHelper::getNumericValue<size_t>(queryJson.json(),
"atMost", ExecutionBlock::DefaultBatchSize);
std::unique_ptr<AqlItemBlock> items;
if (shardId.empty()) {
@ -744,9 +743,8 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
}
}
else if (operation == "skipSome") {
auto atLeast = JsonHelper::getNumericValue<uint64_t>(queryJson.json(),
"atLeast", 1);
auto atMost = JsonHelper::getNumericValue<uint64_t>(queryJson.json(),
auto atLeast = JsonHelper::getNumericValue<size_t>(queryJson.json(), "atLeast", 1);
auto atMost = JsonHelper::getNumericValue<size_t>(queryJson.json(),
"atMost", ExecutionBlock::DefaultBatchSize);
size_t skipped;
try {
@ -773,8 +771,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
answerBody.set("stats", query->getStats());
}
else if (operation == "skip") {
auto number = JsonHelper::getNumericValue<uint64_t>(queryJson.json(),
"number", 1);
auto number = JsonHelper::getNumericValue<size_t>(queryJson.json(), "number", 1);
try {
bool exhausted;
if (shardId.empty()) {

View File

@ -762,7 +762,7 @@ int TRI_RemoveElementHashArrayMulti (TRI_hash_array_multi_t* array,
////////////////////////////////////////////////////////////////////////////////
double TRI_SelectivityHashArrayMulti (TRI_hash_array_multi_t* array) {
size_t numTotal = array->_nrUsed + array->_nrOverflowUsed;
size_t numTotal = static_cast<size_t>(array->_nrUsed + array->_nrOverflowUsed);
if (numTotal == 0) {
return 1.0;

View File

@ -835,7 +835,7 @@ uint64_t SkiplistIndex_getNrUsed (SkiplistIndex* skiplistIndex) {
size_t SkiplistIndex_memoryUsage (SkiplistIndex const* skiplistIndex) {
return sizeof(SkiplistIndex) +
skiplistIndex->skiplist->memoryUsage() +
skiplistIndex->skiplist->getNrUsed() * SkiplistIndex_ElementSize(skiplistIndex);
static_cast<size_t>(skiplistIndex->skiplist->getNrUsed()) * SkiplistIndex_ElementSize(skiplistIndex);
}
// -----------------------------------------------------------------------------

View File

@ -124,9 +124,9 @@ void CollectionExport::run (uint64_t maxWaitTime) {
THROW_ARANGO_EXCEPTION(res);
}
size_t const n = _document->_primaryIndex._nrAlloc;
size_t const n = static_cast<size_t>(_document->_primaryIndex._nrAlloc);
_documents->reserve(_document->_primaryIndex._nrUsed);
_documents->reserve(static_cast<size_t>(_document->_primaryIndex._nrUsed));
for (size_t i = 0; i < n; ++i) {
auto ptr = _document->_primaryIndex._table[i];

View File

@ -970,9 +970,9 @@ std::vector<TRI_doc_mptr_copy_t> TRI_SelectByExample (
struct ShapedJsonHash {
size_t operator() (TRI_shaped_json_t const& shap) const {
size_t hash = 0x12345678;
uint64_t hash = 0x12345678;
hash = fasthash64(&shap._sid, sizeof(shap._sid), hash);
return fasthash64(shap._data.data, shap._data.length, hash);
return static_cast<size_t>(fasthash64(shap._data.data, shap._data.length, hash));
}
};

View File

@ -498,7 +498,7 @@ static int RemovePrimary (TRI_index_t* idx,
////////////////////////////////////////////////////////////////////////////////
static size_t MemoryPrimary (TRI_index_t const* idx) {
return idx->_collection->_primaryIndex._nrAlloc * sizeof(void*);
return static_cast<size_t>(idx->_collection->_primaryIndex._nrAlloc) * sizeof(void*);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -284,7 +284,7 @@ static uint64_t HashElementShape (TRI_associative_synced_t* array,
TRI_shape_t const* shape = static_cast<TRI_shape_t const*>(element);
TRI_ASSERT(shape != nullptr);
char const* s = reinterpret_cast<char const*>(shape);
return TRI_FnvHashPointer(s + sizeof(TRI_shape_sid_t), shape->_size - sizeof(TRI_shape_sid_t));
return TRI_FnvHashPointer(s + sizeof(TRI_shape_sid_t), static_cast<size_t>(shape->_size - sizeof(TRI_shape_sid_t)));
}
////////////////////////////////////////////////////////////////////////////////
@ -302,7 +302,7 @@ static bool EqualElementShape (TRI_associative_synced_t* array,
return (l->_size == r->_size)
&& memcmp(ll + sizeof(TRI_shape_sid_t),
rr + sizeof(TRI_shape_sid_t),
l->_size - sizeof(TRI_shape_sid_t)) == 0;
static_cast<size_t>(l->_size) - sizeof(TRI_shape_sid_t)) == 0;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -277,14 +277,14 @@ void AttributeMarker::dump () const {
ShapeMarker::ShapeMarker (TRI_voc_tick_t databaseId,
TRI_voc_cid_t collectionId,
TRI_shape_t const* shape)
: Marker(TRI_WAL_MARKER_SHAPE, sizeof(shape_marker_t) + shape->_size) {
: Marker(TRI_WAL_MARKER_SHAPE, sizeof(shape_marker_t) + static_cast<size_t>(shape->_size)) {
shape_marker_t* m = reinterpret_cast<shape_marker_t*>(begin());
m->_databaseId = databaseId;
m->_collectionId = collectionId;
memcpy(this->shape(), shape, shape->_size);
memcpy(this->shape(), shape, static_cast<size_t>(shape->_size));
#ifdef DEBUG_WAL
dump();

View File

@ -532,9 +532,9 @@ void ArangoClient::_printLine (const string &s) {
// save old cursor position
pos = bufferInfo.dwCursorPosition;
auto newX = pos.X + s.size();
auto oldY = pos.Y;
if (newX >= bufferInfo.dwSize.X) {
size_t newX = static_cast<size_t>(pos.X) + s.size();
size_t oldY = static_cast<size_t>(pos.Y);
if (newX >= static_cast<size_t>(bufferInfo.dwSize.X)) {
for (size_t i = 0; i <= newX / bufferInfo.dwSize.X; ++i) {
// insert as many newlines as we need. this prevents running out of buffer space when printing lines
// at the end of the console output buffer

View File

@ -326,12 +326,12 @@ HttpHandler::status_t RestAdminLogHandler::execute () {
offset = 0;
}
else if (offset > 0) {
length -= offset;
length -= static_cast<size_t>(offset);
}
// restrict to at most <size> elements
if (length > size) {
length = size;
length = static_cast<size_t>(size);
}
qsort(((char*) TRI_BeginVector(&clean)) + offset * sizeof(TRI_log_buffer_t),

View File

@ -367,7 +367,7 @@ namespace triagens {
_nrResizes++;
#endif
_table = new ELEMENT[_nrAlloc];
_table = new ELEMENT[static_cast<unsigned int>(_nrAlloc)];
for (uint64_t j = 0; j < _nrAlloc; j++) {
_desc.clearElement(_table[j]);
@ -567,7 +567,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
void initialise (uint64_t size) {
_table = new ELEMENT[size];
_table = new ELEMENT[static_cast<unsigned int>(size)];
for (uint64_t i = 0; i < size; i++) {
_desc.clearElement(_table[i]);

View File

@ -381,7 +381,7 @@ size_t TRI_MemoryUsageMultiPointer (TRI_multi_pointer_t const* array) {
////////////////////////////////////////////////////////////////////////////////
double TRI_SelectivityEstimateMultiPointer (TRI_multi_pointer_t const* array) {
size_t numTotal = array->_nrUnique + array->_nrDuplicate;
size_t numTotal = static_cast<size_t>(array->_nrUnique + array->_nrDuplicate);
if (numTotal == 0) {
return 1.0;

View File

@ -153,7 +153,7 @@ int JsonLegend::addShape (TRI_shape_sid_t sid,
_have_shape.insert(it, sid);
Shape sh(sid, _shape_data.length(), shape->_size);
_shapes.push_back(sh);
_shape_data.appendText(reinterpret_cast<char const*>(shape), shape->_size);
_shape_data.appendText(reinterpret_cast<char const*>(shape), static_cast<size_t>(shape->_size));
}
}
@ -257,12 +257,12 @@ static inline TRI_shape_size_t roundup8 (TRI_shape_size_t x) {
size_t JsonLegend::getSize () const {
// Add string pool size and shape pool size and add space for header
// and tables in bytes.
return sizeof(TRI_shape_size_t) // number of aids
+ sizeof(AttributeId) * _attribs.size() // aid entries
+ sizeof(TRI_shape_size_t) // number of sids
+ sizeof(Shape) * _shapes.size() // sid entries
+ roundup8(_att_data.length()) // string data, padded
+ roundup8(_shape_data.length()); // shape data, padded
return sizeof(TRI_shape_size_t) // number of aids
+ sizeof(AttributeId) * _attribs.size() // aid entries
+ sizeof(TRI_shape_size_t) // number of sids
+ sizeof(Shape) * _shapes.size() // sid entries
+ static_cast<size_t>(roundup8(_att_data.length())) // string data, padded
+ static_cast<size_t>(roundup8(_shape_data.length())); // shape data, padded
}
JsonLegend::AttributeComparerClass JsonLegend::AttributeComparerObject;
@ -289,10 +289,9 @@ void JsonLegend::dump (void* buf) {
// Attribute ID table:
TRI_shape_size_t* p = reinterpret_cast<TRI_shape_size_t*>(buf);
TRI_shape_size_t i;
*p++ = _attribs.size();
AttributeId* a = reinterpret_cast<AttributeId*>(p);
for (i = 0; i < _attribs.size(); i++) {
for (size_t i = 0; i < _attribs.size(); i++) {
_attribs[i].offset += socle;
*a++ = _attribs[i];
_attribs[i].offset -= socle;
@ -307,7 +306,7 @@ void JsonLegend::dump (void* buf) {
p = reinterpret_cast<TRI_shape_size_t*>(a);
*p++ = n;
Shape* s = reinterpret_cast<Shape*>(p);
for (i = 0; i < n; i++) {
for (size_t i = 0; i < n; i++) {
_shapes[i].offset += socle;
*s++ = _shapes[i];
_shapes[i].offset -= socle;
@ -316,9 +315,9 @@ void JsonLegend::dump (void* buf) {
// Attribute ID string data:
char* c = reinterpret_cast<char*>(s);
memcpy(c, _att_data.c_str(), attDataLength);
i = roundup8(attDataLength);
TRI_shape_size_t i = roundup8(attDataLength);
if (i > attDataLength) {
memset(c + attDataLength, 0, i - attDataLength);
memset(c + attDataLength, 0, static_cast<size_t>(i) - attDataLength);
}
c += i;
@ -327,7 +326,7 @@ void JsonLegend::dump (void* buf) {
memcpy(c, _shape_data.c_str(), shapeDataLength);
i = roundup8(shapeDataLength);
if (i > shapeDataLength) {
memset(c + shapeDataLength, 0, i - shapeDataLength);
memset(c + shapeDataLength, 0, static_cast<size_t>(i) - shapeDataLength);
}
}
// -----------------------------------------------------------------------------

View File

@ -339,7 +339,7 @@ static int FillShapeValueList (v8::Isolate* isolate,
return res;
}
total += p->_size;
total += static_cast<size_t>(p->_size);
}
// check if this list is homoegenous
@ -429,7 +429,7 @@ static int FillShapeValueList (v8::Isolate* isolate,
ptr += sizeof(TRI_shape_length_list_t);
for (p = values; p < e; ++p) {
memcpy(ptr, p->_value, p->_size);
memcpy(ptr, p->_value, static_cast<size_t>(p->_size));
ptr += p->_size;
}
}
@ -511,7 +511,7 @@ static int FillShapeValueList (v8::Isolate* isolate,
*offsets++ = offset;
offset += p->_size;
memcpy(ptr, p->_value, p->_size);
memcpy(ptr, p->_value, static_cast<size_t>(p->_size));
ptr += p->_size;
}
@ -559,7 +559,7 @@ static int FillShapeValueList (v8::Isolate* isolate,
*offsets++ = offset;
offset += p->_size;
memcpy(ptr, p->_value, p->_size);
memcpy(ptr, p->_value, static_cast<size_t>(p->_size));
ptr += p->_size;
}
@ -681,7 +681,7 @@ static int FillShapeValueArray (v8::Isolate* isolate,
return res;
}
total += p->_size;
total += static_cast<size_t>(p->_size);
// count fixed and variable sized values
if (p->_fixedSized) {
@ -789,7 +789,7 @@ static int FillShapeValueArray (v8::Isolate* isolate,
*aids++ = p->_aid;
*sids++ = p->_sid;
memcpy(ptr, p->_value, p->_size);
memcpy(ptr, p->_value, static_cast<size_t>(p->_size));
ptr += p->_size;
dst->_fixedSized &= p->_fixedSized;
@ -1071,7 +1071,7 @@ static v8::Handle<v8::Value> JsonShapeDataArray (v8::Isolate* isolate,
}
const TRI_shape_size_t offset = *offsetsF;
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, offsetsF[1] - offset);
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, static_cast<size_t>(offsetsF[1] - offset));
array->ForceSet(TRI_V8_STRING(name), element);
}
@ -1103,7 +1103,7 @@ static v8::Handle<v8::Value> JsonShapeDataArray (v8::Isolate* isolate,
}
const TRI_shape_size_t offset = *offsetsV;
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, offsetsV[1] - offset);
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, static_cast<size_t>(offsetsV[1] - offset));
array->ForceSet(TRI_V8_STRING(name), element);
}
@ -1180,7 +1180,7 @@ static v8::Handle<v8::Value> JsonShapeDataArray (v8::Isolate* isolate,
}
const TRI_shape_size_t offset = *offsetsF;
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, offsetsF[1] - offset);
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, static_cast<size_t>(offsetsF[1] - offset));
array->ForceSet(TRI_V8_STRING(name), element);
}
@ -1212,7 +1212,7 @@ static v8::Handle<v8::Value> JsonShapeDataArray (v8::Isolate* isolate,
}
const TRI_shape_size_t offset = *offsetsV;
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, offsetsV[1] - offset);
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, static_cast<size_t>(offsetsV[1] - offset));
array->ForceSet(TRI_V8_STRING(name), element);
}
@ -1271,7 +1271,7 @@ static v8::Handle<v8::Value> JsonShapeDataList (v8::Isolate* isolate,
}
const TRI_shape_size_t offset = *offsets;
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, offsets[1] - offset);
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, static_cast<size_t>(offsets[1] - offset));
list->Set((uint32_t) i, element);
}
@ -1316,7 +1316,7 @@ static v8::Handle<v8::Value> JsonShapeDataHomogeneousList (v8::Isolate* isolate,
for (i = 0; i < l; ++i, ++offsets) {
TRI_shape_size_t offset = *offsets;
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, offsets[1] - offset);
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, static_cast<size_t>(offsets[1] - offset));
list->Set((uint32_t) i, element);
}
@ -1366,7 +1366,7 @@ static v8::Handle<v8::Value> JsonShapeDataHomogeneousSizedList (v8::Isolate* iso
v8::Handle<v8::Array> list = v8::Array::New(isolate, l);
for (i = 0; i < l; ++i, offset += length) {
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, length);
v8::Handle<v8::Value> element = JsonShapeData(isolate, shaper, subshape, data + offset, static_cast<size_t>(length));
list->Set((uint32_t) i, element);
}