Search in sources :

Example 1 with ByteArrayList

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();
}
Also used : SecondaryTarget(com.ms.silverking.cloud.dht.SecondaryTarget) ByteList(it.unimi.dsi.fastutil.bytes.ByteList) ByteArrayList(it.unimi.dsi.fastutil.bytes.ByteArrayList)

Example 2 with ByteArrayList

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;
}
Also used : ByteArrayList(it.unimi.dsi.fastutil.bytes.ByteArrayList)

Example 3 with ByteArrayList

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);
}
Also used : ByteArrayList(it.unimi.dsi.fastutil.bytes.ByteArrayList)

Example 4 with ByteArrayList

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);
}
Also used : ByteArrayList(it.unimi.dsi.fastutil.bytes.ByteArrayList)

Example 5 with ByteArrayList

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);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection) Selection(tech.tablesaw.selection.Selection) ByteBuffer(java.nio.ByteBuffer) LinkedHashMap(java.util.LinkedHashMap) Column(tech.tablesaw.columns.Column) CategoricalColumn(tech.tablesaw.api.CategoricalColumn) ByteArrayList(it.unimi.dsi.fastutil.bytes.ByteArrayList) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection)

Aggregations

ByteArrayList (it.unimi.dsi.fastutil.bytes.ByteArrayList)7 SecondaryTarget (com.ms.silverking.cloud.dht.SecondaryTarget)1 ByteList (it.unimi.dsi.fastutil.bytes.ByteList)1 ByteOpenHashSet (it.unimi.dsi.fastutil.bytes.ByteOpenHashSet)1 ByteSet (it.unimi.dsi.fastutil.bytes.ByteSet)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 CategoricalColumn (tech.tablesaw.api.CategoricalColumn)1 Column (tech.tablesaw.columns.Column)1 BitmapBackedSelection (tech.tablesaw.selection.BitmapBackedSelection)1 Selection (tech.tablesaw.selection.Selection)1