public static <X> ArrayKeySelector<X> getSelectorForArray(int[] positions, TypeInformation<X> typeInfo) { if (positions == null || positions.length == 0 || positions.length > Tuple.MAX_ARITY) { throw new IllegalArgumentException("Array keys must have between 1 and " + Tuple.MAX_ARITY + " fields."); } TypeInformation<?> componentType; if (typeInfo instanceof BasicArrayTypeInfo) { BasicArrayTypeInfo<X, ?> arrayInfo = (BasicArrayTypeInfo<X, ?>) typeInfo; componentType = arrayInfo.getComponentInfo(); } else if (typeInfo instanceof PrimitiveArrayTypeInfo) { PrimitiveArrayTypeInfo<X> arrayType = (PrimitiveArrayTypeInfo<X>) typeInfo; componentType = arrayType.getComponentType(); } else { throw new IllegalArgumentException("This method only supports arrays of primitives and boxed primitives."); } TypeInformation<?>[] primitiveInfos = new TypeInformation<?>[positions.length]; Arrays.fill(primitiveInfos, componentType); return new ArrayKeySelector<>(positions, new TupleTypeInfo<>(primitiveInfos)); }
PrimitiveArrayTypeInfo<OUT> primitiveArrayInfo = PrimitiveArrayTypeInfo.getInfoFor(clazz); if (primitiveArrayInfo != null) { return primitiveArrayInfo;
@Override public boolean equals(Object other) { if (other instanceof PrimitiveArrayTypeInfo) { @SuppressWarnings("unchecked") PrimitiveArrayTypeInfo<T> otherArray = (PrimitiveArrayTypeInfo<T>) other; return otherArray.canEqual(this) && arrayClass == otherArray.arrayClass && serializer.equals(otherArray.serializer) && comparatorClass == otherArray.comparatorClass; } else { return false; } }
/** * Gets the type information of the component type. * @return The type information of the component type. */ @PublicEvolving public TypeInformation<?> getComponentType() { return BasicTypeInfo.getInfoFor(getComponentClass()); }
@Override protected TypeComparator<T> createComparator(boolean ascending) { return info.createComparator(ascending, null).duplicate(); }
/** * Gets the type information of the component type. * @return The type information of the component type. */ @PublicEvolving public TypeInformation<?> getComponentType() { return BasicTypeInfo.getInfoFor(getComponentClass()); }
return convertObjectArray(node, ((BasicArrayTypeInfo) info).getComponentInfo()); } else if (info instanceof PrimitiveArrayTypeInfo && ((PrimitiveArrayTypeInfo) info).getComponentType() == Types.BYTE) { return convertByteArray(node); } else {
@Test @SuppressWarnings("unchecked") public void testArray() { int[] a = new int[]{3, 5}; FieldAccessor<int[], Integer> fieldAccessor = (FieldAccessor<int[], Integer>) (Object) FieldAccessorFactory.getAccessor(PrimitiveArrayTypeInfo.getInfoFor(a.getClass()), 1, null); assertEquals(Integer.class, fieldAccessor.getFieldType().getTypeClass()); assertEquals((Integer) a[1], fieldAccessor.get(a)); a = fieldAccessor.set(a, 6); assertEquals((Integer) a[1], fieldAccessor.get(a)); Integer[] b = new Integer[]{3, 5}; FieldAccessor<Integer[], Integer> fieldAccessor2 = (FieldAccessor<Integer[], Integer>) (Object) FieldAccessorFactory.getAccessor(BasicArrayTypeInfo.getInfoFor(b.getClass()), 1, null); assertEquals(Integer.class, fieldAccessor2.getFieldType().getTypeClass()); assertEquals(b[1], fieldAccessor2.get(b)); b = fieldAccessor2.set(b, 6); assertEquals(b[1], fieldAccessor2.get(b)); }
/** * Gets the type information of the component type. * @return The type information of the component type. */ @PublicEvolving public TypeInformation<?> getComponentType() { return BasicTypeInfo.getInfoFor(getComponentClass()); }
@Override public boolean equals(Object other) { if (other instanceof PrimitiveArrayTypeInfo) { @SuppressWarnings("unchecked") PrimitiveArrayTypeInfo<T> otherArray = (PrimitiveArrayTypeInfo<T>) other; return otherArray.canEqual(this) && arrayClass == otherArray.arrayClass && serializer.equals(otherArray.serializer) && comparatorClass == otherArray.comparatorClass; } else { return false; } }
return convertObjectArray(null, ((BasicArrayTypeInfo) info).getComponentInfo(), (Object[]) object); } else if (info instanceof PrimitiveArrayTypeInfo && ((PrimitiveArrayTypeInfo) info).getComponentType() == Types.BYTE) { return container.binaryNode((byte[]) object); } else {
PrimitiveArrayTypeInfo<OUT> primitiveArrayInfo = PrimitiveArrayTypeInfo.getInfoFor(clazz); if (primitiveArrayInfo != null) { return primitiveArrayInfo;
@Override public boolean equals(Object other) { if (other instanceof PrimitiveArrayTypeInfo) { @SuppressWarnings("unchecked") PrimitiveArrayTypeInfo<T> otherArray = (PrimitiveArrayTypeInfo<T>) other; return otherArray.canEqual(this) && arrayClass == otherArray.arrayClass && serializer.equals(otherArray.serializer) && comparatorClass == otherArray.comparatorClass; } else { return false; } }
} else if (typeInfo instanceof PrimitiveArrayTypeInfo) { final PrimitiveArrayTypeInfo arrayTypeInfo = (PrimitiveArrayTypeInfo) typeInfo; return PRIMITIVE_ARRAY + '<' + writeTypeInfo(arrayTypeInfo.getComponentType()) + '>'; } else if (typeInfo instanceof ObjectArrayTypeInfo) { final ObjectArrayTypeInfo arrayTypeInfo = (ObjectArrayTypeInfo) typeInfo;
PrimitiveArrayTypeInfo<OUT> primitiveArrayInfo = PrimitiveArrayTypeInfo.getInfoFor(clazz); if (primitiveArrayInfo != null) { return primitiveArrayInfo;
public static <X> ArrayKeySelector<X> getSelectorForArray(int[] positions, TypeInformation<X> typeInfo) { if (positions == null || positions.length == 0 || positions.length > Tuple.MAX_ARITY) { throw new IllegalArgumentException("Array keys must have between 1 and " + Tuple.MAX_ARITY + " fields."); } TypeInformation<?> componentType; if (typeInfo instanceof BasicArrayTypeInfo) { BasicArrayTypeInfo<X, ?> arrayInfo = (BasicArrayTypeInfo<X, ?>) typeInfo; componentType = arrayInfo.getComponentInfo(); } else if (typeInfo instanceof PrimitiveArrayTypeInfo) { PrimitiveArrayTypeInfo<X> arrayType = (PrimitiveArrayTypeInfo<X>) typeInfo; componentType = arrayType.getComponentType(); } else { throw new IllegalArgumentException("This method only supports arrays of primitives and boxed primitives."); } TypeInformation<?>[] primitiveInfos = new TypeInformation<?>[positions.length]; Arrays.fill(primitiveInfos, componentType); return new ArrayKeySelector<>(positions, new TupleTypeInfo<>(primitiveInfos)); }
public static <X> ArrayKeySelector<X> getSelectorForArray(int[] positions, TypeInformation<X> typeInfo) { if (positions == null || positions.length == 0 || positions.length > Tuple.MAX_ARITY) { throw new IllegalArgumentException("Array keys must have between 1 and " + Tuple.MAX_ARITY + " fields."); } TypeInformation<?> componentType; if (typeInfo instanceof BasicArrayTypeInfo) { BasicArrayTypeInfo<X, ?> arrayInfo = (BasicArrayTypeInfo<X, ?>) typeInfo; componentType = arrayInfo.getComponentInfo(); } else if (typeInfo instanceof PrimitiveArrayTypeInfo) { PrimitiveArrayTypeInfo<X> arrayType = (PrimitiveArrayTypeInfo<X>) typeInfo; componentType = arrayType.getComponentType(); } else { throw new IllegalArgumentException("This method only supports arrays of primitives and boxed primitives."); } TypeInformation<?>[] primitiveInfos = new TypeInformation<?>[positions.length]; Arrays.fill(primitiveInfos, componentType); return new ArrayKeySelector<>(positions, new TupleTypeInfo<>(primitiveInfos)); }
public static <X> ArrayKeySelector<X> getSelectorForArray(int[] positions, TypeInformation<X> typeInfo) { if (positions == null || positions.length == 0 || positions.length > Tuple.MAX_ARITY) { throw new IllegalArgumentException("Array keys must have between 1 and " + Tuple.MAX_ARITY + " fields."); } TypeInformation<?> componentType; if (typeInfo instanceof BasicArrayTypeInfo) { BasicArrayTypeInfo<X, ?> arrayInfo = (BasicArrayTypeInfo<X, ?>) typeInfo; componentType = arrayInfo.getComponentInfo(); } else if (typeInfo instanceof PrimitiveArrayTypeInfo) { PrimitiveArrayTypeInfo<X> arrayType = (PrimitiveArrayTypeInfo<X>) typeInfo; componentType = arrayType.getComponentType(); } else { throw new IllegalArgumentException("This method only supports arrays of primitives and boxed primitives."); } TypeInformation<?>[] primitiveInfos = new TypeInformation<?>[positions.length]; Arrays.fill(primitiveInfos, componentType); return new ArrayKeySelector<>(positions, new TupleTypeInfo<>(primitiveInfos)); }
return convertObjectArray(node, ((BasicArrayTypeInfo) info).getComponentInfo()); } else if (info instanceof PrimitiveArrayTypeInfo && ((PrimitiveArrayTypeInfo) info).getComponentType() == Types.BYTE) { return convertByteArray(node); } else {
return convertObjectArray(node, ((BasicArrayTypeInfo) info).getComponentInfo()); } else if (info instanceof PrimitiveArrayTypeInfo && ((PrimitiveArrayTypeInfo) info).getComponentType() == Types.BYTE) { return convertByteArray(node); } else {