writer.finish();
Schema schema = writer.getSchema();
Tuple tuple = TypesUtils.createTuple(schema);
BasicTable.Writer writer1 = new BasicTable.Writer(path, conf);
int part = 0;
TableInserter inserter = writer1.getInserter("part" + part, true);
TypesUtils.resetTuple(tuple);
DataBag bag2 = TypesUtils.createBag();
Schema schColl2 = schema.getColumn(7).getSchema();
Tuple tupColl2_1 = TypesUtils.createTuple(schColl2);
Tuple tupColl2_2 = TypesUtils.createTuple(schColl2);
// add data to row 1
tuple.set(0, new DataByteArray("column1 row 1 ")); // byte
tuple.set(1,new DataByteArray("column2 row 1"));
tuple.set(2, new DataByteArray("column3 row 1"));
tuple.set(3, new DataByteArray("column4 row 1"));
// column5
Map<String, String> column5 = new HashMap<String, String>();
column5.put("key51", "key511");
column5.put("key52", "key521");
column5.put("key53", "key531");
column5.put("key54", "key541");
column5.put("key55", "key551");
column5.put("key56", "key561");
column5.put("key57", "key571");
tuple.set(4, column5);
//column5:map(bytes),column6:map(bytes),column7:map(bytes),column8:collection(f1:map(bytes)
//column7:map(String, column6:map(String)
HashMap<String, String> column7 = new HashMap<String, String>();
HashMap<String, String> column6 = new HashMap<String, String>();
column6.put("column61", "column61");
column7.put("key71", "key711");
column7.put("key72", "key721");
column7.put("key73", "key731");
column7.put("key74", "key741");
column7.put("key75", "key751");
tuple.set(6, column7);
tuple.set(5, column6);
//column8:collection(f1:map(bytes))
HashMap<String, String> mapInCollection = new HashMap<String, String>();
mapInCollection.put("mc", "mc1");
tupColl2_1.set(0, mapInCollection);
bag2.add(tupColl2_1);
tupColl2_2.set(0, mapInCollection);
bag2.add(tupColl2_2);
tuple.set(7, bag2);
int row = 0;
inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
.getBytes()), tuple);
// row 2
row++;
TypesUtils.resetTuple(tuple);
column5.clear();
column7.clear();
column6.clear();
mapInCollection.clear();
bag2.clear();
TypesUtils.resetTuple(tupColl2_1);
TypesUtils.resetTuple(tupColl2_2);
tuple.set(0, new DataByteArray("column1 row 2 ")); // byte
tuple.set(1,new DataByteArray("column2 row 2"));
tuple.set(2, new DataByteArray("column3 row 2"));
tuple.set(3, new DataByteArray("column4 row 2"));
// column5
column5.put("key51", "key512");
column5.put("key52", "key522");
column5.put("key53", "key532");
column5.put("key54", "key542");
column5.put("key55", "key552");
column5.put("key56", "key562");
column5.put("key57", "key572");
tuple.set(4, column5);
// column6
column6.put("column6", "column62");
column7.put("key71", "key712");
column7.put("key72", "key722");
column7.put("key73", "key732");
column7.put("key74", "key742");
column7.put("key75", "key752");
tuple.set(6, column7);
tuple.set(5, column6);
//column8
//column8:collection(f1:map(bytes))
mapInCollection.put("mc", "mc2");
tupColl2_1.set(0, mapInCollection);
bag2.add(tupColl2_1);
tupColl2_2.set(0, mapInCollection);
bag2.add(tupColl2_2);
tuple.set(7, bag2);
inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
.getBytes()), tuple);
// finish building table, closing out the inserter, writer, writer1
inserter.close();
writer1.finish();
writer.close();
}