MCPcopy Index your code
hub / github.com/jOOQ/jOOQ / arrayTransform

Method arrayTransform

jOOQ/src/main/java/org/jooq/impl/Tools.java:8193–8240  ·  view source on GitHub ↗

A utility for the transformation logic of udt and non-udt arrays, e.g. by DSL#arrayMap(Field, Function1).

(
        Context<?> ctx,
        Field<T[]> array,
        Field<T> element,
        Field<U> mapper,
        Condition predicate
    )

Source from the content-addressed store, hash-verified

8191 * {@link DSL#arrayMap(Field, Function1)}.
8192 */
8193 static final <T, U> Select<? extends Record1<?>> arrayTransform(
8194 Context<?> ctx,
8195 Field<T[]> array,
8196 Field<T> element,
8197 Field<U> mapper,
8198 Condition predicate
8199 ) {
8200 DataType<T[]> t = array.getDataType();
8201 DataType<T> tc = (DataType<T>) t.getArrayComponentDataType();
8202 ArrayAggOrderByStep<U[]> agg = mapper == null ? null : arrayAgg(mapper);
8203
8204 if (ConvertedDataType.delegate(tc) instanceof UDTDataType<?> ut) {
8205 Field<Integer> o = DSL.field(N_O, INTEGER);
8206 Field<T[]> a = DSL.field(N_A, t);
8207 Name[] names = fieldNames(tc.getRow().size());
8208
8209 return
8210 select((Field<?>) (mapper == null
8211 ? one()
8212 : DSL.coalesce(agg.orderBy(o), ifNotNull(array, DSL.cast(array(), agg.getDataType())))))
8213 .from(
8214 values(row(array)).as(N_A, N_A),
8215 unnest(a)
8216 .withOrdinality()
8217 .as(N_T, Tools.concat(Arrays.asList(names), Arrays.asList(N_O))),
8218 lateral(values(row(arrayGet(a, o)))).as(N_E, element.getUnqualifiedName())
8219 )
8220 .where(predicate);
8221 }
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232 else {
8233 return
8234 select((Field<?>) (mapper == null
8235 ? one()
8236 : DSL.coalesce(agg, ifNotNull(array, DSL.cast(array(), agg.getDataType())))))
8237 .from(unnest(array).as(N_T, element.getUnqualifiedName()))
8238 .where(predicate);
8239 }
8240 }
8241
8242 static final int maxParameterCount(Scope ctx) {
8243

Callers 5

acceptMethod · 0.80
acceptMethod · 0.80
acceptMethod · 0.80
acceptMethod · 0.80
acceptMethod · 0.80

Calls 15

delegateMethod · 0.95
fieldMethod · 0.95
fieldNamesMethod · 0.95
coalesceMethod · 0.95
ifNotNullMethod · 0.95
castMethod · 0.95
concatMethod · 0.95
arrayAggMethod · 0.80
oneMethod · 0.80
unnestMethod · 0.80
lateralMethod · 0.80
arrayGetMethod · 0.80

Tested by

no test coverage detected