com.xxdb.data.BasicByteMatrix Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dolphindb-javaapi Show documentation
Show all versions of dolphindb-javaapi Show documentation
The messaging and data conversion protocol between Java and DolphinDB server
package com.xxdb.data;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xxdb.io.ExtendedDataInput;
import com.xxdb.io.ExtendedDataOutput;
/**
*
* Corresponds to DolphinDB char matrix
*
*/
public class BasicByteMatrix extends AbstractMatrix{
private byte[] values;
public BasicByteMatrix(int rows, int columns){
super(rows, columns);
values = new byte[rows * columns];
}
public BasicByteMatrix(int rows, int columns, List listOfArrays) throws Exception {
super(rows,columns);
values = new byte[rows*columns];
if (listOfArrays == null || listOfArrays.size() != columns)
throw new Exception("input list of arrays does not have " + columns + " columns");
for (int i=0; i getElementClass(){
return BasicByte.class;
}
@Override
protected void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput in) throws IOException{
int size = rows * columns;
values =new byte[size];
int off = 0;
while (off < size) {
int len = Math.min(BUF_SIZE, size - off);
in.readFully(values, off, len);
off += len;
}
}
protected void writeVectorToOutputStream(ExtendedDataOutput out) throws IOException{
for(byte value : values)
out.writeByte(value);
}
@JsonIgnore
@Override
public int getScale() {
return super.getScale();
}
}