/** * Parse a line of a CSV into a Honeycomb {@link Row} * * @param line CSV line * @return Honeycomb {@link Row} * @throws IOException The CSV line was improperly formed * @throws ParseException The CSV line contained invalid data. */ public Row parseRow(String line) throws IOException, ParseException { checkNotNull(line); String[] unparsedFields = csvParser.parseLine(line); checkArgument((schema.getColumns().size() == unparsedFields.length), "Line contains wrong number of columns."); ImmutableMap.Builder<String, ByteBuffer> fields = ImmutableMap.builder(); for (int i = 0; i < columns.length; i++) { fields.put(columns[i], FieldParser.parse(unparsedFields[i], schema.getColumnSchema(columns[i]))); } return new Row(fields.build(), UUID.randomUUID()); } }
@Test(expected = NullPointerException.class) public void testGetColumnSchemaInvalidColumnName() { tableSchema.getColumnSchema(null); }
@Test(expected = IllegalArgumentException.class) public void testGetColumnSchemaEmptyColumnName() { tableSchema.getColumnSchema(""); }
if (record != null) { byte[] encodedRecord = encodeValue(record, tableSchema.getColumnSchema(column)); encodedRecords.add(order == SortOrder.Ascending ? encodedRecord
@Test public void testGetColumnSchemaValidColumnName() { final TableSchema schema = new TableSchema(ImmutableList.<ColumnSchema>of(FAKE_COL_SCHEMA), INDICES); final ColumnSchema actual = schema.getColumnSchema(FAKE_COL_SCHEMA.getColumnName()); assertEquals(FAKE_COL_SCHEMA.getColumnName(), actual.getColumnName()); assertEquals(FAKE_COL_SCHEMA, actual); }