dirty 0.1.5

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 12

Dart Dirty

The dart dirty library is persistent HashMap for Dart.

Create a new database with the constructor:

var db = new Dirty('test/test.db');

Open an existing database with the same constructor:

var db = new Dirty('test/test.db');

Then use the usual HashMap methods to add records:

db['everything'] = {'answer': 42};

And to remove records:

db.remove('everything');

To ensure that everything is written to the filesystem, it is best to properly close a database:

db.close();

Performance

I have not really optimized this yet. Using readAsLines to read DB records seems less than ideal, but it actually works fairly well. Writing could probably be sped up if data was buffered more, but I focused on read for the first pass.

If you would like to improve, see the test/mk_perf_db.dart and test/perf.dart scripts. The former creates a 100,000 record DB and the latter reads it back in. On my machine the former takes ~4 minutes to write and ~10 seconds to read. Performance patches welcome!

Contributors

##License

This software is licensed under the MIT License.

Copyright Chris Strom, 2014.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.1.5

Test Changes

  • unittest package has been removed and replaced with test
  • a few new tests have also been added

Core library changes

  • OnLoadCallback typedef added, constructor onLoad parameter now has to match it
  • operator[], remove, containsKey interface overrides have been adjusted to to match declaration signature
  • addAll now adds keys to queue and attempts to flush as well, just like operator[]=
  • Initialization changes:
    • if the DB file is not present on the disk, it will be created. If that cannot be performed, an exception is raised.
  • If flushing is in progress and a new flush is invoked, Dirty will no longer fail silently, a StateError will be raised.
  • Fixed an issue: sometimes keys would not get persisted

Code cleanup

  • Doc comments have been converted from block comments to /// format
  • Minor code-style upgrades
  • strong mode enabled for library

Possible breaking changes

  • changes to addAll
  • database file will be created on Class instantiation if it is not present on path

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dirty: ^0.1.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dirty/dirty.dart';
  
Version Uploaded Documentation Archive
0.1.5 May 28, 2016 Go to the documentation of dirty 0.1.5 Download dirty 0.1.5 archive
0.1.4 Feb 10, 2014 Go to the documentation of dirty 0.1.4 Download dirty 0.1.4 archive
0.1.3 Nov 7, 2013 Go to the documentation of dirty 0.1.3 Download dirty 0.1.3 archive
0.1.2 Oct 10, 2013 Go to the documentation of dirty 0.1.2 Download dirty 0.1.2 archive
0.1.1 Aug 31, 2013 Go to the documentation of dirty 0.1.1 Download dirty 0.1.1 archive
0.1.0 Aug 28, 2013 Go to the documentation of dirty 0.1.0 Download dirty 0.1.0 archive
0.0.5 Jul 20, 2013 Go to the documentation of dirty 0.0.5 Download dirty 0.0.5 archive
0.0.4 Jun 9, 2013 Go to the documentation of dirty 0.0.4 Download dirty 0.0.4 archive
0.0.3 Mar 12, 2013 Go to the documentation of dirty 0.0.3 Download dirty 0.0.3 archive
0.0.2 Dec 14, 2012 Go to the documentation of dirty 0.0.2 Download dirty 0.0.2 archive

All 11 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
42
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
12
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, other

Primary library: package:dirty/dirty.dart with components: io.

Health issues and suggestions

Fix lib/dirty.dart. (-58.44 points)

Analysis of lib/dirty.dart failed with 3 errors, 3 hints, including:

line 15 col 7: Missing concrete implementations of 'Map.addEntries', 'Map.cast', 'Map.map', 'Map.removeWhere' and 3 more.

line 103 col 17: Undefined name 'JSON'.

line 126 col 20: Undefined name 'JSON'.

line 5 col 8: Unused import: 'dart:convert'.

line 84 col 39: 'WRITE' is deprecated and shouldn't be used.

Maintenance issues and suggestions

Package is too old. (-100 points)

The package was released more than two years ago.

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: logging.

Use analysis_options.yaml. (-10 points)

Rename old .analysis_options file to analysis_options.yaml.

Read more about the setup of analysis-options.yaml.

Add SDK constraint in pubspec.yaml. (-5 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use dirty.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
logging any 0.11.3+2
Dev dependencies
test any