Fix filter path_func to allow record argument as a subset of stream's columns.

This required adding the ability for RecordVal::CoerceTo functions to
optionally allow orphaning fields.  The default is to not allow it, but
now before writing to a log, the value of the stream's columns is coerced
down, if necessary, before passing it on to the filter's path_func.

Addresses #600.
This commit is contained in:
Jon Siwek 2011-09-09 14:57:22 -05:00
parent 3a3f58d5df
commit 7ff2a3e115
6 changed files with 82 additions and 6 deletions

View file

@ -2863,7 +2863,7 @@ Val* RecordVal::LookupWithDefault(int field) const
return record_type->FieldDefault(field);
}
RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr) const
RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool allow_orphaning) const
{
if ( ! record_promotion_compatible(t->AsRecordType(), Type()->AsRecordType()) )
return 0;
@ -2883,6 +2883,8 @@ RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr) const
if ( t_i < 0 )
{
if ( allow_orphaning ) continue;
char buf[512];
safe_snprintf(buf, sizeof(buf),
"orphan field \"%s\" in initialization",
@ -2916,7 +2918,7 @@ RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr) const
return ar;
}
RecordVal* RecordVal::CoerceTo(RecordType* t)
RecordVal* RecordVal::CoerceTo(RecordType* t, bool allow_orphaning)
{
if ( same_type(Type(), t) )
{
@ -2924,7 +2926,7 @@ RecordVal* RecordVal::CoerceTo(RecordType* t)
return this;
}
return CoerceTo(t, 0);
return CoerceTo(t, 0, allow_orphaning);
}
void RecordVal::Describe(ODesc* d) const