/*
Returns a snapshot consolidated from the given snapshots. The resulting
object can be queried for various types of data.
960568
function knMergeSnapshots(snapshots)
{
	var rv, errors, srvname, i, snap;

	rv = new knSnapshot();
	errors = [];

	for (i = 0; i < snapshots.length; i++) {
		snap = snapshots[i];

		if (!('service' in snap)) {
			errors.push([ snap, 'missing "service" property' ]);
			continue;
		}

		srvname = snap['service']['name'];

		if ('component' in snap['service'])
			srvname += '.' + snap['service']['component'];

		snap['service']['source'] =
		    snap['source']['protocol'] + '://' +
		    snap['source']['host'] + ':' + snap['source']['port'] +
		    snap['source']['path'];
		srvname += '.' + snap['service']['ident'];
		rv.add('service', srvname, snap['service']);

		if ('stats' in snap)
			rv.add('stats', srvname, snap['stats']);

		if (!('types' in snap))
			continue;

		snap['types'].forEach(function (type) {
			var objects, key;

			objects = snap[type];

			for (key in objects) {
				objects[key]['origin'] = srvname;
				rv.add(type, key, objects[key]);
			}
		});
	}

	return (rv);
}
1017644
function( isUndo )
		{
			var snapshots = this.snapshots,
				currentImage = this.currentImage,
				image, i;

			if ( currentImage )
			{
				if ( isUndo )
				{
					for ( i = this.index - 1 ; i >= 0 ; i-- )
					{
						image = snapshots[ i ];
						if ( !currentImage.equals( image, true ) )
						{
							image.index = i;
							return image;
						}
					}
				}
				else
				{
					for ( i = this.index + 1 ; i < snapshots.length ; i++ )
					{
						image = snapshots[ i ];
						if ( !currentImage.equals( image, true ) )
						{
							image.index = i;
							return image;
						}
					}
				}
			}

			return null;
		}
78054
public Snapshot getCurrentSnapshot() {
    Map.Entry<Long, Snapshot> entry = snapshots.lastEntry();
    return entry != null ? entry.getValue() : null;
  }
399871
def annotate_snapshot(self, snapshot):
        
        if hasattr(snapshot, 'classes'):
            return

        snapshot.classes = {}

        for classname in list(self.index.keys()):
            total = 0
            active = 0
            merged = Asized(0, 0)
            for tobj in self.index[classname]:
                _merge_objects(snapshot.timestamp, merged, tobj)
                total += tobj.get_size_at_time(snapshot.timestamp)
                if tobj.birth < snapshot.timestamp and \
                    (tobj.death is None or tobj.death > snapshot.timestamp):
                    active += 1

            try:
                pct = total * 100.0 / snapshot.total
            except ZeroDivisionError: # pragma: no cover
                pct = 0
            try:
                avg = total / active
            except ZeroDivisionError:
                avg = 0

            snapshot.classes[classname] = dict(sum=total,
                                               avg=avg,
                                               pct=pct,
                                               active=active)
            snapshot.classes[classname]['merged'] = merged
858
private Map<String, Snapshot> getSnapshots() {
        /*
         * Use the individual snapshot directories instead of voltroot, because
         * they can be set individually
         */
        Map<String, SnapshotPathType> paths = new HashMap<String, SnapshotPathType>();
        if (VoltDB.instance().getConfig().m_isEnterprise) {
            if (m_clSnapshotPath != null) {
                paths.put(m_clSnapshotPath, SnapshotPathType.SNAP_CL);
            }
        }
        if (m_snapshotPath != null) {
            paths.put(m_snapshotPath, SnapshotPathType.SNAP_AUTO);
        }
        HashMap<String, Snapshot> snapshots = new HashMap<String, Snapshot>();
        FileFilter filter = new SnapshotUtil.SnapshotFilter();

        for (String path : paths.keySet()) {
            SnapshotUtil.retrieveSnapshotFiles(new File(path), snapshots, filter, false, paths.get(path), LOG);
        }

        return snapshots;
    }
290674
def get_snapshots(topology):
    
    snapshots = []
    snap_dir = os.path.join(topology_dirname(topology), 'snapshots')
    if os.path.exists(snap_dir):
        snaps = os.listdir(snap_dir)
        for directory in snaps:
            snap_top = os.path.join(snap_dir, directory, 'topology.net')
            if os.path.exists(snap_top):
                snapshots.append({'file': snap_top,
                                  'snapshot': True})
    return snapshots
603744
public GetSnapshotResponse getSnapshot(GetSnapshotRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getSnapshotId(), "request snapshotId should no be empty.");
        InternalRequest internalRequest =
                this.createRequest(request, HttpMethodName.GET, SNAPSHOT_PREFIX, request.getSnapshotId());
        return invokeHttpClient(internalRequest, GetSnapshotResponse.class);
    }
943619
def _get_snapshot(vm, snapshot_name):
        
        snapshots = SnapshotRetriever.get_vm_snapshots(vm)

        if snapshot_name not in snapshots:
            raise SnapshotNotFoundException('Snapshot {0} was not found'.format(snapshot_name))

        return snapshots[snapshot_name]
412302
public java.util.List<DBSnapshot> getDBSnapshots() {
        if (dBSnapshots == null) {
            dBSnapshots = new com.amazonaws.internal.SdkInternalList<DBSnapshot>();
        }
        return dBSnapshots;
    }
209823
function normalizeSnapshot() {
		snapshot.heap.forEach(function(obj) {
			if (!obj) return;
			if (obj.function && obj.function.type === 'BindFunc') {
				obj.function.target = convertUndefined(obj.function.target)
				obj.function.arguments = obj.function.arguments.map(convertUndefined)
			}
			if ('env' in obj) {
				obj.env = convertUndefined(obj.env)
			}
			if ('prototype' in obj) {
				obj.prototype = convertUndefined(obj.prototype)
			}
			for (var k in obj.properties) {
				var prty = obj.properties[k]
				if ('value' in prty) {
					prty.value = convertUndefined(prty.value)
				}
				if ('get' in prty) {
					prty.get = convertUndefined(prty.get)
				}
				if ('set' in prty) {
					prty.set = convertUndefined(prty.set)
				}
			}
		})
	}
815378
def get_snapshots(self,**kwargs):
        
        commits = self.repository.get_commits(**kwargs)
        snapshots = []
        for commit in commits:
            for key in ('committer_date','author_date'):
                commit[key] = datetime.datetime.fromtimestamp(commit[key+'_ts'])
            snapshot = GitSnapshot(commit)
            hasher = Hasher()
            hasher.add(snapshot.sha)
            snapshot.hash = hasher.digest.hexdigest()
            snapshot.project = self.project
            snapshot.pk = uuid.uuid4().hex
            snapshots.append(snapshot)
        return snapshots
343994
def get_snapshot(number=0, config='root'):
    '''
    
    '''
    try:
        snapshot = snapper.GetSnapshot(config, int(number))
        return _snapshot_to_data(snapshot)
    except dbus.DBusException as exc:
        raise CommandExecutionError(
            'Error encountered while retrieving snapshot: {0}'
            .format(_dbus_exception_to_reason(exc, locals()))
        )
750643
def find_snapshot(name)
      find_helper = lambda do |name, root|
        return nil if root.nil?
        return root if root.name == name || root.uuid == name

        root.children.each do |child|
          result = find_helper.call(name, child)
          return result unless result.nil?
        end

        nil
      end

      find_helper.call(name, root_snapshot)
    end
1132179
public function getSnapshot(): Snapshot
    {
        try {
            $value = $this->apiClient->get($this->getUri());
        } catch (ApiException $e) {
            throw QueryException::fromApiException($e, $this);
        }

        if ($this->sorter) {
            $value = $this->sorter->modifyValue($value);
        }

        foreach ($this->filters as $filter) {
            $value = $filter->modifyValue($value);
        }

        return new Snapshot($this->reference, $value);
    }
613937
protected synchronized void snapshotAll() {
        snapshotsManager.getAll().forEach(s -> {
            RepositorySnapshotter.SnapshotIdentifier id = s.prepare();
            s.snapshot(repository.getData(), id);
            s.commit(journalsStorage.getLastStoreVersion(), id);
        });
    }
691690
@Override
    public Restoration getBySnapshotId(String snapshotId)
        throws RestorationNotFoundException {
        List<Restoration> restorations = this.restoreRepo.findBySnapshotNameOrderByModifiedDesc(snapshotId);
        if (CollectionUtils.isEmpty(restorations)) {
            log.debug("Restoration returned null for snapshot id {}. Throwing exception...",
                      snapshotId);
            throw new RestorationNotFoundException(
                "No restorations associated with snapshot " + snapshotId);
        }

        return restorations.get(0);
    }
157795
protected void completeSnapshot(Snapshot snapshot) {
    Assert.notNull(snapshot, "snapshot");
    snapshots.put(snapshot.index(), snapshot);

    if (currentSnapshot == null || snapshot.index() > currentSnapshot.index()) {
      currentSnapshot = snapshot;
    }

    // Delete old snapshots if necessary.
    if (!storage.retainStaleSnapshots()) {
      Iterator<Map.Entry<Long, Snapshot>> iterator = snapshots.entrySet().iterator();
      while (iterator.hasNext()) {
        Snapshot oldSnapshot = iterator.next().getValue();
        if (oldSnapshot.index() < currentSnapshot.index()) {
          iterator.remove();
          oldSnapshot.close();
          oldSnapshot.delete();
        }
      }
    }
  }