protected DataOutputBuffer writeWritable(Writable writable) throws IOException { DataOutputBuffer out = new DataOutputBuffer(1024); writable.write(out); out.flush(); return out; } }
@Override public void flush() throws IOException { checkStream(); out.flush(); }
@Override public void flush() throws IOException { checkStream(); out.flush(); }
public int readMarker(SequenceFile.Reader reader) throws IOException { if (valueBytes == null) { valueBytes = reader.createValueBytes(); } rawKey.reset(); rawValue.reset(); // valueBytes need not be reset since nextRaw call does it (and it is a private method) int status = reader.nextRaw(rawKey, valueBytes); // if we reach EOF, return -1 if (status == -1) { return -1; } // Check if the marker key is valid and return the count if (isMarkerValid()) { valueBytes.writeUncompressedBytes(rawValue); rawValue.flush(); // rawValue.getData() may return a larger byte array but Ints.fromByteArray will only read the first four bytes return Ints.fromByteArray(rawValue.getData()); } // EOF not reached and marker is not valid, then thrown an IOException since we can't make progress throw new IOException(String.format("Invalid key for num entries appended found %s, expected : %s", new String(rawKey.getData()), TxConstants.TransactionLog.NUM_ENTRIES_APPENDED)); }
protected DataOutputBuffer writeWritable(Writable writable) throws IOException { DataOutputBuffer out = new DataOutputBuffer(1024); writable.write(out); out.flush(); return out; }
protected DataOutputBuffer writeWritable(Writable writable) throws IOException { DataOutputBuffer out = new DataOutputBuffer(1024); writable.write(out); out.flush(); return out; }
public int readMarker(SequenceFile.Reader reader) throws IOException { if (valueBytes == null) { valueBytes = reader.createValueBytes(); } rawKey.reset(); rawValue.reset(); // valueBytes need not be reset since nextRaw call does it (and it is a private method) int status = reader.nextRaw(rawKey, valueBytes); // if we reach EOF, return -1 if (status == -1) { return -1; } // Check if the marker key is valid and return the count if (isMarkerValid()) { valueBytes.writeUncompressedBytes(rawValue); rawValue.flush(); // rawValue.getData() may return a larger byte array but Ints.fromByteArray will only read the first four bytes return Ints.fromByteArray(rawValue.getData()); } // EOF not reached and marker is not valid, then thrown an IOException since we can't make progress throw new IOException(String.format("Invalid key for num entries appended found %s, expected : %s", new String(rawKey.getData()), TxConstants.TransactionLog.NUM_ENTRIES_APPENDED)); }
public int readMarker(SequenceFile.Reader reader) throws IOException { if (valueBytes == null) { valueBytes = reader.createValueBytes(); } rawKey.reset(); rawValue.reset(); // valueBytes need not be reset since nextRaw call does it (and it is a private method) int status = reader.nextRaw(rawKey, valueBytes); // if we reach EOF, return -1 if (status == -1) { return -1; } // Check if the marker key is valid and return the count if (isMarkerValid()) { valueBytes.writeUncompressedBytes(rawValue); rawValue.flush(); // rawValue.getData() may return a larger byte array but Ints.fromByteArray will only read the first four bytes return Ints.fromByteArray(rawValue.getData()); } // EOF not reached and marker is not valid, then thrown an IOException since we can't make progress throw new IOException(String.format("Invalid key for num entries appended found %s, expected : %s", new String(rawKey.getData()), TxConstants.TransactionLog.NUM_ENTRIES_APPENDED)); }