use of com.google.spanner.v1.Type in project cel-java by projectnessie.
the class AttributesTest method benchmarkResolverFieldQualifier.
@Test
void benchmarkResolverFieldQualifier() {
TestAllTypes msg = TestAllTypes.newBuilder().setSingleNestedMessage(NestedMessage.newBuilder().setBb(123)).build();
TypeRegistry reg = newRegistry(msg);
AttributeFactory attrs = newAttributeFactory(Container.defaultContainer, reg, reg);
Activation vars = newActivation(mapOf("msg", msg));
NamespacedAttribute attr = attrs.absoluteAttribute(1, "msg");
Type opType = reg.findType("google.api.expr.test.v1.proto3.TestAllTypes");
assertThat(opType).isNotNull();
Type fieldType = reg.findType("google.api.expr.test.v1.proto3.TestAllTypes.NestedMessage");
assertThat(fieldType).isNotNull();
attr.addQualifier(makeQualifier(attrs, opType.getType(), 2, "single_nested_message"));
attr.addQualifier(makeQualifier(attrs, fieldType.getType(), 3, "bb"));
// Note: migrated to JMH
}
use of com.google.spanner.v1.Type in project cel-java by projectnessie.
the class FieldDescriptionTest method fieldDescription.
@Test
void fieldDescription() {
Db pbdb = newDb();
NestedTestAllTypes msg = NestedTestAllTypes.getDefaultInstance();
String msgName = msg.getDescriptorForType().getFullName();
pbdb.registerMessage(msg);
PbTypeDescription td = pbdb.describeType(msgName);
assertThat(td).isNotNull();
FieldDescription fd = td.fieldByName("payload");
assertThat(fd).isNotNull();
assertThat(fd).extracting(FieldDescription::name).isEqualTo("payload");
assertThat(fd).extracting(FieldDescription::isOneof).isEqualTo(false);
assertThat(fd).extracting(FieldDescription::isMap).isEqualTo(false);
assertThat(fd).extracting(FieldDescription::isMessage).isEqualTo(true);
assertThat(fd).extracting(FieldDescription::isEnum).isEqualTo(false);
assertThat(fd).extracting(FieldDescription::isList).isEqualTo(false);
// Access the field by its Go struct name and check to see that it's index
// matches the one determined by the TypeDescription utils.
Type got = fd.checkedType();
Type wanted = Type.newBuilder().setMessageType("google.api.expr.test.v1.proto3.TestAllTypes").build();
assertThat(got).isEqualTo(wanted);
}
use of com.google.spanner.v1.Type in project cel-java by projectnessie.
the class PbTypeDescriptionTest method checkedType.
@Test
void checkedType() {
Db pbdb = newDb();
TestAllTypes msg = TestAllTypes.getDefaultInstance();
String msgName = msg.getDescriptorForType().getFullName();
pbdb.registerMessage(msg);
PbTypeDescription td = pbdb.describeType(msgName);
assertThat(td).isNotNull();
FieldDescription field = td.fieldByName("map_string_string");
assertThat(field).isNotNull();
Type mapType = Decls.newMapType(Decls.String, Decls.String);
assertThat(field.checkedType()).isEqualTo(mapType);
field = td.fieldByName("repeated_nested_message");
assertThat(field).isNotNull();
Type listType = Decls.newListType(Decls.newObjectType("google.api.expr.test.v1.proto3.TestAllTypes.NestedMessage"));
assertThat(field.checkedType()).isEqualTo(listType);
}
use of com.google.spanner.v1.Type in project java-smt by sosy-lab.
the class CVC4FormulaCreator method getFormulaType.
@SuppressWarnings("unchecked")
@Override
public <T extends Formula> FormulaType<T> getFormulaType(T pFormula) {
Type t = extractInfo(pFormula).getType();
if (pFormula instanceof BitvectorFormula) {
checkArgument(t.isBitVector(), "BitvectorFormula with actual type %s: %s", t, pFormula);
return (FormulaType<T>) getFormulaType(extractInfo(pFormula));
} else if (pFormula instanceof FloatingPointFormula) {
checkArgument(t.isFloatingPoint(), "FloatingPointFormula with actual type %s: %s", t, pFormula);
edu.stanford.CVC4.FloatingPointType fpType = new edu.stanford.CVC4.FloatingPointType(t);
return (FormulaType<T>) FormulaType.getFloatingPointType((int) fpType.getExponentSize(), // without sign bit
(int) fpType.getSignificandSize() - 1);
} else if (pFormula instanceof ArrayFormula<?, ?>) {
FormulaType<T> arrayIndexType = getArrayFormulaIndexType((ArrayFormula<T, T>) pFormula);
FormulaType<T> arrayElementType = getArrayFormulaElementType((ArrayFormula<T, T>) pFormula);
return (FormulaType<T>) FormulaType.getArrayType(arrayIndexType, arrayElementType);
}
return super.getFormulaType(pFormula);
}
use of com.google.spanner.v1.Type in project java-smt by sosy-lab.
the class CVC4FormulaCreator method declareUFImpl.
@Override
public Expr declareUFImpl(String pName, Type pReturnType, List<Type> pArgTypes) {
Expr exp = functionsCache.get(pName);
if (exp == null) {
vectorType args = new vectorType();
for (Type t : pArgTypes) {
args.add(t);
}
exp = exprManager.mkVar(pName, exprManager.mkFunctionType(args, pReturnType));
functionsCache.put(pName, exp);
}
return exp;
}
Aggregations