@DefaultCoder(AvroCoder.class) static class Singer { long singerId; String firstName; String lastName; Singer() {} Singer(long singerId, String firstName, String lastName) { this.singerId = singerId; this.firstName = firstName; this.lastName = lastName; } }
@DefaultCoder(AvroCoder.class) static class Album { long singerId; long albumId; String albumTitle; Album() {} Album(long singerId, long albumId, String albumTitle) { this.singerId = singerId; this.albumId = albumId; this.albumTitle = albumTitle; } }
@DefaultCoder(AvroCoder.class) static class Singer { long singerId; String firstName; String lastName; Singer() { } Singer(long singerId, String firstName, String lastName) { this.singerId = singerId; this.firstName = firstName; this.lastName = lastName; } }
@DefaultCoder(AvroCoder.class) static class Album { long singerId; long albumId; String albumTitle; Album() { } Album(long singerId, long albumId, String albumTitle) { this.singerId = singerId; this.albumId = albumId; this.albumTitle = albumTitle; } }
@DefaultCoder(AvroCoder.class) static class Quote { final String source; final String quote; public Quote() { this.source = ""; this.quote = ""; } public Quote(String source, String quote) { this.source = source; this.quote = quote; } }
@DefaultCoder(AvroCoder.class) static class WeatherData { final long year; final long month; final long day; final double maxTemp; public WeatherData() { this.year = 0; this.month = 0; this.day = 0; this.maxTemp = 0.0f; } public WeatherData(long year, long month, long day, double maxTemp) { this.year = year; this.month = month; this.day = day; this.maxTemp = maxTemp; } }
@Builder @Data @DefaultCoder(value = AvroCoder.class) public static class RedisMutation { private final Method method; private final byte[] key; private final byte[] value; private final long expiryMillis; private final long score; // Score is only utilized when method is ZSET }
@DefaultCoder(SerializableCoder.class) private static class SerializableRecord extends SerializableBase {}
@DefaultCoder(SerializableCoder.class) private static class MySerializableGeneric<T extends Serializable> implements Serializable { @SuppressWarnings("unused") private T foo; }
@DefaultCoder(AvroCoder.class) private static class MyValueA implements Serializable {}
@DefaultCoder(AvroCoder.class) private static class AvroRecord {}
@DefaultCoder(CustomSerializableCoder.class) private static class CustomRecord extends SerializableBase {}
@DefaultCoder(OldCustomSerializableCoder.class) private static class OldCustomRecord extends SerializableBase {}
@DefaultCoder(AvroCoder.class) private static class UserWriteType { String destination; String metadata; UserWriteType() { this.destination = ""; this.metadata = ""; } UserWriteType(String destination, String metadata) { this.destination = destination; this.metadata = metadata; } @Override public String toString() { return String.format("destination: %s metadata : %s", destination, metadata); } }
@DefaultCoder(SerializableCoder.class) static class MyRecord implements Serializable { private static final long serialVersionUID = 42L; public String value; public MyRecord(String value) { this.value = value; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } MyRecord myRecord = (MyRecord) o; return value.equals(myRecord.value); } @Override public int hashCode() { return value.hashCode(); } }
@DefaultCoder(AvroCoder.class) static class GenericClass { int intField; String stringField; public GenericClass() {} public GenericClass(int intField, String stringField) { this.intField = intField; this.stringField = stringField; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("intField", intField) .add("stringField", stringField) .toString(); } @Override public int hashCode() { return Objects.hash(intField, stringField); } @Override public boolean equals(Object other) { if (other == null || !(other instanceof GenericClass)) { return false; } GenericClass o = (GenericClass) other; return Objects.equals(intField, o.intField) && Objects.equals(stringField, o.stringField); } }
@DefaultCoder(AvroCoder.class) static class VisitOrImpression { @Nullable private Visit visit; @Nullable private Impression impression; @SuppressWarnings("unused") public VisitOrImpression() { } public VisitOrImpression(Visit visit, Impression impression) { this.visit = visit; this.impression = impression; } public Visit visit() { return visit; } public Impression impression() { return impression; } }
/** This class holds information about a route's speed/slowdown. */ @DefaultCoder(AvroCoder.class) static class RouteInfo { @Nullable String route; @Nullable Double avgSpeed; @Nullable Boolean slowdownEvent; public RouteInfo() {} public RouteInfo(String route, Double avgSpeed, Boolean slowdownEvent) { this.route = route; this.avgSpeed = avgSpeed; this.slowdownEvent = slowdownEvent; } public String getRoute() { return this.route; } public Double getAvgSpeed() { return this.avgSpeed; } public Boolean getSlowdownEvent() { return this.slowdownEvent; } }
@DefaultCoder(AvroCoder.class) static class Impression { @Nullable private Long id; @Nullable private String sourceUrl; @Nullable private String targetUrl; @Nullable private Instant timestamp; public static String sourceAndTarget(String source, String target) { return source + ":" + target; } @SuppressWarnings("unused") public Impression() { } public Impression(Long id, String sourceUrl, String targetUrl, Instant timestamp) { this.id = id; this.sourceUrl = sourceUrl; this.targetUrl = targetUrl; this.timestamp = timestamp; } public Long id() { return id; } public String sourceUrl() { return sourceUrl; } public String targetUrl() { return targetUrl; } public String sourceAndTarget() { return sourceAndTarget(sourceUrl, targetUrl); } public Instant timestamp() { return timestamp; } @Override public String toString() { return String.format("{ %s source:%s target:%s %s }", id, sourceUrl, targetUrl, timestamp); } }
/** Pojo class used as the record type in tests. */ @DefaultCoder(AvroCoder.class) @SuppressWarnings("unused") // Used by Avro reflection. static class Bird { long number; @Nullable String species; @Nullable Double quality; @Nullable Long quantity; @Nullable Long birthday; // Exercises TIMESTAMP. @Nullable ByteBuffer birthdayMoney; // Exercises NUMERIC. @Nullable Boolean flighted; @Nullable ByteBuffer sound; @Nullable Utf8 anniversaryDate; @Nullable String anniversaryDatetime; @Nullable Utf8 anniversaryTime; @Nullable SubBird scion; SubBird[] associates; static class SubBird { @Nullable String species; public SubBird() {} } public Bird() { associates = new SubBird[1]; associates[0] = new SubBird(); } } }