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


Java CfSplit类代码示例

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


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

示例1: getSplits

import org.apache.cassandra.thrift.CfSplit; //导入依赖的package包/类
/**
 * Returns the computed token range splits of the specified token range.
 *
 * @param deepTokenRange the token range to be splitted.
 * @return the list of token range splits, which are also token ranges.
 */
public List<DeepTokenRange> getSplits(DeepTokenRange deepTokenRange) {

    String start = tokenAsString((Comparable) deepTokenRange.getStartToken());
    String end = tokenAsString((Comparable) deepTokenRange.getEndToken());
    List<String> endpoints = deepTokenRange.getReplicas();

    for (String endpoint : endpoints) {
        try {
            ThriftClient client = ThriftClient.build(endpoint, rpcPort, keyspace);
            List<CfSplit> splits = client.describe_splits_ex(columnFamily, start, end, splitSize);
            client.close();
            return deepTokenRanges(splits, endpoints);
        } catch (TException e) {
            LOG.warn("Endpoint %s failed while splitting range %s", endpoint, deepTokenRange);
        }
    }
    throw new DeepGenericException("No available replicas for splitting range " + deepTokenRange);
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:25,代码来源:ThriftRangeUtils.java

示例2: deepTokenRanges

import org.apache.cassandra.thrift.CfSplit; //导入依赖的package包/类
/**
 * Returns the Deep splits represented by the specified Thrift splits using the specified endpoints for all of them.
 * Note that the returned list can contain one more ranges than the specified because the range containing the
 * partitioner's minimum token are divided into two ranges.
 *
 * @param splits    the Thrift splits to be converted.
 * @param endpoints the endpoints list to be set in each generated Deep split
 * @return the {@link com.stratio.deep.commons.rdd.DeepTokenRange}s represented by the specified
 * {@link org.apache.cassandra.thrift.CfSplit}s
 */
public List<DeepTokenRange> deepTokenRanges(List<CfSplit> splits, List<String> endpoints) {
    List<DeepTokenRange> result = new ArrayList<>();
    for (CfSplit split : splits) {
        Comparable splitStart = tokenAsComparable(split.getStart_token());
        Comparable splitEnd = tokenAsComparable(split.getEnd_token());
        if (splitStart.equals(splitEnd)) {
            result.add(new DeepTokenRange(minToken, minToken, endpoints));
        } else if (splitStart.compareTo(splitEnd) > 0) {
            result.add(new DeepTokenRange(splitStart, minToken, endpoints));
            result.add(new DeepTokenRange(minToken, splitEnd, endpoints));
        } else {
            result.add(new DeepTokenRange(splitStart, splitEnd, endpoints));
        }
    }
    return result;
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:27,代码来源:ThriftRangeUtils.java

示例3: testDeepTokenRanges

import org.apache.cassandra.thrift.CfSplit; //导入依赖的package包/类
private static <K extends Comparable, T extends Token<K>> void testDeepTokenRanges(IPartitioner<T> partitioner,
                                                                                   K startToken,
                                                                                   K endToken,
                                                                                   List<String> endpoints,
                                                                                   List<DeepTokenRange> expectedRanges) {

    ThriftRangeUtils utils = new ThriftRangeUtils(partitioner, "", 0, "", "", 0);

    Token.TokenFactory tokenFactory = partitioner.getTokenFactory();
    AbstractType tokenType = partitioner.getTokenValidator();
    String start = tokenFactory.toString(tokenFactory.fromByteArray(tokenType.decompose(startToken)));
    String end = tokenFactory.toString(tokenFactory.fromByteArray(tokenType.decompose(endToken)));
    CfSplit thriftSplit = new CfSplit(start, end, 0);
    List<DeepTokenRange> actualRanges = utils.deepTokenRanges(Arrays.asList(thriftSplit), endpoints);
    assertEquals(actualRanges, expectedRanges);
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:17,代码来源:ThriftRangeUtilsTest.java

示例4: tokenListToSplits

import org.apache.cassandra.thrift.CfSplit; //导入依赖的package包/类
private List<CfSplit> tokenListToSplits(List<String> splitTokens, int splitsize)
{
    List<CfSplit> splits = Lists.newArrayListWithExpectedSize(splitTokens.size() - 1);
    for (int j = 0; j < splitTokens.size() - 1; j++)
        splits.add(new CfSplit(splitTokens.get(j), splitTokens.get(j + 1), splitsize));
    return splits;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:AbstractColumnFamilyInputFormat.java

示例5: tokenListToSplits

import org.apache.cassandra.thrift.CfSplit; //导入依赖的package包/类
private static List<CfSplit> tokenListToSplits(List<String> splitTokens, int splitSize)
{
    List<CfSplit> splits = Lists.newArrayListWithExpectedSize(splitTokens.size() - 1);
    for (int index = 0; index < splitTokens.size() - 1; index++) {
        splits.add(new CfSplit(splitTokens.get(index), splitTokens.get(index + 1), splitSize));
    }
    return splits;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:9,代码来源:CassandraThriftClient.java

示例6: tokenListToSplits

import org.apache.cassandra.thrift.CfSplit; //导入依赖的package包/类
private List<CfSplit> tokenListToSplits(List<String> splitTokens, int splitsize) {
    List<CfSplit> splits = Lists.newArrayListWithExpectedSize(splitTokens.size() - 1);
    for (int j = 0; j < splitTokens.size() - 1; j++) {
        splits.add(new CfSplit(splitTokens.get(j), splitTokens.get(j + 1), splitsize));
    }
    return splits;
}
 
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:8,代码来源:AbstractColumnFamilyInputFormat.java


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