@Override public Tuple next() throws IOException { while((tuple = child.next()) != null) { appender.addTuple(tuple); } return null; }
@Override public Tuple next() throws IOException { while((tuple = child.next()) != null) { appender.addTuple(tuple); } return null; }
@Override public Tuple next() throws IOException { Tuple tuple; while(!context.isStopped() && (tuple = child.next()) != null) { partKey.set(tuple); // add tuple getAppender(partKey, tuple).addTuple(tuple); } List<TableStats> statSet = new ArrayList<>(); for (Appender app : appenderMap.values()) { app.flush(); app.close(); statSet.add(app.getStats()); } // Collect and aggregated statistics data TableStats aggregated = StatisticsUtil.aggregateTableStat(statSet); context.setResultStats(aggregated); return null; } }
@Override public Tuple next() throws IOException { Tuple tuple; while(!context.isStopped() && (tuple = child.next()) != null) { partKey.set(tuple); // add tuple getAppender(partKey, tuple).addTuple(tuple); } List<TableStats> statSet = new ArrayList<TableStats>(); for (Appender app : appenderMap.values()) { app.flush(); app.close(); statSet.add(app.getStats()); } // Collect and aggregated statistics data TableStats aggregated = StatisticsUtil.aggregateTableStat(statSet); context.setResultStats(aggregated); return null; } }
@Override public Tuple next() throws IOException { Tuple tuple; while(!context.isStopped() && (tuple = child.next()) != null) { appender.addTuple(tuple); if (maxPerFileSize > 0 && maxPerFileSize <= appender.getEstimatedOutputSize()) { appender.close(); writtenFileNum++; StatisticsUtil.aggregateTableStat(sumStats, appender.getStats()); openNewFile(writtenFileNum); } } return null; }
@Override public Tuple next() throws IOException { Tuple tuple; while(!context.isStopped() && (tuple = child.next()) != null) { appender.addTuple(tuple); if (maxPerFileSize > 0 && maxPerFileSize <= appender.getEstimatedOutputSize()) { appender.close(); writtenFileNum++; StatisticsUtil.aggregateTableStat(sumStats, appender.getStats()); openNewFile(writtenFileNum); } } return null; }
public static void writeTmpTable(TajoConf conf, Path tablePath) throws IOException { FileTablespace sm = TablespaceManager.getDefault(); Appender appender; Path filePath = new Path(tablePath, "table.csv"); FileSystem fs = filePath.getFileSystem(conf); if (fs.exists(tablePath)) { fs.delete(tablePath, true); } fs.mkdirs(tablePath); appender = sm.getAppender(mockupMeta, mockupSchema, filePath); appender.init(); int deptSize = 10000; int tupleNum = 100; Tuple tuple; for (int i = 0; i < tupleNum; i++) { tuple = new VTuple(2); String key = "test" + (i % deptSize); tuple.put(0, DatumFactory.createText(key)); tuple.put(1, DatumFactory.createInt4(i + 1)); appender.addTuple(tuple); } appender.close(); } }
appender.init(); for (Tuple t : tuples) { appender.addTuple(t);
appender.addTuple(tuple);
appender.init(); for(Tuple t : tuples) { appender.addTuple(t);
}); appender.addTuple(tuple);
@Override public Tuple next() throws IOException { Tuple tuple; while(!context.isStopped() && (tuple = child.next()) != null) { if (prevKey == null) { appender = getNextPartitionAppender(getSubdirectory(tuple)); prevKey = new ComparableTuple(inSchema, keyIds); prevKey.set(tuple); } else if (!prevKey.equals(tuple)) { appender.close(); StatisticsUtil.aggregateTableStat(aggregatedStats, appender.getStats()); appender = getNextPartitionAppender(getSubdirectory(tuple)); prevKey.set(tuple); // reset all states for file rotating writtenFileNum = 0; } appender.addTuple(tuple); if (maxPerFileSize > 0 && maxPerFileSize <= appender.getEstimatedOutputSize()) { appender.close(); writtenFileNum++; StatisticsUtil.aggregateTableStat(aggregatedStats, appender.getStats()); openAppender(writtenFileNum); } } return null; }
@Override public Tuple next() throws IOException { Tuple tuple; while(!context.isStopped() && (tuple = child.next()) != null) { if (prevKey == null) { appender = getNextPartitionAppender(getSubdirectory(tuple)); prevKey = new ComparableTuple(inSchema, keyIds); prevKey.set(tuple); } else if (!prevKey.equals(tuple)) { appender.close(); StatisticsUtil.aggregateTableStat(aggregatedStats, appender.getStats()); appender = getNextPartitionAppender(getSubdirectory(tuple)); prevKey.set(tuple); // reset all states for file rotating writtenFileNum = 0; } appender.addTuple(tuple); if (maxPerFileSize > 0 && maxPerFileSize <= appender.getEstimatedOutputSize()) { appender.close(); writtenFileNum++; StatisticsUtil.aggregateTableStat(aggregatedStats, appender.getStats()); openAppender(writtenFileNum); } } return null; }
@Test public void testDateTextHandling() throws Exception { if (dataFormat.equalsIgnoreCase(BuiltinStorages.AVRO) || internalType) { return; } Schema schema = SchemaBuilder.builder().add("col1", Type.TEXT).build(); TableMeta meta = CatalogUtil.newTableMeta(dataFormat, conf); FileTablespace sm = TablespaceManager.getLocalFs(); Path tablePath = new Path(testDir, "testTextHandling.data"); Appender appender = sm.getAppender(meta, schema, tablePath); appender.init(); VTuple tuple = new VTuple(1); tuple.put(0, DatumFactory.createDate(1994,7,30)); appender.addTuple(tuple); appender.flush(); appender.close(); FileStatus status = fs.getFileStatus(tablePath); FileFragment fragment = new FileFragment("table", tablePath, 0, status.getLen()); Scanner scanner = sm.getScanner(meta, schema, fragment, null); scanner.init(); Tuple retrieved; while ((retrieved = scanner.next()) != null) { assertEquals(tuple.get(0).asChars(), retrieved.asDatum(0).asChars()); } scanner.close(); if (internalType){ OldStorageManager.clearCache(); } }
appender.addTuple(tuple); m++;
}); appender.addTuple(expect); appender.flush(); appender.close();
DatumFactory.createInt4(rnd.nextInt(10)), DatumFactory.createText("dept_" + rnd.nextInt(10))}); appender.addTuple(tuple);
}); appender.addTuple(tuple); appender.flush(); appender.close();