Commit Graph

199 Commits

Author SHA1 Message Date
Jesse Ditson
8be0ae7c6b update code blocks to always specify syntax, fix ordered list (#3734) 2017-09-23 16:25:46 -07:00
Dan Willhite
10ec10dc00 Add ability to register HRSCommenters on Structs. (#3609)
Clients can register HRSCommenters to cause additional info
to be included as comments when generating the human readable
encoding for Noms Structs.
2017-09-13 17:21:08 -07:00
Ben Kalman
03b7221c36 Use stretchr/testify not attic-labs/testify (#3677)
stretchr has fixed a bug with the -count flag. I could merge these
changes into attic-labs, but it's easier to just use strechr.

We forked stretchr a long time ago so that we didn't link in the HTTP
testing libraries into the noms binaries (because we were using d.Chk in
production code). The HTTP issue doesn't seem to happen anymore, even
though we're still using d.Chk.
2017-09-07 15:01:03 -07:00
Ian Davis
8c4fa02c6e Fix godoc strings for several functions (#3665) 2017-09-05 11:50:30 -07:00
Ian Davis
99f696edb8 Rename --summarize flag to --stat 2017-09-03 07:26:38 -07:00
Erik Arvidsson
84b4aba5a6 HRS: Prefix map/set values with map/set (#3655)
We now print map and set values as:

```
map {
  "string": 42,
  "set": set {
    true,
    false,
  },
}
```

Towards #1466
2017-08-31 13:31:21 -07:00
Erik Arvidsson
a93777d93a HRS: Cleanup struct head (#3647)
For struct values we always prefix with struct.

For struct types we always prefix with Struct.

Towards #1466
2017-08-29 17:47:54 -07:00
Erik Arvidsson
9cd2aae786 Print Refs with # (#3644)
Print Ref values as #123 instead of 123

Since our hashes are SHA-512 and we write them using Base32 there are a lot of overlaps with other parts of NomDL. This makes them unambiguous.

Towards #1466
2017-08-29 17:43:29 -07:00
Rafael Weinstein
c3f98d1631 Remove in mem graphs (#3635)
This patch removes the ability to keep alive uncommitted prolly-tree sequences.
2017-08-29 13:12:10 -07:00
Ben Kalman
963fb83dc3 Implement type sploring (#3641)
Display names are relatively similar to `noms show`.
I've also changed the display names for struct values to be more similar
to `noms show`.
2017-08-25 18:42:02 -07:00
Ben Kalman
1f5ce92100 Remove unnecessary TypeOf in splore (#3632) 2017-08-23 12:23:56 -07:00
Ben Kalman
a67aa18847 Improve command line parsing of noms splore (#3627)
Make it use kingpin, and clean up tests.
2017-08-21 17:45:55 -07:00
Ben Kalman
9d1f9a3ab4 Introduce noms-splore (#3623)
A lot of the JS code is taken from the old splore sample, but in
particular main.js is completely different - much simpler, because the
architecture of noms-splore uses a specialised {path => node} HTTP API,
implemented in Go, which does the noms graph traversal.

noms-splore also improves on the old splore sample by making it more
obvious what the key/value pairs are for maps and structs, but regresses
slightly in what it can say about prollytrees.
2017-08-21 11:59:14 -07:00
Jesse Ditson
5db3cf1679 kingpin docs, noms blob [put | get] (#3621)
* use kingpin for help and new commands, set up dummy command for noms blob

* document existing commands using kingpin

* remove noms-get and noms-set in favor of new noms blob command

* normalize bool flags in tests, remove redundant cases that kingpin now handles

* add kingpin to vendor files

* make profile flags global

* move --verbose and --quiet to global flags
2017-08-16 16:35:22 -07:00
Eric Halpern
b7a96bc591 Use log.PrintXXX rather than fmt.PrintXXX for informational messages (#3591)
All messages emitted from non-cli code are now output through the standard
logger rather than directly to stdout. This gives code that embeds noms control
over how messages are logged (using log.SetFlags and log.SetOutput).

When the noms cli is used, the logger is initialized so that it only prints the
string logged. In other cases, the log setup is left to the embedding code.

toward: #3590
2017-07-18 11:24:38 -07:00
Rafael Weinstein
d675e4d8f4 Chunking V2 (#3521) 2017-06-13 10:48:03 -07:00
Rafael Weinstein
3ff92950d8 Revert removal of |last| from Commit() (#3531) 2017-06-09 11:20:45 -07:00
Rafael Weinstein
214054986b Enforce clearer concurrency semantics of ValueStore (#3527) 2017-06-08 11:40:22 -07:00
Rafael Weinstein
81769cd7b3 move flushing of uncommitted ptree nodes out of EncodeValue (#3524) 2017-06-07 11:21:56 -07:00
cmasone-attic
46cf38eaae Simplify Pull() (#3490)
In an NBS world, bulk 'has' checks are waaaay cheaper than they used
to be. In light of this, we can toss out the complex logic we were
using in Pull() -- which basically existed for no reason other than to
avoid doing 'has' checks. Now, the code basically just descends down a
tree of chunks breadth-first, using HasMany() at each level to figure
out which chunks are not yet in the sink all at once, and GetMany() to
pull them from the source in bulk.

Fixes #3182, Towards #3384
2017-05-22 15:50:12 -07:00
Rafael Weinstein
0570d0c565 add noms show --stats (#3486) 2017-05-18 15:24:22 -07:00
cmasone-attic
ff7cae6d34 Merge chunks.RootTracker interface into chunks.ChunkStore (#3408)
You can't fully specify RootTracker without referring to the
ChunkStore interface, so they should just merge.

Fixes #3402
2017-04-19 21:34:20 -07:00
cmasone-attic
cb930dee81 Merge BatchStore into ChunkStore (#3403)
BatchStore is dead, long live ChunkStore! Merging these two required
some modification of the old ChunkStore contract to make it more
BatchStore-like in places, most specifically around Root(), Put() and
PutMany().

The first big change is that Root() now returns a cached value for the
root hash of the Store. This is how NBS worked already, so the more
interesting change here is the addition of Rebase(), which loads the
latest persistent root. Any chunks that appeared in backing storage
since the ChunkStore was opened (or last rebased) also become
visible.

UpdateRoot() has been replaced with Commit(), because UpdateRoot() was
ALREADY doing the work of persisting novel chunks as well as moving
the persisted root hash of the ChunkStore in both NBS and
httpBatchStore. This name, and the new contract (essentially Flush() +
UpdateRoot()), is a more accurate representation of what's going on.

As for Put(), the former contract for claimed to block until the chunk
was durable. That's no longer the case. Indeed, NBS was already not
fulfilling this contract. The new contract reflects this, asserting
that novel chunks aren't persisted until a Flush() or Commit() --
which has replaced UpdateRoot(). Novel chunks are immediately visible
to Get and Has calls, however.

In addition to this larger change, there are also some tweaks to
ValueStore and Database. ValueStore.Flush() no longer takes a hash,
and instead just persists any and all Chunks it has buffered since the
last time anyone called Flush(). Database.Close() used to have some
side effects where it persisted Chunks belonging to any Values the
caller had written -- that is no longer so. Values written to a
Database only become persistent upon a Commit-like operation (Commit,
CommitValue, FastForward, SetHead, or Delete).

/******** New ChunkStore interface ********/

type ChunkStore interface {
     ChunkSource
     RootTracker
}

// RootTracker allows querying and management of the root of an entire tree of
// references. The "root" is the single mutable variable in a ChunkStore. It
// can store any hash, but it is typically used by higher layers (such as
// Database) to store a hash to a value that represents the current state and
// entire history of a database.
type RootTracker interface {
     // Rebase brings this RootTracker into sync with the persistent storage's
     // current root.
     Rebase()

     // Root returns the currently cached root value.
     Root() hash.Hash

     // Commit atomically attempts to persist all novel Chunks and update the
     // persisted root hash from last to current. If last doesn't match the
     // root in persistent storage, returns false.
     // TODO: is last now redundant? Maybe this should just try to update from
     // the cached root to current?
     // TODO: Does having a separate RootTracker make sense anymore? BUG 3402
     Commit(current, last hash.Hash) bool
}

// ChunkSource is a place chunks live.
type ChunkSource interface {
     // Get the Chunk for the value of the hash in the store. If the hash is
     // absent from the store nil is returned.
     Get(h hash.Hash) Chunk

     // GetMany gets the Chunks with |hashes| from the store. On return,
     // |foundChunks| will have been fully sent all chunks which have been
     // found. Any non-present chunks will silently be ignored.
     GetMany(hashes hash.HashSet, foundChunks chan *Chunk)

     // Returns true iff the value at the address |h| is contained in the
     // source
     Has(h hash.Hash) bool

     // Returns a new HashSet containing any members of |hashes| that are
     // present in the source.
     HasMany(hashes hash.HashSet) (present hash.HashSet)

     // Put caches c in the ChunkSink. Upon return, c must be visible to
     // subsequent Get and Has calls, but must not be persistent until a call
     // to Flush(). Put may be called concurrently with other calls to Put(),
     // PutMany(), Get(), GetMany(), Has() and HasMany().
     Put(c Chunk)

     // PutMany caches chunks in the ChunkSink. Upon return, all members of
     // chunks must be visible to subsequent Get and Has calls, but must not be
     // persistent until a call to Flush(). PutMany may be called concurrently
     // with other calls to Put(), PutMany(), Get(), GetMany(), Has() and
     // HasMany().
     PutMany(chunks []Chunk)

     // Returns the NomsVersion with which this ChunkSource is compatible.
     Version() string

     // On return, any previously Put chunks must be durable. It is not safe to
     // call Flush() concurrently with Put() or PutMany().
     Flush()

     io.Closer
}

Fixes #2945
2017-04-19 13:31:58 -07:00
Aaron Boodman
cdc657f5e4 Define DateTime using struct embedding rather than type renaming. (#3386)
Define DateTime using struct embedding rather than type renaming.

This results in us inheriting all the methods of DateTime automatically.
2017-04-17 13:53:05 -07:00
Aaron Boodman
06cebbe346 Introduce @target annotation for paths (#3352)
Introduce @target annotation for paths

Fixes #2172
2017-04-13 14:56:31 -07:00
Erik Arvidsson
fd997f7bfa Add IsValueSubtypeOf and IsCommit (#3375)
This adds IsValueSubtypeOf which skips computing the type of the value.

Use IsValueSubtypeOf to implement IsCommit which checks if a value is a
commit.

Replace usages of IsSubtype(t, TypeOf(v)) with IsValueSubtypeOf(v, t).

Fixes #3326
Fixes #3348
2017-04-13 10:49:17 -07:00
Rafael Weinstein
fbfdd317fc Encode all noms quantities as varint (#3368) 2017-04-08 22:48:03 -07:00
Rafael Weinstein
ad6ffaec9b remove noms migration (#3362) 2017-04-08 10:07:44 -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
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
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
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
Jesse Ditson
c42056b15d Remove implicit directory creation when creating a local db (#3235)
Remove implicit directory creation when creating a local db

- remove Mkdir from NewLocalStore and NewLocalStoreFactory
- add specific error messages for directory does not exist and path is not a directory
- add tests for missing directory and path not directory

fixes: #3222
2017-03-01 13:29:09 -08:00
Aaron Boodman
4c55f2d64e noms log: add ability to log any path, not just dataset (#3202) 2017-02-21 23:12:11 -08:00
Aaron Boodman
4eaa0ba353 Remove Spec.DatasetName and Spec.Spec (#3102)
Remove Spec.DatasetName and Spec.Spec.

They were duplicating state that already existed elsewhere and easily
got out of sync.
2017-02-21 11:26:12 -08:00
cmasone-attic
5025a45b0b Remove usages of LevelDBStore (#3190)
NBS is stable enough that we've made it the default store for command
line tools, and the go-to store for tests that require temporary, but
persistent, storage.

We intend to remove support for LevelDB-backed chunk storage
completely ASAP. This patch removes all usage of LevelDBStore from
noms.git, but doesn't remove LevelDBStore _just_ yet as there are
still some dependencies on it elsewhere.

Toward #3127
2017-02-14 19:49:23 -08:00
Aaron Boodman
0b596da7be Add noms root command for getting and setting root of entire db (#2992)
* Add `noms root` command for getting and setting root of entire db

* fix missing import

* rebase, review feedback

* review feedback

* moar review
2017-01-30 17:34:06 -08:00
cmasone-attic
d809bb2a09 Increase Chunk locality when writing Values through ValueStore (#3064)
Readahead + NBS benefit greatly when "related" Chunks are close to
each other. The current code did a good job of writing siblings in the
Chunk graph next to each other, but "cousins" (that is, children whose
parents are siblings) might wind up spread quite far apart.  This
patch makes WriteValue hold onto novel Chunks until it sees a
_grandparent_ come through the pipeline. All of that Chunk's queued
grandchildren will be Put at that time.

Additionally, ValueStore.Flush() now takes a Hash and flushes all
Chunks that are reachable from the Chunk with that Hash, as opposed
to simply flushing all Chunks to the BatchStore. This means that
there's now no supported way to write orphaned Chunks/Values to a
Database.

Fixes #3051


* More logging for TestStreamingMap2
2017-01-23 12:16:55 -08:00
Rafael Weinstein
5fa5484f46 remove orederedparallel (#3050) 2017-01-10 15:45:05 -08:00
Aaron Boodman
a09ef6fb44 Revert "Introduce noms version 8. Use it to guard type simplification." (#3043) 2017-01-09 16:30:25 -08:00
Aaron Boodman
a4ffa5ba9b Introduce noms version 8. Use it to guard type simplification. (#3035)
Introduce noms version 8. Use it to guard type simplification.
2017-01-06 17:32:32 -08:00
cmasone-attic
ad3037f869 ValueStore writes chunks only when referenced (#3016)
The old strategy for writing values was to recursively encode them,
putting the resulting chunks into a BatchStore from the bottom up as
they were generated. The BatchStore implementation was responsible for
handling concurrency, so chunks from different Values would be
interleaved if the there were multiple calls to WriteValue happening
at the same time.

The new strategy tries to keep chunks from the same 'level' of a
graph together by caching chunks as they're encoded and only writing
them once they're referenced by some other value. When a collection
is written, the graph representing it is encoded recursively, and
chunks are generated bottom-up. The new strategy should, in practice,
mean that the children of a given parent node in this graph will be
cached until that parent gets written, and then they'll get written
all at once.
2017-01-04 12:19:10 -08:00
Aaron Boodman
b5f3c8bc4f add noms show --raw (#2991)
add noms show --raw
2016-12-26 11:38:46 -08:00
cmasone-attic
22d8e175f7 Modify httpBatchStore so that writing values maintains some locality (#2983)
NBS benefits from related chunks being near one another. Initially,
let's use write-order as a proxy for "related".

This patch contains a pretty heinous hack to allow sync to continue
putting chunks into httpBatchStore top-down without breaking
server-side validation. Work to fix this is tracked in #2982

This patch fixes #2968, at least for now

* Introduces PullWithFlush() to allow noms sync to explicitly
pull chunks over and flush directly after. This allows UpdateRoot
to behave as before.

Also clears out all the legacy batch-put machinery. Now, Flush()
just directly calls sendWriteRequests().
2016-12-23 11:48:42 -08:00
Aaron Boodman
8241483c19 noms show no longer shows type information (#2893)
If you want that, do `noms show <thing>@type`.

Fixes #2694
2016-12-02 08:58:51 -08:00
Ben Kalman
5e4c1c06d8 Remove noms-ui and update splore README.md (#2861) 2016-11-29 16:53:51 -08:00
Ben Kalman
cdfbee1b3d Remove spec GetDataset/GetDatabase/GetPath, update all clients (#2815)
These are now ForDataset/ForDatabase/ForPath.
2016-11-09 17:34:39 -08:00
cmasone-attic
f2ca3d6e8e Add noms merge (#2768)
Add optional merging functionality to noms commit.
noms merge <database> <left-dataset-name> <right-dataset-name> <output-dataset-name>

The command above will look in the given Database for the two named
Datasets and, if possible, merge their HeadValue()s and commit the
result back to <output-dataset-name>.

Fixes #2535
2016-10-27 15:27:36 -07:00
Erik Arvidsson
0eb940e50a First cut at noms migrate (#2594)
This iterates over all the values of the old version and creates new
values of the new version.

Closes #2428
Fixes #2272
2016-10-21 15:16:29 -07:00
Dan Willhite
d94fb97788 Move diff package to top-level go directory (#2739)
Towards #609.
2016-10-20 10:19:57 -07:00