Skip to content

Commit

Permalink
Introduce split identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
shixuan-fan committed Oct 1, 2020
1 parent a1b9176 commit 069629b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
10 changes: 10 additions & 0 deletions presto-hive/src/main/java/com/facebook/presto/hive/HiveSplit.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ public Object getInfo()
.build();
}

@Override
public Object getSplitIdentifier()
{
return ImmutableMap.builder()
.put("path", path)
.put("start", start)
.put("length", length)
.build();
}

@Override
public OptionalLong getSplitSizeInBytes()
{
Expand Down
47 changes: 47 additions & 0 deletions presto-main/src/main/java/com/facebook/presto/metadata/Split.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public NodeSelectionStrategy getNodeSelectionStrategy()
return connectorSplit.getNodeSelectionStrategy();
}

public SplitIdentifier getSplitIdentifier()
{
return new SplitIdentifier(connectorId, connectorSplit.getSplitIdentifier());
}

@Override
public String toString()
{
Expand Down Expand Up @@ -139,4 +144,46 @@ public int hashCode()
// Requires connectorSplit's hash function to be set up correctly
return Objects.hash(connectorId, transactionHandle, connectorSplit, lifespan);
}

public static class SplitIdentifier
{
public final ConnectorId connectorId;
public final Object splitIdentifier;

public SplitIdentifier(ConnectorId connectorId, Object splitIdentifier)
{
this.connectorId = requireNonNull(connectorId, "connectorId is null");
this.splitIdentifier = requireNonNull(splitIdentifier, "splitIdentifier is null");
}

public ConnectorId getConnectorId()
{
return connectorId;
}

public Object getSplitIdentifier()
{
return splitIdentifier;
}

@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SplitIdentifier that = (SplitIdentifier) o;
return Objects.equals(connectorId, that.connectorId) &&
Objects.equals(splitIdentifier, that.splitIdentifier);
}

@Override
public int hashCode()
{
return Objects.hash(connectorId, splitIdentifier);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public interface ConnectorSplit

Object getInfo();

// TODO: Make similar changes like getInfo. Please comment if not addressed once PR is marked as ready for review
default Object getSplitIdentifier()
{
return this;
}

default OptionalLong getSplitSizeInBytes()
{
return OptionalLong.empty();
Expand Down

0 comments on commit 069629b

Please sign in to comment.