/** {@inheritDoc} */ @Override public long length() { return is.length(); }
/** * Constructor. * * @param is Base input stream. * @param start Start position. * @param maxLen Maximum stream length. * @throws IOException In case of exception. */ public IgfsRangeInputStream(IgfsInputStream is, long start, long maxLen) throws IOException { if (is == null) throw new IllegalArgumentException("Input stream cannot be null."); if (start < 0) throw new IllegalArgumentException("Start position cannot be negative."); if (start >= is.length()) throw new IllegalArgumentException("Start position cannot be greater that file length."); if (maxLen < 0) throw new IllegalArgumentException("Length cannot be negative."); if (start + maxLen > is.length()) throw new IllegalArgumentException("Sum of start position and length cannot be greater than file length."); this.is = is; this.start = start; this.maxLen = maxLen; is.seek(start); }
@Override public HadoopIgfsStreamDelegate apply() { IgfsInputStream stream = igfs.open(path, bufSize); return new HadoopIgfsStreamDelegate(HadoopIgfsInProc.this, stream, stream.length()); } });
@Override public HadoopIgfsStreamDelegate apply() { IgfsInputStream stream = igfs.open(path, bufSize, seqReadsBeforePrefetch); return new HadoopIgfsStreamDelegate(HadoopIgfsInProc.this, stream, stream.length()); } });
/** {@inheritDoc} */ @Override public IgfsFileRange resolveRecords(IgniteFileSystem fs, IgfsInputStream stream, IgfsFileRange suggestedRecord) throws IgniteException, IOException { long suggestedEnd = suggestedRecord.start() + suggestedRecord.length(); long startRem = suggestedRecord.start() % recLen; long endRem = suggestedEnd % recLen; long start = Math.min(suggestedRecord.start() + (startRem != 0 ? (recLen - startRem) : 0), stream.length()); long end = Math.min(suggestedEnd + (endRem != 0 ? (recLen - endRem) : 0), stream.length()); assert end >= start; return start != end ? new IgfsFileRange(suggestedRecord.path(), start, end - start) : null; }
/** * Runs query check result. * * @param expRes Expected result. * @param qry Query. * @throws Exception If failed. */ private void checkQuery(String expRes, String qry) throws Exception { assertEquals(0, executeHiveQuery("drop table if exists result")); assertEquals(0, executeHiveQuery( "create table result " + "row format delimited fields terminated by ' ' " + "stored as textfile " + "location '/result' as " + qry )); IgfsInputStream in = igfs.open(new IgfsPath("/result/000000_0")); byte[] buf = new byte[(int) in.length()]; in.read(buf); assertEquals(expRes, new String(buf)); }
/** {@inheritDoc} */ @Override public long length() { return is.length(); }
req.path() + ", streamId=" + streamId + ", ses=" + ses + ']'); res.response(new IgfsInputStreamDescriptor(streamId, igfsIn.length()));
/** * Constructor. * * @param is Base input stream. * @param start Start position. * @param maxLen Maximum stream length. * @throws IOException In case of exception. */ public IgfsRangeInputStream(IgfsInputStream is, long start, long maxLen) throws IOException { if (is == null) throw new IllegalArgumentException("Input stream cannot be null."); if (start < 0) throw new IllegalArgumentException("Start position cannot be negative."); if (start >= is.length()) throw new IllegalArgumentException("Start position cannot be greater that file length."); if (maxLen < 0) throw new IllegalArgumentException("Length cannot be negative."); if (start + maxLen > is.length()) throw new IllegalArgumentException("Sum of start position and length cannot be greater than file length."); this.is = is; this.start = start; this.maxLen = maxLen; is.seek(start); }
/** {@inheritDoc} */ @Override public IgfsFileRange resolveRecords(IgniteFileSystem fs, IgfsInputStream stream, IgfsFileRange suggestedRecord) throws IgniteException, IOException { long suggestedEnd = suggestedRecord.start() + suggestedRecord.length(); long startRem = suggestedRecord.start() % recLen; long endRem = suggestedEnd % recLen; long start = Math.min(suggestedRecord.start() + (startRem != 0 ? (recLen - startRem) : 0), stream.length()); long end = Math.min(suggestedEnd + (endRem != 0 ? (recLen - endRem) : 0), stream.length()); assert end >= start; return start != end ? new IgfsFileRange(suggestedRecord.path(), start, end - start) : null; }
req.path() + ", streamId=" + streamId + ", ses=" + ses + ']'); res.response(new IgfsInputStreamDescriptor(streamId, igfsIn.length()));