Examples of Writable


Examples of org.apache.hadoop.io.Writable

          if (isError) {
            UTF8 utf8 = new UTF8();
            utf8.readFields(in);                  // read error string
            call.setResult(null, utf8.toString());
          } else {
            Writable value = makeValue();
            try {
              readingCall = call;
              if(value instanceof Configurable) {
                ((Configurable) value).setConf(conf);
              }
              value.readFields(in);                 // read value
            } finally {
              readingCall = null;
            }
            call.setResult(value, null);
          }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

        Call call = calls.get(id);

        int state = in.readInt();     // read call status
        if (state == Status.SUCCESS.state) {
          Writable value = ReflectionUtils.newInstance(valueClass, conf);
          value.readFields(in);                 // read value
          call.setValue(value);
          calls.remove(id);
        } else if (state == Status.ERROR.state) {
          call.setException(new RemoteException(WritableUtils.readString(in),
                                                WritableUtils.readString(in)));
View Full Code Here

Examples of org.apache.hadoop.io.Writable

   
    // Read the data back and check
    LOG.info("Reading from the SequenceFile...");
    SequenceFile.Reader reader = new SequenceFile.Reader(fs, filePath, conf);
   
    Writable key = (Writable)reader.getKeyClass().newInstance();
    Writable value = (Writable)reader.getValueClass().newInstance();
   
    int lc = 0;
    try {
      while (reader.next(key, value)) {
        assertEquals("key" + lc, key.toString());
        assertEquals("value" + lc, value.toString());
        lc ++;
      }
    } finally {
      reader.close();
    }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

      int id = dis.readInt();                    // try to read an id
       
      if (LOG.isDebugEnabled())
        LOG.debug(" got #" + id);

      Writable param = ReflectionUtils.newInstance(paramClass, conf);//read param
      param.readFields(dis);       
       
      Call call = new Call(id, param, this);
      callQueue.put(call);              // queue the call; maybe blocked here
      incRpcCount()// Increment the rpc count
    }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

            LOG.debug(getName() + ": has #" + call.id + " from " +
                      call.connection);
         
          String errorClass = null;
          String error = null;
          Writable value = null;

          CurCall.set(call);
          try {
            // Make the call as the user via Subject.doAs, thus associating
            // the call with the Subject
View Full Code Here

Examples of org.apache.hadoop.io.Writable

        MockResult<ExSummarized> result = MockResult.create();
        Rendezvous<Writable> object = createRendezvous(
                loader,
                name.getQualifiedName(),
                result);
        Writable key = (Writable) create(loader, shuffle.getCompiled().getKeyTypeName());
        Writable value = (Writable) create(loader, shuffle.getCompiled().getValueTypeName());

        Ex1 orig = new Ex1();
        orig.setValueOption(new IntOption().modify(100));
        ExSummarized model = new ExSummarized();
        model.setValue(100);
View Full Code Here

Examples of org.apache.hadoop.io.Writable

    protected void reduce(
            SortableSlot key,
            Iterable<WritableSlot> values,
            Context context) throws IOException, InterruptedException {
        int slot = key.getSlot();
        Writable cache = objects[slot];
        Result<Writable> result = results[slot];
        for (WritableSlot holder : values) {
            holder.loadTo(cache);
            result.add(cache);
        }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

        object.set("type_decimal", new BigDecimal("1234.567"));
        object.set("type_text", new Text("Hello, world!"));
        object.set("type_date", new Date(2011, 3, 31));
        object.set("type_datetime", new DateTime(2011, 3, 31, 23, 30, 1));

        Writable writable = (Writable) object.unwrap();

        DataOutputBuffer output = new DataOutputBuffer();
        writable.write(output);

        Writable copy = (Writable) loader.newModel("Primitives").unwrap();
        DataInputBuffer input = new DataInputBuffer();
        input.reset(output.getData(), output.getLength());
        copy.readFields(input);

        assertThat(input.read(), is(-1));
        assertThat(writable, equalTo(copy));
    }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

    @SuppressWarnings("unchecked")
    private <T extends Writable> T restoreWritable(T value) {
        try {
            ByteArrayInputStream read = new ByteArrayInputStream(toBytes(value));
            DataInputStream in = new DataInputStream(read);
            Writable copy = value.getClass().newInstance();
            copy.readFields(in);
            assertThat(in.read(), is(-1));
            assertThat(copy, is((Writable) value));
            assertThat(copy.hashCode(), is(value.hashCode()));
            return (T) copy;
        } catch (Exception e) {
            throw new AssertionError(e);
        }
    }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

        try {
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            actual.clear();
            while (rs.next()) {
                Writable model;
                try {
                    model = getModelFromResultSet(rs);
                    actual.add(model);
                } catch (InstantiationException e) {
                    throw new RuntimeException(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.