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


Java UniqueId.stringToUid方法代码示例

本文整理汇总了Java中net.opentsdb.uid.UniqueId.stringToUid方法的典型用法代码示例。如果您正苦于以下问题:Java UniqueId.stringToUid方法的具体用法?Java UniqueId.stringToUid怎么用?Java UniqueId.stringToUid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.opentsdb.uid.UniqueId的用法示例。


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

示例1: newTSMeta

import net.opentsdb.uid.UniqueId; //导入方法依赖的package包/类
/**
 * Creates a new TSMeta with random content
 * @param tagCount The number of tags
 * @param customMapEntries The number of custom map entries in the TSMeta and underlying UIDMetas
 * @return the built TSMeta
 */
public static TSMeta newTSMeta(final int tagCount, final int customMapEntries) {
	
	LinkedList<UIDMeta> uidMetas = new LinkedList<UIDMeta>();
	for(int i = 0; i < tagCount+1; i++) {
		uidMetas.add(newUIDMeta(UniqueIdType.TAGK, customMapEntries));
		uidMetas.add(newUIDMeta(UniqueIdType.TAGV, customMapEntries));
	}
	
	UIDMeta metricMeta = newUIDMeta(UniqueIdType.METRIC, customMapEntries);
	StringBuilder strTsuid = new StringBuilder(metricMeta.getUID());
	for(UIDMeta umeta: uidMetas) {
		strTsuid.append(umeta.getUID());
	}
	byte[] tsuid = UniqueId.stringToUid(strTsuid.toString());
	TSMeta tsMeta = new TSMeta(tsuid, SystemClock.unixTime());
	setTags(tsMeta, new ArrayList<UIDMeta>(uidMetas));
	setMetric(tsMeta, metricMeta);
	return tsMeta;
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:26,代码来源:BaseTest.java

示例2: buildUIDMeta

import net.opentsdb.uid.UniqueId; //导入方法依赖的package包/类
/**
 * Builds a UIDMeta from the current row in the passed result set
 * @param rset The result set to read from
 * @param type THe UIDMeta type to build
 * @return the built UIDMeta
 */
private UIDMeta buildUIDMeta(final ResultSet rset, final UniqueIdType type) {
	try {
		UIDMeta meta = new UIDMeta(type, UniqueId.stringToUid(rset.getString("XUID")), rset.getString("NAME"));
		meta.setCreated(mstou(rset.getTimestamp("CREATED").getTime()));
		String mapStr = rset.getString("CUSTOM");
		if(mapStr!=null) {
			meta.setCustom((HashMap<String, String>) readMap(mapStr));
		}
		meta.setDescription(rset.getString("DESCRIPTION"));
		meta.setNotes(rset.getString("NOTES"));
		meta.setDisplayName(rset.getString("DISPLAY_NAME"));
		return meta;
	} catch (Exception ex) {
		throw new RuntimeException("Failed to build UIDMeta of type [" + type + "]", ex);
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:23,代码来源:DefaultMetaReader.java

示例3: uidFor

import net.opentsdb.uid.UniqueId; //导入方法依赖的package包/类
/**
 * Returns the UIDMeta uid as a byte array for the passed int
 * @param key The int ot generate a byte array for
 * @return the uid byte array
 */
public static byte[] uidFor(int key) {
	StringBuilder b = new StringBuilder(Integer.toHexString(key));
	while(b.length()<6) {
		b.insert(0, "0");
	}
	return UniqueId.stringToUid(b.toString());
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:13,代码来源:BaseTest.java

示例4: readUIDMetas

import net.opentsdb.uid.UniqueId; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * @see com.heliosapm.streams.metrichub.MetaReader#readUIDMetas(java.sql.ResultSet, net.opentsdb.uid.UniqueId.UniqueIdType)
 */
@Override
public List<UIDMeta> readUIDMetas(final ResultSet rset, final UniqueIdType uidType) {
	if(rset==null) throw new IllegalArgumentException("The passed result set was null");
	List<UIDMeta> uidMetas = new ArrayList<UIDMeta>();
	
	try {
		while(rset.next()) {
			UniqueIdType utype = null;
			if(uidType!=null) {
				utype = uidType;
			} else {
				utype = UniqueIdType.valueOf(rset.getString("TAG_TYPE"));
			}
			UIDMeta meta = new UIDMeta(utype, UniqueId.stringToUid(rset.getString("XUID")), rset.getString("NAME"));
			meta.setCreated(mstou(rset.getTimestamp("CREATED").getTime()));
			String mapStr = rset.getString("CUSTOM");
			if(mapStr!=null) {
				meta.setCustom((HashMap<String, String>) readMap(mapStr));
			}
			meta.setDescription(rset.getString("DESCRIPTION"));
			meta.setNotes(rset.getString("NOTES"));
			meta.setDisplayName(rset.getString("DISPLAY_NAME"));
			uidMetas.add(meta);
		}
	} catch (Exception ex) {
		throw new RuntimeException("Failed to read UIDMetas from ResultSet", ex);
	}
	return uidMetas;
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:34,代码来源:DefaultMetaReader.java

示例5: buildTSMeta

import net.opentsdb.uid.UniqueId; //导入方法依赖的package包/类
/**
 * Builds a TSMeta from the current row in the passed result set
 * @param rset The result set to read from
 * @param includeUIDs true to load UIDs, false otherwise
 * @return the built TSMeta
 */
protected TSMeta buildTSMeta(final ResultSet rset, final boolean includeUIDs) {
	try {
		TSMeta meta = new TSMeta(UniqueId.stringToUid(rset.getString("TSUID")), mstou(rset.getTimestamp("CREATED").getTime()));
		String mapStr = rset.getString("CUSTOM");
		if(mapStr!=null) {
			meta.setCustom((HashMap<String, String>) readMap(mapStr));
		}
		meta.setDescription(rset.getString("DESCRIPTION"));
		meta.setNotes(rset.getString("NOTES"));
		String disp = rset.getString("DISPLAY_NAME");
		if(disp==null || disp.trim().isEmpty()) disp = rset.getString("FQN"); 
		meta.setDisplayName(disp);
		meta.setDataType(rset.getString("DATA_TYPE"));
		meta.setMax(rset.getDouble("MAX_VALUE"));
		meta.setMin(rset.getDouble("MIN_VALUE"));
		meta.setRetention(rset.getInt("RETENTION"));
		meta.setUnits(rset.getString("UNITS"));
		final long fqnId = rset.getLong("FQNID");
		if(includeUIDs) {
			loadUIDs(
					rset.isClosed() ? null : rset.getStatement().getConnection(), 
						meta, rset.getString("METRIC_UID"), fqnId);
		}
		return meta;
	} catch (Exception ex) {
		throw new RuntimeException("Failed to read TSMetas from ResultSet", ex);
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:35,代码来源:DefaultMetaReader.java


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