private TextValue String(RecordPropertyCursor cursor, long reference, PageCursor page) { ByteBuffer buffer = cursor.Buffer = _read.loadString(reference, cursor.Buffer, page); buffer.flip(); return(Values.stringValue(UTF8.decode(buffer.array(), 0, buffer.limit()))); }
public override AnyValue MapText(TextValue value) { if (value.Length() > _maxTextParameterLength) { return(Values.stringValue(value.StringValue().Substring(0, _maxTextParameterLength))); } return(value); }
private void Encode(string @string) { PropertyBlock block = new PropertyBlock(); TextValue expectedValue = Values.stringValue(@string); _propertyStore.encodeValue(block, KEY_ID, expectedValue); assertEquals(0, block.ValueRecords.Count); Value readValue = block.Type.value(block, _propertyStore); assertEquals(expectedValue, readValue); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void minimalSplitterShouldRemoveEntityIdIfPossible() internal virtual void MinimalSplitterShouldRemoveEntityIdIfPossible() { // Given StringLayout layout = new StringLayout(); StringIndexKey left = layout.NewKey(); StringIndexKey right = layout.NewKey(); StringIndexKey minimalSplitter = layout.NewKey(); string @string = _random.nextString(); TextValue leftValue = Values.stringValue(@string); TextValue rightValue = Values.stringValue(@string + _random.randomValues().nextCharRaw()); // keys with unique values left.Initialize(1); left.initFromValue(0, leftValue, NEUTRAL); right.Initialize(2); right.initFromValue(0, rightValue, NEUTRAL); // When creating minimal splitter layout.MinimalSplitter(left, right, minimalSplitter); // Then that minimal splitter should have entity id shaved off assertEquals(NO_ENTITY_ID, minimalSplitter.EntityId, "Expected minimal splitter to have entityId removed when constructed from keys with unique values: " + "left=" + leftValue + ", right=" + rightValue); }
internal RelationshipReference RelationshipReference = VirtualValues.relationship(11L); // Should equal relationshipProxyValue when converted //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotTouchValuesThatDoNotNeedConversion() public virtual void ShouldNotTouchValuesThatDoNotNeedConversion() { // Given ListValue nodeList = VirtualValues.list(NodeProxyValue, DirectNodeValue); ListValue relationshipList = VirtualValues.list(RelationshipProxyValue, DirectRelationshipValue); MapValue nodeMap = VirtualValues.map(new string[] { "a", "b" }, new AnyValue[] { NodeProxyValue, DirectNodeValue }); MapValue relationshipMap = VirtualValues.map(new string[] { "a", "b" }, new AnyValue[] { RelationshipProxyValue, DirectRelationshipValue }); // Verify VerifyDoesNotTouchValue(NodeProxyValue); VerifyDoesNotTouchValue(RelationshipProxyValue); VerifyDoesNotTouchValue(DirectNodeValue); VerifyDoesNotTouchValue(DirectRelationshipValue); VerifyDoesNotTouchValue(nodeList); VerifyDoesNotTouchValue(relationshipList); VerifyDoesNotTouchValue(nodeMap); VerifyDoesNotTouchValue(relationshipMap); // This is not an exhaustive test since the other cases are very uninteresting... VerifyDoesNotTouchValue(Values.booleanValue(false)); VerifyDoesNotTouchValue(Values.stringValue("Hello")); VerifyDoesNotTouchValue(Values.longValue(42L)); // ... }
private void InitializeInstanceFields() { DirectRelationshipValue = VirtualValues.relationshipValue(12L, NodeProxyValue, DirectNodeValue, Values.stringValue("TYPE"), VirtualValues.emptyMap()); }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: public static RangePredicate<?> range(int propertyKeyId, String from, boolean fromInclusive, String to, boolean toInclusive) public static RangePredicate <object> Range(int propertyKeyId, string from, bool fromInclusive, string to, bool toInclusive) { return(new TextRangePredicate(propertyKeyId, string.ReferenceEquals(from, null) ? null : Values.stringValue(from), fromInclusive, string.ReferenceEquals(to, null) ? null : Values.stringValue(to), toInclusive)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAllowConcurrentViolationOfConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAllowConcurrentViolationOfConstraint() { // Given GraphDatabaseAPI graphDb = Db.GraphDatabaseAPI; System.Func <KernelTransaction> ktxSupplier = () => graphDb.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); Label label = label("Foo"); string propertyKey = "bar"; string conflictingValue = "baz"; // a constraint using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create(); tx.Success(); } // When using (Transaction tx = graphDb.BeginTx()) { KernelTransaction ktx = ktxSupplier(); int labelId = ktx.TokenRead().nodeLabel(label.Name()); int propertyKeyId = ktx.TokenRead().propertyKey(propertyKey); IndexDescriptor index = TestIndexDescriptorFactory.uniqueForLabel(labelId, propertyKeyId); Read read = ktx.DataRead(); using (NodeValueIndexCursor cursor = ktx.Cursors().allocateNodeValueIndexCursor()) { read.NodeIndexSeek(ktx.SchemaRead().index(labelId, propertyKeyId), cursor, IndexOrder.NONE, false, IndexQuery.exact(index.Schema().PropertyId, "The value is irrelevant, we just want to perform some sort of lookup against this " + "index")); } // then let another thread come in and create a node Threads.execute(Db => { using (Transaction transaction = Db.beginTx()) { Db.createNode(label).setProperty(propertyKey, conflictingValue); transaction.success(); } return(null); }, graphDb).get(); // before we create a node with the same property ourselves - using the same statement that we have // already used for lookup against that very same index long node = ktx.DataWrite().nodeCreate(); ktx.DataWrite().nodeAddLabel(node, labelId); try { ktx.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of(conflictingValue)); fail("exception expected"); } // Then catch (UniquePropertyValueValidationException e) { assertEquals(ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKeyId), e.Constraint()); IndexEntryConflictException conflict = Iterators.single(e.Conflicts().GetEnumerator()); assertEquals(Values.stringValue(conflictingValue), conflict.SinglePropertyValue); } tx.Success(); } }
public override AnyValue MapPath(PathValue value) { return(Values.stringValue("§PATH[" + value.Size() + "]")); }
public override AnyValue MapSequence(SequenceValue value) { return(Values.stringValue("§LIST[" + value.Length() + "]")); }
public override AnyValue MapMap(MapValue map) { return(Values.stringValue("§MAP[" + map.Size() + "]")); }