@Override
    public Value evaluate(Context context) {
        Tensor inputTensor = input.evaluate(context).asTensor();
        TensorType inputType = inputTensor.type();
        var meta = analyze(inputType);
        var builder = Tensor.Builder.of(meta.outputType());
        for (var iter = inputTensor.cellIterator(); iter.hasNext(); ) {
            var cell = iter.next();
            var oldAddr = cell.getKey();
            for (int bitIdx = 0; bitIdx < 8; bitIdx++) {
                var addrBuilder = new TensorAddress.Builder(meta.outputType());
                for (int i = 0; i < inputType.dimensions().size(); i++) {
                    var dim = inputType.dimensions().get(i);
                    if (dim.name().equals(meta.unpackDimension())) {
                        long newIdx = oldAddr.numericLabel(i) * 8 + bitIdx;
                        addrBuilder.add(dim.name(), newIdx);
                    } else {
                        addrBuilder.add(dim.name(), oldAddr.numericLabel(i));
                    }
                }
                var newAddr = addrBuilder.build();
                int oldValue = (int)(cell.getValue().doubleValue());
                if (endian.equals(EndianNess.BIG_ENDIAN)) {
                    float newCellValue = 1 & (oldValue >>> (7 - bitIdx));
                    builder.cell(newAddr, newCellValue);
                } else {
                    float newCellValue = 1 & (oldValue >>> bitIdx);
                    builder.cell(newAddr, newCellValue);
                }
            }
        }
        return new TensorValue(builder.build());
    }
Macro that expands to the appropriate map_subspaces magic incantation

@author arnej
searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/UnpackBitsNode.java