internal virtual ValueType[] RandomSetOfSupportedAndSortableTypes() { ValueType[] types = TestSuite.supportedValueTypes(); types = RemoveSpatialTypes(types); // <- don't use spatial values types = RandomValues.excluding(types, ValueType.STRING, ValueType.STRING_ARRAY); // <- don't use strings outside of BMP types = Random.randomValues().selection(types, 2, types.Length, false); return(types); }
/// <summary> /// If targetedTypes only contain types that has very low cardinality, then add one random high cardinality value type to the array. /// This is to prevent createTestGraph from looping forever when trying to generate unique values. /// </summary> private ValueType[] EnsureHighEnoughCardinality(ValueType[] targetedTypes) { ValueType[] lowCardinalityArray = new ValueType[] { ValueType.BOOLEAN, ValueType.BYTE, ValueType.BOOLEAN_ARRAY }; IList <ValueType> typesOfLowCardinality = new List <ValueType>(Arrays.asList(lowCardinalityArray)); foreach (ValueType targetedType in targetedTypes) { if (!typesOfLowCardinality.Contains(targetedType)) { return(targetedTypes); } } List <ValueType> result = new List <ValueType>(Arrays.asList(targetedTypes)); ValueType highCardinalityType = RandomRule.randomValues().among(RandomValues.excluding(lowCardinalityArray)); result.Add(highCardinalityType); return(result.ToArray()); }
public override void CreateTestGraph(GraphDatabaseService graphDb) { using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().indexFor(label("Node")).on("prop").create(); graphDb.Schema().indexFor(label("Node")).on("prop").on("prip").create(); tx.Success(); } using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().awaitIndexesOnline(5, MINUTES); tx.Success(); } RandomValues randomValues = RandomRule.randomValues(); ValueType[] allExceptNonOrderable = RandomValues.excluding(ValueType.STRING, ValueType.STRING_ARRAY, ValueType.GEOGRAPHIC_POINT, ValueType.GEOGRAPHIC_POINT_ARRAY, ValueType.GEOGRAPHIC_POINT_3D, ValueType.GEOGRAPHIC_POINT_3D_ARRAY, ValueType.CARTESIAN_POINT, ValueType.CARTESIAN_POINT_ARRAY, ValueType.CARTESIAN_POINT_3D, ValueType.CARTESIAN_POINT_3D_ARRAY); _targetedTypes = randomValues.Selection(allExceptNonOrderable, 1, allExceptNonOrderable.Length, false); _targetedTypes = EnsureHighEnoughCardinality(_targetedTypes); using (Transaction tx = graphDb.BeginTx()) { for (int i = 0; i < _nNodes; i++) { Node node = graphDb.CreateNode(label("Node")); Value propValue; Value pripValue; NodeValueTuple singleValue; NodeValueTuple doubleValue; do { propValue = randomValues.NextValueOfTypes(_targetedTypes); pripValue = randomValues.NextValueOfTypes(_targetedTypes); singleValue = new NodeValueTuple(this, node.Id, propValue); doubleValue = new NodeValueTuple(this, node.Id, propValue, pripValue); } while (_singlePropValues.Contains(singleValue) || _doublePropValues.Contains(doubleValue)); _singlePropValues.Add(singleValue); _doublePropValues.Add(doubleValue); node.SetProperty("prop", propValue.AsObject()); node.SetProperty("prip", pripValue.AsObject()); } tx.Success(); } }
public override void CreateTestGraph(GraphDatabaseService graphDb) { using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().indexFor(label("Node")).on("prop").create(); graphDb.Schema().indexFor(label("Node")).on("prop").on("prip").create(); tx.Success(); } using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().awaitIndexesOnline(5, MINUTES); tx.Success(); } using (Transaction tx = graphDb.BeginTx()) { RandomValues randomValues = RandomRule.randomValues(); ValueType[] allExceptNonSortable = RandomValues.excluding(ValueType.STRING, ValueType.STRING_ARRAY); for (int i = 0; i < _nNodes; i++) { Node node = graphDb.CreateNode(label("Node")); Value propValue = randomValues.NextValueOfTypes(allExceptNonSortable); node.SetProperty("prop", propValue.AsObject()); Value pripValue = randomValues.NextValue(); node.SetProperty("prip", pripValue.AsObject()); _singlePropValues.Add(propValue); _doublePropValues.Add(ValueTuple.of(propValue, pripValue)); } tx.Success(); } _singlePropValues.sort(Values.COMPARATOR); _doublePropValues.sort(ValueTuple.COMPARATOR); }