com.scudata.dw.compress.IntColumn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esproc Show documentation
Show all versions of esproc Show documentation
SPL(Structured Process Language) A programming language specially for structured data computing.
package com.scudata.dw.compress;
import java.io.IOException;
import java.util.ArrayList;
import com.scudata.common.MessageManager;
import com.scudata.common.ObjectCache;
import com.scudata.common.RQException;
import com.scudata.dw.BufferReader;
import com.scudata.resources.EngineMessage;
import com.scudata.util.HashUtil;
public class IntColumn extends Column {
// ????Сֵ??ʾnull
private static final int NULL = Integer.MIN_VALUE;
// ???ݰ???洢??ÿ????Column.BLOCK_RECORD_COUNT????¼
private ArrayList blockList = new ArrayList(1024);
private int lastRecordCount = Column.BLOCK_RECORD_COUNT; // ???һ??ļ?¼??
public void addData(Object data) {
int value;
if (data instanceof Number) {
value = ((Number)data).intValue();
} else if (data == null) {
value = NULL;
} else {
// ???쳣
MessageManager mm = EngineMessage.get();
throw new RQException(mm.getMessage("ds.colTypeDif"));
}
if (lastRecordCount < Column.BLOCK_RECORD_COUNT) {
int []block = blockList.get(blockList.size() - 1);
block[lastRecordCount++] = value;
} else {
int []block = new int[Column.BLOCK_RECORD_COUNT];
block[0] = value;
blockList.add(block);
lastRecordCount = 1;
}
}
// ȡ??row?е?????
public Object getData(int row) {
// row?кţ???1??ʼ????
row--;
int []block = blockList.get(row / Column.BLOCK_RECORD_COUNT);
int value = block[row % Column.BLOCK_RECORD_COUNT];
if (value != NULL) {
//return new Integer(value);
return ObjectCache.getInteger(value);
} else {
return null;
}
}
// ȡ??row?е?????
public int getValue(int row) {
// row?кţ???1??ʼ????
row--;
int []block = blockList.get(row / Column.BLOCK_RECORD_COUNT);
int value = block[row % Column.BLOCK_RECORD_COUNT];
return value;
}
public Column clone() {
return new IntColumn();
}
public void appendData(BufferReader br) throws IOException {
addData(br.readObject());
// int value = br.readBaseInt();
//
// if (lastRecordCount < Column.BLOCK_RECORD_COUNT) {
// int []block = blockList.get(blockList.size() - 1);
// block[lastRecordCount++] = value;
// } else {
// int []block = new int[Column.BLOCK_RECORD_COUNT];
// block[0] = value;
// blockList.add(block);
// lastRecordCount = 1;
// }
}
public int[] makeHashCode(HashUtil hashUtil) {
int[] hashCol = new int[hashUtil.getCapacity()];
int row = 1;
for (int i = 0, len = blockList.size(); i < len; ++i) {
int[] array = blockList.get(i);
int arrayLen = array.length;
for (int j = 0; j < arrayLen; j++) {
int hash = hashUtil.hashCode(array[j]);
hashCol[hash] = row;
row++;
}
}
return hashCol;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy