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

fix bug in lake scan when merging by non-ts pool key #2752

Merged
merged 1 commit into from
May 21, 2021
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
11 changes: 10 additions & 1 deletion lake/sorted.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,17 @@ func newSortedScanner(ctx context.Context, pool *Pool, zctx *zson.Context, filte
sched: sched,
})
}
keys := pool.Layout.Keys
var merger zbuf.Puller
if len(pullers) == 1 {
merger = pullers[0]
} else if len(keys) > 0 && len(keys[0]) == 1 && keys[0][0] == "ts" {
merger = zbuf.MergeByTs(ctx, pullers, pool.Layout.Order)
Copy link
Member

Choose a reason for hiding this comment

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

We're eventually going to have to address the fact that zbuf.MergeByTs doesn't do the right thing for records with a non-time ts field.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this can easily be part of the JIT-CG. The scan scheduler can look at the metadata across a partition to see inspect the type signature(s) for the pool key.

} else {
merger = zbuf.NewMerger(ctx, pullers, importCompareFn(pool))
}
return &sortedPuller{
Puller: zbuf.MergeByTs(ctx, pullers, pool.Layout.Order),
Puller: merger,
Closer: closers,
}, nil
}
Expand Down
54 changes: 54 additions & 0 deletions lake/ztests/merge-by-addr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
script: |
export ZED_LAKE_ROOT=test
zed lake init -q
zed lake create -q -S 75B -p logs -orderby addr:asc
zed lake load -q -p logs in.zson
zed lake query -z 'from logs | cut addr'

inputs:
- name: in.zson
data: |
{ts:2018-03-24T17:16:15.624089Z,addr:10.128.0.241,uid:"CzJyWf4UbQbYGKPUKl"}
{ts:2018-03-24T17:15:32.124366Z,addr:10.128.0.248,uid:"CzMQei2GoNVRxPPeGa"}
{ts:2018-03-24T17:16:18.196163Z,addr:10.128.0.241,uid:"CzNWmr24TkNjgiqZrj"}
{ts:2018-03-24T17:16:19.296543Z,addr:10.128.0.241,uid:"CzPcfx16mAtMJ8cobl"}
{ts:2018-03-24T17:15:30.829612Z,addr:10.128.0.248,uid:"CzSVzs15FHBuzD849l"}
{ts:2018-03-24T17:15:49.212749Z,addr:10.174.251.215,uid:"CzUF5T1E9rGyFlVpUj"}
{ts:2018-03-24T17:15:43.820748Z,addr:10.47.1.10,uid:"CzVIzI28Lv7h63ygtk"}
{ts:2018-03-24T17:16:15.204827Z,addr:10.128.0.241,uid:"CzX38EuDhrdMCAry"}
{ts:2018-03-24T17:15:59.246551Z,addr:10.128.0.248,uid:"CzZyLD2vB5NSfav0l6"}
{ts:2018-03-24T17:15:37.161368Z,addr:10.224.110.133,uid:"CzaCxT2532474LLLU6"}
{ts:2018-03-24T17:16:09.025779Z,addr:10.47.7.10,uid:"CzatK01nVTMr13XNg8"}
{ts:2018-03-24T17:16:18.194559Z,addr:10.128.0.241,uid:"CzcoU9nOnSmtCMqnj"}
{ts:2018-03-24T17:16:16.762659Z,addr:10.128.0.241,uid:"CzcswW3cTVbkkhxu62"}
{ts:2018-03-24T17:15:33.284901Z,addr:10.224.110.133,uid:"CzeOmZxRd4CShWLR5"}
{ts:2018-03-24T17:15:49.790699Z,addr:10.47.5.100,uid:"CzkWyj3ANVuSANwQT8"}
{ts:2018-03-24T17:16:19.270496Z,addr:10.128.0.241,uid:"Czm7ey4b2kDXx89kw5"}
{ts:2018-03-24T17:16:15.625193Z,addr:10.128.0.241,uid:"CzngVe10knDMmjcf12"}
{ts:2018-03-24T17:15:46.091461Z,addr:10.47.6.154,uid:"Czqhh93DQVJjU5Igr5"}
{ts:2018-03-24T17:15:23.461005Z,addr:10.47.2.153,uid:"Czrzs74DZscCd8oMn7"}
{ts:2018-03-24T17:16:16.958922Z,addr:10.128.0.241,uid:"Czs9Fm3TxKlTX3LTPh"}

outputs:
- name: stdout
data: |
{addr:10.47.1.10}
{addr:10.47.2.153}
{addr:10.47.5.100}
{addr:10.47.6.154}
{addr:10.47.7.10}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.241}
{addr:10.128.0.248}
{addr:10.128.0.248}
{addr:10.128.0.248}
{addr:10.174.251.215}
{addr:10.224.110.133}
{addr:10.224.110.133}