FAQ
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-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 | 2 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