/** * Deserialize the provided serialized row buffer to a new {@link Row} instance * * @param serializedRow byte buffer containing serialized Row * @return new Row instance from serializedRow */ public static Row deserialize(byte[] serializedRow) { checkNotNull(serializedRow); checkArgument(serializedRow.length > 0); SchemaVersionUtils.processSchemaVersion(serializedRow[0], RowSchemaInfo.VER_CURRENT); return new Row(Util.deserializeAvroObject(serializedRow, reader)); }
/** * 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()); } }
@Override public Row next() { ImmutableMap.Builder<String, ByteBuffer> records = ImmutableMap.builder(); for (Map.Entry<String, Generator<ByteBuffer>> record : recordGenerators.entrySet()) { ByteBuffer nextValue = record.getValue().next(); if (nextValue != null) { records.put(record.getKey(), nextValue); } } return new Row(records.build(), uuids.next()); } }