@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (key == null) { key = NullWritable.get(); } if (value == null) { value = ReflectionUtils.newInstance(inputClass, this.configuration); } Preconditions.checkNotNull(this.resultSet); try { if(!resultSet.next()) { return false; } value.readFields(resultSet); return true; } catch (SQLException e) { LOG.error(String.format(" Error [%s] occurred while iterating over the resultset. ",e.getMessage())); throw new RuntimeException(e); } }
@Override public void write(NullWritable key, T record) throws IOException { try { record.write(pstmt); numRecords++; pstmt.executeUpdate(); if (numRecords % batchSize == 0) { LOG.debug("Commit called on a batch of size : " + batchSize); conn.commit(); } } catch (SQLException e) { throw new IOException("Exception while writing to table.", e); } }
@Override public boolean next(WritableComparable key, T value) throws IOException { try { if (!resultSet.next()) { return false; } value.readFields(resultSet); if (isTransactional) { ((PhoenixResultWritable) value).readPrimaryKey((PhoenixRowKey) key); } ++readCount; if (LOG.isTraceEnabled()) { LOG.trace("Result[" + readCount + "] : " + ((PhoenixResultWritable) value) .getResultMap()); } return true; } catch (SQLException e) { LOG.error(String.format(" Error [%s] occurred while iterating over the resultset. ", e.getMessage())); throw new RuntimeException(e); } }
@Override public void write(NullWritable n, T record) throws IOException, InterruptedException { try { record.write(statement); numRecords++; statement.execute(); if (numRecords % batchSize == 0) { LOG.debug("commit called on a batch of size : " + batchSize); conn.commit(); } } catch (SQLException e) { throw new RuntimeException("Exception while committing to database.", e); } }
@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (key == null) { key = NullWritable.get(); } if (value == null) { value = ReflectionUtils.newInstance(inputClass, this.configuration); } Preconditions.checkNotNull(this.resultSet); try { if(!resultSet.next()) { return false; } value.readFields(resultSet); return true; } catch (SQLException e) { LOG.error(String.format(" Error [%s] occurred while iterating over the resultset. ",e.getMessage())); throw new RuntimeException(e); } }
@Override public void write(NullWritable n, T record) throws IOException, InterruptedException { try { record.write(statement); numRecords++; statement.execute(); if (numRecords % batchSize == 0) { LOG.debug("commit called on a batch of size : " + batchSize); conn.commit(); } } catch (SQLException e) { throw new RuntimeException("Exception while committing to database.", e); } }
@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (key == null) { key = NullWritable.get(); } if (value == null) { value = ReflectionUtils.newInstance(inputClass, this.configuration); } Preconditions.checkNotNull(this.resultSet); try { if(!resultSet.next()) { return false; } value.readFields(resultSet); return true; } catch (SQLException e) { LOG.error(String.format(" Error [%s] occurred while iterating over the resultset. ",e.getMessage())); throw new RuntimeException(e); } }
@Override public void write(NullWritable n, T record) throws IOException, InterruptedException { try { record.write(statement); numRecords++; statement.execute(); if (numRecords % batchSize == 0) { LOG.debug("commit called on a batch of size : " + batchSize); conn.commit(); } } catch (SQLException e) { throw new RuntimeException("Exception while committing to database.", e); } }
/** {@inheritDoc} */ public boolean nextKeyValue() throws IOException { try { if (key == null) { key = new LongWritable(); } if (value == null) { value = createValue(); } if (null == this.results) { // First time into this method, run the query. this.results = executeQuery(getSelectQuery()); } if (!results.next()) return false; // Set the key field value as the output key value key.set(pos + split.getStart()); value.readFields(results); pos ++; } catch (SQLException e) { throw new IOException("SQLException in nextKeyValue", e); } return true; }
/** {@inheritDoc} */ public boolean nextKeyValue() throws IOException { try { if (key == null) { key = new LongWritable(); } if (value == null) { value = createValue(); } if (null == this.results) { // First time into this method, run the query. this.results = executeQuery(getSelectQuery()); } if (!results.next()) return false; // Set the key field value as the output key value key.set(pos + split.getStart()); value.readFields(results); pos ++; } catch (SQLException e) { throw new IOException("SQLException in nextKeyValue", e); } return true; }
/** {@inheritDoc} */ public boolean nextKeyValue() throws IOException { try { if (key == null) { key = new LongWritable(); } if (value == null) { value = createValue(); } if (null == this.results) { // First time into this method, run the query. this.results = executeQuery(getSelectQuery()); } if (!results.next()) return false; // Set the key field value as the output key value key.set(pos + split.getStart()); value.readFields(results); pos ++; } catch (SQLException e) { throw new IOException("SQLException in nextKeyValue", e); } return true; }
/** {@inheritDoc} */ public boolean nextKeyValue() throws IOException { try { if (key == null) { key = new LongWritable(); } if (value == null) { value = createValue(); } if (null == this.results) { // First time into this method, run the query. this.results = executeQuery(getSelectQuery()); } if (!results.next()) return false; // Set the key field value as the output key value key.set(pos + split.getStart()); value.readFields(results); pos ++; } catch (SQLException e) { throw new IOException("SQLException in nextKeyValue", e); } return true; }
/** {@inheritDoc} */ public boolean nextKeyValue() throws IOException { try { if (key == null) { key = new LongWritable(); } if (value == null) { value = createValue(); } if (null == this.results) { // First time into this method, run the query. this.results = executeQuery(getSelectQuery()); } if (!results.next()) return false; // Set the key field value as the output key value key.set(pos + split.getStart()); value.readFields(results); pos ++; } catch (SQLException e) { throw new IOException("SQLException in nextKeyValue", e); } return true; }