Esempio n. 1
0
        public bool OnGetEnumerator(EntriesInput input, EntriesOutput output)
        {
            int count = input.entries.Count;
            if (i >= count)
            {
                i = 0;
                return false; // At end; stop.
            }
            List<byte[]> net = input.net;
            List<Entry> entries = input.entries;
            int KeyLength = input.KeyLength;

            Entry entry = input.entries[i++];

            byte[] keybuf = net[entry.NetIndex];
            int keyoffset = entry.NetEntryOffset;
            int keylength = KeyLength; // Direct from input.

            byte[] valuebuf = net[entry.NetIndex];
            int valueoffset = entry.NetEntryOffset + KeyLength + 4; // Internal storage layout.
            int valuelength = Entry.BytesToInt(valuebuf, entry.NetEntryOffset + KeyLength); // Internal storage layout.

            output.Add(keybuf, keyoffset, keylength, valuebuf, valueoffset, valuelength);
            return true; // Continue.
        }
Esempio n. 2
0
 public void AppendKey(EntriesInput input, List<byte> list)
 {
     byte[] netbuf = input.net[NetIndex];
     for (int i = 0; i != input.KeyLength; i++)
     {
         list.Add(netbuf[NetEntryOffset + i]);
     }
 }
Esempio n. 3
0
        public int NetEntryOffset; // Where in the net's buffer is this entry.


        // Copies this key into buffer starting at bufferoffset.
        public void CopyKey(EntriesInput input, byte[] buffer, int bufferoffset)
        {
            byte[] netbuf = input.net[NetIndex];
            for (int i = 0; i != input.KeyLength; i++)
            {
                buffer[bufferoffset + i] = netbuf[NetEntryOffset + i];
            }
        }
Esempio n. 4
0
 // Copies this value into buffer starting at bufferoffset.
 public void CopyValue(EntriesInput input, byte[] buffer, int bufferoffset)
 {
     byte[] netbuf = input.net[NetIndex];
     //int valuelen = GetValueLength(input);
     int valuelen = Entry.BytesToInt(netbuf, NetEntryOffset + input.KeyLength);
     for (int i = 0; i != valuelen; i++)
     {
         buffer[bufferoffset + i] = netbuf[NetEntryOffset + input.KeyLength + 4 + i];
     }
 }
Esempio n. 5
0
 public bool OnGetEnumerator(EntriesInput input, EntriesOutput output)
 {
     if (null == raout)
     {
         raout = new RandomAccessOutput(output);
     }
     if (null == raentries)
     {
         raentries = new RandomAccessEntries();
     }
     raentries.SetInput(input);
     byte[] firstkeybuf, xkeybuf;
     int firstkeyoffset, xkeyoffset;
     int firstkeylen, xkeylen;
     for (; i < input.entries.Count; )
     {
         input.entries[i].LocateKey(input, out firstkeybuf, out firstkeyoffset, out firstkeylen);
         int len = 1;
         for (int j = i + 1; j < input.entries.Count; j++)
         {
             bool nomatch = false;
             input.entries[j].LocateKey(input, out xkeybuf, out xkeyoffset, out xkeylen);
             if (firstkeylen != xkeylen)
             {
                 break;
             }
             for (int ki = 0; ki != xkeylen; ki++)
             {
                 if (xkeybuf[xkeyoffset + ki] != firstkeybuf[firstkeyoffset + ki])
                 {
                     nomatch = true;
                     break;
                 }
             }
             if (nomatch)
             {
                 break;
             }
             len++;
         }
         raentries.set(i, len);
         Reduce(raentries[0].Key, raentries, raout);
         i += len;
         return true; // Continue.
     }
     i = 0;
     return false; // At end; stop.
 }
Esempio n. 6
0
        public bool OnGetEnumerator(EntriesInput input, EntriesOutput output)
        {
            int count = input.entries.Count;
            if (i >= count)
            {
                i = 0;
                return false; // At end; stop.
            }

            Entry entry = input.entries[i++];

            byte[] keybuf;
            int keyoffset;
            int keylength;
            entry.LocateKey(input, out keybuf, out keyoffset, out keylength);

            byte[] valuebuf;
            int valueoffset;
            int valuelength;
            entry.LocateValue(input, out valuebuf, out valueoffset, out valuelength);

            output.Add(keybuf, keyoffset, keylength, valuebuf, valueoffset, valuelength);
            return true; // Continue.
        }
Esempio n. 7
0
 public void AppendValue(EntriesInput input, List<byte> list)
 {
     int valuelen = GetValueLength(input);
     byte[] netbuf = input.net[NetIndex];
     for (int i = 0; i != valuelen; i++)
     {
         list.Add(netbuf[NetEntryOffset + input.KeyLength + 4 + i]);
     }
 }
Esempio n. 8
0
 public void CopyValue(EntriesInput input, byte[] buffer)
 {
     CopyValue(input, buffer, 0);
 }
Esempio n. 9
0
 // Get the value length for this entry.
 public int GetValueLength(EntriesInput input)
 {
     byte[] netbuf = input.net[NetIndex];
     return Entry.BytesToInt(netbuf, NetEntryOffset + input.KeyLength);
 }
Esempio n. 10
0
 public void LocateKey(EntriesInput input, out byte[] netbuf, out int offset, out int length)
 {
     netbuf = input.net[NetIndex];
     offset = NetEntryOffset;
     length = input.KeyLength;
 }
Esempio n. 11
0
 public void CopyKey(EntriesInput input, byte[] buffer)
 {
     CopyKey(input, buffer, 0);
 }
Esempio n. 12
0
 public static ReduceEntry Create(EntriesInput inp, Entry ent)
 {
     ReduceEntry result;
     result.inp = inp;
     result.ent = ent;
     return result;
 }
Esempio n. 13
0
        /*private ReduceInput()
        {
        }*/

        public static ReduceInput Start(EntriesInput einput)
        {
            ReduceInput result;
            result.einput = einput;
            result.eindex = -1; // Start one before.
            result.estartindex = 0;
            return result;
        }
Esempio n. 14
0
 public void LocateValue(EntriesInput input, out byte[] netbuf, out int offset, out int length)
 {
     netbuf = input.net[NetIndex];
     offset = NetEntryOffset + input.KeyLength + 4;
     length = GetValueLength(input);
 }
 internal EntriesInput GetEntriesInput()
 {
     EntriesInput input = new EntriesInput();
     input.entries = this.entries;
     input.KeyLength = this.keylen;
     input.net = this.net;
     return input;
 }
Esempio n. 16
0
 internal void SetInput(EntriesInput input)
 {
     this.input = input;
 }