mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Faster stats.
This commit is contained in:
@@ -28,11 +28,13 @@ type percentile struct {
|
||||
}
|
||||
|
||||
func (q *percentile) Step(ctx sqlite3.Context, arg ...sqlite3.Value) {
|
||||
if a := arg[0]; a.NumericType() != sqlite3.NULL {
|
||||
q.nums = append(q.nums, a.Float())
|
||||
a := arg[0]
|
||||
f := a.Float()
|
||||
if f != 0.0 || a.NumericType() != sqlite3.NULL {
|
||||
q.nums = append(q.nums, f)
|
||||
}
|
||||
if q.kind != median {
|
||||
q.arg1 = append(q.arg1[:0], arg[1].RawText()...)
|
||||
if q.kind != median && q.arg1 == nil {
|
||||
q.arg1 = append(q.arg1, arg[1].RawText()...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,14 +121,18 @@ func (fn *variance) Value(ctx sqlite3.Context) {
|
||||
}
|
||||
|
||||
func (fn *variance) Step(ctx sqlite3.Context, arg ...sqlite3.Value) {
|
||||
if a := arg[0]; a.NumericType() != sqlite3.NULL {
|
||||
fn.enqueue(a.Float())
|
||||
a := arg[0]
|
||||
f := a.Float()
|
||||
if f != 0.0 || a.NumericType() != sqlite3.NULL {
|
||||
fn.enqueue(f)
|
||||
}
|
||||
}
|
||||
|
||||
func (fn *variance) Inverse(ctx sqlite3.Context, arg ...sqlite3.Value) {
|
||||
if a := arg[0]; a.NumericType() != sqlite3.NULL {
|
||||
fn.dequeue(a.Float())
|
||||
a := arg[0]
|
||||
f := a.Float()
|
||||
if f != 0.0 || a.NumericType() != sqlite3.NULL {
|
||||
fn.dequeue(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,14 +182,22 @@ func (fn *covariance) Value(ctx sqlite3.Context) {
|
||||
|
||||
func (fn *covariance) Step(ctx sqlite3.Context, arg ...sqlite3.Value) {
|
||||
b, a := arg[1], arg[0] // avoid a bounds check
|
||||
if a.NumericType() != sqlite3.NULL && b.NumericType() != sqlite3.NULL {
|
||||
fn.enqueue(a.Float(), b.Float())
|
||||
fa := a.Float()
|
||||
fb := b.Float()
|
||||
if true &&
|
||||
(fa != 0.0 || a.NumericType() != sqlite3.NULL) &&
|
||||
(fb != 0.0 || b.NumericType() != sqlite3.NULL) {
|
||||
fn.enqueue(fa, fb)
|
||||
}
|
||||
}
|
||||
|
||||
func (fn *covariance) Inverse(ctx sqlite3.Context, arg ...sqlite3.Value) {
|
||||
b, a := arg[1], arg[0] // avoid a bounds check
|
||||
if a.NumericType() != sqlite3.NULL && b.NumericType() != sqlite3.NULL {
|
||||
fn.dequeue(a.Float(), b.Float())
|
||||
fa := a.Float()
|
||||
fb := b.Float()
|
||||
if true &&
|
||||
(fa != 0.0 || a.NumericType() != sqlite3.NULL) &&
|
||||
(fb != 0.0 || b.NumericType() != sqlite3.NULL) {
|
||||
fn.dequeue(fa, fb)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user