final List<byte[]> lengthDimensionAndQueryBinaries = new ArrayList<byte[]>(
dimensions);
final NumericData[] dataPerDimension = constraints.getDataPerDimension();
for (int d = 0; d < dimensions; d++) {
final DimensionField<?> dimension = dimensionFields[d];
final NumericData data = dataPerDimension[d];
final byte[] dimensionBinary = PersistenceUtils.toBinary(dimension);
final int currentDimensionByteBufferLength = (20 + dimensionBinary.length);
final ByteBuffer buf = ByteBuffer.allocate(currentDimensionByteBufferLength);
buf.putInt(dimensionBinary.length);
buf.putDouble(data.getMin());
buf.putDouble(data.getMax());
buf.put(dimensionBinary);
byteBufferLength += currentDimensionByteBufferLength;
lengthDimensionAndQueryBinaries.add(buf.array());
}
final ByteBuffer buf = ByteBuffer.allocate(byteBufferLength);