每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,歡迎關注開源日報。交流QQ群:202790710;電報群 https://t.me/OpeningSourceOrg


今日推薦開源項目:《編輯器之神——Vim

推薦理由:儘管多年過去了,Vim 仍然是熱度不減的超級流行開源項目,號稱編輯器之神。Vim 是從 vi 發展出來的一個文本編輯器。它類似於vi但又存在區別,因為它功能強大且高度可配置,在vi的基礎上進行了很多的改進。代碼補全、編譯及錯誤跳轉等方便編程的功能特別豐富,在程序員中被廣泛使用,還可以創建和更改任何類型的文本,效率非常高。

開源項目精選: 編輯器之神——Vim

而從 vi 發展出來的 Vim 具有很多模式,這種獨特的設計容易使初學者產生混淆。

Vim 具有6中基本模式和5中派生模式

基本模式

普通模式

在普通模式中,用的編輯器命令,比如移動游標,刪除文本等等。這也是Vim 啟動後的默認模式。Vim 強大的編輯能力來自於其普通模式命令。普通模式命令往往需要一個操作符結尾。例如普通模式命令」dd」刪除當前行,但是第一個」d」的後面可以跟另外的移動命令來代替第二個」d」,比如用移動到下一行的」j」鍵就可以刪除當前行和下一行。另外還可以指定命令重複次數,」2dd」(重複」dd」兩次),和」dj」的效果是一樣的。在普通模式中,有很多方法可以進入插入模式。比較普通的方式是按」a」(append/追加)鍵或者」i」(insert/插入)鍵。

插入模式

在這個模式中,大多數按鍵都會向文本緩衝區中插入文本。大多數新用戶希望文本編輯器編輯過程中一直保持這個模式。在插入模式中,可以按ESC 鍵回到普通模式。

可視模式

這個模式與普通模式比較相似。但是移動命令會擴大高亮的文本區域。高亮區域可以是字元、行或者是一塊文本。當執行一個非移動命令時,命令會被執行到這塊高亮的區域上。Vim 的」文本對象」也能和移動命令一樣用在這個模式中。

選擇模式

這個模式和無模式編輯器的行為比較相似。這個模式中,可以用滑鼠或者游標鍵高亮選擇文本,不過輸入任何字元的話,Vim 會用這個字元替換選擇的高亮文本塊,並且自動進入插入模式。

命令行模式

在命令行模式中可以輸入會被解釋成並執行的文本。例如執行命令(」:」鍵),搜索(」/」和」?」鍵)或者過濾命令(」!」鍵)。在命令執行之後,Vim 返回到命令行模式之前的模式,通常是普通模式。

Ex模式

這和命令行模式比較相似,在使用」:visual」命令離開 Ex 模式前,可以一次執行多條命令。

派生模式

操作符等待模式

這個派生模式指普通模式中,執行一個操作命令後 Vim 等待一個」動作」來完成這個命令。Vim 也支持在操作符等待模式中使用」文本對象」作為動作,包括」aw」一個單詞(a word)、」as」一個句子(a sentence)、」ap」一個段落(a paragraph)等等。比如,在普通模式下」d2as」刪除當前和下一個句子。在可視模式下」apU」把當前段落所有字母大寫。

插入普通模式

這個模式是在插入模式下按下 ctrl+o 鍵的時候進入。這個時候暫時進入普通模式,執行完一個命令之後,Vim 返回插入模式

插入可視模式

這個模式是在插入模式下按下 ctrl+o 鍵並且開始一個可視選擇的時候開始。在可視區域選擇取消的時候,Vim 返回插入模式。

插入選擇模式

通常這個模式由插入模式下滑鼠拖拽或者 shift 方向鍵來進入。當選擇區域取消的時候,Vim返回插入模式。

替換模式

這是一個特殊的插入模式,在這個模式中可以做和插入模式一樣的操作,但是每個輸入的字元都會覆蓋文本緩衝中已經存在的字元。在普通模式下按」R」鍵進入。

其他

Evim (Easy Vim)

Evim(Easy Vim)是一個特殊的GUI模式用來盡量的表現的和」無模式」編輯器一樣。編輯器自動進入並且停留在插入模式,用戶只能通過菜單、滑鼠和鍵盤控制鍵來對文本進行操作。可以在命令行下輸入」evim」或者」vim -y」進入。在 Windows 下,通常也可以點擊桌面上 Evim(Easy Vim)的圖標。

Vim 的正確學習方式

在正式接觸到 Vim 之前,你一定從別人那裡聽說過 Vim 是多麼多麼的強無敵,雖然它的命令的確非常方便,但是要正確的入門卻不是一件容易的事。一不小心就會弄成《Vim——從入門到放棄》。

 

要學習這個工具,首先得明白以下幾點:

1,學習Vim在開始是痛苦的

2,不要希望你3天就能精通,實際上你可能需要2周甚至更久。

3,需要不斷的練習。

學習順序:

1,在 Insert/Normal 模式下編輯文檔(五個命令:i,x,:wq,dd,p)

2,學習更多的命令(插入模式,移動游標,拷貝/粘貼,Undo/Redo,打開/保存/退出/改變文件)

3,學習技巧型命令(如何更好,更快,更強)

4,學習超能力(超能力級功能)

Vim的常用命令

Vim中的命令數不勝數,它可以讓你只需要看你的鍵盤就可以完成所有的事情,但是其中並不是所有的命令都那麼常用,這裡就列舉那些最有用的命令。

這些命令也可以分為以下四級

1,在 Insert/Normal 模式下編輯文檔(五個命令:i,x,:wq,dd,p)

2,學習更多的命令(插入模式,移動游標,拷貝/粘貼,Undo/Redo,打開/保存/退出/改變文件)

3,學習技巧型命令(如何更好,更快,更強)

4,學習超能力(殺手級功能)

在 Insert/Normal 模式下編輯文檔

打開vim之後默認是Normal模式。Normal模式下你可以操作你的游標,接下來是Normal模式中的一些簡單命令,在Normal模式下,幾乎所有的鍵都是功能鍵。

 

i —— 插入模式,這個模式讓你你可以像記事本一樣的輸入文本,如果已經輸入完了,按ESC返回Normal模式。

x —— 刪除當前游標所在處的字元

:w —— 存檔

:q —— 退出,你可以使用 :wq來同時進行這兩個操作

dd —— 剪切當前行

p —— 粘貼

hjkl —— 效果等同於←↓↑→,用於移動游標

:help<command> —— 顯示相關命令的幫助

學習更多的命令

除了i之外,還有別的插入模式可以選擇

a —— 在游標後插入

o —— 在當前行後插入新行

O —— 在當前行前插入新行

一些快速移動游標的指令

0 —— 數字零,到行頭

^ —— 到本行第一個不是空字元的位置

$ —— 到行尾

g_ —— 到行尾最後一個不是空字元的位置

/pa —— 搜索 pa 這個字元串,按n查找下一個

關於文件的指令

:e <path/to/file> —— 打開一個文件

:saveas <path/to/file> —— 另存為

:q! —— 不保存退出 :qa!可以退出所有編輯中的文件

:bn :bp ——當你打開了很多文件,用這個切換到下一個/上一個

其他的指令

u —— 撤銷

ctrl+r —— 重做

學習技巧型命令

Vim重複自己的方法

. —— 小數點,重複上次命令

N<command> —— 重複一個命令N次

 

下面是一個特殊的例子

100imeow[ESC] —— 寫下100個「meow」

. —— 重複上一個命令 也就是再寫100個「meow」

3. —— 重複3次命令 寫下3個(而不是300個)「meow」

進階級移動游標的命令

NG —— 移動到第N行 ,:N也可以

gg —— 到第一行

g —— 到最後一行

w —— 到下一個單詞開頭

e —— 到下一個單詞結尾

% —— 當游標在括弧上時,可以移動到與之對應的另一個括弧

*和# —— 移動到下一個/上一個游標所在的單詞上

 

實際上這些命令都可以組合輸入,格式為:<start position><command><end position> 舉個簡單的例子

0y$ —— 0和 $ 是位置,y是指令,這個指令的意思就是從行頭拷貝到本行最後一個字元。

 

除了 y,還有不少命令可以這麼做,比如

d  —— 刪除

gU/gu —— 變為大寫/小寫

v ——可視化選擇

學習超能力

更高級的移動游標

Fa/fa —— 移動到上一個/下一個a字元,a可以換成其他字元

T,/t, —— 移動到逗號後/前的那一個字元,逗號可以換成其他字元

3fa ——到第三個a字元處

dt」 —— 在遇到」前刪除所有內容

區域選擇

區域選擇的命令格式一般為<action>a<object> 和 <action>i<object>

用一個簡單的例子來區別a和i

假如說有這樣一個字元串——[123((abcd))],你的游標在b上

vi)——會選擇abcd

va)——會選擇(abcd)

v2i)——會選擇(abcd)

v2a)——會選擇((abcd))

自動補齊

在 insert 模式下輸入一個詞的開頭,然後按ctrl+p或+n,就可以使用自動補齊了

qa——開始錄製宏,並把你的操作記錄在a

@a—— replay你在a錄製的宏

@@—— replay最新的宏


今日推薦英文原文:《Why MariaDB Scores Over MySQL》作者:

原文鏈接:https://opensourceforu.com/2018/04/why-mariadb-scores-over-mysql/

推薦理由:自從 MySQL 落入 Oracle 之手之後,江湖上就掀起了血雨腥風;Oracle 有著強大的法律部門,但是在對待開源上喲組合不太良好的歷史,所以很多開源社區的用戶和支持者都不太信任 Oracle,後來就有了 MariaDB,處於對開源精神的堅持,很多用戶轉而使用 MariaDB,事實上除了更符合開源精神,MariaDB 也從性能上超越了 MySQL,這篇文章就是告訴你這件事情的。

Why MariaDB Scores Over MySQL

This article gives readers an insight into MariaDB as well as MySQL. Both are analysed and the differences between them are discussed. There is also a section on why MySQL users should switch to MariaDB.

Today, organisations have a range of database options to choose from—whether commercial or open source. There was a time when most database management systems (DBMSs) were commercial. But now, with a number of open source databases available, industry professionals prefer to use them. In fact, open source databases have gained a significant share of the market today, because users have the freedom to implement these systems as per requirements and get the best out of them.

Open source database systems are available from various vendors like Oracle, Microsoft, Google, Amazon and Rackspace. The history of open source DBMSs is not very old. The first operational open source DBMS was MySQL, which was launched in 1995 and till date, lots of significant improvements have been incorporated in it, which has made it a strong competitor even to commercial database software.

Open source DBMSs are gaining popularity not only because they are feature-rich and low cost, but also due to their operational efficiency. The freedom users enjoy in customising the source code as per individual needs, and with little programming knowledge, is a plus point. Gartner reports that open source DBMSs are growing by 42 per cent each year, and this industry will be worth US$ 8 billion by 2020. About 80 per cent of the users polled for the report use some sort of open source software, including DBMSs. Various commercial vendors like Microsoft and IBM are also offering 『Express Editions』 of their DBMS software.

The most widely adopted open source DBMSs are MySQL and MariaDB. This article discusses their similarities, differences and relative merits, before going on to suggest why users ought to migrate to MariaDB.

Databases

Databases are specific structures that hold data in the form of tables. The software that enables the flow of data through a table-based structure is called a DBMS. The most widely used DBMS is a relational database management system (RDBMS). A DBMS is a computer software application that interacts with end users, other applications and the database itself to capture data. A general-purpose DBMS allows definition, creation, querying, updation and the administration of databases.

The functions of a database and its data are:

Data definition: Creation, modification and removal of definitions that lay the foundation for data organisation

Data updation: Insertion, modification and deletion of data

Retrieval: Retrieval of data from the entire database by making specific queries

Administration: User creation and modification, data security, performance monitoring, data integrity, concurrency control and data recovery

So, a database system is a combination of a database model, a DBMS and a database.

MySQL

MySQL is an open source, multi-threaded, relational database management system (RDBMS) written in C and C++. MySQL was created by a Swedish company, MySQL AB, founded by David Axmark, Allan Larsson and Micheal 『Monty』 Widenius, and development started in 1994. The first version was launched on May 23, 1995. MySQL is named after co-founder Monty Widenius』s daughter, My. The name of the MySQL dolphin logo, Sakila, was chosen from a huge list of names suggested by users in a 『Name the Dolphin』 contest.

MySQL server is suitable for mission-critical, heavy-load production systems as well as for embedding into mass deployed software. It is regarded as a central component of the LAMP stack (Linux, Apache, MySQL and PHP). The MySQL database is available for various operating system platforms like Linux, Windows, MAC, BSD UNIX, etc. Popular websites like Wikipedia, Facebook and YouTube use MySQL.

MySQL is now a trademark owned by Oracle Corporation and/or its affiliates, and is dual licensed. Users can choose to use the software as open source under the GNU licence and even purchase a commercial

licence from Oracle.

MySQL architecture

The MySQL server is based on a tiered architecture and consists of both primary sub-systems and support components that interact with each other to read, parse and execute queries to return the results.

The five types of primary sub-systems of MySQL are:

  • Query engine
  • Storage manager
  • Buffer manager
  • Transaction manager
  • Recovery manager

Query engine: This contains three main interrelated components—the syntax parser, the query optimiser and the execution component. The syntax parser decomposes the SQL commands it receives from calling programs in a form that is understood by the MySQL engine. The 『query optimiser』 streamlines the syntax for use by the execution component and then prepares the most efficient plan for query execution. The execution component interprets the execution plan, based on the information it receives and makes requests to other components to retrieve the records.

The storage manager: This interfaces with the operating system to write data to the disk in the form of user tables, indices and logs as well as internal system data.

The query cache: The MySQL engine uses an extremely efficient result set caching mechanism called query cache, which dramatically enhances the response time for queries that are called upon to retrieve the same data as the previous query.

The buffer manager: This handles all memory management issues between requests for data by the query engine and the storage manager. MySQL makes use of memory to cache result sets that can be returned, and the cache is maintained in the buffer manager.

The transaction manager: This sub-system provides a locking facility to ensure that multiple users access the data in a consistent manner without corrupting or damaging the data.

The recovery manager: This keeps copies of data for the purpose of retrieval in case of any sort of data loss.

The two support components of MySQL are:

  • Process manager
  • Function libraries

Process manager: This performs two main functions —managing user connections via modules for network connection management, and synchronisation of tasks and processes via modules for multi-threading, thread locking and performing thread-safe operations.

Function libraries: This contains general-purpose routines like string manipulation, sorting operations and performing OS-specific functions like memory management and file I/O.

Features of MySQL

  • Relational database management system: MySQL supports all features, which makes it a complete RDBMS system. It supports full SQL as a standardised language for querying and updating data, and to administer the database.
  • Easy and secure: MySQL is very simple and interactive to use, compared to other DBMS software, and is also highly secure with a solid data security layer providing efficient encryption to data.
  • Client/server architecture: Its simple client/server architecture helps end users to create a server with connectivity to many clients, in order to communicate with the server for inserting, updating and administrating the database.
  • Scalable: MySQL can handle high volumes of data without any hiccups—as much as 50 million rows. It can handle up to 8TB of data without any issues.
  • Cross-platform: It is compatible with almost every operating system, like UNIX, Windows, Linux, MAC OS X, etc.
  • High-performance, flexible and good productivity: MySQL provides faster, highly reliable, cheap storage solutions and supports a large number of embedded applications. It makes use of triggers, procedures and views to deliver better productivity.

MariaDB

MariaDB is a forked version of MySQL. It was primarily developed due to concerns that arose when MySQL was acquired by Oracle Inc. MariaDB is a general-purpose DBMS engineered with extensible architecture to support a broad set of use cases via pluggable storage engines. It uses different storage engines to support different use cases.

MariaDB is an open source, multi-threaded, relational database management system, released under the GNU Public License (GPL). Its lead developer is Michael Monty Widenius, who is also one of the founders of MySQL AB. Many features contribute to MariaDB』s popularity as a database system. Its speed is one of its most prominent features. MariaDB is also remarkably scalable, and is able to handle tens of thousands of tables and billions of rows of data. It can also manage small amounts of data quickly and smoothly, making it convenient for small businesses or personal projects. Another feature that sets it apart from its predecessors is a focus on security. MariaDB』s built-in functions include those for manipulating and formatting text, business and statistical calculations, recording chronological information, as well as speciality features such as those related to GPS mapping.

MariaDB Server is one of the most popular open source databases in the world. It is available in Debian and Ubuntu, and is now the default database on Arch Linux, Manjaro, openSUSE, Red Hat Enterprise Linux, CentOS, Fedora and SUSE Linux Enterprise. And as one of the most broadly adopted and widely deployed in the world, MariaDB Server receives contributions from companies like Alibaba, Facebook and Google. Recently, Microsoft has also joined hands to support the MariaDB community.

Features of MariaDB

  • MariaDB is available for use under GPL, LGPL and BSD.
  • It includes a wide selection of storage engines, including high-performance storage engines, for working with other RDBMS data sources.
  • It uses a standard and popular querying language.
  • MariaDB runs on a number of operating systems and supports a wide variety of programming languages.
  • It offers support for PHP, one of the most popular Web development languages.
  • It offers Galera cluster technology.
  • MariaDB also offers many operations and commands unavailable in MySQL, and eliminates/replaces features that impact performance negatively.

Other features include multi-source replication, fusion IO optimisations, table discovery and online alter table.

A comparative analysis of MariaDB and MySQL

MariaDB has a significantly high number of new features, which makes it better in terms of performance and user-orientation. Let』s evaluate both MariaDB and MySQL to determine which one is the better. The choice will ultimately depend on the IT managers and their familiarity with open source databases.

Some significant differences between MySQL and MariaDB

1. Usage of the database: Since 1995, MySQL has been regarded as the most implemented and widely used open source database till date. Many IT giants like Twitter, YouTube, Netflix and PayPal, as well as NASA, the US defence forces and Walmart, make use of this database.

MariaDB, being a more recent arrival, is also taking strong root as back-end software in various IT giant organisations, such as Google, Red Hat, CentOS and Fedora.

2. Structure of the database and the index: MySQL is a pure relational database integrated with an ANSI-standard information schema, and consists of tables, columns, views, procedures, triggers, cursors, etc. The SQL of MySQL is a subset of ANSI SQL 99.

MariaDB, on the other hand, is a fork of MySQL and, hence, has the same database structure and index. This facility makes MariaDB a strong choice for users who want to switch or upgrade their back-end directly without any issues of upgrading the database and data structures.

Everything—from the data, table definitions, structures and APIs—remains identical when upgrading from MySQL to MariaDB.

3. Binaries and implementation: MySQL was developed using C and C++ and is fully compatible to run with almost every operating system like Microsoft Windows, MAC OS X, Linux, FreeBSD, UNIX, NetBSD, Novell Netware and many others.

MariaDB was developed using C, C++, Bash and Perl. It is compatible with various operating systems like Microsoft Windows, Linux, MAC OS X, FreeBSD, Solaris, etc.

4. Replication and clustering: MySQL provides strong replication and clustering through master-master and master-slave replication, and makes use of the Galera Cluster for multi-master clustering.

MariaDB provides almost the same replication and clustering facilities to end users as MySQL in terms of master-master and master-slave replication. It also uses Galera Cluster from version 10.1 onwards.

5. Support for databases: MySQL technical support services are provided round-the-clock via Oracle, and the support team consists of professional developers and engineers who provide various facilities like bug fixes, patches and version releases. Oracle offers MySQL premier support, extended support and sustaining support, depending on what users need.

MariaDB provides strong support to users through the open source community, online forums and even via experts. Round-the-clock support is available for MariaDB via enterprise subscription especially for mission-critical production systems.

6. Security: In terms of security, MySQL provides a strong encryption mechanism for tablespace data. It provides strong security parameters in terms of choosing good passwords, not granting unnecessary privileges to users, and ensures application security by preventing SQL injections and data corruption.

MariaDB has had a significant boost in terms of security features like internal security and password check, PAM and LDAP authentication, Kerberos, user roles, and strong encryption over tablespaces, tables and logs.

7. Extensibility: A database supporting an extensible system can be extended by the user in many different ways like adding new data types, functions, operators, aggregate functions, index methods and procedural languages. MySQL has no support for extensibility.

MariaDB is built on a modern architecture that is extensible at every layer—client, cluster, kernel and storage. This extensibility provides two major advantages. It allows for continual community innovation via plugins, which means that a variety of storage engines, like MariaDB ColumnStore or Facebook』s MyRocks, can be integrated through MariaDB』s extensible architecture. Additionally, it makes it easy for customers to configure MariaDB to support a wide variety of use cases, ranging from OLTP to OLAP.

8. JSON support: MySQL supports a native JSON data type that enables efficient access to data in JSON (JavaScript Object Notation) documents. The JSON data type provides the following advantages over storing JSON-format strings in a string column:

  • Automatic validation of JSON documents stored in JSON columns. Invalid documents produce an error.
  • Optimised storage format: JSON documents stored in JSON columns are converted to an internal format that permits quick read access to document elements. When the server later has to read a JSON value stored in this binary format, the value need not be parsed from a text representation. The binary format is structured to enable the server to look up sub-objects or nested values directly by key or array index without reading all values before or after them in the document.

On the other hand, MariaDB Server 10.2 introduces a comprehensive set of 24 functions for reading and writing of JSON documents. In addition, the JSON_VALID function can be used with a check constraint for validation, while functions like JSON_VALUE can be used with dynamic columns to index specific fields.

9. Licensing: MySQL offers its code as open source under the GPL, and provides the option of non-GPL commercial distribution in the form of MySQL Enterprise.

MariaDB can only use the GPL, because its work is derived from the MySQL source code under the terms of that licence.

10. Performance: MariaDB achieves best-in-class performance with numerous innovations that are absent for MySQL. These include thread pool management to maximise processing efficiency and extensive optimisation features such as defragmentation within the InnoDB data store. So, when rows are deleted from an InnoDB table, the free space immediately becomes available to the operating system. There』s no need to copy data from old tables to new ones, and there are no gaps in the tablespace. MariaDB also offers engine-independent table statistics to improve the optimiser』s performance, speeding up query processing and data analysis on the size and structure of the tables.

Without these enhancements, MySQL falls short in terms of performance. Thread utilisation in MySQL is sub-optimal and InnoDB tables become fragmented over time, compromising performance.

MariaDB vs MySQL

The following points highlight the pros and cons of MariaDB.

Pros

  • MariaDB has been optimised for performance and is much more powerful than MySQL for large data sets. Elegant migration from other database systems to MariaDB is yet another benefit.
  • Switching from MySQL to MariaDB is relatively easy and is a piece of cake for systems administrators.
  • MariaDB provides better monitoring through the introduction of micro-second precision and extended user statistics.
  • MariaDB enhances the KILL command to allow you to kill all queries from a user (KILL USER username) or to kill a query ID (KILL QUERY ID query_id). MariaDB has also switched to Perl-compatible regular expressions (PCRE), which offer more powerful and precise queries than standard MySQL regex support.
  • MariaDB has applied a number of query optimisations for queries connected with disk access, join operations, sub-queries, derived tables and views, execution control, and even explain statements.
  • MariaDB is purely open source, instead of the dual-licensing model that MySQL uses. Some plugins that are available only for MySQL Enterprise customers have equivalent open source implementations in MariaDB.
  • MariaDB supports significantly more engines (SphinxSE, Aria, FederatedX, TokuDB, Spider, ScaleDB, etc) compared to MySQL.
  • MariaDB offers a cluster database for commercial use, which also enables multi-master replication. Anyone can use it freely and reliance on a MySQL Enterprise system is not required.

Cons

  • Migration of MariaDB back to MySQL has not been possible since release 5.5.36.
  • For new releases of MariaDB, the appropriate libraries (for Debian) will not be deployed in time, which will result in a required upgrade to a newer version due to dependencies.
  • Cluster version of MariaDB is not very stable.

Top reasons to migrate to MariaDB

  • First and foremost, MariaDB offers more and better storage engines. NoSQL support, provided by Cassandra, allows you to run SQL and NoSQL in a single database system. MariaDB also supports TokuDB, which can handle Big Data for large organisations and corporate users.
  • MySQL』s usual (and slow) database engines MyISAM and InnoDB have been replaced in MariaDB by Aria and XtraDB respectively. Aria offers better caching, which makes a difference when it comes to disk-intensive operations.
  • MariaDB provides better monitoring through the introduction of micro-second precision and extended user statistics.
  • The cutting-edge features of MariaDB like GIS, dynamic column support, etc, make it a better choice.
  • MariaDB follows good industry standards by releasing security announcements and upgrades at the same time, and handling the pre-release secrecy and post-release transparency in a proper way.

每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,歡迎關注開源日報。交流QQ群:202790710;電報群 https://t.me/OpeningSourceOrg