@SuppressWarnings("unchecked") private ReflectionRowReader<T> getReflectionRowReader() { if (rowReader == null) { try { // this can throw a runtime exception from a ClassNotFoundException Type type = typeRepresentation.toType(); rowReader = new ReflectionRowReader<>(objectSchema, (TypeToken<T>) TypeToken.of(type)); } catch (RuntimeException e) { String missingClass = isClassNotFoundException(e); if (missingClass != null) { LOG.error("Cannot load dataset because class {} could not be found. This is probably because the " + "type parameter of the dataset is not present in the dataset's jar file. See the developer " + "guide for more information.", missingClass); } throw e; } } return rowReader; }
@SuppressWarnings("unchecked") private ReflectionRowReader<T> getReflectionRowReader() { if (rowReader == null) { try { // this can throw a runtime exception from a ClassNotFoundException Type type = typeRepresentation.toType(); rowReader = new ReflectionRowReader<>(objectSchema, (TypeToken<T>) TypeToken.of(type)); } catch (RuntimeException e) { String missingClass = isClassNotFoundException(e); if (missingClass != null) { LOG.error("Cannot load dataset because class {} could not be found. This is probably because the " + "type parameter of the dataset is not present in the dataset's jar file. See the developer " + "guide for more information.", missingClass); } throw e; } } return rowReader; }
@Override public void apply() throws Exception { Put put = new Put(rowKey); ReflectionPutWriter<User> putWriter = new ReflectionPutWriter<>(fullSchema); putWriter.write(SAMUEL, put); usersTable.put(put); Row row = usersTable.get(rowKey); ReflectionRowReader<User2> rowReader = new ReflectionRowReader<>(projSchema, TypeToken.of(User2.class)); User2 actual = rowReader.read(row, fullSchema); Assert.assertEquals(projected, actual); } });
@Override public void apply() throws Exception { Put put = new Put(rowKey); ReflectionPutWriter<User> putWriter = new ReflectionPutWriter<>(schema); putWriter.write(obj, put); table.put(put); Row row = table.get(rowKey); ReflectionRowReader<User> rowReader = new ReflectionRowReader<>(schema, TypeToken.of(User.class)); User actual = rowReader.read(row, schema); Assert.assertEquals(obj, actual); } });