{"id":301850,"date":"2020-04-14T15:00:33","date_gmt":"2020-04-14T15:00:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301850"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301850","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 key-value \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Snappy \u0432 Android"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/497222\/\">SnapyDB \u2014 NoSQL key-value \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f Android. \u041e\u043d\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c NoSQL \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/tproger.ru\/translations\/sql-vs-nosql\/\" rel=\"nofollow\">\u0442\u0443\u0442<\/a>).<br \/>  \u041f\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f Snappy \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 SQLite:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/99\/r0\/lk\/99r0lkhf53wttfsury9v2r2k-9o.png\" alt=\"image\"><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c dependencies \u0432 build.gradle:<\/p>\n<p>  <code>implementation 'com.snappydb:snappydb-lib:0.5.2'<br \/>  implementation 'com.esotericsoftware.kryo:kryo:2.24.0'<\/code><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u043d\u0451\u043c, \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0441\u0430\u043c\u043e\u0439 \u0411\u0414.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a SnappyDB \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443:  <\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;RelativeLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;     xmlns:app=&quot;http:\/\/schemas.android.com\/apk\/res-auto&quot;     xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;     android:layout_width=&quot;match_parent&quot;     android:layout_height=&quot;match_parent&quot;     tools:context=&quot;.MainActivity&quot;&gt;      &lt;TextView         android:id=&quot;@+id\/filmNameTextView&quot;         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:textSize=&quot;25sp&quot;         android:layout_centerInParent=&quot;true&quot;         android:layout_margin=&quot;8dp&quot;         \/&gt;      &lt;TextView         android:id=&quot;@+id\/filmBudgetTextView&quot;         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:layout_centerInParent=&quot;true&quot;         android:textSize=&quot;25sp&quot;         android:layout_below=&quot;@+id\/filmNameTextView&quot;         android:layout_margin=&quot;8dp&quot;         \/&gt;      &lt;TextView         android:id=&quot;@+id\/genreTextView&quot;         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:layout_centerInParent=&quot;true&quot;         android:textSize=&quot;25sp&quot;         android:layout_below=&quot;@id\/filmBudgetTextView&quot;         android:layout_margin=&quot;8dp&quot;         \/&gt;      &lt;TextView         android:id=&quot;@+id\/isAdult&quot;         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:layout_below=&quot;@id\/genreTextView&quot;         android:textSize=&quot;25sp&quot;         android:layout_centerInParent=&quot;true&quot;         \/&gt; &lt;\/RelativeLayout&gt;<\/code><\/pre>\n<p>  <i>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0438\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u0439 \u0411\u0414 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0444\u0438\u043b\u044c\u043c\u0435<\/i><br \/>  \u0412 MainActivity \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 PutValues:  <\/p>\n<pre><code class=\"java\">private void putValues(String name, int budget, boolean isAdult, String[] genres) throws SnappydbException {         DB snappyDB = DBFactory.open(this,&quot;Film&quot;);         \/\/ \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0411\u0414 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c Film (\u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 open)          snappyDB.put(&quot;Name&quot;, name);         snappyDB.putInt(&quot;budget&quot;, budget);         snappyDB.putBoolean(&quot;isAdult&quot;, isAdult);         snappyDB.put(&quot;genres&quot;, genres);         \/\/\u043a\u043b\u0430\u0434\u0451\u043c \u0432 \u0411\u0414 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 }<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441\u043e SnappyDB \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SnappydbException.<br \/>  <cut><\/cut><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 setValues \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0411\u0414 \u0438 \u0438\u0445 \u0432\u044b\u0432\u043e\u0434\u0430:  <\/p>\n<pre><code class=\"java\">private void setValues(DB snappyDB) throws SnappydbException {         TextView filmNameTextView = findViewById(R.id.filmNameTextView),                  filmBudgetTextView = findViewById(R.id.filmBudgetTextView),                  genresTextView = findViewById(R.id.genreTextView),                  isAdultTextView = findViewById(R.id.isAdult); \/\/\u043f\u043e\u043b\u044f \u0438\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438          String name = snappyDB.get(&quot;Name&quot;);         int budget = snappyDB.getInt(&quot;budget&quot;);         boolean isAdult = snappyDB.getBoolean(&quot;isAdult&quot;);         String[] genres = snappyDB.getObjectArray(&quot;genres&quot;, String.class);\/\/2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 = \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430         \/\/ \u043c\u0435\u0442\u043e\u0434 get... \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445          filmNameTextView.setText(name);         filmBudgetTextView.setText(String.valueOf(budget));         isAdultTextView.setText(String.valueOf(isAdult));          for(int i = 0;i &lt; genres.length;i++) {             genresTextView.setText(genresTextView.getText() + &quot; &quot; + genres[i]);         } }<\/code><\/pre>\n<p>  <cut><\/cut><br \/>  \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 onCreate (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043a\u0440\u0443\u0436\u0438\u0432 \u0438\u0445 \u0431\u043b\u043e\u043a\u043e\u043c try\/catch):  <\/p>\n<pre><code class=\"java\">@Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          try {             putValues(&quot;Forrest Gump&quot;, 677000000,false, new String[] {&quot;Drama&quot;,&quot;Melodrama&quot;});         } catch (SnappydbException e) {             e.printStackTrace();         }                  try {             DB snappyDB = DBFactory.open(this, &quot;Film&quot;);             setValues(snappyDB);         } catch (SnappydbException e) {             e.printStackTrace();         } } <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sf\/4s\/ut\/sf4sutox8dzujhi0d-i6xg44z9y.png\" alt=\"image\"><br \/>  <cut><\/cut><br \/>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438.<br \/>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Film \u0441 3 \u043f\u043e\u043b\u044f\u043c\u0438:  <\/p>\n<pre><code class=\"java\">public class Film {     private String name;     private int budget;     private String[] genres;      public Film() {}      public Film(String name, int budget, String[] genres) {         this.name = name;         this.budget = budget;         this.genres = genres;     }      public String getName() {         return name;     }      public void setName(String name) {         this.name = name;     }      public int getBudget() {         return budget;     }      public void setBudget(int budget) {         this.budget = budget;     }      public String[] getGenres() {         return genres;     }      public void setGenres(String[] genres) {         this.genres = genres;     } } <\/code><\/pre>\n<p>  \u0423\u0431\u0435\u0440\u0451\u043c \u0432\u044b\u0437\u043e\u0432\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 setValues \u0438 putValues \u0432 onCreate. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043d\u0451\u043c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Film \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0411\u0414:  <\/p>\n<pre><code class=\"java\">Film film = new Film(&quot;Shawshank redemption&quot;,28000000, new String[] {&quot;Drama&quot;}); try {        DB snappyDB = DBFactory.open(this, &quot;NewFilmDB&quot;);        snappyDB.put(&quot;FilmObj&quot;,film); } catch (SnappydbException e) {        e.printStackTrace(); }<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 setValues:  <\/p>\n<pre><code class=\"java\">private void setValues(DB snappyDB) throws SnappydbException {         TextView filmNameTextView = findViewById(R.id.filmNameTextView),                  filmBudgetTextView = findViewById(R.id.filmBudgetTextView),                  genresTextView = findViewById(R.id.genreTextView);          Film film = snappyDB.getObject(&quot;FilmObj&quot;, Film.class);                  String name = film.getName();         int budget = film.getBudget();         String[] genres = film.getGenres();          filmNameTextView.setText(name);         filmBudgetTextView.setText(String.valueOf(budget));          for(int i = 0;i &lt; genres.length;i++) {             genresTextView.setText(genresTextView.getText() + &quot; &quot; + genres[i]);         } } <\/code><\/pre>\n<p>  \u0412\u043d\u043e\u0432\u044c \u0432\u044b\u0437\u043e\u0432\u0435\u043c setValues \u0432 onCreate:  <\/p>\n<pre><code class=\"java\">try {         DB snappyDB = DBFactory.open(this, &quot;NewFilmDB&quot;);         setValues(snappyDB); } catch (SnappydbException e) {         e.printStackTrace(); }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p8\/ki\/5y\/p8ki5yenheetsi_ci9fifkuxzz4.png\" alt=\"image\"><br \/>  <cut><\/cut><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 SnappyDB:<br \/>  1) \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0438 \u043f\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0443:  <\/p>\n<pre><code class=\"java\">Film film1 = new Film(&quot;Green mile&quot;,60000000,new String[] {&quot;Drama&quot;, &quot;Fantasy&quot;}),   film2 = new Film(&quot;Gentlemen&quot;,22000000,new String[] {&quot;Comedy&quot;, &quot;Crime&quot;}),   film3 = new Film(&quot;In Bruges&quot;,15000000,new String[] {&quot;Comedy&quot;, &quot;Crime&quot;, &quot;Thriller&quot;});          try {             DB snappyDB = DBFactory.open(this, &quot;NewFilmDB&quot;);             snappyDB.put(&quot;FilmObj: Green Mile&quot;,film1);             snappyDB.put(&quot;FilmObj: Gentlemen&quot;,film2);             snappyDB.put(&quot;FilmObj: In Bruges&quot;,film3);             String[] filmKeys = snappyDB.findKeys(&quot;FilmObj:&quot;);             \/\/\u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 filmKeys \u043a\u043b\u044e\u0447\u0438 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c &quot;FilmObj:&quot;             \/\/\u0435\u0441\u043b\u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439             for(int i = 0;i &lt; filmKeys.length;i++) {                 Log.d(&quot;film_key: &quot;,  filmKeys[i] + &quot;\\n&quot;);             }              Log.d(&quot;film_name: &quot;,  snappyDB.getObject(filmKeys[2],Film.class).getName() + &quot;\\n&quot;);             \/\/\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u044d\u043b-\u0442 \u043f\u043e \u043a\u043b\u044e\u0447\u0443, \u0432\u0437\u044f\u0442\u043e\u043c\u0443 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 filmKeys          } catch (SnappydbException e) {             e.printStackTrace();  } <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mh\/6l\/hb\/mh6lhbibwjhbckf0-wwhsitkznm.png\" alt=\"image\"><br \/>  <i>\u0412\u044b\u0432\u043e\u0434 \u0432 \u043b\u043e\u0433<\/i><br \/>  <cut><\/cut><br \/>  2) \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u0411\u0414:  <\/p>\n<pre><code class=\"java\">try {              DB snappyDB = DBFactory.open(this, &quot;NewFilmDB&quot;);              for (String[] batch : snappyDB.allKeysIterator().byBatch(1)) {                 \/\/\u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 \u043a\u043b\u044e\u0447\u0435\u0439(batch), \u0430 \u043d\u0435 \u0441 \u0441\u0430\u043c\u0438\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438                 for (String key : batch) {                     Log.d(&quot;film&quot;,snappyDB.getObject(key,Film.class).getName());                 }             }         } catch (SnappydbException e) {             e.printStackTrace(); } <\/code><\/pre>\n<p>  \u0411\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f byBatch \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e KeyIterator, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 Iterator \u0438\u043b\u0438 Iterable, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0446\u0438\u043a\u043b\u0435.<br \/>  byBatch (n) \u0441\u043e\u0437\u0434\u0430\u0435\u0442 BatchIterable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Iterable \u0438 Iterator. \u041f\u043e \u0441\u0443\u0442\u0438, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 next (n) \u0434\u043b\u044f KeyIterator, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 next () \u0434\u043b\u044f \u043d\u0435\u0433\u043e.<br \/>  \u041d\u043e byBatch \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b-\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c findKeys\/findKeysBetween.<br \/>  <cut><\/cut><br \/>  3) \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0443:  <\/p>\n<pre><code class=\"java\">snappyDB.del(&quot;FilmObj: Gentlemen&quot;);<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rz\/8p\/kk\/rz8pkk08sx528nm5_1cb1_st2pa.png\" alt=\"image\"><br \/>  <i>\u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0434\u0430\u043b\u0451\u043d<\/i><br \/>  4) \u0417\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0411\u0414:  <\/p>\n<pre><code class=\"java\">snappyDB.close(); snappyDB.destroy();<\/code><\/pre>\n<p>  5) \u0423\u0437\u043d\u0430\u0442\u044c, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u043a\u043b\u044e\u0447 \u0432 \u0411\u0414:  <\/p>\n<pre><code class=\"java\">snappyDB.put(&quot;FilmObj: Gentlemen&quot;,new Film()); boolean isExist = snappyDB.exists(&quot;FilmObj: Gentlemen&quot;);\/\/ true snappyDB.del(&quot;FilmObj: Gentlemen&quot;); isExist = snappyDB.exists(&quot;FilmObj: Gentlemen&quot;);\/\/false<\/code><\/pre>\n<p>  <cut><\/cut><\/p>\n<p>  \u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0451. \u0412\u0430\u043c \u0440\u0435\u0448\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438 \u044d\u0442\u0443 \u0411\u0414 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u041e\u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u043d\u043e \u0432\u044b\u0431\u043e\u0440 \u0437\u0430 \u0432\u0430\u043c\u0438. \u042d\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0411\u0414 \u0434\u043b\u044f Android.<\/p>\n<p>  P.S: <a href=\"https:\/\/github.com\/nhachicha\/SnappyDB\" rel=\"nofollow\">SnappyDB \u043d\u0430 GitHub (\u043e\u0444.\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0442\u0430\u043c \u0436\u0435).<\/a><br \/>  \u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u043c\u0435\u0436\u0434\u0443 SQL \u0438 NoSQL: <a href=\"https:\/\/tproger.ru\/translations\/sql-vs-nosql\/\" rel=\"nofollow\">1<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/152477\/\">2<\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/497222\/\"> https:\/\/habr.com\/ru\/post\/497222\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/497222\/\">SnapyDB \u2014 NoSQL key-value \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f Android. \u041e\u043d\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c NoSQL \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/tproger.ru\/translations\/sql-vs-nosql\/\" rel=\"nofollow\">\u0442\u0443\u0442<\/a>).<br \/>  \u041f\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f Snappy \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 SQLite:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/99\/r0\/lk\/99r0lkhf53wttfsury9v2r2k-9o.png\" alt=\"image\">  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-301850","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301850"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301850\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}