Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

add clear functional option for imports#1699

Merged
travisturner merged 7 commits intoFeatureBaseDB:masterfrom
travisturner:import-clear
Oct 24, 2018
Merged

add clear functional option for imports#1699
travisturner merged 7 commits intoFeatureBaseDB:masterfrom
travisturner:import-clear

Conversation

@travisturner
Copy link
Member

@travisturner travisturner commented Oct 22, 2018

Overview

This PR adds functional options to all exposed Import-related api methods. Providing OptImportOptionsClear(true) to an Import() method will treat the payload as clear-bits.

Fixes #1657

TODO:

  • We don't currently support any type of clearValue for int fields. The setValue import requires a column, value, but for clearValue it doesn't really make sense to require the value for clears. In that case you just need the column. Is that a reasonable way to handle it?
  • documentation
  • update ImportRoaring to support clear

Pull request checklist

Code review checklist

This is the checklist that the reviewer will follow while reviewing your pull request. You do not need to do anything with this checklist, but be aware of what the reviewer will be looking for.

  • Ensure that any changes to external docs have been included in this pull request.
  • If the changes require that minor/major versions need to be updated, tag the PR appropriately.
  • Ensure the new code is properly commented and follows Idiomatic Go.
  • Check that tests have been written and that they cover the new functionality.
  • Run tests and ensure they pass.
  • Build and run the code, performing any applicable integration testing.

api.go Outdated
}

// Set up import options.
options := &ImportOptions{}
Copy link
Contributor

Choose a reason for hiding this comment

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

This block should be moved to a function, the same block is used at lines 704 and 776 and client.go 582.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a function to consolidate these. I can't share the function with http/client.go without exporting it (because it's a separate package). I don't think it's worth exporting for that one instance.

api.go Outdated
Clear bool
}

// ImportOption is a functional option type for API.Import
Copy link
Contributor

Choose a reason for hiding this comment

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

Dot is missing at the end of the comment

t.Fatalf("unexpected values: got sum=%v, count=%v; expected sum=30, cnt=2", sum, cnt)
}

// Verify Range
Copy link
Contributor

Choose a reason for hiding this comment

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

Dot at the end of the comment is missing.

http/client.go Outdated

url := fmt.Sprintf("%s/index/%s/field/%s/import-roaring/%d?remote=%v", uri, index, field, shard, remote)
if options.Clear {
url += "&clear=true"
Copy link
Contributor

@yuce yuce Oct 23, 2018

Choose a reason for hiding this comment

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

I think it's better to use url.Values to create the query part of the URL instead of string concatenation. Something like:

u := fmt.Sprintf("%s/index/%s/field/%s/import-roaring/%d", uri, index, field, shard)
vs := url.Values{}
vs.Set("remote", strconv.FormatBool(remote))
if options.Clear{
    vs.Set("clear", "true")
}
u = fmt.Sprintf("%s?%s", u, vs.Encode())

count = row.intersectionCount(filter)
} else {
count = row.Count()
consider = consider.Intersect(filter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't intersectionCount faster than separate Intersect and Count?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but this change is necessary because of a bug with this sum() method. It wasn't taking the not-null bitmap (row(bitDepth)) into consideration when calculating sum. So if not-null was set to 0, but the BSI rows still contained a non-zero value, that value would be included in the sum. Basically, we need consider later in the method.

With all that said, there may be a way to leverage instersectCount() that I'm missing. Can you suggest a different approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, that makes sense.

Copy link
Contributor

@yuce yuce left a comment

Choose a reason for hiding this comment

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

Roaring import doesn't support the clear flag. Is that intentional?

@travisturner
Copy link
Member Author

travisturner commented Oct 24, 2018

I implemented it at the API. Looks like it needs to be added to the http handler.

yuce
yuce previously approved these changes Oct 24, 2018
Copy link
Contributor

@yuce yuce left a comment

Choose a reason for hiding this comment

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

Client tests run OK.

@travisturner travisturner merged commit 79bf01f into FeatureBaseDB:master Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Inverse Imports

4 participants