Return-Path: X-Original-To: apmail-tajo-commits-archive@minotaur.apache.org Delivered-To: apmail-tajo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D3C9F19F46 for ; Mon, 18 Apr 2016 09:40:31 +0000 (UTC) Received: (qmail 23841 invoked by uid 500); 18 Apr 2016 09:40:31 -0000 Delivered-To: apmail-tajo-commits-archive@tajo.apache.org Received: (qmail 23803 invoked by uid 500); 18 Apr 2016 09:40:31 -0000 Mailing-List: contact commits-help@tajo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tajo.apache.org Delivered-To: mailing list commits@tajo.apache.org Received: (qmail 23794 invoked by uid 99); 18 Apr 2016 09:40:31 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Apr 2016 09:40:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 22D061A051C for ; Mon, 18 Apr 2016 09:40:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.399 X-Spam-Level: **** X-Spam-Status: No, score=4.399 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, MANY_SPAN_IN_TEXT=2.6, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id uJbC19_i55YL for ; Mon, 18 Apr 2016 09:40:22 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 3BB245FB39 for ; Mon, 18 Apr 2016 09:40:22 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 28EAAE05FF for ; Mon, 18 Apr 2016 09:40:21 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 4927B3A022C for ; Mon, 18 Apr 2016 09:40:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1739720 [2/5] - in /tajo/site: ./ docs/devel/ docs/devel/_static/ docs/devel/backup_and_restore/ docs/devel/configuration/ docs/devel/functions/ docs/devel/index/ docs/devel/partitioning/ docs/devel/sql_language/ docs/devel/storage_plugins... Date: Mon, 18 Apr 2016 09:40:19 -0000 To: commits@tajo.apache.org From: jhkim@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160418094020.4927B3A022C@svn01-us-west.apache.org> Modified: tajo/site/docs/devel/functions/python.html URL: http://svn.apache.org/viewvc/tajo/site/docs/devel/functions/python.html?rev=1739720&r1=1739719&r2=1739720&view=diff ============================================================================== --- tajo/site/docs/devel/functions/python.html (original) +++ tajo/site/docs/devel/functions/python.html Mon Apr 18 09:40:18 2016 @@ -7,7 +7,7 @@ - Python Functions — Apache Tajo 0.11.0 documentation + Python Functions — Apache Tajo 0.12.0-SNAPSHOT documentation @@ -28,7 +28,7 @@ - + @@ -224,21 +224,21 @@ After that, you can register your functi

Please note that you can specify multiple paths with ',' as a delimiter. Each file can contain multiple functions. Here is a typical example of a script file.

-
# /path/to/udf1.py
+
# /path/to/udf1.py
 
-@output_type('int4')
+@output_type('int4')
 def return_one():
   return 1
 
-@output_type("text")
+@output_type("text")
 def helloworld():
-  return 'Hello, World'
+  return 'Hello, World'
 
-# No decorator - blob
+# No decorator - blob
 def concat_py(str):
   return str+str
 
-@output_type('int4')
+@output_type('int4')
 def sum_py(a,b):
   return a+b
 
@@ -250,7 +250,7 @@ After that, you can register your functi

By default, every function has a return type of BLOB. You can use Python decorators to define output types for the script functions. Tajo can figure out return types from the annotations of the Python script.

    -
  • output_type: Defines the return data type for a script UDF in a format that Tajo can understand. The defined type must be one of the types supported by Tajo. For supported types, please refer to Data Model.
  • +
  • output_type: Defines the return data type for a script UDF in a format that Tajo can understand. The defined type must be one of the types supported by Tajo. For supported types, please refer to Data Model.
@@ -267,7 +267,7 @@ You can use Python decorators to define

Function registration¶

To define your Python aggregation functions, you should write Python classes for each function. Followings are typical examples of Python UDAFs.

-
# /path/to/udaf1.py
+
# /path/to/udaf1.py
 
 class AvgPy:
   sum = 0
@@ -280,22 +280,22 @@ Followings are typical examples of Pytho
       self.sum = 0
       self.cnt = 0
 
-  # eval at the first stage
+  # eval at the first stage
   def eval(self, item):
       self.sum += item
       self.cnt += 1
 
-  # get intermediate result
+  # get intermediate result
   def get_partial_result(self):
       return [self.sum, self.cnt]
 
-  # merge intermediate results
+  # merge intermediate results
   def merge(self, list):
       self.sum += list[0]
       self.cnt += list[1]
 
-  # get final result
-  @output_type('float8')
+  # get final result
+  @output_type('float8')
   def get_final_result(self):
       return self.sum / float(self.cnt)
 
@@ -309,20 +309,20 @@ Followings are typical examples of Pytho
   def reset(self):
       self.cnt = 0
 
-  # eval at the first stage
+  # eval at the first stage
   def eval(self):
       self.cnt += 1
 
-  # get intermediate result
+  # get intermediate result
   def get_partial_result(self):
       return self.cnt
 
-  # merge intermediate results
+  # merge intermediate results
   def merge(self, cnt):
       self.cnt += cnt
 
-  # get final result
-  @output_type('int4')
+  # get final result
+  @output_type('int4')
   def get_final_result(self):
       return self.cnt
 
@@ -368,7 +368,7 @@ Followings are typical examples of Pytho

- © Copyright 2015, Apache Tajo Team. + © Copyright 2016, Apache Tajo Team.

@@ -388,7 +388,7 @@ Followings are typical examples of Pytho @@ -731,7 +731,7 @@

- © Copyright 2015, Apache Tajo Team. + © Copyright 2016, Apache Tajo Team.

@@ -751,7 +751,7 @@ @@ -224,7 +224,7 @@

- © Copyright 2015, Apache Tajo Team. + © Copyright 2016, Apache Tajo Team.

@@ -244,7 +244,7 @@