コード例 #1
0
        private static Labels Labels(int labelId, params long[] nodeIds)
        {
            IList <Pair <LabelScanKey, LabelScanValue> > entries = new List <Pair <LabelScanKey, LabelScanValue> >();
            long           currentRange = 0;
            LabelScanValue value        = new LabelScanValue();

            foreach (long nodeId in nodeIds)
            {
                long range = nodeId / RANGE_SIZE;
                if (range != currentRange)
                {
                    if (value.Bits != 0)
                    {
                        entries.Add(Pair.of((new LabelScanKey()).Set(labelId, currentRange), value));
                        value = new LabelScanValue();
                    }
                }
                value.Set(toIntExact(nodeId % RANGE_SIZE));
                currentRange = range;
            }

            if (value.Bits != 0)
            {
                entries.Add(Pair.of((new LabelScanKey()).Set(labelId, currentRange), value));
            }

            return(new Labels(labelId, entries));
        }
コード例 #2
0
        private static Hit <LabelScanKey, LabelScanValue> Hit(long baseNodeId, long bits)
        {
            LabelScanKey   key   = new LabelScanKey(LABEL_ID, baseNodeId);
            LabelScanValue value = new LabelScanValue();

            value.Bits = bits;
            return(new MutableHit <LabelScanKey, LabelScanValue>(key, value));
        }
コード例 #3
0
 private void Merge(sbyte type, LabelScanValue existingValue, LabelScanValue newValue)
 {
     try
     {
         _channel.put(type);
         _channel.putLong(existingValue.Bits);
         _channel.putLong(newValue.Bits);
         _position.add(1 + 8 + 8);
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveBits()
        public virtual void ShouldRemoveBits()
        {
            // GIVEN
            LabelScanValue value = new LabelScanValue();

            value.Bits = 0b1100__1000_0100__0010_0001;

            // WHEN
            LabelScanValue other = new LabelScanValue();

            other.Bits = 0b1000__0100_0100__0100_0100;
            value.Remove(other);

            // THEN
            assertEquals(0b0100__1000_0000__0010_0001, value.Bits);
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogAndDumpData() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogAndDumpData()
        {
            // given
            DatabaseLayout        databaseLayout = this.Directory.databaseLayout();
            LabelScanWriteMonitor writeMonitor   = new LabelScanWriteMonitor(Fs, databaseLayout);
            LabelScanValue        value          = new LabelScanValue();

            writeMonitor.Range(3, 0);
            writeMonitor.PrepareAdd(123, 4);
            writeMonitor.PrepareAdd(123, 5);
            writeMonitor.MergeAdd(new LabelScanValue(), value.Set(4).set(5));
            writeMonitor.FlushPendingUpdates();
            writeMonitor.PrepareRemove(124, 5);
            writeMonitor.MergeRemove(value, (new LabelScanValue()).Set(5));
            writeMonitor.WriteSessionEnded();
            writeMonitor.Range(5, 1);
            writeMonitor.PrepareAdd(125, 10);
            writeMonitor.MergeAdd((new LabelScanValue()).Set(9), (new LabelScanValue()).Set(10));
            writeMonitor.FlushPendingUpdates();
            writeMonitor.WriteSessionEnded();
            writeMonitor.Close();

            // when
            LabelScanWriteMonitor.Dumper dumper = mock(typeof(LabelScanWriteMonitor.Dumper));
            LabelScanWriteMonitor.Dump(Fs, databaseLayout, dumper, null);

            // then
            InOrder inOrder = Mockito.inOrder(dumper);

            inOrder.verify(dumper).prepare(true, 0, 0, 123, 64 * 3 + 4, 0);
            inOrder.verify(dumper).prepare(true, 0, 0, 123, 64 * 3 + 5, 0);
            inOrder.verify(dumper).merge(true, 0, 0, 3, 0, 0, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000000_00110000);
            inOrder.verify(dumper).prepare(false, 0, 1, 124, 64 * 3 + 5, 0);
            inOrder.verify(dumper).merge(false, 0, 1, 3, 0, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000000_00110000, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000000_00100000);
            inOrder.verify(dumper).prepare(true, 1, 0, 125, 64 * 5 + 10, 1);
            inOrder.verify(dumper).merge(true, 1, 0, 5, 1, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000010_00000000, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000100_00000000);
            inOrder.verifyNoMoreInteractions();
        }
コード例 #6
0
 public override void MergeRemove(LabelScanValue existingValue, LabelScanValue newValue)
 {
     Merge(TYPE_MERGE_REMOVE, existingValue, newValue);
 }
コード例 #7
0
 public override void MergeAdd(LabelScanValue existingValue, LabelScanValue newValue)
 {
     Merge(TYPE_MERGE_ADD, existingValue, newValue);
 }