/** {@inheritDoc} */ @Override public Object getCurrentKey() throws IOException, InterruptedException { if (reader != null) return reader.getCurrentKey(); return input.key(); }
@Override public Tuple2<K, V> nextRecord(Tuple2<K, V> record) throws IOException { if (!this.fetched) { fetchNext(); } if (!this.hasNext) { return null; } try { record.f0 = recordReader.getCurrentKey(); record.f1 = recordReader.getCurrentValue(); } catch (InterruptedException e) { throw new IOException("Could not get KeyValue pair.", e); } this.fetched = false; return record; }
/** * {@inheritDoc}. * * This method will throw a {@link ClassCastException} if type {@link #<D>} is not compatible * with type {@link #<K>} if keys are supposed to be read, or if it is not compatible with type * {@link #<V>} if values are supposed to be read. */ @Override @SuppressWarnings("unchecked") public D readRecord(@Deprecated D reuse) throws DataRecordException, IOException { try { if (this.recordReader.nextKeyValue()) { return this.readKeys ? (D) this.recordReader.getCurrentKey() : (D) this.recordReader.getCurrentValue(); } } catch (InterruptedException ie) { throw new IOException(ie); } return null; }
@Override public boolean nextKeyValue() throws IOException, InterruptedException { while (reader.nextKeyValue()) { // TODO titan05 integration -- the duplicate() call may be unnecessary final TinkerVertex maybeNullTinkerVertex = deser.readHadoopVertex(reader.getCurrentKey(), reader.getCurrentValue()); if (null != maybeNullTinkerVertex) { vertex = new VertexWritable(maybeNullTinkerVertex); //vertexQuery.filterRelationsOf(vertex); // TODO reimplement vertexquery filtering return true; } } return false; }
@Test public void testRecordReader() throws Exception { List<String> paths = Lists.newArrayList("/path1", "/path2"); GobblinWorkUnitsInputFormat.GobblinSplit split = new GobblinWorkUnitsInputFormat.GobblinSplit(paths); GobblinWorkUnitsInputFormat inputFormat = new GobblinWorkUnitsInputFormat(); RecordReader<LongWritable, Text> recordReader = inputFormat.createRecordReader(split, new TaskAttemptContextImpl(new Configuration(), new TaskAttemptID("a", 1, TaskType.MAP, 1, 1))); recordReader.nextKeyValue(); Assert.assertEquals(recordReader.getCurrentKey().get(), 0); Assert.assertEquals(recordReader.getCurrentValue().toString(), "/path1"); recordReader.nextKeyValue(); Assert.assertEquals(recordReader.getCurrentKey().get(), 1); Assert.assertEquals(recordReader.getCurrentValue().toString(), "/path2"); Assert.assertFalse(recordReader.nextKeyValue()); }
key = recordReader.getCurrentKey(); value = recordReader.getCurrentValue(); key == recordReader.getCurrentKey()); assertTrue("getCurrentValue() returned different values for the same record", value == recordReader.getCurrentValue()); key = recordReader.getCurrentKey(); value = recordReader.getCurrentValue();
key = recordReader.getCurrentKey(); value = recordReader.getCurrentValue(); key == recordReader.getCurrentKey()); assertTrue("getCurrentValue() returned different values for the same record", value == recordReader.getCurrentValue()); key = recordReader.getCurrentKey(); value = recordReader.getCurrentValue();
byte[] row = rr.getCurrentKey().get(); verifyRowFromMap(rr.getCurrentKey(), rr.getCurrentValue()); rowTracker.addRow(row);
LOG.info(String.format("Fill: Collected %d samples from %d splits", counter, i)); counter++; samples.add(ReflectionUtils.copy(job.getConfiguration(), reader.getCurrentKey(), null)); } else { if (ind != numSamples) { samples.set(ind, ReflectionUtils.copy(job.getConfiguration(), reader.getCurrentKey(), null)); if (counter % 1000 == 0) LOG.info(String.format("Replace Random: Collected %d samples from %d splits", counter, i));
@Override public K getCurrentKey() throws IOException, InterruptedException { return rr.getCurrentKey(); }
@Override public K getCurrentKey() throws IOException, InterruptedException { return rr.getCurrentKey(); }
@Override public final LongWritable getCurrentKey() throws IOException, InterruptedException { return this.reader.getCurrentKey(); }
@Override public E getCurrentKey() throws IOException, InterruptedException { return delegate.getCurrentKey().datum(); } }
/** * Helper for populating currentKey and currentValue from delegateReader. Should only be called * once per new key/value from the delegateReader; this method is also responsible for tracking * the number of records read so far. */ private void populateCurrentKeyValue() throws IOException, InterruptedException { currentKey = delegateReader.getCurrentKey(); currentValue = delegateReader.getCurrentValue(); ++recordsRead; }
@Override public Long getCurrentKey() throws IOException, InterruptedException { LongWritable writable = delegate.getCurrentKey(); return writable == null ? null : writable.get(); }
private E computeNextKey() throws IOException, InterruptedException { while (unfiltered.nextKeyValue()) { E element = unfiltered.getCurrentKey(); if (predicate.apply(element)) { return element; } } return null; }
/** * Read the next k,v pair into the head of this object; return true iff * the RR and this are exhausted. */ private boolean next() throws IOException, InterruptedException { empty = !rr.nextKeyValue(); key = rr.getCurrentKey(); value = rr.getCurrentValue(); return !empty; }
/** * Read the next k,v pair into the head of this object; return true iff * the RR and this are exhausted. */ private boolean next() throws IOException, InterruptedException { empty = !rr.nextKeyValue(); key = rr.getCurrentKey(); value = rr.getCurrentValue(); return !empty; }
/** * Read the next k,v pair into the head of this object; return true iff * the RR and this are exhausted. */ private boolean next() throws IOException, InterruptedException { empty = !rr.nextKeyValue(); key = rr.getCurrentKey(); value = rr.getCurrentValue(); return !empty; }
private Object getCurrentKeyObject() throws IOException, InterruptedException { DataInputBuffer ibuf = (DataInputBuffer) reader.getCurrentKey(); keyDataByteArray.set(Arrays.copyOf(ibuf.getData(), ibuf.getLength())); return config.keyConverter.bytesToObject(keyDataByteArray); }