diff --git a/theodolite-benchmarks/commons/build.gradle b/theodolite-benchmarks/commons/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..2eabcaf6a25bfc00a2c1ee02001dbb799af45945 --- /dev/null +++ b/theodolite-benchmarks/commons/build.gradle @@ -0,0 +1,80 @@ +plugins { + // common java conventions + id 'theodolite.java-conventions' + + // avro plugin + id "com.github.davidmc24.gradle.plugin.avro-base" version "1.3.0" +} + + + +repositories { + mavenCentral() + maven { + url "https://oss.sonatype.org/content/repositories/snapshots/" + } + maven { + url 'https://packages.confluent.io/maven/' + } +} + +dependencies { + // These dependencies is exported to consumers, that is to say found on their compile classpath. + implementation 'org.apache.kafka:kafka-clients:2.4.0' + implementation 'org.apache.commons:commons-configuration2:2.0' + + implementation "org.apache.avro:avro:1.11.0" + + // These dependencies are used internally, and not exposed to consumers on their own compile classpath. + implementation 'commons-beanutils:commons-beanutils:1.9.2' // necessary for commons-configuration2 + implementation 'com.google.code.gson:gson:2.8.2' + implementation 'com.google.guava:guava:24.1-jre' + implementation 'org.slf4j:slf4j-api:1.7.25' + + // Use JUnit test framework + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' + testImplementation 'com.github.stefanbirkner:system-rules:1.17.0' +} + + +// Local sources +sourceSets { + main { + java { + srcDir 'src/main/java' + srcDir 'src-gen/main/java' + } + } +} + + +//// Local avro creation +avro { + fieldVisibility = "PRIVATE" + createSetters = false +} + +task("generateAvroProtocol", type: com.github.davidmc24.gradle.plugin.avro.GenerateAvroProtocolTask) { + group 'Generate Sources' + source file("src/main/avro") + include("**/*.avdl") + outputDir = file("build/generated-avro-main-avpr") +} + +task("generateAvroSchema", type: com.github.davidmc24.gradle.plugin.avro.GenerateAvroSchemaTask) { + group 'Generate Sources' + dependsOn generateAvroProtocol + source file("src/main/avro") + source file("build/generated-avro-main-avpr") + include("**/*.avpr") + outputDir = file("src-gen/main/avro") +} + +task ("generateAvroJava", type: com.github.davidmc24.gradle.plugin.avro.GenerateAvroJavaTask) { + group 'Generate Sources' + dependsOn generateAvroSchema + source file("src-gen/main/avro") + outputDir = file("src-gen/main/java") +} + + diff --git a/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/ActivePowerRecord.avsc b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/ActivePowerRecord.avsc new file mode 100644 index 0000000000000000000000000000000000000000..d3b397f9816f21531150094fa610db8973c9ed23 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/ActivePowerRecord.avsc @@ -0,0 +1,18 @@ +{ + "type" : "record", + "name" : "ActivePowerRecord", + "namespace" : "theodolite.commons.model.records", + "fields" : [ { + "name" : "identifier", + "type" : "string", + "doc" : "*" + }, { + "name" : "timestamp", + "type" : "long", + "doc" : "*" + }, { + "name" : "valueInW", + "type" : "double", + "doc" : "*" + } ] +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/AggregatedActivePowerRecord.avsc b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/AggregatedActivePowerRecord.avsc new file mode 100644 index 0000000000000000000000000000000000000000..29475110421c9db4271aebe1c566790e77227ca0 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/AggregatedActivePowerRecord.avsc @@ -0,0 +1,26 @@ +{ + "type" : "record", + "name" : "AggregatedActivePowerRecord", + "namespace" : "theodolite.commons.model.records", + "fields" : [ { + "name" : "identifier", + "type" : "string", + "doc" : "*" + }, { + "name" : "timestamp", + "type" : "long", + "doc" : "*" + }, { + "name" : "count", + "type" : "long", + "doc" : "*" + }, { + "name" : "sumInW", + "type" : "double", + "doc" : "*" + }, { + "name" : "averageInW", + "type" : "double", + "doc" : "*" + } ] +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/DayOfWeekActivePowerRecord.avsc b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/DayOfWeekActivePowerRecord.avsc new file mode 100644 index 0000000000000000000000000000000000000000..4f1c43cdaec54c97388728bbbbfdfc8317265bd8 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/DayOfWeekActivePowerRecord.avsc @@ -0,0 +1,33 @@ +{ + "type" : "record", + "name" : "DayOfWeekActivePowerRecord", + "namespace" : "theodolite.commons.model.records", + "fields" : [ { + "name" : "identifier", + "type" : "string" + }, { + "name" : "dayOfWeek", + "type" : "int" + }, { + "name" : "periodStart", + "type" : "long" + }, { + "name" : "periodEnd", + "type" : "long" + }, { + "name" : "count", + "type" : "long" + }, { + "name" : "mean", + "type" : "double" + }, { + "name" : "populationVariance", + "type" : "double" + }, { + "name" : "min", + "type" : "double" + }, { + "name" : "max", + "type" : "double" + } ] +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/HourOfDayActivePowerRecord.avsc b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/HourOfDayActivePowerRecord.avsc new file mode 100644 index 0000000000000000000000000000000000000000..29cce1306b98ba1480ddba014328a6936fb14edf --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/HourOfDayActivePowerRecord.avsc @@ -0,0 +1,33 @@ +{ + "type" : "record", + "name" : "HourOfDayActivePowerRecord", + "namespace" : "theodolite.commons.model.records", + "fields" : [ { + "name" : "identifier", + "type" : "string" + }, { + "name" : "hourOfDay", + "type" : "int" + }, { + "name" : "periodStart", + "type" : "long" + }, { + "name" : "periodEnd", + "type" : "long" + }, { + "name" : "count", + "type" : "long" + }, { + "name" : "mean", + "type" : "double" + }, { + "name" : "populationVariance", + "type" : "double" + }, { + "name" : "min", + "type" : "double" + }, { + "name" : "max", + "type" : "double" + } ] +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/HourOfWeekActivePowerRecord.avsc b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/HourOfWeekActivePowerRecord.avsc new file mode 100644 index 0000000000000000000000000000000000000000..451ddd82138946f5e752c23866780339868e0dd6 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/HourOfWeekActivePowerRecord.avsc @@ -0,0 +1,36 @@ +{ + "type" : "record", + "name" : "HourOfWeekActivePowerRecord", + "namespace" : "theodolite.commons.model.records", + "fields" : [ { + "name" : "identifier", + "type" : "string" + }, { + "name" : "dayOfWeek", + "type" : "int" + }, { + "name" : "hourOfDay", + "type" : "int" + }, { + "name" : "periodStart", + "type" : "long" + }, { + "name" : "periodEnd", + "type" : "long" + }, { + "name" : "count", + "type" : "long" + }, { + "name" : "mean", + "type" : "double" + }, { + "name" : "populationVariance", + "type" : "double" + }, { + "name" : "min", + "type" : "double" + }, { + "name" : "max", + "type" : "double" + } ] +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/MonthOfYearActivePowerRecord.avsc b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/MonthOfYearActivePowerRecord.avsc new file mode 100644 index 0000000000000000000000000000000000000000..9078ab64fcb00188834d675b81de2e4de5c08c21 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/MonthOfYearActivePowerRecord.avsc @@ -0,0 +1,33 @@ +{ + "type" : "record", + "name" : "MonthOfYearActivePowerRecord", + "namespace" : "theodolite.commons.model.records", + "fields" : [ { + "name" : "identifier", + "type" : "string" + }, { + "name" : "monthOfYear", + "type" : "int" + }, { + "name" : "periodStart", + "type" : "long" + }, { + "name" : "periodEnd", + "type" : "long" + }, { + "name" : "count", + "type" : "long" + }, { + "name" : "mean", + "type" : "double" + }, { + "name" : "populationVariance", + "type" : "double" + }, { + "name" : "min", + "type" : "double" + }, { + "name" : "max", + "type" : "double" + } ] +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/YearActivePowerRecord.avsc b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/YearActivePowerRecord.avsc new file mode 100644 index 0000000000000000000000000000000000000000..e3da3cdcf9e59a4debca6f417f1a41fadb796374 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/avro/theodolite/commons/model/records/YearActivePowerRecord.avsc @@ -0,0 +1,33 @@ +{ + "type" : "record", + "name" : "YearActivePowerRecord", + "namespace" : "theodolite.commons.model.records", + "fields" : [ { + "name" : "identifier", + "type" : "string" + }, { + "name" : "year", + "type" : "int" + }, { + "name" : "periodStart", + "type" : "long" + }, { + "name" : "periodEnd", + "type" : "long" + }, { + "name" : "count", + "type" : "long" + }, { + "name" : "mean", + "type" : "double" + }, { + "name" : "populationVariance", + "type" : "double" + }, { + "name" : "min", + "type" : "double" + }, { + "name" : "max", + "type" : "double" + } ] +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/ActivePowerRecord.java b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/ActivePowerRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..817e7df17b15aa93bf8b3f7c4bafb68fb932a15b --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/ActivePowerRecord.java @@ -0,0 +1,468 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package theodolite.commons.model.records; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class ActivePowerRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -4772359879403751266L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"ActivePowerRecord\",\"namespace\":\"theodolite.commons.model.records\",\"fields\":[{\"name\":\"identifier\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"*\"},{\"name\":\"timestamp\",\"type\":\"long\",\"doc\":\"*\"},{\"name\":\"valueInW\",\"type\":\"double\",\"doc\":\"*\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder<ActivePowerRecord> ENCODER = + new BinaryMessageEncoder<ActivePowerRecord>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder<ActivePowerRecord> DECODER = + new BinaryMessageDecoder<ActivePowerRecord>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder<ActivePowerRecord> getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder<ActivePowerRecord> getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder<ActivePowerRecord> createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<ActivePowerRecord>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this ActivePowerRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a ActivePowerRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a ActivePowerRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static ActivePowerRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + /** * */ + private java.lang.String identifier; + /** * */ + private long timestamp; + /** * */ + private double valueInW; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use <code>newBuilder()</code>. + */ + public ActivePowerRecord() {} + + /** + * All-args constructor. + * @param identifier * + * @param timestamp * + * @param valueInW * + */ + public ActivePowerRecord(java.lang.String identifier, java.lang.Long timestamp, java.lang.Double valueInW) { + this.identifier = identifier; + this.timestamp = timestamp; + this.valueInW = valueInW; + } + + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + // Used by DatumWriter. Applications should not call. + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return identifier; + case 1: return timestamp; + case 2: return valueInW; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: identifier = value$ != null ? value$.toString() : null; break; + case 1: timestamp = (java.lang.Long)value$; break; + case 2: valueInW = (java.lang.Double)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'identifier' field. + * @return * + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + + /** + * Gets the value of the 'timestamp' field. + * @return * + */ + public long getTimestamp() { + return timestamp; + } + + + + /** + * Gets the value of the 'valueInW' field. + * @return * + */ + public double getValueInW() { + return valueInW; + } + + + + /** + * Creates a new ActivePowerRecord RecordBuilder. + * @return A new ActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.ActivePowerRecord.Builder newBuilder() { + return new theodolite.commons.model.records.ActivePowerRecord.Builder(); + } + + /** + * Creates a new ActivePowerRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new ActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.ActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.ActivePowerRecord.Builder other) { + if (other == null) { + return new theodolite.commons.model.records.ActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.ActivePowerRecord.Builder(other); + } + } + + /** + * Creates a new ActivePowerRecord RecordBuilder by copying an existing ActivePowerRecord instance. + * @param other The existing instance to copy. + * @return A new ActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.ActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.ActivePowerRecord other) { + if (other == null) { + return new theodolite.commons.model.records.ActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.ActivePowerRecord.Builder(other); + } + } + + /** + * RecordBuilder for ActivePowerRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<ActivePowerRecord> + implements org.apache.avro.data.RecordBuilder<ActivePowerRecord> { + + /** * */ + private java.lang.String identifier; + /** * */ + private long timestamp; + /** * */ + private double valueInW; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(theodolite.commons.model.records.ActivePowerRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.timestamp)) { + this.timestamp = data().deepCopy(fields()[1].schema(), other.timestamp); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.valueInW)) { + this.valueInW = data().deepCopy(fields()[2].schema(), other.valueInW); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + } + + /** + * Creates a Builder by copying an existing ActivePowerRecord instance + * @param other The existing instance to copy. + */ + private Builder(theodolite.commons.model.records.ActivePowerRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.timestamp)) { + this.timestamp = data().deepCopy(fields()[1].schema(), other.timestamp); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.valueInW)) { + this.valueInW = data().deepCopy(fields()[2].schema(), other.valueInW); + fieldSetFlags()[2] = true; + } + } + + /** + * Gets the value of the 'identifier' field. + * * + * @return The value. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + /** + * Sets the value of the 'identifier' field. + * * + * @param value The value of 'identifier'. + * @return This builder. + */ + public theodolite.commons.model.records.ActivePowerRecord.Builder setIdentifier(java.lang.String value) { + validate(fields()[0], value); + this.identifier = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'identifier' field has been set. + * * + * @return True if the 'identifier' field has been set, false otherwise. + */ + public boolean hasIdentifier() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'identifier' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.ActivePowerRecord.Builder clearIdentifier() { + identifier = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'timestamp' field. + * * + * @return The value. + */ + public long getTimestamp() { + return timestamp; + } + + + /** + * Sets the value of the 'timestamp' field. + * * + * @param value The value of 'timestamp'. + * @return This builder. + */ + public theodolite.commons.model.records.ActivePowerRecord.Builder setTimestamp(long value) { + validate(fields()[1], value); + this.timestamp = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'timestamp' field has been set. + * * + * @return True if the 'timestamp' field has been set, false otherwise. + */ + public boolean hasTimestamp() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'timestamp' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.ActivePowerRecord.Builder clearTimestamp() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'valueInW' field. + * * + * @return The value. + */ + public double getValueInW() { + return valueInW; + } + + + /** + * Sets the value of the 'valueInW' field. + * * + * @param value The value of 'valueInW'. + * @return This builder. + */ + public theodolite.commons.model.records.ActivePowerRecord.Builder setValueInW(double value) { + validate(fields()[2], value); + this.valueInW = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'valueInW' field has been set. + * * + * @return True if the 'valueInW' field has been set, false otherwise. + */ + public boolean hasValueInW() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'valueInW' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.ActivePowerRecord.Builder clearValueInW() { + fieldSetFlags()[2] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public ActivePowerRecord build() { + try { + ActivePowerRecord record = new ActivePowerRecord(); + record.identifier = fieldSetFlags()[0] ? this.identifier : (java.lang.String) defaultValue(fields()[0]); + record.timestamp = fieldSetFlags()[1] ? this.timestamp : (java.lang.Long) defaultValue(fields()[1]); + record.valueInW = fieldSetFlags()[2] ? this.valueInW : (java.lang.Double) defaultValue(fields()[2]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter<ActivePowerRecord> + WRITER$ = (org.apache.avro.io.DatumWriter<ActivePowerRecord>)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader<ActivePowerRecord> + READER$ = (org.apache.avro.io.DatumReader<ActivePowerRecord>)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.identifier); + + out.writeLong(this.timestamp); + + out.writeDouble(this.valueInW); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.identifier = in.readString(); + + this.timestamp = in.readLong(); + + this.valueInW = in.readDouble(); + + } else { + for (int i = 0; i < 3; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.identifier = in.readString(); + break; + + case 1: + this.timestamp = in.readLong(); + break; + + case 2: + this.valueInW = in.readDouble(); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/AggregatedActivePowerRecord.java b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/AggregatedActivePowerRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..73800ddc24be47cb51156a2120de0a71c7decdd1 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/AggregatedActivePowerRecord.java @@ -0,0 +1,624 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package theodolite.commons.model.records; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class AggregatedActivePowerRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 1730295472331295596L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"AggregatedActivePowerRecord\",\"namespace\":\"theodolite.commons.model.records\",\"fields\":[{\"name\":\"identifier\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"*\"},{\"name\":\"timestamp\",\"type\":\"long\",\"doc\":\"*\"},{\"name\":\"count\",\"type\":\"long\",\"doc\":\"*\"},{\"name\":\"sumInW\",\"type\":\"double\",\"doc\":\"*\"},{\"name\":\"averageInW\",\"type\":\"double\",\"doc\":\"*\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder<AggregatedActivePowerRecord> ENCODER = + new BinaryMessageEncoder<AggregatedActivePowerRecord>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder<AggregatedActivePowerRecord> DECODER = + new BinaryMessageDecoder<AggregatedActivePowerRecord>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder<AggregatedActivePowerRecord> getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder<AggregatedActivePowerRecord> getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder<AggregatedActivePowerRecord> createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<AggregatedActivePowerRecord>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this AggregatedActivePowerRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a AggregatedActivePowerRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a AggregatedActivePowerRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static AggregatedActivePowerRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + /** * */ + private java.lang.String identifier; + /** * */ + private long timestamp; + /** * */ + private long count; + /** * */ + private double sumInW; + /** * */ + private double averageInW; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use <code>newBuilder()</code>. + */ + public AggregatedActivePowerRecord() {} + + /** + * All-args constructor. + * @param identifier * + * @param timestamp * + * @param count * + * @param sumInW * + * @param averageInW * + */ + public AggregatedActivePowerRecord(java.lang.String identifier, java.lang.Long timestamp, java.lang.Long count, java.lang.Double sumInW, java.lang.Double averageInW) { + this.identifier = identifier; + this.timestamp = timestamp; + this.count = count; + this.sumInW = sumInW; + this.averageInW = averageInW; + } + + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + // Used by DatumWriter. Applications should not call. + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return identifier; + case 1: return timestamp; + case 2: return count; + case 3: return sumInW; + case 4: return averageInW; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: identifier = value$ != null ? value$.toString() : null; break; + case 1: timestamp = (java.lang.Long)value$; break; + case 2: count = (java.lang.Long)value$; break; + case 3: sumInW = (java.lang.Double)value$; break; + case 4: averageInW = (java.lang.Double)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'identifier' field. + * @return * + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + + /** + * Gets the value of the 'timestamp' field. + * @return * + */ + public long getTimestamp() { + return timestamp; + } + + + + /** + * Gets the value of the 'count' field. + * @return * + */ + public long getCount() { + return count; + } + + + + /** + * Gets the value of the 'sumInW' field. + * @return * + */ + public double getSumInW() { + return sumInW; + } + + + + /** + * Gets the value of the 'averageInW' field. + * @return * + */ + public double getAverageInW() { + return averageInW; + } + + + + /** + * Creates a new AggregatedActivePowerRecord RecordBuilder. + * @return A new AggregatedActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.AggregatedActivePowerRecord.Builder newBuilder() { + return new theodolite.commons.model.records.AggregatedActivePowerRecord.Builder(); + } + + /** + * Creates a new AggregatedActivePowerRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new AggregatedActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.AggregatedActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.AggregatedActivePowerRecord.Builder other) { + if (other == null) { + return new theodolite.commons.model.records.AggregatedActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.AggregatedActivePowerRecord.Builder(other); + } + } + + /** + * Creates a new AggregatedActivePowerRecord RecordBuilder by copying an existing AggregatedActivePowerRecord instance. + * @param other The existing instance to copy. + * @return A new AggregatedActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.AggregatedActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.AggregatedActivePowerRecord other) { + if (other == null) { + return new theodolite.commons.model.records.AggregatedActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.AggregatedActivePowerRecord.Builder(other); + } + } + + /** + * RecordBuilder for AggregatedActivePowerRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<AggregatedActivePowerRecord> + implements org.apache.avro.data.RecordBuilder<AggregatedActivePowerRecord> { + + /** * */ + private java.lang.String identifier; + /** * */ + private long timestamp; + /** * */ + private long count; + /** * */ + private double sumInW; + /** * */ + private double averageInW; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(theodolite.commons.model.records.AggregatedActivePowerRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.timestamp)) { + this.timestamp = data().deepCopy(fields()[1].schema(), other.timestamp); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.count)) { + this.count = data().deepCopy(fields()[2].schema(), other.count); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.sumInW)) { + this.sumInW = data().deepCopy(fields()[3].schema(), other.sumInW); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.averageInW)) { + this.averageInW = data().deepCopy(fields()[4].schema(), other.averageInW); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + } + + /** + * Creates a Builder by copying an existing AggregatedActivePowerRecord instance + * @param other The existing instance to copy. + */ + private Builder(theodolite.commons.model.records.AggregatedActivePowerRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.timestamp)) { + this.timestamp = data().deepCopy(fields()[1].schema(), other.timestamp); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.count)) { + this.count = data().deepCopy(fields()[2].schema(), other.count); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.sumInW)) { + this.sumInW = data().deepCopy(fields()[3].schema(), other.sumInW); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.averageInW)) { + this.averageInW = data().deepCopy(fields()[4].schema(), other.averageInW); + fieldSetFlags()[4] = true; + } + } + + /** + * Gets the value of the 'identifier' field. + * * + * @return The value. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + /** + * Sets the value of the 'identifier' field. + * * + * @param value The value of 'identifier'. + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder setIdentifier(java.lang.String value) { + validate(fields()[0], value); + this.identifier = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'identifier' field has been set. + * * + * @return True if the 'identifier' field has been set, false otherwise. + */ + public boolean hasIdentifier() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'identifier' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder clearIdentifier() { + identifier = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'timestamp' field. + * * + * @return The value. + */ + public long getTimestamp() { + return timestamp; + } + + + /** + * Sets the value of the 'timestamp' field. + * * + * @param value The value of 'timestamp'. + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder setTimestamp(long value) { + validate(fields()[1], value); + this.timestamp = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'timestamp' field has been set. + * * + * @return True if the 'timestamp' field has been set, false otherwise. + */ + public boolean hasTimestamp() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'timestamp' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder clearTimestamp() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'count' field. + * * + * @return The value. + */ + public long getCount() { + return count; + } + + + /** + * Sets the value of the 'count' field. + * * + * @param value The value of 'count'. + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder setCount(long value) { + validate(fields()[2], value); + this.count = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'count' field has been set. + * * + * @return True if the 'count' field has been set, false otherwise. + */ + public boolean hasCount() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'count' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder clearCount() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'sumInW' field. + * * + * @return The value. + */ + public double getSumInW() { + return sumInW; + } + + + /** + * Sets the value of the 'sumInW' field. + * * + * @param value The value of 'sumInW'. + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder setSumInW(double value) { + validate(fields()[3], value); + this.sumInW = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'sumInW' field has been set. + * * + * @return True if the 'sumInW' field has been set, false otherwise. + */ + public boolean hasSumInW() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'sumInW' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder clearSumInW() { + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'averageInW' field. + * * + * @return The value. + */ + public double getAverageInW() { + return averageInW; + } + + + /** + * Sets the value of the 'averageInW' field. + * * + * @param value The value of 'averageInW'. + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder setAverageInW(double value) { + validate(fields()[4], value); + this.averageInW = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'averageInW' field has been set. + * * + * @return True if the 'averageInW' field has been set, false otherwise. + */ + public boolean hasAverageInW() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'averageInW' field. + * * + * @return This builder. + */ + public theodolite.commons.model.records.AggregatedActivePowerRecord.Builder clearAverageInW() { + fieldSetFlags()[4] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public AggregatedActivePowerRecord build() { + try { + AggregatedActivePowerRecord record = new AggregatedActivePowerRecord(); + record.identifier = fieldSetFlags()[0] ? this.identifier : (java.lang.String) defaultValue(fields()[0]); + record.timestamp = fieldSetFlags()[1] ? this.timestamp : (java.lang.Long) defaultValue(fields()[1]); + record.count = fieldSetFlags()[2] ? this.count : (java.lang.Long) defaultValue(fields()[2]); + record.sumInW = fieldSetFlags()[3] ? this.sumInW : (java.lang.Double) defaultValue(fields()[3]); + record.averageInW = fieldSetFlags()[4] ? this.averageInW : (java.lang.Double) defaultValue(fields()[4]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter<AggregatedActivePowerRecord> + WRITER$ = (org.apache.avro.io.DatumWriter<AggregatedActivePowerRecord>)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader<AggregatedActivePowerRecord> + READER$ = (org.apache.avro.io.DatumReader<AggregatedActivePowerRecord>)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.identifier); + + out.writeLong(this.timestamp); + + out.writeLong(this.count); + + out.writeDouble(this.sumInW); + + out.writeDouble(this.averageInW); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.identifier = in.readString(); + + this.timestamp = in.readLong(); + + this.count = in.readLong(); + + this.sumInW = in.readDouble(); + + this.averageInW = in.readDouble(); + + } else { + for (int i = 0; i < 5; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.identifier = in.readString(); + break; + + case 1: + this.timestamp = in.readLong(); + break; + + case 2: + this.count = in.readLong(); + break; + + case 3: + this.sumInW = in.readDouble(); + break; + + case 4: + this.averageInW = in.readDouble(); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/DayOfWeekActivePowerRecord.java b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/DayOfWeekActivePowerRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..2cf0c3d88e8bc11db4f463ca70d790179a06b561 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/DayOfWeekActivePowerRecord.java @@ -0,0 +1,882 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package theodolite.commons.model.records; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class DayOfWeekActivePowerRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -758726405664358568L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"DayOfWeekActivePowerRecord\",\"namespace\":\"theodolite.commons.model.records\",\"fields\":[{\"name\":\"identifier\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"dayOfWeek\",\"type\":\"int\"},{\"name\":\"periodStart\",\"type\":\"long\"},{\"name\":\"periodEnd\",\"type\":\"long\"},{\"name\":\"count\",\"type\":\"long\"},{\"name\":\"mean\",\"type\":\"double\"},{\"name\":\"populationVariance\",\"type\":\"double\"},{\"name\":\"min\",\"type\":\"double\"},{\"name\":\"max\",\"type\":\"double\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder<DayOfWeekActivePowerRecord> ENCODER = + new BinaryMessageEncoder<DayOfWeekActivePowerRecord>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder<DayOfWeekActivePowerRecord> DECODER = + new BinaryMessageDecoder<DayOfWeekActivePowerRecord>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder<DayOfWeekActivePowerRecord> getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder<DayOfWeekActivePowerRecord> getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder<DayOfWeekActivePowerRecord> createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<DayOfWeekActivePowerRecord>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this DayOfWeekActivePowerRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a DayOfWeekActivePowerRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a DayOfWeekActivePowerRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static DayOfWeekActivePowerRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.String identifier; + private int dayOfWeek; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use <code>newBuilder()</code>. + */ + public DayOfWeekActivePowerRecord() {} + + /** + * All-args constructor. + * @param identifier The new value for identifier + * @param dayOfWeek The new value for dayOfWeek + * @param periodStart The new value for periodStart + * @param periodEnd The new value for periodEnd + * @param count The new value for count + * @param mean The new value for mean + * @param populationVariance The new value for populationVariance + * @param min The new value for min + * @param max The new value for max + */ + public DayOfWeekActivePowerRecord(java.lang.String identifier, java.lang.Integer dayOfWeek, java.lang.Long periodStart, java.lang.Long periodEnd, java.lang.Long count, java.lang.Double mean, java.lang.Double populationVariance, java.lang.Double min, java.lang.Double max) { + this.identifier = identifier; + this.dayOfWeek = dayOfWeek; + this.periodStart = periodStart; + this.periodEnd = periodEnd; + this.count = count; + this.mean = mean; + this.populationVariance = populationVariance; + this.min = min; + this.max = max; + } + + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + // Used by DatumWriter. Applications should not call. + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return identifier; + case 1: return dayOfWeek; + case 2: return periodStart; + case 3: return periodEnd; + case 4: return count; + case 5: return mean; + case 6: return populationVariance; + case 7: return min; + case 8: return max; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: identifier = value$ != null ? value$.toString() : null; break; + case 1: dayOfWeek = (java.lang.Integer)value$; break; + case 2: periodStart = (java.lang.Long)value$; break; + case 3: periodEnd = (java.lang.Long)value$; break; + case 4: count = (java.lang.Long)value$; break; + case 5: mean = (java.lang.Double)value$; break; + case 6: populationVariance = (java.lang.Double)value$; break; + case 7: min = (java.lang.Double)value$; break; + case 8: max = (java.lang.Double)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value of the 'identifier' field. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + + /** + * Gets the value of the 'dayOfWeek' field. + * @return The value of the 'dayOfWeek' field. + */ + public int getDayOfWeek() { + return dayOfWeek; + } + + + + /** + * Gets the value of the 'periodStart' field. + * @return The value of the 'periodStart' field. + */ + public long getPeriodStart() { + return periodStart; + } + + + + /** + * Gets the value of the 'periodEnd' field. + * @return The value of the 'periodEnd' field. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + + /** + * Gets the value of the 'count' field. + * @return The value of the 'count' field. + */ + public long getCount() { + return count; + } + + + + /** + * Gets the value of the 'mean' field. + * @return The value of the 'mean' field. + */ + public double getMean() { + return mean; + } + + + + /** + * Gets the value of the 'populationVariance' field. + * @return The value of the 'populationVariance' field. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + + /** + * Gets the value of the 'min' field. + * @return The value of the 'min' field. + */ + public double getMin() { + return min; + } + + + + /** + * Gets the value of the 'max' field. + * @return The value of the 'max' field. + */ + public double getMax() { + return max; + } + + + + /** + * Creates a new DayOfWeekActivePowerRecord RecordBuilder. + * @return A new DayOfWeekActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder newBuilder() { + return new theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder(); + } + + /** + * Creates a new DayOfWeekActivePowerRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new DayOfWeekActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder other) { + if (other == null) { + return new theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder(other); + } + } + + /** + * Creates a new DayOfWeekActivePowerRecord RecordBuilder by copying an existing DayOfWeekActivePowerRecord instance. + * @param other The existing instance to copy. + * @return A new DayOfWeekActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.DayOfWeekActivePowerRecord other) { + if (other == null) { + return new theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder(other); + } + } + + /** + * RecordBuilder for DayOfWeekActivePowerRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<DayOfWeekActivePowerRecord> + implements org.apache.avro.data.RecordBuilder<DayOfWeekActivePowerRecord> { + + private java.lang.String identifier; + private int dayOfWeek; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.dayOfWeek)) { + this.dayOfWeek = data().deepCopy(fields()[1].schema(), other.dayOfWeek); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + } + + /** + * Creates a Builder by copying an existing DayOfWeekActivePowerRecord instance + * @param other The existing instance to copy. + */ + private Builder(theodolite.commons.model.records.DayOfWeekActivePowerRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.dayOfWeek)) { + this.dayOfWeek = data().deepCopy(fields()[1].schema(), other.dayOfWeek); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = true; + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + /** + * Sets the value of the 'identifier' field. + * @param value The value of 'identifier'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setIdentifier(java.lang.String value) { + validate(fields()[0], value); + this.identifier = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'identifier' field has been set. + * @return True if the 'identifier' field has been set, false otherwise. + */ + public boolean hasIdentifier() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'identifier' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearIdentifier() { + identifier = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'dayOfWeek' field. + * @return The value. + */ + public int getDayOfWeek() { + return dayOfWeek; + } + + + /** + * Sets the value of the 'dayOfWeek' field. + * @param value The value of 'dayOfWeek'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setDayOfWeek(int value) { + validate(fields()[1], value); + this.dayOfWeek = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'dayOfWeek' field has been set. + * @return True if the 'dayOfWeek' field has been set, false otherwise. + */ + public boolean hasDayOfWeek() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'dayOfWeek' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearDayOfWeek() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'periodStart' field. + * @return The value. + */ + public long getPeriodStart() { + return periodStart; + } + + + /** + * Sets the value of the 'periodStart' field. + * @param value The value of 'periodStart'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setPeriodStart(long value) { + validate(fields()[2], value); + this.periodStart = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'periodStart' field has been set. + * @return True if the 'periodStart' field has been set, false otherwise. + */ + public boolean hasPeriodStart() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'periodStart' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearPeriodStart() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'periodEnd' field. + * @return The value. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + /** + * Sets the value of the 'periodEnd' field. + * @param value The value of 'periodEnd'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setPeriodEnd(long value) { + validate(fields()[3], value); + this.periodEnd = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'periodEnd' field has been set. + * @return True if the 'periodEnd' field has been set, false otherwise. + */ + public boolean hasPeriodEnd() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'periodEnd' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearPeriodEnd() { + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'count' field. + * @return The value. + */ + public long getCount() { + return count; + } + + + /** + * Sets the value of the 'count' field. + * @param value The value of 'count'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setCount(long value) { + validate(fields()[4], value); + this.count = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'count' field has been set. + * @return True if the 'count' field has been set, false otherwise. + */ + public boolean hasCount() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'count' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearCount() { + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'mean' field. + * @return The value. + */ + public double getMean() { + return mean; + } + + + /** + * Sets the value of the 'mean' field. + * @param value The value of 'mean'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setMean(double value) { + validate(fields()[5], value); + this.mean = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'mean' field has been set. + * @return True if the 'mean' field has been set, false otherwise. + */ + public boolean hasMean() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'mean' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearMean() { + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'populationVariance' field. + * @return The value. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + /** + * Sets the value of the 'populationVariance' field. + * @param value The value of 'populationVariance'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setPopulationVariance(double value) { + validate(fields()[6], value); + this.populationVariance = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'populationVariance' field has been set. + * @return True if the 'populationVariance' field has been set, false otherwise. + */ + public boolean hasPopulationVariance() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'populationVariance' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearPopulationVariance() { + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'min' field. + * @return The value. + */ + public double getMin() { + return min; + } + + + /** + * Sets the value of the 'min' field. + * @param value The value of 'min'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setMin(double value) { + validate(fields()[7], value); + this.min = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'min' field has been set. + * @return True if the 'min' field has been set, false otherwise. + */ + public boolean hasMin() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'min' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearMin() { + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'max' field. + * @return The value. + */ + public double getMax() { + return max; + } + + + /** + * Sets the value of the 'max' field. + * @param value The value of 'max'. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder setMax(double value) { + validate(fields()[8], value); + this.max = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'max' field has been set. + * @return True if the 'max' field has been set, false otherwise. + */ + public boolean hasMax() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'max' field. + * @return This builder. + */ + public theodolite.commons.model.records.DayOfWeekActivePowerRecord.Builder clearMax() { + fieldSetFlags()[8] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public DayOfWeekActivePowerRecord build() { + try { + DayOfWeekActivePowerRecord record = new DayOfWeekActivePowerRecord(); + record.identifier = fieldSetFlags()[0] ? this.identifier : (java.lang.String) defaultValue(fields()[0]); + record.dayOfWeek = fieldSetFlags()[1] ? this.dayOfWeek : (java.lang.Integer) defaultValue(fields()[1]); + record.periodStart = fieldSetFlags()[2] ? this.periodStart : (java.lang.Long) defaultValue(fields()[2]); + record.periodEnd = fieldSetFlags()[3] ? this.periodEnd : (java.lang.Long) defaultValue(fields()[3]); + record.count = fieldSetFlags()[4] ? this.count : (java.lang.Long) defaultValue(fields()[4]); + record.mean = fieldSetFlags()[5] ? this.mean : (java.lang.Double) defaultValue(fields()[5]); + record.populationVariance = fieldSetFlags()[6] ? this.populationVariance : (java.lang.Double) defaultValue(fields()[6]); + record.min = fieldSetFlags()[7] ? this.min : (java.lang.Double) defaultValue(fields()[7]); + record.max = fieldSetFlags()[8] ? this.max : (java.lang.Double) defaultValue(fields()[8]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter<DayOfWeekActivePowerRecord> + WRITER$ = (org.apache.avro.io.DatumWriter<DayOfWeekActivePowerRecord>)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader<DayOfWeekActivePowerRecord> + READER$ = (org.apache.avro.io.DatumReader<DayOfWeekActivePowerRecord>)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.identifier); + + out.writeInt(this.dayOfWeek); + + out.writeLong(this.periodStart); + + out.writeLong(this.periodEnd); + + out.writeLong(this.count); + + out.writeDouble(this.mean); + + out.writeDouble(this.populationVariance); + + out.writeDouble(this.min); + + out.writeDouble(this.max); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.identifier = in.readString(); + + this.dayOfWeek = in.readInt(); + + this.periodStart = in.readLong(); + + this.periodEnd = in.readLong(); + + this.count = in.readLong(); + + this.mean = in.readDouble(); + + this.populationVariance = in.readDouble(); + + this.min = in.readDouble(); + + this.max = in.readDouble(); + + } else { + for (int i = 0; i < 9; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.identifier = in.readString(); + break; + + case 1: + this.dayOfWeek = in.readInt(); + break; + + case 2: + this.periodStart = in.readLong(); + break; + + case 3: + this.periodEnd = in.readLong(); + break; + + case 4: + this.count = in.readLong(); + break; + + case 5: + this.mean = in.readDouble(); + break; + + case 6: + this.populationVariance = in.readDouble(); + break; + + case 7: + this.min = in.readDouble(); + break; + + case 8: + this.max = in.readDouble(); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/HourOfDayActivePowerRecord.java b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/HourOfDayActivePowerRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..77a61394b585fb370942c7465a3af2548f141bb1 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/HourOfDayActivePowerRecord.java @@ -0,0 +1,882 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package theodolite.commons.model.records; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class HourOfDayActivePowerRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -6848505675940050496L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"HourOfDayActivePowerRecord\",\"namespace\":\"theodolite.commons.model.records\",\"fields\":[{\"name\":\"identifier\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"hourOfDay\",\"type\":\"int\"},{\"name\":\"periodStart\",\"type\":\"long\"},{\"name\":\"periodEnd\",\"type\":\"long\"},{\"name\":\"count\",\"type\":\"long\"},{\"name\":\"mean\",\"type\":\"double\"},{\"name\":\"populationVariance\",\"type\":\"double\"},{\"name\":\"min\",\"type\":\"double\"},{\"name\":\"max\",\"type\":\"double\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder<HourOfDayActivePowerRecord> ENCODER = + new BinaryMessageEncoder<HourOfDayActivePowerRecord>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder<HourOfDayActivePowerRecord> DECODER = + new BinaryMessageDecoder<HourOfDayActivePowerRecord>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder<HourOfDayActivePowerRecord> getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder<HourOfDayActivePowerRecord> getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder<HourOfDayActivePowerRecord> createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<HourOfDayActivePowerRecord>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this HourOfDayActivePowerRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a HourOfDayActivePowerRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a HourOfDayActivePowerRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static HourOfDayActivePowerRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.String identifier; + private int hourOfDay; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use <code>newBuilder()</code>. + */ + public HourOfDayActivePowerRecord() {} + + /** + * All-args constructor. + * @param identifier The new value for identifier + * @param hourOfDay The new value for hourOfDay + * @param periodStart The new value for periodStart + * @param periodEnd The new value for periodEnd + * @param count The new value for count + * @param mean The new value for mean + * @param populationVariance The new value for populationVariance + * @param min The new value for min + * @param max The new value for max + */ + public HourOfDayActivePowerRecord(java.lang.String identifier, java.lang.Integer hourOfDay, java.lang.Long periodStart, java.lang.Long periodEnd, java.lang.Long count, java.lang.Double mean, java.lang.Double populationVariance, java.lang.Double min, java.lang.Double max) { + this.identifier = identifier; + this.hourOfDay = hourOfDay; + this.periodStart = periodStart; + this.periodEnd = periodEnd; + this.count = count; + this.mean = mean; + this.populationVariance = populationVariance; + this.min = min; + this.max = max; + } + + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + // Used by DatumWriter. Applications should not call. + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return identifier; + case 1: return hourOfDay; + case 2: return periodStart; + case 3: return periodEnd; + case 4: return count; + case 5: return mean; + case 6: return populationVariance; + case 7: return min; + case 8: return max; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: identifier = value$ != null ? value$.toString() : null; break; + case 1: hourOfDay = (java.lang.Integer)value$; break; + case 2: periodStart = (java.lang.Long)value$; break; + case 3: periodEnd = (java.lang.Long)value$; break; + case 4: count = (java.lang.Long)value$; break; + case 5: mean = (java.lang.Double)value$; break; + case 6: populationVariance = (java.lang.Double)value$; break; + case 7: min = (java.lang.Double)value$; break; + case 8: max = (java.lang.Double)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value of the 'identifier' field. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + + /** + * Gets the value of the 'hourOfDay' field. + * @return The value of the 'hourOfDay' field. + */ + public int getHourOfDay() { + return hourOfDay; + } + + + + /** + * Gets the value of the 'periodStart' field. + * @return The value of the 'periodStart' field. + */ + public long getPeriodStart() { + return periodStart; + } + + + + /** + * Gets the value of the 'periodEnd' field. + * @return The value of the 'periodEnd' field. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + + /** + * Gets the value of the 'count' field. + * @return The value of the 'count' field. + */ + public long getCount() { + return count; + } + + + + /** + * Gets the value of the 'mean' field. + * @return The value of the 'mean' field. + */ + public double getMean() { + return mean; + } + + + + /** + * Gets the value of the 'populationVariance' field. + * @return The value of the 'populationVariance' field. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + + /** + * Gets the value of the 'min' field. + * @return The value of the 'min' field. + */ + public double getMin() { + return min; + } + + + + /** + * Gets the value of the 'max' field. + * @return The value of the 'max' field. + */ + public double getMax() { + return max; + } + + + + /** + * Creates a new HourOfDayActivePowerRecord RecordBuilder. + * @return A new HourOfDayActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder newBuilder() { + return new theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder(); + } + + /** + * Creates a new HourOfDayActivePowerRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new HourOfDayActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder other) { + if (other == null) { + return new theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder(other); + } + } + + /** + * Creates a new HourOfDayActivePowerRecord RecordBuilder by copying an existing HourOfDayActivePowerRecord instance. + * @param other The existing instance to copy. + * @return A new HourOfDayActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.HourOfDayActivePowerRecord other) { + if (other == null) { + return new theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder(other); + } + } + + /** + * RecordBuilder for HourOfDayActivePowerRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<HourOfDayActivePowerRecord> + implements org.apache.avro.data.RecordBuilder<HourOfDayActivePowerRecord> { + + private java.lang.String identifier; + private int hourOfDay; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.hourOfDay)) { + this.hourOfDay = data().deepCopy(fields()[1].schema(), other.hourOfDay); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + } + + /** + * Creates a Builder by copying an existing HourOfDayActivePowerRecord instance + * @param other The existing instance to copy. + */ + private Builder(theodolite.commons.model.records.HourOfDayActivePowerRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.hourOfDay)) { + this.hourOfDay = data().deepCopy(fields()[1].schema(), other.hourOfDay); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = true; + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + /** + * Sets the value of the 'identifier' field. + * @param value The value of 'identifier'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setIdentifier(java.lang.String value) { + validate(fields()[0], value); + this.identifier = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'identifier' field has been set. + * @return True if the 'identifier' field has been set, false otherwise. + */ + public boolean hasIdentifier() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'identifier' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearIdentifier() { + identifier = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'hourOfDay' field. + * @return The value. + */ + public int getHourOfDay() { + return hourOfDay; + } + + + /** + * Sets the value of the 'hourOfDay' field. + * @param value The value of 'hourOfDay'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setHourOfDay(int value) { + validate(fields()[1], value); + this.hourOfDay = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'hourOfDay' field has been set. + * @return True if the 'hourOfDay' field has been set, false otherwise. + */ + public boolean hasHourOfDay() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'hourOfDay' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearHourOfDay() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'periodStart' field. + * @return The value. + */ + public long getPeriodStart() { + return periodStart; + } + + + /** + * Sets the value of the 'periodStart' field. + * @param value The value of 'periodStart'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setPeriodStart(long value) { + validate(fields()[2], value); + this.periodStart = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'periodStart' field has been set. + * @return True if the 'periodStart' field has been set, false otherwise. + */ + public boolean hasPeriodStart() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'periodStart' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearPeriodStart() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'periodEnd' field. + * @return The value. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + /** + * Sets the value of the 'periodEnd' field. + * @param value The value of 'periodEnd'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setPeriodEnd(long value) { + validate(fields()[3], value); + this.periodEnd = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'periodEnd' field has been set. + * @return True if the 'periodEnd' field has been set, false otherwise. + */ + public boolean hasPeriodEnd() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'periodEnd' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearPeriodEnd() { + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'count' field. + * @return The value. + */ + public long getCount() { + return count; + } + + + /** + * Sets the value of the 'count' field. + * @param value The value of 'count'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setCount(long value) { + validate(fields()[4], value); + this.count = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'count' field has been set. + * @return True if the 'count' field has been set, false otherwise. + */ + public boolean hasCount() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'count' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearCount() { + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'mean' field. + * @return The value. + */ + public double getMean() { + return mean; + } + + + /** + * Sets the value of the 'mean' field. + * @param value The value of 'mean'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setMean(double value) { + validate(fields()[5], value); + this.mean = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'mean' field has been set. + * @return True if the 'mean' field has been set, false otherwise. + */ + public boolean hasMean() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'mean' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearMean() { + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'populationVariance' field. + * @return The value. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + /** + * Sets the value of the 'populationVariance' field. + * @param value The value of 'populationVariance'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setPopulationVariance(double value) { + validate(fields()[6], value); + this.populationVariance = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'populationVariance' field has been set. + * @return True if the 'populationVariance' field has been set, false otherwise. + */ + public boolean hasPopulationVariance() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'populationVariance' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearPopulationVariance() { + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'min' field. + * @return The value. + */ + public double getMin() { + return min; + } + + + /** + * Sets the value of the 'min' field. + * @param value The value of 'min'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setMin(double value) { + validate(fields()[7], value); + this.min = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'min' field has been set. + * @return True if the 'min' field has been set, false otherwise. + */ + public boolean hasMin() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'min' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearMin() { + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'max' field. + * @return The value. + */ + public double getMax() { + return max; + } + + + /** + * Sets the value of the 'max' field. + * @param value The value of 'max'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder setMax(double value) { + validate(fields()[8], value); + this.max = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'max' field has been set. + * @return True if the 'max' field has been set, false otherwise. + */ + public boolean hasMax() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'max' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfDayActivePowerRecord.Builder clearMax() { + fieldSetFlags()[8] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public HourOfDayActivePowerRecord build() { + try { + HourOfDayActivePowerRecord record = new HourOfDayActivePowerRecord(); + record.identifier = fieldSetFlags()[0] ? this.identifier : (java.lang.String) defaultValue(fields()[0]); + record.hourOfDay = fieldSetFlags()[1] ? this.hourOfDay : (java.lang.Integer) defaultValue(fields()[1]); + record.periodStart = fieldSetFlags()[2] ? this.periodStart : (java.lang.Long) defaultValue(fields()[2]); + record.periodEnd = fieldSetFlags()[3] ? this.periodEnd : (java.lang.Long) defaultValue(fields()[3]); + record.count = fieldSetFlags()[4] ? this.count : (java.lang.Long) defaultValue(fields()[4]); + record.mean = fieldSetFlags()[5] ? this.mean : (java.lang.Double) defaultValue(fields()[5]); + record.populationVariance = fieldSetFlags()[6] ? this.populationVariance : (java.lang.Double) defaultValue(fields()[6]); + record.min = fieldSetFlags()[7] ? this.min : (java.lang.Double) defaultValue(fields()[7]); + record.max = fieldSetFlags()[8] ? this.max : (java.lang.Double) defaultValue(fields()[8]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter<HourOfDayActivePowerRecord> + WRITER$ = (org.apache.avro.io.DatumWriter<HourOfDayActivePowerRecord>)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader<HourOfDayActivePowerRecord> + READER$ = (org.apache.avro.io.DatumReader<HourOfDayActivePowerRecord>)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.identifier); + + out.writeInt(this.hourOfDay); + + out.writeLong(this.periodStart); + + out.writeLong(this.periodEnd); + + out.writeLong(this.count); + + out.writeDouble(this.mean); + + out.writeDouble(this.populationVariance); + + out.writeDouble(this.min); + + out.writeDouble(this.max); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.identifier = in.readString(); + + this.hourOfDay = in.readInt(); + + this.periodStart = in.readLong(); + + this.periodEnd = in.readLong(); + + this.count = in.readLong(); + + this.mean = in.readDouble(); + + this.populationVariance = in.readDouble(); + + this.min = in.readDouble(); + + this.max = in.readDouble(); + + } else { + for (int i = 0; i < 9; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.identifier = in.readString(); + break; + + case 1: + this.hourOfDay = in.readInt(); + break; + + case 2: + this.periodStart = in.readLong(); + break; + + case 3: + this.periodEnd = in.readLong(); + break; + + case 4: + this.count = in.readLong(); + break; + + case 5: + this.mean = in.readDouble(); + break; + + case 6: + this.populationVariance = in.readDouble(); + break; + + case 7: + this.min = in.readDouble(); + break; + + case 8: + this.max = in.readDouble(); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/HourOfWeekActivePowerRecord.java b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/HourOfWeekActivePowerRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..a9ad313cffddc06b86b3b67f747dd03a9f2d7857 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/HourOfWeekActivePowerRecord.java @@ -0,0 +1,954 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package theodolite.commons.model.records; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class HourOfWeekActivePowerRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 170760910567947295L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"HourOfWeekActivePowerRecord\",\"namespace\":\"theodolite.commons.model.records\",\"fields\":[{\"name\":\"identifier\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"dayOfWeek\",\"type\":\"int\"},{\"name\":\"hourOfDay\",\"type\":\"int\"},{\"name\":\"periodStart\",\"type\":\"long\"},{\"name\":\"periodEnd\",\"type\":\"long\"},{\"name\":\"count\",\"type\":\"long\"},{\"name\":\"mean\",\"type\":\"double\"},{\"name\":\"populationVariance\",\"type\":\"double\"},{\"name\":\"min\",\"type\":\"double\"},{\"name\":\"max\",\"type\":\"double\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder<HourOfWeekActivePowerRecord> ENCODER = + new BinaryMessageEncoder<HourOfWeekActivePowerRecord>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder<HourOfWeekActivePowerRecord> DECODER = + new BinaryMessageDecoder<HourOfWeekActivePowerRecord>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder<HourOfWeekActivePowerRecord> getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder<HourOfWeekActivePowerRecord> getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder<HourOfWeekActivePowerRecord> createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<HourOfWeekActivePowerRecord>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this HourOfWeekActivePowerRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a HourOfWeekActivePowerRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a HourOfWeekActivePowerRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static HourOfWeekActivePowerRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.String identifier; + private int dayOfWeek; + private int hourOfDay; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use <code>newBuilder()</code>. + */ + public HourOfWeekActivePowerRecord() {} + + /** + * All-args constructor. + * @param identifier The new value for identifier + * @param dayOfWeek The new value for dayOfWeek + * @param hourOfDay The new value for hourOfDay + * @param periodStart The new value for periodStart + * @param periodEnd The new value for periodEnd + * @param count The new value for count + * @param mean The new value for mean + * @param populationVariance The new value for populationVariance + * @param min The new value for min + * @param max The new value for max + */ + public HourOfWeekActivePowerRecord(java.lang.String identifier, java.lang.Integer dayOfWeek, java.lang.Integer hourOfDay, java.lang.Long periodStart, java.lang.Long periodEnd, java.lang.Long count, java.lang.Double mean, java.lang.Double populationVariance, java.lang.Double min, java.lang.Double max) { + this.identifier = identifier; + this.dayOfWeek = dayOfWeek; + this.hourOfDay = hourOfDay; + this.periodStart = periodStart; + this.periodEnd = periodEnd; + this.count = count; + this.mean = mean; + this.populationVariance = populationVariance; + this.min = min; + this.max = max; + } + + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + // Used by DatumWriter. Applications should not call. + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return identifier; + case 1: return dayOfWeek; + case 2: return hourOfDay; + case 3: return periodStart; + case 4: return periodEnd; + case 5: return count; + case 6: return mean; + case 7: return populationVariance; + case 8: return min; + case 9: return max; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: identifier = value$ != null ? value$.toString() : null; break; + case 1: dayOfWeek = (java.lang.Integer)value$; break; + case 2: hourOfDay = (java.lang.Integer)value$; break; + case 3: periodStart = (java.lang.Long)value$; break; + case 4: periodEnd = (java.lang.Long)value$; break; + case 5: count = (java.lang.Long)value$; break; + case 6: mean = (java.lang.Double)value$; break; + case 7: populationVariance = (java.lang.Double)value$; break; + case 8: min = (java.lang.Double)value$; break; + case 9: max = (java.lang.Double)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value of the 'identifier' field. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + + /** + * Gets the value of the 'dayOfWeek' field. + * @return The value of the 'dayOfWeek' field. + */ + public int getDayOfWeek() { + return dayOfWeek; + } + + + + /** + * Gets the value of the 'hourOfDay' field. + * @return The value of the 'hourOfDay' field. + */ + public int getHourOfDay() { + return hourOfDay; + } + + + + /** + * Gets the value of the 'periodStart' field. + * @return The value of the 'periodStart' field. + */ + public long getPeriodStart() { + return periodStart; + } + + + + /** + * Gets the value of the 'periodEnd' field. + * @return The value of the 'periodEnd' field. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + + /** + * Gets the value of the 'count' field. + * @return The value of the 'count' field. + */ + public long getCount() { + return count; + } + + + + /** + * Gets the value of the 'mean' field. + * @return The value of the 'mean' field. + */ + public double getMean() { + return mean; + } + + + + /** + * Gets the value of the 'populationVariance' field. + * @return The value of the 'populationVariance' field. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + + /** + * Gets the value of the 'min' field. + * @return The value of the 'min' field. + */ + public double getMin() { + return min; + } + + + + /** + * Gets the value of the 'max' field. + * @return The value of the 'max' field. + */ + public double getMax() { + return max; + } + + + + /** + * Creates a new HourOfWeekActivePowerRecord RecordBuilder. + * @return A new HourOfWeekActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder newBuilder() { + return new theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder(); + } + + /** + * Creates a new HourOfWeekActivePowerRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new HourOfWeekActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder other) { + if (other == null) { + return new theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder(other); + } + } + + /** + * Creates a new HourOfWeekActivePowerRecord RecordBuilder by copying an existing HourOfWeekActivePowerRecord instance. + * @param other The existing instance to copy. + * @return A new HourOfWeekActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.HourOfWeekActivePowerRecord other) { + if (other == null) { + return new theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder(other); + } + } + + /** + * RecordBuilder for HourOfWeekActivePowerRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<HourOfWeekActivePowerRecord> + implements org.apache.avro.data.RecordBuilder<HourOfWeekActivePowerRecord> { + + private java.lang.String identifier; + private int dayOfWeek; + private int hourOfDay; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.dayOfWeek)) { + this.dayOfWeek = data().deepCopy(fields()[1].schema(), other.dayOfWeek); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.hourOfDay)) { + this.hourOfDay = data().deepCopy(fields()[2].schema(), other.hourOfDay); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[3].schema(), other.periodStart); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[4].schema(), other.periodEnd); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.count)) { + this.count = data().deepCopy(fields()[5].schema(), other.count); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.mean)) { + this.mean = data().deepCopy(fields()[6].schema(), other.mean); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[7].schema(), other.populationVariance); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.min)) { + this.min = data().deepCopy(fields()[8].schema(), other.min); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + if (isValidValue(fields()[9], other.max)) { + this.max = data().deepCopy(fields()[9].schema(), other.max); + fieldSetFlags()[9] = other.fieldSetFlags()[9]; + } + } + + /** + * Creates a Builder by copying an existing HourOfWeekActivePowerRecord instance + * @param other The existing instance to copy. + */ + private Builder(theodolite.commons.model.records.HourOfWeekActivePowerRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.dayOfWeek)) { + this.dayOfWeek = data().deepCopy(fields()[1].schema(), other.dayOfWeek); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.hourOfDay)) { + this.hourOfDay = data().deepCopy(fields()[2].schema(), other.hourOfDay); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[3].schema(), other.periodStart); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[4].schema(), other.periodEnd); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.count)) { + this.count = data().deepCopy(fields()[5].schema(), other.count); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.mean)) { + this.mean = data().deepCopy(fields()[6].schema(), other.mean); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[7].schema(), other.populationVariance); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.min)) { + this.min = data().deepCopy(fields()[8].schema(), other.min); + fieldSetFlags()[8] = true; + } + if (isValidValue(fields()[9], other.max)) { + this.max = data().deepCopy(fields()[9].schema(), other.max); + fieldSetFlags()[9] = true; + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + /** + * Sets the value of the 'identifier' field. + * @param value The value of 'identifier'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setIdentifier(java.lang.String value) { + validate(fields()[0], value); + this.identifier = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'identifier' field has been set. + * @return True if the 'identifier' field has been set, false otherwise. + */ + public boolean hasIdentifier() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'identifier' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearIdentifier() { + identifier = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'dayOfWeek' field. + * @return The value. + */ + public int getDayOfWeek() { + return dayOfWeek; + } + + + /** + * Sets the value of the 'dayOfWeek' field. + * @param value The value of 'dayOfWeek'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setDayOfWeek(int value) { + validate(fields()[1], value); + this.dayOfWeek = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'dayOfWeek' field has been set. + * @return True if the 'dayOfWeek' field has been set, false otherwise. + */ + public boolean hasDayOfWeek() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'dayOfWeek' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearDayOfWeek() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'hourOfDay' field. + * @return The value. + */ + public int getHourOfDay() { + return hourOfDay; + } + + + /** + * Sets the value of the 'hourOfDay' field. + * @param value The value of 'hourOfDay'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setHourOfDay(int value) { + validate(fields()[2], value); + this.hourOfDay = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'hourOfDay' field has been set. + * @return True if the 'hourOfDay' field has been set, false otherwise. + */ + public boolean hasHourOfDay() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'hourOfDay' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearHourOfDay() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'periodStart' field. + * @return The value. + */ + public long getPeriodStart() { + return periodStart; + } + + + /** + * Sets the value of the 'periodStart' field. + * @param value The value of 'periodStart'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setPeriodStart(long value) { + validate(fields()[3], value); + this.periodStart = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'periodStart' field has been set. + * @return True if the 'periodStart' field has been set, false otherwise. + */ + public boolean hasPeriodStart() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'periodStart' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearPeriodStart() { + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'periodEnd' field. + * @return The value. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + /** + * Sets the value of the 'periodEnd' field. + * @param value The value of 'periodEnd'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setPeriodEnd(long value) { + validate(fields()[4], value); + this.periodEnd = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'periodEnd' field has been set. + * @return True if the 'periodEnd' field has been set, false otherwise. + */ + public boolean hasPeriodEnd() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'periodEnd' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearPeriodEnd() { + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'count' field. + * @return The value. + */ + public long getCount() { + return count; + } + + + /** + * Sets the value of the 'count' field. + * @param value The value of 'count'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setCount(long value) { + validate(fields()[5], value); + this.count = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'count' field has been set. + * @return True if the 'count' field has been set, false otherwise. + */ + public boolean hasCount() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'count' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearCount() { + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'mean' field. + * @return The value. + */ + public double getMean() { + return mean; + } + + + /** + * Sets the value of the 'mean' field. + * @param value The value of 'mean'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setMean(double value) { + validate(fields()[6], value); + this.mean = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'mean' field has been set. + * @return True if the 'mean' field has been set, false otherwise. + */ + public boolean hasMean() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'mean' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearMean() { + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'populationVariance' field. + * @return The value. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + /** + * Sets the value of the 'populationVariance' field. + * @param value The value of 'populationVariance'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setPopulationVariance(double value) { + validate(fields()[7], value); + this.populationVariance = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'populationVariance' field has been set. + * @return True if the 'populationVariance' field has been set, false otherwise. + */ + public boolean hasPopulationVariance() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'populationVariance' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearPopulationVariance() { + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'min' field. + * @return The value. + */ + public double getMin() { + return min; + } + + + /** + * Sets the value of the 'min' field. + * @param value The value of 'min'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setMin(double value) { + validate(fields()[8], value); + this.min = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'min' field has been set. + * @return True if the 'min' field has been set, false otherwise. + */ + public boolean hasMin() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'min' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearMin() { + fieldSetFlags()[8] = false; + return this; + } + + /** + * Gets the value of the 'max' field. + * @return The value. + */ + public double getMax() { + return max; + } + + + /** + * Sets the value of the 'max' field. + * @param value The value of 'max'. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder setMax(double value) { + validate(fields()[9], value); + this.max = value; + fieldSetFlags()[9] = true; + return this; + } + + /** + * Checks whether the 'max' field has been set. + * @return True if the 'max' field has been set, false otherwise. + */ + public boolean hasMax() { + return fieldSetFlags()[9]; + } + + + /** + * Clears the value of the 'max' field. + * @return This builder. + */ + public theodolite.commons.model.records.HourOfWeekActivePowerRecord.Builder clearMax() { + fieldSetFlags()[9] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public HourOfWeekActivePowerRecord build() { + try { + HourOfWeekActivePowerRecord record = new HourOfWeekActivePowerRecord(); + record.identifier = fieldSetFlags()[0] ? this.identifier : (java.lang.String) defaultValue(fields()[0]); + record.dayOfWeek = fieldSetFlags()[1] ? this.dayOfWeek : (java.lang.Integer) defaultValue(fields()[1]); + record.hourOfDay = fieldSetFlags()[2] ? this.hourOfDay : (java.lang.Integer) defaultValue(fields()[2]); + record.periodStart = fieldSetFlags()[3] ? this.periodStart : (java.lang.Long) defaultValue(fields()[3]); + record.periodEnd = fieldSetFlags()[4] ? this.periodEnd : (java.lang.Long) defaultValue(fields()[4]); + record.count = fieldSetFlags()[5] ? this.count : (java.lang.Long) defaultValue(fields()[5]); + record.mean = fieldSetFlags()[6] ? this.mean : (java.lang.Double) defaultValue(fields()[6]); + record.populationVariance = fieldSetFlags()[7] ? this.populationVariance : (java.lang.Double) defaultValue(fields()[7]); + record.min = fieldSetFlags()[8] ? this.min : (java.lang.Double) defaultValue(fields()[8]); + record.max = fieldSetFlags()[9] ? this.max : (java.lang.Double) defaultValue(fields()[9]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter<HourOfWeekActivePowerRecord> + WRITER$ = (org.apache.avro.io.DatumWriter<HourOfWeekActivePowerRecord>)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader<HourOfWeekActivePowerRecord> + READER$ = (org.apache.avro.io.DatumReader<HourOfWeekActivePowerRecord>)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.identifier); + + out.writeInt(this.dayOfWeek); + + out.writeInt(this.hourOfDay); + + out.writeLong(this.periodStart); + + out.writeLong(this.periodEnd); + + out.writeLong(this.count); + + out.writeDouble(this.mean); + + out.writeDouble(this.populationVariance); + + out.writeDouble(this.min); + + out.writeDouble(this.max); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.identifier = in.readString(); + + this.dayOfWeek = in.readInt(); + + this.hourOfDay = in.readInt(); + + this.periodStart = in.readLong(); + + this.periodEnd = in.readLong(); + + this.count = in.readLong(); + + this.mean = in.readDouble(); + + this.populationVariance = in.readDouble(); + + this.min = in.readDouble(); + + this.max = in.readDouble(); + + } else { + for (int i = 0; i < 10; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.identifier = in.readString(); + break; + + case 1: + this.dayOfWeek = in.readInt(); + break; + + case 2: + this.hourOfDay = in.readInt(); + break; + + case 3: + this.periodStart = in.readLong(); + break; + + case 4: + this.periodEnd = in.readLong(); + break; + + case 5: + this.count = in.readLong(); + break; + + case 6: + this.mean = in.readDouble(); + break; + + case 7: + this.populationVariance = in.readDouble(); + break; + + case 8: + this.min = in.readDouble(); + break; + + case 9: + this.max = in.readDouble(); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/MonthOfYearActivePowerRecord.java b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/MonthOfYearActivePowerRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..de85dc08049f1c6b8201090da9684a2ed1262986 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/MonthOfYearActivePowerRecord.java @@ -0,0 +1,882 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package theodolite.commons.model.records; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class MonthOfYearActivePowerRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -3792500930026789769L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"MonthOfYearActivePowerRecord\",\"namespace\":\"theodolite.commons.model.records\",\"fields\":[{\"name\":\"identifier\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"monthOfYear\",\"type\":\"int\"},{\"name\":\"periodStart\",\"type\":\"long\"},{\"name\":\"periodEnd\",\"type\":\"long\"},{\"name\":\"count\",\"type\":\"long\"},{\"name\":\"mean\",\"type\":\"double\"},{\"name\":\"populationVariance\",\"type\":\"double\"},{\"name\":\"min\",\"type\":\"double\"},{\"name\":\"max\",\"type\":\"double\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder<MonthOfYearActivePowerRecord> ENCODER = + new BinaryMessageEncoder<MonthOfYearActivePowerRecord>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder<MonthOfYearActivePowerRecord> DECODER = + new BinaryMessageDecoder<MonthOfYearActivePowerRecord>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder<MonthOfYearActivePowerRecord> getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder<MonthOfYearActivePowerRecord> getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder<MonthOfYearActivePowerRecord> createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<MonthOfYearActivePowerRecord>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this MonthOfYearActivePowerRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a MonthOfYearActivePowerRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a MonthOfYearActivePowerRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static MonthOfYearActivePowerRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.String identifier; + private int monthOfYear; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use <code>newBuilder()</code>. + */ + public MonthOfYearActivePowerRecord() {} + + /** + * All-args constructor. + * @param identifier The new value for identifier + * @param monthOfYear The new value for monthOfYear + * @param periodStart The new value for periodStart + * @param periodEnd The new value for periodEnd + * @param count The new value for count + * @param mean The new value for mean + * @param populationVariance The new value for populationVariance + * @param min The new value for min + * @param max The new value for max + */ + public MonthOfYearActivePowerRecord(java.lang.String identifier, java.lang.Integer monthOfYear, java.lang.Long periodStart, java.lang.Long periodEnd, java.lang.Long count, java.lang.Double mean, java.lang.Double populationVariance, java.lang.Double min, java.lang.Double max) { + this.identifier = identifier; + this.monthOfYear = monthOfYear; + this.periodStart = periodStart; + this.periodEnd = periodEnd; + this.count = count; + this.mean = mean; + this.populationVariance = populationVariance; + this.min = min; + this.max = max; + } + + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + // Used by DatumWriter. Applications should not call. + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return identifier; + case 1: return monthOfYear; + case 2: return periodStart; + case 3: return periodEnd; + case 4: return count; + case 5: return mean; + case 6: return populationVariance; + case 7: return min; + case 8: return max; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: identifier = value$ != null ? value$.toString() : null; break; + case 1: monthOfYear = (java.lang.Integer)value$; break; + case 2: periodStart = (java.lang.Long)value$; break; + case 3: periodEnd = (java.lang.Long)value$; break; + case 4: count = (java.lang.Long)value$; break; + case 5: mean = (java.lang.Double)value$; break; + case 6: populationVariance = (java.lang.Double)value$; break; + case 7: min = (java.lang.Double)value$; break; + case 8: max = (java.lang.Double)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value of the 'identifier' field. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + + /** + * Gets the value of the 'monthOfYear' field. + * @return The value of the 'monthOfYear' field. + */ + public int getMonthOfYear() { + return monthOfYear; + } + + + + /** + * Gets the value of the 'periodStart' field. + * @return The value of the 'periodStart' field. + */ + public long getPeriodStart() { + return periodStart; + } + + + + /** + * Gets the value of the 'periodEnd' field. + * @return The value of the 'periodEnd' field. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + + /** + * Gets the value of the 'count' field. + * @return The value of the 'count' field. + */ + public long getCount() { + return count; + } + + + + /** + * Gets the value of the 'mean' field. + * @return The value of the 'mean' field. + */ + public double getMean() { + return mean; + } + + + + /** + * Gets the value of the 'populationVariance' field. + * @return The value of the 'populationVariance' field. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + + /** + * Gets the value of the 'min' field. + * @return The value of the 'min' field. + */ + public double getMin() { + return min; + } + + + + /** + * Gets the value of the 'max' field. + * @return The value of the 'max' field. + */ + public double getMax() { + return max; + } + + + + /** + * Creates a new MonthOfYearActivePowerRecord RecordBuilder. + * @return A new MonthOfYearActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder newBuilder() { + return new theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder(); + } + + /** + * Creates a new MonthOfYearActivePowerRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new MonthOfYearActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder other) { + if (other == null) { + return new theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder(other); + } + } + + /** + * Creates a new MonthOfYearActivePowerRecord RecordBuilder by copying an existing MonthOfYearActivePowerRecord instance. + * @param other The existing instance to copy. + * @return A new MonthOfYearActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.MonthOfYearActivePowerRecord other) { + if (other == null) { + return new theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder(other); + } + } + + /** + * RecordBuilder for MonthOfYearActivePowerRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<MonthOfYearActivePowerRecord> + implements org.apache.avro.data.RecordBuilder<MonthOfYearActivePowerRecord> { + + private java.lang.String identifier; + private int monthOfYear; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.monthOfYear)) { + this.monthOfYear = data().deepCopy(fields()[1].schema(), other.monthOfYear); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + } + + /** + * Creates a Builder by copying an existing MonthOfYearActivePowerRecord instance + * @param other The existing instance to copy. + */ + private Builder(theodolite.commons.model.records.MonthOfYearActivePowerRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.monthOfYear)) { + this.monthOfYear = data().deepCopy(fields()[1].schema(), other.monthOfYear); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = true; + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + /** + * Sets the value of the 'identifier' field. + * @param value The value of 'identifier'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setIdentifier(java.lang.String value) { + validate(fields()[0], value); + this.identifier = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'identifier' field has been set. + * @return True if the 'identifier' field has been set, false otherwise. + */ + public boolean hasIdentifier() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'identifier' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearIdentifier() { + identifier = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'monthOfYear' field. + * @return The value. + */ + public int getMonthOfYear() { + return monthOfYear; + } + + + /** + * Sets the value of the 'monthOfYear' field. + * @param value The value of 'monthOfYear'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setMonthOfYear(int value) { + validate(fields()[1], value); + this.monthOfYear = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'monthOfYear' field has been set. + * @return True if the 'monthOfYear' field has been set, false otherwise. + */ + public boolean hasMonthOfYear() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'monthOfYear' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearMonthOfYear() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'periodStart' field. + * @return The value. + */ + public long getPeriodStart() { + return periodStart; + } + + + /** + * Sets the value of the 'periodStart' field. + * @param value The value of 'periodStart'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setPeriodStart(long value) { + validate(fields()[2], value); + this.periodStart = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'periodStart' field has been set. + * @return True if the 'periodStart' field has been set, false otherwise. + */ + public boolean hasPeriodStart() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'periodStart' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearPeriodStart() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'periodEnd' field. + * @return The value. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + /** + * Sets the value of the 'periodEnd' field. + * @param value The value of 'periodEnd'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setPeriodEnd(long value) { + validate(fields()[3], value); + this.periodEnd = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'periodEnd' field has been set. + * @return True if the 'periodEnd' field has been set, false otherwise. + */ + public boolean hasPeriodEnd() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'periodEnd' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearPeriodEnd() { + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'count' field. + * @return The value. + */ + public long getCount() { + return count; + } + + + /** + * Sets the value of the 'count' field. + * @param value The value of 'count'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setCount(long value) { + validate(fields()[4], value); + this.count = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'count' field has been set. + * @return True if the 'count' field has been set, false otherwise. + */ + public boolean hasCount() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'count' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearCount() { + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'mean' field. + * @return The value. + */ + public double getMean() { + return mean; + } + + + /** + * Sets the value of the 'mean' field. + * @param value The value of 'mean'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setMean(double value) { + validate(fields()[5], value); + this.mean = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'mean' field has been set. + * @return True if the 'mean' field has been set, false otherwise. + */ + public boolean hasMean() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'mean' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearMean() { + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'populationVariance' field. + * @return The value. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + /** + * Sets the value of the 'populationVariance' field. + * @param value The value of 'populationVariance'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setPopulationVariance(double value) { + validate(fields()[6], value); + this.populationVariance = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'populationVariance' field has been set. + * @return True if the 'populationVariance' field has been set, false otherwise. + */ + public boolean hasPopulationVariance() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'populationVariance' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearPopulationVariance() { + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'min' field. + * @return The value. + */ + public double getMin() { + return min; + } + + + /** + * Sets the value of the 'min' field. + * @param value The value of 'min'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setMin(double value) { + validate(fields()[7], value); + this.min = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'min' field has been set. + * @return True if the 'min' field has been set, false otherwise. + */ + public boolean hasMin() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'min' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearMin() { + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'max' field. + * @return The value. + */ + public double getMax() { + return max; + } + + + /** + * Sets the value of the 'max' field. + * @param value The value of 'max'. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder setMax(double value) { + validate(fields()[8], value); + this.max = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'max' field has been set. + * @return True if the 'max' field has been set, false otherwise. + */ + public boolean hasMax() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'max' field. + * @return This builder. + */ + public theodolite.commons.model.records.MonthOfYearActivePowerRecord.Builder clearMax() { + fieldSetFlags()[8] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public MonthOfYearActivePowerRecord build() { + try { + MonthOfYearActivePowerRecord record = new MonthOfYearActivePowerRecord(); + record.identifier = fieldSetFlags()[0] ? this.identifier : (java.lang.String) defaultValue(fields()[0]); + record.monthOfYear = fieldSetFlags()[1] ? this.monthOfYear : (java.lang.Integer) defaultValue(fields()[1]); + record.periodStart = fieldSetFlags()[2] ? this.periodStart : (java.lang.Long) defaultValue(fields()[2]); + record.periodEnd = fieldSetFlags()[3] ? this.periodEnd : (java.lang.Long) defaultValue(fields()[3]); + record.count = fieldSetFlags()[4] ? this.count : (java.lang.Long) defaultValue(fields()[4]); + record.mean = fieldSetFlags()[5] ? this.mean : (java.lang.Double) defaultValue(fields()[5]); + record.populationVariance = fieldSetFlags()[6] ? this.populationVariance : (java.lang.Double) defaultValue(fields()[6]); + record.min = fieldSetFlags()[7] ? this.min : (java.lang.Double) defaultValue(fields()[7]); + record.max = fieldSetFlags()[8] ? this.max : (java.lang.Double) defaultValue(fields()[8]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter<MonthOfYearActivePowerRecord> + WRITER$ = (org.apache.avro.io.DatumWriter<MonthOfYearActivePowerRecord>)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader<MonthOfYearActivePowerRecord> + READER$ = (org.apache.avro.io.DatumReader<MonthOfYearActivePowerRecord>)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.identifier); + + out.writeInt(this.monthOfYear); + + out.writeLong(this.periodStart); + + out.writeLong(this.periodEnd); + + out.writeLong(this.count); + + out.writeDouble(this.mean); + + out.writeDouble(this.populationVariance); + + out.writeDouble(this.min); + + out.writeDouble(this.max); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.identifier = in.readString(); + + this.monthOfYear = in.readInt(); + + this.periodStart = in.readLong(); + + this.periodEnd = in.readLong(); + + this.count = in.readLong(); + + this.mean = in.readDouble(); + + this.populationVariance = in.readDouble(); + + this.min = in.readDouble(); + + this.max = in.readDouble(); + + } else { + for (int i = 0; i < 9; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.identifier = in.readString(); + break; + + case 1: + this.monthOfYear = in.readInt(); + break; + + case 2: + this.periodStart = in.readLong(); + break; + + case 3: + this.periodEnd = in.readLong(); + break; + + case 4: + this.count = in.readLong(); + break; + + case 5: + this.mean = in.readDouble(); + break; + + case 6: + this.populationVariance = in.readDouble(); + break; + + case 7: + this.min = in.readDouble(); + break; + + case 8: + this.max = in.readDouble(); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/YearActivePowerRecord.java b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/YearActivePowerRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..d466a772fa3ded2bb0a570f583ce035f2b703bb0 --- /dev/null +++ b/theodolite-benchmarks/commons/src-gen/main/java/theodolite/commons/model/records/YearActivePowerRecord.java @@ -0,0 +1,882 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package theodolite.commons.model.records; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class YearActivePowerRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -4368523068038395628L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"YearActivePowerRecord\",\"namespace\":\"theodolite.commons.model.records\",\"fields\":[{\"name\":\"identifier\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"year\",\"type\":\"int\"},{\"name\":\"periodStart\",\"type\":\"long\"},{\"name\":\"periodEnd\",\"type\":\"long\"},{\"name\":\"count\",\"type\":\"long\"},{\"name\":\"mean\",\"type\":\"double\"},{\"name\":\"populationVariance\",\"type\":\"double\"},{\"name\":\"min\",\"type\":\"double\"},{\"name\":\"max\",\"type\":\"double\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder<YearActivePowerRecord> ENCODER = + new BinaryMessageEncoder<YearActivePowerRecord>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder<YearActivePowerRecord> DECODER = + new BinaryMessageDecoder<YearActivePowerRecord>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder<YearActivePowerRecord> getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder<YearActivePowerRecord> getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder<YearActivePowerRecord> createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<YearActivePowerRecord>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this YearActivePowerRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a YearActivePowerRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a YearActivePowerRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static YearActivePowerRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.String identifier; + private int year; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use <code>newBuilder()</code>. + */ + public YearActivePowerRecord() {} + + /** + * All-args constructor. + * @param identifier The new value for identifier + * @param year The new value for year + * @param periodStart The new value for periodStart + * @param periodEnd The new value for periodEnd + * @param count The new value for count + * @param mean The new value for mean + * @param populationVariance The new value for populationVariance + * @param min The new value for min + * @param max The new value for max + */ + public YearActivePowerRecord(java.lang.String identifier, java.lang.Integer year, java.lang.Long periodStart, java.lang.Long periodEnd, java.lang.Long count, java.lang.Double mean, java.lang.Double populationVariance, java.lang.Double min, java.lang.Double max) { + this.identifier = identifier; + this.year = year; + this.periodStart = periodStart; + this.periodEnd = periodEnd; + this.count = count; + this.mean = mean; + this.populationVariance = populationVariance; + this.min = min; + this.max = max; + } + + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + // Used by DatumWriter. Applications should not call. + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return identifier; + case 1: return year; + case 2: return periodStart; + case 3: return periodEnd; + case 4: return count; + case 5: return mean; + case 6: return populationVariance; + case 7: return min; + case 8: return max; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: identifier = value$ != null ? value$.toString() : null; break; + case 1: year = (java.lang.Integer)value$; break; + case 2: periodStart = (java.lang.Long)value$; break; + case 3: periodEnd = (java.lang.Long)value$; break; + case 4: count = (java.lang.Long)value$; break; + case 5: mean = (java.lang.Double)value$; break; + case 6: populationVariance = (java.lang.Double)value$; break; + case 7: min = (java.lang.Double)value$; break; + case 8: max = (java.lang.Double)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value of the 'identifier' field. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + + /** + * Gets the value of the 'year' field. + * @return The value of the 'year' field. + */ + public int getYear() { + return year; + } + + + + /** + * Gets the value of the 'periodStart' field. + * @return The value of the 'periodStart' field. + */ + public long getPeriodStart() { + return periodStart; + } + + + + /** + * Gets the value of the 'periodEnd' field. + * @return The value of the 'periodEnd' field. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + + /** + * Gets the value of the 'count' field. + * @return The value of the 'count' field. + */ + public long getCount() { + return count; + } + + + + /** + * Gets the value of the 'mean' field. + * @return The value of the 'mean' field. + */ + public double getMean() { + return mean; + } + + + + /** + * Gets the value of the 'populationVariance' field. + * @return The value of the 'populationVariance' field. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + + /** + * Gets the value of the 'min' field. + * @return The value of the 'min' field. + */ + public double getMin() { + return min; + } + + + + /** + * Gets the value of the 'max' field. + * @return The value of the 'max' field. + */ + public double getMax() { + return max; + } + + + + /** + * Creates a new YearActivePowerRecord RecordBuilder. + * @return A new YearActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.YearActivePowerRecord.Builder newBuilder() { + return new theodolite.commons.model.records.YearActivePowerRecord.Builder(); + } + + /** + * Creates a new YearActivePowerRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new YearActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.YearActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.YearActivePowerRecord.Builder other) { + if (other == null) { + return new theodolite.commons.model.records.YearActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.YearActivePowerRecord.Builder(other); + } + } + + /** + * Creates a new YearActivePowerRecord RecordBuilder by copying an existing YearActivePowerRecord instance. + * @param other The existing instance to copy. + * @return A new YearActivePowerRecord RecordBuilder + */ + public static theodolite.commons.model.records.YearActivePowerRecord.Builder newBuilder(theodolite.commons.model.records.YearActivePowerRecord other) { + if (other == null) { + return new theodolite.commons.model.records.YearActivePowerRecord.Builder(); + } else { + return new theodolite.commons.model.records.YearActivePowerRecord.Builder(other); + } + } + + /** + * RecordBuilder for YearActivePowerRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<YearActivePowerRecord> + implements org.apache.avro.data.RecordBuilder<YearActivePowerRecord> { + + private java.lang.String identifier; + private int year; + private long periodStart; + private long periodEnd; + private long count; + private double mean; + private double populationVariance; + private double min; + private double max; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(theodolite.commons.model.records.YearActivePowerRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.year)) { + this.year = data().deepCopy(fields()[1].schema(), other.year); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + } + + /** + * Creates a Builder by copying an existing YearActivePowerRecord instance + * @param other The existing instance to copy. + */ + private Builder(theodolite.commons.model.records.YearActivePowerRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.identifier)) { + this.identifier = data().deepCopy(fields()[0].schema(), other.identifier); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.year)) { + this.year = data().deepCopy(fields()[1].schema(), other.year); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.periodStart)) { + this.periodStart = data().deepCopy(fields()[2].schema(), other.periodStart); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.periodEnd)) { + this.periodEnd = data().deepCopy(fields()[3].schema(), other.periodEnd); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.count)) { + this.count = data().deepCopy(fields()[4].schema(), other.count); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.mean)) { + this.mean = data().deepCopy(fields()[5].schema(), other.mean); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.populationVariance)) { + this.populationVariance = data().deepCopy(fields()[6].schema(), other.populationVariance); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.min)) { + this.min = data().deepCopy(fields()[7].schema(), other.min); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.max)) { + this.max = data().deepCopy(fields()[8].schema(), other.max); + fieldSetFlags()[8] = true; + } + } + + /** + * Gets the value of the 'identifier' field. + * @return The value. + */ + public java.lang.String getIdentifier() { + return identifier; + } + + + /** + * Sets the value of the 'identifier' field. + * @param value The value of 'identifier'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setIdentifier(java.lang.String value) { + validate(fields()[0], value); + this.identifier = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'identifier' field has been set. + * @return True if the 'identifier' field has been set, false otherwise. + */ + public boolean hasIdentifier() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'identifier' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearIdentifier() { + identifier = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'year' field. + * @return The value. + */ + public int getYear() { + return year; + } + + + /** + * Sets the value of the 'year' field. + * @param value The value of 'year'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setYear(int value) { + validate(fields()[1], value); + this.year = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'year' field has been set. + * @return True if the 'year' field has been set, false otherwise. + */ + public boolean hasYear() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'year' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearYear() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'periodStart' field. + * @return The value. + */ + public long getPeriodStart() { + return periodStart; + } + + + /** + * Sets the value of the 'periodStart' field. + * @param value The value of 'periodStart'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setPeriodStart(long value) { + validate(fields()[2], value); + this.periodStart = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'periodStart' field has been set. + * @return True if the 'periodStart' field has been set, false otherwise. + */ + public boolean hasPeriodStart() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'periodStart' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearPeriodStart() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'periodEnd' field. + * @return The value. + */ + public long getPeriodEnd() { + return periodEnd; + } + + + /** + * Sets the value of the 'periodEnd' field. + * @param value The value of 'periodEnd'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setPeriodEnd(long value) { + validate(fields()[3], value); + this.periodEnd = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'periodEnd' field has been set. + * @return True if the 'periodEnd' field has been set, false otherwise. + */ + public boolean hasPeriodEnd() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'periodEnd' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearPeriodEnd() { + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'count' field. + * @return The value. + */ + public long getCount() { + return count; + } + + + /** + * Sets the value of the 'count' field. + * @param value The value of 'count'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setCount(long value) { + validate(fields()[4], value); + this.count = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'count' field has been set. + * @return True if the 'count' field has been set, false otherwise. + */ + public boolean hasCount() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'count' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearCount() { + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'mean' field. + * @return The value. + */ + public double getMean() { + return mean; + } + + + /** + * Sets the value of the 'mean' field. + * @param value The value of 'mean'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setMean(double value) { + validate(fields()[5], value); + this.mean = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'mean' field has been set. + * @return True if the 'mean' field has been set, false otherwise. + */ + public boolean hasMean() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'mean' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearMean() { + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'populationVariance' field. + * @return The value. + */ + public double getPopulationVariance() { + return populationVariance; + } + + + /** + * Sets the value of the 'populationVariance' field. + * @param value The value of 'populationVariance'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setPopulationVariance(double value) { + validate(fields()[6], value); + this.populationVariance = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'populationVariance' field has been set. + * @return True if the 'populationVariance' field has been set, false otherwise. + */ + public boolean hasPopulationVariance() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'populationVariance' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearPopulationVariance() { + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'min' field. + * @return The value. + */ + public double getMin() { + return min; + } + + + /** + * Sets the value of the 'min' field. + * @param value The value of 'min'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setMin(double value) { + validate(fields()[7], value); + this.min = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'min' field has been set. + * @return True if the 'min' field has been set, false otherwise. + */ + public boolean hasMin() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'min' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearMin() { + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'max' field. + * @return The value. + */ + public double getMax() { + return max; + } + + + /** + * Sets the value of the 'max' field. + * @param value The value of 'max'. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder setMax(double value) { + validate(fields()[8], value); + this.max = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'max' field has been set. + * @return True if the 'max' field has been set, false otherwise. + */ + public boolean hasMax() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'max' field. + * @return This builder. + */ + public theodolite.commons.model.records.YearActivePowerRecord.Builder clearMax() { + fieldSetFlags()[8] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public YearActivePowerRecord build() { + try { + YearActivePowerRecord record = new YearActivePowerRecord(); + record.identifier = fieldSetFlags()[0] ? this.identifier : (java.lang.String) defaultValue(fields()[0]); + record.year = fieldSetFlags()[1] ? this.year : (java.lang.Integer) defaultValue(fields()[1]); + record.periodStart = fieldSetFlags()[2] ? this.periodStart : (java.lang.Long) defaultValue(fields()[2]); + record.periodEnd = fieldSetFlags()[3] ? this.periodEnd : (java.lang.Long) defaultValue(fields()[3]); + record.count = fieldSetFlags()[4] ? this.count : (java.lang.Long) defaultValue(fields()[4]); + record.mean = fieldSetFlags()[5] ? this.mean : (java.lang.Double) defaultValue(fields()[5]); + record.populationVariance = fieldSetFlags()[6] ? this.populationVariance : (java.lang.Double) defaultValue(fields()[6]); + record.min = fieldSetFlags()[7] ? this.min : (java.lang.Double) defaultValue(fields()[7]); + record.max = fieldSetFlags()[8] ? this.max : (java.lang.Double) defaultValue(fields()[8]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter<YearActivePowerRecord> + WRITER$ = (org.apache.avro.io.DatumWriter<YearActivePowerRecord>)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader<YearActivePowerRecord> + READER$ = (org.apache.avro.io.DatumReader<YearActivePowerRecord>)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.identifier); + + out.writeInt(this.year); + + out.writeLong(this.periodStart); + + out.writeLong(this.periodEnd); + + out.writeLong(this.count); + + out.writeDouble(this.mean); + + out.writeDouble(this.populationVariance); + + out.writeDouble(this.min); + + out.writeDouble(this.max); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.identifier = in.readString(); + + this.year = in.readInt(); + + this.periodStart = in.readLong(); + + this.periodEnd = in.readLong(); + + this.count = in.readLong(); + + this.mean = in.readDouble(); + + this.populationVariance = in.readDouble(); + + this.min = in.readDouble(); + + this.max = in.readDouble(); + + } else { + for (int i = 0; i < 9; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.identifier = in.readString(); + break; + + case 1: + this.year = in.readInt(); + break; + + case 2: + this.periodStart = in.readLong(); + break; + + case 3: + this.periodEnd = in.readLong(); + break; + + case 4: + this.count = in.readLong(); + break; + + case 5: + this.mean = in.readDouble(); + break; + + case 6: + this.populationVariance = in.readDouble(); + break; + + case 7: + this.min = in.readDouble(); + break; + + case 8: + this.max = in.readDouble(); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/theodolite-benchmarks/commons/src/main/avro/ActivePower.avdl b/theodolite-benchmarks/commons/src/main/avro/ActivePower.avdl new file mode 100644 index 0000000000000000000000000000000000000000..26cbba16cc30520739c3a109fb014b0509bccba3 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/avro/ActivePower.avdl @@ -0,0 +1,19 @@ +@namespace("theodolite.commons.model.records") +protocol ActivePower { + + record ActivePowerRecord { + /** + * + */ + string identifier; + /** + * + */ + long timestamp; + /** + * + */ + double valueInW; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/avro/AggregatedActivePower.avdl b/theodolite-benchmarks/commons/src/main/avro/AggregatedActivePower.avdl new file mode 100644 index 0000000000000000000000000000000000000000..3eefad92d10f711ccb75e3d2975da61cc2bb98ca --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/avro/AggregatedActivePower.avdl @@ -0,0 +1,27 @@ +@namespace("theodolite.commons.model.records") +protocol AggregatedActivePower { + + record AggregatedActivePowerRecord { + /** + * + */ + string identifier; + /** + * + */ + long timestamp; + /** + * + */ + long count; + /** + * + */ + double sumInW; + /** + * + */ + double averageInW; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/avro/StatsActivePower.avdl b/theodolite-benchmarks/commons/src/main/avro/StatsActivePower.avdl new file mode 100644 index 0000000000000000000000000000000000000000..14fed0afc51cfdb8e7b75058ed8b9ed16f6fdf35 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/avro/StatsActivePower.avdl @@ -0,0 +1,65 @@ +@namespace("theodolite.commons.model.records") +protocol StatsActivePower { + + record HourOfDayActivePowerRecord { + string identifier; + int hourOfDay; + long periodStart; + long periodEnd; + long count; + double mean; + double populationVariance; + double min; + double max; + } + + record DayOfWeekActivePowerRecord { + string identifier; + int dayOfWeek; + long periodStart; + long periodEnd; + long count; + double mean; + double populationVariance; + double min; + double max; + } + + record HourOfWeekActivePowerRecord { + string identifier; + int dayOfWeek; + int hourOfDay; + long periodStart; + long periodEnd; + long count; + double mean; + double populationVariance; + double min; + double max; + } + + record MonthOfYearActivePowerRecord { + string identifier; + int monthOfYear; + long periodStart; + long periodEnd; + long count; + double mean; + double populationVariance; + double min; + double max; + } + + record YearActivePowerRecord { + string identifier; + int year; + long periodStart; + long periodEnd; + long count; + double mean; + double populationVariance; + double min; + double max; + } + +} \ No newline at end of file diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/commons/configuration/NameResolvingEnvironmentConfiguration.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/commons/configuration/NameResolvingEnvironmentConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..b57b49a8a000a3dd22263a0885bc9f114139679d --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/commons/configuration/NameResolvingEnvironmentConfiguration.java @@ -0,0 +1,34 @@ +package theodolite.commons.commons.configuration; + +import java.util.Locale; +import org.apache.commons.configuration2.EnvironmentConfiguration; + +/** + * {@link EnvironmentConfiguration} that automatically translates Java property file style variables + * ({@code my.variable.name}) to environment style variables ({@code MY__VARIABLE_NAME}). + */ +public class NameResolvingEnvironmentConfiguration extends EnvironmentConfiguration { + + @Override + protected Object getPropertyInternal(final String key) { + final Object value = super.getPropertyInternal(key); + if (value == null) { + return super.getPropertyInternal(formatKeyAsEnvVariable(key)); + } + return value; + } + + @Override + protected boolean containsKeyInternal(final String key) { + final boolean value = super.containsKeyInternal(key); + if (!value) { + return super.containsKeyInternal(formatKeyAsEnvVariable(key)); + } + return value; + } + + public static String formatKeyAsEnvVariable(final String key) { + return key.toUpperCase(Locale.ROOT).replace('.', '_'); + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/commons/configuration/ServiceConfigurations.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/commons/configuration/ServiceConfigurations.java new file mode 100644 index 0000000000000000000000000000000000000000..4ce2966970323b043d1b3147bfee141b441d9154 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/commons/configuration/ServiceConfigurations.java @@ -0,0 +1,120 @@ +package theodolite.commons.commons.configuration; + +import com.google.common.io.Resources; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import org.apache.commons.configuration2.CompositeConfiguration; +import org.apache.commons.configuration2.Configuration; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Helper class for creating {@link Configuration}s. + */ +public final class ServiceConfigurations { + + private static final Logger LOGGER = LoggerFactory.getLogger(ServiceConfigurations.class); + + private static final String DEFAULT_PROPERTIES_LOCATION = "META-INF/application.properties"; + private static final String USER_PROPERTIES_LOCATION = "config/application.properties"; + + private ServiceConfigurations() {} + + /** + * Create a {@link Configuration} as it typically used by microservices. More precisely, this + * means when trying to access value with a particular key, this configuration first looks for + * this key in the current environment variables, then in a properties file located in + * {@code config/application.properties}, and finally for a properties file in the classpath at + * {@code META-INF/application.properties}. + * + * @see NameResolvingEnvironmentConfiguration for details regarding the environemnt variable + * lookup. + */ + public static Configuration createWithDefaults() { + return builder() + .withEnvironmentVariables() + .withUserConfigurationFile(USER_PROPERTIES_LOCATION) + .withDefaultConfigurationFile(DEFAULT_PROPERTIES_LOCATION) + .build(); + } + + public static Builder builder() { + return new Builder(); + } + + /** + * Builder class for a {@link Configuration} for a microservice. + */ + public static class Builder { + + private final CompositeConfiguration configuration = new CompositeConfiguration(); + + private Builder() {} + + public Builder withEnvironmentVariables() { + this.configuration.addConfiguration(new NameResolvingEnvironmentConfiguration()); + return this; + } + + /** + * Add a properties file from the user's file system to the {@link Configuration}. + */ + public Builder withUserConfigurationFile(final String userPropertiesLocation) { + final Path path = Paths.get(userPropertiesLocation); + LOGGER.info("Looking for user configuration at {}", userPropertiesLocation); + if (Files.exists(path)) { + LOGGER.info("Found user configuration at {}", userPropertiesLocation); + try { + this.configuration.addConfiguration(configurations().properties(path.toFile())); + } catch (final ConfigurationException e) { + throw new IllegalArgumentException( + "Cannot load configuration from file '" + userPropertiesLocation + "'", e); + } + } else { + LOGGER.info("No user configuration found at {}", userPropertiesLocation); + } + return this; + } + + /** + * Add a properties file from the class path to the {@link Configuration}. + */ + public Builder withDefaultConfigurationFile(final String defaultPropertiesLocation) { + if (resourceExists(defaultPropertiesLocation)) { + try { + this.configuration + .addConfiguration(configurations().properties(defaultPropertiesLocation)); + } catch (final ConfigurationException e) { + throw new IllegalArgumentException( + "Cannot load configuration from ressource '" + defaultPropertiesLocation + "'", e); + } + } + return this; + } + + public Configuration build() { + return this.configuration; + } + + } + + /** + * Shortcut for long class name. + */ + private static org.apache.commons.configuration2.builder.fluent.Configurations configurations() { + // TODO Refactor when Configurations class is removed + return new org.apache.commons.configuration2.builder.fluent.Configurations(); + } + + private static boolean resourceExists(final String resourceName) { + try { + Resources.getResource(resourceName); + } catch (final IllegalArgumentException e) { + return false; + } + return true; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/configuration/events/Event.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/configuration/events/Event.java new file mode 100644 index 0000000000000000000000000000000000000000..84d95d2708f8bf4db60b60406690135bc57b007e --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/configuration/events/Event.java @@ -0,0 +1,13 @@ +package theodolite.commons.configuration.events; + +import theodolite.commons.model.sensorregistry.SensorRegistry; + +/** + * Events that could occur when modifying a {@link SensorRegistry}. Currently only a general change + * event and a status posting event are supported. + */ +public enum Event { + + SENSOR_REGISTRY_CHANGED, SENSOR_REGISTRY_STATUS; + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/configuration/events/EventSerde.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/configuration/events/EventSerde.java new file mode 100644 index 0000000000000000000000000000000000000000..9fde54eadac3ab30575223de60e083f582c94c07 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/configuration/events/EventSerde.java @@ -0,0 +1,81 @@ +package theodolite.commons.configuration.events; + +import java.nio.ByteBuffer; +import java.util.Map; +import org.apache.kafka.common.serialization.ByteBufferDeserializer; +import org.apache.kafka.common.serialization.ByteBufferSerializer; +import org.apache.kafka.common.serialization.Deserializer; +import org.apache.kafka.common.serialization.Serde; +import org.apache.kafka.common.serialization.Serdes; +import org.apache.kafka.common.serialization.Serializer; + +/** + * Provides factory methods for creating Kafka serializers and deserializers for {@link Event}s. + */ +public final class EventSerde { + + private EventSerde() {} + + public static Serde<Event> serde() { + return Serdes.serdeFrom(new EventSerializer(), new EventDeserializer()); + } + + public static Serializer<Event> serializer() { + return new EventSerializer(); + } + + public static Deserializer<Event> deserializer() { + return new EventDeserializer(); + } + + private static class EventSerializer implements Serializer<Event> { + + private static final int INT_SIZE = 4; + + private final ByteBufferSerializer byteBufferSerializer = new ByteBufferSerializer(); + + @Override + public void configure(final Map<String, ?> configs, final boolean isKey) { + this.byteBufferSerializer.configure(configs, isKey); + } + + @Override + public byte[] serialize(final String topic, final Event event) { + return this.byteBufferSerializer.serialize(topic, + ByteBuffer.allocate(INT_SIZE).putInt(event.ordinal())); + } + + @Override + public void close() { + this.byteBufferSerializer.close(); + } + + } + + private static class EventDeserializer implements Deserializer<Event> { + + private final ByteBufferDeserializer byteBufferDeserializer = new ByteBufferDeserializer(); + + @Override + public void configure(final Map<String, ?> configs, final boolean isKey) { + this.byteBufferDeserializer.configure(configs, isKey); + } + + @Override + public Event deserialize(final String topic, final byte[] data) { + final int ordinal = this.byteBufferDeserializer.deserialize(topic, data).getInt(); + for (final Event event : Event.values()) { + if (ordinal == event.ordinal()) { + return event; + } + } + throw new IllegalArgumentException("Deserialized data is not a valid event."); + } + + @Override + public void close() { + this.byteBufferDeserializer.close(); + } + + } +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/AbstractSensor.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/AbstractSensor.java new file mode 100644 index 0000000000000000000000000000000000000000..c572ca1089d2b69ef10a425251b7464db4ba1ae7 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/AbstractSensor.java @@ -0,0 +1,35 @@ +package theodolite.commons.model.sensorregistry; + +import java.util.Optional; + +abstract class AbstractSensor implements Sensor { + + private final AggregatedSensor parent; + + private final String identifier; + + private final String name; + + protected AbstractSensor(final AggregatedSensor parent, final String identifier, + final String name) { + this.parent = parent; + this.identifier = identifier; + this.name = name; + } + + @Override + public Optional<AggregatedSensor> getParent() { + return Optional.ofNullable(this.parent); + } + + @Override + public String getIdentifier() { + return this.identifier; + } + + @Override + public String getName() { + return this.name; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/AggregatedSensor.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/AggregatedSensor.java new file mode 100644 index 0000000000000000000000000000000000000000..8ac57a92b02299f9522933da1f01899e637573a6 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/AggregatedSensor.java @@ -0,0 +1,56 @@ +package theodolite.commons.model.sensorregistry; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +/** + * Representing an aggregated sensor in the {@link SensorRegistry}, i.e. one that may have child + * sensors. + */ +public interface AggregatedSensor extends Sensor { + + Collection<Sensor> getChildren(); + + /** + * Returns all {@link MachineSensor}s that are children (including grandchildren etc.) of this + * aggregated sensor. In other words, it returns all leaves located below this aggregated sensor + * in the corresponding {@link SensorRegistry}. + */ + default Collection<MachineSensor> getAllChildren() { + final List<MachineSensor> allChildren = new ArrayList<>(); + final Queue<Sensor> untraversedSensors = new LinkedList<>(this.getChildren()); + while (!untraversedSensors.isEmpty()) { + final Sensor sensor = untraversedSensors.poll(); + if (sensor instanceof MachineSensor) { + allChildren.add((MachineSensor) sensor); + } else if (sensor instanceof AggregatedSensor) { + untraversedSensors.addAll(((AggregatedSensor) sensor).getChildren()); + } + } + return allChildren; + } + + /** + * Flattens this {@link AggregatedSensor} and all of its children to a collection of + * {@link Sensor}s. + * + * @return A collection containing this {@link AggregatedSensor} and all of its children. + */ + default Collection<Sensor> flatten() { + final List<Sensor> accumulator = new ArrayList<>(); + final Queue<Sensor> untraversedSensors = new LinkedList<>(); + untraversedSensors.add(this); + while (!untraversedSensors.isEmpty()) { + final Sensor sensor = untraversedSensors.poll(); + accumulator.add(sensor); + if (sensor instanceof AggregatedSensor) { + untraversedSensors.addAll(((AggregatedSensor) sensor).getChildren()); + } + } + return accumulator; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/ImmutableSensorRegistry.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/ImmutableSensorRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..8889a11bf2617c9e806cf49b619036852c05fbbd --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/ImmutableSensorRegistry.java @@ -0,0 +1,145 @@ +package theodolite.commons.model.sensorregistry; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.common.collect.ImmutableMap; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import java.util.Collection; +import java.util.Objects; +import java.util.Optional; +import titan.ccp.model.sensorregistry.serialization.AggregatedSensorSerializer; +import titan.ccp.model.sensorregistry.serialization.MachineSensorSerializer; +import titan.ccp.model.sensorregistry.serialization.SensorRegistryDeserializer; +import titan.ccp.model.sensorregistry.serialization.SensorRegistrySerializer; + +/** + * Implementation of a {@link SensorRegistry} that is immutable. + */ +public final class ImmutableSensorRegistry implements SensorRegistry { + + private static final Gson GSON = new GsonBuilder() + .registerTypeAdapter(ImmutableSensorRegistry.class, new SensorRegistrySerializer()) + .registerTypeAdapter(ImmutableSensorRegistry.ImmutableAggregatatedSensor.class, + new AggregatedSensorSerializer()) + .registerTypeAdapter(MachineSensorImpl.class, new MachineSensorSerializer()) + .registerTypeAdapter(SensorRegistry.class, new SensorRegistryDeserializer()).create(); + + private final ImmutableMap<String, MachineSensor> machineSensors; + private final AggregatedSensor topLevelSensor; + + private ImmutableSensorRegistry(final SensorRegistry sensorRegistry) { + final ImmutableMap.Builder<String, MachineSensor> mapBuilder = ImmutableMap.builder(); + this.topLevelSensor = + new ImmutableAggregatatedSensor(null, sensorRegistry.getTopLevelSensor(), mapBuilder); + this.machineSensors = mapBuilder.build(); + } + + @Override + public Optional<MachineSensor> getSensorForIdentifier(final String identifier) { + return Optional.ofNullable(this.machineSensors.get(identifier)); + } + + @Override + public AggregatedSensor getTopLevelSensor() { + return this.topLevelSensor; + } + + @Override + public Collection<MachineSensor> getMachineSensors() { + return this.machineSensors.values(); + } + + @Override + public String toJson() { + // Necessary method. Deletion would cause SensorRegistry.toJson() to fail. + return GSON.toJson(this); + } + + @Override + public int hashCode() { + return Objects.hashCode(this.topLevelSensor); + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof SensorRegistry) { + final SensorRegistry other = (SensorRegistry) obj; + return Objects.equals(this.getTopLevelSensor(), other.getTopLevelSensor()); + } + return false; + } + + public static ImmutableSensorRegistry copyOf(final SensorRegistry sensorRegistry) { + return new ImmutableSensorRegistry(sensorRegistry); + } + + public static SensorRegistry fromJson(final String json) { + return GSON.fromJson(json, SensorRegistry.class); + } + + private static final class ImmutableAggregatatedSensor extends AbstractSensor + implements AggregatedSensor { + + private final ImmutableList<Sensor> children; + + private ImmutableAggregatatedSensor(final AggregatedSensor newParent, + final AggregatedSensor sensorToCopy, + final ImmutableMap.Builder<String, MachineSensor> sensorRegistryMapBuilder) { + super(newParent, sensorToCopy.getIdentifier(), sensorToCopy.getName()); + final Builder<Sensor> childrenBuilder = ImmutableList.builder(); + for (final Sensor child : sensorToCopy.getChildren()) { + if (child instanceof MachineSensor) { + final MachineSensor newChild = + new MachineSensorImpl(this, child.getIdentifier(), child.getName()); + childrenBuilder.add(newChild); + sensorRegistryMapBuilder.put(newChild.getIdentifier(), newChild); + } else if (child instanceof AggregatedSensor) { + final AggregatedSensor newChild = new ImmutableAggregatatedSensor(this, + (AggregatedSensor) child, sensorRegistryMapBuilder); + childrenBuilder.add(newChild); + } else { + throw new IllegalStateException( + "Sensor " + child + " is neither of type '" + + MachineSensor.class.getSimpleName() + "' nor " + + AggregatedSensor.class.getSimpleName() + "' and thus not supported."); + } + } + this.children = childrenBuilder.build(); + } + + @Override + public Collection<Sensor> getChildren() { + return this.children; + } + + @Override + public int hashCode() { + return Objects.hash(this.getIdentifier(), this.children); + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof AggregatedSensor) { + final AggregatedSensor other = (AggregatedSensor) obj; + return Objects.equals(this.getIdentifier(), other.getIdentifier()) + && Objects.equals(this.children, other.getChildren()); + } + return false; + } + + @Override + public String toString() { + return this.getName() + '[' + this.getIdentifier() + "] (" + this.children.size() + + " children)"; + } + + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MachineSensor.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MachineSensor.java new file mode 100644 index 0000000000000000000000000000000000000000..2e49cf60830421242b32adbcdfb59552b38469de --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MachineSensor.java @@ -0,0 +1,25 @@ +package theodolite.commons.model.sensorregistry; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * Representing a real sensor in the {@link SensorRegistry}, i.e. one that is not aggregated. + */ +public interface MachineSensor extends Sensor { + + /** + * Get a list of parent, grandparent etc. sensors. + */ + default List<AggregatedSensor> getParents() { + Optional<AggregatedSensor> parent = this.getParent(); + final List<AggregatedSensor> parents = new ArrayList<>(); + while (parent.isPresent()) { + parents.add(parent.get()); + parent = parent.get().getParent(); + } + return parents; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MachineSensorImpl.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MachineSensorImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8e5d78bf66aab1a8c0985a3293297f183dda8510 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MachineSensorImpl.java @@ -0,0 +1,34 @@ +package theodolite.commons.model.sensorregistry; + +import java.util.Objects; + +class MachineSensorImpl extends AbstractSensor implements MachineSensor { + + protected MachineSensorImpl(final AggregatedSensor parent, final String identifier, + final String name) { + super(parent, identifier, name); + } + + @Override + public int hashCode() { + return Objects.hashCode(this.getIdentifier()); + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof MachineSensor) { + final MachineSensor other = (MachineSensor) obj; + return Objects.equals(this.getIdentifier(), other.getIdentifier()); + } + return false; + } + + @Override + public String toString() { + return this.getName() + '[' + this.getIdentifier() + ']'; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MutableAggregatedSensor.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MutableAggregatedSensor.java new file mode 100644 index 0000000000000000000000000000000000000000..1a98d92a58f12fc096bb68075c791eb60ef13a06 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MutableAggregatedSensor.java @@ -0,0 +1,96 @@ +package theodolite.commons.model.sensorregistry; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +/** + * A {@link MutableAggregatedSensor} which can child sensors be added to. + */ +public class MutableAggregatedSensor extends AbstractSensor implements AggregatedSensor { + + private final List<Sensor> children = new ArrayList<>(); + private final MutableSensorRegistry sensorRegistry; + + protected MutableAggregatedSensor(final MutableSensorRegistry registry, final String identifier, + final String name) { + super(null, identifier, name); + this.sensorRegistry = registry; + } + + protected MutableAggregatedSensor(final MutableAggregatedSensor parent, final String identifier, + final String name) { + super(parent, identifier, name); + this.sensorRegistry = parent.sensorRegistry; + } + + @Override + public Collection<Sensor> getChildren() { + return this.children; + } + + /** + * Create a new {@link MutableAggregatedSensor} as child of this sensor. + */ + public MutableAggregatedSensor addChildAggregatedSensor(final String identifier) { + return this.addChildAggregatedSensor(identifier, ""); + } + + /** + * Create a new {@link MutableAggregatedSensor} as child of this sensor. + */ + public MutableAggregatedSensor addChildAggregatedSensor(final String identifier, + final String name) { + final MutableAggregatedSensor aggregatedSensor = + new MutableAggregatedSensor(this, identifier, name); + this.children.add(aggregatedSensor); + return aggregatedSensor; + } + + /** + * Create a new {@link MachineSensor} as child of this sensor. + */ + public MachineSensor addChildMachineSensor(final String identifier) { + return this.addChildMachineSensor(identifier, ""); + } + + /** + * Create a new {@link MachineSensor} as child of this sensor. + */ + public MachineSensor addChildMachineSensor(final String identifier, final String name) { + final MachineSensorImpl machineSensor = new MachineSensorImpl(this, identifier, name); + final boolean registerResult = this.sensorRegistry.register(machineSensor); + if (!registerResult) { + throw new IllegalArgumentException( + "Sensor width identifier " + identifier + " is already registered."); + } + this.children.add(machineSensor); + return machineSensor; + } + + @Override + public int hashCode() { + return Objects.hash(this.getIdentifier(), this.children); + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof AggregatedSensor) { + final AggregatedSensor other = (AggregatedSensor) obj; + return Objects.equals(this.getIdentifier(), other.getIdentifier()) + && Objects.equals(this.children, other.getChildren()); + } + return false; + } + + @Override + public String toString() { + return this.getName() + '[' + this.getIdentifier() + "] (" + this.children.size() + + " children)"; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MutableSensorRegistry.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MutableSensorRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..5aacbc62fb249f44bdd3eb1dd783539d59815aa8 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/MutableSensorRegistry.java @@ -0,0 +1,84 @@ +package theodolite.commons.model.sensorregistry; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import theodolite.commons.model.sensorregistry.serialization.AggregatedSensorSerializer; +import theodolite.commons.model.sensorregistry.serialization.MachineSensorSerializer; +import theodolite.commons.model.sensorregistry.serialization.SensorRegistrySerializer; + +/** + * A {@link SensorRegistry} to which sensors can be added. + */ +public class MutableSensorRegistry implements SensorRegistry { + + private static final Gson GSON = new GsonBuilder() + .registerTypeAdapter(MutableSensorRegistry.class, new SensorRegistrySerializer()) + .registerTypeAdapter(MutableAggregatedSensor.class, new AggregatedSensorSerializer()) + .registerTypeAdapter(MachineSensorImpl.class, new MachineSensorSerializer()).create(); + + // TODO HashMap for efficient access to machine sensors + private final Map<String, MachineSensorImpl> machineSensors = new HashMap<>(); + + // TODO maybe access to root + private final MutableAggregatedSensor topLevelSensor; + + public MutableSensorRegistry(final String topLevelSensorIdentifier) { + this(topLevelSensorIdentifier, ""); + } + + public MutableSensorRegistry(final String topLevelSensorIdentifier, + final String topLevelSensorName) { + this.topLevelSensor = + new MutableAggregatedSensor(this, topLevelSensorIdentifier, topLevelSensorName); + } + + @Override + public Optional<MachineSensor> getSensorForIdentifier(final String identifier) { + return Optional.ofNullable(this.machineSensors.get(identifier)); + } + + @Override + public MutableAggregatedSensor getTopLevelSensor() { + return this.topLevelSensor; + } + + @Override + public Collection<MachineSensor> getMachineSensors() { + return Collections.unmodifiableCollection(this.machineSensors.values()); + } + + protected boolean register(final MachineSensorImpl machineSensor) { + final Object oldValue = + this.machineSensors.putIfAbsent(machineSensor.getIdentifier(), machineSensor); + return oldValue == null; + } + + @Override + public int hashCode() { + return Objects.hashCode(this.topLevelSensor); + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof SensorRegistry) { + final SensorRegistry other = (SensorRegistry) obj; + return Objects.equals(this.getTopLevelSensor(), other.getTopLevelSensor()); + } + return false; + } + + @Override + public String toJson() { + return GSON.toJson(this); + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/Sensor.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/Sensor.java new file mode 100644 index 0000000000000000000000000000000000000000..fd0de0b8e0fd88bd6a88f088642717f6e190163a --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/Sensor.java @@ -0,0 +1,16 @@ +package theodolite.commons.model.sensorregistry; + +import java.util.Optional; + +/** + * Class representing a sensor in the {@link SensorRegistry}. + */ +public interface Sensor { + + Optional<AggregatedSensor> getParent(); + + String getIdentifier(); + + String getName(); + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/SensorRegistry.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/SensorRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..f8540ba2d6309aec93077eeb35fb91e1f6f44179 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/SensorRegistry.java @@ -0,0 +1,45 @@ +package theodolite.commons.model.sensorregistry; + +import java.util.Collection; +import java.util.Optional; + +/** + * Hierarchical data structure (i.e. a tree) for organizing sensors. A {@link SensorRegistry} has + * one top-level sensor which can have multiple child sensors. These sensors can either be real + * {@link MachineSensor}s or {@link AggregatedSensor}s, having child sensors. + */ +public interface SensorRegistry { + + Optional<MachineSensor> getSensorForIdentifier(final String identifier); + + AggregatedSensor getTopLevelSensor(); + + Collection<MachineSensor> getMachineSensors(); + + /** + * Flattens the hierarchy to a collection of all contained {@link Sensor}s. + * + * @return A collection of all {@link Sensor}s contained in the hierarchy. + */ + default Collection<Sensor> flatten() { + return this.getTopLevelSensor().flatten(); + } + + /** + * Converts this sensor registry into a json string. + * + * <p> + * Per default a copy of this sensor registry is created to ensure that proper (de)serializers + * exist. If subclasses have appropriate serdes, they should override this method. + * </p> + */ + default String toJson() { + final ImmutableSensorRegistry immutableSensorRegistry = ImmutableSensorRegistry.copyOf(this); + return immutableSensorRegistry.toJson(); + } + + static SensorRegistry fromJson(final String json) { + return ImmutableSensorRegistry.fromJson(json); + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/AggregatedSensorSerializer.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/AggregatedSensorSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..9ee6ae9ab7fa76d3abe74bc350ddbaf7360c98cc --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/AggregatedSensorSerializer.java @@ -0,0 +1,25 @@ +package theodolite.commons.model.sensorregistry.serialization; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import java.lang.reflect.Type; +import theodolite.commons.model.sensorregistry.AggregatedSensor; + +/** + * {@link JsonSerializer} for {@link AggregatedSensor}s. + */ +public final class AggregatedSensorSerializer implements JsonSerializer<AggregatedSensor> { + + @Override + public JsonElement serialize(final AggregatedSensor sensor, final Type type, + final JsonSerializationContext context) { + final JsonObject jsonSensorObject = new JsonObject(); + jsonSensorObject.addProperty("identifier", sensor.getIdentifier()); + jsonSensorObject.addProperty("name", sensor.getName()); + jsonSensorObject.add("children", context.serialize(sensor.getChildren())); + return jsonSensorObject; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/MachineSensorSerializer.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/MachineSensorSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..9eb1195606ca2f3b586834667a2d1cbb95386f85 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/MachineSensorSerializer.java @@ -0,0 +1,24 @@ +package theodolite.commons.model.sensorregistry.serialization; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import java.lang.reflect.Type; +import theodolite.commons.model.sensorregistry.MachineSensor; + +/** + * {@link JsonSerializer} for {@link MachineSensor}s. + */ +public final class MachineSensorSerializer implements JsonSerializer<MachineSensor> { + + @Override + public JsonElement serialize(final MachineSensor sensor, final Type type, + final JsonSerializationContext context) { + final JsonObject jsonSensorObject = new JsonObject(); + jsonSensorObject.addProperty("identifier", sensor.getIdentifier()); + jsonSensorObject.addProperty("name", sensor.getName()); + return jsonSensorObject; + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/SensorRegistryDeserializer.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/SensorRegistryDeserializer.java new file mode 100644 index 0000000000000000000000000000000000000000..1e8f495c94dabe8aacdd349b2cc5c6e425cd1070 --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/SensorRegistryDeserializer.java @@ -0,0 +1,121 @@ +package theodolite.commons.model.sensorregistry.serialization; + +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import java.lang.reflect.Type; +import theodolite.commons.model.sensorregistry.AggregatedSensor; +import theodolite.commons.model.sensorregistry.ImmutableSensorRegistry; +import theodolite.commons.model.sensorregistry.MutableAggregatedSensor; +import theodolite.commons.model.sensorregistry.MutableSensorRegistry; +import theodolite.commons.model.sensorregistry.SensorRegistry; + +/** + * {@link JsonDeserializer} for {@link AggregatedSensor}s. + */ +public final class SensorRegistryDeserializer implements JsonDeserializer<SensorRegistry> { + + private static final String IDENTIFIER_KEY = "identifier"; + + private static final String NAME_KEY = "name"; + + private static final String CHILDREN_KEY = "children"; + + @Override + public SensorRegistry deserialize(final JsonElement jsonElement, final Type type, + final JsonDeserializationContext context) throws JsonParseException { + final MutableSensorRegistry sensorRegistry = this.transformTopLevelSensor(jsonElement); + + return ImmutableSensorRegistry.copyOf(sensorRegistry); + } + + private MutableSensorRegistry transformTopLevelSensor(final JsonElement jsonElement) { + final SensorParseResult parseResult = this.parseSensor(jsonElement); // + if (parseResult == null) { + // create empty registry + return new MutableSensorRegistry("", ""); + } else { + // create registry from result + final MutableSensorRegistry sensorRegistry = + new MutableSensorRegistry(parseResult.identifier, parseResult.name); + if (parseResult.children != null) { + for (final JsonElement childJsonElement : parseResult.children) { + this.addSensor(childJsonElement, sensorRegistry.getTopLevelSensor()); + } + } + return sensorRegistry; + } + } + + private void addSensor(final JsonElement jsonElement, + final MutableAggregatedSensor parentSensor) { + final SensorParseResult parseResult = this.parseSensor(jsonElement); + if (parseResult != null) { + // create child sensor from result + if (parseResult.children == null) { + // create MachineSensor + parentSensor.addChildMachineSensor(parseResult.identifier, parseResult.name); + } else { + // create Aggregated Sensor + final MutableAggregatedSensor sensor = + parentSensor.addChildAggregatedSensor(parseResult.identifier, parseResult.name); + for (final JsonElement childJsonElement : parseResult.children) { + this.addSensor(childJsonElement, sensor); + } + } + } + } + + // returns null if invalid JsonElement + private SensorParseResult parseSensor(final JsonElement jsonElement) { + if (jsonElement.isJsonObject()) { + final JsonObject jsonObject = jsonElement.getAsJsonObject(); + if (jsonObject.has(IDENTIFIER_KEY)) { + final JsonElement identifierJsonElement = jsonObject.get(IDENTIFIER_KEY); + final JsonElement nameJsonElement = jsonObject.get(NAME_KEY); + if (identifierJsonElement.isJsonPrimitive() && nameJsonElement.isJsonPrimitive()) { + final JsonPrimitive identifierJsonPrimitive = identifierJsonElement.getAsJsonPrimitive(); + final JsonPrimitive nameJsonPrimitive = nameJsonElement.getAsJsonPrimitive(); + if (identifierJsonPrimitive.isString()) { + final String identifierString = identifierJsonPrimitive.getAsString(); + final String nameString = nameJsonPrimitive.getAsString(); + final JsonArray childrenJsonArray = this.parseChildren(jsonObject); + return new SensorParseResult(identifierString, nameString, childrenJsonArray); + } + } + } + } + return null; + // TODO throw exception + } + + // returns null if JsonObject does not have children or children is not an array + private JsonArray parseChildren(final JsonObject parentJsonObject) { + if (parentJsonObject.has(CHILDREN_KEY)) { + final JsonElement childrenJsonElement = parentJsonObject.get(CHILDREN_KEY); + if (childrenJsonElement.isJsonArray()) { + return childrenJsonElement.getAsJsonArray(); + } + } + return null; + // TODO throw exception + } + + private static class SensorParseResult { + private final String identifier; + private final String name; + private final JsonArray children; + + private SensorParseResult(final String identifier, final String name, + final JsonArray children) { + this.identifier = identifier; + this.children = children; + this.name = name; + } + } + +} diff --git a/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/SensorRegistrySerializer.java b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/SensorRegistrySerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..b389c582e8295d0dc35e1c92df696538906680af --- /dev/null +++ b/theodolite-benchmarks/commons/src/main/java/theodolite/commons/model/sensorregistry/serialization/SensorRegistrySerializer.java @@ -0,0 +1,20 @@ +package theodolite.commons.model.sensorregistry.serialization; + +import com.google.gson.JsonElement; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import java.lang.reflect.Type; +import theodolite.commons.model.sensorregistry.SensorRegistry; + +/** + * {@link JsonSerializer} for {@link SensorRegistry}s. + */ +public final class SensorRegistrySerializer implements JsonSerializer<SensorRegistry> { + + @Override + public JsonElement serialize(final SensorRegistry sensorRegistry, final Type type, + final JsonSerializationContext context) { + return context.serialize(sensorRegistry.getTopLevelSensor()); + } + +} diff --git a/theodolite-benchmarks/settings.gradle b/theodolite-benchmarks/settings.gradle index 0040989a8b3b02487c2d7328726b7caadb90f32f..1979f5f335444084b5421dcdba3228594a7b907e 100644 --- a/theodolite-benchmarks/settings.gradle +++ b/theodolite-benchmarks/settings.gradle @@ -1,5 +1,14 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } +} rootProject.name = 'theodolite-benchmarks' + + +include 'commons' include 'load-generator-commons' include 'kstreams-commons' include 'flink-commons'