BasicTable.Writer writer1 = new BasicTable.Writer(path, conf);
int part = 0;
TableInserter inserter = writer1.getInserter("part" + part, true);
TypesUtils.resetTuple(tuple);
DataBag bag1 = TypesUtils.createBag();
Schema schColl = schema.getColumn(0).getSchema().getColumn(0).getSchema();
Tuple tupColl1 = TypesUtils.createTuple(schColl);
Tuple tupColl2 = TypesUtils.createTuple(schColl);
DataBag bag2 = TypesUtils.createBag();
Schema schColl2 = schema.getColumn(1).getSchema().getColumn(0).getSchema();
Tuple tupColl2_1 = TypesUtils.createTuple(schColl2);
Tuple tupColl2_2 = TypesUtils.createTuple(schColl2);
Tuple collRecord1;
try {
collRecord1 = TypesUtils.createTuple(new Schema("f1:int, f2:string"));
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e);
}
Tuple collRecord2;
try {
collRecord2 = TypesUtils.createTuple(new Schema("f1:int, f2:string"));
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e);
}
// c3:collection(c3_1:collection(e:int,f:bool))
DataBag bag3 = TypesUtils.createBag();
DataBag bag3_1 = TypesUtils.createBag();
DataBag bag3_2 = TypesUtils.createBag();
Tuple tupColl3_1 = null;
try {
tupColl3_1 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e);
}
Tuple tupColl3_2;
try {
tupColl3_2 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e);
}
Tuple tupColl3_3 = null;
try {
tupColl3_3 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e);
}
Tuple tupColl3_4;
try {
tupColl3_4 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e);
}
byte[] abs1 = new byte[3];
byte[] abs2 = new byte[4];
tupColl1.set(0, 3.1415926);
tupColl1.set(1, 1.6);
abs1[0] = 11;
abs1[1] = 12;
abs1[2] = 13;
tupColl1.set(2, new DataByteArray(abs1));
bag1.add(tupColl1);
tupColl2.set(0, 123.456789);
tupColl2.set(1, 100);
abs2[0] = 21;
abs2[1] = 22;
abs2[2] = 23;
abs2[3] = 24;
tupColl2.set(2, new DataByteArray(abs2));
bag1.add(tupColl2);
tuple.set(0, bag1);
collRecord1.set(0, 1);
collRecord1.set(1, "record1_string1");
tupColl2_1.set(0, collRecord1);
tupColl2_1.set(1, "hello1");
bag2.add(tupColl2_1);
collRecord2.set(0, 2);
collRecord2.set(1, "record2_string1");
tupColl2_2.set(0, collRecord2);
tupColl2_2.set(1, "hello2");
bag2.add(tupColl2_2);
tuple.set(1, bag2);
TypesUtils.resetTuple(tupColl3_1);
TypesUtils.resetTuple(tupColl3_2);
tupColl3_1.set(0, 1);
tupColl3_1.set(1, true);
tupColl3_2.set(0, 2);
tupColl3_2.set(1, false);
bag3_1.add(tupColl3_1);
bag3_1.add(tupColl3_2);
bag3.addAll(bag3_1);
tupColl3_3.set(0, 3);
tupColl3_3.set(1, true);
tupColl3_4.set(0, 4);
tupColl3_4.set(1, false);
bag3_2.add(tupColl3_3);
bag3_2.add(tupColl3_4);
bag3.addAll(bag3_2);
tuple.set(2, bag3);
int row = 0;
inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1).getBytes()), tuple);
row++;
bag1.clear();
bag2.clear();
bag3.clear();
bag3_1.clear();
bag3_2.clear();
TypesUtils.resetTuple(tupColl1);
TypesUtils.resetTuple(tupColl2);
TypesUtils.resetTuple(tupColl2_1);
TypesUtils.resetTuple(tupColl2_2);
TypesUtils.resetTuple(collRecord1);
TypesUtils.resetTuple(collRecord2);
TypesUtils.resetTuple(tupColl3_1);
TypesUtils.resetTuple(tupColl3_2);
TypesUtils.resetTuple(tupColl3_3);
TypesUtils.resetTuple(tupColl3_4);
tupColl1.set(0, 7654.321);
tupColl1.set(1, 0.0001);
abs1[0] = 31;
abs1[1] = 32;
abs1[2] = 33;
tupColl1.set(2, new DataByteArray(abs1));
bag1.add(tupColl1);
tupColl2.set(0, 0.123456789);
tupColl2.set(1, 0.3333);
abs2[0] = 41;
abs2[1] = 42;
abs2[2] = 43;
abs2[3] = 44;
tupColl2.set(2, new DataByteArray(abs2));
bag1.add(tupColl2);
tuple.set(0, bag1);
collRecord1.set(0, 3);
collRecord1.set(1, "record1_string2");
tupColl2_1.set(0, collRecord1);
tupColl2_1.set(1, "hello1_2");
bag2.add(tupColl2_1);
collRecord2.set(0, 4);
collRecord2.set(1, "record2_string2");
tupColl2_2.set(0, collRecord2);
tupColl2_2.set(1, "hello2_2");
bag2.add(tupColl2_2);
tuple.set(1, bag2);
tupColl3_1.set(0, 5);
tupColl3_1.set(1, true);
tupColl3_2.set(0, 6);
tupColl3_2.set(1, false);
bag3_1.add(tupColl3_1);
bag3_1.add(tupColl3_2);
bag3.addAll(bag3_1);
tupColl3_3.set(0, 7);
tupColl3_3.set(1, true);
tupColl3_4.set(0, 8);
tupColl3_4.set(1, false);
bag3_2.add(tupColl3_3);
bag3_2.add(tupColl3_4);
bag3.addAll(bag3_2);
tuple.set(2, bag3);
inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
.getBytes()), tuple);