Package com.fasterxml.storemate.store.util

Examples of com.fasterxml.storemate.store.util.CountingInputStream


                    // otherwise, just read from input
                    combined = in;
                }

                final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
                CountingInputStream counter = new CountingInputStream(combined);
                LZFInputStream lzfIn = new LZFInputStream(counter);
                try {
                     lzfIn.readAndWrite(out);
                } finally {
                    _close(lzfIn);
                    if (_diagnostics != null) {
                        final long totalSpent = _timeMaster.nanosForDiagnostics() - start;
                        // Not good, but need to try avoiding double-booking so assume 1/4 for response write
                        long respTime = (totalSpent >> 2);
                        _diagnostics.addResponseWriteTime(respTime);
                        _diagnostics.addFileReadAccess(start, start, start + totalSpent - respTime,
                                counter.readCount());
                    }
                }
                return null;
            }
        });
View Full Code Here


       
    protected void _readAllWriteStreamingCompressed3(InputStream in0, OutputStream out,
            byte[] copyBuffer, StreamyBytesMemBuffer offHeap)
        throws IOException
    {
        final CountingInputStream counter = new CountingInputStream(in0);
       
        InputStream in = Compressors.uncompressingStream(counter, _compression);

        // First: anything to skip (only the case for range requests)?
        if (_dataOffset > 0L) {
            long skipped = 0L;
            long toSkip = _dataOffset;

            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
           
            while (toSkip > 0) {
                long count = in.skip(toSkip);
                if (count <= 0L) { // should not occur really...
                    throw new IOException("Failed to skip more than "+skipped+" bytes (needed to skip "+_dataOffset+")");
                }
                skipped += count;
                toSkip -= count;
            }
            if (_diagnostics != null) {
                // assume here skipping is "free" (i.e. no bytes read)
                _diagnostics.addFileReadAccess(start, _timeMaster, 0L);
            }
        }
        // Second: output the whole thing, or just subset?
        // TODO: buffer
        if (_dataLength < 0) { // all of it
            long prevCount = 0L;
            while (true) {
                final long start = _timeMaster.nanosForDiagnostics();
                int count = in.read(copyBuffer);
                if (_diagnostics != null) {
                    long newCount = counter.readCount();
                    _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                    prevCount = newCount;
                }
               
                if (count <= 0) {
                    break;
                }
                final long outputStart = _timeMaster.nanosForDiagnostics();
                out.write(copyBuffer, 0, count);
                if (_diagnostics != null) {
                    _diagnostics.addResponseWriteTime(outputStart, _timeMaster);
                }
            }
            return;
        }
        // Just some of it
        long left = _dataLength;

        // TODO: buffer
        long prevCount = 0L;
        while (left > 0) {
            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
            int count = in.read(copyBuffer, 0, (int) Math.min(copyBuffer.length, left));
            if (_diagnostics != null) {
                long newCount = counter.readCount();
                _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                prevCount = newCount;
            }
            if (count <= 0) {
                break;
View Full Code Here

                    // otherwise, just read from input
                    combined = in;
                }

                final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
                CountingInputStream counter = new CountingInputStream(combined);
                LZFInputStream lzfIn = new LZFInputStream(counter);
                try {
                     lzfIn.readAndWrite(out);
                } finally {
                    _close(lzfIn);
                    if (_diagnostics != null) {
                        final long totalSpent = _timeMaster.nanosForDiagnostics() - start;
                        // Not good, but need to try avoiding double-booking so assume 1/4 for response write
                        long respTime = (totalSpent >> 2);
                        _diagnostics.addResponseWriteTime(respTime);
                        _diagnostics.addFileReadAccess(start, start, start + totalSpent - respTime,
                                counter.readCount());
                    }
                }
                return null;
            }
        });
View Full Code Here

       
    protected void _readAllWriteStreamingCompressed3(InputStream in0, OutputStream out,
            byte[] copyBuffer, StreamyBytesMemBuffer offHeap)
        throws IOException
    {
        final CountingInputStream counter = new CountingInputStream(in0);
       
        InputStream in = Compressors.uncompressingStream(counter, _compression);

        // First: anything to skip (only the case for range requests)?
        if (_dataOffset > 0L) {
            long skipped = 0L;
            long toSkip = _dataOffset;

            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
           
            while (toSkip > 0) {
                long count = in.skip(toSkip);
                if (count <= 0L) { // should not occur really...
                    throw new IOException("Failed to skip more than "+skipped+" bytes (needed to skip "+_dataOffset+")");
                }
                skipped += count;
                toSkip -= count;
            }
            if (_diagnostics != null) {
                // assume here skipping is "free" (i.e. no bytes read)
                _diagnostics.addFileReadAccess(start, _timeMaster, 0L);
            }
        }
        // Second: output the whole thing, or just subset?
        // TODO: buffer
        if (_dataLength < 0) { // all of it
            long prevCount = 0L;
            while (true) {
                final long start = _timeMaster.nanosForDiagnostics();
                int count = in.read(copyBuffer);
                if (_diagnostics != null) {
                    long newCount = counter.readCount();
                    _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                    prevCount = newCount;
                }
               
                if (count <= 0) {
                    break;
                }
                final long outputStart = _timeMaster.nanosForDiagnostics();
                out.write(copyBuffer, 0, count);
                if (_diagnostics != null) {
                    _diagnostics.addResponseWriteTime(outputStart, _timeMaster);
                }
            }
            return;
        }
        // Just some of it
        long left = _dataLength;

        // TODO: buffer
        long prevCount = 0L;
        while (left > 0) {
            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
            int count = in.read(copyBuffer, 0, (int) Math.min(copyBuffer.length, left));
            if (_diagnostics != null) {
                long newCount = counter.readCount();
                _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                prevCount = newCount;
            }
            if (count <= 0) {
                break;
View Full Code Here

                    // otherwise, just read from input
                    combined = in;
                }

                final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
                CountingInputStream counter = new CountingInputStream(combined);
                LZFInputStream lzfIn = new LZFInputStream(counter);
                try {
                     lzfIn.readAndWrite(out);
                } finally {
                    _close(lzfIn);
                    if (_diagnostics != null) {
                        final long totalSpent = _timeMaster.nanosForDiagnostics() - start;
                        // Not good, but need to try avoiding double-booking so assume 1/4 for response write
                        long respTime = (totalSpent >> 2);
                        _diagnostics.addResponseWriteTime(respTime);
                        _diagnostics.addFileReadAccess(start, start, start + totalSpent - respTime,
                                counter.readCount());
                    }
                }
                return null;
            }
        });
View Full Code Here

       
    protected void _readAllWriteStreamingCompressed3(InputStream in0, OutputStream out,
            byte[] copyBuffer, StreamyBytesMemBuffer offHeap)
        throws IOException
    {
        final CountingInputStream counter = new CountingInputStream(in0);
       
        InputStream in = Compressors.uncompressingStream(counter, _compression);

        // First: anything to skip (only the case for range requests)?
        if (_dataOffset > 0L) {
            long skipped = 0L;
            long toSkip = _dataOffset;

            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
           
            while (toSkip > 0) {
                long count = in.skip(toSkip);
                if (count <= 0L) { // should not occur really...
                    throw new IOException("Failed to skip more than "+skipped+" bytes (needed to skip "+_dataOffset+")");
                }
                skipped += count;
                toSkip -= count;
            }
            if (_diagnostics != null) {
                // assume here skipping is "free" (i.e. no bytes read)
                _diagnostics.addFileReadAccess(start, _timeMaster, 0L);
            }
        }
        // Second: output the whole thing, or just subset?
        // TODO: buffer
        if (_dataLength < 0) { // all of it
            long prevCount = 0L;
            while (true) {
                final long start = _timeMaster.nanosForDiagnostics();
                int count = in.read(copyBuffer);
                if (_diagnostics != null) {
                    long newCount = counter.readCount();
                    _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                    prevCount = newCount;
                }
               
                if (count <= 0) {
                    break;
                }
                final long outputStart = _timeMaster.nanosForDiagnostics();
                out.write(copyBuffer, 0, count);
                if (_diagnostics != null) {
                    _diagnostics.addResponseWriteTime(outputStart, _timeMaster);
                }
            }
            return;
        }
        // Just some of it
        long left = _dataLength;

        // TODO: buffer
        long prevCount = 0L;
        while (left > 0) {
            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
            int count = in.read(copyBuffer, 0, (int) Math.min(copyBuffer.length, left));
            if (_diagnostics != null) {
                long newCount = counter.readCount();
                _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                prevCount = newCount;
            }
            if (count <= 0) {
                break;
View Full Code Here

                    // otherwise, just read from input
                    combined = in;
                }

                final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
                CountingInputStream counter = new CountingInputStream(combined);
                LZFInputStream lzfIn = new LZFInputStream(counter);
                try {
                     lzfIn.readAndWrite(out);
                } finally {
                    _close(lzfIn);
                    if (_diagnostics != null) {
                        final long totalSpent = _timeMaster.nanosForDiagnostics() - start;
                        // Not good, but need to try avoiding double-booking so assume 1/4 for response write
                        long respTime = (totalSpent >> 2);
                        _diagnostics.addResponseWriteTime(respTime);
                        _diagnostics.addFileReadAccess(start, start, start + totalSpent - respTime,
                                counter.readCount());
                    }
                }
                return null;
            }
        });
View Full Code Here

       
    protected void _readAllWriteStreamingCompressed3(InputStream in0, OutputStream out,
            byte[] copyBuffer, StreamyBytesMemBuffer offHeap)
        throws IOException
    {
        final CountingInputStream counter = new CountingInputStream(in0);
       
        InputStream in = Compressors.uncompressingStream(counter, _compression);

        // First: anything to skip (only the case for range requests)?
        if (_dataOffset > 0L) {
            long skipped = 0L;
            long toSkip = _dataOffset;

            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
           
            while (toSkip > 0) {
                long count = in.skip(toSkip);
                if (count <= 0L) { // should not occur really...
                    throw new IOException("Failed to skip more than "+skipped+" bytes (needed to skip "+_dataOffset+")");
                }
                skipped += count;
                toSkip -= count;
            }
            if (_diagnostics != null) {
                // assume here skipping is "free" (i.e. no bytes read)
                _diagnostics.addFileReadAccess(start, _timeMaster, 0L);
            }
        }
        // Second: output the whole thing, or just subset?
        // TODO: buffer
        if (_dataLength < 0) { // all of it
            long prevCount = 0L;
            while (true) {
                final long start = _timeMaster.nanosForDiagnostics();
                int count = in.read(copyBuffer);
                if (_diagnostics != null) {
                    long newCount = counter.readCount();
                    _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                    prevCount = newCount;
                }
               
                if (count <= 0) {
                    break;
                }
                final long outputStart = _timeMaster.nanosForDiagnostics();
                out.write(copyBuffer, 0, count);
                if (_diagnostics != null) {
                    _diagnostics.addResponseWriteTime(outputStart, _timeMaster);
                }
            }
            return;
        }
        // Just some of it
        long left = _dataLength;

        // TODO: buffer
        long prevCount = 0L;
        while (left > 0) {
            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
            int count = in.read(copyBuffer, 0, (int) Math.min(copyBuffer.length, left));
            if (_diagnostics != null) {
                long newCount = counter.readCount();
                _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                prevCount = newCount;
            }
            if (count <= 0) {
                break;
View Full Code Here

                    // otherwise, just read from input
                    combined = in;
                }

                final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
                CountingInputStream counter = new CountingInputStream(combined);
                LZFInputStream lzfIn = new LZFInputStream(counter);
                try {
                     lzfIn.readAndWrite(out);
                } finally {
                    _close(lzfIn);
                    if (_diagnostics != null) {
                        final long totalSpent = _timeMaster.nanosForDiagnostics() - start;
                        // Not good, but need to try avoiding double-booking so assume 1/4 for response write
                        long respTime = (totalSpent >> 2);
                        _diagnostics.addResponseWriteTime(respTime);
                        _diagnostics.addFileReadAccess(start, start, start + totalSpent - respTime,
                                counter.readCount());
                    }
                }
                return null;
            }
        });
View Full Code Here

       
    protected void _readAllWriteStreamingCompressed3(InputStream in0, OutputStream out,
            byte[] copyBuffer, StreamyBytesMemBuffer offHeap)
        throws IOException
    {
        final CountingInputStream counter = new CountingInputStream(in0);
       
        InputStream in = Compressors.uncompressingStream(counter, _compression);

        // First: anything to skip (only the case for range requests)?
        if (_dataOffset > 0L) {
            long skipped = 0L;
            long toSkip = _dataOffset;

            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
           
            while (toSkip > 0) {
                long count = in.skip(toSkip);
                if (count <= 0L) { // should not occur really...
                    throw new IOException("Failed to skip more than "+skipped+" bytes (needed to skip "+_dataOffset+")");
                }
                skipped += count;
                toSkip -= count;
            }
            if (_diagnostics != null) {
                // assume here skipping is "free" (i.e. no bytes read)
                _diagnostics.addFileReadAccess(start, _timeMaster, 0L);
            }
        }
        // Second: output the whole thing, or just subset?
        // TODO: buffer
        if (_dataLength < 0) { // all of it
            long prevCount = 0L;
            while (true) {
                final long start = _timeMaster.nanosForDiagnostics();
                int count = in.read(copyBuffer);
                if (_diagnostics != null) {
                    long newCount = counter.readCount();
                    _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                    prevCount = newCount;
                }
               
                if (count <= 0) {
                    break;
                }
                final long outputStart = _timeMaster.nanosForDiagnostics();
                out.write(copyBuffer, 0, count);
                if (_diagnostics != null) {
                    _diagnostics.addResponseWriteTime(outputStart, _timeMaster);
                }
            }
            return;
        }
        // Just some of it
        long left = _dataLength;

        // TODO: buffer
        long prevCount = 0L;
        while (left > 0) {
            final long start = (_diagnostics == null) ? 0L : _timeMaster.nanosForDiagnostics();
            int count = in.read(copyBuffer, 0, (int) Math.min(copyBuffer.length, left));
            if (_diagnostics != null) {
                long newCount = counter.readCount();
                _diagnostics.addFileReadAccess(start, _timeMaster, newCount-prevCount);
                prevCount = newCount;
            }
            if (count <= 0) {
                break;
View Full Code Here

TOP

Related Classes of com.fasterxml.storemate.store.util.CountingInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.