@Override public TableReader getReader() throws IOException { return new HiveTableReader(database, hiveTable); }
private void initialize() throws IOException { try { this.readCntxt = getHiveReaderContext(dbName, tableName, partitionKV); } catch (Exception e) { e.printStackTrace(); throw new IOException(e); } this.numberOfSplits = readCntxt.numSplits(); }
/** * Constructor for reading a partition of the hive table * @param dbName * @param tableName * @param partitionKV key-value pairs condition on the partition * @throws IOException */ public HiveTableReader(String dbName, String tableName, Map<String, String> partitionKV) throws IOException { this.dbName = dbName; this.tableName = tableName; this.partitionKV = partitionKV; initialize(); }
@Test public void test() throws IOException { HiveTableReader reader = new HiveTableReader("default", "test_kylin_fact"); int rowNumber = 0; while (reader.next()) { String[] row = reader.getRow(); Assert.assertEquals(9, row.length); System.out.println(ArrayUtils.toString(row)); rowNumber++; } reader.close(); Assert.assertEquals(10000, rowNumber); } }
@Override public boolean next() throws IOException { while (currentHCatRecordItr == null || !currentHCatRecordItr.hasNext()) { currentSplit++; if (currentSplit == numberOfSplits) { return false; } currentHCatRecordItr = loadHCatRecordItr(readCntxt, currentSplit); } currentHCatRecord = currentHCatRecordItr.next(); return true; }
@Override public boolean next() throws IOException { while (currentHCatRecordItr == null || !currentHCatRecordItr.hasNext()) { currentSplit++; if (currentSplit == numberOfSplits) { return false; } currentHCatRecordItr = loadHCatRecordItr(readCntxt, currentSplit); } currentHCatRecord = currentHCatRecordItr.next(); return true; }
@Override public TableReader getReader() throws IOException { return new HiveTableReader(database, hiveTable); }
private void initialize() throws IOException { try { this.readCntxt = getHiveReaderContext(dbName, tableName, partitionKV); } catch (Exception e) { e.printStackTrace(); throw new IOException(e); } this.numberOfSplits = readCntxt.numSplits(); }
/** * Constructor for reading a partition of the hive table * @param dbName * @param tableName * @param partitionKV key-value pairs condition on the partition * @throws IOException */ public HiveTableReader(String dbName, String tableName, Map<String, String> partitionKV) throws IOException { this.dbName = dbName; this.tableName = tableName; this.partitionKV = partitionKV; initialize(); }