* a Cast to convert the bytearray to string. Though in reality
* the input to the cast is already a string
*/
@Test
public void testByteArrayToOtherNoCast() throws PlanException, ExecException {
POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
PhysicalPlan plan = constructPlan(op);
TupleFactory tf = TupleFactory.getInstance();
{
Tuple t = tf.newTuple();
Integer input = new Integer(r.nextInt());
t.append(input);
plan.attachInput(t);
Result res = op.getNext(new Integer(0));
if(res.returnStatus == POStatus.STATUS_OK) {
//System.out.println(res.result + " : " + i);
assertEquals(input, res.result);
}
}
{
// create a new POCast each time since we
// maintain a state variable per POCast object
// indicating if cast is really required
POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
plan = constructPlan(newOp);
Tuple t = tf.newTuple();
Float input = new Float(r.nextFloat());
t.append(input);
plan.attachInput(t);
Result res = newOp.getNext(new Float(0));
if(res.returnStatus == POStatus.STATUS_OK) {
//System.out.println(res.result + " : " + i);
assertEquals(input, res.result);
}
}
{
// create a new POCast each time since we
// maintain a state variable per POCast object
// indicating if cast is really required
POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
plan = constructPlan(newOp);
Tuple t = tf.newTuple();
Long input = new Long(r.nextLong());
t.append(input);
plan.attachInput(t);
Result res = newOp.getNext(new Long(0));
if(res.returnStatus == POStatus.STATUS_OK) {
//System.out.println(res.result + " : " + i);
assertEquals(input, res.result);
}
}
{
// create a new POCast each time since we
// maintain a state variable per POCast object
// indicating if cast is really required
POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
plan = constructPlan(newOp);
Tuple t = tf.newTuple();
Double input = new Double(r.nextDouble());
t.append(input);
plan.attachInput(t);
Result res = newOp.getNext(new Double(0));
if(res.returnStatus == POStatus.STATUS_OK) {
//System.out.println(res.result + " : " + i);
assertEquals(input, res.result);
}
}
{
// create a new POCast each time since we
// maintain a state variable per POCast object
// indicating if cast is really required
POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
plan = constructPlan(newOp);
Tuple t = tf.newTuple();
Tuple input = GenRandomData.genRandSmallTuple("test", 1);
t.append(input);
plan.attachInput(t);
Result res = newOp.getNext(tf.newTuple());
if(res.returnStatus == POStatus.STATUS_OK) {
//System.out.println(res.result + " : " + str);
assertEquals(input, res.result);
}
}
{
// create a new POCast each time since we
// maintain a state variable per POCast object
// indicating if cast is really required
POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
plan = constructPlan(newOp);
Tuple t = tf.newTuple();
DataBag input = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
t.append(input);
plan.attachInput(t);
Result res = newOp.getNext(DefaultBagFactory.getInstance().newDefaultBag());
if(res.returnStatus == POStatus.STATUS_OK) {
//System.out.println(res.result + " : " + str);
assertEquals(input, res.result);
}
}
{
// create a new POCast each time since we
// maintain a state variable per POCast object
// indicating if cast is really required
POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
plan = constructPlan(newOp);
Tuple t = tf.newTuple();
Map<Object, Object> input = new HashMap<Object, Object>();
input.put("key1", "value1");
input.put("key2", "value2");
t.append(input);
plan.attachInput(t);
Result res = newOp.getNext(new HashMap<Object, Object>());
if(res.returnStatus == POStatus.STATUS_OK) {
//System.out.println(res.result + " : " + str);
assertEquals(input, res.result);
}
}