@Override public DataByteArray exec(Tuple input) throws IOException { byte[] bytes = (byte[]) input.get(0); byteArray.set(bytes); return byteArray; } }
public static void main(String[] args){ String s = "bla"; DataByteArray dba = new DataByteArray(); dba.set(s.getBytes()); System.out.println(dba.toString()); } }
/** * 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)); } }
private Object getCurrentKeyObject() throws IOException, InterruptedException { DataInputBuffer ibuf = (DataInputBuffer) reader.getCurrentKey(); keyDataByteArray.set(Arrays.copyOf(ibuf.getData(), ibuf.getLength())); return config.keyConverter.bytesToObject(keyDataByteArray); }
/** * 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; }
private Object getCurrentValueObject() throws IOException, InterruptedException { DataInputBuffer ibuf = (DataInputBuffer) reader.getCurrentValue(); valueDataByteArray.set(Arrays.copyOf(ibuf.getData(), ibuf.getLength())); return config.valueConverter.bytesToObject(valueDataByteArray); } }
@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; }
if (w instanceof BytesWritable) { DataByteArray dba = new DataByteArray(); dba.set(((BytesWritable) w).copyBytes()); return dba;