Examples of Writable


Examples of groovy.lang.Writable

   @Deprecated
   public void merge(Template template, BindingContext context) throws Exception
   {
      context.put("_ctx", context);
      context.setGroovyTemplateService(this);
      Writable writable = template.make(context);
      writable.writeTo(context.getWriter());
   }
View Full Code Here

Examples of groovy.lang.Writable

            throw new ScriptException("Unable to compile GSP script: " + e.getMessage());
        }

        Bindings bindings = ctx.getBindings(ScriptContext.ENGINE_SCOPE);

        Writable result = template.make(bindings);

        try {
            result.writeTo(ctx.getWriter());
        } catch (IOException e) {
            throw new ScriptException("Unable to write result of script execution: " + e.getMessage());
        }

        return null;
View Full Code Here

Examples of net.nutch.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

Examples of org.apache.hadoop.io.Writable

    WebPage page = null;
    inlinkedScoreData.clear();
   
    for (NutchWritable nutchWritable : values) {
      Writable val = nutchWritable.get();
      if (val instanceof WebPageWritable) {
        page = ((WebPageWritable) val).getWebPage();
      } else {
        inlinkedScoreData.add((ScoreDatum) val);
        if (inlinkedScoreData.size() >= maxLinks) {
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

            //noinspection ThrowableInstanceNeverThrown
            call.setException(new RemoteException(WritableUtils.readString(in),
                WritableUtils.readString(in)));
          }
        } else {
          Writable value = ReflectionUtils.newInstance(valueClass, conf);
          value.readFields(in);                 // read value
          // it's possible that this call may have been cleaned up due to a RPC
          // timeout, so check if it still exists before setting the value.
          if (call != null) {
            call.setValue(value);
          }
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 = (Writable)ReflectionUtils.newInstance(paramClass, conf);           // read param
      param.readFields(dis);       
       
      Call call = new Call(id, param, this);
      synchronized (callQueue) {
        if (callQueue.size() >= maxQueueSize) {
          Call oldCall = callQueue.removeFirst();
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);
          UserGroupInformation previous = UserGroupInformation.getCurrentUGI();
          UserGroupInformation.setCurrentUGI(call.connection.ticket);
          try {
            value = call(call.param, call.receivedTime);             // make the call
          } catch (Throwable e) {
            LOG.info(getName()+", call "+call+": error: " + e, e);
            errorClass = e.getClass().getName();
            error = StringUtils.stringifyException(e);
          }
          UserGroupInformation.setCurrentUGI(previous);
          CurCall.set(null);

          buf.reset();
          DataOutputStream out = new DataOutputStream(buf);
          out.writeInt(call.id);                // write call id
          out.writeBoolean(error != null);      // write error flag

          if (error == null) {
            value.write(out);
          } else {
            WritableUtils.writeString(out, errorClass);
            WritableUtils.writeString(out, error);
          }
          call.setResponse(ByteBuffer.wrap(buf.toByteArray()));
View Full Code Here

Examples of org.apache.hadoop.io.Writable

        reporter.progress();
      }
    }
   
    private void spill(RawKeyValueIterator resultIter) throws IOException {
      Writable key = null;
      Writable value = null;

      try {
        // indicate progress, since constructor may take a while (because of
        // user code)
        reporter.progress();
        key = (WritableComparable)ReflectionUtils.newInstance(keyClass, job);
        value = (Writable)ReflectionUtils.newInstance(valClass, job);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }

      DataInputBuffer keyIn = new DataInputBuffer();
      DataInputBuffer valIn = new DataInputBuffer();
      DataOutputBuffer valOut = new DataOutputBuffer();
      while (resultIter.next()) {
        keyIn.reset(resultIter.getKey().getData(),
                    resultIter.getKey().getLength());
        key.readFields(keyIn);
        valOut.reset();
        (resultIter.getValue()).writeUncompressedBytes(valOut);
        valIn.reset(valOut.getData(), valOut.getLength());
        value.readFields(valIn);
        writer.append(key, value);
        reporter.progress();
      }
    }
View Full Code Here

Examples of org.apache.hadoop.io.Writable

        int entries = in.readInt();

        // Then read each key/value pair

        for (int i = 0; i < entries; i++) {
            Writable key = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf());

            key.readFields(in);

            Writable value = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf());

            value.readFields(in);
            instance.put(key, value);
        }
    }
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.