Browse Source

WIP: Translating examples

master
Julio Biason 2 years ago
parent
commit
0ed0d2ef24
  1. 33
      content/research/decoding-fast-examples.md
  2. 52
      content/research/decoding-fast-examples.pt.md

33
content/research/decoding-fast-examples.md

@ -189,22 +189,23 @@ bit, but don't merge them: `0101_0101` (85), `0111_0011` (115), `0110_0101`
(101), `0111_0010` (114) and `1011_0001` (49, if we remove the stop bit, that
is), which converted by the ASCII table gives us "User1".
Remember that we jumped the Presence Map? Now it is the time to use it, since
we are reading "ID" and it has an operator that requires the Presence Map. The
Presence Map we read before was `100_0000` (with the stop bit removed), so
yeah, the "ID" is present. We read the next byte, `1000_0100`, which is "4".
But there is a gotcha here: The field is optional. So although we read "4", the
Now it is the time to use the Presence Map, since we are reading the "ID" field
and it has an operator that requires the Presence Map. The Presence Map we read
before was `100_0000` (with the stop bit removed), so yeah, the "ID" is present
in the incoming data. We read the next byte, `1000_0100`, which is "4". But
there is a gotcha here: The field is optional. So although we read "4", the
actual value is "3" -- if the value read was "0" it meant that the ID is Null.
Good. We just finished reading the first record of "InnerSequence". Now we read
the second record.
Good. We just finished reading the first record of "InnerSequence": The user
"User1" has ID "3" and belongs to group "6868070". Now we read the second
record.
We don't need to read the length again, but we need to read the Presence Map
for this record. It is the byte `1000_0000`, a Presence Map indicating that
none of the fields with operators are present. But, again, it is not the time
for the Presence Map, but for the "Username". The bytes for the field are
`0101_0101` (85), `0111_0011` (115), `0110_0101` (101), `0111_0010` (114) and
`1011_0001` (50), which is "User2".
for the Presence Map, 'cause we have to read "Username". The bytes for the
field are `0101_0101` (85), `0111_0011` (115), `0110_0101` (101), `0111_0010`
(114) and `1011_0001` (50), which is "User2".
This second record have an empty presence map (`1000_0000`) meaning that the ID
is not present in the incoming data. Because the field has the Increment
@ -215,15 +216,15 @@ That ends the "InnerSequence" for the first record of "OuterSequence". Going
faster now:
- `1111_1111`: The second "GroupID" (only one byte due the stop bit), which is
127.
"127".
- `1000_0001`: The length of "InnerSequence"; it is just 1 element.
- `1100_0000`: The presence map for the first record of "InnerSequence"; it
means the "ID" is present.
- `0101_0101`, `1011_0001`: The username. "U1".
- `1111_1111`: The "ID" for user "U1" is 126 (it reads as 127, but because the
field is optional, we decrement the value by 1).
- `0000_1000`, `1000_0000`: The third "GroupID". Removing the stop bit and
joining the bits we have `1000_0000_0000` which is 2048.
- `0000_1000`, `1000_0000`: The third "GroupID". Removing the stop bits and
joining the bits we have `0000_1000 0000_0000` which is 2048.
- `1000_0010`: Length of the "InnerSequence" in the 3rd group; 2 elements.
- `1100_0000`: Presence Map of the first record of "InnerSequence"; ID is
present.
@ -233,8 +234,10 @@ faster now:
present.
- `0100_1101`, `1110_0101`: Username. "Me".
- Not reading any bytes now 'cause the Presence Map pointed that the "ID" is
not present, but because the previous value was 53, the ID for username "Me"
is 54.
not present, but because the previous value for this field was 53, the ID for
username "Me" is 54. Since this is the last element of "InnerSequence", that
sequence is complete; also, this is the last element of "OuterSequence", so
everything is done.
# Decimals

52
content/research/decoding-fast-examples.pt.md

@ -191,6 +191,58 @@ bytes até encontrar um com o bit de parada, mas não juntamos os mesmos:
`1011_0001` (49, se removermos o bit de parada), que convertidos pela tabela
ASCII nos dá o valor "User1".
Agora é o momento de usar o Mapa de Presença, já que estamos lendo o campo "ID"
e ele tem um operador que usa o Mapa. O Mapa de Presença que lemos
anteriormente foi `100_0000` (com o bit de parada removido), então sim, o "ID"
está presente nos dados de entrada. Nós lemos o próximo byte, `1000_0100`, que
é "4". Mas tem uma pegadinha aqui: O campo é opcional. Então embora tenhamos
lido "4", o valor de verdade é "3" -- se o valor lido fosse "0", significaria
que o ID é Null.
Beleza. Terminamos de ler o primeiro registro de "InnerSequence": O usuário
"User1" tem ID "3" e pertence ao grupo "6868070". Agora vamos ler o segundo
registro.
Não precisamos ler o tamanho de novo, mas precisamos ler o Mapa de Presença
deste registro. É o byte `1000_0000` um Mapa de Presença indicando que nenhum
dos campos com operadores estão presentes. Mas, de novo, não é hora de usar o
Mapa de Presença, porque nós temos que ler o "Username". Os bytes do campo são
`0101_0101` (85), `0111_0011` (115), `0110_0101` (101), `0111_0010` (114) e
`1011_0001` (50), que gera o valor "User2".
O segundo registro tem um Mapa de Presença vazio (`1000_0000`) o que indica que
o ID não está presente nos dados de entrada. Como o campo tem o operador
Increment, nós precisamos pegar o valor anterior -- "3" -- e incrementar em 1>
Assim, "User2" tem o ID "4".
E assim termina o "InnerSequence" do primeiro regsitro do "OuterSequence".
Agora mais rápido:
- `1111_1111`: O segundo "GroupID" (que usa apenas um byte por causa do bit de
parada), que é "127".
- `1000_0001`: O tamanho do "InnerSequence"; apenas 1 elemento.
- `1100_0000`: O Mapa de Presença do segundo registro de "InnerSequence";
significa que o "ID" está presente.
- `0101_0101`, `1011_0001`: Username. "U1".
- `1111_1111`: O valor de "ID" para o usuário "U1" é 126 (é lido "127", mas
como o campo é opcional, o valor é decrementado em 1).
- `0000_1000`, `1000_0000`: O terceiro "GroupID". Removendo os bits de parada e
juntando os bits restantes temos `0000_1000 0000_0000`, que é "2048".
- `1000_0010`: Tamanho da sequência "InnerSequence" do terceiro grupo; 2
elementos.
- `1100_0000`: Mapa de Presença do primeiro registro de "InnerSequence"; ID
está presente.
- `1100_1001`: Username. "I".
- `1011_0110`: "ID" para o usuário "I". 53.
- `1000_0000`: Mapa de presença do segundo registro de "InnerSequence"; ID não
está presente.
- `0100_1101`, `1110_0101`: Username. "Me".
- Agora não precisamos ler nada, pois o Mapa de Presença aponta que o ID não
está presente, mas como o valor lido anteriormente para este campo foi "53",
o ID para o usuário "Me" é "54". E como este era o último elemento de
"InnerSequence", a sequência está completa; ainda, como este era o último
elemento de "OuterSequence", a leitura terminou.
<!--
vim:spelllang=pt:

Loading…
Cancel
Save