use of com.google.firebase.firestore.index.DirectionalIndexByteEncoder in project firebase-android-sdk by firebase.
the class SQLiteIndexManager method encodeValues.
/**
* Encodes the given field values according to the specification in {@code target}. For IN
* queries, a list of possible values is returned.
*/
@Nullable
private Object[] encodeValues(FieldIndex fieldIndex, Target target, @Nullable Collection<Value> values) {
if (values == null)
return null;
List<IndexByteEncoder> encoders = new ArrayList<>();
encoders.add(new IndexByteEncoder());
Iterator<Value> position = values.iterator();
for (FieldIndex.Segment segment : fieldIndex.getDirectionalSegments()) {
Value value = position.next();
for (IndexByteEncoder encoder : encoders) {
if (isInFilter(target, segment.getFieldPath()) && isArray(value)) {
encoders = expandIndexValues(encoders, segment, value);
} else {
DirectionalIndexByteEncoder directionalEncoder = encoder.forKind(segment.getKind());
FirestoreIndexValueWriter.INSTANCE.writeIndexValue(value, directionalEncoder);
}
}
}
return getEncodedBytes(encoders);
}
use of com.google.firebase.firestore.index.DirectionalIndexByteEncoder in project firebase-android-sdk by firebase.
the class SQLiteIndexManager method encodeDirectionalElements.
/**
* Returns the byte encoded form of the directional values in the field index. Returns {@code
* null} if the document does not have all fields specified in the index.
*/
@Nullable
private byte[] encodeDirectionalElements(FieldIndex fieldIndex, Document document) {
IndexByteEncoder encoder = new IndexByteEncoder();
for (FieldIndex.Segment segment : fieldIndex.getDirectionalSegments()) {
Value field = document.getField(segment.getFieldPath());
if (field == null) {
return null;
}
DirectionalIndexByteEncoder directionalEncoder = encoder.forKind(segment.getKind());
FirestoreIndexValueWriter.INSTANCE.writeIndexValue(field, directionalEncoder);
}
return encoder.getEncodedBytes();
}
Aggregations