Schema schema = new Schema();
schema.addColumn("id", Type.INT4);
schema.addColumn("age", Type.INT8);
schema.addColumn("description", Type.TEXT);
TableMeta meta = CatalogUtil.newTableMeta(StoreType.ROWFILE);
AbstractStorageManager sm = StorageManagerFactory.getStorageManager(conf, new Path(conf.getVar(ConfVars.ROOT_DIR)));
Path tablePath = new Path("/test");
Path metaPath = new Path(tablePath, ".meta");
Path dataPath = new Path(tablePath, "test.tbl");
FileSystem fs = sm.getFileSystem();
fs.mkdirs(tablePath);
FileUtil.writeProto(fs, metaPath, meta.getProto());
Appender appender = StorageManagerFactory.getStorageManager(conf).getAppender(meta, schema, dataPath);
appender.enableStats();
appender.init();
int tupleNum = 100;
Tuple tuple;
Datum stringDatum = DatumFactory.createText("abcdefghijklmnopqrstuvwxyz");
Set<Integer> idSet = Sets.newHashSet();
tuple = new VTuple(3);
long start = System.currentTimeMillis();
for(int i = 0; i < tupleNum; i++) {
tuple.put(0, DatumFactory.createInt4(i + 1));
tuple.put(1, DatumFactory.createInt8(25l));
tuple.put(2, stringDatum);
appender.addTuple(tuple);
idSet.add(i+1);
}
appender.close();
TableStats stat = appender.getStats();
assertEquals(tupleNum, stat.getNumRows().longValue());
FileStatus file = fs.getFileStatus(dataPath);
TableProto proto = (TableProto) FileUtil.loadProto(
cluster.getDefaultFileSystem(), metaPath, TableProto.getDefaultInstance());
meta = new TableMeta(proto);
FileFragment fragment = new FileFragment("test.tbl", dataPath, 0, file.getLen());
int tupleCnt = 0;
start = System.currentTimeMillis();
Scanner scanner = StorageManagerFactory.getStorageManager(conf).getScanner(meta, schema, fragment);