Skip to content

Filter equality matchers on the dynamo side#400

Merged
aaron7 merged 4 commits intomasterfrom
398-filter-labels-server-side-dynamodb
Apr 19, 2017
Merged

Filter equality matchers on the dynamo side#400
aaron7 merged 4 commits intomasterfrom
398-filter-labels-server-side-dynamodb

Conversation

@aaron7
Copy link
Contributor

@aaron7 aaron7 commented Apr 18, 2017

Fixes #398

  • Created some extra tests for the aws storage client and started filtering by range key.
  • Added simple field to IndexEntry which is then used to add the filter condition to dynamo if it exists

@aaron7 aaron7 requested review from jml and tomwilkie April 18, 2017 14:03
Copy link
Contributor

@jml jml left a comment

Choose a reason for hiding this comment

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

Code looks OK to me, but I'd like @tomwilkie to check over the logic.

chunk/schema.go Outdated
RangeValueStart []byte

// Filters for querying
ValueEq []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not usually picky about names, I promise :-)

...but I would either call this Value, ValueEqual.

items := m.tables[*input.TableName].items[hashValue]

// TODO we should also filter by range value
// Optional filters
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for implementing this! I was being lazy.

valueFilter []byte
valueFilterType *string
)
if input.KeyConditions[rangeKey] != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more idiomatic to do:

if c, ok := input.KeyConditions[rangeKey]; ok {
    rangeValueFilter = c.AttributeValueList[0].B
    rangeValueFilterType = *c.ComparisonOperator
}

items := m.tables[*input.TableName].items[hashValue]
for _, item := range items {
rangeValue := item[rangeKey].B
if rangeValueFilterType == "GE" && bytes.Compare(rangeValue, rangeValueFilter) < 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

pls use rangeValueFilterType == dynamodb.ComparisonOperatorGe

if rangeValueFilterType == "GE" && bytes.Compare(rangeValue, rangeValueFilter) < 0 {
continue
}
if rangeValueFilterType == "BEGINS_WITH" && !bytes.HasPrefix(rangeValue, rangeValueFilter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto


if item[valueKey] != nil {
value := item[valueKey].B
if valueFilter != nil && *valueFilterType == "EQ" && !bytes.Equal(value, valueFilter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@tomwilkie
Copy link
Contributor

Just a bunch of nits, LGTM otherwise.

@jml
Copy link
Contributor

jml commented Apr 19, 2017

@aaron7 Feel free to merge this if you've addressed all of @tomwilkie's points.

@aaron7 aaron7 merged commit f486481 into master Apr 19, 2017
aaron7 added a commit that referenced this pull request Apr 19, 2017
aaron7 added a commit that referenced this pull request Apr 19, 2017
@aaron7 aaron7 deleted the 398-filter-labels-server-side-dynamodb branch April 19, 2017 16:27
@aaron7 aaron7 restored the 398-filter-labels-server-side-dynamodb branch April 19, 2017 16:27
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.

3 participants