com.xxdb.data.BasicLongVector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-java Show documentation
Show all versions of api-java Show documentation
The messaging and data conversion protocol between Java and DolphinDB server
package com.xxdb.data;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.List;
import com.xxdb.io.ExtendedDataInput;
import com.xxdb.io.ExtendedDataOutput;
/**
*
* Corresponds to DolphinDB long vector
*
*/
public class BasicLongVector extends AbstractVector{
protected long[] values;
public BasicLongVector(int size){
this(DATA_FORM.DF_VECTOR, size);
}
public BasicLongVector(List list){
super(DATA_FORM.DF_VECTOR);
if (list != null) {
values = new long[list.size()];
for (int i=0; i= 0)
return (int)(value % buckets);
else if(value == Long.MIN_VALUE)
return -1;
else{
return (int)(((Long.MAX_VALUE % buckets) +2 + ((Long.MAX_VALUE + value) % buckets)) % buckets);
}
}
@Override
public Vector combine(Vector vector) {
BasicLongVector v = (BasicLongVector)vector;
int newSize = this.rows() + v.rows();
long[] newValue = new long[newSize];
System.arraycopy(this.values,0, newValue,0,this.rows());
System.arraycopy(v.values,0, newValue,this.rows(),v.rows());
return new BasicLongVector(newValue);
}
@Override
public boolean isNull(int index) {
return values[index] == Long.MIN_VALUE;
}
@Override
public void setNull(int index) {
values[index] = Long.MIN_VALUE;
}
@Override
public DATA_CATEGORY getDataCategory() {
return Entity.DATA_CATEGORY.INTEGRAL;
}
@Override
public DATA_TYPE getDataType() {
return Entity.DATA_TYPE.DT_LONG;
}
@Override
public int rows() {
return values.length;
}
@Override
public Class> getElementClass(){
return BasicLong.class;
}
protected void writeVectorToOutputStream(ExtendedDataOutput out) throws IOException{
out.writeLongArray(values);
}
}