com.bagri.server.hazelcast.predicate.DocsAwarePredicate 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_DocsAwarePredicate;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.Map.Entry;
import com.bagri.core.DataKey;
import com.bagri.core.model.Elements;
import com.bagri.core.query.PathExpression;
import com.bagri.support.util.CollectionUtils;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
@SuppressWarnings("serial")
public class DocsAwarePredicate extends QueryPredicate {
private Set docIds = new HashSet<>();
public DocsAwarePredicate() {
super();
}
public DocsAwarePredicate(PathExpression pex, Object value, Set docIds) {
super(pex, value);
this.docIds.addAll(docIds);
}
@Override
public int getId() {
return cli_DocsAwarePredicate;
}
@Override
public boolean apply(Entry xdmEntry) {
if (docIds.contains(xdmEntry.getKey().getDocumentKey())) {
return super.apply(xdmEntry);
}
return false;
}
@Override
public void readData(ObjectDataInput in) throws IOException {
super.readData(in);
CollectionUtils.fromLongArray(in.readLongArray(), docIds);
}
@Override
public void writeData(ObjectDataOutput out) throws IOException {
super.writeData(out);
out.writeLongArray(CollectionUtils.toLongArray(docIds));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy