如何在OrmLite中解决巨大的byte []问题

时间:2015-08-13 13:42:06

标签: java android sqlite ormlite

我有2个表格标题和二进制文件

标题如下:

@DatabaseTable(tableName = Binary.TABLE_NAME)
public class Binary {
    @DatabaseField(
            generatedId = true,
            columnName = BINARY_ID,
            dataType = DataType.LONG_OBJ)
    private Long id;

    @DatabaseField(
            columnName = BINARY_HEADER_ID,
            foreign = true,
            foreignAutoCreate = true,
            foreignAutoRefresh = true,
            //uniqueCombo = true,
            canBeNull = false, //there always must be a link to Item._ID
            columnDefinition = "integer constraint fk_4 references `"+ Header.TABLE_NAME+"`(`"+ Header.HEADER_ID+"`) on delete cascade"
    )
    private Header header=null;

    @DatabaseField(
            columnName = BINARY_ORDER,
            //uniqueCombo = true,
            canBeNull = false,
            dataType = DataType.INTEGER_OBJ,
            defaultValue = "0"
    )
    private Integer order =0;

    @DatabaseField(
            columnName = BINARY_CHUNK,
            dataType = DataType.BYTE_ARRAY)
    private byte[] chunk=null;
}

Binary是:

byte[] chunk

我的问题出现在Header字段中,因为每个块的大小都是1 mb,而且它们的数量几乎是无限的,所以当我读到Collection<Binary>记录时,OrmLite会隐式读取{{1}列出大量内容 - 因此可能导致内存耗尽。

我应该如何声明我的表来克服这个问题?

0 个答案:

没有答案