publicsynchronizedintread(byte b[], int off, int len) throws IOException { getBufIfOpen(); // Check for closed stream if ((off | len | (off + len) | (b.length - (off + len))) < 0) { thrownew IndexOutOfBoundsException(); } elseif (len == 0) { return0; }
int n = 0; for (;;) { int nread = read1(b, off + n, len - n); if (nread <= 0) return (n == 0) ? nread : n; n += nread; if (n >= len) return n; // if not closed but no bytes available, return InputStream input = in; if (input != null && input.available() <= 0) return n; } }
privateintread1(byte[] b, int off, int len)throws IOException { int avail = count - pos; if (avail <= 0) { /* If the requested length is at least as large as the buffer, and if there is no mark/reset activity, do not bother to copy the bytes into the local buffer. In this way buffered streams will cascade harmlessly. */ if (len >= getBufIfOpen().length && markpos < 0) { return getInIfOpen().read(b, off, len); } fill(); avail = count - pos; if (avail <= 0) return -1; } int cnt = (avail < len) ? avail : len; System.arraycopy(getBufIfOpen(), pos, b, off, cnt); pos += cnt; return cnt; }
publicsynchronizedvoidwrite(byte b[], int off, int len)throws IOException { if (len >= buf.length) { /* If the request length exceeds the size of the output buffer, flush the output buffer and then write the data directly. In this way buffered streams will cascade harmlessly. */ flushBuffer(); out.write(b, off, len); return; } if (len > buf.length - count) { flushBuffer(); } System.arraycopy(b, off, buf, count, len); count += len; }
SELECT der.[session_id],der.[blocking_session_id], sp.lastwaittype,sp.hostname,sp.program_name,sp.loginame, der.[start_time] AS '开始时间', der.[status] AS '状态', dest.[text] AS 'sql语句', DB_NAME(der.[database_id]) AS '数据库名', der.[wait_type] AS '等待资源类型', der.[wait_time] AS '等待时间', der.[wait_resource] AS '等待的资源', der.[logical_reads] AS '逻辑读次数' FROM sys.[dm_exec_requests] AS der INNER JOIN master.dbo.sysprocesses AS sp ON der.session_id=sp.spid CROSS APPLY sys.[dm_exec_sql_text](der.[sql_handle]) AS dest --WHERE [session_id]>50 AND session_id<>@@SPID ORDER BY der.[session_id] GO