oldMetaData.readFields(in); for (Writable key : oldMetaData.keySet()) { metaData.put(key, oldMetaData.get(key));
@Override public String toString() { StringBuilder sb = new StringBuilder(map.size()); for (Writable wkey : map.keySet()) { sb.append(wkey.toString()); List<String> values = getStringList(new Text(wkey.toString())); sb.append("\t").append(values).append("\n"); } return sb.toString(); } }
private static Map<Object, Object> convertMap(MapWritable input, Map.Entry<Schema, Schema> mapSchema) throws IOException { Schema keySchema = mapSchema.getKey(); if (!keySchema.isCompatible(Schema.of(Schema.Type.STRING))) { throw new IOException("Complex key type not supported: " + keySchema); } Schema valueSchema = mapSchema.getValue(); Map<Object, Object> result = new HashMap<>(); for (Writable key : input.keySet()) { result.put(convertWritables(key, keySchema), convertWritables(input.get(key), valueSchema)); } return result; }
Map<String, String> values = Maps.newHashMap(); for (Writable key : value_.keySet()) { Writable value = value_.get(key); values.put(key.toString(), value != null ? value.toString() : null);
MapWritable b = (MapWritable) copyOfMapOfMaps.get(maps[i]); assertEquals(a.size(), b.size()); for (Writable key: a.keySet()) { assertTrue(b.containsKey(key));
@Test public void testAvroWithNoColumnsSpecified() throws Exception { SqoopOptions opts = new SqoopOptions(); opts.setExportDir("myexportdir"); JdbcExportJob jdbcExportJob = stubJdbcExportJob(opts, FileType.AVRO_DATA_FILE); Job job = new Job(); jdbcExportJob.configureInputFormat(job, null, null, null); assertEquals(asSetOfText("Age", "Name", "Gender"), DefaultStringifier.load(job.getConfiguration(), AvroExportMapper.AVRO_COLUMN_TYPES_MAP, MapWritable.class).keySet()); }
@Test public void testAvroWithMoreColumnsSpecified() throws Exception { SqoopOptions opts = new SqoopOptions(); opts.setExportDir("myexportdir"); String[] columns = { "Age", "Name", "Gender", "Address" }; opts.setColumns(columns); JdbcExportJob jdbcExportJob = stubJdbcExportJob(opts, FileType.AVRO_DATA_FILE); Job job = new Job(); jdbcExportJob.configureInputFormat(job, null, null, null); assertEquals(asSetOfText("Age", "Name", "Gender"), DefaultStringifier.load(job.getConfiguration(), AvroExportMapper.AVRO_COLUMN_TYPES_MAP, MapWritable.class).keySet()); }
@Test public void testAvroWithOneColumnSpecified() throws Exception { SqoopOptions opts = new SqoopOptions(); opts.setExportDir("myexportdir"); String[] columns = { "Gender" }; opts.setColumns(columns); JdbcExportJob jdbcExportJob = stubJdbcExportJob(opts, FileType.AVRO_DATA_FILE); Job job = new Job(); jdbcExportJob.configureInputFormat(job, null, null, null); assertEquals(asSetOfText("Gender"), DefaultStringifier.load(job.getConfiguration(), AvroExportMapper.AVRO_COLUMN_TYPES_MAP, MapWritable.class).keySet()); }
@Test public void testAvroWithAllColumnsSpecified() throws Exception { SqoopOptions opts = new SqoopOptions(); opts.setExportDir("myexportdir"); String[] columns = { "Age", "Name", "Gender" }; opts.setColumns(columns); JdbcExportJob jdbcExportJob = stubJdbcExportJob(opts, FileType.AVRO_DATA_FILE); Job job = new Job(); jdbcExportJob.configureInputFormat(job, null, null, null); assertEquals(asSetOfText("Age", "Name", "Gender"), DefaultStringifier.load(job.getConfiguration(), AvroExportMapper.AVRO_COLUMN_TYPES_MAP, MapWritable.class).keySet()); }
@Test public void testAvroWithSomeColumnsSpecified() throws Exception { SqoopOptions opts = new SqoopOptions(); opts.setExportDir("myexportdir"); String[] columns = { "Age", "Name" }; opts.setColumns(columns); JdbcExportJob jdbcExportJob = stubJdbcExportJob(opts, FileType.AVRO_DATA_FILE); Job job = new Job(); jdbcExportJob.configureInputFormat(job, null, null, null); assertEquals(asSetOfText("Age", "Name"), DefaultStringifier.load(job.getConfiguration(), AvroExportMapper.AVRO_COLUMN_TYPES_MAP, MapWritable.class).keySet()); }
MapWritable b = (MapWritable) copyOfMapOfMaps.get(maps[i]); assertEquals(a.size(), b.size()); for (Writable key: a.keySet()) { assertTrue(b.containsKey(key));
MapWritable b = (MapWritable) copyOfMapOfMaps.get(maps[i]); assertEquals(a.size(), b.size()); for (Writable key: a.keySet()) { assertTrue(b.containsKey(key));