Skip to content

segment metadata fallback analysis if no bitmaps#7116

Merged
fjy merged 6 commits intoapache:masterfrom
clintropolis:segment-metadata-string-nobitmap
Feb 26, 2019
Merged

segment metadata fallback analysis if no bitmaps#7116
fjy merged 6 commits intoapache:masterfrom
clintropolis:segment-metadata-string-nobitmap

Conversation

@clintropolis
Copy link
Copy Markdown
Member

Instead of returning an "error" analysis, instead handle string dimensions without bitmaps by using facilities of DictionaryEncodedColumn. Fixes #7114.

max = NullHandling.nullToEmptyIfNeeded(bitmapIndex.getValue(cardinality - 1));
}
} else if (capabilities.isDictionaryEncoded()) {
// fallback if no bitmap index
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno, maybe we should just remove the "size" analysisType. It is nothing but trouble.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I think it would be interesting to have size be representative of "estimated size in memory" for incremental index, or size in bytes of column in the segment file that is mapped, but what it's computing here seems like basically nonsense for all column types.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or size in bytes of column in the segment file that is mapped

dictionary size + bitmap size I vote for that too.

Copy link
Copy Markdown
Member Author

@clintropolis clintropolis Feb 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised proposal #7124, which I will address in a follow up PR to not block this fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until #7124 is sorted, what you're doing here (setting size to 0 when there's no bitmap index) sounds good to me.

{
QueryableIndex index = rollup ? TestIndex.getMMappedTestIndex() : TestIndex.getNoRollupMMappedTestIndex();
QueryableIndex index = bitmaps
? rollup
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested ternaries = 😭. Please consider using normal ifs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, these tests were already painful to slip in a test for this since parameterized, will see if I can clean up. Maybe removing size will help.

if (noBitmapRealtimeIndex != null) {
return noBitmapRealtimeIndex;
}
}
Copy link
Copy Markdown
Contributor

@egor-ryashin egor-ryashin Feb 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this synchronization pattern was before the change, I'm just confused what it tries to accomplish? ie, if noBitmapRealtimeIndex is not created then all threads can initialize noBitmapRealtimeIndex simultaneously, doesn't it look strange?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I wasn't much attention, will fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use Suppliers.memoize instead. I looked into it, and this code is quite old! It appears to be from the PR that added timeseries queries to Druid! Thanks for review 👍

Copy link
Copy Markdown
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - had a couple minor comments but nothing blocking.

String value = bitmapIndex.getValue(i);
if (value != null) {
size += StringUtils.estimatedBinaryLengthAsUTF8(value) * bitmapIndex.getBitmap(bitmapIndex.getIndex(value)).size();
int cardinality = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My aesthetic sensibility would be to have this be final and add a closer else { } that sets it to zero, or something. Minor comment though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to do that, thanks for review 🤘

max = NullHandling.nullToEmptyIfNeeded(bitmapIndex.getValue(cardinality - 1));
}
} else if (capabilities.isDictionaryEncoded()) {
// fallback if no bitmap index
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until #7124 is sorted, what you're doing here (setting size to 0 when there's no bitmap index) sounds good to me.

@jon-wei jon-wei added this to the 0.14.0 milestone Feb 25, 2019
@fjy fjy merged commit 9fa649b into apache:master Feb 26, 2019
clintropolis added a commit to clintropolis/druid that referenced this pull request Feb 26, 2019
* segment metadata fallback analysis if no bitmaps

* remove accidental line

* remove nonsense size estimation

* less ternary

* fix it

* do the thing
@clintropolis clintropolis deleted the segment-metadata-string-nobitmap branch February 26, 2019 20:33
jon-wei pushed a commit that referenced this pull request Mar 1, 2019
* segment metadata fallback analysis if no bitmaps

* remove accidental line

* remove nonsense size estimation

* less ternary

* fix it

* do the thing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants