Пример #1
0
 internal static void ValidateQuery(IndexCapability capability, IndexOrder indexOrder, IndexQuery[] predicates)
 {
     if (indexOrder != IndexOrder.NONE)
     {
         ValueCategory valueCategory   = predicates[0].ValueGroup().category();
         IndexOrder[]  orderCapability = capability.OrderCapability(valueCategory);
         if (!ArrayUtil.contains(orderCapability, indexOrder))
         {
             orderCapability = ArrayUtils.add(orderCapability, IndexOrder.NONE);
             throw new System.NotSupportedException(format("Tried to query index with unsupported order %s. Supported orders for query %s are %s.", indexOrder, Arrays.ToString(predicates), Arrays.ToString(orderCapability)));
         }
     }
 }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadConsistentPropertyValues() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadConsistentPropertyValues()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Node[] nodes = new Node[10];
            Node[] nodes = new Node[10];
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String[] keys = new String[] {"1", "2", "3"};
            string[] keys = new string[] { "1", "2", "3" };
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String[] values = new String[] { longString('a'), longString('b'), longString('c')};
            string[] values = new string[] { LongString('a'), LongString('b'), LongString('c') };
            using (Transaction tx = Db.beginTx())
            {
                for (int i = 0; i < nodes.Length; i++)
                {
                    nodes[i] = Db.createNode();
                    foreach (string key in keys)
                    {
                        nodes[i].SetProperty(key, values[0]);
                    }
                }
                tx.Success();
            }

            int updaters = 10;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicLong updatersDone = new java.util.concurrent.atomic.AtomicLong(updaters);
            AtomicLong updatersDone = new AtomicLong(updaters);
            Race       race         = new Race();

            for (int i = 0; i < updaters; i++)
            {
                // Changers
                race.AddContestant(() =>
                {
                    try
                    {
                        ThreadLocalRandom random = ThreadLocalRandom.current();
                        for (int j = 0; j < 100; j++)
                        {
                            Node node  = nodes[random.Next(nodes.Length)];
                            string key = keys[random.Next(keys.Length)];
                            using (Transaction tx = Db.beginTx())
                            {
                                node.RemoveProperty(key);
                                tx.Success();
                            }
                            using (Transaction tx = Db.beginTx())
                            {
                                node.SetProperty(key, values[random.Next(values.Length)]);
                                tx.Success();
                            }
                        }
                    }
                    finally
                    {
                        updatersDone.decrementAndGet();
                    }
                });
            }
            for (int i = 0; i < 100; i++)
            {
                // Readers
                race.AddContestant(() =>
                {
                    ThreadLocalRandom random = ThreadLocalRandom.current();
                    while (updatersDone.get() > 0)
                    {
                        using (Transaction tx = Db.beginTx())
                        {
                            string value = ( string )nodes[random.Next(nodes.Length)].getProperty(keys[random.Next(keys.Length)], null);
                            assertTrue(value, string.ReferenceEquals(value, null) || ArrayUtil.contains(values, value));
                            tx.Success();
                        }
                    }
                });
            }

            // WHEN
            race.Go();
        }