Exemple #1
0
        public BasicChunkMeta(ExtendedDataInput @in)
        {
            @in.readShort();             //skip the length of the data
            path = @in.readString();
            id   = new sbyte[16];
            @in.readFully(id);
            version      = @in.readInt();
            size_Renamed = @in.readInt();
            flag         = @in.readByte();
            sites        = new List <>();
            int copyCount = @in.readByte();

            for (int i = 0; i < copyCount; ++i)
            {
                sites.Add(@in.readString());
            }
        }
    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;
        }
    }
Exemple #4
0
        public BasicArrayVector(DATA_TYPE type, ExtendedDataInput @in) : base(DATA_FORM.DF_VECTOR)
        {
            this.type = type;
            int rows = @in.readInt();
            int cols = @in.readInt();

            rowIndices = new List <int>(new int[rows]);
            DATA_TYPE valueType = type - 64;

            valueVec             = (AbstractVector)BasicEntityFactory.instance().createVectorWithDefaultValue(valueType, cols);
            this.baseUnitLength_ = valueVec.getUnitLength();

            int rowsRead        = 0;
            int rowsReadInBlock = 0;
            int prevIndex       = 0;
            int totalBytes      = 0;

            while (rowsRead < rows)
            {
                //read block header
                int blockRows  = @in.readShort();
                int countBytes = @in.readChar();
                @in.skipBytes(1);

                //read array of count
                totalBytes      = blockRows * countBytes;
                rowsReadInBlock = 0;
                int offect = 0;
                while (offect < totalBytes)
                {
                    int len = Math.Min(BUF_SIZE, totalBytes - offect);
                    @in.readFully(buf, 0, len);
                    int curRows = len / countBytes;
                    if (countBytes == 1)
                    {
                        for (int i = 0; i < curRows; i++)
                        {
                            int curRowCells = buf[i];
                            rowIndices[rowsRead + rowsReadInBlock + i] = prevIndex + curRowCells;
                            prevIndex += curRowCells;
                        }
                    }
                    else if (countBytes == 2)
                    {
                        for (int i = 0; i < curRows; ++i)
                        {
                            int curRowCells = BitConverter.ToInt16(buf, i * 2);
                            rowIndices[rowsRead + rowsReadInBlock + i] = prevIndex + curRowCells;
                            prevIndex += curRowCells;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < curRows; ++i)
                        {
                            int curRowCells = BitConverter.ToInt32(buf, i * 4);
                            rowIndices[rowsRead + rowsReadInBlock + i] = prevIndex + curRowCells;
                            prevIndex += curRowCells;
                        }
                    }
                    rowsReadInBlock += curRows;
                    offect          += len;
                }

                //read array of values
                int rowStart   = rowsRead == 0 ? 0 : rowIndices[rowsRead - 1];
                int valueCount = rowIndices[rowsRead + rowsReadInBlock - 1] - rowStart;
                valueVec.deserialize(rowStart, valueCount, @in);

                rowsRead += rowsReadInBlock;
            }
        }