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


Golang ReadSeeker.ReadFloat方法代码示例

本文整理汇总了Golang中gopkg/in/istreamdata/orientgo/v2/obinary/rw.ReadSeeker.ReadFloat方法的典型用法代码示例。如果您正苦于以下问题:Golang ReadSeeker.ReadFloat方法的具体用法?Golang ReadSeeker.ReadFloat怎么用?Golang ReadSeeker.ReadFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gopkg/in/istreamdata/orientgo/v2/obinary/rw.ReadSeeker的用法示例。


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

示例1: readSingleValue

func (f binaryRecordFormatV0) readSingleValue(r *rw.ReadSeeker, valueType orient.OType, doc *orient.Document) (value interface{}, err error) {
	defer func() {
		if r := recover(); r != nil {
			if ic, ok := r.(*runtime.TypeAssertionError); ok {
				err = fmt.Errorf("writeSingleValue(%v): %v", valueType, ic)
			} else {
				panic(r)
			}
		}
	}()
	switch valueType {
	case orient.INTEGER:
		value = int32(r.ReadVarint())
	case orient.LONG:
		value = int64(r.ReadVarint())
	case orient.SHORT:
		value = int16(r.ReadVarint())
	case orient.STRING:
		value = f.readString(r)
	case orient.DOUBLE:
		value = r.ReadDouble()
	case orient.FLOAT:
		value = r.ReadFloat()
	case orient.BYTE:
		value = f.readByte(r)
	case orient.BOOLEAN:
		value = f.readByte(r) == 1
	case orient.DATETIME:
		longTime := r.ReadVarint()
		value = time.Unix(longTime/1000, (longTime%1000)*1e6)
	case orient.DATE:
		//	long savedTime = OVarIntSerializer.readAsLong(bytes) * MILLISEC_PER_DAY;
		//	int offset = ODateHelper.getDatabaseTimeZone().getOffset(savedTime);
		//	value = new Date(savedTime - offset);
		savedTime := r.ReadVarint() * millisecPerDay
		t := time.Unix(savedTime/1000, (savedTime%1000)*1e6) //.UTC().Local()
		//		_, offset := t.Zone()
		//		value = t.Add(-time.Duration(offset) * time.Second)
		value = t
	case orient.EMBEDDED:
		doc2 := orient.NewEmptyDocument()
		if err = f.Deserialize(doc2, r); err != nil {
			return nil, err
		}
		value = doc2
	//	if (((ODocument) value).containsField(ODocumentSerializable.CLASS_NAME)) {
	//	String className = ((ODocument) value).field(ODocumentSerializable.CLASS_NAME);
	//	try {
	//	Class<?> clazz = Class.forName(className);
	//	ODocumentSerializable newValue = (ODocumentSerializable) clazz.newInstance();
	//	newValue.fromDocument((ODocument) value);
	//	value = newValue;
	//	} catch (Exception e) {
	//	throw new RuntimeException(e);
	//	}
	//	} else
	//	ODocumentInternal.addOwner((ODocument) value, document);
	case orient.EMBEDDEDSET, orient.EMBEDDEDLIST:
		value, err = f.readEmbeddedCollection(r, doc)
	case orient.LINKSET, orient.LINKLIST:
		value = f.readLinkCollection(r)
	case orient.BINARY:
		value = f.readBinary(r)
	case orient.LINK:
		value = f.readOptimizedLink(r)
	case orient.LINKMAP:
		value, err = f.readLinkMap(r, doc)
	case orient.EMBEDDEDMAP:
		value, err = f.readEmbeddedMap(r, doc)
	case orient.DECIMAL:
		value = f.readDecimal(r)
	case orient.LINKBAG:
		bag := orient.NewRidBag()
		if err = bag.FromStream(r); err != nil {
			return nil, err
		}
		bag.SetOwner(doc)
		value = bag
	case orient.TRANSIENT:
	case orient.ANY:
	case orient.CUSTOM:
		// TODO: implement via Register global function
		panic("CUSTOM type is not supported for now")
		//	try {
		//	String className = readString(bytes);
		//	Class<?> clazz = Class.forName(className);
		//	OSerializableStream stream = (OSerializableStream) clazz.newInstance();
		//	stream.fromStream(readBinary(bytes));
		//	if (stream instanceof OSerializableWrapper)
		//	value = ((OSerializableWrapper) stream).getSerializable();
		//	else
		//	value = stream;
		//	} catch (Exception e) {
		//	throw new RuntimeException(e);
		//	}
	}
	if err == nil {
		err = r.Err()
	}
	return
//.........这里部分代码省略.........
开发者ID:josebalius,项目名称:orientgo,代码行数:101,代码来源:serializer_binary.go


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