public void testFailureNegativeLength() throws IOException { if (skip) return; try { writer.append("keyX".getBytes(), 0, -1, "valueX".getBytes(), 0, 6); Assert.fail("Error on handling negative length."); } catch (Exception e) { // noop, expecting exceptions } closeOutput(); }
public void testFailureKeyLongerThan64K() throws IOException { if (skip) return; byte[] buf = new byte[64 * K + 1]; Random rand = new Random(); rand.nextBytes(buf); try { writer.append(buf, "valueX".getBytes()); } catch (IndexOutOfBoundsException e) { // noop, expecting exceptions } closeOutput(); }
@Override public void setUp() throws IOException { conf = new Configuration(); path = new Path(ROOT, outputFile); fs = path.getFileSystem(conf); out = fs.create(path); writer = new Writer(out, BLOCK_SIZE, compression, null, conf); writer.append("keyZ".getBytes(), "valueZ".getBytes()); writer.append("keyM".getBytes(), "valueM".getBytes()); writer.append("keyN".getBytes(), "valueN".getBytes()); writer.append("keyA".getBytes(), "valueA".getBytes()); closeOutput(); }
@Override public void append(BytesWritable key, BytesWritable value) throws IOException { writer.append(key.get(), 0, key.getSize(), value.get(), 0, value .getSize()); }
@Test public void testFailureNegativeLength() throws IOException { if (skip) return; try { writer.append("keyX".getBytes(), 0, -1, "valueX".getBytes(), 0, 6); Assert.fail("Error on handling negative length."); } catch (Exception e) { // noop, expecting exceptions } closeOutput(); }
@Test public void testFailureNegativeOffset() throws IOException { if (skip) return; try { writer.append("keyX".getBytes(), -1, 4, "valueX".getBytes(), 0, 6); Assert.fail("Error on handling negative offset."); } catch (Exception e) { // noop, expecting exceptions } closeOutput(); }
private void writeEmptyRecords(Writer writer, int n) throws IOException { byte[] key = new byte[0]; byte[] value = new byte[0]; for (int i = 0; i < n; i++) { writer.append(key, value); } }
private int writeLargeRecords(Writer writer, int start, int n) throws IOException { byte[] value = new byte[largeVal]; for (int i = start; i < (start + n); i++) { String key = String.format(localFormatter, i); writer.append(key.getBytes(), value); writer.append(key.getBytes(), value); } return (start + n); }
@Test public void testFailureOutOfOrderKeys() throws IOException { if (skip) return; try { writer.append("keyM".getBytes(), "valueM".getBytes()); writer.append("keyA".getBytes(), "valueA".getBytes()); Assert.fail("Error on handling out of order keys."); } catch (Exception e) { // noop, expecting exceptions // e.printStackTrace(); } closeOutput(); }
@Test public void testFailureKeyLongerThan64K() throws IOException { if (skip) return; byte[] buf = new byte[64 * K + 1]; Random rand = new Random(); rand.nextBytes(buf); try { writer.append(buf, "valueX".getBytes()); } catch (IndexOutOfBoundsException e) { // noop, expecting exceptions } closeOutput(); }
static long writeRecords(Writer writer, int count) throws IOException { long rawDataSize = 0; int nx; for (nx = 0; nx < count; nx++) { byte[] key = composeSortedKey(KEY, count, nx).getBytes(); byte[] value = (VALUE + nx).getBytes(); writer.append(key, value); rawDataSize += WritableUtils.getVIntSize(key.length) + key.length + WritableUtils.getVIntSize(value.length) + value.length; } return rawDataSize; }
private int writeLargeRecords(Writer writer, int start, int n) throws IOException { byte[] value = new byte[largeVal]; for (int i = start; i < (start + n); i++) { String key = String.format(localFormatter, i); writer.append(key.getBytes(), value); writer.append(key.getBytes(), value); } return (start + n); }
@Test public void testFailureNegativeLength() throws IOException { if (skip) return; try { writer.append("keyX".getBytes(), 0, -1, "valueX".getBytes(), 0, 6); Assert.fail("Error on handling negative length."); } catch (Exception e) { // noop, expecting exceptions } closeOutput(); }
private void writeEmptyRecords(Writer writer, int n) throws IOException { byte[] key = new byte[0]; byte[] value = new byte[0]; for (int i = 0; i < n; i++) { writer.append(key, value); } }
private void writeEmptyRecords(Writer writer, int n) throws IOException { byte[] key = new byte[0]; byte[] value = new byte[0]; for (int i = 0; i < n; i++) { writer.append(key, value); } }
@Override public void append(BytesWritable key, BytesWritable value) throws IOException { writer.append(key.get(), 0, key.getSize(), value.get(), 0, value .getSize()); }
public void append(BytesWritable key, BytesWritable value) throws IOException { writer.append(key.get(), 0, key.getSize(), value.get(), 0, value .getSize()); }
@Test public void testFailureNegativeOffset() throws IOException { if (skip) return; try { writer.append("keyX".getBytes(), -1, 4, "valueX".getBytes(), 0, 6); Assert.fail("Error on handling negative offset."); } catch (Exception e) { // noop, expecting exceptions } closeOutput(); }
@Override public void append(byte[] key, byte[] value) throws IOException { writer.append(key, value); }
/** * Adding a new key-value pair to the TFile. This is synonymous to * append(key, 0, key.length, value, 0, value.length) * * @param key * Buffer for key. * @param value * Buffer for value. * @throws IOException */ public void append(byte[] key, byte[] value) throws IOException { append(key, 0, key.length, value, 0, value.length); }