当前位置: 首页>>代码示例>>Golang>>正文


Golang DataInput.ReadBytes方法代码示例

本文整理汇总了Golang中github.com/balzaczyy/golucene/core/util.DataInput.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:Golang DataInput.ReadBytes方法的具体用法?Golang DataInput.ReadBytes怎么用?Golang DataInput.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/balzaczyy/golucene/core/util.DataInput的用法示例。


在下文中一共展示了DataInput.ReadBytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: readField

func (r *CompressingStoredFieldsReader) readField(in util.DataInput,
	visitor StoredFieldVisitor, info *model.FieldInfo, bits int) (err error) {
	switch bits & TYPE_MASK {
	case BYTE_ARR:
		panic("not implemented yet")
	case STRING:
		var length int
		if length, err = int32AsInt(in.ReadVInt()); err != nil {
			return err
		}
		data := make([]byte, length)
		if err = in.ReadBytes(data); err != nil {
			return err
		}
		visitor.StringField(info, string(data))
	case NUMERIC_INT:
		panic("not implemented yet")
	case NUMERIC_FLOAT:
		panic("not implemented yet")
	case NUMERIC_LONG:
		panic("not implemented yet")
	case NUMERIC_DOUBLE:
		panic("not implemented yet")
	default:
		panic(fmt.Sprintf("Unknown type flag: %x", bits))
	}
	return nil
}
开发者ID:kiskovacs,项目名称:golucene,代码行数:28,代码来源:storedFieldsReader.go

示例2: newBytesStoreFromInput

func newBytesStoreFromInput(in util.DataInput, numBytes int64, maxBlockSize uint32) (bs *BytesStore, err error) {
	var blockSize uint32 = 2
	var blockBits uint32 = 1
	for int64(blockSize) < numBytes && blockSize < maxBlockSize {
		blockSize *= 2
		blockBits++
	}
	self := newBytesStore()
	self.blockBits = blockBits
	self.blockSize = blockSize
	self.blockMask = blockSize - 1
	left := numBytes
	for left > 0 {
		chunk := blockSize
		if left < int64(chunk) {
			chunk = uint32(left)
		}
		block := make([]byte, chunk)
		err = in.ReadBytes(block)
		if err != nil {
			return nil, err
		}
		self.blocks = append(self.blocks, block)
		left -= int64(chunk)
	}
	// So .getPosition still works
	self.nextWrite = uint32(len(self.blocks[len(self.blocks)-1]))
	return self, nil
}
开发者ID:kiskovacs,项目名称:golucene,代码行数:29,代码来源:bytes.go

示例3: Read

func (out *ByteSequenceOutputs) Read(in util.DataInput) (e interface{}, err error) {
	log.Printf("Reading from %v...", in)
	if length, err := in.ReadVInt(); err == nil {
		log.Printf("Length: %v", length)
		if length == 0 {
			e = out.NoOutput()
		} else {
			buf := make([]byte, length)
			e = buf
			err = in.ReadBytes(buf)
		}
	} else {
		log.Printf("Failed to read length due to %v", err)
	}
	return e, err
}
开发者ID:voidException,项目名称:golucene,代码行数:16,代码来源:fst.go


注:本文中的github.com/balzaczyy/golucene/core/util.DataInput.ReadBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。