Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3D0F9DBDE for ; Fri, 20 Jul 2012 04:07:55 +0000 (UTC) Received: (qmail 82366 invoked by uid 500); 20 Jul 2012 04:07:54 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 82168 invoked by uid 500); 20 Jul 2012 04:07:52 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 82121 invoked by uid 99); 20 Jul 2012 04:07:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2012 04:07:51 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of comptechgeeky@gmail.com designates 209.85.220.176 as permitted sender) Received: from [209.85.220.176] (HELO mail-vc0-f176.google.com) (209.85.220.176) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2012 04:07:42 +0000 Received: by vcbfl11 with SMTP id fl11so3302939vcb.35 for ; Thu, 19 Jul 2012 21:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=LgwLoXZegsoxcXZAHY1FBwkILR95j8ruvDjbwNiwZIk=; b=aLQMPHh2EoEN0ETJiEVS+CZxJBKjU1ZRSrbZTyDz+cBv+EKGSJncPKQ15MRHHtKJ1I IHgF/5GIM428SGj69tMxkBjfpZgoOU0HSKzWLnozgtHQMEyrP48J7CD0ffeRuMVSvLMu MFdzksLKhEfrNNobFNUgEQzmn5RYGN5pYRdhlCA3S9n1yTE0diU6bI/JMzpGnRtmf+GP +LpF3+ZwhzSDbsJlUrahS1fdLMNLN94sJSaWFUQcQbe1rjeZ5i1mvBcWfdzija9wz8DQ cCC4vG9qUx5h8VvFPH4r4ADnFSGn0aohuuTX3t5pnXnL2jLagqPx3UIxZA5D/k21J6+8 DIcA== MIME-Version: 1.0 Received: by 10.52.72.79 with SMTP id b15mr2746927vdv.13.1342757241462; Thu, 19 Jul 2012 21:07:21 -0700 (PDT) Received: by 10.58.69.84 with HTTP; Thu, 19 Jul 2012 21:07:21 -0700 (PDT) Date: Thu, 19 Jul 2012 21:07:21 -0700 Message-ID: Subject: What will be the Rank UDF for this particular scenario? From: comptech geeky To: user@hive.apache.org Content-Type: multipart/alternative; boundary=20cf307f362e659e2c04c53b085e --20cf307f362e659e2c04c53b085e Content-Type: text/plain; charset=ISO-8859-1 Below is the table data, I have provided in descending order of time- *BUYER_ID ITEM_ID CREATED_TIME* 1345653 330760137950 2012-07-09 21:41:29 1345653 330760137950 2012-07-09 21:40:29 1345653 110909316904 2012-07-09 21:30:06 1345653 110909316904 2012-07-09 21:29:06 1345653 221065796761 2012-07-09 19:32:48 1345653 221065796761 2012-07-09 19:31:48 1345653 300729306444 2012-07-09 19:02:35 1345653 300729306444 2012-07-09 19:01:35 1345653 150851771618 2012-07-09 18:58:33 1345653 130724723989 2012-07-09 16:00:44 *I need TOP 5 data from above table.* * * So By TOP 5, I mean If you see above Table, first two rows should be counted as 1 because BUYER_ID and ITEM_ID are same in first two rows. Then same with third row and fourth row because again BUYER_ID and ITEM_ID are same, so they will be counted as 2. And same with fifth and sixth row, they will be counted as 3 due to same reason. And same with seventh and eigth row, they will be counted as 4 due to same reason. And ninth row, they will be counted as 5. So I need Output something like this below if I need TOP 5- 1345653 330760137950 2012-07-09 21:41:29 1345653 330760137950 2012-07-09 21:40:29 1345653 110909316904 2012-07-09 21:30:06 1345653 110909316904 2012-07-09 21:29:06 1345653 221065796761 2012-07-09 19:32:48 1345653 221065796761 2012-07-09 19:31:48 1345653 300729306444 2012-07-09 19:02:35 1345653 300729306444 2012-07-09 19:01:35 1345653 150851771618 2012-07-09 18:58:33 So problem statement is like this- If BUYER_ID and ITEM_ID is same *two times(should be configurable)*, then they will be counted as 1. So for this particular problem, what will be Rank UDF? Currently I have Rank UDF as- *public final class RankNew extends UDF{* * private int counter;* * private String last_key1;* * private String last_key2;* * public int evaluate(final String key1, final String key2){* * if ( !key1.equalsIgnoreCase(this.last_key1) && !key2.equalsIgnoreCase(this.last_key2) ) {* * this.counter = 0;* * this.last_key1 = key1;* * this.last_key2 = key2;* * }* * return this.counter++;* * }* *}* --20cf307f362e659e2c04c53b085e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Below is the table data, = I have provided in descending order of time-

=A0

BUYER_ID=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0ITEM_ID=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0CREATED_TIME

1345653=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0330760137950=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A02012-07-09 21:41:29

1345653=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0330760137950=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A02012-07-09 21:40:29

=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0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=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0

1345653=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0150851771618=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A02012-07-09 18:58:33

=A0

1345653=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 130724723989=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A02012-07-09 16:00:44

=A0

I need TOP 5 data from= above table.


So By TOP 5, I mean

If you see above Table, f= irst two rows should be counted as 1 because BUYER_ID and ITEM_ID are same in first two rows.

Then same with third row = and fourth row because again BUYER_ID and ITEM_ID are same, so they will be counted as 2.

And same with fifth and s= ixth row, they will be counted as 3 due to same reason.

And same with seventh and= eigth row, they will be counted as 4 due to same reason.

And ninth row, they will = be counted as 5.

So I need Output something like this below if I need TOP 5-

=A0

1345653=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0330760137950=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A02012-07-09 21:41:29

1345653=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0330760137950=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A02012-07-09 21:40:29

=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A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A0=A0=A0 =A0150851771618=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A02012-07-09 18:58:33


So problem statement is like this-

If BUYER_ID and ITEM_ID i= s same two times(should be configurable), then they will be counted as 1.

<= br>

So f= or this particular problem, what will be Rank UDF? Currently I have Rank UD= F as-


public final class Ra= nkNew extends UDF{

=A0 =A0 private int =A0counter;

=A0 =A0 private String last= _key1;

=A0 =A0 private String last_key2;

=A0 =A0 public int evalua= te(final String key1, final String key2){

=A0if ( !key1.equalsIgnoreCase(this.last_key1) &a= mp;& !key2.equalsIgnoreCase(this.last_key2) ) {

=A0 =A0 this.counter =3D 0;

=

=A0 =A0 this.last_key1 =3D key1;

= =A0 =A0 this.last_key2 =3D key2;

=A0}

= =A0return this.counter++;

=A0 =A0 }

}

--20cf307f362e659e2c04c53b085e--