/** * Returns and advances to the next record. Throws exception if * there are no more records. */ @Override public T next() throws IOException, RecordServiceException { T record; try { record = class_.newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not create new record instance.", e); } catch (IllegalAccessException e) { throw new RuntimeException("Could not create new record instance.", e); } // add columns for record. RecordUtil.buildRecord( schema_, records_.next(), avroSchema_, record, recordIndexToRsIndex_); return record; }
/** * Returns the next key / value record. Throws exception if there are no more records. */ public KeyValuePair<K, V> next() throws IOException, RecordServiceException { K key; V value; try { key = keyClass_.newInstance(); value = valueClass_.newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not create new key/value record instance.", e); } catch (IllegalAccessException e) { throw new RuntimeException("Could not create new key/value record instance.", e); } Records.Record rsRecord = records_.next(); // Add columns for the key record. RecordUtil.buildRecord(schema_, rsRecord, keySchema_, key, keyIndexToRsIndex_); // Add columns for the value record. RecordUtil.buildRecord(schema_, rsRecord, valueSchema_, value, valueIndexToRsIndex_); return new KeyValuePair<K, V>(key, value); }
/** * Advances to the next record. Return false if there are no more records. */ public boolean nextRecord() throws IOException { try { if (!reader_.records().hasNext()) return false; } catch (RecordServiceException e) { // TODO: is this the most proper way to deal with this in MR? throw new IOException("Could not fetch record.", e); } currentRSRecord_ = reader_.records().next(); return true; }
/** * Advances to the next record, populating key,value with the results. * This is the hot path. */ @Override public boolean next(WritableComparable<?> key, RecordServiceRecord value) throws IOException { try { if (!reader_.records().hasNext()) return false; } catch (RecordServiceException e) { // TODO: is this the most proper way to deal with this in MR? throw new IOException("Could not fetch record.", e); } value.reset(reader_.records().next()); return true; }
@Override public boolean next(LongWritable key, Text value) throws IOException { try { if (!reader_.records().hasNext()) return false; Records.Record record = reader_.records().next(); if (record.isNull(0)) { value.set(EMPTY); } else { ByteArray data = record.nextByteArray(0); value.set(data.byteBuffer().array(), data.offset(), data.len()); } key.set(recordNum_++); return true; } catch (RecordServiceException e) { throw new IOException("Could not get next record.", e); } }
/** * Advances to the next record. * Returns true if there are more values to retrieve, false otherwise. */ @Override public boolean nextKeyValue() throws IOException, InterruptedException { try { if (!reader_.records().hasNext()) return false; } catch (RecordServiceException e) { // TODO: is this the most proper way to deal with this in MR? throw new IOException("Could not fetch record.", e); } Records.Record record = reader_.records().next(); if (record.isNull(0)) { record_.set(EMPTY); } else { ByteArray data = record.nextByteArray(0); record_.set(data.byteBuffer().array(), data.offset(), data.len()); } currentKey_.set(recordNum_++); return true; }
Records.Record rsRecord = records_.next(); Record record = new Record(avroSchema_); for (int i = 0; i < schema_.cols.size(); ++i) {