private static ReadOnlySpan <byte> GetRowData(KuduMessage message, RowwiseRowBlockPB rowPb) { if (rowPb.HasRowsSidecar) { var offset = message.GetSidecarOffset(rowPb.RowsSidecar); return(message.Buffer.AsSpan(offset.Start, offset.Length)); } return(default);
private static ResultSet CreateResultSet( KuduMessage message, KuduSchema schema, ColumnarRowBlockPB data) { var columns = data.Columns; var numColumns = columns.Count; if (numColumns != schema.Columns.Count) { ThrowColumnCountMismatchException(schema.Columns.Count, numColumns); } if (data.Columns.Count == 0 || data.NumRows == 0) { // Empty projection, usually used for quick row counting. return(CreateEmptyResultSet(schema, data.NumRows)); } var numRows = checked ((int)data.NumRows); var bufferLength = message.Buffer.Length; var nonNullBitmapLength = KuduEncoder.BitsToBytes(numRows); var dataSidecarOffsets = new SidecarOffset[numColumns]; var varlenDataSidecarOffsets = new SidecarOffset[numColumns]; var nonNullBitmapSidecarOffsets = new SidecarOffset[numColumns]; for (int i = 0; i < numColumns; i++) { var column = columns[i]; var columnSchema = schema.GetColumn(i); if (column.HasDataSidecar) { var offset = message.GetSidecarOffset(column.DataSidecar); var length = GetColumnDataSize(columnSchema, numRows); ValidateSidecar(offset, length, bufferLength); dataSidecarOffsets[i] = offset; } else { ThrowMissingDataSidecarException(columnSchema); } if (column.HasVarlenDataSidecar) { var offset = message.GetSidecarOffset(column.VarlenDataSidecar); varlenDataSidecarOffsets[i] = offset; } if (column.HasNonNullBitmapSidecar) { var offset = message.GetSidecarOffset(column.NonNullBitmapSidecar); ValidateSidecar(offset, nonNullBitmapLength, bufferLength); nonNullBitmapSidecarOffsets[i] = offset; } else { nonNullBitmapSidecarOffsets[i] = new SidecarOffset(-1, 0); } } var buffer = message.TakeMemory(); return(new ResultSet( buffer, schema, data.NumRows, dataSidecarOffsets, varlenDataSidecarOffsets, nonNullBitmapSidecarOffsets)); }