use of com.alibaba.datax.core.transport.record.DefaultRecord in project DataX by alibaba.
the class RecordProducer method produceRecord.
public static Record produceRecord() {
try {
Record record = new DefaultRecord();
record.addColumn(ColumnProducer.produceLongColumn(1));
record.addColumn(ColumnProducer.produceStringColumn("bazhen"));
record.addColumn(ColumnProducer.produceBoolColumn(true));
record.addColumn(ColumnProducer.produceDateColumn(System.currentTimeMillis()));
record.addColumn(ColumnProducer.produceBytesColumn("bazhen".getBytes("utf-8")));
return record;
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
}
use of com.alibaba.datax.core.transport.record.DefaultRecord in project DataX by alibaba.
the class RecordExchangerTest method testMemeroySize.
@Test
public void testMemeroySize() throws Exception {
Column longColumn = ColumnProducer.produceLongColumn(1);
Column longColumn2 = new LongColumn("234567891");
Column stringColumn = ColumnProducer.produceStringColumn("sringtest");
Column boolColumn = ColumnProducer.produceBoolColumn(true);
Column dateColumn = ColumnProducer.produceDateColumn(System.currentTimeMillis());
Column bytesColumn = ColumnProducer.produceBytesColumn("test".getBytes("utf-8"));
Assert.assertEquals(longColumn.getByteSize(), 8);
Assert.assertEquals(longColumn2.getByteSize(), 9);
Assert.assertEquals(stringColumn.getByteSize(), 9);
Assert.assertEquals(boolColumn.getByteSize(), 1);
Assert.assertEquals(dateColumn.getByteSize(), 8);
Assert.assertEquals(bytesColumn.getByteSize(), 4);
Record record = new DefaultRecord();
record.addColumn(longColumn);
record.addColumn(longColumn2);
record.addColumn(stringColumn);
record.addColumn(boolColumn);
record.addColumn(dateColumn);
record.addColumn(bytesColumn);
Assert.assertEquals(record.getByteSize(), 39);
// record classSize = 80
// column classSize = 6*24
Assert.assertEquals(record.getMemorySize(), 263);
}
use of com.alibaba.datax.core.transport.record.DefaultRecord in project DataX by alibaba.
the class RecordProducer method produceRecordHasNull.
public static Record produceRecordHasNull() {
try {
Record record = new DefaultRecord();
//0
record.addColumn(ColumnProducer.produceLongColumn(1));
//1
record.addColumn(ColumnProducer.produceStringColumn("bazhen"));
//2
record.addColumn(ColumnProducer.produceBoolColumn(true));
record.addColumn(ColumnProducer.produceDateColumn(System.currentTimeMillis()));
record.addColumn(ColumnProducer.produceBytesColumn("bazhen".getBytes(//4
"utf-8")));
//5
record.addColumn(new LongColumn());
//6
record.addColumn(new StringColumn());
//7
record.addColumn(new BoolColumn());
//8
record.addColumn(new DateColumn());
//9
record.addColumn(new BytesColumn());
return record;
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
}
Aggregations