Package org.apache.hadoop.io

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


            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

        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

    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

        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

    @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

        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

     * @throws SQLException ResultSetから値を取得できなかった場合
     */
    private Writable getModelFromResultSet(ResultSet rs)
            throws InstantiationException, IllegalAccessException,
            NoSuchMethodException, InvocationTargetException, SQLException {
        Writable model = modelClass.newInstance();
        int columnIndex = 0;
        for (ColumnInfo info : columnInfos) {
            columnIndex++;
            String name = info.getSetterName();
            switch (info.getDataType()) {
View Full Code Here

     */
    @Deprecated
    public void load(SequenceFile.Reader reader) throws IOException {
        NullWritable key = NullWritable.get();
        for (;;) {
            Writable model;
            try {
                model = modelClass.newInstance();
            } catch (InstantiationException e) {
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
View Full Code Here

            throw new IllegalArgumentException("input must not be null"); //$NON-NLS-1$
        }
        @SuppressWarnings("unchecked")
        ModelInput<Writable> unsafe = (ModelInput<Writable>) input;
        for (;;) {
            Writable model;
            try {
                model = modelClass.newInstance();
            } catch (InstantiationException e) {
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.Writable

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.