Search in sources :

Example 1 with DefaultRecord

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);
    }
}
Also used : DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord)

Example 2 with DefaultRecord

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);
}
Also used : LongColumn(com.alibaba.datax.common.element.LongColumn) Column(com.alibaba.datax.common.element.Column) LongColumn(com.alibaba.datax.common.element.LongColumn) DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord) DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord) Record(com.alibaba.datax.common.element.Record) Test(org.junit.Test)

Example 3 with DefaultRecord

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);
    }
}
Also used : DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord)

Aggregations

DefaultRecord (com.alibaba.datax.core.transport.record.DefaultRecord)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Column (com.alibaba.datax.common.element.Column)1 LongColumn (com.alibaba.datax.common.element.LongColumn)1 Record (com.alibaba.datax.common.element.Record)1 Test (org.junit.Test)1