@Override public float getProgress() { if(eos) { return 1.0f; } long readBytes = filePosition - startOffset; if (readBytes == 0) { return 0.0f; } else { return Math.min(1.0f, ((float) readBytes / fragment.getLength())); } } }
public RCFileScanner(Configuration conf, final Schema schema, final TableMeta meta, final Fragment fragment) throws IOException { super(conf, schema, meta, fragment); conf.setInt("io.file.buffer.size", 4096); //TODO remove startOffset = this.fragment.getStartKey(); endOffset = startOffset + this.fragment.getLength(); start = 0; }
@Override public float getProgress() { if(!inited) return 0.0f; if(eos) { return 1.0f; } long readBytes = filePosition - fragment.getStartKey(); if (readBytes == 0) { return 0.0f; } else { return Math.min(1.0f, ((float) readBytes / fragment.getLength())); } } }
@Override public void seek(long offset) throws IOException { eos = false; filePosition = channel.position(); // do not fill the buffer if the offset is already included in the buffer. if(!forceFillBuffer && filePosition > offset && offset > filePosition - buffer.limit()){ buffer.position((int)(offset - (filePosition - buffer.limit()))); } else { if(offset < startOffset || offset > startOffset + fragment.getLength()){ throw new IndexOutOfBoundsException(String.format("range(%d, %d), offset: %d", startOffset, startOffset + fragment.getLength(), offset)); } channel.position(offset); filePosition = offset; buffer.clear(); forceFillBuffer = true; fillBuffer(); } }
@Override public float getProgress() { if(!inited) return super.getProgress(); try { if(!more) { return 1.0f; } long filePos = getPosition(); if (startOffset == filePos) { return 0.0f; } else { //if scanner read the header, filePos moved to zero return Math.min(1.0f, (float)(Math.max(filePos - startOffset, 0)) / (float)(fragment.getLength())); } } catch (IOException e) { LOG.error(e.getMessage(), e); return 0.0f; } }
@Override public TableStats getInputStats() { if(inputStats != null){ inputStats.setNumRows(recordCount); inputStats.setReadBytes(totalReadBytes); // actual read bytes (scan + rescan * n) inputStats.setNumBytes(fragment.getLength()); } return inputStats; }
@Override public TableStats getInputStats() { if (inputStats != null && reader != null) { inputStats.setReadBytes(reader.getReadBytes()); //Actual Processed Bytes. (decompressed bytes + overhead) inputStats.setNumRows(recordCount); inputStats.setNumBytes(fragment.getLength()); } return inputStats; } }
@Override public TableStats getInputStats() { if (inputStats != null && reader != null) { inputStats.setReadBytes(reader.getReadBytes()); //Actual Processed Bytes. (decompressed bytes + overhead) inputStats.setNumRows(recordCount); inputStats.setNumBytes(fragment.getLength()); } return inputStats; }
@Override public TableStats getInputStats() { if(inputStats != null){ inputStats.setNumRows(recordCount); inputStats.setReadBytes(filePosition - fragment.getStartKey()); // actual read bytes (scan + rescan * n) inputStats.setNumBytes(fragment.getLength()); } return inputStats; }
private void initChannel() throws IOException { FileSystem fs = FileScanner.getFileSystem((TajoConf) conf, fragment.getPath()); if (fs instanceof LocalFileSystem) { File file; try { if (fragment.getPath().toUri().getScheme() != null) { file = new File(fragment.getPath().toUri()); } else { file = new File(fragment.getPath().toString()); } } catch (IllegalArgumentException iae) { throw new IOException(iae); } channel = new LocalFileInputChannel(new FileInputStream(file)); } else { channel = new FSDataInputChannel(fs.open(fragment.getPath())); } // initial set position if (fragment.getStartKey() > 0) { channel.seek(fragment.getStartKey()); } filePosition = fragment.getStartKey(); endOffset = fragment.getStartKey() + fragment.getLength(); if (LOG.isDebugEnabled()) { LOG.debug("RawFileScanner open:" + fragment.getPath() + ", offset :" + fragment.getStartKey() + ", fragment length :" + fragment.getLength()); } }
is = inputStream; lineReader = new ByteBufLineReader(new LocalFileInputChannel(inputStream), BufferPool.directBuffer((int) Math.min(bufferSize, fragment.getLength()))); } else { fis = fs.open(fragment.getPath()); is = fis; lineReader = new ByteBufLineReader(new FSDataInputChannel(fis), BufferPool.directBuffer((int) Math.min(bufferSize, fragment.getLength())));
+ ", fragment length :" + fragment.getLength());
public void init() throws IOException { inited = true; progress = 0.0f; if (fragment != null) { inputStats.setNumBytes(fragment.getLength()); inputStats.setNumBlocks(1); } if (schema != null) { for(Column eachColumn: schema.getRootColumns()) { ColumnStats columnStats = new ColumnStats(eachColumn); inputStats.addColumnStat(columnStats); } } }
this.end = start + fragment.getLength();