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


Java LongEncoding类代码示例

本文整理汇总了Java中com.thinkaurelius.titan.util.encoding.LongEncoding的典型用法代码示例。如果您正苦于以下问题:Java LongEncoding类的具体用法?Java LongEncoding怎么用?Java LongEncoding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LongEncoding类属于com.thinkaurelius.titan.util.encoding包,在下文中一共展示了LongEncoding类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeUniqueInstanceId

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
private static String computeUniqueInstanceId(Configuration config) {
    final String suffix;

    if (config.has(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX)) {
        suffix = LongEncoding.encode(config.get(
                GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX));
    } else {
        suffix = ManagementFactory.getRuntimeMXBean().getName() + LongEncoding.encode(INSTANCE_COUNTER.incrementAndGet());
    }

    byte[] addrBytes;
    try {
        addrBytes = Inet4Address.getLocalHost().getAddress();
    } catch (UnknownHostException e) {
        throw new TitanConfigurationException("Cannot determine local host", e);
    }
    String uid = new String(Hex.encodeHex(addrBytes)) + suffix;
    for (char c : ConfigElement.ILLEGAL_CHARS) {
        uid = StringUtils.replaceChars(uid,c,'-');
    }
    return uid;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:23,代码来源:GraphDatabaseConfiguration.java

示例2: testEncoding

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
@Test
public void testEncoding() {
    final int number = 1000000;
    final Random r = new Random();
    long start = System.currentTimeMillis();
    for (int i=0;i<number;i++) {
        long l = Math.abs(r.nextLong());
        if (l==Long.MIN_VALUE) continue;
        assertEquals(l, LongEncoding.decode(LongEncoding.encode(l)));
    }
    System.out.println("Time to de/encode "+number+" longs (in ms): " + (System.currentTimeMillis()-start));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:13,代码来源:LongEncodingTest.java

示例3: testCaseInsensitivity

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
@Test
public void testCaseInsensitivity() {
    Set<String> codes = Sets.newHashSet();
    for (int i = 0; i < 500000; i++) {
        assertTrue(codes.add(LongEncoding.encode(i).toLowerCase()));
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:LongEncodingTest.java

示例4: toString

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
@Override
public String toString() {
    StringBuilder s = new StringBuilder();
    s.append(LongEncoding.encode(relationId)).append(TOSTRING_DELIMITER).append(LongEncoding.encode(outVertexId))
            .append(TOSTRING_DELIMITER).append(LongEncoding.encode(typeId));
    if (inVertexId != 0) s.append(TOSTRING_DELIMITER).append(LongEncoding.encode(inVertexId));
    return s.toString();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:9,代码来源:RelationIdentifier.java

示例5: parse

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
public static final RelationIdentifier parse(String id) {
    String[] elements = id.split(TOSTRING_DELIMITER);
    if (elements.length != 3 && elements.length != 4)
        throw new IllegalArgumentException("Not a valid relation identifier: " + id);
    try {
        return new RelationIdentifier(LongEncoding.decode(elements[1]),
                LongEncoding.decode(elements[2]),
                LongEncoding.decode(elements[0]),
                elements.length == 4 ? LongEncoding.decode(elements[3]) : 0);
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException("Invalid id - each token expected to be a number", e);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:14,代码来源:RelationIdentifier.java

示例6: toString

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
@Override
public String toString() {
    StringBuilder s = new StringBuilder();
    s.append(LongEncoding.encode(relationId)).append(TOSTRING_DELIMITER).append(LongEncoding.encode(outVertexId))
            .append(TOSTRING_DELIMITER).append(LongEncoding.encode(typeId));
    if (inVertexId!=0) s.append(TOSTRING_DELIMITER).append(LongEncoding.encode(inVertexId));
    return s.toString();
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:9,代码来源:RelationIdentifier.java

示例7: parse

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
public static final RelationIdentifier parse(String id) {
    String[] elements = id.split(TOSTRING_DELIMITER);
    if (elements.length != 3 && elements.length != 4) throw new IllegalArgumentException("Not a valid relation identifier: " + id);
    try {
        return new RelationIdentifier(LongEncoding.decode(elements[1]),
                LongEncoding.decode(elements[2]),
                LongEncoding.decode(elements[0]),
                elements.length==4?LongEncoding.decode(elements[3]):0);
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException("Invalid id - each token expected to be a number",e);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:13,代码来源:RelationIdentifier.java

示例8: longID2Name

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
private static final String longID2Name(long id) {
    Preconditions.checkArgument(id > 0);
    return LongEncoding.encode(id);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:IndexSerializer.java

示例9: name2LongID

import com.thinkaurelius.titan.util.encoding.LongEncoding; //导入依赖的package包/类
private static final long name2LongID(String name) {
    return LongEncoding.decode(name);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:4,代码来源:IndexSerializer.java


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