use of io.pravega.client.segment.impl.SegmentInfo in project pravega by pravega.
the class RevisionedStreamClientImpl method readFrom.
@Override
public Iterator<Entry<Revision, T>> readFrom(Revision start) {
synchronized (lock) {
long startOffset = start.asImpl().getOffsetInSegment();
SegmentInfo segmentInfo = meta.getSegmentInfo();
long endOffset = segmentInfo.getWriteOffset();
if (startOffset < segmentInfo.getStartingOffset()) {
throw new TruncatedDataException("Data at the supplied revision has been truncated.");
}
log.trace("Creating iterator from {} until {}", startOffset, endOffset);
return new StreamIterator(startOffset, endOffset);
}
}
use of io.pravega.client.segment.impl.SegmentInfo in project pravega by pravega.
the class BatchClientImpl method getSegmentRange.
/*
* Given a segment, fetch its SegmentRange.
* - If segment is part of startStreamCut / endStreamCut update startOffset and endOffset accordingly.
* - If segment is not part of the streamCuts fetch the data using SegmentMetadataClient.
*/
private SegmentRange getSegmentRange(final Segment segment, final StreamCut startStreamCut, final StreamCut endStreamCut) {
SegmentRangeImpl.SegmentRangeImplBuilder segmentRangeBuilder = SegmentRangeImpl.builder().segment(segment);
if (startStreamCut.asImpl().getPositions().containsKey(segment) && endStreamCut.asImpl().getPositions().containsKey(segment)) {
// use the meta data present in startStreamCut and endStreamCuts.
segmentRangeBuilder.startOffset(startStreamCut.asImpl().getPositions().get(segment)).endOffset(endStreamCut.asImpl().getPositions().get(segment));
} else {
// use segment meta data client to fetch the segment offsets.
SegmentInfo r = segmentToInfo(segment);
segmentRangeBuilder.startOffset(startStreamCut.asImpl().getPositions().getOrDefault(segment, r.getStartingOffset())).endOffset(endStreamCut.asImpl().getPositions().getOrDefault(segment, r.getWriteOffset()));
}
return segmentRangeBuilder.build();
}
Aggregations