Record implements Value, CopyableValue<Record> { public void addField(Value value) { final int num = this.numFields; setNumFields(num + 1); internallySetField(num, value); } Record();  Record(Value value);  Record(Value val1, Value val2);  Record(int numFields); int getNumFields(); void setNumFields(final int numFields); void makeSpace(int numFields); @SuppressWarnings("unchecked") T getField(final int fieldNum, final Class<T> type); @SuppressWarnings("unchecked") T getField(int fieldNum, T target); boolean getFieldInto(int fieldNum, Value target); boolean getFieldsInto(int[] positions, Value[] targets); void getFieldsIntoCheckingNull(int[] positions, Value[] targets); void setField(int fieldNum, Value value); void addField(Value value); void removeField(int fieldNum); final boolean isNull(int fieldNum); void setNull(int field); void setNull(long mask); void setNull(long[] mask); void clear(); void concatenate(Record record); void unionFields(Record other); void copyTo(Record target); @Override int getBinaryLength(); @Override Record copy(); @Override void copy(DataInputView source, DataOutputView target); Record createCopy(); void copyFrom(final Record source, final int[] sourcePositions, final int[] targetPositions); final boolean equalsFields(int[] positions, Value[] searchValues, Value[] deserializationHolders); void updateBinaryRepresenation(); @Override void write(DataOutputView out); @Override void read(DataInputView in); long serialize(DataOutputView target); void deserialize(DataInputView source);  }
@Test public void testAddField() { try { Record record = new Record(); assertTrue(record.getNumFields() == 0); record.addField(this.origVal1); assertTrue(record.getNumFields() == 1); assertTrue(origVal1.getValue().equals(record.getField(0, StringValue.class).getValue())); record = new Record(); for (int i = 0; i < 100; i++) { IntValue orig = new IntValue(this.rand.nextInt()); record.addField(orig); IntValue rec = record.getField(i, IntValue.class); assertTrue(record.getNumFields() == i + 1); assertTrue(orig.getValue() == rec.getValue()); } record = new Record(this.origVal1, this.origVal2); record.addField(this.origVal3); assertTrue(record.getNumFields() == 3); StringValue recVal1 = record.getField(0, StringValue.class); DoubleValue recVal2 = record.getField(1, DoubleValue.class); IntValue recVal3 = record.getField(2, IntValue.class); assertTrue("The value of the first field has changed", recVal1.equals(this.origVal1)); assertTrue("The value of the second field changed", recVal2.equals(this.origVal2)); assertTrue("The value of the third field has changed", recVal3.equals(this.origVal3)); } catch (Throwable t) { Assert.fail("Test failed due to an exception: " + t.getMessage()); } }