Ejemplo n.º 1
0
 private void doWork() throws IOException {
   CountingInputStream input = null;
   CountingOutputStream output = null;
   try {
     input = new CountingInputStream(s.getInputStream());
     output = new CountingOutputStream(s.getOutputStream());
     ByteStreams.copy(input, output);
     Counters.increment("BytesIn", input.getCount());
     Counters.increment("BytesOut", output.getCount());
   } finally {
     Closeables.closeQuietly(input);
     Closeables.closeQuietly(output);
   }
 }
Ejemplo n.º 2
0
  public ExampleRecordCursor(List<ExampleColumnHandle> columnHandles, ByteSource byteSource) {
    this.columnHandles = columnHandles;

    fieldToColumnIndex = new int[columnHandles.size()];
    for (int i = 0; i < columnHandles.size(); i++) {
      ExampleColumnHandle columnHandle = columnHandles.get(i);
      fieldToColumnIndex[i] = columnHandle.getOrdinalPosition();
    }

    try (CountingInputStream input = new CountingInputStream(byteSource.openStream())) {
      lines = byteSource.asCharSource(UTF_8).readLines().iterator();
      totalBytes = input.getCount();
    } catch (IOException e) {
      throw Throwables.propagate(e);
    }
  }
Ejemplo n.º 3
0
 public float percentRead() {
   return countingInputStream.getCount() / totalBytesToRead;
 }
Ejemplo n.º 4
0
 public long getRecordOffset() {
   return streamOffset + inputStream.getCount();
 }