m1ha-shvn / django-pg-hll Goto Github PK
View Code? Open in Web Editor NEWProvides a django wrapper for postgresql-hll library by CitusData
License: BSD 3-Clause "New" or "Revised" License
Provides a django wrapper for postgresql-hll library by CitusData
License: BSD 3-Clause "New" or "Revised" License
Can't create empty HllSet()
without parameters
As provided in PR #7 by @markallanson, not all hll functions available are implemented in this library.
I've found a reference.
TODO list
HllFieldTest.test_create_custom_params
using hll empty optional parametersI'm trying to leverage the power of hll by having annotations for stats within a date range, but unsure of the best way to approach this. Basically, I'm trying to somewhat mimic the date stuff they've described in https://github.com/citusdata/postgresql-hll#data-warehouse-use-case
My use case is needing all of the results, but ordered by view count (like needing to order by top viewed this month). So just .filter() within a date range wouldn't work by itself since it filters out objects from the queryset.
Here's a model example:
class Thing(models.Model):
...
class Stats(models.Model):
parent = models.ForeignKey(Thing, related_name='stats', on_delete=models.CASCADE)
hll = HllField()
date = models.DateField(auto_now_add=True, editable=False)
My attempt at it:
from django.utils.datetime_safe import date
monthly = date.today() - timedelta(days=30)
queryset = Thing.objects.all().annotate(
month_view_count=Coalesce(UnionAggCardinality('stats__hll', filter=Q(stats__date__gte=monthly)), 0),
).order_by('month_view_count')
queryset[0]
django.db.utils.ProgrammingError: FILTER specified, but hll_cardinality is not an aggregate function
LINE 1: ...l_timestamp", "things_thing"."featured", COALESCE(hll_cardin...
^
Any ideas of what I should look more into or try out? I've been trying to avoid getting really messy, and it feels like there's a 1 liner here that I'm not thinking of that would do it.
I'll be looking into postgres conditionals next, but curious if this is easier than what I'm making it out to be.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.