static void fill(DataOutputBuffer out, long length) throws IOException { for(int i=0; i < length; ++i) { out.write(0); } }
@Override public byte[] serialize() throws IOException { DataOutputBuffer dob = new DataOutputBuffer(5); dob.writeInt(masterKeyId); dob.write(index); byte[] b = dob.getData(); dob.close(); return b; }
@Override public int read() throws IOException { int ret; if (null == inbuf || -1 == (ret = inbuf.read())) { if (!r.next(key, val)) { return -1; } byte[] tmp = key.toString().getBytes(StandardCharsets.UTF_8); outbuf.write(tmp, 0, tmp.length); outbuf.write('\t'); tmp = val.toString().getBytes(StandardCharsets.UTF_8); outbuf.write(tmp, 0, tmp.length); outbuf.write('\n'); inbuf.reset(outbuf.getData(), outbuf.getLength()); outbuf.reset(); ret = inbuf.read(); } return ret; }
/** @deprecated Call {@link #nextRaw(DataOutputBuffer,SequenceFile.ValueBytes)}. */ @Deprecated synchronized int next(DataOutputBuffer buffer) throws IOException { // Unsupported for block-compressed sequence files if (blockCompressed) { throw new IOException("Unsupported call for block-compressed" + " SequenceFiles - use SequenceFile.Reader.next(DataOutputStream, ValueBytes)"); } try { int length = readRecordLength(); if (length == -1) { return -1; } int keyLength = in.readInt(); buffer.write(in, length); return keyLength; } catch (ChecksumException e) { // checksum failure handleChecksumException(e); return next(buffer); } }
DataOutputBuffer obuf = OBUF_FACTORY.get(); obuf.reset(); obuf.write(in, nBytes); byte[] bytes = obuf.getData(); int i = 0;
/** Append a key/value pair. */ @Override public synchronized void appendRaw(byte[] keyData, int keyOffset, int keyLength, ValueBytes val) throws IOException { if (keyLength < 0) throw new IOException("negative length keys not allowed"); int valLength = val.getSize(); // Save key/value data in relevant buffers WritableUtils.writeVInt(keyLenBuffer, keyLength); keyBuffer.write(keyData, keyOffset, keyLength); WritableUtils.writeVInt(valLenBuffer, valLength); val.writeUncompressedBytes(valBuffer); // Added another key/value pair ++noBufferedRecords; // Compress and flush? int currentBlockSize = keyBuffer.getLength() + valBuffer.getLength(); if (currentBlockSize >= compressionBlockSize) { sync(); } }
/** Read a compressed buffer */ private synchronized void readBuffer(DataInputBuffer buffer, CompressionInputStream filter) throws IOException { // Read data into a temporary buffer DataOutputBuffer dataBuffer = new DataOutputBuffer(); try { int dataBufferLength = WritableUtils.readVInt(in); dataBuffer.write(in, dataBufferLength); // Set up 'buffer' connected to the input-stream buffer.reset(dataBuffer.getData(), 0, dataBuffer.getLength()); } finally { dataBuffer.close(); } // Reset the codec filter.resetState(); }
int length = inputColumnVector.length[0]; try { buffer.write(inputColumnVector.vector[0], inputColumnVector.start[0], length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe);
int length = inputColumnVector.length[0]; try { buffer.write(inputColumnVector.vector[0], inputColumnVector.start[0], length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe);
public void write(DataOutput out) throws IOException { if (firstKey == null) { Utils.writeVInt(out, 0); return; } DataOutputBuffer dob = new DataOutputBuffer(); Utils.writeVInt(dob, firstKey.size()); dob.write(firstKey.buffer()); Utils.writeVInt(out, dob.size()); out.write(dob.getData(), 0, dob.getLength()); for (TFileIndexEntry entry : index) { dob.reset(); entry.write(dob); Utils.writeVInt(out, dob.getLength()); out.write(dob.getData(), 0, dob.getLength()); } } }
int length = bw.getLength(); try { buffer.write(bytes, 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe); int length = colText.getLength(); try { buffer.write(colText.getBytes(), 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe); try { buffer.write(bytes, 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe); buffer.write(bytes, 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe);
int length = bw.getLength(); try { buffer.write(bytes, 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe); int length = colText.getLength(); try { buffer.write(colText.getBytes(), 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe); try { buffer.write(bytes, 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe); buffer.write(bytes, 0, length); } catch (IOException ioe) { throw new IllegalStateException("bad write", ioe);
@Override void commitDigest() throws IOException { if (digester == null) { throw new IOException("Called commitDigest() but digester is null"); } digestValue = digester.digest(); getChecksumWriter().write(digestValue, 0, digestValue.length); } }
int s = r.nextInt(BUFSIZE - 1); int e = r.nextInt(BUFSIZE - s) + 1; verif.write(randBytes, s, e); b.clear(); b.put(randBytes).flip();
.build(); ps.writeTo(buffer); buffer.write(buffer.getLength() - footerEnd); byte[] result = new byte[buffer.getLength()]; System.arraycopy(buffer.getData(), 0, result, 0, buffer.getLength());
blockChecksumBuf.write(checksumBytes, 0, checksumBytes.length); if (LOG.isDebugEnabled()) { LOG.debug("got reply from datanode:{} for blockIdx:{}, checksum:{}",
@Override public void write(byte b[], int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > b.length - off) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } checkStream(); out.write(b, off, len); }
public static void copy(DataInputBuffer src, DataOutputBuffer dst) throws IOException { byte[] b1 = src.getData(); int s1 = src.getPosition(); int l1 = src.getLength(); dst.reset(); dst.write(b1, s1, l1 - s1); }