private NodeValueClientFilter InitializeFilter(params IndexQuery[] filters) { NodeValueClientFilter filter = new NodeValueClientFilter(this, _node, _property, _read, filters); filter.Initialize(TestIndexDescriptorFactory.forLabel(11), this, null, IndexOrder.NONE, true); return(filter); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRejectNodeNotInUse() public virtual void ShouldRejectNodeNotInUse() { // given NodeValueClientFilter filter = InitializeFilter(IndexQuery.exists(12)); // when filter.Next(); assertFalse(filter.AcceptNode(17, null)); filter.Close(); // then AssertEvents(Initialize(), Event.NEXT, Event.CLOSE); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAcceptAllNodesOnNoFilters() public virtual void ShouldAcceptAllNodesOnNoFilters() { // given _node.withNode(17); NodeValueClientFilter filter = InitializeFilter(); // when filter.Next(); assertTrue(filter.AcceptNode(17, null)); filter.Close(); // then AssertEvents(Initialize(), Event.NEXT, new Event.Node(17, null), Event.CLOSE); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAcceptNodeWithoutMatchingProperty() public virtual void ShouldNotAcceptNodeWithoutMatchingProperty() { // given _node.withNode(17, new long[0], genericMap(7, stringValue("wrong"))); NodeValueClientFilter filter = InitializeFilter(IndexQuery.exists(12)); // when filter.Next(); assertFalse(filter.AcceptNode(17, null)); filter.Close(); // then AssertEvents(Initialize(), Event.NEXT, Event.CLOSE); }
private Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient InjectFullValuePrecision(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, IndexQuery[] query, IndexReader reader) { Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient target = cursor; if (!reader.HasFullValuePrecision(query)) { IndexQuery[] filters = new IndexQuery[query.Length]; int count = 0; for (int i = 0; i < query.Length; i++) { IndexQuery q = query[i]; switch (q.Type()) { case range: ValueGroup valueGroup = q.ValueGroup(); if ((valueGroup == NUMBER || valueGroup == GEOMETRY) && !reader.HasFullValuePrecision(q)) { filters[i] = q; count++; } break; case exact: Value value = ((IndexQuery.ExactPredicate)q).value(); if (value.ValueGroup() == ValueGroup.NUMBER || Values.isArrayValue(value) || value.ValueGroup() == ValueGroup.GEOMETRY) { if (!reader.HasFullValuePrecision(q)) { filters[i] = q; count++; } } break; default: break; } } if (count > 0) { // filters[] can contain null elements. The non-null elements are the filters and each sit in the designated slot // matching the values from the index. target = new NodeValueClientFilter(target, _cursors.allocateNodeCursor(), _cursors.allocatePropertyCursor(), this, filters); } } return(target); }
private void ShouldConsultProvidedFilters(System.Func <Value[], Value[]> filterValues, bool filterAcceptsValue) { // given long nodeReference = 123; int labelId = 10; int slots = Random.Next(3, 8); IndexQuery[] filters = new IndexQuery[slots]; Value[] actualValues = new Value[slots]; Value[] values = new Value[slots]; IDictionary <int, Value> properties = new Dictionary <int, Value>(); int[] propertyKeyIds = new int[slots]; int filterCount = 0; for (int i = 0; i < slots; i++) { actualValues[i] = Random.nextValue(); int propertyKeyId = i; propertyKeyIds[i] = propertyKeyId; // we want at least one filter , randomly add filter or not if ((filterCount == 0 && i == slots - 1) || Random.nextBoolean()) { object filterValue = (filterAcceptsValue ? actualValues[i] : AnyOtherValueThan(actualValues[i])).asObjectCopy(); filters[i] = IndexQuery.exact(propertyKeyId, filterValue); filterCount++; } values[i] = Random.nextBoolean() ? NO_VALUE : actualValues[i]; properties[propertyKeyId] = actualValues[i]; } _node.withNode(nodeReference, new long[] { labelId }, properties); // when NodeValueClientFilter filter = new NodeValueClientFilter(this, _node, _property, _read, filters); filter.Initialize(TestIndexDescriptorFactory.forLabel(labelId, propertyKeyIds), this, null, IndexOrder.NONE, true); bool accepted = filter.AcceptNode(nodeReference, filterValues(values)); // then assertEquals(filterAcceptsValue, accepted); }