-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IGNITE-17855 Implement inline size calculation for B+tree #1179
Conversation
case STRING: { | ||
int length = ((VarlenNativeType) nativeType).length(); | ||
|
||
return length == Integer.MAX_VALUE ? UNDEFINED_VARLEN_INLINE_SIZE : length * 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return length == Integer.MAX_VALUE ? UNDEFINED_VARLEN_INLINE_SIZE : length * 2; | |
return length == Integer.MAX_VALUE ? UNDEFINED_VARLEN_INLINE_SIZE : length; |
Do you expect most of users will use 2 bytes chars?
Why should an index over columns of ASCII chars be twice large by default?
And what to do with 4-byte chars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I proceed from the fact that in Java characters is char
(2 bytes).
We can assume, as in Java, that in most cases the characters will be ascii (1 byte).
We're just doing an approximate inline count, I don't know how often we'll see 4 byte characters.
Later we can add an encoding (utf-8, 16, 32) to the configuration or ddl.
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, also I'd limit default value for var-length types (e.g. with 64-256 bytes).
Usually, the upper limit for var-length columns is usually calculated with some reserve.
So, the actual values size is less the limit (often noticeably).
Also, large inline-size means less data will fit to the index page and may have negative impact on performance.
In case of relatively large values with similar prefixes user always can increase inline-size manually,
but imho, in most of cases, this limit will reduce index size with no performance penalty.
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
/** | ||
* Helper class for index inlining. | ||
*/ | ||
public class InlineUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most methods in this class a package-private, while this class is public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class will be used in VolatilePageMemoryTableStorage and PersistentPageMemoryTableStorage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess they're package-private for tests, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...es/page-memory/src/main/java/org/apache/ignite/internal/pagememory/tree/io/BplusInnerIo.java
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Show resolved
Hide resolved
/** | ||
* Helper class for index inlining. | ||
*/ | ||
public class InlineUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess they're package-private for tests, right?
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
...ge-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtils.java
Outdated
Show resolved
Hide resolved
assertEquals(9, inlineSize(nativeType = NativeTypes.datetime())); | ||
nativeTypeSpecs.remove(nativeType.spec()); | ||
|
||
assertEquals(12, inlineSize(nativeType = NativeTypes.timestamp())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12 bytes per timestamp? Jesus! Why is it so big? Just asking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's seconds (long) + nanos (int)
...emory/src/test/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtilsTest.java
Show resolved
Hide resolved
...emory/src/test/java/org/apache/ignite/internal/storage/pagememory/index/InlineUtilsTest.java
Show resolved
Hide resolved
void testBinaryTupleInlineSize() { | ||
IndexDescriptor indexDescriptor = testIndexDescriptor(); | ||
|
||
assertEquals(BinaryTupleCommon.HEADER_SIZE, binaryTupleInlineSize(indexDescriptor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is funny, you know. I'd expect an exception, who would want to make a tuple with 0 columns.
On the other hand, can this be useful somewhere? Just asking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know yet, I can add an assertion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have my approval, let's wait for other guys now
https://issues.apache.org/jira/browse/IGNITE-17855