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

Java LongSet类代码示例

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

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



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

示例1: updateRowVisibility

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
void updateRowVisibility(LongSet nodeSuids) {
    if (session == null || nodeSuids == null || nodeSuids.isEmpty()) {
        setAllVisible();
        return;
    }
    if (filterDomainsCheckBox == null || !filterDomainsCheckBox.isSelected()) {
        setAllVisible();
        return;
    }

    Long[] nodeMappings = session.getNodeMappings();
    if (nodeMappings == null) {
        setAllVisible();
        return;
    }

    domainRows.stream()
              .forEach(row -> row.setVisible(row.hasSignificant(nodeSuids)));
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:20,代码来源:DomainBrowserController.java


示例2: checkBlock

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
private void checkBlock(IDBlock block, LongSet ids) {
    assertEquals(blockSize,block.numIds());
    for (int i=0;i<blockSize;i++) {
        long id = block.getId(i);
        assertEquals(id,block.getId(i));
        assertFalse(ids.contains(id));
        assertTrue(id<idUpperBound);
        assertTrue(id>0);
        ids.add(id);
    }
    if (hasEmptyUid) {
        assertEquals(blockSize-1,block.getId(block.numIds()-1)-block.getId(0));
    }
    try {
        block.getId(blockSize);
        fail();
    } catch (ArrayIndexOutOfBoundsException e) {}
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:19,代码来源:IDAuthorityTest.java


示例3: testSimpleIDAcquisition

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@Test
public void testSimpleIDAcquisition() throws BackendException {
    final IDBlockSizer blockSizer = new InnerIDBlockSizer();
    idAuthorities[0].setIDBlockSizer(blockSizer);
    int numTrials = 100;
    LongSet ids = new LongHashSet((int)blockSize*numTrials);
    long previous = 0;
    for (int i=0;i<numTrials;i++) {
        IDBlock block = idAuthorities[0].getIDBlock(0, 0, GET_ID_BLOCK_TIMEOUT);
        checkBlock(block,ids);
        if (hasEmptyUid) {
            if (previous!=0)
                assertEquals(previous+1, block.getId(0));
            previous=block.getId(block.numIds()-1);
        }
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:18,代码来源:IDAuthorityTest.java


示例4: CombinedTerm

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
public CombinedTerm(AbstractType<?> comparator, DataTerm term)
{
    this.comparator = comparator;
    this.term = term;
    this.tokens = new TreeMap<>();

    RangeIterator<Long, Token> tokens = term.getTokens();
    while (tokens.hasNext())
    {
        Token current = tokens.next();
        LongSet offsets = this.tokens.get(current.get());
        if (offsets == null)
            this.tokens.put(current.get(), (offsets = new LongOpenHashSet()));

        for (Long offset : ((TokenTree.OnDiskToken) current).getOffsets())
            offsets.add(offset);
    }
}
 
开发者ID:xedin,项目名称:sasi,代码行数:19,代码来源:CombinedTerm.java


示例5: createEntry

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
private LeafEntry createEntry(final long tok, final LongSet offsets)
{
    int offsetCount = offsets.size();
    switch (offsetCount)
    {
        case 0:
            throw new AssertionError("no offsets for token " + tok);
        case 1:
            long offset = offsets.toArray()[0];
            if (offset > MAX_OFFSET)
                throw new AssertionError("offset " + offset + " cannot be greater than " + MAX_OFFSET);
            else if (offset <= Integer.MAX_VALUE)
                return new SimpleLeafEntry(tok, offset);
            else
                return new FactoredOffsetLeafEntry(tok, offset);
        case 2:
            long[] rawOffsets = offsets.toArray();
            if (rawOffsets[0] <= Integer.MAX_VALUE && rawOffsets[1] <= Integer.MAX_VALUE &&
                    (rawOffsets[0] <= Short.MAX_VALUE || rawOffsets[1] <= Short.MAX_VALUE))
                return new PackedCollisionLeafEntry(tok, rawOffsets);
            else
                return createOverflowEntry(tok, offsetCount, offsets);
        default:
            return createOverflowEntry(tok, offsetCount, offsets);
    }
}
 
开发者ID:xedin,项目名称:sasi,代码行数:27,代码来源:TokenTreeBuilder.java


示例6: computeNext

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@Override
public Pair<Long, LongSet> computeNext()
{
    if (currentIterator != null && currentIterator.hasNext())
    {
        Map.Entry<Long, LongSet> next = currentIterator.next();
        return Pair.create(next.getKey(), next.getValue());
    }
    else
    {
        if (!levelIterator.hasNext())
            return endOfData();
        else
        {
            currentIterator = ((Leaf) levelIterator.next()).tokenIterator();
            return computeNext();
        }
    }

}
 
开发者ID:xedin,项目名称:sasi,代码行数:21,代码来源:TokenTreeBuilder.java


示例7: buildAndIterate

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@Test
public void buildAndIterate() throws Exception
{
    final TokenTreeBuilder builder = new TokenTreeBuilder(tokens).finish();
    final Iterator<Pair<Long, LongSet>> tokenIterator = builder.iterator();
    final Iterator<Map.Entry<Long, LongSet>> listIterator = tokens.entrySet().iterator();
    while (tokenIterator.hasNext() && listIterator.hasNext())
    {
        Pair<Long, LongSet> tokenNext = tokenIterator.next();
        Map.Entry<Long, LongSet> listNext = listIterator.next();

        Assert.assertEquals(listNext.getKey(), tokenNext.left);
        Assert.assertEquals(listNext.getValue(), tokenNext.right);
    }

    Assert.assertFalse("token iterator not finished", tokenIterator.hasNext());
    Assert.assertFalse("list iterator not finished", listIterator.hasNext());
}
 
开发者ID:xedin,项目名称:sasi,代码行数:19,代码来源:TokenTreeTest.java


示例8: testSimpleIDAcquisition

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@Test
public void testSimpleIDAcquisition() throws BackendException {
    final IDBlockSizer blockSizer = new InnerIDBlockSizer();
    idAuthorities[0].setIDBlockSizer(blockSizer);
    int numTrials = 100;
    LongSet ids = new LongOpenHashSet((int)blockSize*numTrials);
    long previous = 0;
    for (int i=0;i<numTrials;i++) {
        IDBlock block = idAuthorities[0].getIDBlock(0, 0, GET_ID_BLOCK_TIMEOUT);
        checkBlock(block,ids);
        if (hasEmptyUid) {
            if (previous!=0)
                assertEquals(previous+1, block.getId(0));
            previous=block.getId(block.numIds()-1);
        }
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:18,代码来源:IDAuthorityTest.java


示例9: setupSuiteScopeCluster

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@Override
public void setupSuiteScopeCluster() throws Exception {
    assertAcked(client().admin().indices().prepareCreate("idx")
            .addMapping("type", "s", "type=keyword").get());

    cardinality = randomIntBetween(8, 30);
    final List<IndexRequestBuilder> indexRequests = new ArrayList<>();
    final Set<String> stringTerms = new HashSet<>();
    final LongSet longTerms = new LongHashSet();
    for (int i = 0; i < cardinality; ++i) {
        String stringTerm;
        do {
            stringTerm = RandomStrings.randomAsciiOfLength(random(), 8);
        } while (!stringTerms.add(stringTerm));
        long longTerm;
        do {
            longTerm = randomInt(cardinality * 2);
        } while (!longTerms.add(longTerm));
        double doubleTerm = longTerm * Math.PI;
        String dateTerm = DateTimeFormat.forPattern("yyyy-MM-dd")
                .print(new DateTime(2014, 1, ((int) longTerm % 20) + 1, 0, 0, DateTimeZone.UTC));
        final int frequency = randomBoolean() ? 1 : randomIntBetween(2, 20);
        for (int j = 0; j < frequency; ++j) {
            indexRequests.add(client().prepareIndex("idx", "type").setSource(jsonBuilder()
                    .startObject()
                    .field("s", stringTerm)
                    .field("l", longTerm)
                    .field("d", doubleTerm)
                    .field("date", dateTerm)
                    .field("match", randomBoolean())
                    .endObject()));
        }
    }
    cardinality = stringTerms.size();

    indexRandom(true, indexRequests);
    ensureSearchable();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:39,代码来源:MinDocCountIT.java


示例10: updateRowVisibility

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
void updateRowVisibility(LongSet nodeSuids) {
    if (session == null || nodeSuids == null || nodeSuids.isEmpty()) {
        setAllVisible();
        return;
    }
    if (filterAttributesCheckBox == null || !filterAttributesCheckBox.isSelected()) {
        setAllVisible();
        return;
    }

    Long[] nodeMappings = session.getNodeMappings();
    if (nodeMappings == null) {
        setAllVisible();
        return;
    }

    AnalysisMethod analysisMethod = session.getAnalysisMethod();

    Consumer<? super AttributeRow> action;
    if (analysisMethod == AnalysisMethod.HighestAndLowest) {
        action = row -> row.setVisible(row.hasHighest(nodeSuids) || row.hasLowest(nodeSuids));
    } else if (analysisMethod == AnalysisMethod.Highest) {
        action = row -> row.setVisible(row.hasHighest(nodeSuids));
    } else {
        action = row -> row.setVisible(row.hasLowest(nodeSuids));
    }

    attributes.stream()
              .forEach(action);
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:31,代码来源:AttributeBrowserController.java


示例11: notifyNodeSelectionChangedListeners

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void notifyNodeSelectionChangedListeners(LongSet nodeSuids) {
    List<NodeSelectionChangedListener> listeners = (List<NodeSelectionChangedListener>) listenersByClass.get(NodeSelectionChangedListener.class);
    listeners.stream()
             .forEach(l -> l.set(nodeSuids));
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:8,代码来源:DefaultEventService.java


示例12: hasIntersection

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
public static boolean hasIntersection(LongSet set1,
                                      LongSet set2) {
    Iterator<LongCursor> iterator = set1.iterator();
    while (iterator.hasNext()) {
        LongCursor cursor = iterator.next();
        if (set2.contains(cursor.value)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:12,代码来源:SafeUtil.java


示例13: add

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
public void add(Long token, long keyPosition)
{
    LongSet found = tokens.get(token);
    if (found == null)
        tokens.put(token, (found = new LongOpenHashSet(2)));

    found.add(keyPosition);
}
 
开发者ID:xedin,项目名称:sasi,代码行数:9,代码来源:TokenTreeBuilder.java


示例14: writeTerm

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
private void writeTerm(InMemoryTerm term, TokenTreeBuilder keys) throws IOException
{
    term.serialize(buffer);
    buffer.writeByte((byte) keys.getTokenCount());

    Iterator<Pair<Long, LongSet>> tokens = keys.iterator();
    while (tokens.hasNext())
        buffer.writeLong(tokens.next().left);
}
 
开发者ID:xedin,项目名称:sasi,代码行数:10,代码来源:OnDiskIndexBuilder.java


示例15: convert

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
private static Set<DecoratedKey> convert(TokenTreeBuilder offsets)
{
    Set<DecoratedKey> result = new HashSet<>();

    Iterator<Pair<Long, LongSet>> offsetIter = offsets.iterator();
    while (offsetIter.hasNext())
    {
        LongSet v = offsetIter.next().right;

        for (LongCursor offset : v)
            result.add(keyAt(offset.value));
    }
    return result;
}
 
开发者ID:xedin,项目名称:sasi,代码行数:15,代码来源:OnDiskIndexTest.java


示例16: addAll

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
private static void addAll(OnDiskIndexBuilder builder, ByteBuffer term, TokenTreeBuilder tokens)
{
    for (Map.Entry<Long, LongSet> token : tokens.getTokens().entrySet())
    {
        for (long position : token.getValue().toArray())
            builder.add(term, keyAt(position), position);
    }
}
 
开发者ID:xedin,项目名称:sasi,代码行数:9,代码来源:OnDiskIndexTest.java


示例17: buildSerializeAndIterate

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@Test
public void buildSerializeAndIterate() throws Exception
{
    final TokenTreeBuilder builder = new TokenTreeBuilder(simpleTokenMap).finish();

    final File treeFile = File.createTempFile("token-tree-iterate-test1", "tt");
    treeFile.deleteOnExit();

    final SequentialWriter writer = new SequentialWriter(treeFile, 4096, false);
    builder.write(writer);
    writer.close();

    final RandomAccessReader reader = RandomAccessReader.open(treeFile);
    final TokenTree tokenTree = new TokenTree(new MappedBuffer(reader));

    final Iterator<Token> tokenIterator = tokenTree.iterator(KEY_CONVERTER);
    final Iterator<Map.Entry<Long, LongSet>> listIterator = simpleTokenMap.entrySet().iterator();
    while (tokenIterator.hasNext() && listIterator.hasNext())
    {
        Token treeNext = tokenIterator.next();
        Map.Entry<Long, LongSet> listNext = listIterator.next();

        Assert.assertEquals(listNext.getKey(), treeNext.get());
        Assert.assertEquals(convert(listNext.getValue()), convert(treeNext));
    }

    Assert.assertFalse("token iterator not finished", tokenIterator.hasNext());
    Assert.assertFalse("list iterator not finished", listIterator.hasNext());

    reader.close();
}
 
开发者ID:xedin,项目名称:sasi,代码行数:32,代码来源:TokenTreeTest.java


示例18: computeNext

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
@Override
public TokenWithOffsets computeNext()
{
    if (!elements.hasNext())
        return endOfData();

    Map.Entry<Long, LongSet> next = elements.next();
    return new TokenWithOffsets(next.getKey(), next.getValue());
}
 
开发者ID:xedin,项目名称:sasi,代码行数:10,代码来源:TokenTreeTest.java


示例19: convert

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
private static Set<DecoratedKey> convert(LongSet offsets)
{
    Set<DecoratedKey> keys = new HashSet<>();
    for (LongCursor offset : offsets)
        keys.add(KEY_CONVERTER.apply(offset.value));

    return keys;
}
 
开发者ID:xedin,项目名称:sasi,代码行数:9,代码来源:TokenTreeTest.java


示例20: generateTree

import com.carrotsearch.hppc.LongSet; //导入依赖的package包/类
private static TokenTree generateTree(final long minToken, final long maxToken) throws IOException
{
    final SortedMap<Long, LongSet> toks = new TreeMap<Long, LongSet>()
    {{
            for (long i = minToken; i <= maxToken; i++)
            {
                LongSet offsetSet = new LongOpenHashSet();
                offsetSet.add(i);
                put(i, offsetSet);
            }
    }};

    final TokenTreeBuilder builder = new TokenTreeBuilder(toks).finish();
    final File treeFile = File.createTempFile("token-tree-get-test", "tt");
    treeFile.deleteOnExit();

    final SequentialWriter writer = new SequentialWriter(treeFile, 4096, false);
    builder.write(writer);
    writer.close();

    RandomAccessReader reader = null;

    try
    {
        reader = RandomAccessReader.open(treeFile);
        return new TokenTree(new MappedBuffer(reader));
    }
    finally
    {
        FileUtils.closeQuietly(reader);
    }
}
 
开发者ID:xedin,项目名称:sasi,代码行数:33,代码来源:TokenTreeTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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