0

I am currently writing a RandomForest implementation in MapReduce and am trying to figure out how to go about serializing (implementing Writable) somehow on the Predicate interface. I have a class with a field that is of type Predicate. Any tips as to how to go about this? Thanks.

Alex Ramos
  • 135
  • 2
  • 14
  • Where does your `Predicate` interface come from? Is it `java.util.function.Predicate`? – Louis Wasserman Nov 09 '15 at 18:17
  • Yes, and I did figure out how to serialize it using this link. Not using Writables though. [predicate serialization](http://www.coderanch.com/t/631879/java/java/Java-good-bad-ugly) – Alex Ramos Nov 10 '15 at 06:19

1 Answers1

1

You can achieve that with similar ideas from this stack overflow question

If you have a predicate say;

final Predicate<CassandraRow> verifyPredicate = 
r -> Objects.equals(r.getObject("column_name"), Boolean.TRUE);

It can be converted into a serialisable Predicate as

final Predicate<CassandraRow> verifyPredicate = 
(Predicate<CassandraRow> & Serializable) r -> Objects.equals(r.getObject("column_name"), Boolean.TRUE);