https://github.com/mattevans/distil
💧 In memory dataset filtering
https://github.com/mattevans/distil
dataset dataset-filtering filtering go golang golang-library in-memory memory-dataset-filtering
Last synced: 5 months ago
JSON representation
💧 In memory dataset filtering
- Host: GitHub
- URL: https://github.com/mattevans/distil
- Owner: mattevans
- License: mit
- Created: 2016-12-08T19:42:21.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-29T09:28:57.000Z (almost 5 years ago)
- Last Synced: 2024-06-19T00:40:18.218Z (almost 2 years ago)
- Topics: dataset, dataset-filtering, filtering, go, golang, golang-library, in-memory, memory-dataset-filtering
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 49
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# distil 💧
[](https://godoc.org/github.com/mattevans/distil)
[](https://travis-ci.org/mattevans/distil)
[](https://goreportcard.com/report/github.com/mattevans/distil)
[](https://github.com/mattevans/distil/blob/master/LICENSE)
In memory dataset filtering.
Installation
-----------------
`go get -u github.com/mattevans/distil`
Example
-------------
Given a dataset...
```go
data := []map[string]interface{}{
{"location": "New York", "department": "Engineering", "salary": 120000, "start_date": "2016-01-23T12:00:00Z"},
{"location": "New York", "department": "Engineering", "salary": 80000, "start_date": "2016-03-23T12:00:00Z"},
{"location": "New York", "department": "Marketing", "salary": 90000, "start_date": "2016-01-23T12:00:00Z"},
{"location": "New York", "department": "Marketing", "salary": 150000, "start_date": "2016-01-23T12:00:00Z"},
{"location": "Chicago", "department": "Engineering", "salary": 120000, "start_date": "2016-01-23T12:00:00Z"},
{"location": "Chicago", "department": "Engineering", "salary": 160000, "start_date": "2016-03-23T12:00:00Z"},
}
```
Initialize distil, build filters and run...
```go
// Init distil dataset.
dataset := NewDataset(data...)
// Build a distil query and apply filters.
query := &Query{}
query.Filters = append(query.Filters, Filter{
Field: "location",
Value: "Chicago",
Operator: Operator{
Code: "eq",
Type: "string",
},
})
// Run it.
results, err := dataset.Run(query)
if err != nil {
errors.New("Unexpected error running query: %s", err.Error())
}
```
Returns...
```go
[]map[string]interface{}{
{"location": "Chicago", "department": "Engineering", "salary": 120000, "start_date": "2016-01-23T12:00:00Z"},
{"location": "Chicago", "department": "Engineering", "salary": 160000, "start_date": "2016-03-23T12:00:00Z"},
}
```
Find a list of available [operators here](https://github.com/mattevans/distil/blob/master/example/operators.json).
Thanks & Acknowledgements :ok_hand:
----------------
The packages's architecture is adapted from
[aggro](https://github.com/snikch/aggro), created by [Mal
Curtis](https://github.com/snikch). :beers:
Contributing
-----------------
If you've found a bug or would like to contribute, please create an issue here on GitHub, or better yet fork the project and submit a pull request!