featurebase/dax
Seebs c658e771b0 make percentile work on Decimals, also make Percentile slightly better
So there's a lot going on here.

Percentile just did not work, even a little, with decimals.

In theory we try to make the int val part of ValCount work, in
ValCountize, but you can't actually use that for everything because
it unconditionally adds bsig.Base even when it shouldn't. But it
doesn't matter that we were returning those values from, say,
(Field).MinForShard, because ValCount.Smaller was not preserving them
when identifying the smaller of two Decimal ValCounts anyway.
And even if it did, the logic in Percentile wouldn't have worked
with passing the raw unscaled integer in as a value to compare
against.

But that's fine because the logic was also more generally wrong.
According to the existing logic, a value is the median value if
exactly as many values are less than it as are greater than it.

This is... not actually very accurate to what we usually mean by
"median". Because some values are *equal* to a given value. So
for instance, say you have the values {1, 1, 1, [a million 2s], 3}.
Our logic would regard 2 as being too high to be the median, because
3 times as many values are lower as are higher.

New interpretation: Imagine a sorted list of all your values, with
N entries. You want the Nth percentile, which is to say, you want N%
of values to be less than the vale you pick, and (100-N)% to be greater.
You can round both of these down. So for instance, if you have 6 values,
and want the median, you want 3 values greater, and 3 values less. To
be picky, we could demand the average of those middle two values, but
we're not in a good position to do that in this implementation.

If the number of desired things less than, or greater than, a target
is 0, we can short-circuit to the minimum or maximum value. This can
happen when nth is close to an end and the number of things is small,
not just at nth=0/nth=100.

So we rework this, and we rework the tests for this behavior to reflect
that logic.

We change executePercentile to be able to return a nil rather than
a weird ValCount in cases where there's no result, such as when
there's no values to compute a percentile of.

We also change the SQL tests to match the new behavior, since some
of them were expecting everything done on a decimal field with values
10-13 to come back as 10.00 as a decimal because that is what the
code returned.

We also propagate these changes to DAX, and along the way, fix up a
TODO item in the DAX copy, and stop skipping the test that was
failing because of that TODO item.
2023-04-07 15:52:26 -05:00
..
computer Add HasDirective to dax.Node struct to force Directive on restart (#2335) 2023-03-21 13:22:16 -05:00
controller Cloud 1475 (#2371) 2023-04-07 15:08:07 -04:00
http Remove MDS and replace it with Controller (#2219) 2023-01-30 16:54:12 -06:00
migrations Remove Node from data model; standardize on Worker (#2366) 2023-04-04 20:20:53 -05:00
models Remove Node from data model; standardize on Worker (#2366) 2023-04-04 20:20:53 -05:00
queryer make percentile work on Decimals, also make Percentile slightly better 2023-04-07 15:52:26 -05:00
server RetryWithTx (#2348) 2023-03-30 20:54:37 -05:00
snapshotter Sqldb rip boltdb (#2341) 2023-03-22 08:54:13 -05:00
storage hacky workaround: use locking to quiet race detector problems 2023-03-28 11:56:23 -05:00
test make percentile work on Decimals, also make Percentile slightly better 2023-04-07 15:52:26 -05:00
writelogger Support for setting individual DatabaseOptions (#2231) 2023-02-06 08:50:28 -06:00
address.go Database isolation: Balancer (#2407) 2023-01-19 22:10:08 +00:00
address_test.go Sync from private repo to commit 12d608c80d 2022-12-12 09:01:20 -08:00
controller.go Add Drop Database and Drop Table support (#2208) 2023-01-23 19:59:47 -06:00
dax.go Remove MDS and replace it with Controller (#2219) 2023-01-30 16:54:12 -06:00
directive.go RetryWithTx (#2348) 2023-03-30 20:54:37 -05:00
errors.go Cloud 1457 (#2347) 2023-03-23 16:20:45 -04:00
Makefile Cloud 1358 bolt postgres (#2286) 2023-03-20 09:02:22 -05:00
migrations.go Cloud 1358 bolt postgres (#2286) 2023-03-20 09:02:22 -05:00
README.md introduce performance counters and system table fanout, plus refactor metrics (#2363) 2023-01-19 21:35:02 +00:00
role.go Remove Node from data model; standardize on Worker (#2366) 2023-04-04 20:20:53 -05:00
schema.go Support for setting individual DatabaseOptions (#2231) 2023-02-06 08:50:28 -06:00
service_manager.go tweak a bunch of logging and config (#2234) 2023-02-03 14:59:07 -06:00
snapshot.go remove version/directive stuff from other snapshot endpoints 2023-01-10 23:22:58 +00:00
table.go support null/non-null tests for non-BSI fields 2023-03-24 16:01:09 -05:00
table_test.go FB-1968 timestamp data type related fixes and enhancements (#2256) 2023-02-24 14:57:17 -05:00
time.go Add DAX - full list of squashed commits below 2022-12-12 09:01:20 -08:00
transaction.go RetryWithTx (#2348) 2023-03-30 20:54:37 -05:00
transaction_test.go RetryWithTx (#2348) 2023-03-30 20:54:37 -05:00
versioned_partition.go first cut at removing all the shard/field/partition versioning 2023-01-10 23:27:40 +00:00
versioned_shard.go first cut at removing all the shard/field/partition versioning 2023-01-10 23:27:40 +00:00
worker.go Remove Node from data model; standardize on Worker (#2366) 2023-04-04 20:20:53 -05:00
workerjob.go RetryWithTx (#2348) 2023-03-30 20:54:37 -05:00
workerjob_test.go RetryWithTx (#2348) 2023-03-30 20:54:37 -05:00

DAX

DAX encapsulates anything which covers all of the services which make up the "disaggregation of storage and compute" project. Initially, this will include integration tests which pull in things like Metadata Services (MDS), including the Controller, as well as FeatureBase and IDK-based ingesters.

Setting up the tests

The DAX test currently requires docker images for: featurebase and datagen.

If at any point you run into problems with go mod failing to reference a private repo, make sure that you have gitlab.com/featurebasedb in your GOPRIVATE environment variable.

Note that during the docker image build step, go mod vendor is run, which creates a vendor directory in the root directory, and copies that to docker during the build stage. Just be aware of this; you may want to remove that vendor directory after you're done building docker images.

Possible Configuruation

The following were relevent when the dax code was in a separate repository. These may no longer be relevant.

I needed to but this in my ~/.profile file:

export GOPRIVATE=github.com/featurebasedb,gitlab.com/featurebasedb

And this in my ~/.gitconfig

[url "ssh://git@github.com/"]
	insteadOf = https://github.com/
[url "ssh://git@gitlab.com/"]
	insteadOf = https://gitlab.com/

Then make docker ran successfully.

Build the FeatureBase docker image

  • Check out the dax branch of the featurebase repository.
  • Run make docker-image-featurebase to build the docker image
  • You should now have an image in docker named dax/featurebase with the tag latest.

Build the Datagen docker image

  • cd <featurebase_repo_root>/idk
  • Run make docker-image-datagen to build the docker image
  • You should now have an image in docker named dax/datagen with the tag latest.

Running the tests

  • Check out the dax branch of the featurebase repository.
  • Change into the dax directory: cd dax
  • Run make test-integration.