Attempt to refresh "segmentSignatures" for a set of segments for a particular dataSource. Returns the set of
segments actually refreshed, which may be a subset of the asked-for set.
760418
private Set<DataSegment> refreshSegmentsForDataSource(final String dataSource, final Set<DataSegment> segments)
      throws IOException
  {
    log.debug("Refreshing metadata for dataSource[%s].", dataSource);

    final long startTime = System.currentTimeMillis();

    // Segment id -> segment object.
    final Map<String, DataSegment> segmentMap = Maps.uniqueIndex(segments, segment -> segment.getId().toString());

    final Set<DataSegment> retVal = new HashSet<>();
    final Sequence<SegmentAnalysis> sequence = runSegmentMetadataQuery(
        queryLifecycleFactory,
        Iterables.limit(segments, MAX_SEGMENTS_PER_QUERY),
        escalator.createEscalatedAuthenticationResult()
    );

    Yielder<SegmentAnalysis> yielder = Yielders.each(sequence);

    try {
      while (!yielder.isDone()) {
        final SegmentAnalysis analysis = yielder.get();
        final DataSegment segment = segmentMap.get(analysis.getId());

        if (segment == null) {
          log.warn("Got analysis for segment[%s] we didn't ask for, ignoring.", analysis.getId());
        } else {
          synchronized (lock) {
            final RowSignature rowSignature = analysisToRowSignature(analysis);
            log.debug("Segment[%s] has signature[%s].", segment.getId(), rowSignature);
            final Map<DataSegment, AvailableSegmentMetadata> dataSourceSegments =
                segmentMetadataInfo.get(segment.getDataSource());
            if (dataSourceSegments == null) {
              log.warn("No segment map found with datasource[%s], skipping refresh", segment.getDataSource());
            } else {
              final AvailableSegmentMetadata segmentMetadata = dataSourceSegments.get(segment);
              if (segmentMetadata == null) {
                log.warn(
                    "No segment[%s] found, skipping refresh",
                    segment.getId()
                );
              } else {
                final AvailableSegmentMetadata updatedSegmentMetadata = AvailableSegmentMetadata
                    .from(segmentMetadata)
                    .withRowSignature(rowSignature)
                    .withNumRows(analysis.getNumRows())
                    .build();
                dataSourceSegments.put(segment, updatedSegmentMetadata);
                setAvailableSegmentMetadata(segment, updatedSegmentMetadata);
                retVal.add(segment);
              }
            }
          }
        }

        yielder = yielder.next(null);
      }
    }
    finally {
      yielder.close();
    }

    log.info(
        "Refreshed metadata for dataSource[%s] in %,d ms (%d segments queried, %d segments left).",
        dataSource,
        System.currentTimeMillis() - startTime,
        retVal.size(),
        segments.size() - retVal.size()
    );

    return retVal;
  }
767320
def do_refresh(self,args):
        """"""
        self.wrappedStack = self.wrapStack(AwsConnectionFactory.instance.getCfResource().Stack(self.wrappedStack['rawStack'].name))
374130
@Override
    public List<PendingEvent> getUnackedEventsOnSeal() {
        // close connection and update the exception to SegmentSealed, this ensures future writes receive a
        // SegmentSealedException.
        log.debug("GetUnackedEventsOnSeal called on {}", writerId);
        synchronized (writeOrderLock) {   
            state.failConnection(new SegmentSealedException(this.segmentName));
            return Collections.unmodifiableList(state.getAllInflightEvents());
        }
    }
1289543
def segments(name)
      result = call("segments", "segments", {:name => name})

      result["segments"].collect {|item| Segment.new(self, item)}
    end
400219
def get_segments(segment_id=None):
    """"""
    session = db.get_reader_session()
    with session.begin():
        model = segment_models.NetworkSegment
        segments = session.query(model).filter_unnecessary_segments()
        if segment_id:
            segments = segments.filter(model.id == segment_id)
    return segments.all()
71127
def get_segments(ptrms, ptrm_checks, tmax):
    
    ptrms_included = []
    checks_included = []
    ptrms = numpy.array(ptrms)
    for ptrm in ptrms:
        if ptrm[0] <= tmax:
            ptrms_included.append(ptrm)
    for check in ptrm_checks:
        if check[0] <= tmax:
            checks_included.append(check)
    #print "checks", ptrm_checks
    #print "checks_included", checks_included
    return ptrms_included, checks_included
1323353
private SegmentMetadataUpdateTransaction getOrCreateSegmentUpdateTransaction(String segmentName, long segmentId) {
        SegmentMetadataUpdateTransaction sm = tryGetSegmentUpdateTransaction(segmentId);
        if (sm == null) {
            SegmentMetadata baseSegmentMetadata = createSegmentMetadata(segmentName, segmentId);
            sm = new SegmentMetadataUpdateTransaction(baseSegmentMetadata, this.recoveryMode);
            this.segmentUpdates.put(segmentId, sm);
        }

        return sm;
    }
528225
public boolean loadSegment(final DataSegment segment) throws SegmentLoadingException
  {
    final Segment adapter = getAdapter(segment);

    final SettableSupplier<Boolean> resultSupplier = new SettableSupplier<>();

    // compute() is used to ensure that the operation for a data source is executed atomically
    dataSources.compute(
        segment.getDataSource(),
        (k, v) -> {
          final DataSourceState dataSourceState = v == null ? new DataSourceState() : v;
          final VersionedIntervalTimeline<String, ReferenceCountingSegment> loadedIntervals =
              dataSourceState.getTimeline();
          final PartitionHolder<ReferenceCountingSegment> entry = loadedIntervals.findEntry(
              segment.getInterval(),
              segment.getVersion()
          );

          if ((entry != null) && (entry.getChunk(segment.getShardSpec().getPartitionNum()) != null)) {
            log.warn("Told to load an adapter for segment[%s] that already exists", segment.getId());
            resultSupplier.set(false);
          } else {
            loadedIntervals.add(
                segment.getInterval(),
                segment.getVersion(),
                segment.getShardSpec().createChunk(new ReferenceCountingSegment(adapter))
            );
            dataSourceState.addSegment(segment);
            resultSupplier.set(true);
          }
          return dataSourceState;
        }
    );

    return resultSupplier.get();
  }
1258294
def reset
      segments = CrawlSegment.where('crawl_id = ? and parse_time is not null',
                                    self.id)
      segments.map { |segment| segment.update_attribute(:parse_time, nil) }

      status
    end
710987
public void refreshCachedValues() {
        if (noteColumn) {
            note = getHistoryReference().hasNote();
        }
        if (tagsColumn) {
            tags = listToCsv(getHistoryReference().getTags());
        }
        if (highestAlertColumn) {
            alertRiskCellItem = AlertRiskTableCellItem.getItemForRisk(getHistoryReference().getHighestAlert());
        }
    }
559858
def verts_in_common(self, segments):
        
        verts_by_segm = self.verts_by_segm
        return sorted(reduce(lambda s0, s1: s0.intersection(s1),
                             [set(verts_by_segm[segm]) for segm in segments]))
728661
def _get_matchable_segments(segments):
    
    for subsegment in segments:
        if isinstance(subsegment, Token):
            break # No tokens allowed next to segments
        if isinstance(subsegment, Segment):
            if isinstance(subsegment, MatchableSegment):
                yield subsegment

            for matchable_subsegment in _get_matchable_segments(subsegment):
                yield matchable_subsegment
934015
def _get_data_segments(channels, start, end, connection):
    
    allsegs = io_nds2.get_availability(channels, start, end,
                                       connection=connection)
    return allsegs.intersection(allsegs.keys())
1242842
def refresh(self, serviceDefinition=True):
        
        url = self._url + "/MapServer/refresh"
        params = {
            "f" : "json",
            "serviceDefinition" : serviceDefinition
        }

        res =  self._post(url=self._url,
                             param_dict=params,
                             securityHandler=self._securityHandler,
                             proxy_url=self._proxy_url,
                             proxy_port=self._proxy_port)
        self.__init()
        return res
340937
synchronized void refresh(RollingSegmentHandle source) {
        Preconditions.checkArgument(source.getSegmentName().equals(this.getSegmentName()), "SegmentName mismatch.");
        if (this.readOnly == source.readOnly) {
            // Update the header handle, but only if both this handle and the source one have the same read-only flag.
            // Otherwise we risk attaching a read-only header handle to a read-write handle or vice-versa.
            this.headerHandle = source.headerHandle;
        }

        this.segmentChunks = new ArrayList<>(source.chunks());
        setHeaderLength(source.getHeaderLength());
        if (source.isSealed()) {
            markSealed();
        }
        if (source.isDeleted()) {
            markDeleted();
        }
    }
708499
def collect_segment_partitions(self):
        
        from collections import defaultdict

        # Group the segments by their parent partition name, which is the
        # same name, but without the segment.
        partitions = defaultdict(set)
        for p in self.dataset.partitions:
            if p.type == p.TYPE.SEGMENT:
                name = p.identity.name
                name.segment = None
                partitions[name].add(p)

        return partitions
221499
private void updateMetadata(SegmentProperties segmentProperties) {
        this.metadata.setStorageLength(segmentProperties.getLength());
        if (segmentProperties.isSealed() && !this.metadata.isSealedInStorage()) {
            this.metadata.markSealed();
            this.metadata.markSealedInStorage();
        }
    }