@Override public org.apache.avro.Schema getSchema() { return AvroUtils._long(); }
@Override public org.apache.avro.Schema getSchema() { return AvroUtils._long(); }
/** * Checks {@link TalendType#convertFromAvro(Schema)} converts long avro type to "id_Long" di type */ @Test public void testConvertFromAvroLong() { TalendType expectedType = TalendType.LONG; Schema fieldSchema = AvroUtils._long(); assertEquals(expectedType, TalendType.convertFromAvro(fieldSchema)); }
/** * Checks {@link AvroTypeConverter#convertToAvro(String, String)} returns Long avro schema in case TalendType.LONG Talend type * is * passed */ @Test public void testConvertToAvroLong() { Schema expectedSchema = AvroUtils._long(); assertEquals(expectedSchema, AvroTypeConverter.convertToAvro(TalendType.LONG, null)); }
public static Schema getEventSchema() { Schema.Field[] fields = new Schema.Field[10]; Schema.Field field; fields[EventSchemaField.EVENT_IDX] = new Schema.Field("event", AvroUtils._string(), "Type of event", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.PARTITION_IDX] = new Schema.Field("partition", AvroUtils._short(), "Partition number", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.KEY_IDX] = new Schema.Field("key", AvroUtils._string(), "Key", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.CAS_IDX] = new Schema.Field("cas", AvroUtils._long(), "CAS", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.SEQNO_IDX] = new Schema.Field("bySeqno", AvroUtils._long(), "Sequence number", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.REV_SEQNO_IDX] = new Schema.Field("revSeqno", AvroUtils._long(), "Revision sequence number", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.EXPIRATION_IDX] = new Schema.Field("expiration", AvroUtils.wrapAsNullable(AvroUtils._int()), "Expiration", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.FLAGS_IDX] = new Schema.Field("flags", AvroUtils.wrapAsNullable(AvroUtils._int()), "Flags", (Object) null, Schema.Field.Order.ASCENDING); fields[EventSchemaField.LOCK_TIME_IDX] = new Schema.Field("lockTime", AvroUtils.wrapAsNullable(AvroUtils._int()), "Lock time", (Object) null, Schema.Field.Order.ASCENDING); field = new Schema.Field("content", AvroUtils.wrapAsNullable(AvroUtils._bytes()), "Content", (Object) null, Schema.Field.Order.ASCENDING); field.addProp(TALEND_IS_LOCKED, "false"); fields[EventSchemaField.CONTENT_IDX] = field; Schema schema = Schema.createRecord("DcpMessage", "Couchbase DCP message", "com.couchbase", false, Arrays.asList(fields)); schema.addProp(TALEND_IS_LOCKED, "true"); return schema; }
return AvroUtils._int(); case LONG: return AvroUtils._long(); case DOUBLE: return AvroUtils._double();
return AvroUtils._int(); case LONG: return AvroUtils._long(); case DOUBLE: return AvroUtils._double();
/** * Get an Avro schema using {@link AvroUtils#wrapAsNullable(Schema)} by node type. * * @param node Json node. * @return an Avro schema using {@link AvroUtils#wrapAsNullable(Schema)} by node type. */ @VisibleForTesting Schema getAvroSchema(JsonNode node) { if (node instanceof TextNode) { return AvroUtils.wrapAsNullable(AvroUtils._string()); } else if (node instanceof IntNode) { return AvroUtils.wrapAsNullable(AvroUtils._int()); } else if (node instanceof LongNode) { return AvroUtils.wrapAsNullable(AvroUtils._long()); } else if (node instanceof DoubleNode) { return AvroUtils.wrapAsNullable(AvroUtils._double()); } else if (node instanceof BooleanNode) { return AvroUtils.wrapAsNullable(AvroUtils._boolean()); } else if (node instanceof NullNode) { return AvroUtils.wrapAsNullable(AvroUtils._string()); } else { return createSubRecord(node); } }
case SUM: if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._int()) || AvroUtils.isSameType(inputFieldSchema, AvroUtils._long())) { return new SumLongAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._float()) if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._int())) { return new MinIntegerAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._long())) { return new MinLongAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._float())) { if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._int())) { return new MaxIntegerAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._long())) { return new MaxLongAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._float())) {
case SUM: if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._int()) || AvroUtils.isSameType(inputFieldSchema, AvroUtils._long())) { return new SumLongAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._float()) if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._int())) { return new MinIntegerAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._long())) { return new MinLongAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._float())) { if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._int())) { return new MaxIntegerAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._long())) { return new MaxLongAccumulatorFn(); } else if (AvroUtils.isSameType(inputFieldSchema, AvroUtils._float())) {
} else if (AvroUtils.isSameType(fieldSchema, AvroUtils._short())) { return new StringToShortConverter(f); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._long())) { return new StringToLongConverter(f); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._date())) {
} else if (AvroUtils.isSameType(fieldSchema, AvroUtils._short())) { return new StringToShortConverter(f); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._long())) { return new StringToLongConverter(f); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._date())) {
public AvroConverter<String, ?> getConverter(Schema.Field f, FileDelimitedProperties properties) { Schema fieldSchema = AvroUtils.unwrapIfNullable(f.schema()); if (AvroUtils.isSameType(fieldSchema, AvroUtils._boolean())) { return new BooleanConverter(f); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._decimal())) { return new DecimalConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._double())) { return new DoubleConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._float())) { return new FloatConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._int())) { return new IntegerConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._date())) { return new DateConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._long())) { return new LongConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._bytes())) { return new BytesConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._byte())) { return new ByteConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._short())) { return new ShortConverter(f, properties); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._character())) { return new CharacterConverter(f); } else if (AvroUtils.isSameType(fieldSchema, AvroUtils._string())) { return super.getConverter(String.class); } throw new UnsupportedOperationException("The type " + fieldSchema.getType() + " is not supported."); //$NON-NLS-1$ //$NON-NLS-2$ }
} else if (AvroUtils.isSameType(basicSchema, AvroUtils._decimal())) { return Types.DECIMAL; } else if (AvroUtils.isSameType(basicSchema, AvroUtils._long())) { return Types.BIGINT; } else if (AvroUtils.isSameType(basicSchema, AvroUtils._double())) {
} else if (AvroUtils.isSameType(basicSchema, AvroUtils._decimal())) { return Types.DECIMAL; } else if (AvroUtils.isSameType(basicSchema, AvroUtils._long())) { return Types.BIGINT; } else if (AvroUtils.isSameType(basicSchema, AvroUtils._double())) {
} else if (AvroUtils.isSameType(basicSchema, AvroUtils._decimal())) { writer = new BigDecimalTypeWriter(statement, statementIndex, inputValueLocation); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._long())) { writer = new LongTypeWriter(statement, statementIndex, inputValueLocation); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._double())) {
public static DTEConverter createConverter(final Field f, final String mappedName) { Schema basicSchema = AvroUtils.unwrapIfNullable(f.schema()); AzureStorageDTEConverters converters = new AzureStorageDTEConverters(); DTEConverter dteConverter; if (AvroUtils.isSameType(basicSchema, AvroUtils._string()) || AvroUtils.isSameType(basicSchema, AvroUtils._character())) { dteConverter = converters.new StringDTEConverter(f, mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._int()) || AvroUtils.isSameType(basicSchema, AvroUtils._short()) || AvroUtils.isSameType(basicSchema, AvroUtils._byte())) { dteConverter = converters.new IntegerDTEConverter(mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._date())) { dteConverter = converters.new DateDTEConverter(f, mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._decimal()) || AvroUtils.isSameType(basicSchema, AvroUtils._double()) || AvroUtils.isSameType(basicSchema, AvroUtils._float())) { dteConverter = converters.new DoubleDTEConverter(mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._long())) { dteConverter = converters.new LongDTEConverter(f, mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._boolean())) { dteConverter = converters.new BooleanDTEConverter(mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._bytes())) { dteConverter = converters.new ByteArrayDTEConverter(mappedName); } else { dteConverter = converters.new StringDTEConverter(f, mappedName); } return dteConverter; }
public static DTEConverter createConverter(final Field f, final String mappedName) { Schema basicSchema = AvroUtils.unwrapIfNullable(f.schema()); AzureStorageDTEConverters converters = new AzureStorageDTEConverters(); DTEConverter dteConverter; if (AvroUtils.isSameType(basicSchema, AvroUtils._string()) || AvroUtils.isSameType(basicSchema, AvroUtils._character())) { dteConverter = converters.new StringDTEConverter(f, mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._int()) || AvroUtils.isSameType(basicSchema, AvroUtils._short()) || AvroUtils.isSameType(basicSchema, AvroUtils._byte())) { dteConverter = converters.new IntegerDTEConverter(mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._date())) { dteConverter = converters.new DateDTEConverter(f, mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._decimal()) || AvroUtils.isSameType(basicSchema, AvroUtils._double()) || AvroUtils.isSameType(basicSchema, AvroUtils._float())) { dteConverter = converters.new DoubleDTEConverter(mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._long())) { dteConverter = converters.new LongDTEConverter(f, mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._boolean())) { dteConverter = converters.new BooleanDTEConverter(mappedName); } else if (AvroUtils.isSameType(basicSchema, AvroUtils._bytes())) { dteConverter = converters.new ByteArrayDTEConverter(mappedName); } else { dteConverter = converters.new StringDTEConverter(f, mappedName); } return dteConverter; }