@Test public void testImmutability() { FieldList s1 = new FieldList(); FieldList s2 = new FieldList(5); FieldList s3 = new FieldList(Integer.valueOf(7)); FieldList s4 = new FieldList(5, 4, 7, 6); s1.addFields(s2).addFields(s3); s2.addFields(s4); s4.addFields(s1); s1.addField(Integer.valueOf(14)); s2.addFields(78, 13, 66, 3); assertEquals(0, s1.size()); assertEquals(1, s2.size()); assertEquals(1, s3.size()); assertEquals(4, s4.size()); }
@Override public boolean equals(Object obj) { if (obj instanceof GlobalProperties) { final GlobalProperties other = (GlobalProperties) obj; return (this.partitioning == other.partitioning) && (this.ordering == other.ordering || (this.ordering != null && this.ordering.equals(other.ordering))) && (this.partitioningFields == other.partitioningFields || (this.partitioningFields != null && this.partitioningFields.equals(other.partitioningFields))) && (this.uniqueFieldCombinations == other.uniqueFieldCombinations || (this.uniqueFieldCombinations != null && this.uniqueFieldCombinations.equals(other.uniqueFieldCombinations))); } else { return false; } }
/** * Extends this ordering by appending an additional order requirement. * If the index has been previously appended then the unmodified Ordering * is returned. * * @param index Field index of the appended order requirement. * @param type Type of the appended order requirement. * @param order Order of the appended order requirement. * * @return This ordering with an additional appended order requirement. */ public Ordering appendOrdering(Integer index, Class<? extends Comparable<?>> type, Order order) { if (index < 0) { throw new IllegalArgumentException("The key index must not be negative."); } if (order == null) { throw new NullPointerException(); } if (order == Order.NONE) { throw new IllegalArgumentException("An ordering must not be created with a NONE order."); } if (!this.indexes.contains(index)) { this.indexes = this.indexes.addField(index); this.types.add(type); this.orders.add(order); } return this; }
@Test public void testFieldListAdds() { check(new FieldList().addField(1).addField(2), 1, 2); check(FieldList.EMPTY_LIST.addField(3).addField(2), 3, 2); check(new FieldList(13).addFields(new FieldList(17, 31, 42)), 13, 17, 31, 42); check(new FieldList(14).addFields(new FieldList(17)), 14, 17); check(new FieldList(3).addFields(2, 8, 5, 7), 3, 2, 8, 5, 7); }
for (int i = 0; i < this.ordering.getInvolvedIndexes().size(); i++) { int sourceField = this.ordering.getInvolvedIndexes().get(i); FieldSet targetField = props.getForwardingTargetFields(input, sourceField); case ANY_PARTITIONING: case CUSTOM_PARTITIONING: FieldList newPartitioningFields = new FieldList(); for (int sourceField : this.partitioningFields) { FieldSet targetField = props.getForwardingTargetFields(input, sourceField); "semantic forwarded field information. Will only use the field with the lowest index."); newPartitioningFields = newPartitioningFields.addField(targetField.toArray()[0]);
@Test public void testHashPartitioningPreserved1() { SingleInputSemanticProperties sprops = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[]{"0;1;4"}, null, null, tupleInfo, tupleInfo); GlobalProperties gprops = new GlobalProperties(); gprops.setHashPartitioned(new FieldList(0, 1, 4)); GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0); assertEquals(PartitioningProperty.HASH_PARTITIONED, result.getPartitioning()); FieldList pFields = result.getPartitioningFields(); assertEquals(3, pFields.size()); assertTrue(pFields.contains(0)); assertTrue(pFields.contains(1)); assertTrue(pFields.contains(4)); }
public static FieldList createOrderedFromSet(FieldSet set) { if (set instanceof FieldList) { return (FieldList) set; } else { final int[] cols = set.toArray(); Arrays.sort(cols); return new FieldList(cols); } }
produced1.getDataDistribution() != null && produced2.getDataDistribution() != null) { return produced1.getPartitioningFields().size() == produced2.getPartitioningFields().size() && checkSameOrdering(produced1, produced2, produced1.getPartitioningFields().size()) && produced1.getDataDistribution().equals(produced2.getDataDistribution()); return produced1.getPartitioningFields().isExactMatch(this.keys1) && produced2.getPartitioningFields().isExactMatch(this.keys2) && produced1.getCustomPartitioner() != null && produced2.getCustomPartitioner() != null && produced1.getCustomPartitioner().equals(produced2.getCustomPartitioner());
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((indexes == null) ? 0 : indexes.hashCode()); result = prime * result + ((orders == null) ? 0 : orders.hashCode()); result = prime * result + ((types == null) ? 0 : types.hashCode()); return result; }
@SuppressWarnings("unchecked") private <T> TypeComparatorFactory<?> createComparator(TypeInformation<T> typeInfo, FieldList keys, boolean[] sortOrder) { TypeComparator<T> comparator; if (typeInfo instanceof CompositeType) { comparator = ((CompositeType<T>) typeInfo).createComparator(keys.toArray(), sortOrder, 0, executionConfig); } else if (typeInfo instanceof AtomicType) { // handle grouping of atomic types comparator = ((AtomicType<T>) typeInfo).createComparator(sortOrder[0], executionConfig); } else { throw new RuntimeException("Unrecognized type: " + typeInfo); } return new RuntimeComparatorFactory<T>(comparator); }
groupRed1.getInput().getGlobalProperties().getPartitioningFields().isExactMatch(new FieldList(0))); assertTrue("Reduce input should be partitioned on 1.", groupRed2.getInput().getGlobalProperties().getPartitioningFields().isExactMatch(new FieldList(1))); assertTrue("Union input channel should hash partition on 0", i.getShipStrategy().equals(ShipStrategyType.PARTITION_HASH) && i.getShipStrategyKeys().isExactMatch(new FieldList(0))); assertTrue("Union input channel should hash partition on 0", i.getShipStrategy().equals(ShipStrategyType.PARTITION_HASH) && i.getShipStrategyKeys().isExactMatch(new FieldList(1)));
/** * Checks, if this set of properties, as interesting properties, is met by the given * properties. * * @param other * The properties for which to check whether they meet these properties. * @return True, if the properties are met, false otherwise. */ public boolean isMetBy(LocalProperties other) { if (this.ordering != null) { // we demand an ordering return other.getOrdering() != null && this.ordering.isMetBy(other.getOrdering()); } else if (this.groupedFields != null) { // check if the other fields are unique if (other.getGroupedFields() != null && other.getGroupedFields().isValidUnorderedPrefix(this.groupedFields)) { return true; } else { return other.areFieldsUnique(this.groupedFields); } } else { return true; } }
public boolean isExactlyPartitionedOnFields(FieldList fields) { return this.partitioning.isPartitionedOnKey() && fields.isExactMatch(this.partitioningFields); }
public Integer get(int pos) { return get().get(pos); }
@Override public boolean preVisit(PlanNode visitable) { if (visitable instanceof WorksetIterationPlanNode) { PlanNode deltaNode = ((WorksetIterationPlanNode) visitable).getSolutionSetDeltaPlanNode(); //get the CoGroup DualInputPlanNode dpn = (DualInputPlanNode) deltaNode.getInputs().iterator().next().getSource(); Channel in1 = dpn.getInput1(); Channel in2 = dpn.getInput2(); Assert.assertTrue(in1.getLocalProperties().getOrdering() == null); Assert.assertTrue(in2.getLocalProperties().getOrdering() != null); Assert.assertTrue(in2.getLocalProperties().getOrdering().getInvolvedIndexes().contains(0)); Assert.assertTrue(in1.getShipStrategy() == ShipStrategyType.FORWARD); Assert.assertTrue(in2.getShipStrategy() == ShipStrategyType.PARTITION_HASH); return false; } return true; }
Ordering newOrdering = new Ordering(); for (int i = 0; i < this.ordering.getInvolvedIndexes().size(); i++) { int sourceField = this.ordering.getInvolvedIndexes().get(i); FieldSet targetField = props.getForwardingTargetFields(input, sourceField); if (targetField == null || targetField.size() == 0) { FieldList newGroupedFields = new FieldList(); "semantic forwarded field information. Will only use the field with the lowest index."); newGroupedFields = newGroupedFields.addField(targetField.toArray()[0]);
@Test public void testAnyPartitioningPreserved1() { SingleInputSemanticProperties sprops = new SingleInputSemanticProperties(); SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[]{"0;1;4"}, null, null, tupleInfo, tupleInfo); GlobalProperties gprops = new GlobalProperties(); gprops.setAnyPartitioning(new FieldList(0, 1, 4)); GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0); assertEquals(PartitioningProperty.ANY_PARTITIONING, result.getPartitioning()); FieldList pFields = result.getPartitioningFields(); assertEquals(3, pFields.size()); assertTrue(pFields.contains(0)); assertTrue(pFields.contains(1)); assertTrue(pFields.contains(4)); }