### Question:
DefaultHCatRecord extends HCatRecord { @Override public int size() { return contents.size(); } DefaultHCatRecord();  DefaultHCatRecord(int size);  DefaultHCatRecord(List<Object> list); @Override void remove(int idx); @Override Object get(int fieldNum); @Override List<Object> getAll(); @Override void set(int fieldNum, Object val); @Override int size(); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override int hashCode(); @Override String toString(); @Override Object get(String fieldName, HCatSchema recordSchema); @Override void set(String fieldName, HCatSchema recordSchema, Object value); @Override void copy(HCatRecord r);  }### Answer:
@Test public void testGetSetByType1() throws HCatException { HCatRecord inpRec = getHCatRecords()[0]; HCatRecord newRec = new DefaultHCatRecord(inpRec.size()); HCatSchema hsch = HCatSchemaUtils.getHCatSchema( "a:tinyint,b:smallint,c:int,d:bigint,e:float,f:double,g:boolean,h:string,i:binary,j:string"); newRec.setByte("a", hsch, inpRec.getByte("a", hsch)); newRec.setShort("b", hsch, inpRec.getShort("b", hsch)); newRec.setInteger("c", hsch, inpRec.getInteger("c", hsch)); newRec.setLong("d", hsch, inpRec.getLong("d", hsch)); newRec.setFloat("e", hsch, inpRec.getFloat("e", hsch)); newRec.setDouble("f", hsch, inpRec.getDouble("f", hsch)); newRec.setBoolean("g", hsch, inpRec.getBoolean("g", hsch)); newRec.setString("h", hsch, inpRec.getString("h", hsch)); newRec.setByteArray("i", hsch, inpRec.getByteArray("i", hsch)); newRec.setString("j", hsch, inpRec.getString("j", hsch)); Assert.assertTrue(HCatDataCheckUtil.recordsEqual(newRec, inpRec)); }
@Test public void testGetSetByType2() throws HCatException { HCatRecord inpRec = getGetSet2InpRec(); HCatRecord newRec = new DefaultHCatRecord(inpRec.size()); HCatSchema hsch = HCatSchemaUtils.getHCatSchema("a:binary,b:map<string,string>,c:array<int>,d:struct<i:int>"); newRec.setByteArray("a", hsch, inpRec.getByteArray("a", hsch)); newRec.setMap("b", hsch, inpRec.getMap("b", hsch)); newRec.setList("c", hsch, inpRec.getList("c", hsch)); newRec.setStruct("d", hsch, inpRec.getStruct("d", hsch)); Assert.assertTrue(HCatDataCheckUtil.recordsEqual(newRec, inpRec)); }
@Test public void testGetSetByType3() throws HCatException { HCatRecord inpRec = getHCat13TypesRecord(); HCatRecord newRec = new DefaultHCatRecord(inpRec.size()); HCatSchema hsch = HCatSchemaUtils.getHCatSchema( "a:decimal(5,2),b:char(10),c:varchar(20),d:date,e:timestamp"); newRec.setDecimal("a", hsch, inpRec.getDecimal("a", hsch)); newRec.setChar("b", hsch, inpRec.getChar("b", hsch)); newRec.setVarchar("c", hsch, inpRec.getVarchar("c", hsch)); newRec.setDate("d", hsch, inpRec.getDate("d", hsch)); newRec.setTimestamp("e", hsch, inpRec.getTimestamp("e", hsch)); }