Skip to content

Commit

Permalink
Updates according to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
blootsvoets committed Aug 30, 2018
1 parent 1ad9134 commit f1bc125
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion commons/kafka/record_set.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{"name": "keySchemaVersion", "type": "int", "doc": "Key schema version for the given topic."},
{"name": "valueSchemaVersion", "type": "int", "doc": "Value schema version for the given topic."},
{"name": "projectId", "type": ["null", "string"], "doc": "Project ID of the sent data. If null, it is attempted to be deduced from the credentials.", "default": null},
{"name": "userId", "type": ["null", "string"], "doc": "Source ID of the sent data. If null, it is attempted to be deduced from the credentials.", "default": null},
{"name": "userId", "type": ["null", "string"], "doc": "User ID of the sent data. If null, it is attempted to be deduced from the credentials.", "default": null},
{"name": "sourceId", "type": "string", "doc": "Source ID of the sent data."},
{"name": "data", "type": {"type": "array", "items": "bytes", "doc": "Binary serialized Avro records."}, "doc": "Collected data. This should just contain the value records."}
]
Expand Down
18 changes: 4 additions & 14 deletions java-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ dependencies {
// Commons schemas (backend, passive remote monitoring app)
compile 'org.radarcns:radar-schemas-commons:0.4.0'
// REST API schemas (REST API, testing)
compile 'org.radarcns:radar-schemas-restapi:0.4.0'
// Questionnaire schemas (active remote monitoring app)
compile 'org.radarcns:radar-schemas-tools:0.4.0'
}
Expand All @@ -24,20 +21,13 @@ The generated code each refers to a single schema. The classes of Avro records w

```java
public class Deserialize {
public static void main(String args[]) throws Exception {
public PhoneBatteryLevel deserializeBatteryLevel(InputStream json) throws Exception {
//Instantiating the Schema.Parser class.
DatumReader<PhoneBatteryLevel> datumReader = new SpecificDatumReader<>(PhoneBatteryLevel.class);
DataFileReader<PhoneBatteryLevel> dataFileReader = new DataFileReader<>(new File("/path/to/mydata.avro"), datumReader);

System.out.println("Reading phone battery levels");
PhoneBatteryLevel batteryLevel = null;
while (dataFileReader.hasNext()) {
batteryLevel = dataFileReader.next(batteryLevel);
System.out.println("Phone battery level: " + batteryLevel);
}
System.out.println("Done");
Decoder decoder = new DecoderFactory().jsonDecoder(PhoneBatteryLevel.getClassSchema(), outputStream);
return datumReader.read(null, decoder);
}
}
```

Alternatively, use `org.radarcns.data.SpecificRecordEncoder` and `org.radarcns.data.SpecificRecordDecoder` from the `radar-commons` package.
Alternatively, use `org.radarcns.data.SpecificRecordEncoder` and `org.radarcns.data.SpecificRecordDecoder` from the [`radar-commons`](https://github.com/RADAR-base/radar-commons) package.

0 comments on commit f1bc125

Please sign in to comment.