@smanojkumar Can you confirm that results you are looking for are like the following? hex padded_binary nonzero_bits 0002 00000010 00000000 9 00200100 00000000 00000001 0010000...
See more...
@smanojkumar Can you confirm that results you are looking for are like the following? hex padded_binary nonzero_bits 0002 00000010 00000000 9 00200100 00000000 00000001 00100000 00000000 13 16 01100011 00010001 00000000 00010000 00000001 0 12 24 28 This sounds like some data compression game. I can't think of a practical reason to do this in SPL. Is this some sort of homework? Anyway, here is a more or less literal way to interpret your instructions: | eval idx = mvrange(0, len(hex) / 2)
| eval reverse2hex = mvreverse(mvmap(idx, substr(hex, idx*2 + 1, 2)))
| eval ASbinary=if(idx < 1, tostring(tonumber(reverse2hex,16),"binary"), mvmap(reverse2hex, tostring(tonumber(reverse2hex,16),"binary")))
| eval padded_binary = if(idx < 1, printf("%08d", ASbinary), mvmap(ASbinary, printf("%08d", ASbinary)))
| eval reverse_bits = mvreverse(mvmap(padded_binary, split(padded_binary, ""))), position = -1
| foreach reverse_bits mode=multivalue
[eval position = position + 1, nonzero_bits = if(<<ITEM>> == 0, nonzero_bits, mvappend(nonzero_bits, position))]
| fields hex padded_binary nonzero_bits Note mvreverse on padded binary is sort of expensive and can be avoided by arithmetics if there are lots of data. Here is the emulation of the three examples you give: | makeresults format=csv data="hex
0002
00200100
01100011"
``` data emulation above ``` Apply the algorithm to this emulation gives the results tabulated at the top.