Save the date: ApacheCon Miami, May 15-19, 2017

2016-11-30 Thread Rich Bowen
Dear Apache enthusiast,

ApacheCon and Apache Big Data will be held at the Intercontinental in
Miami, Florida, May 16-18, 2017. Submit your talks, and register, at
http://apachecon.com/  Talks aimed at the Big Data section of the event
should go to
http://events.linuxfoundation.org/events/apache-big-data-north-america/program/cfp
while other talks should go to
http://events.linuxfoundation.org/events/apachecon-north-america/program/cfp


ApacheCon is the best place to meet the people that develop the software
that you use and rely on. It’s also a great opportunity to deepen your
involvement in the project, and perhaps make the leap to contributing.
And we find that user case studies, showcasing how you use Apache
projects to solve real world problems, are very popular at this event.
So, do consider whether you have a use case that might make a good
presentation.

ApacheCon will have many different ways that you can participate:

Technical Content: We’ll have three days of technical sessions covering
many of the projects at the ASF. We’ll be publishing a schedule of talks
on March 9th, so that you can plan what you’ll be attending

BarCamp: The Apache BarCamp is a standard feature of ApacheCon - an
un-conference style event, where the schedule is determined on-site by
the attendees, and anything is fair game.

Lightning Talks: Even if you don’t give a full-length talk, the
Lightning Talks are five minute presentations on any topic related to
the ASF, and can be given by any attendee. If there’s something you’re
passionate about, consider giving a Lightning Talk.

Sponsor: It costs money to put on a conference, and this is a great
opportunity for companies involved in Apache projects, or who benefit
from Apache code - your employers - to get their name and products in
front of the community. Sponsors can start any any monetary level, and
can sponsor everything from the conference badge lanyard, through larger
items such as video recordings and evening events. For more information
on sponsoring ApacheCon, see http://apachecon.com/sponsor/

So, get your tickets today at http://apachecon.com/ and submit your
talks. ApacheCon Miami is going to be our best ApacheCon yet, and you,
and your project, can’t afford to miss it.

-- 
Rich Bowen - rbo...@apache.org
VP, Conferences
http://apachecon.com
@apachecon



issue with phoenix udf

2016-11-30 Thread suyash kharade
Hi,
   I have just started using phoenix. I have implemented udf and deployed
in phoenix. Following is code snippet for udf:


import org.apache.phoenix.expression.function.ScalarFunction;
import org.apache.phoenix.parse.FunctionParseNode.Argument;
import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction;
import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.types.PDouble;
import org.apache.phoenix.schema.types.PVarchar;

@BuiltInFunction(name = CalDistanceFunction.NAME, args = {
@Argument(allowedTypes = { PVarchar.class }),
@Argument(allowedTypes = { PVarchar.class }),
@Argument(allowedTypes = { PVarchar.class }) })
public class CalDistanceFunction extends ScalarFunction {
  Logger LOG = Logger.getLogger(CalDistanceFunction.class);
  public static final String NAME = "CALDIST";
  private String startLat;
  private String startLong;

  public CalDistanceFunction(List children) {
super(children);
init();
  }

  private void init() {
LOG.debug("init function");
LOG.debug("init array size " + getChildren().size());
Expression startLatExp = getChildren().get(0);
Expression startLongExp = getChildren().get(1);
if (startLatExp instanceof LiteralExpression
&& startLongExp instanceof LiteralExpression) {
  startLat = ((LiteralExpression) startLatExp).getValue().toString();
  startLong = ((LiteralExpression) startLongExp).getValue().toString();
}
  }

  @Override
  public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
if (!getChildren().get(2).evaluate(tuple, ptr)) {
  return false;
}
String latLangStr = (String) PVarchar.INSTANCE.toObject(ptr,
getChildren().get(0).getSortOrder());
String[] splits = latLangStr.split(",");
String latStr = splits[0];
String longStr = splits[1];
if (latStr == null || longStr == null) {
  LOG.info("returning null");
  return false;
}
double latValue, longValue, startLatValue, startLongValue;
try {
  latValue = Double.parseDouble(latStr);
  longValue = Double.parseDouble(longStr);
  startLatValue = Double.parseDouble(startLat);
  startLongValue = Double.parseDouble(startLong);
} catch (NumberFormatException e) {
  //LOG.error("evaluation failure", e);
  ptr.set(PDouble.INSTANCE.toBytes(Double.MAX_VALUE));
  return true;
}
double answer =
Math.sqrt(Math.pow(111.699 * (latValue - startLatValue), 2) +
Math.pow(
111.699 * (startLongValue - longValue) * Math.cos(latValue /
57.3),
2));
LOG.debug("dz distance calculated : " + answer);
ptr.set(PDouble.INSTANCE.toBytes(answer));
return true;
  }

  @Override
  public PDataType getDataType() {
return PDouble.INSTANCE;
  }

  @Override
  public String getName() {
return NAME;
  }

}

It woking fine with normal select query

select latitude, longitude, CALDIST('28.1','72.3',
latitude||','||longitude) as dist FROM LOCATION.USER_LOCATIONS_LATEST

but it is giving exception for query with where clause

select latitude, longitude, CALDIST('28.1','72.3',
latitude||','||longitude) as dist FROM LOCATION.USER_LOCATIONS_LATEST where
CALDIST('28.1','72.3', latitude||','||longitude) > 700.0

and exception is

java.util.concurrent.ExecutionException:
org.apache.phoenix.schema.TypeMismatchException: ERROR 203 (22005): Type
mismatch. ERROR 203 (22005): Type mismatch. DOUBLE cannot be coerced to
VARCHAR
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at
org.apache.phoenix.iterate.BaseResultIterators.close(BaseResultIterators.java:802)
at
org.apache.phoenix.iterate.BaseResultIterators.getIterators(BaseResultIterators.java:739)
at
org.apache.phoenix.iterate.BaseResultIterators.getIterators(BaseResultIterators.java:638)
at
org.apache.phoenix.iterate.RoundRobinResultIterator.getIterators(RoundRobinResultIterator.java:176)
at
org.apache.phoenix.iterate.RoundRobinResultIterator.next(RoundRobinResultIterator.java:91)
at org.apache.phoenix.jdbc.PhoenixResultSet.next(PhoenixRe


Thanks,
Suyash