-
Notifications
You must be signed in to change notification settings - Fork 861
getScopingInfo utility added #3118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/PopContaining.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.tinkerpop.gremlin.process.traversal.step; | ||
|
|
||
| import java.util.Objects; | ||
| import java.util.Set; | ||
|
|
||
| import org.apache.tinkerpop.gremlin.process.traversal.Pop; | ||
|
|
||
| /** | ||
| * The {@code PopContaining} interface is implemented by traversal steps that maintain Pop instructions | ||
| * for label access. It provides a mechanism to track and manage how labeled elements should | ||
| * be accessed using {@link Pop} semantics (first, last, all, or mixed). | ||
| * | ||
| * In Gremlin traversals, various elements can be labeled and later accessed via these labels. | ||
| * The {@link Pop} enum determines how to access these labeled elements when there are multiple | ||
| * values associated with the same label. | ||
| * | ||
| * <pre> | ||
| * {@code | ||
| * // Simple example with default Pop.last behavior | ||
| * gremlin> g.V().as("a").out().as("a").select("a") | ||
| * ==>[v[2]] // returns the last element labeled "a" | ||
| * | ||
| * // Using Pop.first to get the first labeled element | ||
| * gremlin> g.V().as("a").out().as("a").select(first, "a") | ||
| * ==>[v[1]] // returns the first element labeled "a" | ||
| * | ||
| * // Using Pop.all to get all labeled elements | ||
| * gremlin> g.V().as("a").out().as("a").select(all, "a") | ||
| * ==>[v[1], v[2]] // returns all elements labeled "a" | ||
| * } | ||
| * </pre> | ||
| * | ||
| * Steps implementing this interface maintain a collection of {@link PopInstruction} objects, each containing | ||
| * a label and a {@link Pop} value that specifies how to access elements with that label. | ||
| * | ||
| */ | ||
| public interface PopContaining { | ||
| public Set<PopInstruction> getPopInstructions(); | ||
| /** | ||
| * A class for storing the Scope Context. It has two elements: | ||
| * - label: String | ||
| * - pop: Pop value | ||
| */ | ||
| class PopInstruction { | ||
| private final Pop pop; | ||
| private final String label; | ||
|
|
||
| public PopInstruction(String label, Pop pop) { | ||
| this.pop = pop; | ||
| this.label = label; | ||
| } | ||
|
|
||
| public PopInstruction(final Pop pop, final String label) { | ||
| this.pop = pop; | ||
| this.label = label; | ||
| } | ||
|
|
||
| public PopInstruction() { | ||
| this.pop = null; | ||
| this.label = ""; | ||
| } | ||
|
|
||
| public String getLabel() { | ||
| return label; | ||
| } | ||
|
|
||
| public Pop getPop() { | ||
| return pop; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| final PopInstruction that = (PopInstruction) o; | ||
| return getPop() == that.getPop() && Objects.equals(getLabel(), that.getLabel()); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(getPop(), getLabel()); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.