datastax/csharp-driver — pull request #28 by vytautassurvila (2014-04-28 12:06:55+00:00)
Title: fix CSHARP-120

Current pull request adds unsigned keyword for collection item's length calculation and several tests. The reasoning why follows.

When selecting larger than [signed]Int16.MaxValue collection (reproducable for map, set and list) item we get exception:
```
"Arithmetic operation resulted in an overflow."
at Cassandra.TypeInterpreter.ConvertFromList(IColumnInfo type_info, Byte[] value, Type cSharpType) in e:\git\vytautassurvila\csharp-driver\Cassandra\RowPopulators\TypeInterpreters\TypeInterpreter+List.cs:line 50
```

Sample code to reproduce
```
string b = new string('8', UInt16.MaxValue);
session.Execute(string.Format("INSERT INTO large_list_text(k,i) VALUES({0},['{1}'])", key, b), ConsistencyLevel.Quorum);

using (var rs = session.Execute("SELECT * FROM large_list_text WHERE k = " + key.ToString(), ConsistencyLevel.Quorum))
{
Row row = rs.GetRows().FirstOrDefault();
Assert.True(b.Equals(((List)row["i"])[0]));
}
```

According to "Cql binary protocol" https://git-wip-us.apache.org/repos/asf?p=cassandra.git;a=blob_plain;f=doc/native_protocol_v2.spec;hb=HEAD" list item should support "short bytes"
```
List: a [short] n indicating the size of the list, followed by n elements.
Each element is [short bytes] representing the serialized element
value.
```

"Cql binary protocol" defines types in section "3. Notations"
```
...
[short] A 2 bytes unsigned integer
...
[short bytes] A [short] n, followed by n bytes if n >= 0.
```

Note that short is unsigned, but driver used signed short what caused the arithmetic overflow exception