@Test public void testFillGPDBWritable() throws Exception { RequestContext context = new RequestContext(); addColumn(context, 0, DataType.INTEGER, "col0"); addColumn(context, 1, DataType.FLOAT8, "col1"); addColumn(context, 2, DataType.REAL, "col2"); addColumn(context, 3, DataType.BIGINT, "col3"); addColumn(context, 4, DataType.SMALLINT, "col4"); addColumn(context, 5, DataType.BOOLEAN, "col5"); addColumn(context, 6, DataType.BYTEA, "col6"); addColumn(context, 7, DataType.VARCHAR, "col7"); addColumn(context, 8, DataType.BPCHAR, "col8"); addColumn(context, 9, DataType.TEXT, "col9"); addColumn(context, 10, DataType.NUMERIC, "col10"); addColumn(context, 11, DataType.TIMESTAMP, "col11"); addColumn(context, 12, DataType.DATE, "col12"); BridgeOutputBuilder builder = makeBuilder(context); output = builder.makeGPDBWritableOutput(); List<OneField> recFields = Arrays.asList( new OneField(DataType.INTEGER.getOID(), 0), new OneField( DataType.FLOAT8.getOID(), (double) 0), new OneField( DataType.REAL.getOID(), (float) 0), new OneField( DataType.BIGINT.getOID(), (long) 0), new OneField( DataType.SMALLINT.getOID(), (short) 0), new OneField( DataType.BOOLEAN.getOID(), true), new OneField( DataType.BYTEA.getOID(), new byte[]{0}), new OneField(DataType.VARCHAR.getOID(), "value"), new OneField( DataType.BPCHAR.getOID(), "value"), new OneField( DataType.TEXT.getOID(), "value"), new OneField( DataType.NUMERIC.getOID(), "0"), new OneField( DataType.TIMESTAMP.getOID(), new Timestamp(0)), new OneField(DataType.DATE.getOID(), new Date(1))); builder.fillGPDBWritable(recFields); assertEquals(output.getInt(0), Integer.valueOf(0)); assertEquals(output.getDouble(1), Double.valueOf(0)); assertEquals(output.getFloat(2), Float.valueOf(0)); assertEquals(output.getLong(3), Long.valueOf(0)); assertEquals(output.getShort(4), Short.valueOf((short) 0)); assertEquals(output.getBoolean(5), true); assertArrayEquals(output.getBytes(6), new byte[]{0}); assertEquals(output.getString(7), "value\0"); assertEquals(output.getString(8), "value\0"); assertEquals(output.getString(9), "value\0"); assertEquals(output.getString(10), "0\0"); assertEquals(Timestamp.valueOf(output.getString(11)), new Timestamp(0)); assertEquals(Date.valueOf(output.getString(12).trim()).toString(), new Date(1).toString()); }
void fillGPDBWritable(List<OneField> recFields) throws BadRecordException { int size = recFields.size(); if (size == 0) { throw new BadRecordException("No fields in record"); } else if (size != schema.length) { throw new BadRecordException("Record has " + size + " fields but the schema size is " + schema.length); } for (int i = 0; i < size; i++) { OneField current = recFields.get(i); if (!isTypeInSchema(current.type, schema[i])) { throw new BadRecordException( String.format("For field %s schema requires type %s but input record has type %s", colNames[i], DataType.get(schema[i]), DataType.get(current.type))); } fillOneGPDBWritableField(current, i); } outputList.add(output); }
BridgeOutputBuilder { void fillGPDBWritable(List<OneField> recFields) throws BadRecordException { int size = recFields.size(); if (size == 0) { throw new BadRecordException("No fields in record"); } else if (size != schema.length) { throw new BadRecordException("Record has " + size + " fields but the schema size is " + schema.length); } for (int i = 0; i < size; i++) { OneField current = recFields.get(i); if (!isTypeInSchema(current.type, schema[i])) { throw new BadRecordException( String.format("For field %s schema requires type %s but input record has type %s", colNames[i], DataType.get(schema[i]), DataType.get(current.type))); } fillOneGPDBWritableField(current, i); } outputList.add(output); } }
BridgeOutputBuilder { void fillGPDBWritable(List<OneField> recFields) throws BadRecordException { int size = recFields.size(); if (size == 0) { throw new BadRecordException("No fields in record"); } else if (size != schema.length) { throw new BadRecordException("Record has " + size + " fields but the schema size is " + schema.length); } for (int i = 0; i < size; i++) { OneField current = recFields.get(i); if (!isTypeInSchema(current.type, schema[i])) { throw new BadRecordException( String.format("For field %s schema requires type %s but input record has type %s", colNames[i], DataType.get(schema[i]), DataType.get(current.type))); } fillOneGPDBWritableField(current, i); } outputList.add(output); } BridgeOutputBuilder(RequestContext context); }
BridgeOutputBuilder { void fillGPDBWritable(List<OneField> recFields) throws BadRecordException { int size = recFields.size(); if (size == 0) { throw new BadRecordException("No fields in record"); } else if (size != schema.length) { throw new BadRecordException("Record has " + size + " fields but the schema size is " + schema.length); } for (int i = 0; i < size; i++) { OneField current = recFields.get(i); if (!isTypeInSchema(current.type, schema[i])) { throw new BadRecordException( String.format("For field %s schema requires type %s but input record has type %s", colNames[i], DataType.get(schema[i]), DataType.get(current.type))); } fillOneGPDBWritableField(current, i); } outputList.add(output); } BridgeOutputBuilder(RequestContext context); Writable getErrorOutput(Exception ex); LinkedList<Writable> makeOutput(List<OneField> recFields); LinkedList<Writable> makeVectorizedOutput(List<List<OneField>> recordsBatch); Writable getPartialLine(); }
BridgeOutputBuilder { void fillGPDBWritable(List<OneField> recFields) throws BadRecordException { int size = recFields.size(); if (size == 0) { throw new BadRecordException("No fields in record"); } else if (size != schema.length) { throw new BadRecordException("Record has " + size + " fields but the schema size is " + schema.length); } for (int i = 0; i < size; i++) { OneField current = recFields.get(i); if (!isTypeInSchema(current.type, schema[i])) { throw new BadRecordException( String.format("For field %s schema requires type %s but input record has type %s", colNames[i], DataType.get(schema[i]), DataType.get(current.type))); } fillOneGPDBWritableField(current, i); } outputList.add(output); } BridgeOutputBuilder(RequestContext context); Writable getErrorOutput(Exception ex); LinkedList<Writable> makeOutput(List<OneField> recFields); LinkedList<Writable> makeVectorizedOutput(List<List<OneField>> recordsBatch); Writable getPartialLine();  }