Search in sources :

Example 1 with CompositeConverter

use of com.hazelcast.query.impl.CompositeConverter in project hazelcast by hazelcast.

the class MapTableConverterResolutionTest method checkCompositeConverter.

private void checkCompositeConverter(TypeConverter converter1, TypeConverter converter2, QueryDataType... expectedTypes) {
    CompositeConverter converter = new CompositeConverter(new TypeConverter[] { converter1, converter2 });
    List<QueryDataType> types = MapTableUtils.indexConverterToSqlTypes(converter);
    List<QueryDataType> expectedTypes0 = expectedTypes == null ? Collections.emptyList() : Arrays.asList(expectedTypes);
    assertEquals(expectedTypes0, types);
}
Also used : QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) CompositeConverter(com.hazelcast.query.impl.CompositeConverter)

Example 2 with CompositeConverter

use of com.hazelcast.query.impl.CompositeConverter in project hazelcast by hazelcast.

the class MapTableUtils method indexConverterToSqlTypes.

public static List<QueryDataType> indexConverterToSqlTypes(TypeConverter converter) {
    if (converter == null) {
        return Collections.emptyList();
    }
    if (converter instanceof CompositeConverter) {
        CompositeConverter converter0 = ((CompositeConverter) converter);
        List<QueryDataType> res = new ArrayList<>(converter0.getComponentCount());
        for (int i = 0; i < converter0.getComponentCount(); i++) {
            QueryDataType type = indexConverterToSqlType(converter0.getComponentConverter(i));
            if (type == null) {
                break;
            } else {
                res.add(type);
            }
        }
        if (!res.isEmpty()) {
            return res;
        }
    } else {
        QueryDataType type = indexConverterToSqlType(converter);
        if (type != null) {
            return Collections.singletonList(type);
        }
    }
    return Collections.emptyList();
}
Also used : QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) ArrayList(java.util.ArrayList) CompositeConverter(com.hazelcast.query.impl.CompositeConverter)

Example 3 with CompositeConverter

use of com.hazelcast.query.impl.CompositeConverter in project hazelcast by hazelcast.

the class MapTableConverterResolutionTest method checkUnsupportedConverter.

private void checkUnsupportedConverter(TypeConverter converter) {
    assertNull(MapTableUtils.indexConverterToSqlType(converter));
    assertEquals(Collections.emptyList(), MapTableUtils.indexConverterToSqlTypes(converter));
    CompositeConverter badGood = new CompositeConverter(new TypeConverter[] { converter, INTEGER_CONVERTER });
    assertEquals(Collections.emptyList(), MapTableUtils.indexConverterToSqlTypes(badGood));
    CompositeConverter goodBad = new CompositeConverter(new TypeConverter[] { INTEGER_CONVERTER, converter });
    assertEquals(Collections.singletonList(INT), MapTableUtils.indexConverterToSqlTypes(goodBad));
}
Also used : CompositeConverter(com.hazelcast.query.impl.CompositeConverter)

Aggregations

CompositeConverter (com.hazelcast.query.impl.CompositeConverter)3 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)2 ArrayList (java.util.ArrayList)1