Package com.salesforce.phoenix.schema

Examples of com.salesforce.phoenix.schema.PDataType.toObject()


        Expression expression = getExpression();
        if (!expression.evaluate(tuple, ptr)) {
            return false;
        }
        PDataType type = expression.getDataType();
        Object value = formatter.format(type.toObject(ptr, expression.getColumnModifier()));
        byte[] b = getDataType().toBytes(value);
        ptr.set(b);
        return true;
     }
View Full Code Here


            return true;
        }

        PDataType type = expression.getDataType();
        if (type.isCoercibleTo(PDataType.TIMESTAMP)) {
          Date date = (Date) type.toObject(ptr, expression.getColumnModifier());
          BigDecimal time = new BigDecimal(date.getTime());
            byte[] byteValue = getDataType().toBytes(time);
            ptr.set(byteValue);
            return true;
        }
View Full Code Here

            byte[] byteValue = getDataType().toBytes(time);
            ptr.set(byteValue);
            return true;
        }
       
        String stringValue = (String)type.toObject(ptr, expression.getColumnModifier());
        if (stringValue == null) {
            ptr.set(EMPTY_BYTE_ARRAY);
            return true;
        }
        stringValue = stringValue.trim();
View Full Code Here

        Expression expression = getExpression();
        if (!expression.evaluate(tuple, ptr) || ptr.getLength() == 0) {
            return false;
        }
        PDataType type = expression.getDataType();
        String dateStr = (String)type.toObject(ptr, expression.getColumnModifier());
        try {
            Object value = dateParser.parseObject(dateStr);
            byte[] byteValue = getDataType().toBytes(value);
            ptr.set(byteValue);
            return true;
View Full Code Here

        ImmutableBytesWritable ptr = context.getTempPtr();
        if (node.isStateless()) {
            Object value = null;
            PDataType type = expression.getDataType();
            if (expression.evaluate(null, ptr)) {
                value = type.toObject(ptr);
            }
            return LiteralExpression.newConstant(value, type, expression.isDeterministic());
        }
        boolean isDeterministic = true;
        BuiltInFunctionInfo info = node.getInfo();
View Full Code Here

            // We could potentially not invert the bytes, but we might as well since we're allocating
            // additional space here anyway.
            if (childType.isCoercibleTo(PDataType.VARCHAR)) {
                result = ByteUtil.concat(result, ByteUtil.concat(columnModifier, ptr));
            } else {
                result = ByteUtil.concat(result, PDataType.VARCHAR.toBytes(childType.toObject(ptr, columnModifier).toString()));
            }
        }
        ptr.set(result);
        return true;
    }
View Full Code Here

        return new Timestamp(((DateTime)o).getMillis());
      }
    }
   
    if (targetPhoenixType == inferredPType || inferredPType.isCoercibleTo(targetPhoenixType)) {
      return inferredPType.toObject(o, targetPhoenixType);
    }
   
    throw new RuntimeException(o.getClass().getName()
        + " cannot be coerced to "+targetPhoenixType.toString());
  }
View Full Code Here

        context = context == null ? "" : context;
        ImmutableBytesWritable ptr = new ImmutableBytesWritable();
        assertTrue(expression.evaluate(null, ptr));
        PDataType dataType = expression.getDataType();
        ColumnModifier columnModifier = expression.getColumnModifier();
        Object result = dataType.toObject(ptr.get(), ptr.getOffset(), ptr.getLength(), dataType, columnModifier);
        assertEquals(context, expectedResult, result);
    }
   
    private Expression getLiteral(Object value) throws Exception {
        return LiteralExpression.newConstant(value);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.