fix a bunch of 64-bit integer signedness bugs

git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@940 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
sears 2010-07-16 21:43:21 +00:00
parent eb8b57378a
commit 7bed4b67ba
14 changed files with 41 additions and 41 deletions

View file

@ -133,7 +133,7 @@ void DataPage<TUPLE>::initialize_page(pageid_t pageid) {
releasePage(p); releasePage(p);
} }
template <class TUPLE> template <class TUPLE>
size_t DataPage<TUPLE>::write_bytes(const byte * buf, size_t remaining) { size_t DataPage<TUPLE>::write_bytes(const byte * buf, ssize_t remaining) {
recordid chunk = calc_chunk_from_offset(write_offset_); recordid chunk = calc_chunk_from_offset(write_offset_);
if(chunk.size > remaining) { if(chunk.size > remaining) {
chunk.size = remaining; chunk.size = remaining;
@ -152,7 +152,7 @@ size_t DataPage<TUPLE>::write_bytes(const byte * buf, size_t remaining) {
return chunk.size; return chunk.size;
} }
template <class TUPLE> template <class TUPLE>
size_t DataPage<TUPLE>::read_bytes(byte * buf, off_t offset, size_t remaining) { size_t DataPage<TUPLE>::read_bytes(byte * buf, off_t offset, ssize_t remaining) {
recordid chunk = calc_chunk_from_offset(offset); recordid chunk = calc_chunk_from_offset(offset);
if(chunk.size > remaining) { if(chunk.size > remaining) {
chunk.size = remaining; chunk.size = remaining;

View file

@ -128,8 +128,8 @@ private:
assert(ret.size); assert(ret.size);
return ret; return ret;
} }
size_t write_bytes(const byte * buf, size_t remaining); size_t write_bytes(const byte * buf, ssize_t remaining);
size_t read_bytes(byte * buf, off_t offset, size_t remaining); size_t read_bytes(byte * buf, off_t offset, ssize_t remaining);
bool write_data(const byte * buf, size_t len, bool init_next = true); bool write_data(const byte * buf, size_t len, bool init_next = true);
bool read_data(byte * buf, off_t offset, size_t len); bool read_data(byte * buf, off_t offset, size_t len);
bool initialize_next_page(); bool initialize_next_page();

View file

@ -28,7 +28,7 @@
const int64_t diskTreeComponent::internalNodes::DEPTH = 0; //in root this is the slot num where the DEPTH (of tree) is stored const int64_t diskTreeComponent::internalNodes::DEPTH = 0; //in root this is the slot num where the DEPTH (of tree) is stored
const int64_t diskTreeComponent::internalNodes::COMPARATOR = 1; //in root this is the slot num where the COMPARATOR id is stored const int64_t diskTreeComponent::internalNodes::COMPARATOR = 1; //in root this is the slot num where the COMPARATOR id is stored
const int64_t diskTreeComponent::internalNodes::FIRST_SLOT = 2; //this is the first unused slot in all index pages const int64_t diskTreeComponent::internalNodes::FIRST_SLOT = 2; //this is the first unused slot in all index pages
const size_t diskTreeComponent::internalNodes::root_rec_size = sizeof(int64_t); const ssize_t diskTreeComponent::internalNodes::root_rec_size = sizeof(int64_t);
const int64_t diskTreeComponent::internalNodes::PREV_LEAF = 0; //pointer to prev leaf page const int64_t diskTreeComponent::internalNodes::PREV_LEAF = 0; //pointer to prev leaf page
const int64_t diskTreeComponent::internalNodes::NEXT_LEAF = 1; //pointer to next leaf page const int64_t diskTreeComponent::internalNodes::NEXT_LEAF = 1; //pointer to next leaf page

View file

@ -128,7 +128,7 @@ class diskTreeComponent {
const static int64_t DEPTH; const static int64_t DEPTH;
const static int64_t COMPARATOR; const static int64_t COMPARATOR;
const static int64_t FIRST_SLOT; const static int64_t FIRST_SLOT;
const static size_t root_rec_size; const static ssize_t root_rec_size;
const static int64_t PREV_LEAF; const static int64_t PREV_LEAF;
const static int64_t NEXT_LEAF; const static int64_t NEXT_LEAF;
pageid_t lastLeaf; pageid_t lastLeaf;

View file

@ -145,8 +145,8 @@ void logserver::stopserver()
tot_threadwork_time += idle_th->data->work_time; tot_threadwork_time += idle_th->data->work_time;
num_reqs += idle_th->data->num_reqs; num_reqs += idle_th->data->num_reqs;
printf("thread %d: work_time %.3f\t#calls %d\tavg req process time:\t%.3f\n", printf("thread %llu: work_time %.3f\t#calls %d\tavg req process time:\t%.3f\n",
i, (unsigned long long)i,
idle_th->data->work_time, idle_th->data->work_time,
idle_th->data->num_reqs, idle_th->data->num_reqs,
(( idle_th->data->num_reqs == 0 ) ? 0 : idle_th->data->work_time / idle_th->data->num_reqs) (( idle_th->data->num_reqs == 0 ) ? 0 : idle_th->data->work_time / idle_th->data->num_reqs)
@ -899,8 +899,8 @@ void * thread_work_fn( void * args)
if(err) { if(err) {
if(opcode != OP_DONE) { if(opcode != OP_DONE) {
char *msg; char *msg;
if(-1 != asprintf(&msg, "network error. conn closed. (%d, %d) ", if(-1 != asprintf(&msg, "network error. conn closed. (%d, %llu) ",
*(item->data->workitem), item->data->work_queue->size())) { *(item->data->workitem), (unsigned long long)item->data->work_queue->size())) {
perror(msg); perror(msg);
free(msg); free(msg);
} else { } else {

View file

@ -231,7 +231,7 @@ void mergeManager::tick(mergeStats * s, bool block, bool force) {
total_sleep += sleeptime; total_sleep += sleeptime;
if((spin > 40) || (total_sleep > (max_sleep * 20.0))) { if((spin > 40) || (total_sleep > (max_sleep * 20.0))) {
printf("\nMerge thread %d Overshoot: raw=%lld, d=%lld eff=%lld Throttle min(1, %6f) spin %d, total_sleep %6.3f\n", s->merge_level, raw_overshoot, overshoot_fudge, overshoot, sleeptime, spin, total_sleep); printf("\nMerge thread %d Overshoot: raw=%lld, d=%lld eff=%lld Throttle min(1, %6f) spin %d, total_sleep %6.3f\n", s->merge_level, (long long)raw_overshoot, (long long)overshoot_fudge, (long long)overshoot, sleeptime, spin, total_sleep);
} }
struct timeval now; struct timeval now;
@ -364,7 +364,7 @@ void mergeManager::pretty_print(FILE * out) {
assert((!c2->active) || (c1_c2_progress >= -1 && c1_c2_progress < 102)); assert((!c2->active) || (c1_c2_progress >= -1 && c1_c2_progress < 102));
fprintf(out,"[merge progress MB/s window (lifetime)]: app [%s %6lldMB ~ %3.0f%% %6.1fsec %4.1f (%4.1f)] %s %s [%s %3.0f%% ~ %3.0f%% %4.1f (%4.1f)] %s %s [%s %3.0f%% %4.1f (%4.1f)] %s ", fprintf(out,"[merge progress MB/s window (lifetime)]: app [%s %6lldMB ~ %3.0f%% %6.1fsec %4.1f (%4.1f)] %s %s [%s %3.0f%% ~ %3.0f%% %4.1f (%4.1f)] %s %s [%s %3.0f%% %4.1f (%4.1f)] %s ",
c0->active ? "RUN" : "---", (uint64_t)(c0->lifetime_consumed / mb), c0_out_progress, c0->lifetime_elapsed, c0->bps/((double)mb), c0->lifetime_consumed/(((double)mb)*c0->lifetime_elapsed), c0->active ? "RUN" : "---", (long long)(c0->lifetime_consumed / mb), c0_out_progress, c0->lifetime_elapsed, c0->bps/((double)mb), c0->lifetime_consumed/(((double)mb)*c0->lifetime_elapsed),
have_c0 ? "C0" : "..", have_c0 ? "C0" : "..",
have_c0m ? "C0'" : "...", have_c0m ? "C0'" : "...",
c1->active ? "RUN" : "---", c0_c1_in_progress, c0_c1_out_progress, c1->bps/((double)mb), c1->lifetime_consumed/(((double)mb)*c1->lifetime_elapsed), c1->active ? "RUN" : "---", c0_c1_in_progress, c0_c1_out_progress, c1->bps/((double)mb), c1->lifetime_consumed/(((double)mb)*c1->lifetime_elapsed),

View file

@ -52,7 +52,7 @@ void insertWithConcurrentReads(size_t NUM_ENTRIES) {
RegionAllocator * alloc = new RegionAllocator(xid, 10000); // ~ 10 datapages per region. RegionAllocator * alloc = new RegionAllocator(xid, 10000); // ~ 10 datapages per region.
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES); printf("Stage 1: Writing %llu keys\n", (unsigned long long)NUM_ENTRIES);
int pcount = 1000; int pcount = 1000;
int dpages = 0; int dpages = 0;
@ -154,7 +154,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
RegionAllocator * alloc = new RegionAllocator(xid, 10000); // ~ 10 datapages per region. RegionAllocator * alloc = new RegionAllocator(xid, 10000); // ~ 10 datapages per region.
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES); printf("Stage 1: Writing %llu keys\n", (unsigned long long)NUM_ENTRIES);
int pcount = 1000; int pcount = 1000;
int dpages = 0; int dpages = 0;
@ -196,7 +196,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
xid = Tbegin(); xid = Tbegin();
printf("Stage 2: Reading %d tuples\n", NUM_ENTRIES); printf("Stage 2: Reading %llu tuples\n", (unsigned long long)NUM_ENTRIES);
int tuplenum = 0; int tuplenum = 0;

View file

@ -55,7 +55,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
if(data_arr.size() > NUM_ENTRIES) if(data_arr.size() > NUM_ENTRIES)
data_arr.erase(data_arr.begin()+NUM_ENTRIES, data_arr.end()); data_arr.erase(data_arr.begin()+NUM_ENTRIES, data_arr.end());
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES); printf("Stage 1: Writing %llu keys\n", (unsigned long long)NUM_ENTRIES);
for(size_t i = 0; i < NUM_ENTRIES; i++) for(size_t i = 0; i < NUM_ENTRIES; i++)
{ {
@ -75,7 +75,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
Tcommit(xid); Tcommit(xid);
xid = Tbegin(); xid = Tbegin();
printf("Stage 2: Sequentially reading %d tuples\n", NUM_ENTRIES); printf("Stage 2: Sequentially reading %llu tuples\n", (unsigned long long)NUM_ENTRIES);
size_t tuplenum = 0; size_t tuplenum = 0;
diskTreeComponent::iterator * tree_itr = ltable_c1->open_iterator(); diskTreeComponent::iterator * tree_itr = ltable_c1->open_iterator();

View file

@ -58,7 +58,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
mscheduler.startlogtable(lindex, 10 * 1024 * 1024); mscheduler.startlogtable(lindex, 10 * 1024 * 1024);
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES); printf("Stage 1: Writing %llu keys\n", (unsigned long long)NUM_ENTRIES);
struct timeval start_tv, stop_tv, ti_st, ti_end; struct timeval start_tv, stop_tv, ti_st, ti_end;
double insert_time = 0; double insert_time = 0;
@ -100,7 +100,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
xid = Tbegin(); xid = Tbegin();
printf("Stage 2: Looking up %d keys:\n", NUM_ENTRIES); printf("Stage 2: Looking up %llu keys:\n", (unsigned long long)NUM_ENTRIES);
int found_tuples=0; int found_tuples=0;
for(int i=NUM_ENTRIES-1; i>=0; i--) for(int i=NUM_ENTRIES-1; i>=0; i--)

View file

@ -57,7 +57,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
mscheduler.startlogtable(lindex, 10 * 1024 * 1024); mscheduler.startlogtable(lindex, 10 * 1024 * 1024);
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES); printf("Stage 1: Writing %llu keys\n", (unsigned long long)NUM_ENTRIES);
struct timeval start_tv, stop_tv, ti_st, ti_end; struct timeval start_tv, stop_tv, ti_st, ti_end;
double insert_time = 0; double insert_time = 0;
@ -88,7 +88,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
printf("\nTREE STRUCTURE\n"); printf("\nTREE STRUCTURE\n");
//ltable.get_tree_c1()->print_tree(xid); //ltable.get_tree_c1()->print_tree(xid);
printf("datasize: %lld\n", datasize); printf("datasize: %llu\n", (unsigned long long)datasize);
mscheduler.shutdown(); mscheduler.shutdown();
printf("merge threads finished.\n"); printf("merge threads finished.\n");

View file

@ -47,7 +47,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
std::sort(key_arr->begin(), key_arr->end(), &mycmp); std::sort(key_arr->begin(), key_arr->end(), &mycmp);
key_v_list->push_back(key_arr); key_v_list->push_back(key_arr);
printf("size partition %d is %d\n", i+1, key_arr->size()); printf("size partition %llu is %llu\n", (unsigned long long)i+1, (unsigned long long)key_arr->size());
} }
key_v_t * key_arr = new key_v_t; key_v_t * key_arr = new key_v_t;
@ -58,7 +58,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
iters.push_back(new key_v_t::iterator((*key_v_list)[i]->begin())); iters.push_back(new key_v_t::iterator((*key_v_list)[i]->begin()));
} }
int lc = 0; size_t lc = 0;
while(true) while(true)
{ {
int list_index = -1; int list_index = -1;
@ -80,7 +80,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
(*iters[list_index])++; (*iters[list_index])++;
lc++; lc++;
if(lc % max_partition_size == 0) if(lc % max_partition_size == 0)
printf("%d/%d completed.\n", lc, NUM_ENTRIES); printf("%llu/%llu completed.\n", (unsigned long long)lc, (unsigned long long)NUM_ENTRIES);
} }
for(int i=0; i<list_size; i++) for(int i=0; i<list_size; i++)
@ -92,7 +92,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
key_v_list->clear(); key_v_list->clear();
delete key_v_list; delete key_v_list;
printf("key arr size: %d\n", key_arr->size()); printf("key arr size: %llu\n", (unsigned long long)key_arr->size());
if(key_arr->size() > NUM_ENTRIES) if(key_arr->size() > NUM_ENTRIES)
key_arr->erase(key_arr->begin()+NUM_ENTRIES, key_arr->end()); key_arr->erase(key_arr->begin()+NUM_ENTRIES, key_arr->end());
@ -112,7 +112,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
mscheduler.startlogtable(lindex, 10 * 1024 * 1024); mscheduler.startlogtable(lindex, 10 * 1024 * 1024);
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES); printf("Stage 1: Writing %llu keys\n", (unsigned long long)NUM_ENTRIES);
struct timeval start_tv, stop_tv, ti_st, ti_end; struct timeval start_tv, stop_tv, ti_st, ti_end;
double insert_time = 0; double insert_time = 0;
@ -187,13 +187,13 @@ void insertProbeIter(size_t NUM_ENTRIES)
printf("#deletions: %d\n#updates: %d\n", delcount, upcount); printf("#deletions: %d\n#updates: %d\n", delcount, upcount);
printf("\nTREE STRUCTURE\n"); printf("\nTREE STRUCTURE\n");
printf("datasize: %lld\n", datasize); printf("datasize: %llu\n", (unsigned long long)datasize);
xid = Tbegin(); xid = Tbegin();
printf("Stage 2: Looking up %d keys:\n", NUM_ENTRIES); printf("Stage 2: Looking up %llu keys:\n", (unsigned long long)NUM_ENTRIES);
int found_tuples=0; int found_tuples=0;
for(int i=NUM_ENTRIES-1; i>=0; i--) for(int i=NUM_ENTRIES-1; i>=0; i--)

View file

@ -56,7 +56,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
//ltable.get_tree_c1()->print_tree(xid); //ltable.get_tree_c1()->print_tree(xid);
printf("datasize: %lld\n", (long long)datasize); printf("datasize: %lld\n", (long long)datasize);
printf("Stage 2: Looking up %d keys:\n", NUM_ENTRIES); printf("Stage 2: Looking up %llu keys:\n", (unsigned long long)NUM_ENTRIES);
int found_tuples=0; int found_tuples=0;
for(int i=NUM_ENTRIES-1; i>=0; i--) for(int i=NUM_ENTRIES-1; i>=0; i--)

View file

@ -34,8 +34,8 @@ void insertProbeIter(size_t NUM_ENTRIES)
const static size_t max_partition_size = 100000; const static size_t max_partition_size = 100000;
int KEY_LEN = 100; int KEY_LEN = 100;
std::vector<key_v_t*> *key_v_list = new std::vector<key_v_t*>; std::vector<key_v_t*> *key_v_list = new std::vector<key_v_t*>;
int list_size = NUM_ENTRIES / max_partition_size + 1; size_t list_size = NUM_ENTRIES / max_partition_size + 1;
for(int i =0; i<list_size; i++) for(size_t i =0; i<list_size; i++)
{ {
key_v_t * key_arr = new key_v_t; key_v_t * key_arr = new key_v_t;
if(NUM_ENTRIES < max_partition_size*(i+1)) if(NUM_ENTRIES < max_partition_size*(i+1))
@ -45,7 +45,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
std::sort(key_arr->begin(), key_arr->end(), &mycmp); std::sort(key_arr->begin(), key_arr->end(), &mycmp);
key_v_list->push_back(key_arr); key_v_list->push_back(key_arr);
printf("size partition %d is %d\n", i+1, key_arr->size()); printf("size partition %llu is %llu\n", (unsigned long long)i+1, (unsigned long long)key_arr->size());
} }
@ -53,7 +53,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
key_v_t * key_arr = new key_v_t; key_v_t * key_arr = new key_v_t;
std::vector<key_v_t::iterator*> iters; std::vector<key_v_t::iterator*> iters;
for(int i=0; i<list_size; i++) for(size_t i=0; i<list_size; i++)
{ {
iters.push_back(new key_v_t::iterator((*key_v_list)[i]->begin())); iters.push_back(new key_v_t::iterator((*key_v_list)[i]->begin()));
} }
@ -62,7 +62,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
while(true) while(true)
{ {
int list_index = -1; int list_index = -1;
for(int i=0; i<list_size; i++) for(size_t i=0; i<list_size; i++)
{ {
if(*iters[i] == (*key_v_list)[i]->end()) if(*iters[i] == (*key_v_list)[i]->end())
continue; continue;
@ -80,10 +80,10 @@ void insertProbeIter(size_t NUM_ENTRIES)
(*iters[list_index])++; (*iters[list_index])++;
lc++; lc++;
if(lc % max_partition_size == 0) if(lc % max_partition_size == 0)
printf("%d/%d completed.\n", lc, NUM_ENTRIES); printf("%llu/%llu completed.\n", (unsigned long long)lc, (unsigned long long)NUM_ENTRIES);
} }
for(int i=0; i<list_size; i++) for(size_t i=0; i<list_size; i++)
{ {
(*key_v_list)[i]->clear(); (*key_v_list)[i]->clear();
delete (*key_v_list)[i]; delete (*key_v_list)[i];
@ -91,14 +91,14 @@ void insertProbeIter(size_t NUM_ENTRIES)
} }
key_v_list->clear(); key_v_list->clear();
delete key_v_list; delete key_v_list;
printf("key arr size: %d\n", key_arr->size()); printf("key arr size: %llu\n", (unsigned long long)key_arr->size());
if(key_arr->size() > NUM_ENTRIES) if(key_arr->size() > NUM_ENTRIES)
key_arr->erase(key_arr->begin()+NUM_ENTRIES, key_arr->end()); key_arr->erase(key_arr->begin()+NUM_ENTRIES, key_arr->end());
NUM_ENTRIES=key_arr->size(); NUM_ENTRIES=key_arr->size();
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES); printf("Stage 1: Writing %llu keys\n", (unsigned long long)NUM_ENTRIES);
struct timeval start_tv, stop_tv, ti_st, ti_end; struct timeval start_tv, stop_tv, ti_st, ti_end;
double insert_time = 0; double insert_time = 0;
@ -134,7 +134,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
datatuple::freetuple(newtuple); datatuple::freetuple(newtuple);
if(i % 10000 == 0 && i > 0) if(i % 10000 == 0 && i > 0)
printf("%d / %d inserted.\n", i, NUM_ENTRIES); printf("%llu / %llu inserted.\n", (unsigned long long)i, (unsigned long long)NUM_ENTRIES);
} }
gettimeofday(&stop_tv,0); gettimeofday(&stop_tv,0);
@ -144,7 +144,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
printf("Stage 2: Looking up %d keys:\n", NUM_ENTRIES); printf("Stage 2: Looking up %llu keys:\n", (unsigned long long)NUM_ENTRIES);
int found_tuples=0; int found_tuples=0;

View file

@ -25,7 +25,7 @@ int main(int argc, char * argv[]) {
logstore_client_close(l); logstore_client_close(l);
assert(ret->keylen() == sizeof(uint64_t)); assert(ret->keylen() == sizeof(uint64_t));
assert(ret->datalen() == sizeof(uint64_t)); assert(ret->datalen() == sizeof(uint64_t));
printf("Tree is %lld MB Store file is %lld MB\n", (*(uint64_t*)ret->key()) / (1024*1024), (*(uint64_t*)ret->data()) / (1024*1024)); printf("Tree is %llu MB Store file is %llu MB\n", (unsigned long long)(*(uint64_t*)ret->key()) / (1024*1024), (unsigned long long)(*(uint64_t*)ret->data()) / (1024*1024));
datatuple::freetuple(ret); datatuple::freetuple(ret);
; ;
return 0; return 0;