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));
}
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));
}
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);
}
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);
}
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;
}
Aggregations