当前位置: 首页>>代码示例>>Java>>正文


Java Writable.write方法代码示例

本文整理汇总了Java中org.apache.hadoop.io.Writable.write方法的典型用法代码示例。如果您正苦于以下问题:Java Writable.write方法的具体用法?Java Writable.write怎么用?Java Writable.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.io.Writable的用法示例。


在下文中一共展示了Writable.write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupResponse

import org.apache.hadoop.io.Writable; //导入方法依赖的package包/类
/**
 * Setup response for the IPC Call.
 * 
 * @param response buffer to serialize the response into
 * @param call {@link Call} to which we are setting up the response
 * @param status {@link Status} of the IPC call
 * @param rv return value for the IPC Call, if the call was successful
 * @param errorClass error class, if the the call failed
 * @param error error message, if the call failed
 * @throws IOException
 */
private void setupResponse(ByteArrayOutputStream response, 
                           Call call, Status status, 
                           Writable rv, String errorClass, String error) 
throws IOException {
  response.reset();
  DataOutputStream out = new DataOutputStream(response);
  out.writeInt(call.id);                // write call id
  out.writeInt(status.state);           // write status

  if (status == Status.SUCCESS) {
    rv.write(out);
  } else {
    WritableUtils.writeString(out, errorClass);
    WritableUtils.writeString(out, error);
  }
  /*if (call.connection.useWrap) {
    wrapWithSasl(response, call);
  }*/
  call.setResponse(ByteBuffer.wrap(response.toByteArray()));
}
 
开发者ID:spafka,项目名称:spark_deep,代码行数:32,代码来源:Server.java

示例2: getBytes

import org.apache.hadoop.io.Writable; //导入方法依赖的package包/类
/**
 * @param w writable
 * @return The bytes of <code>w</code> gotten by running its
 * {@link Writable#write(java.io.DataOutput)} method.
 * @throws IOException e
 * @see #getWritable(byte[], Writable)
 */
public static byte [] getBytes(final Writable w) throws IOException {
  if (w == null) {
    throw new IllegalArgumentException("Writable cannot be null");
  }
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  DataOutputStream out = new DataOutputStream(byteStream);
  try {
    w.write(out);
    out.close();
    out = null;
    return byteStream.toByteArray();
  } finally {
    if (out != null) {
      out.close();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:Writables.java

示例3: cloneWritableInto

import org.apache.hadoop.io.Writable; //导入方法依赖的package包/类
@Deprecated
public static void cloneWritableInto(Writable dst, 
                                     Writable src) throws IOException {
  CopyInCopyOutBuffer buffer = CLONE_BUFFERS.get();
  buffer.outBuffer.reset();
  src.write(buffer.outBuffer);
  buffer.moveData();
  dst.readFields(buffer.inBuffer);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:ReflectionUtils.java

示例4: cloneWritableInto

import org.apache.hadoop.io.Writable; //导入方法依赖的package包/类
@Deprecated
public static void cloneWritableInto(Writable dst, 
                                     Writable src) throws IOException {
  CopyInCopyOutBuffer buffer = cloneBuffers.get();
  buffer.outBuffer.reset();
  src.write(buffer.outBuffer);
  buffer.moveData();
  dst.readFields(buffer.inBuffer);
}
 
开发者ID:spafka,项目名称:spark_deep,代码行数:10,代码来源:ReflectionUtils.java

示例5: writeWritable

import org.apache.hadoop.io.Writable; //导入方法依赖的package包/类
public void writeWritable(Writable w) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DataOutputStream dos = new DataOutputStream(baos);
  WritableUtils.writeString(dos, w.getClass().getName());
  w.write(dos);
  dos.close();
  out.writeBytes(baos.toByteArray(), Type.WRITABLE.code);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TypedBytesWritableOutput.java

示例6: serialize

import org.apache.hadoop.io.Writable; //导入方法依赖的package包/类
@Override
public void serialize(Writable w) throws IOException {
  w.write(dataOut);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:5,代码来源:WritableSerialization.java

示例7: serialize

import org.apache.hadoop.io.Writable; //导入方法依赖的package包/类
public void serialize(Writable w) throws IOException {
  w.write(dataOut);
}
 
开发者ID:spafka,项目名称:spark_deep,代码行数:4,代码来源:WritableSerialization.java


注:本文中的org.apache.hadoop.io.Writable.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。