Discussão:Código Natural/Representação interna: mudanças entre as edições
Linha 3: | Linha 3: | ||
<syntaxhighlight lang="sql"> | <syntaxhighlight lang="sql"> | ||
CREATE VIEW wiki_print1_hbig AS | |||
SELECT len, | SELECT len, | ||
bitstring, | bitstring, | ||
hbig as hbig_dec, | hbig as hbig_dec, | ||
Linha 10: | Linha 10: | ||
hbig>>4 as value_dec, | hbig>>4 as value_dec, | ||
len as len_dec | len as len_dec | ||
FROM ( | FROM ( | ||
SELECT row_number() over() AS count, bitstring, | |||
natcod.vBit_to_hSml( bitstring ) as hbig, | |||
natcod.vBit_to_hSml( bitstring ) as hbig, length(bitstring) as len, | length(bitstring) as len, | ||
natcod.vbit_to_hiddenBig( bitstring ) as hidd, | natcod.vbit_to_hiddenBig( bitstring ) as hidd, | ||
natcod.vbit_to_baseh(bitstring,4,true) as b4h, | natcod.vbit_to_baseh(bitstring,4,true) as b4h, | ||
natcod.vbit_to_baseh(bitstring,16,true) as b16h | natcod.vbit_to_baseh(bitstring,16,true) as b16h | ||
FROM natcod.generate_vbit_series(11) t(bitstring) | FROM natcod.generate_vbit_series(11) t(bitstring) | ||
) | ) t2 | ||
) | ; | ||
CREATE VIEW wiki_print2_hcount AS | |||
SELECT row_number() over() AS count, bitstring, | |||
natcod.vbit_to_baseh(bitstring,16,true) as b16h, | |||
natcod.vBit_to_hCount16c48(bitstring,1::bigint) as hcount1, | |||
natcod.vBit_to_hCount16c48(bitstring,17592186044415::bigint) as hc17592186044415 | |||
FROM natcod.generate_vbit_series(11) t(bitstring) | |||
; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
<pre> | <pre> | ||
wiki_print1_hbig: | |||
len | bitstring | hbig_dec | internal_16bits | value_dec | len_dec | len | bitstring | hbig_dec | internal_16bits | value_dec | len_dec | ||
----+-------------+----------+--------------------+-----------+--------- | |||
1 | 0 | 1 | 0 00000000000 0001 | 0 | 1 | 1 | 0 | 1 | 0 00000000000 0001 | 0 | 1 | ||
2 | 00 | 2 | 0 00000000000 0010 | 0 | 2 | 2 | 00 | 2 | 0 00000000000 0010 | 0 | 2 | ||
Linha 40: | Linha 47: | ||
10 | 0000000001 | 42 | 0 00000000010 1010 | 2 | 10 | 10 | 0000000001 | 42 | 0 00000000010 1010 | 2 | 10 | ||
... | ... | ||
wiki_print2_hcount: | |||
count | bitstring | b16h | hcount1 | hc17592186044415 | |||
------+-------------+------+---------------------+--------------------- | |||
1 | 0 | G | 281474976710657 | 299067162755071 | |||
2 | 00 | H | 562949953421313 | 580542139465727 | |||
3 | 000 | J | 844424930131969 | 862017116176383 | |||
4 | 0000 | 0 | 1125899906842625 | 1143492092887039 | |||
5 | 00000 | 0G | 1407374883553281 | 1424967069597695 | |||
6 | 000000 | 0H | 1688849860263937 | 1706442046308351 | |||
7 | 0000000 | 0J | 1970324836974593 | 1987917023019007 | |||
8 | 00000000 | 00 | 2251799813685249 | 2269391999729663 | |||
9 | 000000000 | 00G | 2533274790395905 | 2550866976440319 | |||
10 | 0000000000 | 00H | 2814749767106561 | 2832341953150975 | |||
11 | 00000000000 | 00J | 3096224743817217 | 3113816929861631 | |||
12 | 00000000001 | 00K | 7599824371187713 | 7617416557232127 | |||
13 | 0000000001 | 00M | 11821949021847553 | 11839541207891967 | |||
... | |||
</pre> | </pre> | ||
=== Exemplo de comprimento 11 === | === Exemplo de comprimento 11 === |
Edição das 14h10min de 9 de agosto de 2023
Geração dos exemplos
CREATE VIEW wiki_print1_hbig AS
SELECT len,
bitstring,
hbig as hbig_dec,
'0 '||((hbig-len)>>4)::bit(11)::text ||' ' ||len::bit(4)::text internal_16bits,
hbig>>4 as value_dec,
len as len_dec
FROM (
SELECT row_number() over() AS count, bitstring,
natcod.vBit_to_hSml( bitstring ) as hbig,
length(bitstring) as len,
natcod.vbit_to_hiddenBig( bitstring ) as hidd,
natcod.vbit_to_baseh(bitstring,4,true) as b4h,
natcod.vbit_to_baseh(bitstring,16,true) as b16h
FROM natcod.generate_vbit_series(11) t(bitstring)
) t2
;
CREATE VIEW wiki_print2_hcount AS
SELECT row_number() over() AS count, bitstring,
natcod.vbit_to_baseh(bitstring,16,true) as b16h,
natcod.vBit_to_hCount16c48(bitstring,1::bigint) as hcount1,
natcod.vBit_to_hCount16c48(bitstring,17592186044415::bigint) as hc17592186044415
FROM natcod.generate_vbit_series(11) t(bitstring)
;
wiki_print1_hbig: len | bitstring | hbig_dec | internal_16bits | value_dec | len_dec ----+-------------+----------+--------------------+-----------+--------- 1 | 0 | 1 | 0 00000000000 0001 | 0 | 1 2 | 00 | 2 | 0 00000000000 0010 | 0 | 2 3 | 000 | 3 | 0 00000000000 0011 | 0 | 3 4 | 0000 | 4 | 0 00000000000 0100 | 0 | 4 5 | 00000 | 5 | 0 00000000000 0101 | 0 | 5 6 | 000000 | 6 | 0 00000000000 0110 | 0 | 6 7 | 0000000 | 7 | 0 00000000000 0111 | 0 | 7 8 | 00000000 | 8 | 0 00000000000 1000 | 0 | 8 9 | 000000000 | 9 | 0 00000000000 1001 | 0 | 9 10 | 0000000000 | 10 | 0 00000000000 1010 | 0 | 10 11 | 00000000000 | 11 | 0 00000000000 1011 | 0 | 11 11 | 00000000001 | 27 | 0 00000000001 1011 | 1 | 11 10 | 0000000001 | 42 | 0 00000000010 1010 | 2 | 10 ... wiki_print2_hcount: count | bitstring | b16h | hcount1 | hc17592186044415 ------+-------------+------+---------------------+--------------------- 1 | 0 | G | 281474976710657 | 299067162755071 2 | 00 | H | 562949953421313 | 580542139465727 3 | 000 | J | 844424930131969 | 862017116176383 4 | 0000 | 0 | 1125899906842625 | 1143492092887039 5 | 00000 | 0G | 1407374883553281 | 1424967069597695 6 | 000000 | 0H | 1688849860263937 | 1706442046308351 7 | 0000000 | 0J | 1970324836974593 | 1987917023019007 8 | 00000000 | 00 | 2251799813685249 | 2269391999729663 9 | 000000000 | 00G | 2533274790395905 | 2550866976440319 10 | 0000000000 | 00H | 2814749767106561 | 2832341953150975 11 | 00000000000 | 00J | 3096224743817217 | 3113816929861631 12 | 00000000001 | 00K | 7599824371187713 | 7617416557232127 13 | 0000000001 | 00M | 11821949021847553 | 11839541207891967 ...
Exemplo de comprimento 11
Distribuição dos comprimentos:
select len, count(*) n from wiki_print1 group by 1 order by 2 desc, 1; len | n -----+------ 11 | 2048 10 | 1024 9 | 512 8 | 256 7 | 128 6 | 64 5 | 32 4 | 16 3 | 8 2 | 4 1 | 2 (11 rows)
Distribuição dos valores sem diferenciador cache-length:
select value_dec, count(*) n from wiki_print1 group by 1 order by 2 desc, 1; value_dec | n -----------+---- 0 | 11 1024 | 11 512 | 10 1536 | 10 256 | 9 768 | 9 1280 | 9 1792 | 9 128 | 8 384 | 8 640 | 8 896 | 8 1152 | 8 1408 | 8 1664 | 8 1920 | 8 64 | 7 192 | 7 320 | 7 448 | 7 576 | 7 ... | ... 2012 | 3 2020 | 3 2028 | 3 2036 | 3 2044 | 3 2 | 2 6 | 2 10 | 2 14 | 2 18 | 2 22 | 2 ... | ... 2039 | 1 2041 | 1 2043 | 1 2045 | 1 2047 | 1 (2048 rows)