use of org.apache.avro.util.Utf8 in project hadoop by apache.
the class ReduceAttemptFinishedEvent method getDatum.
public Object getDatum() {
if (datum == null) {
datum = new ReduceAttemptFinished();
datum.setTaskid(new Utf8(attemptId.getTaskID().toString()));
datum.setAttemptId(new Utf8(attemptId.toString()));
datum.setTaskType(new Utf8(taskType.name()));
datum.setTaskStatus(new Utf8(taskStatus));
datum.setShuffleFinishTime(shuffleFinishTime);
datum.setSortFinishTime(sortFinishTime);
datum.setFinishTime(finishTime);
datum.setHostname(new Utf8(hostname));
datum.setPort(port);
if (rackName != null) {
datum.setRackname(new Utf8(rackName));
}
datum.setState(new Utf8(state));
datum.setCounters(EventWriter.toAvro(counters));
datum.setClockSplits(AvroArrayUtils.toAvro(ProgressSplitsBlock.arrayGetWallclockTime(allSplits)));
datum.setCpuUsages(AvroArrayUtils.toAvro(ProgressSplitsBlock.arrayGetCPUTime(allSplits)));
datum.setVMemKbytes(AvroArrayUtils.toAvro(ProgressSplitsBlock.arrayGetVMemKbytes(allSplits)));
datum.setPhysMemKbytes(AvroArrayUtils.toAvro(ProgressSplitsBlock.arrayGetPhysMemKbytes(allSplits)));
}
return datum;
}
use of org.apache.avro.util.Utf8 in project crunch by cloudera.
the class AvrosTest method testCollections.
@Test
public void testCollections() throws Exception {
Collection<String> j = Lists.newArrayList();
j.add("a");
j.add("b");
Schema collectionSchema = Schema.createArray(Schema.createUnion(ImmutableList.of(Avros.strings().getSchema(), Schema.create(Type.NULL))));
GenericData.Array<Utf8> w = new GenericData.Array<Utf8>(2, collectionSchema);
w.add(new Utf8("a"));
w.add(new Utf8("b"));
testInputOutputFn(Avros.collections(Avros.strings()), j, w);
}
use of org.apache.avro.util.Utf8 in project crunch by cloudera.
the class AvrosTest method testPairs.
@Test
public void testPairs() throws Exception {
AvroType<Pair<String, String>> at = Avros.pairs(Avros.strings(), Avros.strings());
Pair<String, String> j = Pair.of("a", "b");
GenericData.Record w = new GenericData.Record(at.getSchema());
w.put(0, new Utf8("a"));
w.put(1, new Utf8("b"));
testInputOutputFn(at, j, w);
}
use of org.apache.avro.util.Utf8 in project crunch by cloudera.
the class AvrosTest method testStrings.
@Test
public void testStrings() throws Exception {
String s = "abc";
Utf8 w = new Utf8(s);
testInputOutputFn(Avros.strings(), s, w);
}
use of org.apache.avro.util.Utf8 in project crunch by cloudera.
the class AvrosTest method testQuads.
@Test
@SuppressWarnings("rawtypes")
public void testQuads() throws Exception {
AvroType at = Avros.quads(Avros.strings(), Avros.strings(), Avros.strings(), Avros.strings());
Tuple4 j = Tuple4.of("a", "b", "c", "d");
GenericData.Record w = new GenericData.Record(at.getSchema());
w.put(0, new Utf8("a"));
w.put(1, new Utf8("b"));
w.put(2, new Utf8("c"));
w.put(3, new Utf8("d"));
testInputOutputFn(at, j, w);
}
Aggregations