public boolean satisfies(RelTrait trait) { return this == trait || trait instanceof RelCollationImpl && Util.startsWith(fieldCollations, ((RelCollationImpl) trait).fieldCollations); }
public boolean satisfies(RelTrait trait) { return this == trait || trait instanceof RelCollationImpl && Util.startsWith(fieldCollations, ((RelCollationImpl) trait).fieldCollations); }
@Override protected void matched(List<String> prefixNames, List<String> names) { matchedNames = ImmutableList.copyOf( Util.startsWith(names, prefixNames) ? Util.skip(names, prefixNames.size()) : names); }
@Override protected void matched(List<String> prefixNames, List<String> names) { matchedNames = ImmutableList.copyOf( Util.startsWith(names, prefixNames) ? Util.skip(names, prefixNames.size()) : names); }
public boolean satisfies(RelTrait trait) { if (trait == this || trait == ANY) { return true; } if (trait instanceof RelDistributionImpl) { RelDistributionImpl distribution = (RelDistributionImpl) trait; if (type == distribution.type) { switch (type) { case HASH_DISTRIBUTED: // The "leading edge" property of Range does not apply to Hash. // Only Hash[x, y] satisfies Hash[x, y]. return keys.equals(distribution.keys); case RANGE_DISTRIBUTED: // Range[x, y] satisfies Range[x, y, z] but not Range[x] return Util.startsWith(distribution.keys, keys); default: return true; } } } if (trait == RANDOM_DISTRIBUTED) { // RANDOM is satisfied by HASH, ROUND-ROBIN, RANDOM, RANGE; // we've already checked RANDOM return type == Type.HASH_DISTRIBUTED || type == Type.ROUND_ROBIN_DISTRIBUTED || type == Type.RANGE_DISTRIBUTED; } return false; }
public boolean satisfies(RelTrait trait) { if (trait == this || trait == ANY) { return true; } if (trait instanceof RelDistributionImpl) { RelDistributionImpl distribution = (RelDistributionImpl) trait; if (type == distribution.type) { switch (type) { case HASH_DISTRIBUTED: // The "leading edge" property of Range does not apply to Hash. // Only Hash[x, y] satisfies Hash[x, y]. return keys.equals(distribution.keys); case RANGE_DISTRIBUTED: // Range[x, y] satisfies Range[x, y, z] but not Range[x] return Util.startsWith(distribution.keys, keys); default: return true; } } } if (trait == RANDOM_DISTRIBUTED) { // RANDOM is satisfied by HASH, ROUND-ROBIN, RANDOM, RANGE; // we've already checked RANDOM return type == Type.HASH_DISTRIBUTED || type == Type.ROUND_ROBIN_DISTRIBUTED || type == Type.RANGE_DISTRIBUTED; } return false; }
/** Unit test for {@link Util#startsWith}. */ @Test public void testStartsWithList() { assertThat(Util.startsWith(list("x"), list()), is(true)); assertThat(Util.startsWith(list("x"), list("x")), is(true)); assertThat(Util.startsWith(list("x"), list("y")), is(false)); assertThat(Util.startsWith(list("x"), list("x", "y")), is(false)); assertThat(Util.startsWith(list("x", "y"), list("x")), is(true)); assertThat(Util.startsWith(list(), list()), is(true)); assertThat(Util.startsWith(list(), list("x")), is(false)); }
/** Unit test for {@link Util#startsWith}. */ @Test public void testStartsWithList() { assertThat(Util.startsWith(list("x"), list()), is(true)); assertThat(Util.startsWith(list("x"), list("x")), is(true)); assertThat(Util.startsWith(list("x"), list("y")), is(false)); assertThat(Util.startsWith(list("x"), list("x", "y")), is(false)); assertThat(Util.startsWith(list("x", "y"), list("x")), is(true)); assertThat(Util.startsWith(list(), list()), is(true)); assertThat(Util.startsWith(list(), list("x")), is(false)); }