-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add analysisTypes to SegmentMetadataQuery cache key #1782
Conversation
import java.util.Map; | ||
|
||
public class SegmentMetadataQuery extends BaseQuery<SegmentAnalysis> | ||
{ | ||
public static final byte[] ANALYSIS_TYPES_CACHE_PREFIX = new byte[]{0x70}; |
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.
is this needed?
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 saw that ListColumnIncluderator also puts a prefix byte before its list in the cache key, so I added that to be consistent
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.
ah, in that case, there's different types for the last column includerator and the cache key is required to distinguish those types. In this case, analysis types is an enum, which is a little bit different. I think what needs to happen is that the analysis_types_cache_prefix cannot be a static constant, but should instead reflect what type of analysis type it is (you can use the enum value).
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.
actually u already have typeBytes, so u can remove the analysis_types_cache_prefix entirely
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.
@fjy removed the prefix byte for analysistypes
c83b759
to
f7e4805
Compare
👍 |
|
||
public byte[] getBytes() |
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 could be called getCacheBytes to make it clearer what it's for
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.
or probably getCacheKey in order to be consistent with other places where we create cacheKey
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.
@gianm @nishantmonu51 Renamed getBytes() to getCacheKey()
f7e4805
to
41ff271
Compare
👍 lgtm |
} | ||
|
||
final ByteBuffer bytes = ByteBuffer.allocate(size); | ||
bytes.put(ANALYSIS_TYPES_CACHE_PREFIX); |
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.
Does there need to be anything between the individual cache keys? Is it possible two different analysisTypes could have cache keys that yield the same cache key?
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 think we need a separator. Right now the keys are just single bytes (and probably forever… how many flags could there be!) so this is not an imminent risk. If we do find that we need a ton of types then we can use the high bit for a variable length encoding.
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 think that would happen in this case since each analysisType's byte[] has the same fixed length
Add analysisTypes to SegmentMetadataQuery cache key
Addresses issue #1779