mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
added handling for padded var length datasets
This commit is contained in:
parent
12601ea919
commit
4796901e9f
@ -44,7 +44,23 @@ public class HdfFileToVarLengthIntArray extends AbstractHdfFileToVectorType impl
|
||||
@Override
|
||||
public int[] apply(long l) {
|
||||
Object data = getDataFrom(l);
|
||||
return extractIds(data, l);
|
||||
if (data instanceof Object[]) {
|
||||
return extractIds(data, l);
|
||||
} else if (data instanceof int[]) {
|
||||
return stripPadding((int[]) data);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported data type: " + data.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
private int[] stripPadding(int[] data) {
|
||||
int length = data.length;
|
||||
while (length > 0 && data[length - 1] == 0) {
|
||||
length--;
|
||||
}
|
||||
int[] result = new int[length];
|
||||
System.arraycopy(data, 0, result, 0, length);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,7 @@ import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.library.hdf5.from_long.AbstractHdfFileToVectorType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
@ -45,7 +46,24 @@ public class HdfFileToVarLengthIntList extends AbstractHdfFileToVectorType imple
|
||||
@Override
|
||||
public List<Integer> apply(long l) {
|
||||
Object data = getDataFrom(l);
|
||||
return extractIds(data, l);
|
||||
if (data instanceof Object[]) {
|
||||
return extractIds(data, l);
|
||||
} else if (data instanceof int[]) {
|
||||
return stripPadding((int[]) data);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported data type: " + data.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
private List<Integer> stripPadding(int[] data) {
|
||||
List<Integer> result = new ArrayList<>();
|
||||
int index = 0;
|
||||
int val = data[index];
|
||||
while (val > 0) {
|
||||
result.add(val);
|
||||
val = data[++index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user