pathTable1 = new Path(pathWorking, "1");
System.out.println("pathTable1 =" + pathTable1);
BasicTable.Writer writer = new BasicTable.Writer(pathTable1, STR_SCHEMA1,
STR_STORAGE1, false, conf);
Schema schema = writer.getSchema();
Tuple tuple = TypesUtils.createTuple(schema);
BasicTable.Writer writer1 = new BasicTable.Writer(pathTable1, conf);
int part = 0;
TableInserter inserter = writer1.getInserter("part" + part, true);
TypesUtils.resetTuple(tuple);
DataBag bag1 = TypesUtils.createBag();
Schema schColl = schema.getColumn(0).getSchema();
Tuple tupColl1 = TypesUtils.createTuple(schColl);
Tuple tupColl2 = TypesUtils.createTuple(schColl);
int row = 0;
tupColl1.set(0, "1.1");
tupColl1.set(1, "1.11");
bag1.add(tupColl1);
tupColl2.set(0, "1.111");
tupColl2.set(1, "1.1111");
bag1.add(tupColl2);
tuple.set(0, bag1);
Map<String, String> m1 = new HashMap<String, String>();
m1.put("k1", "k11");
m1.put("b", "b1");
m1.put("c", "c1");
tuple.set(1, m1);
Tuple tupRecord1;
try {
tupRecord1 = TypesUtils.createTuple(schema.getColumnSchema("c")
.getSchema());
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e);
}
tupRecord1.set(0, "1");
tupRecord1.set(1, "hello1");
tuple.set(2, tupRecord1);
tuple.set(3, "world1");
inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
.getBytes()), tuple);
// second row
row++;
TypesUtils.resetTuple(tuple);
TypesUtils.resetTuple(tupRecord1);
TypesUtils.resetTuple(tupColl1);
TypesUtils.resetTuple(tupColl2);
m1.clear();
bag1.clear();
row++;
tupColl1.set(0, "2.2");
tupColl1.set(1, "2.22");
bag1.add(tupColl1);
tupColl2.set(0, "2.222");
tupColl2.set(1, "2.2222");
bag1.add(tupColl2);
tuple.set(0, bag1);
m1.put("k2", "k22");
m1.put("k3", "k32");
m1.put("k1", "k12");
m1.put("k4", "k42");
tuple.set(1, m1);
tupRecord1.set(0, "2");
tupRecord1.set(1, "hello2");
tuple.set(2, tupRecord1);
tuple.set(3, "world2");
inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
.getBytes()), tuple);
inserter.close();
writer1.finish();
writer.close();
/*
* create 2nd basic table;
*/
pathTable2 = new Path(pathWorking, "2");
System.out.println("pathTable2 =" + pathTable2);
BasicTable.Writer writer2 = new BasicTable.Writer(pathTable2, STR_SCHEMA2,
STR_STORAGE2, false, conf);
Schema schema2 = writer.getSchema();
Tuple tuple2 = TypesUtils.createTuple(schema2);
BasicTable.Writer writer22 = new BasicTable.Writer(pathTable2, conf);
part = 0;