Java 类org.apache.cassandra.thrift.CfSplit 实例源码

项目:deep-spark    文件:ThriftRangeUtils.java   
/**
 * 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);
}
项目:deep-spark    文件:ThriftRangeUtils.java   
/**
 * 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;
}
项目:deep-spark    文件:ThriftRangeUtilsTest.java   
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);
}
项目:cassandra-kmean    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:ACaZoo    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:presto    文件:CassandraThriftClient.java   
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;
}
项目:GraphTrek    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:Cassandra-Wasef    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:stratio-cassandra    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:cassandra-cqlMod    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:wso2-cassandra    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:cassandra-trunk    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:cassandra-1.2.16    文件:AbstractColumnFamilyInputFormat.java   
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;
}
项目:hive-cassandra    文件:AbstractColumnFamilyInputFormat.java   
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;
}