reading seems to work with all atomic types + records...

This commit is contained in:
Bernhard Amann 2011-11-02 14:29:58 -07:00
parent 638976791e
commit b5a77aa77b
2 changed files with 21 additions and 6 deletions

View file

@ -334,12 +334,12 @@ void InputMgr::SendEntry(const InputReader* reader, const LogVal* const *vals) {
} }
reporter->Error("Hashing %d index fields", i->num_idx_fields); //reporter->Error("Hashing %d index fields", i->num_idx_fields);
HashKey* idxhash = HashLogVals(i->num_idx_fields, vals); HashKey* idxhash = HashLogVals(i->num_idx_fields, vals);
reporter->Error("Result: %d", (uint64_t) idxhash->Hash()); //reporter->Error("Result: %d", (uint64_t) idxhash->Hash());
reporter->Error("Hashing %d val fields", i->num_val_fields); //reporter->Error("Hashing %d val fields", i->num_val_fields);
HashKey* valhash = HashLogVals(i->num_val_fields, vals+i->num_idx_fields); HashKey* valhash = HashLogVals(i->num_val_fields, vals+i->num_idx_fields);
reporter->Error("Result: %d", (uint64_t) valhash->Hash()); //reporter->Error("Result: %d", (uint64_t) valhash->Hash());
//reporter->Error("received entry with idxhash %d and valhash %d", (uint64_t) idxhash->Hash(), (uint64_t) valhash->Hash()); //reporter->Error("received entry with idxhash %d and valhash %d", (uint64_t) idxhash->Hash(), (uint64_t) valhash->Hash());
@ -422,7 +422,6 @@ void InputMgr::EndCurrentSend(const InputReader* reader) {
// lastdict contains all deleted entries and should be empty apart from that // lastdict contains all deleted entries and should be empty apart from that
IterCookie *c = i->lastDict->InitForIteration(); IterCookie *c = i->lastDict->InitForIteration();
InputHash* ih; InputHash* ih;
reporter->Error("ending");
while ( ( ih = i->lastDict->NextEntry(c) ) ) { while ( ( ih = i->lastDict->NextEntry(c) ) ) {
reporter->Error("Expiring element"); reporter->Error("Expiring element");
i->tab->Delete(ih->idxkey); i->tab->Delete(ih->idxkey);
@ -589,6 +588,11 @@ HashKey* InputMgr::HashLogVals(const int num_elements, const LogVal* const *vals
length += NUM_ADDR_WORDS*sizeof(uint32_t); length += NUM_ADDR_WORDS*sizeof(uint32_t);
break; break;
case TYPE_SUBNET:
length += sizeof(val->val.subnet_val.width);
length += sizeof(val->val.subnet_val.net);
break;
default: default:
reporter->InternalError("unsupported type for hashlogvals"); reporter->InternalError("unsupported type for hashlogvals");
} }
@ -641,6 +645,13 @@ HashKey* InputMgr::HashLogVals(const int num_elements, const LogVal* const *vals
position += NUM_ADDR_WORDS*sizeof(uint32_t); position += NUM_ADDR_WORDS*sizeof(uint32_t);
break; break;
case TYPE_SUBNET:
memcpy(data+position,(const char*) &(val->val.subnet_val.width), sizeof(val->val.subnet_val.width) );
position += sizeof(val->val.subnet_val.width);
memcpy(data+position, (const char*) &(val->val.subnet_val.net), sizeof(val->val.subnet_val.net) );
position += sizeof(val->val.subnet_val.net);
break;
default: default:
reporter->InternalError("unsupported type for hashlogvals2"); reporter->InternalError("unsupported type for hashlogvals2");
} }
@ -694,6 +705,10 @@ Val* InputMgr::LogValToVal(const LogVal* val, TypeTag request_type) {
return new AddrVal(val->val.addr_val); return new AddrVal(val->val.addr_val);
break; break;
case TYPE_SUBNET:
return new SubNetVal(val->val.subnet_val.net, val->val.subnet_val.width);
break;
default: default:
reporter->InternalError("unsupported type for input_read"); reporter->InternalError("unsupported type for input_read");
} }

View file

@ -216,7 +216,7 @@ bool InputReaderAscii::DoUpdate() {
case TYPE_SUBNET: { case TYPE_SUBNET: {
int pos = s.find("/"); int pos = s.find("/");
string width = s.substr(pos); string width = s.substr(pos+1);
val->val.subnet_val.width = atoi(width.c_str()); val->val.subnet_val.width = atoi(width.c_str());
string addr = s.substr(0, pos); string addr = s.substr(0, pos);
s = addr; s = addr;