internal BasicInt128Vector(DATA_FORM df, int size) : base(df) { values = new Long2[size]; for (int i = 0; i < size; ++i) { values[i] = new Long2(0, 0); } }
internal BasicInt128Vector(DATA_FORM df, int size) : base(df) { values = new List <Long2>(); values.AddRange(new Long2[size]); for (int i = 0; i < size; ++i) { values[i] = new Long2(0, 0); } }
public override void serialize(int start, int count, ExtendedDataOutput @out) { Long2[] buffer = new Long2[count]; for (int i = 0; i < count; ++i) { buffer[i] = values[i + start]; } @out.writeLong2Array(buffer); }
protected Long2[] getSubArray(int[] indices) { int length = indices.Length; Long2[] sub = new Long2[length]; for (int i = 0; i < length; ++i) { sub[i] = values[indices[i]]; } return(sub); }
public override IVector getSubVector(int[] indices) { int length = indices.Length; Long2[] sub = new Long2[length]; for (int i = 0; i < length; ++i) { sub[i] = values[indices[i]]; } return(new BasicInt128Vector(sub)); }
public override void set(int index, IScalar value) { if (value.getDataType() == DATA_TYPE.DT_UUID) { Long2 t = ((BasicInt128)value).getLong2(); setInt128(index, t.high, t.low); } else { throw new Exception("The value must be a uuid scalar. "); } }
public static String getString(Long2 value) { if (value.high == 0 && (value.low >> 32) == 0) { //ip4 long ip4 = value.low; return(String.Format("{0}.{1}.{2}.{3}", ip4 >> 24, (ip4 >> 16) & 0xff, (ip4 >> 8) & 0xff, ip4 & 0xff)); } else { //ip6 StringBuilder sb = new StringBuilder(); bool consecutiveZeros = false; int[] data = new int[8]; data[0] = (int)(value.high >> 48); data[1] = (int)((value.high >> 32) & 0xffff); data[2] = (int)((value.high >> 16) & 0xffff); data[3] = (int)(value.high & 0xffff); data[4] = (int)(value.low >> 48); data[5] = (int)((value.low >> 32) & 0xffff); data[6] = (int)((value.low >> 16) & 0xffff); data[7] = (int)(value.low & 0xffff); for (int i = 0; i < 8; ++i) { if (i > 0 && i < 6 && !consecutiveZeros && data[i] == 0 && data[i + 1] == 0) { //consecutive zeros consecutiveZeros = true; ++i; while (i < 6 && data[i + 1] == 0) { ++i; } } else { //swap two bytes sb.Append(String.Format("{0}x", (short)data[i])); } sb.Append(':'); } return(sb.ToString().Substring(0, sb.Length - 1)); } }
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; } }
public BasicInt128(long high, long low) { value = new Long2(high, low); }
public BasicInt128(ExtendedDataInput @in) { value = @in.readLong2(); }