public static Object convertValue()

in baremaps-calcite/src/main/java/org/apache/baremaps/calcite/geoparquet/GeoParquetTypeConversion.java [154:215]


  public static Object convertValue(Field field, GeoParquetGroup group, int index) {
    // Handle repeated fields
    if (field.cardinality() == Cardinality.REPEATED) {
      // Use if-else instead of switch expression to avoid enum constant issues
      Type type = field.type();
      if (type == Type.BINARY) {
        return group.getBinaryValues(index).stream().map(Binary::getBytes).toList();
      } else if (type == Type.BOOLEAN) {
        return group.getBooleanValues(index);
      } else if (type == Type.INTEGER) {
        return group.getIntegerValues(index);
      } else if (type == Type.INT96 || type == Type.LONG) {
        return group.getLongValues(index);
      } else if (type == Type.FLOAT) {
        return group.getFloatValues(index);
      } else if (type == Type.DOUBLE) {
        return group.getDoubleValues(index);
      } else if (type == Type.STRING) {
        return group.getStringValues(index);
      } else if (type == Type.GEOMETRY) {
        return group.getGeometryValues(index);
      } else if (type == Type.ENVELOPE) {
        List<Envelope> envelopes = group.getEnvelopeValues(index);
        return envelopes.stream()
            .map(envelope -> envelope != null ? GEOMETRY_FACTORY.toGeometry(envelope) : null)
            .collect(Collectors.toList());
      } else if (type == Type.GROUP) {
        return group.getGroupValues(index).stream().map(GeoParquetTypeConversion::asNested)
            .toList();
      } else {
        throw new IllegalArgumentException("Unsupported type: " + type);
      }
    } else {
      // Handle non-repeated fields
      // Use if-else instead of switch expression to avoid enum constant issues
      Type type = field.type();
      if (type == Type.BINARY) {
        return group.getBinaryValue(index).getBytes();
      } else if (type == Type.BOOLEAN) {
        return group.getBooleanValue(index);
      } else if (type == Type.INTEGER) {
        return group.getIntegerValue(index);
      } else if (type == Type.INT96 || type == Type.LONG) {
        return group.getLongValue(index);
      } else if (type == Type.FLOAT) {
        return group.getFloatValue(index);
      } else if (type == Type.DOUBLE) {
        return group.getDoubleValue(index);
      } else if (type == Type.STRING) {
        return group.getStringValue(index);
      } else if (type == Type.GEOMETRY) {
        return group.getGeometryValue(index);
      } else if (type == Type.ENVELOPE) {
        Envelope envelope = group.getEnvelopeValue(index);
        return envelope != null ? GEOMETRY_FACTORY.toGeometry(envelope) : null;
      } else if (type == Type.GROUP) {
        return asNested(group.getGroupValue(index));
      } else {
        throw new IllegalArgumentException("Unsupported type: " + type);
      }
    }
  }