• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TreeRange类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testInvalids

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testInvalids()
{
    Iterator<TreeRange> ranges;

    // (zero, zero]
    ranges = mt.invalids();
    assertEquals(new Range<>(tok(-1), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());

    // all invalid
    mt.split(tok(4));
    mt.split(tok(2));
    mt.split(tok(6));
    mt.split(tok(3));
    mt.split(tok(5));
    ranges = mt.invalids();
    assertEquals(new Range<>(tok(6), tok(-1)), ranges.next());
    assertEquals(new Range<>(tok(-1), tok(2)), ranges.next());
    assertEquals(new Range<>(tok(2), tok(3)), ranges.next());
    assertEquals(new Range<>(tok(3), tok(4)), ranges.next());
    assertEquals(new Range<>(tok(4), tok(5)), ranges.next());
    assertEquals(new Range<>(tok(5), tok(6)), ranges.next());
    assertEquals(new Range<>(tok(6), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:MerkleTreeTest.java


示例2: testSerialization

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception
{
    Range<Token> full = new Range<>(tok(-1), tok(-1));

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);

    DataOutputBuffer out = new DataOutputBuffer();
    MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    ByteArrayDataInput in = ByteStreams.newDataInput(serialized);
    MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(full));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:MerkleTreeTest.java


示例3: testSerialization

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception
{
    Range<Token> full = new Range<>(tok(-1), tok(-1));

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);

    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    ByteArrayDataInput in = ByteStreams.newDataInput(serialized);
    MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(full));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:23,代码来源:MerkleTreeTest.java


示例4: testInvalids

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testInvalids()
{
    Iterator<TreeRange> ranges;

    // (zero, zero]
    ranges = mts.invalids();
    assertEquals(new Range<>(tok(-1), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());

    // all invalid
    mts.split(tok(4));
    mts.split(tok(2));
    mts.split(tok(6));
    mts.split(tok(3));
    mts.split(tok(5));
    ranges = mts.invalids();
    assertEquals(new Range<>(tok(6), tok(-1)), ranges.next());
    assertEquals(new Range<>(tok(-1), tok(2)), ranges.next());
    assertEquals(new Range<>(tok(2), tok(3)), ranges.next());
    assertEquals(new Range<>(tok(3), tok(4)), ranges.next());
    assertEquals(new Range<>(tok(4), tok(5)), ranges.next());
    assertEquals(new Range<>(tok(5), tok(6)), ranges.next());
    assertEquals(new Range<>(tok(6), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:MerkleTreesTest.java


示例5: testSerialization

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception
{
    Range<Token> full = new Range<>(tok(-1), tok(-1));

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);

    DataOutputBuffer out = new DataOutputBuffer();
    MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    DataInputPlus in = new DataInputBuffer(serialized);
    MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(full));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:MerkleTreeTest.java


示例6: testInvalids

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testInvalids()
{
    Iterator<TreeRange> ranges;

    // (zero, zero]
    ranges = mt.invalids();
    assertEquals(new Range(tok(-1), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());

    // all invalid
    mt.split(tok(4));
    mt.split(tok(2));
    mt.split(tok(6));
    mt.split(tok(3));
    mt.split(tok(5));
    ranges = mt.invalids();
    assertEquals(new Range(tok(6), tok(-1)), ranges.next());
    assertEquals(new Range(tok(-1), tok(2)), ranges.next());
    assertEquals(new Range(tok(2), tok(3)), ranges.next());
    assertEquals(new Range(tok(3), tok(4)), ranges.next());
    assertEquals(new Range(tok(4), tok(5)), ranges.next());
    assertEquals(new Range(tok(5), tok(6)), ranges.next());
    assertEquals(new Range(tok(6), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:27,代码来源:MerkleTreeTest.java


示例7: testInvalids

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testInvalids()
{
    Iterator<TreeRange> ranges;
    
    // (zero, zero]
    ranges = mt.invalids();
    assertEquals(new Range(tok(-1), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());

    // all invalid
    mt.split(tok(4));
    mt.split(tok(2));
    mt.split(tok(6));
    mt.split(tok(3));
    mt.split(tok(5));
    ranges = mt.invalids();
    assertEquals(new Range(tok(6), tok(-1)), ranges.next());
    assertEquals(new Range(tok(-1), tok(2)), ranges.next());
    assertEquals(new Range(tok(2), tok(3)), ranges.next());
    assertEquals(new Range(tok(3), tok(4)), ranges.next());
    assertEquals(new Range(tok(4), tok(5)), ranges.next());
    assertEquals(new Range(tok(5), tok(6)), ranges.next());
    assertEquals(new Range(tok(6), tok(-1)), ranges.next());
    assertFalse(ranges.hasNext());
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:27,代码来源:MerkleTreeTest.java


示例8: testSerialization

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception
{
    Range<Token> first = new Range<>(tok(3), tok(4));

    Collection<Range<Token>> ranges = new ArrayList<>();

    ranges.add(first);
    ranges.add(new Range<Token>(tok(5), tok(2)));

    mts = new MerkleTrees(partitioner);
    mts.addMerkleTrees(256, ranges);

    // populate and validate the tree
    mts.init();
    for (TreeRange range : mts.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mts.hash(first);

    long serializedSize = MerkleTrees.serializer.serializedSize(mts, MessagingService.current_version);
    DataOutputBuffer out = new DataOutputBuffer();
    MerkleTrees.serializer.serialize(mts, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    assertEquals(serializedSize, serialized.length);

    DataInputBuffer in = new DataInputBuffer(serialized);
    MerkleTrees restored = MerkleTrees.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(first));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:33,代码来源:MerkleTreesTest.java


示例9: testSerialization

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception
{
    Range full = new Range(tok(-1), tok(-1));
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream oout = new ObjectOutputStream(bout);

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);
    oout.writeObject(mt);
    oout.close();

    ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream oin = new ObjectInputStream(bin);
    MerkleTree restored = (MerkleTree)oin.readObject();

    // restore partitioner after serialization
    restored.partitioner(partitioner);
    restored.fullRange = fullRange();

    assertHashEquals(initialhash, restored.hash(full));
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:28,代码来源:MerkleTreeTest.java


示例10: testValidateTree

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
/**
 * Generate two trees with different splits, but containing the same keys, and
 * check that they compare equally.
 *
 * The set of keys used in this test is: #{2,4,6,8,12,14,0}
 */
@Test
public void testValidateTree()
{
    TOKEN_SCALE = new BigInteger("16"); // this test needs slightly more resolution

    Range<Token> full = new Range<>(tok(-1), tok(-1));
    Iterator<TreeRange> ranges;
    MerkleTree mt2 = new MerkleTree(partitioner, fullRange(), RECOMMENDED_DEPTH, Integer.MAX_VALUE);

    mt.split(tok(8));
    mt.split(tok(4));
    mt.split(tok(12));
    mt.split(tok(6));
    mt.split(tok(10));

    ranges = mt.invalids();
    ranges.next().addAll(new HIterator(2, 4)); // (-1,4]: depth 2
    ranges.next().addAll(new HIterator(6)); // (4,6]
    ranges.next().addAll(new HIterator(8)); // (6,8]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,10]
    ranges.next().addAll(new HIterator(12)); // (10,12]
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2


    mt2.split(tok(8));
    mt2.split(tok(4));
    mt2.split(tok(12));
    mt2.split(tok(2));
    mt2.split(tok(10));
    mt2.split(tok(9));
    mt2.split(tok(11));

    ranges = mt2.invalids();
    ranges.next().addAll(new HIterator(2)); // (-1,2]
    ranges.next().addAll(new HIterator(4)); // (2,4]
    ranges.next().addAll(new HIterator(6, 8)); // (4,8]: depth 2
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,9]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (9,10]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (10,11]: depth 4
    ranges.next().addAll(new HIterator(12)); // (11,12]: depth 4
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2

    byte[] mthash = mt.hash(full);
    byte[] mt2hash = mt2.hash(full);
    assertHashEquals("Tree hashes did not match: " + mt + " && " + mt2, mthash, mt2hash);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:53,代码来源:MerkleTreeTest.java


示例11: testValidateTree

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
/**
 * Generate two trees with different splits, but containing the same keys, and
 * check that they compare equally.
 *
 * The set of keys used in this test is: #{2,4,6,8,12,14,0}
 */
@Test
public void testValidateTree()
{
    TOKEN_SCALE = new BigInteger("16"); // this test needs slightly more resolution

    Range<Token> full = new Range<>(tok(-1), tok(-1));
    Iterator<TreeRange> ranges;
    MerkleTrees mts2 = new MerkleTrees(partitioner);
    mts2.addMerkleTree(Integer.MAX_VALUE, fullRange());

    mts.split(tok(8));
    mts.split(tok(4));
    mts.split(tok(12));
    mts.split(tok(6));
    mts.split(tok(10));

    ranges = mts.invalids();
    ranges.next().addAll(new HIterator(2, 4)); // (-1,4]: depth 2
    ranges.next().addAll(new HIterator(6)); // (4,6]
    ranges.next().addAll(new HIterator(8)); // (6,8]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,10]
    ranges.next().addAll(new HIterator(12)); // (10,12]
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2


    mts2.split(tok(8));
    mts2.split(tok(4));
    mts2.split(tok(12));
    mts2.split(tok(2));
    mts2.split(tok(10));
    mts2.split(tok(9));
    mts2.split(tok(11));

    ranges = mts2.invalids();
    ranges.next().addAll(new HIterator(2)); // (-1,2]
    ranges.next().addAll(new HIterator(4)); // (2,4]
    ranges.next().addAll(new HIterator(6, 8)); // (4,8]: depth 2
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,9]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (9,10]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (10,11]: depth 4
    ranges.next().addAll(new HIterator(12)); // (11,12]: depth 4
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2

    byte[] mthash = mts.hash(full);
    byte[] mt2hash = mts2.hash(full);
    assertHashEquals("Tree hashes did not match: " + mts + " && " + mts2, mthash, mt2hash);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:54,代码来源:MerkleTreesTest.java


示例12: testValidateTree

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
/**
 * Generate two trees with different splits, but containing the same keys, and
 * check that they compare equally.
 *
 * The set of keys used in this test is: #{2,4,6,8,12,14,0}
 */
@Test
public void testValidateTree()
{
    TOKEN_SCALE = new BigInteger("16"); // this test needs slightly more resolution

    Range full = new Range(tok(-1), tok(-1));
    Iterator<TreeRange> ranges;
    MerkleTree mt2 = new MerkleTree(partitioner, fullRange(), RECOMMENDED_DEPTH, Integer.MAX_VALUE);

    mt.split(tok(8));
    mt.split(tok(4));
    mt.split(tok(12));
    mt.split(tok(6));
    mt.split(tok(10));

    ranges = mt.invalids();
    ranges.next().addAll(new HIterator(2, 4)); // (-1,4]: depth 2
    ranges.next().addAll(new HIterator(6)); // (4,6]
    ranges.next().addAll(new HIterator(8)); // (6,8]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,10]
    ranges.next().addAll(new HIterator(12)); // (10,12]
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2


    mt2.split(tok(8));
    mt2.split(tok(4));
    mt2.split(tok(12));
    mt2.split(tok(2));
    mt2.split(tok(10));
    mt2.split(tok(9));
    mt2.split(tok(11));

    ranges = mt2.invalids();
    ranges.next().addAll(new HIterator(2)); // (-1,2]
    ranges.next().addAll(new HIterator(4)); // (2,4]
    ranges.next().addAll(new HIterator(6, 8)); // (4,8]: depth 2
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,9]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (9,10]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (10,11]: depth 4
    ranges.next().addAll(new HIterator(12)); // (11,12]: depth 4
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2

    byte[] mthash = mt.hash(full);
    byte[] mt2hash = mt2.hash(full);
    assertHashEquals("Tree hashes did not match: " + mt + " && " + mt2, mthash, mt2hash);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:53,代码来源:MerkleTreeTest.java


示例13: testValidateTree

import org.apache.cassandra.utils.MerkleTree.TreeRange; //导入依赖的package包/类
/**
 * Generate two trees with different splits, but containing the same keys, and
 * check that they compare equally.
 *
 * The set of keys used in this test is: #{2,4,6,8,12,14,0}
 */
@Test
public void testValidateTree()
{
    TOKEN_SCALE = new BigInteger("16"); // this test needs slightly more resolution

    Range full = new Range(tok(-1), tok(-1));
    Iterator<TreeRange> ranges;
    MerkleTree mt2 = new MerkleTree(partitioner, fullRange(), RECOMMENDED_DEPTH, Integer.MAX_VALUE);

    mt.split(tok(8));
    mt.split(tok(4));
    mt.split(tok(12));
    mt.split(tok(6));
    mt.split(tok(10));
    
    ranges = mt.invalids();
    ranges.next().addAll(new HIterator(2, 4)); // (-1,4]: depth 2
    ranges.next().addAll(new HIterator(6)); // (4,6]
    ranges.next().addAll(new HIterator(8)); // (6,8]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,10]
    ranges.next().addAll(new HIterator(12)); // (10,12]
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2


    mt2.split(tok(8));
    mt2.split(tok(4));
    mt2.split(tok(12));
    mt2.split(tok(2));
    mt2.split(tok(10));
    mt2.split(tok(9));
    mt2.split(tok(11));

    ranges = mt2.invalids();
    ranges.next().addAll(new HIterator(2)); // (-1,2]
    ranges.next().addAll(new HIterator(4)); // (2,4]
    ranges.next().addAll(new HIterator(6, 8)); // (4,8]: depth 2
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (8,9]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (9,10]
    ranges.next().addAll(new HIterator(/*empty*/ new int[0])); // (10,11]: depth 4
    ranges.next().addAll(new HIterator(12)); // (11,12]: depth 4
    ranges.next().addAll(new HIterator(14, -1)); // (12,-1]: depth 2

    byte[] mthash = mt.hash(full);
    byte[] mt2hash = mt2.hash(full);
    assertHashEquals("Tree hashes did not match: " + mt + " && " + mt2, mthash, mt2hash);
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:53,代码来源:MerkleTreeTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WeakEventHandler类代码示例发布时间:2022-05-22
下一篇:
Java AuxiliaryServiceHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap