Package org.apache.crunch

Examples of org.apache.crunch.Pair


            LOG.warn("Defaulting to write to a text file from MemPipeline");
            Path outputPath = new Path(path, "out" + outputIndex + ".txt");
            FSDataOutputStream os = fs.create(outputPath);
            if (collection instanceof PTable) {
              for (Object o : collection.materialize()) {
                Pair p = (Pair) o;
                os.writeBytes(p.first().toString());
                os.writeBytes("\t");
                os.writeBytes(p.second().toString());
                os.writeBytes("\r\n");
              }
            } else {
              for (Object o : collection.materialize()) {
                os.writeBytes(o.toString() + "\r\n");
View Full Code Here


    // test create
    TupleN newTuple = toi.create("Alice", 28, 165.2f);
    assertEquals(tuple, newTuple);
    TupleObjectInspector<Pair> poi = new TupleObjectInspector<Pair>(TupleFactory.PAIR,
        Writables.strings(), Writables.ints());
    Pair pair = poi.create("word", 29);
    assertEquals("word", pair.first());
    assertEquals(29, pair.second());
  }
View Full Code Here

            writeAvroFile(os, collection.materialize());
          } else {
            LOG.warn("Defaulting to write to a text file from MemPipeline");
            if (collection instanceof PTable) {
              for (Object o : collection.materialize()) {
                Pair p = (Pair) o;
                os.writeBytes(p.first().toString());
                os.writeBytes("\t");
                os.writeBytes(p.second().toString());
                os.writeBytes("\r\n");
              }
            } else {
              for (Object o : collection.materialize()) {
                os.writeBytes(o.toString() + "\r\n");
View Full Code Here

            FSDataOutputStream os = fs.create(outputPath);
            byte[] newLine = "\r\n".getBytes(Charsets.UTF_8);
            if (collection instanceof PTable) {
              byte[] tab = "\t".getBytes(Charsets.UTF_8);
              for (Object o : collection.materialize()) {
                Pair p = (Pair) o;
                os.write(p.first().toString().getBytes(Charsets.UTF_8));
                os.write(tab);
                os.write(p.second().toString().getBytes(Charsets.UTF_8));
                os.write(newLine);
              }
            } else {
              for (Object o : collection.materialize()) {
                os.write(o.toString().getBytes(Charsets.UTF_8));
View Full Code Here

        FileSystem fs = path.getFileSystem(conf);
        FSDataOutputStream os = fs.create(new Path(path, "out" + outputIndex));
        outputIndex++;
        if (collection instanceof PTable) {
          for (Object o : collection.materialize()) {
            Pair p = (Pair) o;
            os.writeBytes(p.first().toString());
            os.writeBytes("\t");
            os.writeBytes(p.second().toString());
            os.writeBytes("\r\n");
          }
        } else {
          for (Object o : collection.materialize()) {
            os.writeBytes(o.toString() + "\r\n");
View Full Code Here

            FSDataOutputStream os = fs.create(outputPath);
            byte[] newLine = "\r\n".getBytes(Charsets.UTF_8);
            if (collection instanceof PTable) {
              byte[] tab = "\t".getBytes(Charsets.UTF_8);
              for (Object o : collection.materialize()) {
                Pair p = (Pair) o;
                os.write(p.first().toString().getBytes(Charsets.UTF_8));
                os.write(tab);
                os.write(p.second().toString().getBytes(Charsets.UTF_8));
                os.write(newLine);
              }
            } else {
              for (Object o : collection.materialize()) {
                os.write(o.toString().getBytes(Charsets.UTF_8));
View Full Code Here

            writeAvroFile(os, collection.materialize());
          } else {
            LOG.warn("Defaulting to write to a text file from MemPipeline");
            if (collection instanceof PTable) {
              for (Object o : collection.materialize()) {
                Pair p = (Pair) o;
                os.writeBytes(p.first().toString());
                os.writeBytes("\t");
                os.writeBytes(p.second().toString());
                os.writeBytes("\r\n");
              }
            } else {
              for (Object o : collection.materialize()) {
                os.writeBytes(o.toString() + "\r\n");
View Full Code Here

        FileSystem fs = path.getFileSystem(conf);
        FSDataOutputStream os = fs.create(new Path(path, "out" + outputIndex));
        outputIndex++;
        if (collection instanceof PTable) {
          for (Object o : collection.materialize()) {
            Pair p = (Pair) o;
            os.writeBytes(p.first().toString());
            os.writeBytes("\t");
            os.writeBytes(p.second().toString());
            os.writeBytes("\r\n");
          }
        } else {
          for (Object o : collection.materialize()) {
            os.writeBytes(o.toString() + "\r\n");
View Full Code Here

      try {
        FileSystem fs = path.getFileSystem(conf);
        FSDataOutputStream os = fs.create(new Path(path, "out"));
        if (collection instanceof PTable) {
          for (Object o : collection.materialize()) {
            Pair p = (Pair) o;
            os.writeBytes(p.first().toString());
            os.writeBytes("\t");
            os.writeBytes(p.second().toString());
            os.writeBytes("\r\n");
          }
        } else {
          for (Object o : collection.materialize()) {
            os.writeBytes(o.toString() + "\r\n");
View Full Code Here

TOP

Related Classes of org.apache.crunch.Pair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.