Commit Graph

3476 Commits

Author SHA1 Message Date
Erik Arvidsson 7c4e2385ab Normalize our number encoding (#3370)
Our Number encoding consists of two parts. Firsts we convert the float
into f * 2**exp, then we uvarint encode f and exp. However, we didn't
normalize f so in theory we could end up with multiple representations
of the same number.

This changes the representation to make the f the smallest possible
integer that fulfills the formula above.

For example we used to encode 256 as (0x100, 0) but with this we instead
encode it as (0x01, 8).

Fixes #2307
2017-04-10 12:20:52 -07:00
Rafael Weinstein 0b10350af3 cleanup (#3372) 2017-04-10 11:45:26 -07:00
Rafael Weinstein fbfdd317fc Encode all noms quantities as varint (#3368) 2017-04-08 22:48:03 -07:00
Rafael Weinstein 34ae4262c8 Types refactor (#3367)
1. Decoder no longer needed to remove struct cycles. That happened as we decoded
2. Remove no-op tests.
3. Remove dead code
4. Refactor and add test.
5. Just moving code around (mostly type_cache -> make_type)
6. Remove (no longer necessary) typeDepth counter in ValueDecoder
2017-04-08 12:14:39 -07:00
Rafael Weinstein a2bb7d7a75 Remove to unresolved type (#3366) 2017-04-08 11:12:54 -07:00
Rafael Weinstein d8b5d03520 Zero-tolerance for unnamed struct cycles (#3365) 2017-04-08 10:39:03 -07:00
Rafael Weinstein ad6ffaec9b remove noms migration (#3362) 2017-04-08 10:07:44 -07:00
Rafael Weinstein cb06559428 correctly encode struct cycles (#3360) 2017-04-08 10:01:15 -07:00
cmasone-attic d95b367179 Rename 'lock' attribute in dynamo_manifest.go (#3358)
Turns out 'lock' is a reserved word for DynamoDB attributes,
so change it.
2017-04-07 20:27:00 -07:00
Erik Arvidsson f40e5ae7bf Compare target hash instead (#3356)
Also handle cycles of unnamed structs.
2017-04-07 17:56:46 -07:00
cmasone-attic fe2c476469 Fix NBS optimistic locking (#3353)
Introduce a "lock" hash into NBS manifests to address the bad
interaction between Flush() and optimistic locking. Our original
design didn't include Flush(), which changes the set of tables without
updating the root. Thus... an optimistic locking strategy predicated
on checking the currently-persisted root hash is not robust to
interleaved Flush() calls from multiple clients.

Fixes #3349
2017-04-07 16:55:39 -07:00
Erik Arvidsson 3cda20e251 Add types.HasStructCycle and cleanup MakeStructType (#3354) 2017-04-07 16:27:17 -07:00
Erik Arvidsson 4e913dc210 Fix issue with ilooping with unnamed structs (#3350)
When we clone it is possible to run into loops between named and
unnamed structs. We need to stop cloning the type tree when we see
cycle.

Also update Describe to print the actual type tree, even if it is
invalid.
2017-04-07 09:50:24 -07:00
Aaron Boodman 5ed5b764b6 NewStreamingBlob: print out err details from reader (#3351)
We're getting an error here but can't see what it is in the logs.
2017-04-07 09:39:46 -07:00
Erik Arvidsson fd815b10ad Compute type based on value (#3338)
This moves the type off from the value and instead we compute it as we ask for.

This also changes how we detect cycles. If a named struct contains a struct with the
same name we now create a cycle between them. This also means that cycle types
now take a string and not a number.

For encoding we no longer write the type with the value (unless it is a types.Ref).

This is a format change so this takes us to 7.6

Fixes #3328
Fixes #3325
Fixes #3324
Fixes #3323
2017-04-06 17:43:49 -07:00
cmasone-attic de76d37f09 Rip out hinting, reverse-order hack; make validation lazy (#3340)
* Add HasMany() to the ChunkStore interface

We'll need this as a part of #3180

* Rip out hinting

The hinting mechanism used to assist in server-side validation
of values served us well, but now it's in the way of building a
more suitable validation strategy. Tear it out and go without
validation for a hot minute until #3180 gets done.

Fixes #3178

* Implement server-side lazy ref validation

The server, when handling writeValue, now just keeps track of all the
refs it sees in the novel chunks coming from the client. Once it's
processed all the incoming chunks, it just does a big bulk HasMany to
determine if any of them aren't present in the storage backend.

Fixes #3180

* Remove chunk-write-order requirements

With our old validation strategy, it was critical that
chunk graphs be written bottom-up, during both novel value
creation and sync. With the strategy implemented in #3180,
this is no longer required, which lets us get rid of a bunch
of machinery:

1) The reverse-order hack in httpBatchStore
2) the EnumerationOrder stuff in NomsBlockCache
3) the orderedPutCache in datas/
4) the refHeight arg on SchedulePut()

Fixes #2982
2017-04-06 16:54:40 -07:00
Dan Willhite ecc39d1c76 Fix datetime nanosecods (#3342)
We were not correctly marshalling the nanoseconds which lead to issues with round tripping.
2017-04-06 10:43:21 -07:00
Eric Halpern 9ff2c1d855 Go slice to Noms Set mashalling (#3339)
* Go slice to Noms Set mashalling

fixes: #3335
2017-04-04 11:33:30 -07:00
Erik Arvidsson c964aff0af Remove types.Value Type() in favor of types.TypeOf() (#3337)
BREAKING CHANGE

This removes the `Type()` method from the `types.Value` interface.
Instead use the `types.TypeOf(v types.Value) bool` function.

Fixes #3324
2017-04-03 14:04:13 -07:00
cmasone-attic 344d859775 Fix dynamoManifest to properly handle an empty set of tables (#3336)
DynamoDB doesn't allow empty strings in records. We were sending an
empty string in the case where a store had no tables in it. Instead,
the right thing is to leave this attribute out of the record, and then
detect the case where the attribute is empty when reading the record.
2017-04-03 13:48:18 -07:00
Erik Arvidsson ebbefcc511 Use Struct fields directly in HRS (#3334) 2017-04-02 19:31:20 -07:00
Erik Arvidsson f1d7214af6 Update struct in memory representation (#3333)
* Update struct in memory representation

To contain struct name and field names.

This is in preparation for removing types from the value.

Towards ##3324

* Rename structFields to structTypeFields

* Undo change in vendoring

* searchField and copy
2017-04-02 07:46:39 -07:00
Erik Arvidsson 1c00c80f8d Simplify List, Map, Set and Ref types too (#3331)
Towards #3325
2017-03-31 18:29:19 -07:00
Rafael Weinstein 22a7d8cf7e Type.Kind => Type.TargetKind, Add Value.Kind (#3332) 2017-03-31 18:09:35 -07:00
Rafael Weinstein 2a5a720165 Remove type cache (#3330) 2017-03-31 16:24:40 -07:00
Aaron Boodman f4edb1ec1f Update README.md 2017-03-31 15:37:55 -07:00
Erik Arvidsson 79587b00e3 Use hash of Type instead of pointer to Type (#3329) 2017-03-31 15:33:05 -07:00
Rafael Weinstein 1f3d9beda5 Implement Type Simplification v2 (#3318)
When we simplify types (currently only done when creating unions) we now also make all structs with the same name use the same struct type.
2017-03-31 10:45:55 -07:00
Erik Arvidsson 4ef13e2ff0 Refactor simplifyStruct (#3317)
Pull out the code that computes the struct fields so we can reuse
to mutate an existing struct type.
2017-03-30 17:59:02 -07:00
Rafael Weinstein 9630b93830 inlineStructTypes (#3316) 2017-03-30 16:23:15 -07:00
Rafael Weinstein f6f595501b Yay! Remove hashes from tests (#3308) 2017-03-30 16:16:40 -07:00
Erik Arvidsson 9bb03a99ed Replace and collect (#3315)
This replaces all `struct N { ... }` with `struct N {}` in a type
and returns a the types it replaces for future use
2017-03-30 15:42:38 -07:00
Erik Arvidsson cc48470e91 Add walkStructTypes helper function (#3314) 2017-03-30 15:38:56 -07:00
Erik Arvidsson 61c2273ecd Fix union ordering between two cycle types (#3310)
We were not enforcing the order between two cycle types. In other words
the following two should be equal:

```
Cycle<0> | Cycle<1> = Cycle<1> | Cycle<0>
```
2017-03-30 12:29:02 -07:00
Erik Arvidsson 90b62269cc Add panic in writeType if union order is wrong (#3311) 2017-03-30 11:36:44 -07:00
Erik Arvidsson be20c35cd1 Add panic in make union if order is not correct (#3309) 2017-03-29 20:50:27 -07:00
Erik Arvidsson 61e5e71c81 Make sure we flatten unions before calling simplify types (#3307)
We ran into an issue where we passed non flatten types to simplify types
which lead to us having two `struct Commit` in a union.
2017-03-29 20:26:47 -07:00
Ben Kalman 9a864dcfd4 Make marshal.MustFoo not go via defer-recover (#3305) 2017-03-29 15:18:46 -07:00
Erik Arvidsson d4b412fa1f Rename MakeStructType2 to MakeStructType (#3304)
and remove the old MakeStructType
2017-03-29 15:04:26 -07:00
Erik Arvidsson c9e4a3af02 Resurrect MakeUnionType2 as MakeUnionTypeIntersectStructs (#3303)
This is needed by attic and it uses internal APIs so it has to be
exported 😢

A better path forward would be to fully implement intersection types
but that is a large change for an edge case feature.
2017-03-29 13:21:03 -07:00
cmasone-attic 3086084f77 Correctly create custom http.Transport in http_batch_store.go (#3302)
For the longest time, there's been a 'go vet' warning telling us that
when we build a custom http.Client in http_batch_store.go, we were
copying a Mutex down in there. That seems like not what you want to do.
Turns out we should be creating our own http.Transport object and
sharing that, instead of copying the default one every time we build
a new httpBatchStore.
2017-03-29 11:17:25 -07:00
Erik Arvidsson 2b669edcb3 ToUnresolvedType lost the optional flag (#3301) 2017-03-28 17:40:05 -07:00
Erik Arvidsson 1d56b95b21 IsSubtype more tests (#3299)
Adding more tests as I'm tracking down issues
2017-03-28 15:13:21 -07:00
Ben Kalman 3b82ab4ef1 Add missing .babelrc and .flowconfig (#3298) 2017-03-28 13:23:58 -07:00
Aaron Boodman 3315c31fe3 Update CONTRIBUTING.md 2017-03-28 10:32:41 -07:00
Sam Herrmann 7116bc0902 Remove Windows instructions from README.md (#3295) 2017-03-28 10:14:21 -07:00
Sam Herrmann 385d4e7bcd Fix v7 hyperlink in README.md (#3296) 2017-03-28 10:12:50 -07:00
Erik Arvidsson 22f70f585d Optional fields (#3287)
This adds optional fields to structs.

New version: 7.4

To create a struct type with optional fields use types.MakeStructType2

There are some API changes in this commit and there will be some more in followup commits.

Fixes #2327
2017-03-27 16:54:04 -07:00
Erik Arvidsson 7763b8b503 Remove OID (#3275)
Fixes #3121
2017-03-27 16:17:53 -07:00
Ben Kalman 3c764c1eb5 Remove JS SDK, examples, and tools (#3293) 2017-03-27 15:54:39 -07:00