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:
parent
eb8b57378a
commit
7bed4b67ba
14 changed files with 41 additions and 41 deletions
|
@ -133,7 +133,7 @@ void DataPage<TUPLE>::initialize_page(pageid_t pageid) {
|
|||
releasePage(p);
|
||||
}
|
||||
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_);
|
||||
if(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;
|
||||
}
|
||||
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);
|
||||
if(chunk.size > remaining) {
|
||||
chunk.size = remaining;
|
||||
|
|
|
@ -128,8 +128,8 @@ private:
|
|||
assert(ret.size);
|
||||
return ret;
|
||||
}
|
||||
size_t write_bytes(const byte * buf, size_t remaining);
|
||||
size_t read_bytes(byte * buf, off_t offset, size_t remaining);
|
||||
size_t write_bytes(const byte * buf, ssize_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 read_data(byte * buf, off_t offset, size_t len);
|
||||
bool initialize_next_page();
|
||||
|
|
|
@ -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::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 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::NEXT_LEAF = 1; //pointer to next leaf page
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class diskTreeComponent {
|
|||
const static int64_t DEPTH;
|
||||
const static int64_t COMPARATOR;
|
||||
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 NEXT_LEAF;
|
||||
pageid_t lastLeaf;
|
||||
|
|
|
@ -145,8 +145,8 @@ void logserver::stopserver()
|
|||
tot_threadwork_time += idle_th->data->work_time;
|
||||
num_reqs += idle_th->data->num_reqs;
|
||||
|
||||
printf("thread %d: work_time %.3f\t#calls %d\tavg req process time:\t%.3f\n",
|
||||
i,
|
||||
printf("thread %llu: work_time %.3f\t#calls %d\tavg req process time:\t%.3f\n",
|
||||
(unsigned long long)i,
|
||||
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(opcode != OP_DONE) {
|
||||
char *msg;
|
||||
if(-1 != asprintf(&msg, "network error. conn closed. (%d, %d) ",
|
||||
*(item->data->workitem), item->data->work_queue->size())) {
|
||||
if(-1 != asprintf(&msg, "network error. conn closed. (%d, %llu) ",
|
||||
*(item->data->workitem), (unsigned long long)item->data->work_queue->size())) {
|
||||
perror(msg);
|
||||
free(msg);
|
||||
} else {
|
||||
|
|
|
@ -231,7 +231,7 @@ void mergeManager::tick(mergeStats * s, bool block, bool force) {
|
|||
total_sleep += sleeptime;
|
||||
|
||||
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;
|
||||
|
@ -364,7 +364,7 @@ void mergeManager::pretty_print(FILE * out) {
|
|||
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 ",
|
||||
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_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),
|
||||
|
|
|
@ -52,7 +52,7 @@ void insertWithConcurrentReads(size_t NUM_ENTRIES) {
|
|||
|
||||
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 dpages = 0;
|
||||
|
@ -154,7 +154,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
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 dpages = 0;
|
||||
|
@ -196,7 +196,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
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;
|
||||
|
|
|
@ -55,7 +55,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
if(data_arr.size() > NUM_ENTRIES)
|
||||
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++)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
Tcommit(xid);
|
||||
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;
|
||||
diskTreeComponent::iterator * tree_itr = ltable_c1->open_iterator();
|
||||
|
|
|
@ -58,7 +58,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
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;
|
||||
double insert_time = 0;
|
||||
|
@ -100,7 +100,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
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;
|
||||
for(int i=NUM_ENTRIES-1; i>=0; i--)
|
||||
|
|
|
@ -57,7 +57,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
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;
|
||||
double insert_time = 0;
|
||||
|
@ -88,7 +88,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
printf("\nTREE STRUCTURE\n");
|
||||
//ltable.get_tree_c1()->print_tree(xid);
|
||||
printf("datasize: %lld\n", datasize);
|
||||
printf("datasize: %llu\n", (unsigned long long)datasize);
|
||||
|
||||
mscheduler.shutdown();
|
||||
printf("merge threads finished.\n");
|
||||
|
|
|
@ -47,7 +47,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
std::sort(key_arr->begin(), key_arr->end(), &mycmp);
|
||||
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;
|
||||
|
@ -58,7 +58,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
iters.push_back(new key_v_t::iterator((*key_v_list)[i]->begin()));
|
||||
}
|
||||
|
||||
int lc = 0;
|
||||
size_t lc = 0;
|
||||
while(true)
|
||||
{
|
||||
int list_index = -1;
|
||||
|
@ -80,7 +80,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
(*iters[list_index])++;
|
||||
lc++;
|
||||
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++)
|
||||
|
@ -92,7 +92,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
key_v_list->clear();
|
||||
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)
|
||||
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);
|
||||
|
||||
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;
|
||||
double insert_time = 0;
|
||||
|
@ -187,13 +187,13 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
printf("#deletions: %d\n#updates: %d\n", delcount, upcount);
|
||||
|
||||
printf("\nTREE STRUCTURE\n");
|
||||
printf("datasize: %lld\n", datasize);
|
||||
printf("datasize: %llu\n", (unsigned long long)datasize);
|
||||
|
||||
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;
|
||||
for(int i=NUM_ENTRIES-1; i>=0; i--)
|
||||
|
|
|
@ -56,7 +56,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
//ltable.get_tree_c1()->print_tree(xid);
|
||||
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;
|
||||
for(int i=NUM_ENTRIES-1; i>=0; i--)
|
||||
|
|
|
@ -34,8 +34,8 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
const static size_t max_partition_size = 100000;
|
||||
int KEY_LEN = 100;
|
||||
std::vector<key_v_t*> *key_v_list = new std::vector<key_v_t*>;
|
||||
int list_size = NUM_ENTRIES / max_partition_size + 1;
|
||||
for(int i =0; i<list_size; i++)
|
||||
size_t list_size = NUM_ENTRIES / max_partition_size + 1;
|
||||
for(size_t i =0; i<list_size; i++)
|
||||
{
|
||||
key_v_t * key_arr = new key_v_t;
|
||||
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);
|
||||
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;
|
||||
|
||||
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()));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
while(true)
|
||||
{
|
||||
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())
|
||||
continue;
|
||||
|
@ -80,10 +80,10 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
(*iters[list_index])++;
|
||||
lc++;
|
||||
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();
|
||||
delete (*key_v_list)[i];
|
||||
|
@ -91,14 +91,14 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
}
|
||||
key_v_list->clear();
|
||||
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)
|
||||
key_arr->erase(key_arr->begin()+NUM_ENTRIES, key_arr->end());
|
||||
|
||||
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;
|
||||
double insert_time = 0;
|
||||
|
@ -134,7 +134,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
datatuple::freetuple(newtuple);
|
||||
|
||||
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);
|
||||
|
@ -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;
|
||||
|
|
|
@ -25,7 +25,7 @@ int main(int argc, char * argv[]) {
|
|||
logstore_client_close(l);
|
||||
assert(ret->keylen() == 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);
|
||||
;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue