Search in sources :

Example 6 with Utf8

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;
}
Also used : Utf8(org.apache.avro.util.Utf8)

Example 7 with Utf8

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);
}
Also used : Schema(org.apache.avro.Schema) Utf8(org.apache.avro.util.Utf8) GenericData(org.apache.avro.generic.GenericData) Test(org.junit.Test)

Example 8 with Utf8

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);
}
Also used : Utf8(org.apache.avro.util.Utf8) GenericData(org.apache.avro.generic.GenericData) Pair(org.apache.crunch.Pair) Test(org.junit.Test)

Example 9 with Utf8

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);
}
Also used : Utf8(org.apache.avro.util.Utf8) Test(org.junit.Test)

Example 10 with Utf8

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);
}
Also used : Tuple4(org.apache.crunch.Tuple4) Utf8(org.apache.avro.util.Utf8) GenericData(org.apache.avro.generic.GenericData) Test(org.junit.Test)

Aggregations

Utf8 (org.apache.avro.util.Utf8)123 Test (org.junit.Test)34 WebPage (org.apache.gora.examples.generated.WebPage)32 GenericRecord (org.apache.avro.generic.GenericRecord)17 Schema (org.apache.avro.Schema)14 GenericData (org.apache.avro.generic.GenericData)13 ByteBuffer (java.nio.ByteBuffer)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Employee (org.apache.gora.examples.generated.Employee)11 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 Field (org.apache.avro.Schema.Field)6 Record (org.apache.avro.generic.GenericData.Record)5 File (java.io.File)4 SpecificDatumReader (org.apache.avro.specific.SpecificDatumReader)4 Metadata (org.apache.gora.examples.generated.Metadata)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Iterator (java.util.Iterator)3 List (java.util.List)3