Skip to content
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

Merged
merged 1 commit into from
Sep 29, 2015

Conversation

jon-wei
Copy link
Contributor

@jon-wei jon-wei commented Sep 28, 2015

Addresses issue #1779

import java.util.Map;

public class SegmentMetadataQuery extends BaseQuery<SegmentAnalysis>
{
public static final byte[] ANALYSIS_TYPES_CACHE_PREFIX = new byte[]{0x70};
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed?

Copy link
Contributor Author

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

Copy link
Contributor

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).

Copy link
Contributor

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

Copy link
Contributor Author

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

@fjy
Copy link
Contributor

fjy commented Sep 29, 2015

👍


public byte[] getBytes()
Copy link
Contributor

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

Copy link
Member

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

Copy link
Contributor Author

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()

@gianm
Copy link
Contributor

gianm commented Sep 29, 2015

👍 lgtm

}

final ByteBuffer bytes = ByteBuffer.allocate(size);
bytes.put(ANALYSIS_TYPES_CACHE_PREFIX);
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

drcrallen added a commit that referenced this pull request Sep 29, 2015
Add analysisTypes to SegmentMetadataQuery cache key
@drcrallen drcrallen merged commit 8199ecf into apache:master Sep 29, 2015
@jon-wei jon-wei deleted the smq_cachekey branch October 6, 2017 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants