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

Revert "fix (#718)" #720

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions internal/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2524,9 +2524,6 @@ func (h *Handler) HandleGetPoint(w http.ResponseWriter, r *http.Request) {
respondJSON(w, nil, 0, 0, err, h.verbose, ai.user, sl)
return
}
if req.version == "" {
req.version = "2"
}
options := seriesRequestOptions{
debugQueries: true,
stat: sl,
Expand Down Expand Up @@ -2631,7 +2628,6 @@ func (h *Handler) handleGetPoint(ctx context.Context, ai accessInfo, opt seriesR
shiftTimestamp(req.from.Unix(), -1, toSec(oldestShift), h.location),
shiftTimestamp(req.to.Unix(), -1, toSec(oldestShift), h.location),
h.utcOffset,
req.expandToLODBoundary,
h.location,
)

Expand Down
42 changes: 18 additions & 24 deletions internal/api/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ func (pq pointQuery) isFast() bool {
return pq.fromSec+fastQueryTimeInterval >= pq.toSec
}

func selectQueryPoint(version string, preKeyFrom int64, preKeyOnly bool, resolution int, isUnique bool, isStringTop bool, now int64, from int64, to int64, utcOffset int64, excessPoints bool, location *time.Location) *pointQuery {
lods := selectQueryLODs(version, preKeyFrom, preKeyOnly, resolution, isUnique, isStringTop, now, from, to, utcOffset, resolution, widthLODRes, location)
lod := mergeForPointQuery(from, to, mergeLODs(lods), utcOffset, excessPoints)
func selectQueryPoint(version string, preKeyFrom int64, preKeyOnly bool, resolution int, isUnique bool, isStringTop bool, now int64, from int64, to int64, utcOffset int64, location *time.Location) *pointQuery {
var lods []lodInfo
lods = selectQueryLODs(version, preKeyFrom, preKeyOnly, resolution, isUnique, isStringTop, now, from, to, utcOffset, resolution, widthLODRes, location)
lods = mergeForPointQuery(mergeLODs(lods), utcOffset, location)
if len(lods) == 0 {
return nil
}
lod := lods[0]
return &pointQuery{
fromSec: lod.fromSec,
toSec: lod.toSec,
Expand All @@ -31,31 +33,23 @@ func selectQueryPoint(version string, preKeyFrom int64, preKeyOnly bool, resolut
}
}

func roundRangeForPoint(start int64, end int64, step int64, utcOffset int64, round bool) (int64, int64) {
rStart := roundTime(start, step, utcOffset)
rEnd := roundTime(end, step, utcOffset)
if end != start {
if rStart < start && !round {
rStart += step
}
if rEnd < end && round {
rEnd += step
}
func mergeForPointQuery(lods []lodInfo, utcOffset int64, location *time.Location) []lodInfo {
if len(lods) <= 1 {
return lods
}
return rStart, rEnd
}

func mergeForPointQuery(reqFrom, reqTo int64, lods []lodInfo, utcOffset int64, excessPoints bool) lodInfo {
hasPreKey := lods[0].hasPreKey
preKeyOnly := lods[0].preKeyOnly
from := lods[0].fromSec
to := lods[0].toSec
for _, lod := range lods {
hasPreKey = hasPreKey && lod.hasPreKey
to = lod.toSec
}
fromSec, toSec := roundRangeForPoint(reqFrom, reqTo, lods[0].stepSec, utcOffset, excessPoints)
lod := lods[0]
lod.hasPreKey = hasPreKey
lod.preKeyOnly = preKeyOnly
lod.fromSec = fromSec
lod.toSec = toSec
return lod
fromSec, toSec := roundRange(from, to, lods[0].stepSec, utcOffset, location)
lods = lods[:1]
lods[0].hasPreKey = hasPreKey
lods[0].preKeyOnly = preKeyOnly
lods[0].fromSec = fromSec
lods[0].toSec = toSec
return lods
}