Commit Graph

12 Commits

Author SHA1 Message Date
Durham Goode
4a0a22abdc ctree: implement treemanifest_copy
Summary:
This implements the copy function, which will be used to create a copy of a
parent manifest when beginning to create a new manifest.

Test Plan:
Used in conjunction with future diffs to serialize a new treemanifest
into a pack file.

Reviewers: #fastmanifest, ttung

Reviewed By: ttung

Subscribers: ttung, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3837415

Signature: t1:3837415:1473453896:494fc856256764f14741c65258f354e08383f1f7
2016-09-12 11:44:47 -07:00
Tony Tung
430b9a37ec [ctree] get rid of the remaining magic numbers for hash size (bin and hex)
Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3837310

Signature: t1:3837310:1473377616:d6c917e93efd3b64cebe4ac05fb60f966283b3ab
2016-09-10 16:27:53 -07:00
Tony Tung
54195bfd97 [ctree] method to update a manifest entry's node and flags
Summary: This is needed when we're updating a node that already exists.

Test Plan: used in later diff.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3832631

Signature: t1:3832631:1473362920:8a39f02ced91cc9328c57e416d7dfc9a704b0cc6
2016-09-08 13:39:48 -07:00
Tony Tung
65ccf8ee98 [ctree] change how ManifestEntry.initialize works to match initialization from flat text
Summary:
flags should be == NULL if it's not present, not that it points to NULL.

Since the flags pointer isn't always set, we have to use the filename pointer to set the separator field ('\n').

Test Plan: used in later diff.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3832555

Signature: t1:3832555:1473359723:9f05dd353f0c1866232214cd0d489d1fb4573f51
2016-09-08 13:34:56 -07:00
Tony Tung
3c8381a899 [cfastmanifest] only create a Manifest object for ManifestEntry::initialize if it's a directory
Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3803565

Signature: t1:3803565:1472759508:750a6c87d271260df7d6a3af1e1de48707145839
2016-09-06 12:40:15 -07:00
Tony Tung
96a13a14bf [ctreemanifest] const-ify the manifest directory flag
Summary:
DRY.  Also, it's safer.

Depends on D3772947

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3796249

Signature: t1:3796249:1472663415:944a5209e0fecd0f9e6a5c54bf40df430b53016e
2016-09-06 12:38:54 -07:00
Tony Tung
5e5270d3a7 [ctree] initialize the ManifestEntry in addChild after adding to the list
Summary: When a ManifestEntry is destroyed, we reap the heap-allocated resources it holds.  However, this (erroneously) happens when we create a ManifestEntry and add it to the list of children.  What we really need is a move constructor from C++11.  The workaround is to initialize a blank ManifestEntry, add it to the proper location, and then populate it afterwards.

Test Plan: addChild (in a later diff) no longer tramples over memory it no longer owns.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3772915

Signature: t1:3772915:1472174144:a4baac5cb5f6e01a38042c5c6cd92570c8f8e100
2016-08-26 13:49:17 -07:00
Tony Tung
13ec463298 [ctree] a newly instantiated ManifestEntry should point to a new Manifest
Test Plan: haven't used this yet, but it makes a whole lot of sense.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3770366

Signature: t1:3770366:1472173969:b83e10e27a63b863a3566d2df7cc861417b8208e
2016-08-26 13:49:17 -07:00
Tony Tung
a6bc389217 [ctree] free memory when destroying a treemanifest object
Summary: Everyone who holds heap-allocated memory gets destructors!

Test Plan: valgrind and confirmed no memory leaking from ctreemanifest

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3763327

Tasks: 12818084

Signature: t1:3763327:1472105103:8ac9d9694be4bf3b09e19e4381737622c94a2dac
2016-08-26 14:00:37 -07:00
Tony Tung
75c02e78a9 [ctree] initialize all the fields in ManifestEntry constructor
Summary: It makes a destructor possible.

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3763322

Signature: t1:3763322:1472104242:e76ef1943c2082ddecff872c6472de4706505922
2016-08-26 13:49:17 -07:00
Tony Tung
e953a3cc27 [ctree] get rid of manifestkey
Summary: Directly pass in the path + len and the node.  Note that the path is now a char* + len, because this allows us to use the path in treemanifest_find directly, rather than to construct a new path.

Test Plan: run existing perftest without crash.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3738280

Signature: t1:3738280:1471890923:c13283f1c61dc020ba1918ee9b25c24dfd2fc19b
2016-08-22 15:42:03 -07:00
Tony Tung
33f0d41725 [ctree] modularize the code
Summary:
I like many small files.

There is one place where I'm making a functional change (convert.h) to satisfy angry compilers.

Test Plan: make local.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3732584

Signature: t1:3732584:1471542758:d0b7804753ea4fd39a507090338ae3c5104dc7fa
2016-08-22 15:40:56 -07:00