Search in sources :

Example 1 with BitmaskedPairComparator

use of org.locationtech.geowave.core.store.flatten.BitmaskedPairComparator in project geowave by locationtech.

the class BaseDataStoreUtils method combineValues.

private static byte[] combineValues(final List<Pair<Integer, FieldInfo<?>>> fieldInfoList) {
    int totalLength = 0;
    Collections.sort(fieldInfoList, new BitmaskedPairComparator());
    final List<byte[]> fieldInfoBytesList = new ArrayList<>(fieldInfoList.size());
    for (final Pair<Integer, FieldInfo<?>> fieldInfoPair : fieldInfoList) {
        final FieldInfo<?> fieldInfo = fieldInfoPair.getRight();
        final ByteBuffer fieldInfoBytes = ByteBuffer.allocate(VarintUtils.unsignedIntByteLength(fieldInfo.getWrittenValue().length) + fieldInfo.getWrittenValue().length);
        VarintUtils.writeUnsignedInt(fieldInfo.getWrittenValue().length, fieldInfoBytes);
        fieldInfoBytes.put(fieldInfo.getWrittenValue());
        fieldInfoBytesList.add(fieldInfoBytes.array());
        totalLength += fieldInfoBytes.array().length;
    }
    final ByteBuffer allFields = ByteBuffer.allocate(totalLength);
    for (final byte[] bytes : fieldInfoBytesList) {
        allFields.put(bytes);
    }
    return allFields.array();
}
Also used : ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) IndexDimensionHint(org.locationtech.geowave.core.index.IndexDimensionHint) BitmaskedPairComparator(org.locationtech.geowave.core.store.flatten.BitmaskedPairComparator) FieldInfo(org.locationtech.geowave.core.store.base.IntermediaryWriteEntryInfo.FieldInfo)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 IndexDimensionHint (org.locationtech.geowave.core.index.IndexDimensionHint)1 FieldInfo (org.locationtech.geowave.core.store.base.IntermediaryWriteEntryInfo.FieldInfo)1 BitmaskedPairComparator (org.locationtech.geowave.core.store.flatten.BitmaskedPairComparator)1