Search in sources :

Example 91 with LinkedHashSet

use of java.util.LinkedHashSet in project jedis by xetorthio.

the class SortedSetCommandsTest method zintertoreParams.

@Test
public void zintertoreParams() {
    jedis.zadd("foo", 1, "a");
    jedis.zadd("foo", 2, "b");
    jedis.zadd("bar", 2, "a");
    ZParams params = new ZParams();
    params.weights(2, 2.5);
    params.aggregate(ZParams.Aggregate.SUM);
    long result = jedis.zinterstore("dst", params, "foo", "bar");
    assertEquals(1, result);
    Set<Tuple> expected = new LinkedHashSet<Tuple>();
    expected.add(new Tuple("a", new Double(7)));
    assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
    // Binary
    jedis.zadd(bfoo, 1, ba);
    jedis.zadd(bfoo, 2, bb);
    jedis.zadd(bbar, 2, ba);
    ZParams bparams = new ZParams();
    bparams.weights(2, 2.5);
    bparams.aggregate(ZParams.Aggregate.SUM);
    long bresult = jedis.zinterstore(SafeEncoder.encode("dst"), bparams, bfoo, bbar);
    assertEquals(1, bresult);
    Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
    bexpected.add(new Tuple(ba, new Double(7)));
    assertEquals(bexpected, jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
}
Also used : ZParams(redis.clients.jedis.ZParams) LinkedHashSet(java.util.LinkedHashSet) Tuple(redis.clients.jedis.Tuple) Test(org.junit.Test)

Example 92 with LinkedHashSet

use of java.util.LinkedHashSet in project jedis by xetorthio.

the class SortedSetCommandsTest method zinterstore.

@Test
public void zinterstore() {
    jedis.zadd("foo", 1, "a");
    jedis.zadd("foo", 2, "b");
    jedis.zadd("bar", 2, "a");
    long result = jedis.zinterstore("dst", "foo", "bar");
    assertEquals(1, result);
    Set<Tuple> expected = new LinkedHashSet<Tuple>();
    expected.add(new Tuple("a", new Double(3)));
    assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
    // Binary
    jedis.zadd(bfoo, 1, ba);
    jedis.zadd(bfoo, 2, bb);
    jedis.zadd(bbar, 2, ba);
    long bresult = jedis.zinterstore(SafeEncoder.encode("dst"), bfoo, bbar);
    assertEquals(1, bresult);
    Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
    bexpected.add(new Tuple(ba, new Double(3)));
    assertEquals(bexpected, jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Tuple(redis.clients.jedis.Tuple) Test(org.junit.Test)

Example 93 with LinkedHashSet

use of java.util.LinkedHashSet in project jedis by xetorthio.

the class SortedSetCommandsTest method zrevrangeWithScores.

@Test
public void zrevrangeWithScores() {
    jedis.zadd("foo", 1d, "a");
    jedis.zadd("foo", 10d, "b");
    jedis.zadd("foo", 0.1d, "c");
    jedis.zadd("foo", 2d, "a");
    Set<Tuple> expected = new LinkedHashSet<Tuple>();
    expected.add(new Tuple("b", 10d));
    expected.add(new Tuple("a", 2d));
    Set<Tuple> range = jedis.zrevrangeWithScores("foo", 0, 1);
    assertEquals(expected, range);
    expected.add(new Tuple("c", 0.1d));
    range = jedis.zrevrangeWithScores("foo", 0, 100);
    assertEquals(expected, range);
    // Binary
    jedis.zadd(bfoo, 1d, ba);
    jedis.zadd(bfoo, 10d, bb);
    jedis.zadd(bfoo, 0.1d, bc);
    jedis.zadd(bfoo, 2d, ba);
    Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
    bexpected.add(new Tuple(bb, 10d));
    bexpected.add(new Tuple(ba, 2d));
    Set<Tuple> brange = jedis.zrevrangeWithScores(bfoo, 0, 1);
    assertEquals(bexpected, brange);
    bexpected.add(new Tuple(bc, 0.1d));
    brange = jedis.zrevrangeWithScores(bfoo, 0, 100);
    assertEquals(bexpected, brange);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Tuple(redis.clients.jedis.Tuple) Test(org.junit.Test)

Example 94 with LinkedHashSet

use of java.util.LinkedHashSet in project jedis by xetorthio.

the class SortedSetCommandsTest method zrangebyscoreWithScores.

@Test
public void zrangebyscoreWithScores() {
    jedis.zadd("foo", 1d, "a");
    jedis.zadd("foo", 10d, "b");
    jedis.zadd("foo", 0.1d, "c");
    jedis.zadd("foo", 2d, "a");
    Set<Tuple> range = jedis.zrangeByScoreWithScores("foo", 0d, 2d);
    Set<Tuple> expected = new LinkedHashSet<Tuple>();
    expected.add(new Tuple("c", 0.1d));
    expected.add(new Tuple("a", 2d));
    assertEquals(expected, range);
    range = jedis.zrangeByScoreWithScores("foo", 0d, 2d, 0, 1);
    expected = new LinkedHashSet<Tuple>();
    expected.add(new Tuple("c", 0.1d));
    assertEquals(expected, range);
    range = jedis.zrangeByScoreWithScores("foo", 0d, 2d, 1, 1);
    expected = new LinkedHashSet<Tuple>();
    expected.add(new Tuple("a", 2d));
    assertEquals(expected, range);
    // Binary
    jedis.zadd(bfoo, 1d, ba);
    jedis.zadd(bfoo, 10d, bb);
    jedis.zadd(bfoo, 0.1d, bc);
    jedis.zadd(bfoo, 2d, ba);
    Set<Tuple> brange = jedis.zrangeByScoreWithScores(bfoo, 0d, 2d);
    Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
    bexpected.add(new Tuple(bc, 0.1d));
    bexpected.add(new Tuple(ba, 2d));
    assertEquals(bexpected, brange);
    brange = jedis.zrangeByScoreWithScores(bfoo, 0d, 2d, 0, 1);
    bexpected = new LinkedHashSet<Tuple>();
    bexpected.add(new Tuple(bc, 0.1d));
    assertEquals(bexpected, brange);
    brange = jedis.zrangeByScoreWithScores(bfoo, 0d, 2d, 1, 1);
    bexpected = new LinkedHashSet<Tuple>();
    bexpected.add(new Tuple(ba, 2d));
    assertEquals(bexpected, brange);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Tuple(redis.clients.jedis.Tuple) Test(org.junit.Test)

Example 95 with LinkedHashSet

use of java.util.LinkedHashSet in project intellij-community by JetBrains.

the class ModuleFileIndexImpl method iterateContent.

@Override
public boolean iterateContent(@NotNull ContentIterator processor) {
    final Set<VirtualFile> contentRoots = ReadAction.compute(() -> {
        if (myModule.isDisposed())
            return Collections.emptySet();
        Set<VirtualFile> result = new LinkedHashSet<>();
        VirtualFile[][] allRoots = getModuleContentAndSourceRoots(myModule);
        for (VirtualFile[] roots : allRoots) {
            for (VirtualFile root : roots) {
                DirectoryInfo info = getInfoForFileOrDirectory(root);
                if (!info.isInProject())
                    continue;
                VirtualFile parent = root.getParent();
                if (parent != null) {
                    DirectoryInfo parentInfo = myDirectoryIndex.getInfoForFile(parent);
                    // inner content - skip it
                    if (parentInfo.isInProject() && myModule.equals(parentInfo.getModule()))
                        continue;
                }
                result.add(root);
            }
        }
        return result;
    });
    for (VirtualFile contentRoot : contentRoots) {
        if (!iterateContentUnderDirectory(contentRoot, processor)) {
            return false;
        }
    }
    return true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)3111 ArrayList (java.util.ArrayList)632 Set (java.util.Set)410 HashSet (java.util.HashSet)334 HashMap (java.util.HashMap)312 Map (java.util.Map)284 List (java.util.List)269 File (java.io.File)266 LinkedHashMap (java.util.LinkedHashMap)257 IOException (java.io.IOException)240 Test (org.junit.Test)239 LinkedList (java.util.LinkedList)139 Collection (java.util.Collection)103 URL (java.net.URL)83 ProcessResult (org.asqatasun.entity.audit.ProcessResult)76 Iterator (java.util.Iterator)73 SourceCodeRemark (org.asqatasun.entity.audit.SourceCodeRemark)73 TreeMap (java.util.TreeMap)70 TreeSet (java.util.TreeSet)70 Collectors (java.util.stream.Collectors)69