Decimal Encoding and Presence Map

Imported from previous forum

Hi,

The template contains optional decimal field without any operator. See below the node:

If there is no value, this can be encoded in two ways :

  1. NULL
  2. Set the Presence Map(PM) bit to 0 (meaning exponent is not present in the stream).

The parser sees if the value at the current location is NULL or not. If NULL, value is absent. If not NULL, it checks the PM (for exponent) and proceed accordingly (if not set, value is absent).

My question is, if NULL encoding is followed, does this field occupy any bit in the PM?

Argumnet 1: According to specification, it should not.(Section 10.5.1: “If a field is optional and has no field operator, it is encoded with a nullable representation and the NULL is used to represent absence of a value. It will not occupy any bits in the presence map”).

Argumnet 2: Since exponent’s operator is default, it should occupy a bit in PM always.

Which argument is right?
If second argumnet is right, Does it occupy 2 bits in PM for the following:







Am I missing anything here? Thanks.

Regards
Kiran

You’re right that there are two alternatives for encoding an absent exponent in your example: encode the NULL explicitly in the stream or rely on the absence of an initial value on the default operator. However, in both cases the default operator is in play:

set the bit to 1 and encode the NULL in the stream, or
set the bit to 0

The later is the preferred way since it is more compact and is exactly the purpose of this particular construct.

I don’t quit follow your Argument 1: the exponent indeed has an operator so the rule does not apply.

Argument 2 is correct.

In your second example the field will occupy 1 or 2 bits depending on whether the exponent is considered to be NULL or not.

If the exponent is considered NULL then there is no mantissa in the stream, nor will any operator on the mantissa occupy any bits in the presence map. If the exponent is considered non-NULL, then the instruction for the mantissa should be processed and consequently an operator with a presence bit will occupy a bit in the presence map.

So your second example has three basic scenarios:

  1. The exponent bit is 0
    As specified by the default operator, the exponent is considered
    NULL, and no mantissa or associated bits are present in the stream.

  2. The exponent bit is 1 and NULL is encoded in the stream
    Same consequence as in scenario 1.

  3. The exponent bit is 1 and a non-NULL value is encoded in the stream
    The exponent is non-NULL and the field as a whole is considered
    present, hence the mantissa must be processed. Since the mantissa
    has a copy operator, a second bit is occupied in the presence map.

/David

Hi,

The template contains optional decimal field without any operator.
See below the node: <decimal name="xyz" id="451"
presence="optional"> <exponent> <default /> </exponent> <mantissa>
<delta /> </mantissa> </decimal>

If there is no value, this can be encoded in two ways :

  1. NULL 2. Set the Presence Map(PM) bit to 0 (meaning exponent is not
    present in the stream).

The parser sees if the value at the current location is NULL or not. If
NULL, value is absent. If not NULL, it checks the PM (for exponent) and
proceed accordingly (if not set, value is absent).

My question is, if NULL encoding is followed, does this field occupy any
bit in the PM?

Argumnet 1: According to specification, it should not.(Section 10.5.1:
“If a field is optional and has no field operator, it is encoded with a
nullable representation and the NULL is used to represent absence of a
value. It will not occupy any bits in the presence map”).

Argumnet 2: Since exponent’s operator is default, it should occupy a bit
in PM always.

Which argument is right? If second argumnet is right, Does it occupy 2
bits in PM for the following:

Am I missing anything here? Thanks.

Regards Kiran

You’re right that there are two alternatives for encoding an absent
exponent in your example: encode the NULL explicitly in the stream or
rely on the absence of an initial value on the default operator.
However, in both cases the default operator is in play:

set the bit to 1 and encode the NULL in the stream, or set the bit to 0

The later is the preferred way since it is more compact and is exactly
the purpose of this particular construct.

I don’t quit follow your Argument 1: the exponent indeed has an operator

Here I am talking about the Decimal that doesn't have any operator (since Decimal itself can have an operator) rather than the exponent. According to section 10.5.1, the Decimal is NULL encoded in the stream. If NULL, then it doesn't occupy any bits in the stream. If not NULL, then it occupy bits in the PM based on individual operators. 

Am I missing anything here? Thanks.

so the rule does not apply.

Argument 2 is correct.

In your second example the field will occupy 1 or 2 bits depending on
whether the exponent is considered to be NULL or not.

If the exponent is considered NULL then there is no mantissa in the
stream, nor will any operator on the mantissa occupy any bits in the
presence map. If the exponent is considered non-NULL, then the
instruction for the mantissa should be processed and consequently an
operator with a presence bit will occupy a bit in the presence map.

So your second example has three basic scenarios:

  1. The exponent bit is 0 As specified by the default operator, the
    exponent is considered NULL, and no mantissa or associated bits are
    present in the stream.

  2. The exponent bit is 1 and NULL is encoded in the stream Same
    consequence as in scenario 1.

  3. The exponent bit is 1 and a non-NULL value is encoded in the stream
    The exponent is non-NULL and the field as a whole is considered
    present, hence the mantissa must be processed. Since the mantissa has
    a copy operator, a second bit is occupied in the presence map.

/David

Regards
Kiran

Ok, those are two fully separate cases.

Either you have a single operator for the whole field and then the decimal is treated as a single entity in terms of the field operator, i.e, it will at most use one single entry in the dictionary.

Or, you have individual operators (one or two) and then the decimal is treated as two signed integers possibly using two entries in the dictionary. This second case is identified by the appearance of an element, an element or both.

My previous reply was only discussing the second case. The first case is simpler and similar to fields of other types.

/David

You’re right that there are two alternatives for encoding an absent
exponent in your example: encode the NULL explicitly in the stream or
rely on the absence of an initial value on the default operator.
However, in both cases the default operator is in play:

set the bit to 1 and encode the NULL in the stream, or set the
bit to 0

The later is the preferred way since it is more compact and is exactly
the purpose of this particular construct.

I don’t quit follow your Argument 1: the exponent indeed has an
operator

Here I am talking about the Decimal that doesn't have any operator
(since Decimal itself can have an operator) rather than the
exponent. According to section 10.5.1, the Decimal is NULL encoded
in the stream. If NULL, then it doesn't occupy any bits in the
stream. If not NULL, then it occupy bits in the PM based on
individual operators.

Am I missing anything here? Thanks.

so the rule does not apply.

Argument 2 is correct.

In your second example the field will occupy 1 or 2 bits depending on
whether the exponent is considered to be NULL or not.

If the exponent is considered NULL then there is no mantissa in the
stream, nor will any operator on the mantissa occupy any bits in the
presence map. If the exponent is considered non-NULL, then the
instruction for the mantissa should be processed and consequently an
operator with a presence bit will occupy a bit in the presence map.

So your second example has three basic scenarios:

  1. The exponent bit is 0 As specified by the default operator, the
    exponent is considered NULL, and no mantissa or associated bits are
    present in the stream.

  2. The exponent bit is 1 and NULL is encoded in the stream Same
    consequence as in scenario 1.

  3. The exponent bit is 1 and a non-NULL value is encoded in the stream
    The exponent is non-NULL and the field as a whole is considered
    present, hence the mantissa must be processed. Since the mantissa
    has a copy operator, a second bit is occupied in the presence map.

/David

Regards Kiran

This makes the remainder of a message that possibly contains a null exponent really difficult to work with, because the following fields’ presence map positions must now be determined at run time.

I can’t easily have logic pre-configured based on the template that knows the presence map bit positions of all fields.

If it weren’t for this one weirdness, I could.

jh

You’re right that there are two alternatives for encoding an absent
exponent in your example: encode the NULL explicitly in the stream or
rely on the absence of an initial value on the default operator.
However, in both cases the default operator is in play:

set the bit to 1 and encode the NULL in the stream, or set the bit to 0

The later is the preferred way since it is more compact and is exactly
the purpose of this particular construct.

I don’t quit follow your Argument 1: the exponent indeed has an operator
so the rule does not apply.

Argument 2 is correct.

In your second example the field will occupy 1 or 2 bits depending on
whether the exponent is considered to be NULL or not.

If the exponent is considered NULL then there is no mantissa in the
stream, nor will any operator on the mantissa occupy any bits in the
presence map. If the exponent is considered non-NULL, then the
instruction for the mantissa should be processed and consequently an
operator with a presence bit will occupy a bit in the presence map.

So your second example has three basic scenarios:

  1. The exponent bit is 0 As specified by the default operator, the
    exponent is considered NULL, and no mantissa or associated bits are
    present in the stream.

  2. The exponent bit is 1 and NULL is encoded in the stream Same
    consequence as in scenario 1.

  3. The exponent bit is 1 and a non-NULL value is encoded in the stream
    The exponent is non-NULL and the field as a whole is considered
    present, hence the mantissa must be processed. Since the mantissa has
    a copy operator, a second bit is occupied in the presence map.

/David

Hi,

The template contains optional decimal field without any operator.
See below the node: <decimal name="xyz" id="451"
presence="optional"> <exponent> <default /> </exponent> <mantissa>
<delta /> </mantissa> </decimal>

If there is no value, this can be encoded in two ways : 1. NULL 2. Set
the Presence Map(PM) bit to 0 (meaning exponent is not present in the
stream).

The parser sees if the value at the current location is NULL or not.
If NULL, value is absent. If not NULL, it checks the PM (for exponent)
and proceed accordingly (if not set, value is absent).

My question is, if NULL encoding is followed, does this field occupy
any bit in the PM?

Argumnet 1: According to specification, it should not.(Section 10.5.1:
“If a field is optional and has no field operator, it is encoded with
a nullable representation and the NULL is used to represent absence of
a value. It will not occupy any bits in the presence map”).

Argumnet 2: Since exponent’s operator is default, it should occupy a
bit in PM always.

Which argument is right? If second argumnet is right, Does it occupy 2
bits in PM for the following:

Am I missing anything here? Thanks.

Regards Kiran