Smaller compile fixes for the new opaque serialization.

Also remove the non-existing clone function for EntrypyVals - which now
can just use serialization :)
This commit is contained in:
Johanna Amann 2019-06-17 14:48:02 -07:00
parent a50b06d6c1
commit 618f0802f4
8 changed files with 21 additions and 29 deletions

View file

@ -41,8 +41,8 @@ const std::string& OpaqueMgr::TypeID(const OpaqueVal* v) const
auto x = _types.find(v->OpaqueName());
if ( x == _types.end() )
reporter->InternalError(fmt("OpaqueMgr::TypeID: opaque type %s not registered",
v->OpaqueName()));
reporter->InternalError("OpaqueMgr::TypeID: opaque type %s not registered",
v->OpaqueName());
return x->first;
}
@ -644,12 +644,6 @@ EntropyVal::EntropyVal() : OpaqueVal(entropy_type)
{
}
Val* EntropyVal::DoClone(CloneState* state)
{
// Fixme
return nullptr;
}
bool EntropyVal::Feed(const void* data, size_t size)
{
state.add(data, size);

View file

@ -21,14 +21,12 @@ public:
/**
* Return's a unique ID for the type of an opaque value.
* @param v opaque value to return type for; it's classmust have been
* @param v opaque value to return type for; its class must have been
* registered with the manager, otherwise this method will abort
* execugtion.
* execution.
*
* @return type ID, which can used with *Instantiate()* to create a
* new
* instnace of the same type.
* new instance of the same type.
*/
const std::string& TypeID(const OpaqueVal* v) const;
@ -66,8 +64,8 @@ private:
/** Macro to insert into an OpaqueVal-derived class's declaration. */
#define DECLARE_OPAQUE_VALUE(T) \
friend class OpaqueMgr::Register<T>; \
broker::data DoSerialize() const; \
bool DoUnserialize(const broker::data& data); \
broker::data DoSerialize() const override; \
bool DoUnserialize(const broker::data& data) override; \
const char* OpaqueName() const override { return #T; } \
static OpaqueVal* OpaqueInstantiate() { return new T(); }
@ -90,7 +88,7 @@ public:
/**
* Serializes the value into a Broker representation.
*
* @return the broker representatio, or an error if serialization
* @return the broker representation, or an error if serialization
* isn't supported or failed.
*/
broker::expected<broker::data> Serialize() const;
@ -244,8 +242,6 @@ class EntropyVal : public OpaqueVal {
public:
EntropyVal();
Val* DoClone(CloneState* state) override;
bool Feed(const void* data, size_t size);
bool Get(double *r_ent, double *r_chisq, double *r_mean,
double *r_montepicalc, double *r_scc);

View file

@ -1183,7 +1183,8 @@ IMPLEMENT_OPAQUE_VALUE(bro_broker::VectorIterator)
broker::data bro_broker::VectorIterator::DoSerialize() const
{
return broker::vector{dat, it - dat.begin()};
broker::integer difference = it - dat.begin();
return broker::vector{dat, difference};
}
bool bro_broker::VectorIterator::DoUnserialize(const broker::data& data)
@ -1193,7 +1194,7 @@ bool bro_broker::VectorIterator::DoUnserialize(const broker::data& data)
return false;
auto x = caf::get_if<broker::vector>(&(*v)[0]);
auto y = caf::get_if<broker::vector::difference_type>(&(*v)[1]);
auto y = caf::get_if<broker::integer>(&(*v)[1]);
dat = *x;
it = dat.begin() + *y;
@ -1204,7 +1205,8 @@ IMPLEMENT_OPAQUE_VALUE(bro_broker::RecordIterator)
broker::data bro_broker::RecordIterator::DoSerialize() const
{
return broker::vector{dat, it - dat.begin()};
broker::integer difference = it - dat.begin();
return broker::vector{dat, difference};
}
bool bro_broker::RecordIterator::DoUnserialize(const broker::data& data)
@ -1214,7 +1216,7 @@ bool bro_broker::RecordIterator::DoUnserialize(const broker::data& data)
return false;
auto x = caf::get_if<broker::vector>(&(*v)[0]);
auto y = caf::get_if<broker::vector::difference_type>(&(*v)[1]);
auto y = caf::get_if<broker::integer>(&(*v)[1]);
dat = *x;
it = dat.begin() + *y;

View file

@ -543,7 +543,7 @@ std::unique_ptr<BitVector> BitVector::Unserialize(const broker::data& data)
bv->bits.push_back(*x);
}
return std::move(bv);
return bv;
}
BitVector::size_type BitVector::lowest_bit(block_type block)

View file

@ -70,7 +70,7 @@ std::unique_ptr<BloomFilter> BloomFilter::Unserialize(const broker::data& data)
return nullptr;
bf->hasher = hasher_.release();
return std::move(bf);
return bf;
}
size_t BasicBloomFilter::M(double fp, size_t capacity)

View file

@ -234,7 +234,7 @@ std::unique_ptr<CardinalityCounter> CardinalityCounter::Unserialize(const broker
cc->buckets.push_back(*x);
}
return std::move(cc);
return cc;
}
/**

View file

@ -179,7 +179,7 @@ std::unique_ptr<CounterVector> CounterVector::Unserialize(const broker::data& da
auto cv = std::unique_ptr<CounterVector>(new CounterVector());
cv->width = *width;
cv->bits = bits.release();
return std::move(cv);
return cv;
}

View file

@ -84,7 +84,7 @@ std::unique_ptr<Hasher> Hasher::Unserialize(const broker::data& data)
// their own. They reconstruct all their information from their
// constructors' arguments.
return std::move(hasher);
return hasher;
}
UHF::UHF()