@Override public FieldSet getForwardingTargetFields(int input, int sourceField) { if (input != 0 && input != 1) { throw new IndexOutOfBoundsException("Invalid input index for binary union node."); } return new FieldSet(sourceField); }
@Override public FieldSet getForwardingTargetFields(int input, int sourceField) { if(input != 0) { throw new IndexOutOfBoundsException(); } return new FieldSet(sourceField); }
public FieldSet addField(Integer fieldID) { if (fieldID == null) { throw new IllegalArgumentException("Field ID must not be null."); } return new FieldSet(this, fieldID); }
/** * Adds a field as having only unique values. * * @param field The field with unique values. */ public void addUniqueField(int field) { if (this.uniqueFields == null) { this.uniqueFields = new HashSet<FieldSet>(); } this.uniqueFields.add(new FieldSet(field)); }
/** * Creates a new node with a single input for the optimizer plan. * * @param programOperator The PACT that the node represents. */ protected SingleInputNode(SingleInputOperator<?, ?, ?> programOperator) { super(programOperator); int[] k = programOperator.getKeyColumns(0); this.keys = k == null || k.length == 0 ? null : new FieldSet(k); }
public PartitionDescriptor(PartitionMethod pMethod, FieldSet pKeys, Ordering ordering, Partitioner<?> customPartitioner, DataDistribution distribution) { super(pKeys); Preconditions.checkArgument(pMethod != PartitionMethod.RANGE || pKeys.equals(new FieldSet(ordering.getFieldPositions())), "Partition keys must match the given ordering."); this.pMethod = pMethod; this.customPartitioner = customPartitioner; this.distribution = distribution; this.ordering = ordering; }
@Test public void testFieldSetAdds() { check(new FieldSet().addField(1).addField(2), 1, 2); check(FieldSet.EMPTY_SET.addField(3).addField(2), 3, 2); check(new FieldSet(13).addFields(new FieldSet(17, 31, 42)), 17, 13, 42, 31); check(new FieldSet(14).addFields(new FieldSet(17)), 17, 14); check(new FieldSet(3).addFields(2, 8, 5, 7), 3, 2, 8, 5, 7); check(new FieldSet().addFields(new FieldSet())); check(new FieldSet().addFields(new FieldSet(3, 4)), 4, 3); check(new FieldSet(5, 1).addFields(new FieldSet()), 5, 1); }
@Test(expected = NullPointerException.class) public void testNullProps() { RequestedLocalProperties rlProp = new RequestedLocalProperties(); rlProp.setGroupedFields(new FieldSet(0, 2, 3)); rlProp.filterBySemanticProperties(null, 0); }
@Test(expected = IndexOutOfBoundsException.class) public void testGetReadFieldsInvalidIndex() { SingleInputSemanticProperties sp = new SingleInputSemanticProperties(); sp.addReadFields(new FieldSet(0, 1)); sp.getReadFields(1); }
@Test public void testAllErased() { SingleInputSemanticProperties sProps = new SingleInputSemanticProperties(); RequestedLocalProperties rlProp = new RequestedLocalProperties(); rlProp.setGroupedFields(new FieldSet(0, 2, 3)); RequestedLocalProperties filtered = rlProp.filterBySemanticProperties(sProps, 0); assertNull(filtered); }
@Test public void testEraseAll1() { SingleInputSemanticProperties sProp = new SingleInputSemanticProperties(); RequestedGlobalProperties rgProps = new RequestedGlobalProperties(); rgProps.setAnyPartitioning(new FieldSet(0,1,2)); RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0); assertNull(filtered); }
@Test(expected = IndexOutOfBoundsException.class) public void testInvalidInputIndex() { SingleInputSemanticProperties sprops = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[]{"0;1"}, null, null, tupleInfo, tupleInfo); RequestedGlobalProperties gprops = new RequestedGlobalProperties(); gprops.setHashPartitioned(new FieldSet(0,1)); gprops.filterBySemanticProperties(sprops, 1); }
@Test(expected = IndexOutOfBoundsException.class) public void testInvalidInputIndex() { SingleInputSemanticProperties sProps = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[]{"1; 4"}, null, null, tupleInfo, tupleInfo); RequestedLocalProperties rlProp = new RequestedLocalProperties(); rlProp.setGroupedFields(new FieldSet(1, 4)); rlProp.filterBySemanticProperties(sProps, 1); }
@Test public void testGroupingErased() { SingleInputSemanticProperties sProps = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[]{"0;2"}, null, null, tupleInfo, tupleInfo); RequestedLocalProperties rlProp = new RequestedLocalProperties(); rlProp.setGroupedFields(new FieldSet(0, 2, 3)); RequestedLocalProperties filtered = rlProp.filterBySemanticProperties(sProps, 0); assertNull(filtered); }
@Test public void testHashPartitioningErased() { SingleInputSemanticProperties sProp = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sProp, new String[]{"1;2"}, null, null, tupleInfo, tupleInfo); RequestedGlobalProperties rgProps = new RequestedGlobalProperties(); rgProps.setHashPartitioned(new FieldSet(0, 3, 4)); RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0); assertNull(filtered); }
@Test public void testAllErased1() { SingleInputSemanticProperties sp = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sp, null, null, null, tupleInfo, tupleInfo); LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 1, 2)); lProps = lProps.addUniqueFields(new FieldSet(3,4)); lProps = lProps.addUniqueFields(new FieldSet(5,6)); LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0); assertNull(filtered.getGroupedFields()); assertNull(filtered.getOrdering()); assertNull(filtered.getUniqueFields()); }
@Test public void testEraseAll2() { SingleInputSemanticProperties sProp = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sProp, new String[]{"3;4"}, null, null, tupleInfo, tupleInfo); RequestedGlobalProperties rgProps = new RequestedGlobalProperties(); rgProps.setAnyPartitioning(new FieldSet(0, 1, 2)); RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0); assertNull(filtered); }
@Test public void testCustomPartitioningErased() { SingleInputSemanticProperties sProp = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sProp, new String[]{"0;1;2"}, null, null, tupleInfo, tupleInfo); RequestedGlobalProperties rgProps = new RequestedGlobalProperties(); rgProps.setCustomPartitioned(new FieldSet(0, 1, 2), new MockPartitioner()); RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0); assertNull(filtered); }
@Test public void testAllErased2() { SingleInputSemanticProperties sp = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[]{"5"}, null, null, tupleInfo, tupleInfo); LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 1, 2)); lProps = lProps.addUniqueFields(new FieldSet(3,4)); LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0); assertNull(filtered.getGroupedFields()); assertNull(filtered.getOrdering()); assertNull(filtered.getUniqueFields()); }