本文整理汇总了Java中uk.gov.gchq.koryphe.impl.predicate.And类的典型用法代码示例。如果您正苦于以下问题:Java And类的具体用法?Java And怎么用?Java And使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
And类属于uk.gov.gchq.koryphe.impl.predicate包,在下文中一共展示了And类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: firstItemIsLessThan2AndSecondItemIsMoreThan5
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
public void firstItemIsLessThan2AndSecondItemIsMoreThan5() {
// ---------------------------------------------------------
final And function = new And.Builder()
.select(0)
.execute(new IsLessThan(2))
.select(1)
.execute(new IsMoreThan(5))
.build();
// ---------------------------------------------------------
runExample(function,
null,
new Tuple2<>(1, 10),
new Tuple2<>(1, 1),
new Tuple2<>(10, 10),
new Tuple2<>(10, 1),
new Tuple2<>(1L, 10L),
new Tuple1<>(1));
}
示例2: buildFilter
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
/**
* Builds the Parquet filters for a given Gaffer filter and the selection of which columns to apply the filter to.
* This method handles the nested And, Or and Not's.
*
* @param filterFunction A Gaffer filter
* @param selection An array of column names, either the Gaffer column names of Parquet column names
* @param group A Gaffer group name
* @return The Parquet filter based on the provided Gaffer filters
* @throws SerialisationException If any of the Gaffer objects are unable to be serialised to Parquet objects
*/
private Pair<FilterPredicate, Set<Path>> buildFilter(final Predicate filterFunction, final String[] selection, final String group) throws SerialisationException {
Pair<FilterPredicate, Set<Path>> filterResult;
if (filterFunction instanceof AgeOff) {
filterResult = addAgeOffFilter(((AgeOff) filterFunction), selection, group);
} else if (filterFunction instanceof And) {
filterResult = addAndFilter(((And) filterFunction).getComponents(), selection, group);
} else if (filterFunction instanceof Or) {
filterResult = addOrFilter(((Or) filterFunction).getComponents(), selection, group);
} else if (filterFunction instanceof Not) {
filterResult = buildFilter(((Not) filterFunction).getPredicate(), selection, group);
if (filterResult != null) {
filterResult = new Pair<>(not(filterResult.getFirst()), getAllPathsForColumn(group));
}
} else {
filterResult = addPrimitiveFilter(filterFunction, selection[0], group);
if (null == filterResult) {
needsValidatorsAndFiltersApplying = true;
}
}
return filterResult;
}
示例3: isLessThan3AndIsMoreThan0
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
public void isLessThan3AndIsMoreThan0() {
// ---------------------------------------------------------
final And function = new And<>(
new IsLessThan(3),
new IsMoreThan(0)
);
// ---------------------------------------------------------
runExample(function,
null,
0, 1, 2, 3, 1L, 2L);
}
示例4: getPredicate
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
@Override
public Predicate<Tuple<String>> getPredicate() {
TupleAdaptedPredicate<String, Comparable> tupleIsMoreThan = new TupleAdaptedPredicate<>();
tupleIsMoreThan.setSelection(new String[]{"A"});
tupleIsMoreThan.setPredicate(new IsMoreThan(2));
TupleAdaptedPredicate<String, Comparable> tupleIsLessThan = new TupleAdaptedPredicate<>();
tupleIsLessThan.setSelection(new String[]{"C"});
tupleIsLessThan.setPredicate(new IsLessThan(8));
return new And<>(Arrays.asList(tupleIsMoreThan, tupleIsLessThan));
}
示例5: setupView
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
@Override
public void setupView() {
view = new View.Builder()
.edge(TestGroups.EDGE,
new ViewElementDefinition.Builder()
.preAggregationFilter(
new ElementFilter.Builder()
.select("treeSet", "long")
.execute(
new And.Builder()
.select(0)
.execute(new IsEqual(TestUtils.MERGED_TREESET))
.select(1)
.execute(
new And.Builder()
.select(0)
.execute(new IsMoreThan(89L, true))
.select(0)
.execute(new IsLessThan(95L, true))
.build())
.build())
.build())
.build())
.entity(TestGroups.ENTITY,
new ViewElementDefinition.Builder()
.preAggregationFilter(
new ElementFilter.Builder()
.select("freqMap", ParquetStoreConstants.VERTEX)
.execute(
new Or.Builder()
.select(0)
.execute(new Not<>(new IsEqual(TestUtils.MERGED_FREQMAP)))
.select(1)
.execute(new IsLessThan(2L, true))
.build())
.build())
.build())
.build();
}
示例6: shouldValidateAndReturnTrueForAndFilter
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
@Test
public void shouldValidateAndReturnTrueForAndFilter() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder()
.entity(TestGroups.ENTITY, new ViewElementDefinition.Builder()
.preAggregationFilter(new ElementFilter.Builder()
.select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2)
.execute(new And.Builder()
.select(0)
.execute(new IsEqual("some value"))
.select(1)
.execute(new IsEqual("some other value"))
.build())
.build())
.build())
.build();
final Schema schema = new Schema.Builder()
.type("obj", Object.class)
.type("string", String.class)
.entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder()
.property(TestPropertyNames.PROP_1, "obj")
.property(TestPropertyNames.PROP_2, "string")
.build())
.build();
// When
final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
// Then
assertTrue(result.isValid());
}
示例7: shouldValidateAndReturnFalseForAndFilterWithIncompatibleProperties
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
@Test
public void shouldValidateAndReturnFalseForAndFilterWithIncompatibleProperties() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder()
.entity(TestGroups.ENTITY, new ViewElementDefinition.Builder()
.preAggregationFilter(new ElementFilter.Builder()
.select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2)
.execute(new And.Builder()
.select(0)
.execute(new IsMoreThan(2))
.select(1)
.execute(new IsEqual("some other value"))
.build())
.build())
.build())
.build();
final Schema schema = new Schema.Builder()
.type("obj", Object.class)
.type("string", String.class)
.entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder()
.property(TestPropertyNames.PROP_1, "obj")
.property(TestPropertyNames.PROP_2, "string")
.build())
.build();
// When
final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
// Then
assertFalse(result.isValid());
}
示例8: AndExample
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
public AndExample() {
super(And.class);
}
示例9: buildPathToFilterMap
import uk.gov.gchq.koryphe.impl.predicate.And; //导入依赖的package包/类
@Test
public void buildPathToFilterMap() throws StoreException, SerialisationException, OperationException {
final ParquetStore store = new ParquetStore();
final Schema gafferSchema = TestUtils.gafferSchema("schemaUsingStringVertexType");
final ParquetStoreProperties storeProperties = TestUtils.getParquetStoreProperties();
store.initialise("buildPathToFilterMap", gafferSchema, storeProperties);
final ParquetFilterUtils parquetFilterUtils = new ParquetFilterUtils(store);
final ElementFilter filter = new ElementFilter.Builder()
.select(ParquetStoreConstants.SOURCE)
.execute(
new And.Builder()
.select(0)
.execute(
new IsMoreThan("c1"))
.select(0)
.execute(
new IsLessThan("e"))
.build())
.build();
final View view = new View.Builder().edge(TestGroups.EDGE,
new ViewElementDefinition.Builder()
.preAggregationFilter(filter)
.build())
.build();
final DirectedType directedType = DirectedType.EITHER;
final SeededGraphFilters.IncludeIncomingOutgoingType includeIncomingOutgoingType = SeededGraphFilters.IncludeIncomingOutgoingType.EITHER;
final SeedMatching.SeedMatchingType seedMatchingType = SeedMatching.SeedMatchingType.RELATED;
final Iterable<? extends ElementId> seeds = null;
final GraphIndex graphIndex = new GraphIndex();
final GroupIndex edgeIndex = new GroupIndex();
graphIndex.add(TestGroups.EDGE, edgeIndex);
final ColumnIndex srcIndex = new ColumnIndex();
edgeIndex.add(ParquetStoreConstants.SOURCE, srcIndex);
srcIndex.add(new MinValuesWithPath(new Object[]{"a"}, "srcFileA"));
srcIndex.add(new MinValuesWithPath(new Object[]{"b"}, "srcFileB"));
srcIndex.add(new MinValuesWithPath(new Object[]{"c"}, "srcFileC"));
srcIndex.add(new MinValuesWithPath(new Object[]{"d"}, "srcFileD"));
srcIndex.add(new MinValuesWithPath(new Object[]{"e"}, "srcFileE"));
srcIndex.add(new MinValuesWithPath(new Object[]{"f"}, "srcFileF"));
srcIndex.add(new MinValuesWithPath(new Object[]{"g"}, "srcFileG"));
srcIndex.add(new MinValuesWithPath(new Object[]{"h"}, "srcFileH"));
final ColumnIndex dstIndex = new ColumnIndex();
edgeIndex.add(ParquetStoreConstants.DESTINATION, dstIndex);
dstIndex.add(new MinValuesWithPath(new Object[]{"a"}, "dstFileA"));
dstIndex.add(new MinValuesWithPath(new Object[]{"b"}, "dstFileB"));
dstIndex.add(new MinValuesWithPath(new Object[]{"c"}, "dstFileC"));
dstIndex.add(new MinValuesWithPath(new Object[]{"d"}, "dstFileD"));
dstIndex.add(new MinValuesWithPath(new Object[]{"e"}, "dstFileE"));
dstIndex.add(new MinValuesWithPath(new Object[]{"f"}, "dstFileF"));
dstIndex.add(new MinValuesWithPath(new Object[]{"g"}, "dstFileG"));
dstIndex.add(new MinValuesWithPath(new Object[]{"h"}, "dstFileH"));
parquetFilterUtils.buildPathToFilterMap(view, directedType, includeIncomingOutgoingType, seedMatchingType, seeds, graphIndex);
final Map<Path, FilterPredicate> pathToFilterMap = parquetFilterUtils.getPathToFilterMap();
final Set<String> expectedPaths = new HashSet<>(3);
expectedPaths.add("srcFileC");
expectedPaths.add("srcFileD");
expectedPaths.add("srcFileE");
final Object[] actualPaths = pathToFilterMap.keySet().stream().map(Path::getName).toArray();
assertThat(expectedPaths, containsInAnyOrder(actualPaths));
}