Re: [C++] Maximum type code for union types

2021-06-23 Thread Ying Zhou
Thanks! Issue filed. I will work on it.

https://issues.apache.org/jira/browse/ARROW-13154

> On Jun 20, 2021, at 5:26 PM, Wes McKinney  wrote:
> 
> UnionType::kMaxTypeCode is 127, so we intend to have codes from 0 to
> 127. If there is code preventing things from going up to and including
> 127 it's a bug.
> 
> On Sun, Jun 20, 2021 at 3:06 PM Ying Zhou  wrote:
>> 
>> Moreover it seems that negative type_codes are banned due to type.cc:622 
>>  . Moreover in type_test.cc  and 
>> array_union_test.cc  type_codes are always 
>> nonnegative. However maybe negative type_codes should be allowed since 
>> type_codes are of type int8_t. Is this also intended?
>> 
>>> On Jun 20, 2021, at 4:01 PM, Ying Zhou  wrote:
>>> 
>>> Hi,
>>> 
>>> Due to the following in builder_union.cc  (Line 
>>> 67-70)
>>> 
>>>  type_id_to_children_.resize(union_type.max_type_code() + 1, nullptr);
>>>  DCHECK_LT(
>>>  type_id_to_children_.size(),
>>>  
>>> static_cast(UnionType::kMaxTypeCode));
>>> 
>>> and type.cc  (Line 640-644)
>>> uint8_t UnionType::max_type_code() const {
>>>  return type_codes_.size() == 0
>>> ? 0
>>> : *std::max_element(type_codes_.begin(), type_codes_.end());
>>> }
>>> 
>>> In practice type codes of the union type must always be below or equal to 
>>> 125. Is this intended behavior?
>>> 
>> 



Re: [C++] Maximum type code for union types

2021-06-20 Thread Wes McKinney
UnionType::kMaxTypeCode is 127, so we intend to have codes from 0 to
127. If there is code preventing things from going up to and including
127 it's a bug.

On Sun, Jun 20, 2021 at 3:06 PM Ying Zhou  wrote:
>
> Moreover it seems that negative type_codes are banned due to type.cc:622 
>  . Moreover in type_test.cc  and 
> array_union_test.cc  type_codes are always 
> nonnegative. However maybe negative type_codes should be allowed since 
> type_codes are of type int8_t. Is this also intended?
>
> > On Jun 20, 2021, at 4:01 PM, Ying Zhou  wrote:
> >
> > Hi,
> >
> > Due to the following in builder_union.cc  (Line 
> > 67-70)
> >
> >   type_id_to_children_.resize(union_type.max_type_code() + 1, nullptr);
> >   DCHECK_LT(
> >   type_id_to_children_.size(),
> >   
> > static_cast(UnionType::kMaxTypeCode));
> >
> > and type.cc  (Line 640-644)
> > uint8_t UnionType::max_type_code() const {
> >   return type_codes_.size() == 0
> >  ? 0
> >  : *std::max_element(type_codes_.begin(), type_codes_.end());
> > }
> >
> > In practice type codes of the union type must always be below or equal to 
> > 125. Is this intended behavior?
> >
>


[C++] Maximum type code for union types

2021-06-20 Thread Ying Zhou
Hi,

Due to the following in builder_union.cc  (Line 67-70)

  type_id_to_children_.resize(union_type.max_type_code() + 1, nullptr);
  DCHECK_LT(
  type_id_to_children_.size(),
  
static_cast(UnionType::kMaxTypeCode));

and type.cc  (Line 640-644)
uint8_t UnionType::max_type_code() const {
  return type_codes_.size() == 0
 ? 0
 : *std::max_element(type_codes_.begin(), type_codes_.end());
}

In practice type codes of the union type must always be below or equal to 125. 
Is this intended behavior?



Re: [C++] Maximum type code for union types

2021-06-20 Thread Ying Zhou
Moreover it seems that negative type_codes are banned due to type.cc:622 
 . Moreover in type_test.cc  and 
array_union_test.cc  type_codes are always 
nonnegative. However maybe negative type_codes should be allowed since 
type_codes are of type int8_t. Is this also intended? 

> On Jun 20, 2021, at 4:01 PM, Ying Zhou  wrote:
> 
> Hi,
> 
> Due to the following in builder_union.cc  (Line 
> 67-70)
> 
>   type_id_to_children_.resize(union_type.max_type_code() + 1, nullptr);
>   DCHECK_LT(
>   type_id_to_children_.size(),
>   
> static_cast(UnionType::kMaxTypeCode));
> 
> and type.cc  (Line 640-644)
> uint8_t UnionType::max_type_code() const {
>   return type_codes_.size() == 0
>  ? 0
>  : *std::max_element(type_codes_.begin(), type_codes_.end());
> }
> 
> In practice type codes of the union type must always be below or equal to 
> 125. Is this intended behavior?
>