what-the-bank/sources/com/google/firebase/firestore/index/FirestoreIndexValueWriter.java

230 lines
9.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.firestore.index;
import com.google.firebase.firestore.model.ResourcePath;
import com.google.firebase.firestore.model.Values;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import o.AQX;
import o.QwV;
import o.jrE;
import o.ldG;
import o.sbb;
import o.uOO;
/* loaded from: classes2.dex */
public class FirestoreIndexValueWriter {
public static final FirestoreIndexValueWriter INSTANCE = new FirestoreIndexValueWriter();
private FirestoreIndexValueWriter() {
}
public void writeIndexValue(sbb sbbVar, DirectionalIndexByteEncoder directionalIndexByteEncoder) {
writeIndexValueAux(sbbVar, directionalIndexByteEncoder);
directionalIndexByteEncoder.writeInfinity();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: com.google.firebase.firestore.index.FirestoreIndexValueWriter$1, reason: invalid class name */
/* loaded from: classes2.dex */
public static /* synthetic */ class AnonymousClass1 {
static final int[] $SwitchMap$com$google$firestore$v1$Value$ValueTypeCase;
static {
int[] iArr = new int[sbb.HBt.values().length];
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase = iArr;
try {
iArr[sbb.HBt.NULL_VALUE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.BOOLEAN_VALUE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.DOUBLE_VALUE.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.INTEGER_VALUE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.TIMESTAMP_VALUE.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.STRING_VALUE.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.BYTES_VALUE.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.REFERENCE_VALUE.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.GEO_POINT_VALUE.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.MAP_VALUE.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.ARRAY_VALUE.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
}
}
private void writeIndexValueAux(sbb sbbVar, DirectionalIndexByteEncoder directionalIndexByteEncoder) {
AQX c;
QwV qwV;
jrE a;
ldG d;
uOO e;
switch (AnonymousClass1.$SwitchMap$com$google$firestore$v1$Value$ValueTypeCase[sbb.HBt.c(sbbVar.valueTypeCase_).ordinal()]) {
case 1:
writeValueTypeLabel(directionalIndexByteEncoder, 5);
return;
case 2:
writeValueTypeLabel(directionalIndexByteEncoder, 10);
if (sbbVar.valueTypeCase_ == 1 && ((Boolean) sbbVar.valueType_).booleanValue()) {
r2 = 1;
}
directionalIndexByteEncoder.writeLong(r2);
return;
case 3:
double doubleValue = sbbVar.valueTypeCase_ == 3 ? ((Double) sbbVar.valueType_).doubleValue() : 0.0d;
if (Double.isNaN(doubleValue)) {
writeValueTypeLabel(directionalIndexByteEncoder, 13);
return;
}
writeValueTypeLabel(directionalIndexByteEncoder, 15);
if (doubleValue == 0.0d) {
directionalIndexByteEncoder.writeDouble(0.0d);
return;
} else {
directionalIndexByteEncoder.writeDouble(doubleValue);
return;
}
case 4:
writeValueTypeLabel(directionalIndexByteEncoder, 15);
directionalIndexByteEncoder.writeDouble(sbbVar.valueTypeCase_ == 2 ? ((Long) sbbVar.valueType_).longValue() : 0L);
return;
case 5:
if (sbbVar.valueTypeCase_ == 10) {
c = (AQX) sbbVar.valueType_;
} else {
c = AQX.c();
}
writeValueTypeLabel(directionalIndexByteEncoder, 20);
directionalIndexByteEncoder.writeLong(c.seconds_);
directionalIndexByteEncoder.writeLong(c.nanos_);
return;
case 6:
writeIndexString(sbbVar.valueTypeCase_ == 17 ? (String) sbbVar.valueType_ : "", directionalIndexByteEncoder);
writeTruncationMarker(directionalIndexByteEncoder);
return;
case 7:
writeValueTypeLabel(directionalIndexByteEncoder, 30);
if (sbbVar.valueTypeCase_ == 18) {
qwV = (QwV) sbbVar.valueType_;
} else {
qwV = QwV.a;
}
directionalIndexByteEncoder.writeBytes(qwV);
writeTruncationMarker(directionalIndexByteEncoder);
return;
case 8:
writeIndexEntityRef(sbbVar.valueTypeCase_ == 5 ? (String) sbbVar.valueType_ : "", directionalIndexByteEncoder);
return;
case 9:
if (sbbVar.valueTypeCase_ == 8) {
a = (jrE) sbbVar.valueType_;
} else {
a = jrE.a();
}
writeValueTypeLabel(directionalIndexByteEncoder, 45);
directionalIndexByteEncoder.writeDouble(a.latitude_);
directionalIndexByteEncoder.writeDouble(a.longitude_);
return;
case 10:
if (Values.isMaxValue(sbbVar)) {
writeValueTypeLabel(directionalIndexByteEncoder, Integer.MAX_VALUE);
return;
}
if (sbbVar.valueTypeCase_ == 6) {
d = (ldG) sbbVar.valueType_;
} else {
d = ldG.d();
}
writeIndexMap(d, directionalIndexByteEncoder);
writeTruncationMarker(directionalIndexByteEncoder);
return;
case 11:
if (sbbVar.valueTypeCase_ == 9) {
e = (uOO) sbbVar.valueType_;
} else {
e = uOO.e();
}
writeIndexArray(e, directionalIndexByteEncoder);
writeTruncationMarker(directionalIndexByteEncoder);
return;
default:
StringBuilder sb = new StringBuilder("unknown index value type ");
sb.append(sbb.HBt.c(sbbVar.valueTypeCase_));
throw new IllegalArgumentException(sb.toString());
}
}
private void writeIndexString(String str, DirectionalIndexByteEncoder directionalIndexByteEncoder) {
writeValueTypeLabel(directionalIndexByteEncoder, 25);
writeUnlabeledIndexString(str, directionalIndexByteEncoder);
}
private void writeUnlabeledIndexString(String str, DirectionalIndexByteEncoder directionalIndexByteEncoder) {
directionalIndexByteEncoder.writeString(str);
}
private void writeIndexMap(ldG ldg, DirectionalIndexByteEncoder directionalIndexByteEncoder) {
writeValueTypeLabel(directionalIndexByteEncoder, 55);
for (Map.Entry entry : Collections.unmodifiableMap(ldg.fields_).entrySet()) {
String str = (String) entry.getKey();
sbb sbbVar = (sbb) entry.getValue();
writeIndexString(str, directionalIndexByteEncoder);
writeIndexValueAux(sbbVar, directionalIndexByteEncoder);
}
}
private void writeIndexArray(uOO uoo, DirectionalIndexByteEncoder directionalIndexByteEncoder) {
writeValueTypeLabel(directionalIndexByteEncoder, 50);
Iterator<sbb> it = uoo.values_.iterator();
while (it.hasNext()) {
writeIndexValueAux(it.next(), directionalIndexByteEncoder);
}
}
private void writeIndexEntityRef(String str, DirectionalIndexByteEncoder directionalIndexByteEncoder) {
writeValueTypeLabel(directionalIndexByteEncoder, 37);
ResourcePath fromString = ResourcePath.fromString(str);
int length = fromString.length();
for (int i = 5; i < length; i++) {
String segment = fromString.getSegment(i);
writeValueTypeLabel(directionalIndexByteEncoder, 60);
writeUnlabeledIndexString(segment, directionalIndexByteEncoder);
}
}
private void writeValueTypeLabel(DirectionalIndexByteEncoder directionalIndexByteEncoder, int i) {
directionalIndexByteEncoder.writeLong(i);
}
private void writeTruncationMarker(DirectionalIndexByteEncoder directionalIndexByteEncoder) {
directionalIndexByteEncoder.writeLong(2L);
}
}