use of com.alibaba.maxgraph.sdkcommon.compiler.custom.CustomPredicate in project GraphScope by alibaba.
the class TreeBuilder method convertHasContainer.
private HasContainer convertHasContainer(String key, Predicate<?> predicate, ValueType inputValueType) {
if (null == predicate) {
return new HasContainer(key, null);
}
if (predicate instanceof CustomPredicate) {
if (StringUtils.isEmpty(key)) {
checkArgument(inputValueType instanceof ListValueType || inputValueType instanceof ValueValueType, "Output value for predicate must be value while current type=>" + inputValueType);
PredicateType predicateType = ((CustomPredicate) predicate).getPredicateType();
Message.VariantType variantType = inputValueType instanceof ListValueType ? Message.VariantType.valueOf(ValueValueType.class.cast(((ListValueType) inputValueType).getListValue()).getDataType().name() + "_LIST") : ValueValueType.class.cast(inputValueType).getDataType();
validPredicateVariantType(variantType, predicateType);
return new HasContainer(key, CustomPredicate.class.cast(predicate));
} else {
Set<DataType> dataTypeSet = SchemaUtils.getPropDataTypeList(key, schema);
if (dataTypeSet.isEmpty()) {
return new HasContainer(key, CustomPredicate.class.cast(predicate));
} else {
if (dataTypeSet.size() > 1) {
logger.warn("There's multiple type=>" + dataTypeSet + " for property=>" + key);
return new HasContainer(key, CustomPredicate.class.cast(predicate));
} else {
Message.VariantType variantType = CompilerUtils.parseVariantFromDataType(dataTypeSet.iterator().next());
PredicateType predicateType = ((CustomPredicate) predicate).getPredicateType();
validPredicateVariantType(variantType, predicateType);
return new HasContainer(key, CustomPredicate.class.cast(predicate));
}
}
}
} else {
if (StringUtils.isEmpty(key)) {
Message.VariantType variantType = ValueValueType.class.cast(inputValueType).getDataType();
return createContainerFromVariantyType(key, P.class.cast(predicate), variantType);
} else {
Set<DataType> dataTypeSet = SchemaUtils.getPropDataTypeList(key, schema);
if (dataTypeSet.isEmpty()) {
return new HasContainer(key, P.class.cast(predicate));
} else {
if (dataTypeSet.size() > 1) {
logger.warn("There's multiple type=>" + dataTypeSet + " for property=>" + key);
return new HasContainer(key, P.class.cast(predicate));
} else {
Message.VariantType variantType = CompilerUtils.parseVariantFromDataType(dataTypeSet.iterator().next());
return createContainerFromVariantyType(key, P.class.cast(predicate), variantType);
}
}
}
}
}
Aggregations