5 Star 43 Fork 21

springrain/dm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
zr.go 4.61 KB
一键复制 编辑 原始数据 按行查看 历史
springrain 提交于 2024-11-11 12:14 . v1.8.17 来自 达梦8.1.4.6
/*
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* All rights reserved.
*/
package dm
import (
"io"
)
const (
READ_LEN = Dm_build_408
)
type iOffRowBinder interface {
read(buf *Dm_build_1212)
isReadOver() bool
getObj() interface{}
}
type offRowBinder struct {
obj interface{}
encoding string
readOver bool
buffer *Dm_build_1212
position int32
offRow bool
targetLength int64
}
func newOffRowBinder(obj interface{}, encoding string, targetLength int64) *offRowBinder {
return &offRowBinder{
obj: obj,
encoding: encoding,
targetLength: targetLength,
readOver: false,
buffer: Dm_build_1216(),
position: 0,
}
}
type offRowBytesBinder struct {
*offRowBinder
}
func newOffRowBytesBinder(obj []byte, encoding string) *offRowBytesBinder {
var binder = &offRowBytesBinder{
newOffRowBinder(obj, encoding, int64(IGNORE_TARGET_LENGTH)),
}
binder.read(binder.buffer)
binder.offRow = binder.buffer.Dm_build_1217() > Dm_build_405
return binder
}
func (b *offRowBytesBinder) read(buf *Dm_build_1212) {
if b.buffer.Dm_build_1217() > 0 {
buf.Dm_build_1249(b.buffer)
} else if !b.readOver {
var obj = b.obj.([]byte)
buf.Dm_build_1238(obj, 0, len(obj))
b.readOver = true
}
}
func (b *offRowBytesBinder) isReadOver() bool {
return b.readOver
}
func (b *offRowBytesBinder) getObj() interface{} {
return b.obj
}
type offRowBlobBinder struct {
*offRowBinder
}
func newOffRowBlobBinder(blob DmBlob, encoding string) *offRowBlobBinder {
var binder = &offRowBlobBinder{
newOffRowBinder(blob, encoding, int64(IGNORE_TARGET_LENGTH)),
}
binder.read(binder.buffer)
binder.offRow = binder.buffer.Dm_build_1217() > Dm_build_405
return binder
}
func (b *offRowBlobBinder) read(buf *Dm_build_1212) {
if b.buffer.Dm_build_1217() > 0 {
buf.Dm_build_1249(b.buffer)
} else if !b.readOver {
var obj = b.obj.(DmBlob)
var totalLen, _ = obj.GetLength()
var leaveLen = totalLen - int64(b.position)
var readLen = int32(leaveLen)
if leaveLen > READ_LEN {
readLen = READ_LEN
}
var bytes, _ = obj.getBytes(int64(b.position)+1, readLen)
b.position += readLen
if b.position == int32(totalLen) {
b.readOver = true
}
buf.Dm_build_1238(bytes, 0, len(bytes))
}
}
func (b *offRowBlobBinder) isReadOver() bool {
return b.readOver
}
func (b *offRowBlobBinder) getObj() interface{} {
return b.obj
}
type offRowClobBinder struct {
*offRowBinder
}
func newOffRowClobBinder(clob DmClob, encoding string) *offRowClobBinder {
var binder = &offRowClobBinder{
newOffRowBinder(clob, encoding, int64(IGNORE_TARGET_LENGTH)),
}
binder.read(binder.buffer)
binder.offRow = binder.buffer.Dm_build_1217() > Dm_build_405
return binder
}
func (b *offRowClobBinder) read(buf *Dm_build_1212) {
if b.buffer.Dm_build_1217() > 0 {
buf.Dm_build_1249(b.buffer)
} else if !b.readOver {
var obj = b.obj.(DmClob)
var totalLen, _ = obj.GetLength()
var leaveLen = totalLen - int64(b.position)
var readLen = int32(leaveLen)
if leaveLen > READ_LEN {
readLen = READ_LEN
}
var str, _ = obj.getSubString(int64(b.position)+1, readLen)
var bytes = Dm_build_931.Dm_build_1147(str, b.encoding, nil)
b.position += readLen
if b.position == int32(totalLen) {
b.readOver = true
}
buf.Dm_build_1238(bytes, 0, len(bytes))
}
}
func (b *offRowClobBinder) isReadOver() bool {
return b.readOver
}
func (b *offRowClobBinder) getObj() interface{} {
return b.obj
}
type offRowReaderBinder struct {
*offRowBinder
}
func newOffRowReaderBinder(reader io.Reader, encoding string) *offRowReaderBinder {
var binder = &offRowReaderBinder{
newOffRowBinder(reader, encoding, int64(IGNORE_TARGET_LENGTH)),
}
binder.read(binder.buffer)
binder.offRow = binder.buffer.Dm_build_1217() > Dm_build_405
return binder
}
func (b *offRowReaderBinder) read(buf *Dm_build_1212) {
if b.buffer.Dm_build_1217() > 0 {
buf.Dm_build_1249(b.buffer)
} else if !b.readOver {
var err error
var readLen = READ_LEN
var reader = b.obj.(io.Reader)
var bytes = make([]byte, readLen)
readLen, err = reader.Read(bytes)
if err == io.EOF {
b.readOver = true
return
}
b.position += int32(readLen)
if readLen < len(bytes) || b.targetLength != int64(IGNORE_TARGET_LENGTH) && int64(b.position) == b.targetLength {
b.readOver = true
}
buf.Dm_build_1238(bytes[0:readLen], 0, readLen)
}
}
func (b *offRowReaderBinder) readAll() []byte {
var byteArray = Dm_build_1216()
b.read(byteArray)
for !b.readOver {
b.read(byteArray)
}
return byteArray.Dm_build_1259()
}
func (b *offRowReaderBinder) isReadOver() bool {
return b.readOver
}
func (b *offRowReaderBinder) getObj() interface{} {
return b.obj
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/chunanyong/dm.git
git@gitee.com:chunanyong/dm.git
chunanyong
dm
dm
master

搜索帮助