internal BasicInt128Vector(DATA_FORM df, ExtendedDataInput @in) : base(df) { int rows = @in.readInt(); int cols = @in.readInt(); int size = rows * cols; values = new List <Long2>(); values.AddRange(new Long2[size]); int totalBytes = size * 16, off = 0; bool littleEndian = @in.isLittleEndian(); while (off < totalBytes) { int len = System.Math.Min(BUF_SIZE, totalBytes - off); @in.readFully(buf, 0, len); int start = off / 16, end = len / 16; Byte[] dst = new Byte[len]; Buffer.BlockCopy(buf, 0, dst, 0, len); if (!littleEndian) { Array.Reverse(dst); } if (littleEndian) { for (int i = 0; i < end; i++) { long low = BitConverter.ToInt64(dst, i * 16); long high = BitConverter.ToInt64(dst, i * 16 + 8); values[i + start] = new Long2(high, low); } } else { for (int i = 0; i < end; i++) { long high = BitConverter.ToInt64(dst, i * 16); long low = BitConverter.ToInt64(dst, i * 16 + 8); values[i + start] = new Long2(high, low); } } off += len; } }
public override void deserialize(int start, int count, ExtendedDataInput @in) { if (start + count > values.Count) { values.AddRange(new Long2[start + count - values.Count]); } int totalBytes = count * 16, off = 0; bool littleEndian = @in.isLittleEndian(); while (off < totalBytes) { int len = System.Math.Min(BUF_SIZE, totalBytes - off); @in.readFully(buf, 0, len); int subStart = off / 16, end = len / 16; Byte[] dst = new Byte[len]; Buffer.BlockCopy(buf, 0, dst, 0, len); if (!littleEndian) { Array.Reverse(dst); } if (littleEndian) { for (int i = 0; i < end; i++) { long low = BitConverter.ToInt64(dst, i * 16); long high = BitConverter.ToInt64(dst, i * 16 + 8); values[i + subStart + start] = new Long2(high, low); } } else { for (int i = 0; i < end; i++) { long high = BitConverter.ToInt64(dst, i * 16); long low = BitConverter.ToInt64(dst, i * 16 + 8); values[i + subStart + start] = new Long2(high, low); } } off += len; } }