com.bagri.server.hazelcast.predicate.ResultsQueryPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bagri-server-hazelcast Show documentation
Show all versions of bagri-server-hazelcast Show documentation
Bagri DB Cache: Hazelcast implementation
The newest version!
package com.bagri.server.hazelcast.predicate;
import static com.bagri.server.hazelcast.serialize.SystemSerializationFactory.cli_ResultsQueryPredicate;
import static com.bagri.server.hazelcast.serialize.SystemSerializationFactory.cli_factory_id;
import static com.bagri.support.util.CollectionUtils.*;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import com.bagri.core.model.QueryResult;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.query.Predicate;
public class ResultsQueryPredicate implements Predicate, IdentifiedDataSerializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Set queryIds = new HashSet<>();
public ResultsQueryPredicate() {
// for de-serialization
}
public ResultsQueryPredicate(Collection queryIds) {
this.queryIds.addAll(queryIds);
}
@Override
public int getFactoryId() {
return cli_factory_id;
}
@Override
public int getId() {
return cli_ResultsQueryPredicate;
}
@Override
public boolean apply(Entry resEntry) {
long resultKey = resEntry.getKey();
Integer queryKey = (int) (resultKey >> 32);
return queryIds.contains(queryKey);
}
@Override
public void readData(ObjectDataInput in) throws IOException {
queryIds.addAll(toIntList(in.readIntArray()));
}
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeIntArray(toIntArray(queryIds));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy