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 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(""); } }
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; } }
@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)); } } });