Search in sources :

Example 1 with NullableBitHolder

use of org.apache.arrow.vector.holders.NullableBitHolder in project aws-athena-query-federation by awslabs.

the class VertexRowWriter method writeRowTemplate.

public static void writeRowTemplate(RowWriterBuilder rowWriterBuilder, Field field) {
    ArrowType arrowType = field.getType();
    Types.MinorType minorType = Types.getMinorTypeForArrowType(arrowType);
    switch(minorType) {
        case BIT:
            rowWriterBuilder.withExtractor(field.getName(), (BitExtractor) (Object context, NullableBitHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                ArrayList<Object> objValues = (ArrayList) obj.get(field.getName());
                value.isSet = 0;
                if (objValues != null && objValues.get(0) != null) {
                    Boolean booleanValue = Boolean.parseBoolean(objValues.get(0).toString());
                    value.value = booleanValue ? 1 : 0;
                    value.isSet = 1;
                }
            });
            break;
        case VARCHAR:
            rowWriterBuilder.withExtractor(field.getName(), (VarCharExtractor) (Object context, NullableVarCharHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                String fieldName = field.getName().toLowerCase().trim();
                value.isSet = 0;
                // check for special keys and parse them separately
                if (fieldName.equals(SpecialKeys.ID.toString().toLowerCase())) {
                    Object fieldValue = obj.get(T.id);
                    if (fieldValue != null) {
                        value.value = fieldValue.toString();
                        value.isSet = 1;
                    }
                } else {
                    ArrayList<Object> objValues = (ArrayList) obj.get(field.getName());
                    if (objValues != null && objValues.get(0) != null) {
                        value.value = objValues.get(0).toString();
                        value.isSet = 1;
                    }
                }
            });
            break;
        case INT:
            rowWriterBuilder.withExtractor(field.getName(), (IntExtractor) (Object context, NullableIntHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                value.isSet = 0;
                ArrayList<Object> objValues = (ArrayList) obj.get(field.getName());
                if (objValues != null && objValues.get(0) != null) {
                    value.value = Integer.parseInt(objValues.get(0).toString());
                    value.isSet = 1;
                }
            });
            break;
        case BIGINT:
            rowWriterBuilder.withExtractor(field.getName(), (BigIntExtractor) (Object context, NullableBigIntHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                ArrayList<Object> objValues = (ArrayList) obj.get(field.getName());
                value.isSet = 0;
                if (objValues != null && objValues.get(0) != null) {
                    value.value = Long.parseLong(objValues.get(0).toString());
                    value.isSet = 1;
                }
            });
            break;
        case FLOAT4:
            rowWriterBuilder.withExtractor(field.getName(), (Float4Extractor) (Object context, NullableFloat4Holder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                ArrayList<Object> objValues = (ArrayList) obj.get(field.getName());
                value.isSet = 0;
                if (objValues != null && objValues.get(0) != null) {
                    value.value = Float.parseFloat(objValues.get(0).toString());
                    value.isSet = 1;
                }
            });
            break;
        case FLOAT8:
            rowWriterBuilder.withExtractor(field.getName(), (Float8Extractor) (Object context, NullableFloat8Holder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                ArrayList<Object> objValues = (ArrayList) obj.get(field.getName());
                value.isSet = 0;
                if (objValues != null && objValues.get(0) != null) {
                    value.value = Double.parseDouble(objValues.get(0).toString());
                    value.isSet = 1;
                }
            });
            break;
    }
}
Also used : Types(org.apache.arrow.vector.types.Types) NullableFloat8Holder(org.apache.arrow.vector.holders.NullableFloat8Holder) ArrowType(org.apache.arrow.vector.types.pojo.ArrowType) ArrayList(java.util.ArrayList) NullableBigIntHolder(org.apache.arrow.vector.holders.NullableBigIntHolder) NullableBitHolder(org.apache.arrow.vector.holders.NullableBitHolder) NullableVarCharHolder(com.amazonaws.athena.connector.lambda.data.writers.holders.NullableVarCharHolder) NullableFloat4Holder(org.apache.arrow.vector.holders.NullableFloat4Holder) NullableIntHolder(org.apache.arrow.vector.holders.NullableIntHolder) Map(java.util.Map)

Example 2 with NullableBitHolder

use of org.apache.arrow.vector.holders.NullableBitHolder in project aws-athena-query-federation by awslabs.

the class TimestreamRecordHandler method buildRowWriter.

private GeneratedRowWriter buildRowWriter(ReadRecordsRequest request) {
    GeneratedRowWriter.RowWriterBuilder builder = GeneratedRowWriter.newBuilder(request.getConstraints());
    int fieldNum = 0;
    for (Field nextField : request.getSchema().getFields()) {
        int curFieldNum = fieldNum++;
        switch(Types.getMinorTypeForArrowType(nextField.getType())) {
            case VARCHAR:
                builder.withExtractor(nextField.getName(), (VarCharExtractor) (Object context, NullableVarCharHolder value) -> {
                    value.isSet = 1;
                    value.value = ((Row) context).getData().get(curFieldNum).getScalarValue();
                });
                break;
            case FLOAT8:
                builder.withExtractor(nextField.getName(), (Float8Extractor) (Object context, NullableFloat8Holder value) -> {
                    value.isSet = 1;
                    value.value = Double.valueOf(((Row) context).getData().get(curFieldNum).getScalarValue());
                });
                break;
            case BIT:
                builder.withExtractor(nextField.getName(), (BitExtractor) (Object context, NullableBitHolder value) -> {
                    value.isSet = 1;
                    value.value = Boolean.valueOf(((Row) context).getData().get(curFieldNum).getScalarValue()) == false ? 0 : 1;
                });
                break;
            case BIGINT:
                builder.withExtractor(nextField.getName(), (BigIntExtractor) (Object context, NullableBigIntHolder value) -> {
                    value.isSet = 1;
                    value.value = Long.valueOf(((Row) context).getData().get(curFieldNum).getScalarValue());
                });
                break;
            case DATEMILLI:
                builder.withExtractor(nextField.getName(), (DateMilliExtractor) (Object context, NullableDateMilliHolder value) -> {
                    value.isSet = 1;
                    value.value = TIMESTAMP_FORMATTER.parse(((Row) context).getData().get(curFieldNum).getScalarValue()).getTime();
                });
                break;
            case LIST:
                // TODO: This presently only supports TimeSeries results but it is possible that customers may
                // generate LIST type results for other reasons when using VIEWs. For now this seems like an OK
                // compromise since it enables an important capability of TimeStream even if it doesn't enable arbitrary
                // complex types.
                buildTimeSeriesExtractor(builder, nextField, curFieldNum);
                break;
            default:
                throw new RuntimeException("Unsupported field type[" + nextField.getType() + "] for field[" + nextField.getName() + "]");
        }
    }
    return builder.build();
}
Also used : NullableBitHolder(org.apache.arrow.vector.holders.NullableBitHolder) Field(org.apache.arrow.vector.types.pojo.Field) NullableVarCharHolder(com.amazonaws.athena.connector.lambda.data.writers.holders.NullableVarCharHolder) GeneratedRowWriter(com.amazonaws.athena.connector.lambda.data.writers.GeneratedRowWriter) NullableDateMilliHolder(org.apache.arrow.vector.holders.NullableDateMilliHolder) NullableFloat8Holder(org.apache.arrow.vector.holders.NullableFloat8Holder) Row(com.amazonaws.services.timestreamquery.model.Row) TimeSeriesDataPoint(com.amazonaws.services.timestreamquery.model.TimeSeriesDataPoint) NullableBigIntHolder(org.apache.arrow.vector.holders.NullableBigIntHolder)

Example 3 with NullableBitHolder

use of org.apache.arrow.vector.holders.NullableBitHolder in project aws-athena-query-federation by awslabs.

the class ElasticsearchTypeUtilsTest method testField.

/**
 * Uses the correct field extractor to extract values from a document.
 * @param mapping is the metadata definitions of the document being processed.
 * @param document contains the values to be extracted.
 * @return a map of the field names and their associated values extracted from the document.
 * @throws Exception
 */
private Map<String, Object> testField(Schema mapping, Map<String, Object> document) throws Exception {
    Map<String, Object> results = new HashMap<>();
    for (Field field : mapping.getFields()) {
        Extractor extractor = typeUtils.makeExtractor(field);
        if (extractor instanceof VarCharExtractor) {
            NullableVarCharHolder holder = new NullableVarCharHolder();
            ((VarCharExtractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof BigIntExtractor) {
            NullableBigIntHolder holder = new NullableBigIntHolder();
            ((BigIntExtractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof IntExtractor) {
            NullableIntHolder holder = new NullableIntHolder();
            ((IntExtractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof SmallIntExtractor) {
            NullableSmallIntHolder holder = new NullableSmallIntHolder();
            ((SmallIntExtractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof TinyIntExtractor) {
            NullableTinyIntHolder holder = new NullableTinyIntHolder();
            ((TinyIntExtractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof Float8Extractor) {
            NullableFloat8Holder holder = new NullableFloat8Holder();
            ((Float8Extractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof Float4Extractor) {
            NullableFloat4Holder holder = new NullableFloat4Holder();
            ((Float4Extractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof DateMilliExtractor) {
            NullableDateMilliHolder holder = new NullableDateMilliHolder();
            ((DateMilliExtractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        } else if (extractor instanceof BitExtractor) {
            NullableBitHolder holder = new NullableBitHolder();
            ((BitExtractor) extractor).extract(document, holder);
            assertEquals("Could not extract value for: " + field.getName(), 1, holder.isSet);
            results.put(field.getName(), holder.value);
        }
    }
    return results;
}
Also used : BigIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BigIntExtractor) BigIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BigIntExtractor) TinyIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.TinyIntExtractor) SmallIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.SmallIntExtractor) IntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.IntExtractor) SmallIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.SmallIntExtractor) DateMilliExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.DateMilliExtractor) NullableDateMilliHolder(org.apache.arrow.vector.holders.NullableDateMilliHolder) HashMap(java.util.HashMap) NullableSmallIntHolder(org.apache.arrow.vector.holders.NullableSmallIntHolder) NullableFloat8Holder(org.apache.arrow.vector.holders.NullableFloat8Holder) NullableTinyIntHolder(org.apache.arrow.vector.holders.NullableTinyIntHolder) Float8Extractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.Float8Extractor) NullableBigIntHolder(org.apache.arrow.vector.holders.NullableBigIntHolder) NullableBitHolder(org.apache.arrow.vector.holders.NullableBitHolder) Field(org.apache.arrow.vector.types.pojo.Field) NullableVarCharHolder(com.amazonaws.athena.connector.lambda.data.writers.holders.NullableVarCharHolder) NullableFloat4Holder(org.apache.arrow.vector.holders.NullableFloat4Holder) BitExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BitExtractor) NullableIntHolder(org.apache.arrow.vector.holders.NullableIntHolder) Float4Extractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.Float4Extractor) BigIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BigIntExtractor) TinyIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.TinyIntExtractor) BitExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BitExtractor) Float8Extractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.Float8Extractor) SmallIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.SmallIntExtractor) VarCharExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.VarCharExtractor) IntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.IntExtractor) Float4Extractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.Float4Extractor) DateMilliExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.DateMilliExtractor) Extractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.Extractor) VarCharExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.VarCharExtractor) TinyIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.TinyIntExtractor)

Example 4 with NullableBitHolder

use of org.apache.arrow.vector.holders.NullableBitHolder in project aws-athena-query-federation by awslabs.

the class ExampleRecordHandler method makeExtractor.

/**
 * Creates an Extractor for the given field. In this example the extractor just creates some random data.
 */
private Extractor makeExtractor(Field field, RowContext rowContext) {
    Types.MinorType fieldType = Types.getMinorTypeForArrowType(field.getType());
    // they need to match the split otherwise filtering will brake in unexpected ways.
    if (field.getName().equals("year")) {
        return (IntExtractor) (Object context, NullableIntHolder dst) -> {
            dst.isSet = 1;
            dst.value = rowContext.getYear();
        };
    } else if (field.getName().equals("month")) {
        return (IntExtractor) (Object context, NullableIntHolder dst) -> {
            dst.isSet = 1;
            dst.value = rowContext.getMonth();
        };
    } else if (field.getName().equals("day")) {
        return (IntExtractor) (Object context, NullableIntHolder dst) -> {
            dst.isSet = 1;
            dst.value = rowContext.getDay();
        };
    }
    switch(fieldType) {
        case INT:
            return (IntExtractor) (Object context, NullableIntHolder dst) -> {
                dst.isSet = 1;
                dst.value = ((RowContext) context).seed * (((RowContext) context).negative ? -1 : 1);
            };
        case DATEMILLI:
            return (DateMilliExtractor) (Object context, NullableDateMilliHolder dst) -> {
                dst.isSet = 1;
                dst.value = ((RowContext) context).seed * (((RowContext) context).negative ? -1 : 1);
            };
        case DATEDAY:
            return (DateDayExtractor) (Object context, NullableDateDayHolder dst) -> {
                dst.isSet = 1;
                dst.value = ((RowContext) context).seed * (((RowContext) context).negative ? -1 : 1);
            };
        case TINYINT:
            return (TinyIntExtractor) (Object context, NullableTinyIntHolder dst) -> {
                dst.isSet = 1;
                dst.value = (byte) ((((RowContext) context).seed % 4) * (((RowContext) context).negative ? -1 : 1));
            };
        case SMALLINT:
            return (SmallIntExtractor) (Object context, NullableSmallIntHolder dst) -> {
                dst.isSet = 1;
                dst.value = (short) ((((RowContext) context).seed % 4) * (((RowContext) context).negative ? -1 : 1));
            };
        case FLOAT4:
            return (Float4Extractor) (Object context, NullableFloat4Holder dst) -> {
                dst.isSet = 1;
                dst.value = ((float) ((RowContext) context).seed) * 1.1f * (((RowContext) context).negative ? -1f : 1f);
            };
        case FLOAT8:
            return (Float8Extractor) (Object context, NullableFloat8Holder dst) -> {
                dst.isSet = 1;
                dst.value = ((double) ((RowContext) context).seed) * 1.1D;
            };
        case DECIMAL:
            return (DecimalExtractor) (Object context, NullableDecimalHolder dst) -> {
                dst.isSet = 1;
                double d8Val = ((RowContext) context).seed * 1.1D * (((RowContext) context).negative ? -1d : 1d);
                BigDecimal bdVal = new BigDecimal(d8Val);
                dst.value = bdVal.setScale(((ArrowType.Decimal) field.getType()).getScale(), RoundingMode.HALF_UP);
            };
        case BIT:
            return (BitExtractor) (Object context, NullableBitHolder dst) -> {
                dst.isSet = 1;
                dst.value = ((RowContext) context).seed % 2;
            };
        case BIGINT:
            return (BigIntExtractor) (Object context, NullableBigIntHolder dst) -> {
                dst.isSet = 1;
                dst.value = ((RowContext) context).seed * 1L * (((RowContext) context).negative ? -1 : 1);
            };
        case VARCHAR:
            return (VarCharExtractor) (Object context, NullableVarCharHolder dst) -> {
                dst.isSet = 1;
                dst.value = "VarChar" + ((RowContext) context).seed;
            };
        case VARBINARY:
            return (VarBinaryExtractor) (Object context, NullableVarBinaryHolder dst) -> {
                dst.isSet = 1;
                dst.value = ("VarChar" + ((RowContext) context).seed).getBytes(Charsets.UTF_8);
            };
        default:
            return null;
    }
}
Also used : Types(org.apache.arrow.vector.types.Types) BigIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BigIntExtractor) TinyIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.TinyIntExtractor) IntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.IntExtractor) SmallIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.SmallIntExtractor) SmallIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.SmallIntExtractor) NullableDateMilliHolder(org.apache.arrow.vector.holders.NullableDateMilliHolder) NullableFloat8Holder(org.apache.arrow.vector.holders.NullableFloat8Holder) NullableTinyIntHolder(org.apache.arrow.vector.holders.NullableTinyIntHolder) Float8Extractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.Float8Extractor) DecimalExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.DecimalExtractor) NullableVarBinaryHolder(com.amazonaws.athena.connector.lambda.data.writers.holders.NullableVarBinaryHolder) NullableVarCharHolder(com.amazonaws.athena.connector.lambda.data.writers.holders.NullableVarCharHolder) BigDecimal(java.math.BigDecimal) NullableIntHolder(org.apache.arrow.vector.holders.NullableIntHolder) DateDayExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.DateDayExtractor) Float4Extractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.Float4Extractor) TinyIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.TinyIntExtractor) NullableDateDayHolder(org.apache.arrow.vector.holders.NullableDateDayHolder) BigIntExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BigIntExtractor) DateMilliExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.DateMilliExtractor) NullableSmallIntHolder(org.apache.arrow.vector.holders.NullableSmallIntHolder) NullableDecimalHolder(com.amazonaws.athena.connector.lambda.data.writers.holders.NullableDecimalHolder) BigDecimal(java.math.BigDecimal) NullableBigIntHolder(org.apache.arrow.vector.holders.NullableBigIntHolder) NullableBitHolder(org.apache.arrow.vector.holders.NullableBitHolder) NullableFloat4Holder(org.apache.arrow.vector.holders.NullableFloat4Holder) BitExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.BitExtractor) VarBinaryExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.VarBinaryExtractor) VarCharExtractor(com.amazonaws.athena.connector.lambda.data.writers.extractors.VarCharExtractor)

Example 5 with NullableBitHolder

use of org.apache.arrow.vector.holders.NullableBitHolder in project aws-athena-query-federation by awslabs.

the class EdgeRowWriter method writeRowTemplate.

public static void writeRowTemplate(RowWriterBuilder rowWriterBuilder, Field field) {
    ArrowType arrowType = field.getType();
    Types.MinorType minorType = Types.getMinorTypeForArrowType(arrowType);
    switch(minorType) {
        case BIT:
            rowWriterBuilder.withExtractor(field.getName(), (BitExtractor) (Object context, NullableBitHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                Object fieldValue = obj.get(field.getName());
                value.isSet = 0;
                if (fieldValue != null) {
                    Boolean booleanValue = Boolean.parseBoolean(fieldValue.toString());
                    value.value = booleanValue ? 1 : 0;
                    value.isSet = 1;
                }
            });
            break;
        case VARCHAR:
            rowWriterBuilder.withExtractor(field.getName(), (VarCharExtractor) (Object context, NullableVarCharHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                value.isSet = 0;
                String fieldName = field.getName().toLowerCase().trim();
                // check for special keys and parse them separately
                if (fieldName.equals(SpecialKeys.ID.toString().toLowerCase())) {
                    Object fieldValue = obj.get(T.id);
                    if (fieldValue != null) {
                        value.value = fieldValue.toString();
                        value.isSet = 1;
                    }
                } else if (fieldName.equals(SpecialKeys.IN.toString().toLowerCase())) {
                    Object fieldValue = ((LinkedHashMap) obj.get(Direction.IN)).get(T.id);
                    if (fieldValue != null) {
                        value.value = fieldValue.toString();
                        value.isSet = 1;
                    }
                } else if (fieldName.equals(SpecialKeys.OUT.toString().toLowerCase())) {
                    Object fieldValue = ((LinkedHashMap) obj.get(Direction.OUT)).get(T.id);
                    if (fieldValue != null) {
                        value.value = fieldValue.toString();
                        value.isSet = 1;
                    }
                } else {
                    Object fieldValue = obj.get(field.getName());
                    if (fieldValue != null) {
                        value.value = fieldValue.toString();
                        value.isSet = 1;
                    }
                }
            });
            break;
        case INT:
            rowWriterBuilder.withExtractor(field.getName(), (IntExtractor) (Object context, NullableIntHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                value.isSet = 0;
                Object fieldValue = obj.get(field.getName());
                if (fieldValue != null) {
                    value.value = Integer.parseInt(fieldValue.toString());
                    value.isSet = 1;
                }
            });
            break;
        case BIGINT:
            rowWriterBuilder.withExtractor(field.getName(), (BigIntExtractor) (Object context, NullableBigIntHolder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                value.isSet = 0;
                Object fieldValue = obj.get(field.getName());
                if (fieldValue != null) {
                    value.value = Long.parseLong(fieldValue.toString());
                    value.isSet = 1;
                }
            });
            break;
        case FLOAT4:
            rowWriterBuilder.withExtractor(field.getName(), (Float4Extractor) (Object context, NullableFloat4Holder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                ArrayList<Object> objValues = (ArrayList) obj.get(field.getName());
                value.isSet = 0;
                Object fieldValue = obj.get(field.getName());
                if (fieldValue != null) {
                    value.value = Float.parseFloat(fieldValue.toString());
                    value.isSet = 1;
                }
            });
            break;
        case FLOAT8:
            rowWriterBuilder.withExtractor(field.getName(), (Float8Extractor) (Object context, NullableFloat8Holder value) -> {
                Map<Object, Object> obj = (Map<Object, Object>) context;
                value.isSet = 0;
                Object fieldValue = obj.get(field.getName());
                if (fieldValue != null) {
                    value.value = Double.parseDouble(fieldValue.toString());
                    value.isSet = 1;
                }
            });
            break;
    }
}
Also used : Types(org.apache.arrow.vector.types.Types) NullableFloat8Holder(org.apache.arrow.vector.holders.NullableFloat8Holder) ArrowType(org.apache.arrow.vector.types.pojo.ArrowType) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) NullableBigIntHolder(org.apache.arrow.vector.holders.NullableBigIntHolder) NullableBitHolder(org.apache.arrow.vector.holders.NullableBitHolder) NullableVarCharHolder(com.amazonaws.athena.connector.lambda.data.writers.holders.NullableVarCharHolder) NullableFloat4Holder(org.apache.arrow.vector.holders.NullableFloat4Holder) NullableIntHolder(org.apache.arrow.vector.holders.NullableIntHolder) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

NullableVarCharHolder (com.amazonaws.athena.connector.lambda.data.writers.holders.NullableVarCharHolder)5 NullableBigIntHolder (org.apache.arrow.vector.holders.NullableBigIntHolder)5 NullableBitHolder (org.apache.arrow.vector.holders.NullableBitHolder)5 NullableFloat8Holder (org.apache.arrow.vector.holders.NullableFloat8Holder)5 NullableFloat4Holder (org.apache.arrow.vector.holders.NullableFloat4Holder)4 NullableIntHolder (org.apache.arrow.vector.holders.NullableIntHolder)4 NullableDateMilliHolder (org.apache.arrow.vector.holders.NullableDateMilliHolder)3 Types (org.apache.arrow.vector.types.Types)3 BigIntExtractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.BigIntExtractor)2 BitExtractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.BitExtractor)2 DateMilliExtractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.DateMilliExtractor)2 Float4Extractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.Float4Extractor)2 Float8Extractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.Float8Extractor)2 IntExtractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.IntExtractor)2 SmallIntExtractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.SmallIntExtractor)2 TinyIntExtractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.TinyIntExtractor)2 VarCharExtractor (com.amazonaws.athena.connector.lambda.data.writers.extractors.VarCharExtractor)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 NullableSmallIntHolder (org.apache.arrow.vector.holders.NullableSmallIntHolder)2