Skip to content

Commit

Permalink
make float types int
Browse files Browse the repository at this point in the history
  • Loading branch information
tjungblu committed Apr 24, 2024
1 parent d1d8ac6 commit 1052901
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TESTFLAGS :=
LDFLAGS :=
GOFLAGS :=
BINARY := octosql-plugin-etcdsnapshot
VERSION := 0.1.3
VERSION := 0.1.4
VVERSION := "v$(VERSION)"
OCTOSQLPATH := ${HOME}/.octosql/plugins/etcdsnapshot/octosql-plugin-etcdsnapshot/${VERSION}/

Expand Down
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ $ octosql "SELECT * FROM etcd.snapshot" --describe
+-------------------+-----------------+------------+
| 'apigroup' | 'NULL | String' | false |
| 'apiserverPrefix' | 'NULL | String' | false |
| 'createRevision' | 'Float' | false |
| 'createRevision' | 'Int' | false |
| 'key' | 'String' | false |
| 'lease' | 'Float' | false |
| 'modRevision' | 'Float' | false |
| 'lease' | 'Int' | false |
| 'modRevision' | 'Int' | false |
| 'name' | 'NULL | String' | false |
| 'namespace' | 'NULL | String' | false |
| 'resourceType' | 'NULL | String' | false |
| 'value' | 'String' | false |
| 'valueSize' | 'Int' | false |
| 'version' | 'Int' | false |
| 'version' | 'Int' | false |
+-------------------+-----------------+------------+
```

Expand All @@ -62,8 +62,8 @@ $ octosql "SELECT * FROM etcd.snapshot" --describe
* `name` is the resource name
* `value` is the value as a string (usually JSON in K8s/CRDs)
* `valueSize` is the amount of bytes needed to store the value
* `createRevision` is the revision of last creation on this key (note it is of type float to fit an 64 bit integer)
* `modRevision` is the revision of last modification on this key (note it is of type float to fit an 64 bit integer)
* `createRevision` is the revision of last creation on this key
* `modRevision` is the revision of last modification on this key
* `version` is the version of the key, a deletion resets it to zero and a modification increments its value
* `lease` contains the lease id, if a lease is attached to that key, a value of zero means no lease

Expand Down Expand Up @@ -187,17 +187,14 @@ Note that "key" seems to be a reserved keyword, so when querying the key you wil
### Get the latest create revision

```sql
$ octosql "SELECT MAX(INT(createRevision)) FROM etcd.snapshot"
$ octosql "SELECT MAX(createRevision) FROM etcd.snapshot"
+-----------+
| max |
+-----------+
| 612442603 |
+-----------+
```

[Note that the revision/version related columns are stored as float64 to avoid losing data.](https://github.com/cube2222/octosql/issues/330)
You might need to cast the respective values with INT() or re-format the scientific output.

### Count revisions for a key

```sql
Expand Down
14 changes: 7 additions & 7 deletions etcdsnapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ func (d Database) GetTable(ctx context.Context, name string, options map[string]
{
// size of the entire database file
Name: "size",
Type: octosql.Float, // float because there's no 64 bit integer type in octosql
Type: octosql.Int,
},
{
// how many bytes of "size" are in use
Name: "sizeInUse",
Type: octosql.Float, // float because there's no 64 bit integer type in octosql
Type: octosql.Int,
},
{
// how much space is considered free, meaning "size - sizeInUse".
Name: "sizeFree",
Type: octosql.Float, // float because there's no 64 bit integer type in octosql
Type: octosql.Int,
},
}

Expand Down Expand Up @@ -94,19 +94,19 @@ func (d Database) GetTable(ctx context.Context, name string, options map[string]
},
{
Name: "createRevision",
Type: octosql.Float,
Type: octosql.Int,
},
{
Name: "modRevision",
Type: octosql.Float,
Type: octosql.Int,
},
{
Name: "version",
Type: octosql.Float,
Type: octosql.Int,
},
{
Name: "lease",
Type: octosql.Float,
Type: octosql.Int,
},
// this should always be the last entry in this definition listing
{
Expand Down
2 changes: 1 addition & 1 deletion octosql_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"binary_download_url_pattern": "https://github.com/tjungblu/octosql-plugin-etcdsnapshot/releases/download/v{{version}}/octosql-plugin-etcdsnapshot_{{version}}_{{os}}_{{arch}}.tar.gz",
"versions": [
{
"number": "0.1.3"
"number": "0.1.4"
}
]
}

0 comments on commit 1052901

Please sign in to comment.