use of it.unimi.dsi.fastutil.bytes.ByteArrayList in project SilverKing by Morgan-Stanley.
the class SecondaryTargetSerializer method serialize.
public static byte[] serialize(Set<SecondaryTarget> specs) {
ByteList list;
list = new ByteArrayList(initialBufferSize);
for (SecondaryTarget spec : specs) {
byte[] targetBytes;
list.add((byte) spec.getType().ordinal());
targetBytes = spec.getTarget().getBytes();
list.addElements(list.size(), NumConversion.shortToBytes((short) targetBytes.length));
list.addElements(list.size(), targetBytes);
}
return list.toByteArray();
}
use of it.unimi.dsi.fastutil.bytes.ByteArrayList in project symja_android_library by axkr.
the class BooleanColumn method lag.
@Override
public BooleanColumn lag(int n) {
int srcPos = n >= 0 ? 0 : 0 - n;
byte[] dest = new byte[size()];
int destPos = n <= 0 ? 0 : n;
int length = n >= 0 ? size() - n : size() + n;
for (int i = 0; i < size(); i++) {
dest[i] = BooleanColumnType.MISSING_VALUE;
}
System.arraycopy(data.toByteArray(), srcPos, dest, destPos, length);
BooleanColumn copy = emptyCopy(size());
copy.data = new ByteArrayList(dest);
copy.setName(name() + " lag(" + n + ")");
return copy;
}
use of it.unimi.dsi.fastutil.bytes.ByteArrayList in project symja_android_library by axkr.
the class ByteDictionaryMap method sortDescending.
@Override
public void sortDescending() {
byte[] elements = values.toByteArray();
ByteArrays.parallelQuickSort(elements, reverseDictionarySortComparator);
this.values = new ByteArrayList(elements);
}
use of it.unimi.dsi.fastutil.bytes.ByteArrayList in project symja_android_library by axkr.
the class ByteDictionaryMap method sortAscending.
@Override
public void sortAscending() {
byte[] elements = values.toByteArray();
ByteArrays.parallelQuickSort(elements, dictionarySortComparator);
this.values = new ByteArrayList(elements);
}
use of it.unimi.dsi.fastutil.bytes.ByteArrayList in project symja_android_library by axkr.
the class StandardTableSliceGroup method splitOn.
/**
* Splits the sourceTable table into sub-tables, grouping on the columns whose names are given in
* splitColumnNames
*/
private void splitOn(String... splitColumnNames) {
Map<ByteArray, Selection> selectionMap = new LinkedHashMap<>();
Map<ByteArray, String> sliceNameMap = new HashMap<>();
List<Column<?>> splitColumns = getSourceTable().columns(splitColumnNames);
if (containsTextColumn(splitColumns)) {
for (int i = 0; i < getSourceTable().rowCount(); i++) {
ByteArrayList byteArrayList = new ByteArrayList();
StringBuilder stringKey = new StringBuilder();
int count = 0;
for (Column<?> col : splitColumns) {
stringKey.append(col.getString(i));
if (count < splitColumns.size() - 1) {
stringKey.append(SPLIT_STRING);
}
byteArrayList.addElements(byteArrayList.size(), col.asBytes(i));
count++;
}
// Add to the matching selection.
ByteArray byteArray = new ByteArray(byteArrayList.toByteArray());
Selection selection = selectionMap.getOrDefault(byteArray, new BitmapBackedSelection());
selection.add(i);
selectionMap.put(byteArray, selection);
sliceNameMap.put(byteArray, stringKey.toString());
}
} else {
// handle the case where split is on non-text-columns
int byteSize = getByteSize(splitColumns);
for (int i = 0; i < getSourceTable().rowCount(); i++) {
StringBuilder stringKey = new StringBuilder();
ByteBuffer byteBuffer = ByteBuffer.allocate(byteSize);
int count = 0;
for (Column<?> col : splitColumns) {
stringKey.append(col.getString(i));
if (count < splitColumns.size() - 1) {
stringKey.append(SPLIT_STRING);
}
byteBuffer.put(col.asBytes(i));
count++;
}
// Add to the matching selection.
ByteArray byteArray = new ByteArray(byteBuffer.array());
Selection selection = selectionMap.getOrDefault(byteArray, new BitmapBackedSelection());
selection.add(i);
selectionMap.put(byteArray, selection);
sliceNameMap.put(byteArray, stringKey.toString());
}
}
// Construct slices for all the values in our maps
for (Entry<ByteArray, Selection> entry : selectionMap.entrySet()) {
TableSlice slice = new TableSlice(getSourceTable(), entry.getValue());
slice.setName(sliceNameMap.get(entry.getKey()));
addSlice(slice);
}
}
Aggregations