while (reader.next()) { String[] row = reader.getRow(); if (row.length <= maxIndex) { throw new IllegalStateException("Bad hive table row, " + tableDesc + " expect " + (maxIndex + 1) + " columns, but got " + Arrays.toString(row)); reader = table.getReader(); try { while (reader.next()) { String[] row = reader.getRow(); int[] rowIndex = new int[tableDesc.getColumnCount()]; for (ColumnDesc column : tableDesc.getColumns()) {
while (reader.next()) { String[] row = reader.getRow(); if (row.length <= maxIndex) { throw new IllegalStateException("Bad hive table row, " + tableDesc + " expect " + (maxIndex + 1) + " columns, but got " + Arrays.toString(row)); reader = table.getReader(); try { while (reader.next()) { String[] row = reader.getRow(); int[] rowIndex = new int[tableDesc.getColumnCount()]; for (ColumnDesc column : tableDesc.getColumns()) {
@Override public boolean moveNext() throws IOException { if (reader.next()) { String colStrValue; String[] split = reader.getRow(); if (split.length == 1) { colStrValue = split[0]; } else { // normal case if (split.length <= colIndex) { throw new ArrayIndexOutOfBoundsException("Column no. " + colIndex + " not found, line split is " + Arrays.asList(split)); } colStrValue = split[colIndex]; } colValue = colStrValue; return true; } else { colValue = null; return false; } }
private void reload() throws IOException { if (reader.next()) { String[] split = reader.getRow(); if (split.length == 1) { this.cache = split[0]; } else { // normal case if (split.length <= colIndex) { throw new ArrayIndexOutOfBoundsException("Column no. " + colIndex + " not found, line split is " + Arrays.asList(split)); } this.cache = split[colIndex]; } } else { this.cache = null; } }
protected void init() throws IOException { int[] keyIndex = new int[keyColumns.length]; for (int i = 0; i < keyColumns.length; i++) { keyIndex[i] = tableDesc.findColumnByName(keyColumns[i]).getZeroBasedIndex(); } TableReader reader = table.getReader(); try { while (reader.next()) { initRow(reader.getRow(), keyIndex); } } finally { IOUtils.closeQuietly(reader); } }
public void close() throws IOException { if (this.reader != null) reader.close(); }
public void close() throws IOException { if (this.reader != null) reader.close(); }
@Override public void close() throws IOException { for (IReadableTable.TableReader reader : readers) { if (reader != null) reader.close(); } }
@Override public void close() throws IOException { for (IReadableTable.TableReader reader : readers) reader.close(); }
@Override public void close() throws IOException { if (reader != null) reader.close(); }
@Test public void testBasics() throws Exception { TableMetadataManager tblManager = TableMetadataManager.getInstance(getTestConfig()); TableDesc tblDesc = tblManager.getTableDesc("test_kylin_fact", "default"); IReadableTable table = SourceManager.getSource(new JdbcSourceTest.JdbcSourceAware()) .createReadableTable(tblDesc, null); // test TableReader try (IReadableTable.TableReader reader = table.getReader()) { Assert.assertTrue(reader instanceof JdbcTableReader); Assert.assertTrue(table instanceof JdbcTable); Assert.assertTrue(reader.next()); String[] row = reader.getRow(); Assert.assertNotNull(row); Assert.assertEquals(tblDesc.getColumnCount(), row.length); } // test basics Assert.assertTrue(table.exists()); IReadableTable.TableSignature sign = table.getSignature(); Assert.assertNotNull(sign); Assert.assertEquals(String.format(Locale.ROOT, "%s.%s", tblDesc.getDatabase(), tblDesc.getName()), sign.getPath()); Assert.assertTrue(sign.getLastModifiedTime() > 0); }
@Override public boolean moveNext() throws IOException { if (reader.next()) { String colStrValue; String[] split = reader.getRow(); if (split.length == 1) { colStrValue = split[0]; } else { // normal case if (split.length <= colIndex) { throw new ArrayIndexOutOfBoundsException("Column no. " + colIndex + " not found, line split is " + Arrays.asList(split)); } colStrValue = split[colIndex]; } colValue = colStrValue; return true; } else { colValue = null; return false; } }
private void reload() throws IOException { if (reader.next()) { String[] split = reader.getRow(); if (split.length == 1) { this.cache = split[0]; } else { // normal case if (split.length <= colIndex) { throw new ArrayIndexOutOfBoundsException("Column no. " + colIndex + " not found, line split is " + Arrays.asList(split)); } this.cache = split[colIndex]; } } else { this.cache = null; } }
protected void init() throws IOException { int[] keyIndex = new int[keyColumns.length]; for (int i = 0; i < keyColumns.length; i++) { keyIndex[i] = tableDesc.findColumnByName(keyColumns[i]).getZeroBasedIndex(); } TableReader reader = table.getReader(); try { while (reader.next()) { initRow(reader.getRow(), keyIndex); } } finally { IOUtils.closeQuietly(reader); } }
public void close() throws IOException { if (this.reader != null) reader.close(); }
public void close() throws IOException { if (this.reader != null) reader.close(); }
@Override public void close() throws IOException { if (reader != null) reader.close(); }
@Override public void close() throws IOException { for (IReadableTable.TableReader reader : readers) { if (reader != null) reader.close(); } }