Skip to content

Multi index#17

Merged
slackpad merged 1 commit intohashicorp:masterfrom
floridoo:multi-index
Dec 16, 2016
Merged

Multi index#17
slackpad merged 1 commit intohashicorp:masterfrom
floridoo:multi-index

Conversation

@floridoo
Copy link
Copy Markdown

See #15

@floridoo
Copy link
Copy Markdown
Author

No tests for now. If the approach is ok for you in general, I can add tests and a StringSliceFieldIndex.

txn.go Outdated
idSchema := tableSchema.Indexes[id]
ok, idVal, err := idSchema.Indexer.FromObject(obj)
idIndexer, ok := idSchema.Indexer.(SingleIndexer)
if !ok {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would push this check into the Validate of the schema, just so it can be avoided here

@armon
Copy link
Copy Markdown
Contributor

armon commented Feb 15, 2016

@floridoo I like the implementation, its moving the right way, left some feedback on cleanups for it!

@floridoo
Copy link
Copy Markdown
Author

@armon Updated and rebased the pull request, added StringSliceFieldIndex and tests

@vieux
Copy link
Copy Markdown

vieux commented Mar 22, 2016

@floridoo works great for my usecase, thanks!

@vieux
Copy link
Copy Markdown

vieux commented Mar 23, 2016

@armon do you plan to merge this anytime soon ? :)

@aluzzardi
Copy link
Copy Markdown

Hey @armon, any way to move this forward?

We temporarily switched to @floridoo's fork (moby/swarmkit#1728) to use this feature but we'd very much prefer to move back to mainline.

This feature allows us to handle many to many relationships and without it we had to resort to a very costly linear scan.

This is our use case, maybe there's a better way to do this: a container can reference multiple networks and a network can be referenced by multiple containers. When removing a network, we want to figure out if any container is referencing it (sanity check to avoid dangling references).

With multi index, we can simply create a container indexer that returns all network IDs the container is referencing. When deleting a network, we just lookup the container table by network ID.

Without it, we have to scan all containers (there can be a ton) and manually check if they reference the network.

@slackpad
Copy link
Copy Markdown
Contributor

slackpad commented Nov 2, 2016

Hey @floridoo sorry for the delay on this one - it got buried under some things. I'll review this week.

@slackpad
Copy link
Copy Markdown
Contributor

Thanks @floridoo - finally had some time to review and close this out!

@slackpad slackpad mentioned this pull request Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants