6
如何創建嵌套字段的鑲木地板文件?我有以下幾點:如何在鑲木地板文件中創建嵌套的對象和數組?
public static void main(String []args) throws IOException{
int fileNum = 10; //num of files constructed
int fileRecordNum = 50; //record num of each file
int rowKey = 0;
for(int i = 0; i < fileNum; ++ i) {
Map<String, String> metas = new HashMap<>();
metas.put(HConstants.START_KEY, genRowKey("%10d", rowKey + 1));
metas.put(HConstants.END_KEY, genRowKey("%10d", rowKey + fileRecordNum));
ParquetWriter<Group> writer = initWriter("pfile/scanner_test_file" + i, metas);
for (int j = 0; j < fileRecordNum; ++j) {
rowKey ++;
Group group = sfg.newGroup().append("rowkey", genRowKey("%10d", rowKey))
.append("cf:name", "wangxiaoyi" + rowKey)
.append("cf:age", String.format("%10d", rowKey))
.append("cf:job", "student")
.append("timestamp", System.currentTimeMillis());
writer.write(group);
}
writer.close();
}
}
我要創建兩個字段:
- 愛好含有愛好列表(「游泳」,「跆拳道」)
- 包含子字段老師對象像: { 'teachername':'Rachel家, 'teacherage':50 }
ç有人提供了一個例子如何在Java中做到這一點?
您希望從哪些數據源創建這些對象?你只是問如何創建一個字符串列表和一個對象來填充某種輸入,但在'java'中? – mass
我也很難理解你究竟在問什麼。在某種程度上,這看起來像你想創建的幾乎像數據格式的json? – GhostCat