Examples of Writable


Examples of org.apache.hadoop.io.Writable

   
          FileSystem outputFS = getFileSystem();
          Path outputPath = new Path(outputFS.getHomeDirectory(), "output/part-r-00000");
          Configuration conf = new Configuration();
          SequenceFile.Reader reader = new SequenceFile.Reader(outputFS, outputPath, conf);
          Writable writableKey = (Writable)
          ReflectionUtils.newInstance(reader.getKeyClass(), conf);
          Writable writableValue = (Writable)
          ReflectionUtils.newInstance(reader.getValueClass(), conf);
          List<LongWritable> expectedOutput = new ArrayList<LongWritable>();
          expectedOutput.add(new LongWritable(1));
          expectedOutput.add(new LongWritable(2));
          expectedOutput.add(new LongWritable(3));
View Full Code Here

Examples of org.apache.hadoop.io.Writable

   
      FileSystem outputFS = getFileSystem();
        Path outputPath = new Path(outputFS.getHomeDirectory(), "output/part-r-00000");
        Configuration conf = new Configuration();
        SequenceFile.Reader reader = new SequenceFile.Reader(outputFS, outputPath, conf);
        Writable writableKey = (Writable)
        ReflectionUtils.newInstance(reader.getKeyClass(), conf);
        Writable writableValue = (Writable)
        ReflectionUtils.newInstance(reader.getValueClass(), conf);
        List<Text> expectedOutput = new ArrayList<Text>();
        expectedOutput.add(new Text("Macon Kent,6269 Aenean St.,1-247-399-1051,08253"));
        expectedOutput.add(new Text("Dale Zamora,521-7792 Mauris Rd.,1-214-625-6970,90510"));
        expectedOutput.add(new Text("Charles Wood,525-9709 In Rd.,1-370-528-4758,62714"));
View Full Code Here

Examples of org.apache.hadoop.io.Writable

   
    FileSystem outputFS = getFileSystem();
    Path outputPath = new Path(outputFS.getHomeDirectory(), "output/part-r-00000");
    Configuration conf = new Configuration();
    SequenceFile.Reader reader = new SequenceFile.Reader(outputFS, outputPath, conf);
    Writable writableKey = (Writable)
    ReflectionUtils.newInstance(reader.getKeyClass(), conf);
    Writable writableValue = (Writable)
    ReflectionUtils.newInstance(reader.getValueClass(), conf);
    List<IntWritable> expectedOutput = new ArrayList<IntWritable>();
    expectedOutput.add(new IntWritable(1));
    expectedOutput.add(new IntWritable(2));
    expectedOutput.add(new IntWritable(3));
View Full Code Here

Examples of org.apache.hadoop.io.Writable

   
    List<Cluster> clusters = new ArrayList<Cluster>();
   
    SequenceFile.Reader reader = new SequenceFile.Reader(
        fs, path, conf);
    Writable key = (Writable) reader.getKeyClass()
        .newInstance();
    Writable value = (Writable) reader.getValueClass()
        .newInstance();
   
    while (reader.next(key, value)) {
      Cluster cluster = (Cluster) value;
      clusters.add(cluster);
View Full Code Here

Examples of org.apache.hadoop.io.Writable

    // read the whole file
    org.apache.hadoop.mapred.RecordReader reader =
        in.getRecordReader(splits[0], conf, Reporter.NULL);
    Object key = reader.createKey();
    Writable value = (Writable) reader.createValue();
    int rowNum = 0;
    List<? extends StructField> fields =inspector.getAllStructFieldRefs();
    IntObjectInspector intInspector =
        (IntObjectInspector) fields.get(0).getFieldObjectInspector();
    assertEquals(0.0, reader.getProgress(), 0.00001);
View Full Code Here

Examples of org.apache.hadoop.io.Writable

    // read the whole file
    org.apache.hadoop.mapred.RecordReader reader =
        in.getRecordReader(splits[0], conf, Reporter.NULL);
    Object key = reader.createKey();
    Writable value = (Writable) reader.createValue();
    List<? extends StructField> fields =inspector.getAllStructFieldRefs();
    StringObjectInspector strInspector = (StringObjectInspector)
        fields.get(0).getFieldObjectInspector();
    assertEquals(true, reader.next(key, value));
    assertEquals("owen", strInspector.getPrimitiveJavaObject(inspector.
View Full Code Here

Examples of org.apache.hadoop.io.Writable

  /** Called for each call. */
  public abstract Writable call(Writable param) throws IOException;

 
  private Writable makeParam() {
    Writable param;                               // construct param
    try {
      param = (Writable)paramClass.newInstance();
      if (param instanceof Configurable) {
        ((Configurable)param).setConf(conf);
      }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

          }
       
          if (LOG.isLoggable(Level.FINE))
            LOG.fine(getName() + " got #" + id);
       
          Writable param = makeParam();           // read param
          param.readFields(in);       
       
          Call call = new Call(id, param, this);
       
          synchronized (callQueue) {
            callQueue.addLast(call);              // queue the call
View Full Code Here

Examples of org.apache.hadoop.io.Writable

          if (LOG.isLoggable(Level.FINE))
            LOG.fine(getName() + ": has #" + call.id + " from " +
                     call.connection.socket.getInetAddress().getHostAddress());
         
          String error = null;
          Writable value = null;
          try {
            value = call(call.param);             // make the call
          } catch (IOException e) {
            LOG.log(Level.INFO, getName() + " call error: " + e, e);
            error = getStackTrace(e);
          } catch (Exception e) {
            LOG.log(Level.INFO, getName() + " call error: " + e, e);
            error = getStackTrace(e);
          }
           
          DataOutputStream out = call.connection.out;
          synchronized (out) {
            out.writeInt(call.id);                // write call id
            out.writeBoolean(error!=null);        // write error flag
            if (error != null)
              value = new UTF8(error);
            value.write(out);                     // write value
            out.flush();
          }

        } catch (Exception e) {
          LOG.log(Level.INFO, getName() + " caught: " + e, e);
View Full Code Here

Examples of org.apache.hadoop.io.Writable

    }
    return connection;
  }

  private Writable makeValue() {
    Writable value;                             // construct value
    try {
      value = (Writable)valueClass.newInstance();
    } catch (InstantiationException e) {
      throw new RuntimeException(e.toString());
    } catch (IllegalAccessException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.