public ColumnSelectorBuilder forAll()

in harry-core/src/harry/model/OpSelectors.java [441:504]


        public ColumnSelectorBuilder forAll(SchemaSpec schema, Surjections.Surjection<BitSet> orig)
        {
            for (OperationKind type : OperationKind.values())
            {
                Surjections.Surjection<BitSet> gen = orig;

                switch (type)
                {
                    case UPDATE_WITH_STATICS:
                    case DELETE_COLUMN_WITH_STATICS:
                        gen = (descriptor) -> {
                            long counter = 0;
                            while (counter <= 100)
                            {
                                BitSet bitSet = orig.inflate(descriptor);
                                if ((schema.regularColumns.isEmpty() || !bitSet.allUnset(schema.regularColumnsMask))
                                    && (schema.staticColumns.isEmpty() || !bitSet.allUnset(schema.staticColumnsMask)))
                                    return bitSet;

                                descriptor = RngUtils.next(descriptor);
                                counter++;
                            }
                            throw new RuntimeException(String.format("Could not generate a value after %d attempts.", counter));
                        };
                        break;
                    // Can not have an UPDATE statement without anything to update
                    case UPDATE:
                        gen = descriptor -> {
                            long counter = 0;
                            while (counter <= 100)
                            {
                                BitSet bitSet = orig.inflate(descriptor);

                                if (!bitSet.allUnset(schema.regularColumnsMask))
                                    return bitSet;

                                descriptor = RngUtils.next(descriptor);
                                counter++;
                            }
                            throw new RuntimeException(String.format("Could not generate a value after %d attempts.", counter));
                        };
                        break;
                    case DELETE_COLUMN:
                        gen = (descriptor) -> {
                            long counter = 0;
                            while (counter <= 100)
                            {
                                BitSet bitSet = orig.inflate(descriptor);
                                BitSet mask = schema.regularColumnsMask;

                                if (!bitSet.allUnset(mask))
                                    return bitSet;

                                descriptor = RngUtils.next(descriptor);
                                counter++;
                            }
                            throw new RuntimeException(String.format("Could not generate a value after %d attempts.", counter));
                        };
                        break;
                }
                this.m.put(type, gen);
            }
            return this;
        }