public PreviewPrinter(PrintStream out, ModelManager modelManager, Schema schema) { this.out = out; this.modelManager = modelManager; this.schema = schema; this.stringValues = new String[schema.getColumnCount()]; }
static int nullBitSetSize(Schema schema) { return (schema.getColumnCount() + 7) / 8; }
private static int maxColumnNameLength(Schema schema) { int max = 0; for (int i = 0; i < schema.getColumnCount(); i++) { max = Math.max(max, schema.getColumnName(i).length()); } return max; }
private static int maxColumnTypeNameLength(Schema schema) { int max = 0; for (int i = 0; i < schema.getColumnCount(); i++) { max = Math.max(max, schema.getColumnType(i).toString().length()); } return max; }
public void printRecord(Object... values) throws IOException { int min = Math.min(schema.getColumnCount(), values.length); for (int i = 0; i < min; i++) { stringValues[i] = valueToString(values[i]); } for (int i = min; i < schema.getColumnCount(); i++) { stringValues[i] = valueToString(null); } printRecord(stringValues); }
public TablePreviewPrinter(PrintStream out, ModelManager modelManager, Schema schema) { super(out, modelManager, schema); this.samples = new ArrayList<String[]>(); String[] header = new String[schema.getColumnCount()]; for (int i = 0; i < header.length; i++) { header[i] = schema.getColumnName(i) + ":" + schema.getColumnType(i); } samples.add(header); }
@Override protected void printRecord(String[] values) throws IOException { count++; out.format("*************************** %d ***************************%n", count); for (int i = 0; i < schema.getColumnCount(); i++) { out.format(format, schema.getColumnName(i), schema.getColumnType(i), values[i]); } } }
public PagePrinter(final Schema schema, final String timeZoneId) { this.schema = schema; this.timestampFormatters = new TimestampFormatter[schema.getColumnCount()]; for (int i = 0; i < timestampFormatters.length; i++) { if (schema.getColumnType(i) instanceof TimestampType) { TimestampType type = (TimestampType) schema.getColumnType(i); timestampFormatters[i] = TimestampFormatter.of( getFormatFromTimestampTypeWithDeprecationSuppressed(type), timeZoneId); } } this.record = new ArrayList<String>(schema.getColumnCount()); for (int i = 0; i < schema.getColumnCount(); i++) { record.add(""); } }
@Deprecated // https://github.com/embulk/embulk/issues/937 @SuppressWarnings("deprecation") public PagePrinter(final Schema schema, final org.joda.time.DateTimeZone timezone) { this.schema = schema; this.timestampFormatters = new TimestampFormatter[schema.getColumnCount()]; for (int i = 0; i < timestampFormatters.length; i++) { if (schema.getColumnType(i) instanceof TimestampType) { TimestampType type = (TimestampType) schema.getColumnType(i); // Constructor of TimestampFormatter is deprecated. timestampFormatters[i] = new TimestampFormatter( getFormatFromTimestampTypeWithDeprecationSuppressed(type), timezone); } } this.record = new ArrayList<String>(schema.getColumnCount()); for (int i = 0; i < schema.getColumnCount(); i++) { record.add(""); } }
sb.append("| "); borderBuilder.append("+-"); for (int i = 0; i < schema.getColumnCount(); i++) { if (i != 0) { sb.append(" | ");
static int[] columnOffsets(Schema schema) { int[] offsets = new int[schema.getColumnCount()]; if (!schema.isEmpty()) { offsets[0] = recordHeaderSize(schema); for (int i = 0; i < schema.getColumnCount() - 1; i++) { offsets[i + 1] = offsets[i] + schema.getColumnType(i).getFixedStorageSize(); } } return offsets; } }
public static TimestampFormatter[] newTimestampColumnFormatters( TimestampFormatter.Task formatterTask, Schema schema, Map<String, ? extends TimestampFormatter.TimestampColumnOption> columnOptions) { TimestampFormatter[] formatters = new TimestampFormatter[schema.getColumnCount()]; int i = 0; for (Column column : schema.getColumns()) { if (column.getType() instanceof TimestampType) { Optional<TimestampFormatter.TimestampColumnOption> option = Optional.fromNullable(columnOptions.get(column.getName())); formatters[i] = TimestampFormatter.of(formatterTask, option); } i++; } return formatters; } }
private static Row newRow(Schema schema) { ColumnValue[] values = new ColumnValue[schema.getColumnCount()]; for (Column column : schema.getColumns()) { values[column.getIndex()] = newValue(column); } return new Row(values); }
@Override public void run(TaskSource task, Schema renamedSchema) { assertEquals(originalSchema.getColumnCount(), renamedSchema.getColumnCount()); assertEquals(expected.length, renamedSchema.getColumnCount()); for (int i = 0; i < renamedSchema.getColumnCount(); ++i) { assertEquals(originalSchema.getColumnType(i), renamedSchema.getColumnType(i)); assertEquals(expected[i], renamedSchema.getColumnName(i)); } } });
throw new ConfigException("\"max_length\" in rule \"unique_number_suffix\" must be larger than \"digits\""); int digitsOfNumberOfColumns = Integer.toString(inputSchema.getColumnCount() + offset - 1).length(); if (maxLength.isPresent() && maxLength.get() <= digitsOfNumberOfColumns) { throw new ConfigException("\"max_length\" in rule \"unique_number_suffix\" must be larger than digits of ((number of columns) + \"offset\" - 1)");
while (idx < values.length) { for (int column = 0; column < builder.getSchema() .getColumnCount(); ++column) { Object value = values[idx++]; if (value == null) {
int idx = 0; while (idx < objects.length) { for (int column = 0; column < builder.getSchema().getColumnCount(); ++column) { Object value = objects[idx++]; if (value == null) {
private void checkPage(Schema schema, Page page, final Object... objects) { this.reader = new PageReader(schema); reader.setPage(page); int idx = 0; while (idx < objects.length && reader.nextRecord()) { for (int column = 0; column < reader.getSchema().getColumnCount(); ++column) { Object value = objects[idx++]; if (value == null) { assertEquals(true, reader.isNull(column)); } else if (value instanceof Boolean) { assertEquals(value, reader.getBoolean(column)); } else if (value instanceof Double) { assertEquals(value, reader.getDouble(column)); } else if (value instanceof Long) { assertEquals(value, reader.getLong(column)); } else if (value instanceof String) { assertEquals(value, reader.getString(column)); } else if (value instanceof Timestamp) { assertEquals(value, reader.getTimestamp(column)); } else if (value instanceof Value) { assertEquals(value, reader.getJson(column)); } else { throw new IllegalStateException( "Unsupported type in test utils: " + value.toString()); } } } }