org.apache.pig.data.DataByteArray.set()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中org.apache.pig.data.DataByteArray.set()方法的一些代码示例,展示了DataByteArray.set()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataByteArray.set()方法的具体详情如下:
包路径:org.apache.pig.data.DataByteArray
类名称:DataByteArray
方法名:set

DataByteArray.set介绍

[英]Set the internal byte array. This should not be called unless the default constructor was used.
[中]设置内部字节数组。除非使用默认构造函数,否则不应调用此函数。

代码示例

代码示例来源:origin: pl.edu.icm.coansys/commons

@Override
  public DataByteArray exec(Tuple input) throws IOException {
    byte[] bytes = (byte[]) input.get(0);
    byteArray.set(bytes);
    return byteArray;
  }
}

代码示例来源:origin: pl.edu.icm.coansys/commons

public static void main(String[] args){
    String s = "bla";
    DataByteArray dba = new DataByteArray();
    dba.set(s.getBytes());
    System.out.println(dba.toString());
  }
}

代码示例来源:origin: org.apache.pig/pig

/**
 * This method calls the set method of the underlying DataByteArray with one exception:
 * if given a RubyDataByteArray, it will set the encapsulated DataByteArray to be equal.
 *
 * @param arg an object to set the encapsulated DataByteArray's bits to. In the case of
 *            a RubyString or byte array, the underlying bytes will be sit directly. In
 *            the case of a RubyDataByteArray, the encapsulated DataByteArray will be set
 *            equal to arg.
 */
@JRubyMethod
public void set(IRubyObject arg) {
  if (arg instanceof RubyDataByteArray) {
    internalDBA = ((RubyDataByteArray)arg).getDBA();
  } else if (arg instanceof RubyString) {
    internalDBA.set(arg.toString());
  } else {
    internalDBA.set((byte[])arg.toJava(byte[].class));
  }
}

代码示例来源:origin: com.twitter.elephantbird/elephant-bird-pig

private Object getCurrentKeyObject() throws IOException, InterruptedException {
 DataInputBuffer ibuf = (DataInputBuffer) reader.getCurrentKey();
 keyDataByteArray.set(Arrays.copyOf(ibuf.getData(), ibuf.getLength()));
 return config.keyConverter.bytesToObject(keyDataByteArray);
}

代码示例来源:origin: org.apache.pig/pig

/**
 * Given a String or a set of bytes[], initializes the encapsulated DataByteArray
 * using {@link DataByteArray#set}. In the case of a DataByteArray, will copy
 * the underlying bytes.
 *
 * @param arg a value to set the encapsulated DataByteArray to. A DataByteArray
       will be copied, whereas a byte array will be encapsulated directly,
       and a string's bits will be used per {@link DataByteArray#set}.
 * @return    the initialized RubyDataByteArray
 */
@JRubyMethod
public RubyDataByteArray initialize(IRubyObject arg) {
  if (arg instanceof RubyString) {
    internalDBA.set(arg.toString());
  } else if (arg instanceof RubyDataByteArray) {
    byte[] buf1 = ((RubyDataByteArray)arg).getDBA().get();
    byte[] buf2 = new byte[buf1.length];
    System.arraycopy(buf1, 0, buf2, 0, buf1.length);
    internalDBA = new DataByteArray(buf2);
  } else {
    internalDBA.set((byte[])arg.toJava(byte[].class));
  }
  return this;
}

代码示例来源:origin: com.twitter.elephantbird/elephant-bird-pig

private Object getCurrentValueObject() throws IOException, InterruptedException {
  DataInputBuffer ibuf = (DataInputBuffer) reader.getCurrentValue();
  valueDataByteArray.set(Arrays.copyOf(ibuf.getData(), ibuf.getLength()));
  return config.valueConverter.bytesToObject(valueDataByteArray);
 }
}

代码示例来源:origin: pl.edu.icm.coansys/commons

@Override
public Tuple exec(Tuple input) throws IOException {
  byte[] documentProto = (byte[]) input.get(0);
  DocumentWrapper document = DocumentWrapper.parseFrom(documentProto);
  
  rowId.set(document.getRowId());
  mproto.set(document.getDocumentMetadata().toByteArray());
  cproto.set(document.getMediaContainer().toByteArray());
  
  output.set(0, rowId);
  output.set(1, mproto);
  output.set(2, cproto);
  
  return output;
}

代码示例来源:origin: pl.edu.icm.coansys/commons

if (w instanceof BytesWritable) {
  DataByteArray dba = new DataByteArray();
  dba.set(((BytesWritable) w).copyBytes());
  return dba;

相关文章

微信公众号

最新文章

更多