Commit Graph

177 Commits

Author SHA1 Message Date
Ben Kalman 7ebc0f2feb Rename NewTypedRefFromValue to NewRef and old NewRef to constructRef (#1427)
This is because:
* All type.Ref are now typed, so Typed was a tautology.
* The only way to construct a type.Ref is with a Value, so FromValue was
  a tautology (with a small amount of work to remove callers of NewRef).
2016-05-11 18:06:17 -07:00
Rafael Weinstein 08d306a1dc refactor go ordered sequence operations (#1461) 2016-05-09 15:31:35 -07:00
cmasone-attic 57320aad8e Go: Back datas.unwrittenPutCache with a LevelDB (#1442)
* Go: Back datas.unwrittenPutCache with a LevelDB

httpBatchStore was caching as-yet-unwritten Chunks both in memory and
on disk. To avoid this, the in-memory cache is now backed by a
LevelDB, which handles spilling to disk when it needs to. When it's
time to send Chunks to the server, the cache is enumerated in
insert-order so that the payload of the write request is properly
structured.

Fixes #1348
2016-05-09 09:29:31 -07:00
Erik Arvidsson 014e330315 Rename DataStore to Database (#1448) 2016-05-06 17:37:19 -07:00
Ben Kalman e7219f3603 Add height to every RefValue (#1415)
This is to support efficient chunk diff. Most of the churn in this patch
comes from updating test expectations, and updating every Ref construction
to include a height and every MetaTuple to include a Ref.
2016-05-05 10:11:05 -07:00
Chris Masone 9684881b5f Go: Maintain validation cache on DataStore across Commit
While this causes the cache to potentially grow infinitely,
having a DataStore keep track of every value it's read or written
makes it simpler to program with. Once types.Ref can only come to
be by being read out of a DataStore, we can do away with this
altogether.
2016-05-03 10:19:24 -07:00
cmasone-attic 78bd9c32f6 Merge pull request #1395 from kalman/go-commit
Go: change Datastore/Dataset Commit to use Ref<Commit> for parents
2016-05-02 15:57:41 -07:00
Benjamin Kalman d1484690ff Go: change Datastore/Dataset Commit to use Ref<Commit> for parents
The goal is to remove places where we construct a types.Ref from a
ref.Ref, so that we can attach a height to it later. This should also
make it unnecessary to read in the Commit values at all (which is the
case in the JS SDK) but commit validation prevents that for now.
2016-05-02 15:42:01 -07:00
Erik Arvidsson 3032c76a39 Use a map for the struct fields
Fixes #1368
2016-05-02 15:35:27 -07:00
Chris Masone 12c08dc969 Go: Add hashes seen to HTTP error in writeValue handler
We're seeing some raciness in RemoteDataStore tests that don't
repro locally. This adds the hashes of all chunks seen prior to the
failure to the error response sent back by the DataStoreServer.
Hopefully, this will help debug the raciness.
2016-05-02 14:10:59 -07:00
cmasone-attic 848b030a4b Merge pull request #1383 from cmasone-attic/issue1377
Align Go and JS implementations of ValueStore.WriteValue()
2016-05-02 12:05:10 -07:00
Chris Masone 5eda7e8243 Align Go and JS implementations of ValueStore.WriteValue()
Fixes #1377
2016-05-02 11:54:23 -07:00
cmasone-attic 7ef62df1f4 Switch to network-byte-order in DataStore wire format (#1386)
* Switch to network-byte-order in DataStore wire format

Fixes #1370
2016-05-02 11:44:53 -07:00
Dan Willhite 49917b6633 Remove -store arg and add flags library. 2016-05-02 10:33:11 -07:00
Chris Masone f26a94584c JS: Implement new DataStore client protocol
This replaces the HTTP ChunkStore implementation with an implementation of
our new DataStore client protocol. It migrates much of the batching logic
from RemoteStore into the new BatchStore, which is analogous to a class we
have on the Go side, but continues to use a Delegate to handle all the HTTP
work.

This patch also introduces ValueStore, which handles validating Values as
they're written. Instead of handling Value reading and writing itself,
DataStore now extends ValueStore.

Towards #1280
2016-05-02 09:52:36 -07:00
Chris Masone 8eba180782 Revert "renaming datastore to database (#1374) - fixes bug #1290"
This reverts commit d77902b323.
2016-05-02 09:01:44 -07:00
Mike Gray d77902b323 renaming datastore to database (#1374) - fixes bug #1290
* datastore -> database
* fixing bug 1290, renaming datastore to database
2016-05-01 22:02:16 -04:00
Erik Arvidsson 6f972c9d7c Make the order of struct fields insignificant (#1367)
The fields are now sorted upon creation

Fixes #814
2016-04-29 21:16:13 -07:00
Erik Arvidsson d4d6de6a76 Rename Field t to type (#1366)
* Rename Field t to type

* Fix clients/csv too
2016-04-29 13:47:52 -07:00
Erik Arvidsson fa742aecb1 Remove unions from structs (#1345)
Fixes #1344
2016-04-28 11:13:59 -07:00
Erik Arvidsson 3ff6ee6add Inline struct type declaration into chunk (#1324)
Struct type definition is now inlined into the chunk. To break
cycles we use back references.

- Removes unresolved type refs
- Removes packages

Fixes #1164
Fixes #1165
2016-04-27 20:39:51 -07:00
Rafael Weinstein 24826ade3d Remove common noms file & RefBase 2016-04-25 11:20:01 -07:00
Dan Willhite 32bb498339 Replace Commit type with types.Struct().
Remove last vestiges of codegen in datas. Fixes #1296.
2016-04-25 10:24:09 -07:00
Erik Arvidsson 423d3a87ec Make MakeCompoundType package private (#1304)
And same for MakePrimitiveType. This also makes sure that we return
the same primitive type every single time.

Fixes #1271
2016-04-22 17:49:27 -07:00
Erik Arvidsson 02c47661fd Make all usages of Type in Go use pointers (#1295)
This is in preparation of allowing back references which requires
pointers to be able to compare that the structs are the same.
2016-04-22 15:19:42 -07:00
Erik Arvidsson 5896559db7 Remove support for enums (#1291) 2016-04-22 10:14:05 -07:00
Erik Arvidsson bbeb504943 Type describe use human readable serialization (#1287)
* Make Type Describe use the Human Readable Serialization

This reduces code duplication.

* Remove Choices in favor of []Field
2016-04-21 11:12:37 -07:00
Dan Willhite 6db8f5def1 Merge pull request #1284 from willhite/datas
Remove codegen artifacts from types.
2016-04-21 10:03:47 -07:00
Dan Willhite bb7f039e69 Remove codegen artifacts from types. 2016-04-20 17:41:09 -07:00
Erik Arvidsson 0d5b6c4223 Remove Go codegen (#1285) 2016-04-20 16:59:43 -07:00
Dan Willhite 9300a81df6 Remove nomsdl info from datas. 2016-04-20 15:42:39 -07:00
Chris Masone 6ff58aa38b Report backpressure over the wire
Using ChunkStore.PutMany() means that the DataStore server code
can detect when the ChunkStore it's writing to can't handle
the amount of data being pushed. This patch reports that
status back across the wire to the client that's attempting
to write a Value graph. Due to Issue #1259, the only thing the
client can currently do is retry the entire batch, but we hope
to do better in the future.
2016-04-19 11:27:45 -07:00
Marina Moore 42b468e591 added flags library 2016-04-19 09:42:54 -07:00
Marina Moore 2ac56f9821 changed read-data for new method of making remote datastore 2016-04-15 14:41:10 -07:00
Chris Masone c1e1fb97bb Remove now-unneeded PrivateRefFromType
Fixes #1209.

Also, clean up a few comments.
2016-04-15 13:36:46 -07:00
Chris Masone 0fc183d429 Refactor new DataStore code
The initial refactor had some pretty confusing struct and method
names, so this patch renames a number of things and migrates a bunch
of code to the types/ from datas/, where it seems to be a better
logical fit.

datas.cachingValueStore          -> types.ValueStore
datas.hintedChunkStore interface -> types.BatchStore
datas.naiveHintedChunkSink       -> types.BatchStoreAdaptor
datas.httpHintedChunkStore       -> datas.httpBatchStore
datas.notAHintedChunkSink        -> datas.notABatchStore

Also, types now exports a ValidatingBatchingSink, which is used by
datas.HandleWriteValue to process incoming hints and validate incoming
Chunks before putting them into a ChunkStore.

Towards Issue #1250
2016-04-15 10:57:45 -07:00
Erik Arvidsson c91b8146dc Go: Eagerly fixup types after the Package has been created (#1241)
This fixes the package refs in NewPackage and makes the serializer
know about these refs when a Package is encoded.
2016-04-13 18:09:22 -07:00
Rafael Weinstein 45e5dc6260 tree walks now operate over types.RefBase 2016-04-13 15:26:44 -07:00
Chris Masone a8423c9234 Special-case Package chunks when caching reachables during ReadValue
For performance reasons, Package objects for generated Noms Types are
side-loaded when reading Values. This means that the
opportunistically-populated chunk->Type map used by DataStore when
validating writes won't see these chunks in a number of cases. This
can lead to false negatives and erroneous validation failures. This
patch special-cases RefOfPackage when caching the Chunks reachable
from a newly-read Value, manually fetching them from the
types.PackageRegistry and crawling their reachable Chunks.

Fixes #1229.
2016-04-13 15:08:18 -07:00
Chris Masone 7db243745b httpHintedChunkStore uses one big batch
A novel chunk may contain references to any other novel chunk, as long
as there are no cycles. This means that breaking up the stream of
novel chunks being written to the server into batches risks creating
races -- chunks in one batch might reference chunks in another,
meaning that the server would somehow need to be able to
cross-reference batches. This seems super hard, so we've just forced
the code to write in one massive batch upon Commit(). We'll evaluate
the performance of this solution and see what we need to change.

Also, there's a terrible hack in HandleWriteValue to make it so that
pulls can work by back-channeling all their chunks via postRefs/ and
then writing the final Commit object via writeValue/
This can be fixed once we fix issue 822
2016-04-12 18:50:35 -07:00
Chris Masone d8a2d285e9 Pull DataStore API over the wire and kill chunks.HTTPStore
This patch is unfortunately large, but it seemed necessary to make all
these changes at once to transition away from having an HTTP
ChunkStore that could allow for invalid state in the DB. Now, we have
a RemoteDataStoreClient that allows for reading and writing of Values,
and performs validation on the server side before persisting chunks.
The semantics of DataStore are that written values can be read back
out immediately, but are not guaranteed to be persistent until after
Commit() The semantics are now that Put() blocks until the Chunk is
persisted, and the new PutMany() can be used to write a number of
Chunks all at once.

From a command-line tool point of view, -h and -h-auth still work as
expected.
2016-04-12 14:08:58 -07:00
Rafael Weinstein 4006746b21 Remove Ref.SetTargetValue 2016-04-11 17:25:56 -07:00
Rafael Weinstein 1676707906 WriteValue returns RefBase 2016-04-11 17:09:25 -07:00
Chris Masone 1d857a4686 Refactor DataStore Copy methods into functions
This patch removes the special RemoteDataStore implementation of
CopyReachableChunksP, as this is seldom-used and adds complexity
that stands in the way of Issue 654
2016-04-04 15:23:43 -07:00
Chris Masone 44bb16385c Add DataStore 'Type' cache to remember Noms type info as well.
To facilitate validation, DataStore needs to remember which chunks
it's seen, what their refs are, and the Noms type of the Values they
encode. Then, DataStore can look at each Value that comes in via
WriteValue() and validate it by checking every embedded ref (if any)
against this cache.

Towards #654
2016-03-22 16:34:26 -07:00
Chris Masone 82338bb5be Change Value.Chunks() to return []types.RefBase
In pursuit of issue #654, we want to be able to figure out all the
refs contained in a given Value, along with the Types of the Values to
which those refs point. Value.Chunks() _almost_ met those needs, but
it returned a slice of ref.Ref, which doesn't convey any type info.

To address this, this patch does two things:
1) RefBase embeds the Value interface, and
2) Chunks() now returns []types.RefBase

RefBase now provides Type() as well, by virtue of embedding Value, so
callers can just iterate through the slice returned from Chunks() and
gather type info for all the refs embedded in a given Value.

I went all the way and made RefBase a Value instead of just adding the
Type() method because both types.Ref and the generated Ref types are
actually all Values, and doing so allowed me to change the definition of
refBuilderFunc in package_registry.go to be more precise. It now returns
RefBase instead of just Value.
2016-03-21 16:13:14 -06:00
Rafael Weinstein c515b80c88 types.WriteValue -> types.EncodeValue 2016-03-18 13:53:04 -07:00
Chris Masone 119a56c3a9 Move ReadValue and WriteValue to DataStore
This patch is the first step in moving all reading and writing to the
DataStore API, so that we can validate data commited to Noms.

The big change here is that types.ReadValue() no longer exists and is
replaced with a ReadValue() method on DataStore. A similar
WriteValue() method deprecates types.WriteValue(), but fully removing
that is left for a later patch. Since a lot of code in the types
package needs to read and write values, but cannot import the datas
package without creating an import cycle, the types package exports
ValueReader and ValueWriter interfaces, which DataStore implements.
Thus, a DataStore can be passed to anything in the types package which
needs to read or write values (e.g. a collection constructor or
typed-ref)

Relatedly, this patch also introduces the DataSink interface, so that
some public-facing apis no longer need to provide a ChunkSink.

Towards #654
2016-03-17 12:57:44 -07:00
Chris Masone 6b4c93a3f7 Fix up DataStore comments
If I'm going to start refactoring this code, it's important
that I'm sure what all the methods do. So, update the comments
2016-03-09 12:45:45 -08:00
Chris Masone 8eb61455c2 Clean up DataStore interface comments 2016-02-25 17:05:04 -08:00