Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the source code of RedisOutputStream.java

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what is the source code of RedisOutputStream.java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Package redis.clients.util;import java.io.*;import java.nio.charset.Charset;/** * The class implements a buffered output stream without synchronization * There are also special operations like in-place string encoding. * This stream fully ignore mark/reset and should not be used outside Jedis * / public final class RedisOutputStream extends FilterOutputStream {protected final byte buf []; / / buffer protected int count;// counter public static final Charset CHARSET = Charset.forName ("UTF-8"); / / Encoding method public RedisOutputStream (OutputStream out) {/ / initialize this (out, 8192);} public RedisOutputStream (OutputStream out, int size) {/ / initialize super (out) If (size 0) {out.write (buf, 0, count); count = 0;}} public void write (int b) throws IOException {/ / write to buffer, perform buffer cleanup buf [count++] = (byte) b when full; if (count = = buf.length) {flushBuffer () }} public void write (byte b [], int off, int len) throws IOException {/ / write to buffer if (len > = buf.length) {flushBuffer (); out.write (b, off, len);} else {if (len > = buf.length-count) {flushBuffer () } System.arraycopy (b, off, buf, count, len); count+ = len;}} public void writeAsciiCrLf (String in) throws IOException {/ / write to buffer final int size = in.length (); for (int I = 0; I! = size; + + I) {buf [count++] = (byte) in.charAt (I) If (count = = buf.length) {flushBuffer ();}} writeCrLf ();} public static boolean isSurrogate (char ch) {/ / XXX return ch > = Character.MIN_SURROGATE & & ch = buf.length-count) {flushBuffer ();} buf [count++] ='\ rpm; buf [count++] ='\ n' } public void writeUtf8CrLf (String str) throws IOException {/ / XXX int strLen = str.length (); int i; for (I = 0; I

< strLen; i++) { char c = str.charAt(i); if (!(c < 0x80)) break; buf[count++] = (byte) c; if(count == buf.length) { flushBuffer(); } } for (; i < strLen; i++) { char c = str.charAt(i); if (c < 0x80) { buf[count++] = (byte) c; if(count == buf.length) { flushBuffer(); } } else if (c < 0x800) { if(2 < buf.length - count) { flushBuffer(); } buf[count++] = (byte)(0xc0 | (c >

< buf.length - count) { flushBuffer(); } int uc = Character.toCodePoint(c, str.charAt(i++)); buf[count++] = ((byte)(0xf0 | ((uc >

> 18); buf [count++] = ((byte) (0x80 | (uc > > 12) & 0x3f); buf [count++] = ((byte) (0x80 | (uc > > 6) & 0x3f); buf [count++] = ((byte) (0x80 | (uc & 0x3f);} else {if (3)

< buf.length - count) { flushBuffer(); } buf[count++] =((byte)(0xe0 | ((c >

> 12); buf [count++] = ((byte) (0x80 | (c > > 6) & 0x3f)); buf [count++] = ((byte) (0x80 | (c & 0x3f);}} writeCrLf ();} private final static int [] sizeTable = {9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE} Private final static byte [] DigitTens = {# # * * $$} 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2. 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 and 4 respectively 44th, 4th, 4th, 4th, 4th, 4th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 5th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th, 6th 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9. 'nine, nine Private final static byte [] DigitOnes = {# # * * $$} 0, 1, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 5, 6, 7, 8, 9, 0' 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 4, 5, 6, 4, 8, 3, 3, 4, 4, 5, 6, 7, 8, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 8, 3, 4, 8, 8, 4, 8, 8, 4, 8, 8, 8, 4, 4, 5, 6, 4, 8, 4, 8, 4, 8, 4, 4, 8, 4, 4, 8, 4, 4, 8, 4, 4, 8, 4, 4, 8, 4, 4, 8, 4, 4, 8, 4, 4, 8, 4, 4, 8, 8 'nine, two, three, four, five, six, seven, eight, nine, zero, one, two, three, four, eight, eight, nine, one, six, seven, eight, eight, nine, nine, one. '2percent, 3percent, 4percent, 5percent, 6percent, 7percent, 8percent, 9percent,} Private final static byte [] digits = {'0,1,' 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, I, J' 'Knowles, 'lags,' masks, 'nails,' oaks, 'packs,' qalities, 'rudes,' tweets, 'utensils,' vaults, 'winters,' xylene, 'yearly,' z'} Public void writeIntCrLf (int value) throws IOException {/ / write an integer if (value)

< 0) { write('-'); value = -value; } int size = 0; while (value >

SizeTable [size]) size++; size++; if (size > = buf.length-count) {flushBuffer ();} int Q, r; int charPos = count + size; while (value > = 65536) {Q = value / 100; r = value-(Q (16 + 3); r = value-((Q)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report