public synchronized Builder row(Object... values) { rows.add(new MaterializedRow(DEFAULT_PRECISION, values)); return this; }
private static Function<List<Object>, MaterializedRow> dataToRow(final List<Type> types) { return data -> { checkArgument(data.size() == types.size(), "columns size does not match types size"); List<Object> row = new ArrayList<>(); for (int i = 0; i < data.size(); i++) { Object value = data.get(i); Type type = types.get(i); row.add(convertToRowValue(type, value)); } return new MaterializedRow(DEFAULT_PRECISION, row); }; }
public synchronized Builder page(Page page) { requireNonNull(page, "page is null"); checkArgument(page.getChannelCount() == types.size(), "Expected a page with %s columns, but got %s columns", types.size(), page.getChannelCount()); for (int position = 0; position < page.getPositionCount(); position++) { List<Object> values = new ArrayList<>(page.getChannelCount()); for (int channel = 0; channel < page.getChannelCount(); channel++) { Type type = types.get(channel); Block block = page.getBlock(channel); values.add(type.getObjectValue(session, block, position)); } values = Collections.unmodifiableList(values); rows.add(new MaterializedRow(DEFAULT_PRECISION, values)); } return this; }
return new MaterializedRow(MaterializedResult.DEFAULT_PRECISION, row);
return new MaterializedRow(prestoRow.getPrecision(), convertedValues);
}); assertEquals(properties.get("test_string"), new MaterializedRow(1, "test_string", "foo string", "test default", "varchar", "test string property")); assertEquals(properties.get("test_long"), new MaterializedRow(1, "test_long", "424242", "42", "bigint", "test long property")); assertEquals(properties.get(TESTING_CATALOG + ".connector_string"), new MaterializedRow(1, TESTING_CATALOG + ".connector_string", "bar string", "connector default", "varchar", "connector string property")); assertEquals(properties.get(TESTING_CATALOG + ".connector_long"), new MaterializedRow(1, TESTING_CATALOG + ".connector_long", "11", "33", "bigint", "connector long property"));
rowCount = result.getRowCount(); assertEquals(rowCount, 1); assertEquals(result.getMaterializedRows().get(0), new MaterializedRow(DEFAULT_PRECISION, "key2", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)); rowCount = result.getRowCount(); assertEquals(rowCount, 1); assertEquals(result.getMaterializedRows().get(0), new MaterializedRow(DEFAULT_PRECISION, "key3", null, 999, null, null, null, "ansi", false, null, null, null, null, null, null, null, null, null, null));
public synchronized Builder row(Object... values) { rows.add(new MaterializedRow(DEFAULT_PRECISION, values)); return this; }
private static Function<List<Object>, MaterializedRow> dataToRow(final List<Type> types) { return data -> { checkArgument(data.size() == types.size(), "columns size does not match types size"); List<Object> row = new ArrayList<>(); for (int i = 0; i < data.size(); i++) { Object value = data.get(i); Type type = types.get(i); row.add(convertToRowValue(type, value)); } return new MaterializedRow(DEFAULT_PRECISION, row); }; }
private static MaterializedRow toTimeZone(MaterializedRow prestoRow, DateTimeZone oldTimeZone, DateTimeZone newTimeZone) { List<Object> values = new ArrayList<>(); for (int field = 0; field < prestoRow.getFieldCount(); field++) { Object value = prestoRow.getField(field); if (value instanceof Date) { long oldMillis = ((Date) value).getTime(); long newMillis = oldTimeZone.getMillisKeepLocal(newTimeZone, oldMillis); value = new Date(newMillis); } values.add(value); } return new MaterializedRow(prestoRow.getPrecision(), values); }
public synchronized Builder page(Page page) { requireNonNull(page, "page is null"); checkArgument(page.getChannelCount() == types.size(), "Expected a page with %s columns, but got %s columns", types.size(), page.getChannelCount()); for (int position = 0; position < page.getPositionCount(); position++) { List<Object> values = new ArrayList<>(page.getChannelCount()); for (int channel = 0; channel < page.getChannelCount(); channel++) { Type type = types.get(channel); Block block = page.getBlock(channel); values.add(type.getObjectValue(session, block, position)); } values = Collections.unmodifiableList(values); rows.add(new MaterializedRow(DEFAULT_PRECISION, values)); } return this; }
private static MaterializedRow convertToJdbcTypes(MaterializedRow prestoRow) { List<Object> jdbcValues = new ArrayList<>(); for (int field = 0; field < prestoRow.getFieldCount(); field++) { Object prestoValue = prestoRow.getField(field); Object jdbcValue; if (prestoValue instanceof SqlDate) { int days = ((SqlDate) prestoValue).getDays(); jdbcValue = new Date(TimeUnit.DAYS.toMillis(days)); } else if (prestoValue instanceof SqlTime) { jdbcValue = new Time(((SqlTime) prestoValue).getMillisUtc()); } else if (prestoValue instanceof SqlTimeWithTimeZone) { jdbcValue = new Time(((SqlTimeWithTimeZone) prestoValue).getMillisUtc()); } else if (prestoValue instanceof SqlTimestamp) { jdbcValue = new Timestamp(((SqlTimestamp) prestoValue).getMillisUtc()); } else if (prestoValue instanceof SqlTimestampWithTimeZone) { jdbcValue = new Timestamp(((SqlTimestampWithTimeZone) prestoValue).getMillisUtc()); } else { jdbcValue = prestoValue; } jdbcValues.add(jdbcValue); } return new MaterializedRow(prestoRow.getPrecision(), jdbcValues); }
return new MaterializedRow(MaterializedResult.DEFAULT_PRECISION, row);
}); assertEquals(properties.get("test_string"), new MaterializedRow(1, "test_string", "foo string", "test default", "varchar", "test string property")); assertEquals(properties.get("test_long"), new MaterializedRow(1, "test_long", "424242", "42", "bigint", "test long property")); assertEquals(properties.get(TESTING_CATALOG + ".connector_string"), new MaterializedRow(1, TESTING_CATALOG + ".connector_string", "bar string", "connector default", "varchar", "connector string property")); assertEquals(properties.get(TESTING_CATALOG + ".connector_long"), new MaterializedRow(1, TESTING_CATALOG + ".connector_long", "11", "33", "bigint", "connector long property"));
rowCount = result.getRowCount(); assertEquals(rowCount, 1); assertEquals(result.getMaterializedRows().get(0), new MaterializedRow(DEFAULT_PRECISION, "key2", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)); rowCount = result.getRowCount(); assertEquals(rowCount, 1); assertEquals(result.getMaterializedRows().get(0), new MaterializedRow(DEFAULT_PRECISION, "key3", null, 999, null, null, null, "ansi", false, null, null, null, null, null, null, null, null, null, null));
.map(row -> new MaterializedRow(row.getPrecision(), newArrayList(concat(row.getFields(), ImmutableList.of("2015-07-0" + row.getField(0)))))) .collect(toList()), ImmutableList.<Type>builder()