org.redkalex.source.pgsql.PgRespCountDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redkale-plugins Show documentation
Show all versions of redkale-plugins Show documentation
Redkale-Plugins -- java framework
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkalex.source.pgsql;
import java.nio.ByteBuffer;
import org.redkale.util.ByteArray;
/** @author zhangjx */
public class PgRespCountDecoder extends PgRespDecoder {
public static final PgRespCountDecoder instance = new PgRespCountDecoder();
private PgRespCountDecoder() {}
@Override
public byte messageid() {
return 'C';
}
@Override
public Integer read(
PgClientConnection conn,
ByteBuffer buffer,
int length,
ByteArray array,
PgClientRequest request,
PgResultSet dataset) {
int len = length - 5; // 最后字节是(byte)0
byte b;
int rows = -1;
boolean debug = PgsqlDataSource.debug;
if (debug) {
array.clear();
}
for (int i = 0; i < len; i++) {
b = buffer.get();
if (rows != -1) {
rows = rows * 10 + (b - '0');
} else if (b == ' ') {
rows = 0;
}
if (debug) {
array.put(b);
}
}
buffer.get();
return rows;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy