-
Notifications
You must be signed in to change notification settings - Fork 805
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 pagination and flatten customized search attributes #5234
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ca46817
implement pagination
bowenxia 1e71231
add a test case for nextPageToken
bowenxia cb6adfd
add more test cases for pagination
bowenxia 0c0fae5
change elastic search token into pinot token
bowenxia e08e461
clean up
bowenxia 191ef89
fix count didn'w work issue
bowenxia 6f3eeb4
try to implement flatten schema, add attributes into schema
bowenxia ee5b703
add attributes into schema
bowenxia b85afd0
add some code to convert time to unix time in customized search attri…
bowenxia e2fbdc5
refactor previously added code to a function
bowenxia 267120e
customized search attributes and unit tests
bowenxia 9894d83
Remove attr column and minor clean up
neil-xie 4ffefed
edge case for ORDER BY in customized search attribute
bowenxia 59f4be4
Fix typo in name
neil-xie bd6aa15
add one more condition for parseLastElement
bowenxia 5d601d3
split one element of customized search attribute by operator instead …
bowenxia 598d265
update unit test
bowenxia c11fcaa
update unit test
bowenxia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) 2020 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package pinot | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/uber/cadence/common/types" | ||
) | ||
|
||
type ( | ||
// PinotVisibilityPageToken holds the paging token for Pinot | ||
PinotVisibilityPageToken struct { | ||
From int | ||
} | ||
) | ||
|
||
// DeserializePageToken return the structural token | ||
func DeserializePageToken(data []byte) (*PinotVisibilityPageToken, error) { | ||
var token PinotVisibilityPageToken | ||
dec := json.NewDecoder(bytes.NewReader(data)) | ||
dec.UseNumber() | ||
err := dec.Decode(&token) | ||
if err != nil { | ||
return nil, &types.BadRequestError{ | ||
Message: fmt.Sprintf("unable to deserialize page token. err: %v", err), | ||
} | ||
} | ||
return &token, nil | ||
} | ||
|
||
// SerializePageToken return the token blob | ||
func SerializePageToken(token *PinotVisibilityPageToken) ([]byte, error) { | ||
data, err := json.Marshal(token) | ||
if err != nil { | ||
return nil, &types.BadRequestError{ | ||
Message: fmt.Sprintf("unable to serialize page token. err: %v", err), | ||
} | ||
} | ||
return data, nil | ||
} | ||
|
||
// GetNextPageToken returns the structural token with nil handling | ||
func GetNextPageToken(token []byte) (*PinotVisibilityPageToken, error) { | ||
var result *PinotVisibilityPageToken | ||
var err error | ||
if len(token) > 0 { | ||
result, err = DeserializePageToken(token) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} else { | ||
result = &PinotVisibilityPageToken{} | ||
} | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,5 @@ | |
"indexTypes":["TEXT"] | ||
} | ||
] | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just curious why GetRowCount() is not working here
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.
The previous query used Select (), so we could use getRowCount for the total number of results. But we added pagination, the Select () will only return a certain number of results according to the pagination. So we need to change the query to be Select count(*), which means there will only be one result.