/** {@inheritDoc} */ @Override public Object getCurrentValue() throws IOException, InterruptedException { return reader.getCurrentValue(); }
@Override public HCatRecord next() { try { return curRecReader.getCurrentValue(); } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } }
@Override public boolean next(ImmutableBytesWritable rowKey, ResultWritable value) throws IOException { boolean next = false; try { next = recordReader.nextKeyValue(); if (next) { rowKey.set(recordReader.getCurrentValue().getRow()); value.setResult(recordReader.getCurrentValue()); } } catch (InterruptedException e) { throw new IOException(e); } return next; } };
@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; }
@Override public T nextRecord(T record) throws IOException { if (!this.fetched) { // first record fetchNext(); } if (!this.hasNext) { return null; } try { // get next HCatRecord HCatRecord v = this.recordReader.getCurrentValue(); this.fetched = false; if (this.fieldNames.length > 0) { // return as Flink tuple return this.buildFlinkTuple(record, v); } else { // return as HCatRecord return (T) v; } } catch (InterruptedException e) { throw new IOException("Could not get next record.", e); } }
/** * {@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; }
final ArrayWritable tmpCurValue = realReader.getCurrentValue(); if (value != tmpCurValue) { final Writable[] arrValue = value.get();
final ArrayWritable tmpCurValue = realReader.getCurrentValue(); if (value != tmpCurValue) { final Writable[] arrValue = value.get();
if (isJSON) { dataMap = new HashMap(1); dataMap.put("data", reader.getCurrentValue()); } else { dataMap = reader.getCurrentValue();
@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; }
@Override public Tuple getNext() throws IOException { try { HCatRecord hr = (HCatRecord) (reader.nextKeyValue() ? reader.getCurrentValue() : null); Tuple t = PigHCatUtil.transformToTuple(hr, outputSchema); // TODO : we were discussing an iter interface, and also a LazyTuple // change this when plans for that solidifies. return t; } catch (ExecException e) { int errCode = 6018; String errMsg = "Error while reading input"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT, e); } catch (Exception eOther) { int errCode = 6018; String errMsg = "Error converting read value to tuple"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT, eOther); } }
@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()); }
valueObj = realReader.getCurrentValue(); } else { eof = true;
@Override public VertexWritable getCurrentValue() throws IOException, InterruptedException { return this.recordReader.getCurrentValue(); }
valueObj = realReader.getCurrentValue(); } else { eof = true;
value = recordReader.getCurrentValue(); key == recordReader.getCurrentKey()); assertTrue("getCurrentValue() returned different values for the same record", value == recordReader.getCurrentValue()); value = recordReader.getCurrentValue();
value = recordReader.getCurrentValue(); key == recordReader.getCurrentKey()); assertTrue("getCurrentValue() returned different values for the same record", value == recordReader.getCurrentValue()); value = recordReader.getCurrentValue();
verifyRowFromMap(rr.getCurrentKey(), rr.getCurrentValue()); rowTracker.addRow(row);
@Override public Edge next() { try { while (true) { if (this.edgeIterator.hasNext()) return new HadoopEdge(this.edgeIterator.next(), this.graph); if (this.readers.isEmpty()) throw FastNoSuchElementException.instance(); if (this.readers.peek().nextKeyValue()) { this.edgeIterator = this.readers.peek().getCurrentValue().get().edges(Direction.OUT); } else { this.readers.remove().close(); } } } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (null == this.graphFilter) { return this.recordReader.nextKeyValue(); } else { while (true) { if (this.recordReader.nextKeyValue()) { final VertexWritable vertexWritable = this.recordReader.getCurrentValue(); final Optional<StarGraph.StarVertex> vertex = vertexWritable.get().applyGraphFilter(this.graphFilter); if (vertex.isPresent()) { vertexWritable.set(vertex.get()); return true; } } else { return false; } } } }