use of org.apache.asterix.external.library.java.JObjects.JPoint3D in project asterixdb by apache.
the class AllTypesFunction method evaluate.
@Override
public void evaluate(IFunctionHelper functionHelper) throws Exception {
newFieldList.clear();
JRecord inputRecord = (JRecord) functionHelper.getArgument(0);
JInt id = (JInt) inputRecord.getValueByName("id");
JString name = (JString) inputRecord.getValueByName("name");
JFloat age = (JFloat) inputRecord.getValueByName("age");
JDouble salary = (JDouble) inputRecord.getValueByName("salary");
JBoolean married = (JBoolean) inputRecord.getValueByName("married");
JUnorderedList interest = (JUnorderedList) inputRecord.getValueByName("interests");
JOrderedList children = (JOrderedList) inputRecord.getValueByName("children");
JRecord address = (JRecord) inputRecord.getValueByName("address");
JDate dob = (JDate) inputRecord.getValueByName("dob");
JTime time = (JTime) inputRecord.getValueByName("time");
JDateTime dateTime = (JDateTime) inputRecord.getValueByName("datetime");
JDuration duration = (JDuration) inputRecord.getValueByName("duration");
JPoint location2d = (JPoint) inputRecord.getValueByName("location2d");
JPoint3D location3d = (JPoint3D) inputRecord.getValueByName("location3d");
JLine line = (JLine) inputRecord.getValueByName("line");
JPolygon polygon = (JPolygon) inputRecord.getValueByName("polygon");
JCircle circle = (JCircle) inputRecord.getValueByName("circle");
JRecord result = (JRecord) functionHelper.getResultObject();
result.setField("id", id);
result.setField("name", name);
result.setField("age", age);
result.setField("salary", salary);
result.setField("married", married);
result.setField("interests", interest);
result.setField("children", children);
JInt zipCode = (JInt) functionHelper.getObject(JTypeTag.INT);
zipCode.setValue(92841);
address.addField("Zipcode", zipCode);
result.setField("address", address);
result.setField("dob", dob);
result.setField("time", time);
result.setField("datetime", dateTime);
result.setField("duration", duration);
result.setField("location2d", location2d);
result.setField("location3d", location3d);
result.setField("line", line);
result.setField("polygon", polygon);
result.setField("circle", circle);
JString newFieldString = (JString) functionHelper.getObject(JTypeTag.STRING);
newFieldString.setValue("processed");
result.addField("status", newFieldString);
/*
* JString element = (JString)
* functionHelper.getObject(JTypeTag.STRING); element.setValue("raman");
* newFieldList.add(element); result.addField("mylist", newFieldList);
*/
JString newFieldString2 = (JString) functionHelper.getObject(JTypeTag.STRING);
newFieldString2.setValue("this is working");
result.addField("working", newFieldString);
functionHelper.setResult(result);
}
use of org.apache.asterix.external.library.java.JObjects.JPoint3D in project asterixdb by apache.
the class JTypeObjectFactory method create.
@Override
public IJObject create(IAType type) {
IJObject retValue = null;
switch(type.getTypeTag()) {
case INTEGER:
retValue = new JInt(0);
break;
case STRING:
retValue = new JString("");
break;
case FLOAT:
retValue = new JFloat(0);
break;
case DOUBLE:
retValue = new JDouble(0);
break;
case BOOLEAN:
retValue = new JBoolean(false);
break;
case CIRCLE:
retValue = new JCircle(new JPoint(0, 0), 0);
break;
case POINT:
retValue = new JPoint(0, 0);
break;
case POINT3D:
retValue = new JPoint3D(0, 0, 0);
break;
case POLYGON:
retValue = new JPolygon(new JPoint[] {});
break;
case LINE:
retValue = new JLine(new JPoint(0, 0), new JPoint(0, 0));
break;
case RECTANGLE:
retValue = new JRectangle(new JPoint(0, 0), new JPoint(1, 1));
break;
case DATE:
retValue = new JDate(0);
break;
case DATETIME:
retValue = new JDateTime(0);
break;
case DURATION:
retValue = new JDuration(0, 0);
break;
case INTERVAL:
retValue = new JInterval(0, 0);
break;
case TIME:
retValue = new JTime(0);
break;
case BIGINT:
retValue = new JLong(0);
break;
case NULL:
retValue = JObjects.JNull.INSTANCE;
break;
case MISSING:
retValue = JObjects.JMissing.INSTANCE;
break;
case ARRAY:
AOrderedListType ot = (AOrderedListType) type;
IAType orderedItemType = ot.getItemType();
IJObject orderedItemObject = create(orderedItemType);
retValue = new JOrderedList(orderedItemObject);
break;
case MULTISET:
AUnorderedListType ut = (AUnorderedListType) type;
IAType unorderedItemType = ut.getItemType();
IJObject unorderedItemObject = create(unorderedItemType);
retValue = new JUnorderedList(unorderedItemObject);
break;
case OBJECT:
IAType[] fieldTypes = ((ARecordType) type).getFieldTypes();
IJObject[] fieldObjects = new IJObject[fieldTypes.length];
int index = 0;
for (IAType fieldType : fieldTypes) {
fieldObjects[index] = create(fieldType);
index++;
}
retValue = new JRecord((ARecordType) type, fieldObjects);
break;
case UNION:
AUnionType unionType = (AUnionType) type;
IJObject itemObject = null;
if (unionType.isMissableType()) {
itemObject = create(unionType);
}
retValue = itemObject;
break;
default:
break;
}
return retValue;
}
Aggregations