Skip to content

Instantly share code, notes, and snippets.

@miniway
miniway / gist:5746350
Created June 10, 2013 03:29
An errno replacement
diff --git a/src/main/java/zmq/Ctx.java b/src/main/java/zmq/Ctx.java
index c1703ca..a9780bf 100644
--- a/src/main/java/zmq/Ctx.java
+++ b/src/main/java/zmq/Ctx.java
@@ -130,6 +130,8 @@ public class Ctx {
io_threads = new ArrayList<IOThread>();
sockets = new ArrayList<SocketBase>();
endpoints = new HashMap<String, Endpoint>();
+
+ ZError.clear();

Presto UDF

The core logic for the Presto functions is at FunctionRegistry.java which defineds window, aggregate and scalar types of functions.

We might want to add functions without changing Presto code. then we can implement & use experimental functions easily. But Presto doesn't have a room for UDF, UDAF and UDTF yet.

So here're an idea of how Presto could support UDF and UDAF in a othogonal way. We might not consider UDTF at this time to make thinghs simple but it would not be much different. Also supporting existing Hive UDF is out of scope of this topic and should be an issue of the HiveConnector.

  • Presto already has well-defined plugin arhitecture. Sets of UDF and UDAF functions could be thought as a plugin having a FunctionFactory.class services
  • So UD(A)F functions can be easily a part of exsting connectors or they can build a seperate functions only plugin.
@miniway
miniway / Main.java
Created November 18, 2015 00:04
test case
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.LockSupport;
public class Main
{
public static class ResourcePoolNew
extends ResourcePool<Object> {
diff --git a/presto-main/src/main/java/com/facebook/presto/connector/system/CatalogSystemTable.java b/presto-main/src/main/java/com/facebook/presto/connector/system/CatalogSystemTable.java
index 3c0e699..81d3544 100644
--- a/presto-main/src/main/java/com/facebook/presto/connector/system/CatalogSystemTable.java
+++ b/presto-main/src/main/java/com/facebook/presto/connector/system/CatalogSystemTable.java
@@ -27,6 +27,7 @@ import com.facebook.presto.spi.predicate.TupleDomain;
import javax.inject.Inject;
import java.util.Map;
+import java.util.Optional;
This file has been truncated, but you can view the full file.
k1 | v1 | rnk1 | k2 | v2 | rnk2
--------+---------+--------+--------+---------+--------
44733 | -684.41 | 145641 | 44733 | -684.41 | 145641
129771 | -684.43 | 145642 | 129771 | -684.43 | 145642
20488 | -684.9 | 145643 | 20488 | -684.9 | 145643
24992 | -684.97 | 145644 | 24992 | -684.97 | 145644
146153 | -685.0 | 145645 | 146153 | -685.0 | 145645
79004 | -685.09 | 145646 | 79004 | -685.09 | 145646
63623 | -685.09 | 145646 | 63623 | -685.09 | 145646
147407 | -685.1 | 145648 | 147407 | -685.1 | 145648
import sys
decimals = [
'cr_return_amount','cr_return_tax','cr_return_amt_inc_tax','cr_fee','cr_return_ship_cost','cr_refunded_cash','cr_reversed_charge','cr_store_credit','cr_net_loss',
'ws_wholesale_cost','ws_list_price','ws_sales_price','ws_ext_discount_amt','ws_ext_sales_price','ws_ext_wholesale_cost','ws_ext_list_price','ws_ext_tax','ws_coupon_amt','ws_ext_ship_cost','ws_net_paid','ws_net_paid_inc_tax','ws_net_paid_inc_ship','ws_net_paid_inc_ship_tax','ws_net_profit',
'wr_return_amt','wr_return_tax','wr_return_amt_inc_tax','wr_fee','wr_return_ship_cost','wr_refunded_cash','wr_reversed_charge','wr_account_credit','wr_net_loss',
'sr_return_amt','sr_return_tax','sr_return_amt_inc_tax','sr_fee','sr_return_ship_cost','sr_refunded_cash','sr_reversed_charge','sr_store_credit','sr_net_loss',
'web_gmt_offset','web_tax_percentage',
'w_gmt_offset',
's_gmt_offset','s_tax_precentage',
import os
import sys
import requests
apikey=sys.argv[1]
host=sys.argv[2]
file=sys.argv[3]
headers={
"Authorization": "TD1 %s" % apikey,
"Content-Type": "application/json"
import os
import sys
import requests
import urlparse
apikey=sys.argv[1]
host=sys.argv[2]
database=sys.argv[3]
table=sys.argv[4]
headers={
import os
import sys
import requests
import urlparse
apikey=sys.argv[1]
host=sys.argv[2]
database=sys.argv[3]
table=sys.argv[4]
headers={
require 'uri'
require 'json'
require 'faraday'
require 'presto-client'
require 'date'
def get(url, path)
conn = Faraday.new(url: url) {|faraday|
faraday.adapter Faraday.default_adapter
}