FAQ
This is a good question and I can't really answer you. I suspect there can
be only one aggregation occuring in a request, and combining sorting and
taking top-n yields 2 operations that can't be mixed in a single query ?

Maybe someone with better understanding can answer you.

My workflow is usually write a simple request outputting every wanted
tuples and then I wrap it with first-n. Maybe there's a better way :)

Philippe


On Mon, Jul 8, 2013 at 10:48 AM, Bruno Bonacci wrote:

Hi Philippe

thanks for the response. I just followed the blog post from Nathan
http://nathanmarz.com/blog/new-cascalog-features-outer-joins-combiners-sorting-and-more.html

Why that one doesn't work anymore? Wasn't a Cascalog objective to be able
to use plain Clojure's functions as well?

Bruno
On Saturday, July 6, 2013 3:12:17 PM UTC+1, Philippe Guillebert wrote:

Hi,

You should be using the built-in first-n :

*https://github.com/nathanmarz/cascalog/wiki/Built-in-operations#first-n


*

On Fri, Jul 5, 2013 at 11:23 AM, Bruno Bonacci wrote:

Hi
I'm trying to write a query that returns the topN items by score per
user:

my dataset looks like this:

(def users (map #(vector (str "userid-" %) (str "username-" %) %)
(range 10)))
;=> ( ["userid-0" "username-0" 0] ...

(def items (map #(vector (str "itemid-" %) (str "itemname-" %)) (range
100)))
;=> (["itemid-0" "itemname-0"] ...

(def scores (for [[uid] users, [iid] items] (vector uid iid (rand))))
;=> ( ["userid-9" "itemid-63" 0.3394122528226101] ...



This is my topN function

(defbufferop topN-tuples [tuples] (take 3 tuples))


This is my query

(?<- (stdout)
[?name ?iid ?topX]
(users ?userId ?name _)
(scores ?userId ?iid ?score)
(:sort ?score)
(:reverse true)
(topN-tuples ?score :> ?topX))


But the result yielded by the query seems not matching

can anyone help me to understand where is my mistake?

Bruno

--
You received this message because you are subscribed to the Google
Groups "cascalog-user" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to cascalog-use...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.



--
*
Philippe*
--
You received this message because you are subscribed to the Google Groups
"cascalog-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to cascalog-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
*
Philippe*

--
You received this message because you are subscribed to the Google Groups "cascalog-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cascalog-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 5 | next ›
Discussion Overview
groupcascalog-user @
categoriesclojure, hadoop
postedJul 5, '13 at 9:23a
activeJul 11, '13 at 10:04a
posts5
users3
websiteclojure.org
irc#clojure

People

Translate

site design / logo © 2021 Grokbase