FAQ
Hi, I'd like to use first-n (see http://nathanmarz.github.com/cascalog/cascalog.ops.html#var-first-n)
but I can't seem to execute the query correctly.

Straight from the example:

(def src [[1] [3] [2]]) ;; produces 3 tuples
(def query (<- [?x ?y] (src ?x) (inc ?x :> ?y))) ;; produces ([1 2] [3
4] [2 3]) when executed
(first-n query 1 :sort ["?x"] :reverse true) ;; produces ([3 4]) when
executed

user=> (first-n query 1 :sort ["?x"] :reverse true)
{:type :generator, :id "cdecc924-85da-4d58-801e-4e0e24933f54", :join-
set-var nil, :ground? true, :sourcemap {"dd1782be-1aff-4484-bd2a-
cc05ba7607b1" #<MemorySourceTap cascalog.MemorySourceTap@3e0>}, :pipe
#<Each Each(d5b525f3-48c8-49f3-bee9-99911663d910)
[Identity[decl:ARGS]]>, :outfields ["!__gen11" "!__gen12"], :trapmap
{}}

user=> (?<- (stdout) [?a] (first-n query 1 :sort ["?x"] :reverse
true))
IllegalArgumentException Unable to join predicates together
jackknife.core/throw-illegal (core.clj:100)


How can I execute this?

Thanks,
Avram

Search Discussions

  • Sam Ritchie at Jan 30, 2012 at 8:23 pm
    Avram,

    first-n returns a subquery, which you should execute just like you executed
    query.

    (?- (stdout) query) ;; produces (([1 2] [2 3] [3 4]))
    (?- (stdout) (first-n query 1 :sort ["?x"] :reverse true)) ;; produces (([3
    4]))

    Cheers,
    Sam
    On Mon, Jan 30, 2012 at 12:02 PM, Avram wrote:


    Hi, I'd like to use first-n (see
    http://nathanmarz.github.com/cascalog/cascalog.ops.html#var-first-n)
    but I can't seem to execute the query correctly.

    Straight from the example:

    (def src [[1] [3] [2]]) ;; produces 3 tuples
    (def query (<- [?x ?y] (src ?x) (inc ?x :> ?y))) ;; produces ([1 2] [3
    4] [2 3]) when executed
    (first-n query 1 :sort ["?x"] :reverse true) ;; produces ([3 4]) when
    executed

    user=> (first-n query 1 :sort ["?x"] :reverse true)
    {:type :generator, :id "cdecc924-85da-4d58-801e-4e0e24933f54", :join-
    set-var nil, :ground? true, :sourcemap {"dd1782be-1aff-4484-bd2a-
    cc05ba7607b1" #<MemorySourceTap cascalog.MemorySourceTap@3e0>}, :pipe
    #<Each Each(d5b525f3-48c8-49f3-bee9-99911663d910)
    [Identity[decl:ARGS]]>, :outfields ["!__gen11" "!__gen12"], :trapmap
    {}}

    user=> (?<- (stdout) [?a] (first-n query 1 :sort ["?x"] :reverse
    true))
    IllegalArgumentException Unable to join predicates together
    jackknife.core/throw-illegal (core.clj:100)


    How can I execute this?

    Thanks,
    Avram



    --
    Sam Ritchie, Twitter Inc
    703.662.1337
    @sritchie09

    (Too brief? Here's why! http://emailcharter.org)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcascalog-user @
categoriesclojure, hadoop
postedJan 30, '12 at 8:02p
activeJan 30, '12 at 8:23p
posts2
users2
websiteclojure.org
irc#clojure

2 users in discussion

Avram: 1 post Sam Ritchie: 1 post

People

Translate

site design / logo © 2022 Grokbase