Hi Sindhu

Let's start from the beginning. You have some source of data. I'll simulate
this with a vector:

    (def info
      [["Warning" "Something went wrong"]
       ["Status" "Error"]
       ["Sequence Hold" "Holding"]])

No doubt your actual data looks quite different, but bear with me.

Next, I'll construct a tap from the data source. You're probably pulling it
in from a file or database, so your code won't be the same as this:

(def info-tap

  (<- [?category ?message]
      (info :> ?category ?message)))


This demonstrates how to construct a tap using the <- form. The [?category
?message] part tells Cascalog the columns you want outputted, and the (info
:> ?category ?message) part pulls this information from a data source.

Now I have some data, let's look at your problem. You said you want to pull
this information into an array, so that you can check which category is
"Warning" and display only those entries. However, you can do all of this
from within Cascalog itself. In fact, it's just the sort of task that
Cascalog was designed to do.

Let's start by just printing out the categories and messages. We can do
this with the "?-" function:


(?- (stdout) info-tap)


This passes all the entries in info-tap to STDOUT. In other words, it
prints them to the screen.

But we want to print out *just* the warnings, so to do that we need to
create a new tap:

(def warning-tap

  (<- [?category ?message]

      (info-tap :> ?category ?message)

      (= ?category "Warning")))


Do you see how it's almost exactly the same as how I defined "info-tap"?
The only difference is I added a constraint, (= ?category "Warning"). This
filters out only the rows where this constraint is true.

We can print this the same way as we did before:

(?- (stdout) warning-tap)


We can also combine the two previous examples into one. The ?<- form is
equivalent to ?- combined with <-.


(?<- (stdout)
     [?category ?message]

     (info-tap :> ?category ?message)

     (= ?category "Warning")))


Finally, if you really want the output as a data structure, rather than
just printing it out, we can use ??<-.

(def warning-list
  (??<- [?category ?message]

        (info-tap :> ?category ?message)

        (= ?category "Warning")))


Does that make things clearer?

- James


On 27 November 2013 21:43, sindhu hosamane <sindh...@gmail.com> wrote:

> Hello
>
>
> Tried using ??- and ??<-
>
> It didn't work .
>
> I still get an error
>
>
> IllegalArgumentException Parameter declaration let should be a vector
> clojure.core/assert-valid-fdecl (core.clj:6732)
>
>
> my output looks like
>
>
>   Warning
>
>   Warning
>
>   Warning
>
>   Sequence Hold
>
>   Warning
>
>   Sequence Hold
>
>   Sequence Hold
>
>   Status
>
>   Status
>
>   Sequence Hold
>
>
> I want store this output of cascalog query  in a array and then check
> which ?category entry is "warning " and display only those.
>
>
> Tried below code didn't work .
>
>
> (defn checkout
>
>   (let [ x (?<- (stdout)[?category]((select-fields info-tap 
> ["?category"])?category
>
>                                ))]
>
>      (if (= x "Warning")
>
>          println x
>
>
>
>        )))
>
>
> Please help .I am a newbie in clojure .
>
>
>
> On Sunday, November 17, 2013 10:05:50 PM UTC+1, sindhu hosamane wrote:
>>
>> Hello friends ,
>>
>> (?<- (stdout)[?category]((select-fields info-tap ["?category"]) ?category
>> ))
>>
>> Above is my Cascalog query which produces result like :
>>
>>
>> Warning
>>
>> Start inhibit
>>
>> Stop
>>
>> Inhibit
>>
>> Warning
>>
>> Halt
>>
>>
>> how to store the above result in a vector ?
>>
>> my way is
>>
>>
>> (let [x (?<- (stdout)[?category]((select-fields info-tap ["?category"])
>>  ?category
>>
>>                                   ))])
>>
>>
>> is this correct ? but it does not seem working.Or how to store the above
>> result ?
>>
>>
>>
>>
>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to