Commit Graph

82 Commits

Author SHA1 Message Date
Rafael Weinstein
45e5dc6260 tree walks now operate over types.RefBase 2016-04-13 15:26:44 -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
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
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
224215f340 Use Type() to validate Commit in Dataset.SetNewHead()
Since we put a type system in Noms, we can now use it
to check that a ref that purports to be the new Head
for a Dataset after a pull actually points to a Commit.

Fixes #133
2016-03-09 14:07:04 -08:00
Benjamin Kalman
ebac4157cf Add progress updating to the picasa client. 2016-02-23 13:12:45 -08:00
Aaron Boodman
cff0de3696 non-vendor changes 2016-02-08 23:15:09 -08:00
Rafael Weinstein
6c3239a1d0 Collections no longer need a ChunkStore on creation 2016-02-02 13:39:26 -08:00
Chris Masone
da2d86c889 Remove Dataset.Close()
We decided this API doesn't really make sense. So, remove it.

Fixes #932
2016-02-01 11:12:09 -08:00
Erik Arvidsson
47f6c196e4 Refactor CSV importer so that the function can be reused 2016-01-25 13:48:03 -08:00
Aaron Boodman
550462ae38 shove: allow pulling from ref or ds head, like Git 2015-12-16 20:40:22 -08:00
Erik Arvidsson
40d164fe47 Go: Encode numbers as strings
Because JSON encoders encode numbers differently we cannot just use
numbers in the output.

This still encodes the NomsKind as numbers.

Towards #749
2015-12-11 16:30:07 -05:00
Rafael Weinstein
e5409f2698 Remove MetaSequenceKind from serialization 2015-12-04 13:34:30 -08:00
Dan Willhite
699cc2accc Fixes #687.
Make dataStoreCommon.doCommit() return an error instead of boolean.
2015-12-02 16:41:00 -08:00
Dan Willhite
afc3944341 Add top-down sync strategy. 2015-12-01 12:39:42 -08:00
Rafael Weinstein
7caa08bc5c Complex Types embed a ChunkStore 2015-12-01 10:40:47 -08:00
Rafael Weinstein
e75f5097c7 Allow Map & Set to order by natural ordering of element type if available. 2015-11-16 14:30:30 -08:00
Erik Arvidsson
9aadd85004 Add types.Struct and improve typed structs
The generated code for typed structs now uses a Go struct which
implements Value directly. The fields in this struct uses the "user"
type. (The union value still uses types.Value though.)

When a typed struct is created by the decoder, it asks for a struct
builder which returns a channel that the values of the fields of the
struct are sent to.
2015-11-04 11:55:07 -05:00
Erik Arvidsson
eeaac87d5f Make Chunks return all reachable Refs from the current Value
We now do a recursive call which bottoms out with a ref.Ref for RefKind
Values. This means that we traverse into nested structures consistently.

The effect of this is that we get all the refs that the current chunk
references.
2015-11-03 17:13:20 -05:00
Rafael Weinstein
0e0be1c59b Remove trailing newline from json encoding in typed serialization 2015-10-28 17:07:34 -07:00
Erik Arvidsson
1d13a878c4 Fix types.Ref and RefKind objects
Ref Values now have a TargetRef() method that returns the ref.Ref of
the target the Value is referencing.

Note: This is a breaking change. In old code the Ref() of the Value was
the Ref of the underlying target.

Fixes #464
2015-10-26 11:18:02 -04:00
Erik Arvidsson
0b80508047 Fix Commit to use Set(Ref(Commit)) 2015-10-21 19:29:11 -04:00
Erik Arvidsson
16353f38f8 NomDL: Make the new serialization default
This makes the new typed serialization the default (the old
serialization is not used but the code has not been cleaned up yet).

Some things are no working in the new world:

Chunking -  The compound list is not working correctly any more. The
Chunks method is having issues because it assumed things based on the
old implicit chunking.

Commit - uses a `Set(Commit)` which means that the parent commit is
embedded. We need to change that to be `Set(Ref(Commit))` so that the
parent commit is referenced instead.
2015-10-21 19:04:22 -04:00
Erik Arvidsson
d6869cef35 NomDL: Make Package a primitive type
This solves the bootstrapping problems we are encountering.

Previously Package was a Struct but structs depend on Package.
2015-10-20 10:26:00 -04:00
Chris Masone
f9e39f1b89 NewDataset() should refuse to accept "" as the datasetID
Also, update codegen.go to use a sensical default if nothing is provided
on the command line.
2015-10-19 10:45:53 -07:00
Chris Masone
9b225dce9b Introduce UnresolvedKind, so TypeRefKind isn't overloaded.
We'd wound up in a spot where serialization code used 'TypeRefKind' to
mean one of two very different things...either an actual value that
describes some Noms type, or a reference to a type definition that
lives somewhere else. To get rid of this ambiguity, we introduce
'UnresolvedKind' to take over the latter meaning. Now, TypeRefKind
means _only_ a value that describes a type. If you want to point off
to a type definition elsewhere in the type package, or in another
type package, use UnresolvedKind.
2015-10-19 09:58:27 -07:00
Erik Arvidsson
f064d35253 NomDL: Move pkgRef to UnresolvedDesc
Only unresolved type refs should have a package ref.
2015-10-16 19:39:49 -04:00
Erik Arvidsson
36d9362628 NomDL: Use ordinal for unresolved type refs
Instead of using the name of the type we now use the index of the type
in the Package that defines it.
2015-10-16 17:46:15 -04:00
Erik Arvidsson
6185ea1ddb NomDL: Use a list for the types in the package
This does not yet update the serialization to use the ordinal.
2015-10-14 14:49:04 -04:00
Dan Willhite
43d9a6f4fb Remove commit lineage from datastore head.
Replace datastore head with a map of datasetID's to commits. Each commit in the map represents that dataset's head. Fixes #402. Fixes #60. Filed #404 about small window of potential conflict with updating root that needs to be resolved at some point. # Please enter the commit message for your changes. Lines starting
2015-10-14 11:04:13 -07:00
Erik Arvidsson
8565f175ee Make sure Chunks includes type.Refs and the TypeRef
Chunks shold return the futures for types.Ref values.

For typed values that have a TypeRef which has a package ref, also
include that.
2015-10-13 11:00:51 -04:00
Dan Willhite
4852067aad Fix concurrency overwrite on dataset.
When there are two dataset clients working on the same empty dataset. The second one to commit would override the first.
2015-10-12 10:50:28 -07:00
Erik Arvidsson
37336f41be NomDL serializing
This now handles serializing TypeRef values
2015-10-09 14:09:49 -07:00
Erik Arvidsson
9cb7596409 NomDL: Make NomsValue a Value
This means that when we ReadValue we can now return a NomsValue

Towards #281
2015-10-06 16:38:11 -07:00
Erik Arvidsson
2dec53453e NomDL: Add new serialization format
The new serialization format use "t " as in typed. The rest of the
message is a JSON array describing the typed data. The type is
described by types.TypeRef

Fixes #384
Issues #281, #304
2015-10-06 15:56:10 -07:00
Erik Arvidsson
72f4cd3a7a NomDL Codegen: Make the TypeRef return a package ref
The TypeRef function for a Noms Struct should be the (Name, PkgRef) and
not the description of the struct fields. This is important because
when serializing we need to write the package ref.

Towards #281 #304
2015-10-05 14:24:25 -07:00
Aaron Boodman
572130f563 Revert "Purposely break the build to test drone integration"
This reverts commit 8909eb5b42.
2015-09-30 16:46:14 -07:00
Aaron Boodman
8909eb5b42 Purposely break the build to test drone integration 2015-09-30 16:45:21 -07:00
Erik Arvidsson
8c2caa3b27 NomDL Codegen: Add TypeRef method to typed objects 2015-09-30 17:48:32 -04:00
Chris Masone
9168a902f9 Modify codegen to include pacakge refs for unresolved types
Also, switch to using a ref.Ref when getting/setting the package
ref in a TypeRef. Using a types.Ref just led to lots of manual
boxing and unboxing every time I wanted to use the reference.

Toward issue #294
2015-09-29 12:58:56 -07:00
Chris Masone
5ce93dad2e Beginning of import support in NomDL
This patch mostly merges parse.Package and types.Package, though it
can't quite go all the way. A types.Package doesn't have 'using'
declarations, while the parsed representation of a .noms file needs to
have that information. Hence, the parse package is moved to the 'pkg'
package, and pkg.Parsed is introduced. This type embeds types.Package
and adds the necessary additional information.

To make inroads on handling imports, I enhanced ParsePackage() (now
called ParseNomDL()) to actually process the 'alias' and 'import'
statements in the input and go replace namespaced type names in the
package with refs of imported packages. For example, the TypeRef for
'Bar' generated in the following package

alias Foo = import "sha1-ffffffff"

struct Bar {
  f: Foo.RockinStruct
}

will actually return types.Ref{sha1-ffffffff} when you call PackageRef()
on it.

In addition, I've added a function to the new 'pkg' package,
which allows the caller to get the dependencies of a type package
from a chunk store.

Fixes issue #353, towards issue #294
2015-09-28 16:08:22 -07:00
Chris Masone
c80a1c55b3 Merge parse.TypeRef and types.TypeRef
These were two representations of, essentially, the same information.
They were separate because they provided different APIs to similar
information, but the APIs became more similar once we started using
native types (as opposed to Noms types) for the various Make*TypeRef()
functions.

Unifying these is a big step to unifying parse.Package and types.Package,
which is pretty necessary for dealing with imported packages.

Fixes issue #338
2015-09-25 15:17:49 -07:00
Erik Arvidsson
bf095dab3c Merge branch 'master' into nomdl-optional-codegen 2015-09-25 17:20:23 -04:00
Erik Arvidsson
d17dc67a73 NomDL CodeGen: Rename self 2015-09-25 17:17:12 -04:00
Erik Arvidsson
c254a1391a Codegen for optional fields in structs 2015-09-25 17:08:57 -04:00
Erik Arvidsson
5b3f611104 NomDL Codegen: Add optional flag to Field 2015-09-25 14:38:41 -04:00
Erik Arvidsson
c48f365076 Nomgen -> nomdl/codegen for dataset/ 2015-09-25 11:28:10 -04:00
Rafael Weinstein
ec8461e8fd RemoteDataStore / CopyReachableChunksP 2015-09-24 11:06:50 -07:00
Erik Arvidsson
b67ab2a9e1 Convert datas/ to nomdl/codegen
This make Commit a typed struct with a Set(Commit).

This also fixes a case where the recursive detection for determining
if a Def can be created was not working.
2015-09-24 12:56:58 -04:00