Re: Add ability to specify INLINE_SIZE for PK sorted index and key's schema validation [IGNITE-11402]

2021-12-06 Thread Maksim Timonin
Hi, Taras!

I get critical system failure when I tried to explicitly set inline size
with negative value. WDYT, if we restrict it with only positive numbers for
public API?

Also, I put some minor comments. Can you please have a look?

On Fri, Dec 3, 2021 at 6:09 PM Taras Ledkov  wrote:

> Hi Igniters,
>
> There is an issue to add ability to specify INLINE_SIZE for sorted index on
> the primary key and index on affinite fields [1].
> Please take a look at the last comment (proposal).
>
> I duplicate the proposal here.
>
> *Proposal:*
> add to the public QueryEntity properties:
> - Integer primaryKeyInlineSize - use wrapper object to compatibility (null
> value - default behavior);
> - Integer affinityFieldInlineSize - use wrapper object to compatibility
> (null value - default behavior);
>
> The approach has a contradiction with cache API behavior.
> Now there is no ability to specify PK sorted index with unwrapped PK fields
> by cache API + QueryEntity. This functionality is available only from SQL
> command 'CREATE TABLE' (see H2TableDescriptor#extractKeyColumns)
>
> So,
> - by SQL command we cannot create 'wrapped' PK sorted index for composite
> PK;
> - by cache API we cannot create 'unwrapped' PK sorted index for composite
> PK.
>
> I propose to add the public property:
> Boolean QueryEntity#unwrapPrimaryKeyFieldsForSortedIndex
> to make SQL & cache API symmetrical.
>
> *There is a pitfall here*
> User may specify the key class like below:
>
> class MyKey{
>   @QuerySqlField
>   int id0;
>
>   @QuerySqlField
>   int id1;
>
>   int hiddenId;
> }
>
> In this case two objects MyKey(0, 0, 0) & MyKey(0,0,1) are different and
> may be put into cache as a two different keys.
> But they are similar for SQL PK.
> But this scenario now may be produced by SQL command CREATE TABLE + cache
> API.
>
> I propose to add key schema validation to the
> QueryTypeDescriptorImpl#validateKeyAndValue.
> [1]. https://issues.apache.org/jira/browse/IGNITE-11402
>


Add ability to specify INLINE_SIZE for PK sorted index and key's schema validation [IGNITE-11402]

2021-12-03 Thread Taras Ledkov
Hi Igniters,

There is an issue to add ability to specify INLINE_SIZE for sorted index on
the primary key and index on affinite fields [1].
Please take a look at the last comment (proposal).

I duplicate the proposal here.

*Proposal:*
add to the public QueryEntity properties:
- Integer primaryKeyInlineSize - use wrapper object to compatibility (null
value - default behavior);
- Integer affinityFieldInlineSize - use wrapper object to compatibility
(null value - default behavior);

The approach has a contradiction with cache API behavior.
Now there is no ability to specify PK sorted index with unwrapped PK fields
by cache API + QueryEntity. This functionality is available only from SQL
command 'CREATE TABLE' (see H2TableDescriptor#extractKeyColumns)

So,
- by SQL command we cannot create 'wrapped' PK sorted index for composite
PK;
- by cache API we cannot create 'unwrapped' PK sorted index for composite
PK.

I propose to add the public property:
Boolean QueryEntity#unwrapPrimaryKeyFieldsForSortedIndex
to make SQL & cache API symmetrical.

*There is a pitfall here*
User may specify the key class like below:

class MyKey{
  @QuerySqlField
  int id0;

  @QuerySqlField
  int id1;

  int hiddenId;
}

In this case two objects MyKey(0, 0, 0) & MyKey(0,0,1) are different and
may be put into cache as a two different keys.
But they are similar for SQL PK.
But this scenario now may be produced by SQL command CREATE TABLE + cache
API.

I propose to add key schema validation to the
QueryTypeDescriptorImpl#validateKeyAndValue.
[1]. https://issues.apache.org/jira/browse/IGNITE-11402