make optional fields possible for input framework.

This do not have to be present in the input file and are marked as &optional in the record description.

Those can e.g. be used to create field values on the file in a predicate while reading a file - example:

	Input::add_table([$source="input.log", $name="input", $idx=Idx, $val=Val, $destination=servers,
				$pred(typ: Input::Event, left: Idx, right: Val) = { right$notb = !right$b; return T; }
This commit is contained in:
Bernhard Amann 2012-03-20 14:11:59 -07:00
parent 08e1771682
commit d39a389201
7 changed files with 90 additions and 8 deletions

View file

@ -492,7 +492,11 @@ bool Manager::CreateTableStream(RecordVal* fval) {
Unref(pred);
if ( valfields > 1 ) {
assert(filter->want_record);
if ( ! filter->want_record ) {
reporter->Error("Stream %s does not want a record (want_record=F), but has more then one value field. Aborting", filter->name.c_str());
delete filter;
return false;
}
}
@ -631,6 +635,10 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec, co
field->secondary_name = c->AsStringVal()->AsString()->CheckString();
}
if ( rec->FieldDecl(i)->FindAttr(ATTR_OPTIONAL ) ) {
field->optional = true;
}
fields->push_back(field);
}
}