/** * @param source * @throws IOException */ public void deserialize(DataInputView source) throws IOException { read(source); }
/** * @param source * @throws IOException */ public void deserialize(DataInputView source) throws IOException { read(source); }
@Override public int compare(DataInputView source1, DataInputView source2) throws IOException { this.temp1.read(source1); this.temp2.read(source2); for (int i = 0; i < this.keyFields.length; i++) { @SuppressWarnings("rawtypes") final Key k1 = this.temp1.getField(this.keyFields[i], this.keyHolders[i]); @SuppressWarnings("rawtypes") final Key k2 = this.temp2.getField(this.keyFields[i], this.transientKeyHolders[i]); if (k1 == null || k2 == null) { throw new NullKeyFieldException(this.keyFields[i]); } @SuppressWarnings("unchecked") final int comp = k1.compareTo(k2); if (comp != 0) { return this.ascending[i] ? comp : -comp; } } return 0; }
@Test public void testEmptyRecordSerialization() { try { // test deserialize into self Record empty = new Record(); empty.write(this.out); empty.read(this.in); Assert.assertTrue("Deserialized Empty record is not another empty record.", empty.getNumFields() == 0); // test deserialize into new empty = new Record(); empty.write(this.out); empty = new Record(); empty.read(this.in); Assert.assertTrue("Deserialized Empty record is not another empty record.", empty.getNumFields() == 0); } catch (Throwable t) { Assert.fail("Test failed due to an exception: " + t.getMessage()); } }
rec.read(reader); testAllRetrievalMethods(rec, permutation2, values); rec.read(reader); testAllRetrievalMethods(rec, permutation2, values); rec.write(writer); rec = new Record(); rec.read(reader); rec.write(writer); rec = new Record(); rec.read(reader); if (i == updatePos) { rec.write(writer); rec.read(reader); rec.read(reader); rec.write(writer); rec = new Record(); rec.read(reader); rec.read(reader); testAllRetrievalMethods(rec, permutation2, values); if (i == updatePos) { rec.write(writer);
@Test public void testClear() throws IOException { try { Record record = new Record(new IntValue(42)); record.write(out); Assert.assertEquals(42, record.getField(0, IntValue.class).getValue()); record.setField(0, new IntValue(23)); record.write(out); Assert.assertEquals(23, record.getField(0, IntValue.class).getValue()); record.clear(); Assert.assertEquals(0, record.getNumFields()); Record record2 = new Record(new IntValue(42)); record2.read(in); Assert.assertEquals(42, record2.getField(0, IntValue.class).getValue()); record2.read(in); Assert.assertEquals(23, record2.getField(0, IntValue.class).getValue()); } catch (Throwable t) { Assert.fail("Test failed due to an exception: " + t.getMessage()); } }
record2.read(this.in);