예제 #1
0
        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())));
        }
예제 #2
0
 public override AnyValue MapText(TextValue value)
 {
     if (value.Length() > _maxTextParameterLength)
     {
         return(Values.stringValue(value.StringValue().Substring(0, _maxTextParameterLength)));
     }
     return(value);
 }
예제 #3
0
        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);
        }
예제 #4
0
//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);
        }
예제 #5
0
        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));
            // ...
        }
예제 #6
0
 private void InitializeInstanceFields()
 {
     DirectRelationshipValue = VirtualValues.relationshipValue(12L, NodeProxyValue, DirectNodeValue, Values.stringValue("TYPE"), VirtualValues.emptyMap());
 }
예제 #7
0
//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));
        }
예제 #8
0
//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();
            }
        }
예제 #9
0
 public override AnyValue MapPath(PathValue value)
 {
     return(Values.stringValue("§PATH[" + value.Size() + "]"));
 }
예제 #10
0
 public override AnyValue MapSequence(SequenceValue value)
 {
     return(Values.stringValue("§LIST[" + value.Length() + "]"));
 }
예제 #11
0
 public override AnyValue MapMap(MapValue map)
 {
     return(Values.stringValue("§MAP[" + map.Size() + "]"));
 }