text:
package com.ds.master.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.ds.master.R;
import com.ds.master.adapter.FileListViewAdapter;
import com.ds.master.bean.FileInfo;
import com.ds.master.utils.FileIconAndType;
import com.ds.master.view.TitleBarView;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/10/25.
 */

public class FileActivity extends BaseActivity{

    private Intent intent;
    private TitleBarView mTbnFileItemTitle;
    private TextView mTvFileCount;
    private TextView mTvFileSpace;
    private ListView mLvFileShow;
    private FileListViewAdapter fileListViewAdapter;

    private void assignViews() {
        mTbnFileItemTitle = (TitleBarView) findViewById(R.id.tbn_file_item_title);
        mTvFileCount = (TextView) findViewById(R.id.tv_file_count);
        mTvFileSpace = (TextView) findViewById(R.id.tv_file_space);
        mLvFileShow = (ListView) findViewById(R.id.lv_file_show);
    }

    @Override
    protected void initView() {
        setContentView(R.layout.activity_file);
        assignViews();
    }

    @Override
    protected void initData() {
        intent = getIntent();

        mTbnFileItemTitle.setTopTitleText(intent.getStringExtra("title"));
        getIntent().getBundleExtra("data");
        ArrayList<FileInfo> list = (ArrayList<FileInfo>) getIntent().getSerializableExtra("list");
        String size = getIntent().getStringExtra("size");
        if(list != null){
            mTvFileCount.setText(list.size()+" 个");
        }
        if (size != null){
            mTvFileSpace.setText(size);
        }

        switch (getIntent().getStringExtra("type")){
            case FileIconAndType.TYPE_ALL:

                break;
            case FileIconAndType.TYPE_TXT:

                break;
            case FileIconAndType.TYPE_VIDEO:

                break;
            case FileIconAndType.TYPE_AUDIO:

                break;
            case FileIconAndType.TYPE_IMAGE:

                break;
            case FileIconAndType.TYPE_ZIP:

                break;
            case FileIconAndType.TYPE_APK:

                break;
        }

        //获取数据

        fileListViewAdapter = new FileListViewAdapter(this);
        fileListViewAdapter.setList(list);
        fileListViewAdapter.notifyDataSetChanged();
        mLvFileShow.setAdapter(fileListViewAdapter);

    }

    @Override
    protected void setListener() {
        mTbnFileItemTitle.setOnClickListener(listener);
    }

    private View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.ib_top_title_left:
                    finish();
                    break;
            }
        }
    };
}


text: {% include "logined/admintemplates/charts/3dpie_charts.html" %}

redpajama_set_name: RedPajamaGithub


text:
class RenameOrganizationsToOrganisations < ActiveRecord::Migration
  def change
    rename_table :organizations, :organisations
  end
end


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Method GetRequestTokenAsync
   </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="Method GetRequestTokenAsync
   ">
    <meta name="generator" content="docfx 2.52.0.0">

    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" href="../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../styles/docfx.css">
    <link rel="stylesheet" href="../styles/main.css">
    <meta property="docfx:navrel" content="../toc.html">
    <meta property="docfx:tocrel" content="toc.html">

              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                Toggle navigation

              </button>

              <form class="navbar-form navbar-right" role="search" id="search">

                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">

              </form>

          Show / Hide Table of Contents

Method GetRequestTokenAsync

  |
  Improve this Doc

  View Source

GetRequestTokenAsync(String)

Asynchronously gets a request token.

Declaration

public Task<Token> GetRequestTokenAsync(string callbackUrl)

Parameters

      Type
      Name
      Description

      System.String
      callbackUrl

The server redirects Users to this URL after they authorize access to their private data.

Returns

      Type
      Description

      System.Threading.Tasks.Task<Token>

The request token.

Remarks

The Consumer obtains an unauthorized Request Token by asking the Service Provider to issue a Token.
The Request Token's sole purpose is to receive User approval and can only be used to obtain an Access Token.

Exceptions

      Type
      Condition

      System.ArgumentNullException

callbackUrl is null.

      System.ArgumentException

callbackUrl is empty.

      OAuthException

		Could not determine oauth_token and oauth_token_secret from server response.

	An exception occurred during the method call.

                    Improve this Doc

                    View Source

              Back to top

            Generated by DocFX


text:
using System;

namespace Plugin.Threading
{
    public partial class UIThreadRunInvoker
    {
        public void BeginInvokeOnUIThread(Action action)
        {
            #if NETFX_CORE && WINDOWS_PHONE       // Windows Phone WinRT 8.1
            // using Windows.ApplicationModel.Core;
            var dispatcher =
                Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;
            dispatcher.RunAsync
                             (
                                Windows.UI.Core.CoreDispatcherPriority.Normal,
                                delegate
                                {
                                    action();
                                }
                             );
            #endif

            return;
        }
    }
}


text:
var supertest = require('supertest');
var request = require('request');
var assert = require('assert');
var proxy = require('..');
var setup = require('./setup');

describe('request abortion', function() {
  var self;
  var fullyExecuted = false;
  var postCount = 0;
  var remoteRequestDelay = 50;

  beforeEach(setup.beforeEach);
  afterEach(setup.afterEach);

  beforeEach(function() {
    this.remoteApi.get('/longRoute', function(req, res) {
      var closedBeforeSend = false;
      req.on('close', function() {
        closedBeforeSend = true;
      })
      setTimeout(function() {
        fullyExecuted = !closedBeforeSend;
        res.send({status: true});
      }, remoteRequestDelay);
    });
    this.remoteApi.post('/postCounter', function(req, res) {
      postCount++;
      res.send({status: true});
    });
    this.server.get('/proxyLongRoute', proxy({
      url: 'http://localhost:' + this.apiPort + '/longRoute',
      cache: false
    }));
    this.server.post('/proxyPostCounter', proxy({
      url: 'http://localhost:' + this.apiPort + '/postCounter',
      cache: false
    }));
  });

  it('should process the remote api request fully if client do not close prematurely connection', function(done) {
    fullyExecuted = false;
    supertest(this.server)
      .get('/proxyLongRoute')
      .expect(200)
      .end(function(err, res) {
        if (!fullyExecuted) return done(new Error('Not fully executed'));
        done();
      });
  });

  it('should cancel the remote api request fully if client do not close prematurely connection', function(done) {
    var self = this;
    this.server.listen(this.apiPort + 1, function() {
      fullyExecuted = false;
      var req = request({
        url: 'http://localhost:' + (self.apiPort + 1) + '/proxyLongRoute'
      });
      // Abort main request after 250ms.
      setTimeout(function() { req.abort(); }, remoteRequestDelay / 2);
      setTimeout(function() {
        if (!fullyExecuted) return done();
        done(new Error('Request has not been closed.'));
      }, remoteRequestDelay + 10);
    });
  });

  it('should call the remote api request only once when request has a body', function(done) {
    postCount = 0;
    supertest(this.server)
      .post('/proxyPostCounter')
      .set('Content-Type', 'application/json')
      .send({sample: 'content'})
      .expect(200)
      .end(function(err, res) {
        setTimeout(() => {
          assert.equal(postCount, 1);
          done();
        }, 50);
      });
  });
});


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>DB_ENV->repmgr_add_remote_site()</title>
    <link rel="stylesheet" href="apiReference.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB C API Reference" />
    <link rel="up" href="rep.html" title="Chapter 10.  Replication Methods" />
    <link rel="prev" href="repsync.html" title="DB_ENV->rep_sync()" />
    <link rel="next" href="repmgrget_ack_policy.html" title="DB_ENV->repmgr_get_ack_policy()" />

          DB_ENV->repmgr_add_remote_site()

          Prev
          Chapter 10.
                Replication Methods

           Next

DB_ENV->repmgr_add_remote_site()

#include <db.h>

int
DB_ENV->repmgr_add_remote_site(DB_ENV *env,
    const char *host, u_int port, int *eidp, u_int32_t flags);

         The DB_ENV->repmgr_add_remote_site() method adds a new replication
         site to the Replication Manager's list of known sites.  It is not
         necessary for all sites in a replication group to know about all other
         sites in the group.

         The DB_ENV->repmgr_add_remote_site() method may be called at any time
         during the life of the application.

         The DB_ENV->repmgr_add_remote_site()

                  method returns a non-zero error value on failure and 0 on success.

Parameters

eidp

                         If eidp is non-NULL, and the database
                         environment has already been opened by calling
                         DB_ENV->open(), then the environment
                         ID assigned to the remote site is returned in the memory location
                         referenced by eidp.

flags

                          The flags parameter must be set to 0
                          or by bitwise inclusively OR'ing
                          together one or more of the following values:

                        DB_REPMGR_PEER

                        Specifying the DB_REPMGR_PEER flag configures client-to-client
                        synchronization with the specified remote site.

                        Currently, the Replication Manager framework only supports a single
                        client peer, and the last specified peer is used.

host

                          The site's host identification string, generally a TCP/IP host name.

port

                          The port number on which the remote site is receiving.

Errors

            The DB_ENV->repmgr_add_remote_site()

                 method may fail and return one of the following non-zero errors:

EINVAL

                If this method is called from a base replication API
                application; or if an invalid flag value or parameter was
                specified.

Class

                DB_ENV

See Also

                     Replication and Related Methods

          Prev

            Up

           Next

          DB_ENV->rep_sync()

            Home

           DB_ENV->repmgr_get_ack_policy()


text:
package jp.co.future.uroborosql.mapping;

import java.time.LocalDate;
import java.util.Optional;

public class TestDataNoKeyEntity {
	private long id;
	private String name;
	private int age;
	private LocalDate birthday;
	private Optional<String> memo;

	public TestDataNoKeyEntity() {
	}

	public TestDataNoKeyEntity(final long id, final String name, final int age, final LocalDate birthday,
			final Optional<String> memo) {
		this.id = id;
		this.name = name;
		this.age = age;
		this.birthday = birthday;
		this.memo = memo;
	}

	/**
	 * id を取得します。
	 *
	 * @return id
	 */
	public long getId() {
		return id;
	}

	/**
	 * id を設定します。
	 *
	 * @param id id
	 */
	public void setId(final long id) {
		this.id = id;
	}

	/**
	 * name を取得します。
	 *
	 * @return name
	 */
	public String getName() {
		return name;
	}

	/**
	 * name を設定します。
	 *
	 * @param name name
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * age を取得します。
	 *
	 * @return age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * age を設定します。
	 *
	 * @param age age
	 */
	public void setAge(final int age) {
		this.age = age;
	}

	/**
	 * birthday を取得します。
	 *
	 * @return birthday
	 */
	public LocalDate getBirthday() {
		return birthday;
	}

	/**
	 * birthday を設定します。
	 *
	 * @param birthday birthday
	 */
	public void setBirthday(final LocalDate birthday) {
		this.birthday = birthday;
	}

	/**
	 * memo を取得します。
	 *
	 * @return memo
	 */
	public Optional<String> getMemo() {
		return memo;
	}

	/**
	 * memo を設定します。
	 *
	 * @param memo memo
	 */
	public void setMemo(final Optional<String> memo) {
		this.memo = memo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + age;
		result = prime * result + (birthday == null ? 0 : birthday.hashCode());
		result = prime * result + (int) (id ^ id >>> 32);
		result = prime * result + (memo == null ? 0 : memo.hashCode());
		result = prime * result + (name == null ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		TestDataNoKeyEntity other = (TestDataNoKeyEntity) obj;
		if (age != other.age) {
			return false;
		}
		if (birthday == null) {
			if (other.birthday != null) {
				return false;
			}
		} else if (!birthday.equals(other.birthday)) {
			return false;
		}
		if (id != other.id) {
			return false;
		}
		if (memo == null) {
			if (other.memo != null) {
				return false;
			}
		} else if (!memo.equals(other.memo)) {
			return false;
		}
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "TestDataNoKeyEntity [id=" + id + ", name=" + name + ", age=" + age + ", birthday=" + birthday
				+ ", memo=" + memo + "]";
	}

}


text:
require 'spec_helper'

describe Answer do
  subject { described_class}

  let(:obj) { double }

  describe '#success?' do
    context 'nil' do
      context 'activerecord-like object with #errors' do
        let(:obj) { double(errors: errors) }

        context 'without errors' do
          let(:errors) { [] }

          it 'succeeds' do
            expect(subject.new(obj).success?).to eq(true)
          end
        end

        context 'with errors' do
          let(:errors) { { base: [ 'error' ] } }

          it 'fails' do
            expect(subject.new(obj).success?).to eq(false)
          end
        end
      end

      context 'object is nil' do
        it 'fails' do
          expect(subject.new(nil).success?).to eq(false)
        end
      end

      context 'object not responding to errors' do
        it 'defaults to true' do
          expect(subject.new(obj).success?).to eq(true)
        end
      end
    end

    context 'explicit value' do
      let(:success) { 'asdf' }

      it 'returns whatever boolean the value evaluates to' do
        expect(subject.new(obj, success).success?).to eq(!!success)
      end
    end
  end

  describe '#object' do
    context 'success' do
      it 'returns object' do
        expect(subject.new(obj).object).to eq(obj)
      end
    end

    context 'failure' do
      let(:errors) { { base: [ 'error' ] } }

      shared_examples 'error responder' do
        it 'returns a hash with errors' do
          expect(subject.new(obj, false).object).to eq(errors: errors)
        end
      end

      context 'responding to #errors' do
        let(:obj) { double(errors: errors) }

        it_behaves_like 'error responder'
      end

      context 'is a Hash' do
        let(:obj) { errors }

        it_behaves_like 'error responder'
      end

      context 'is an Array' do
        let(:obj) { errors[:base] }

        it_behaves_like 'error responder'
      end

      context 'is just a string' do
        let(:obj) { errors[:base].first }

        it_behaves_like 'error responder'
      end
    end

    context 'object is nil' do
      it 'returns a hash with an "error not found" message' do
        expect(subject.new(nil).object).to eq(
          errors: { base: ['Record not found'] }
        )
      end
    end
  end

  describe '#status' do
    context 'supplied status' do
      let(:success_does_not_matter) { [true, false].sample }
      let(:status) { 100 }

      it 'returns supplied status' do
        expect(subject.new(obj, success_does_not_matter, status).status).
          to eq(status)
      end
    end

    context 'status is nil' do
      context 'success' do
        it 'has status 200' do
          expect(subject.new(obj, true).status).to eq(200)
        end
      end

      context 'failure' do
        it 'has status 422' do
          expect(subject.new(obj, false).status).to eq(422)
        end
      end
    end

    context 'object is nil' do
      it 'has status 404' do
        expect(subject.new(nil).status).to eq(404)
      end
    end
  end

  describe '#render' do
    let(:controller) { double(params: params) }
    let(:params) { {} }
    let(:status) { 100 }

    it 'renders the object from the supplied controller' do
      expect(controller).to receive(:render).with(json: obj, status: status)

      subject.new(obj, true, status).render(controller)
    end

    context 'serializers' do
      let(:serializer) { double }

      context 'singular object' do
        it 'can specify a serializer' do
          expect(controller).to receive(:render).with(
            json: obj, status: status, serializer: serializer
          )

          subject.new(obj, true, status, serializer).render(controller)
        end
      end

      context 'enumerable object' do
        let(:obj) { [] }

        it 'can specify a serializer' do
          expect(controller).to receive(:render).with(
            json: instance_of(ActiveModel::ArraySerializer), status: status
          )

          subject.new(obj, true, status, serializer).render(controller)
        end
      end
    end

    context 'create action' do
      let(:params) { { action: 'create' } }

      it 'renders 201 if there was a success' do
        expect(controller).to receive(:render).with(json: obj, status: 201)

        subject.new(obj, true).render(controller)
      end
    end
  end
end


text:
<?php

namespace ZENben\FoosballBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class FoosballBundle extends Bundle
{
}


text:
<regions>
  <region displayname="AUTHENTICATION_SG_REGION" hostname="sg"
		allowedProductLocales="all" localesThatDefaultToThisRegion="enSG"/>
  <region displayname="AUTHENTICATION_US_REGION" hostname="us"
		allowedProductLocales="all" localesThatDefaultToThisRegion="enUS"/>
  <region displayname="AUTHENTICATION_EU_REGION" hostname="eu"
		allowedProductLocales="all" localesThatDefaultToThisRegion="enGB"/>
  <region displayname="AUTHENTICATION_KR_REGION" hostname="kr"
		allowedProductLocales="all" localesThatDefaultToThisRegion="koKR"/>
</regions>


text:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="40dp"
    android:height="40dp"
    android:viewportWidth="40"
    android:viewportHeight="40"
    android:tint="?attr/colorControlNormal">
  <path
      android:fillColor="@android:color/white"
      android:pathData="M16.708,38.083V23.292H11.792V3.625H28.208L21.625,18.375H28.208Z"/>
</vector>


text:
package kieker.monitoring.probe.spring.executions.jetty;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

/**
 * @author Christian Wulf
 *
 * @since 1.13
 */
public final class UrlUtil {

	private UrlUtil() {
		// utility class
	}

	public static void ping(final URL url) throws IOException {
		BufferedReader in = null;
		try {
			in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
			// final String result = in.readLine(); // the result is currently an empty string.
		} finally {
			if (null != in) {
				in.close();
			}
		}
	}

}


text:
<?php
class ModelToolImage extends Model {
	public function resize($filename, $width, $height) {
		if (!is_file(DIR_IMAGE . $filename) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != DIR_IMAGE) {
			return;
		}

		$extension = pathinfo($filename, PATHINFO_EXTENSION);

		$image_old = $filename;
		$image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.' . $extension;

		if (!is_file(DIR_IMAGE . $image_new) || (filectime(DIR_IMAGE . $image_old) > filectime(DIR_IMAGE . $image_new))) {
			list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);

			if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) {
				return DIR_IMAGE . $image_old;
			}

			$path = '';

			$directories = explode('/', dirname($image_new));

			foreach ($directories as $directory) {
				$path = $path . '/' . $directory;

				if (!is_dir(DIR_IMAGE . $path)) {
					@mkdir(DIR_IMAGE . $path, 0777);
				}
			}

			if ($width_orig != $width || $height_orig != $height) {
				$image = new Image(DIR_IMAGE . $image_old);
				$image->resize($width, $height);
				$image->save(DIR_IMAGE . $image_new);
			} else {
				copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new);
			}
		}

		$image_new = str_replace(' ', '%20', $image_new);  // fix bug when attach image on email (gmail.com). it is automatic changing space " " to +

		if ($this->request->server['HTTPS']) {
			return $this->config->get('config_ssl') . 'image/' . $image_new;
		} else {
			return $this->config->get('config_url') . 'image/' . $image_new;
		}
	}
}


text:
package com.intellij.openapi.vcs.changes;

import com.google.common.collect.Sets;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsKey;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.BeforeAfter;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;

import static com.intellij.util.containers.ContainerUtil.newHashSet;

public class ChangeListsIndexes {
  private final TreeMap<FilePath, FileStatus> myFileToStatus;
  private final Map<FilePath, Pair<VcsKey, VcsRevisionNumber>> myFileToVcs;

  ChangeListsIndexes() {
    myFileToStatus = new TreeMap<FilePath, FileStatus>(HierarchicalFilePathComparator.SYSTEM_CASE_SENSITIVE);
    myFileToVcs = new HashMap<FilePath, Pair<VcsKey, VcsRevisionNumber>>();
  }

  ChangeListsIndexes(final ChangeListsIndexes idx) {
    myFileToStatus = new TreeMap<FilePath, FileStatus>(idx.myFileToStatus);
    myFileToVcs = new HashMap<FilePath, Pair<VcsKey, VcsRevisionNumber>>(idx.myFileToVcs);
  }

  void add(final FilePath file, final FileStatus status, final VcsKey key, VcsRevisionNumber number) {
    myFileToStatus.put(file, status);
    myFileToVcs.put(file, Pair.create(key, number));
  }

  void remove(final FilePath file) {
    myFileToStatus.remove(file);
    myFileToVcs.remove(file);
  }

  public FileStatus getStatus(final VirtualFile file) {
    return myFileToStatus.get(VcsUtil.getFilePath(file));
  }

  public FileStatus getStatus(@NotNull FilePath file) {
    return myFileToStatus.get(file);
  }

  public void changeAdded(final Change change, final VcsKey key) {
    addChangeToIdx(change, key);
  }

  public void changeRemoved(final Change change) {
    final ContentRevision afterRevision = change.getAfterRevision();
    final ContentRevision beforeRevision = change.getBeforeRevision();

    if (afterRevision != null) {
      remove(afterRevision.getFile());
    }
    if (beforeRevision != null) {
      remove(beforeRevision.getFile());
    }
  }

  public VcsKey getVcsFor(final Change change) {
    VcsKey key = getVcsForRevision(change.getAfterRevision());
    if (key != null) return key;
    return getVcsForRevision(change.getBeforeRevision());
  }

  @Nullable
  private VcsKey getVcsForRevision(final ContentRevision revision) {
    if (revision != null) {
      final FilePath fileKey = revision.getFile();
      final Pair<VcsKey, VcsRevisionNumber> pair = myFileToVcs.get(fileKey);
      return pair == null ? null : pair.getFirst();
    }
    return null;
  }

  private void addChangeToIdx(final Change change, final VcsKey key) {
    final ContentRevision afterRevision = change.getAfterRevision();
    final ContentRevision beforeRevision = change.getBeforeRevision();
    if (afterRevision != null) {
      add(afterRevision.getFile(), change.getFileStatus(), key, beforeRevision == null ? VcsRevisionNumber.NULL : beforeRevision.getRevisionNumber());
    }
    if (beforeRevision != null) {
      if (afterRevision != null) {
        if (! Comparing.equal(beforeRevision.getFile(), afterRevision.getFile())) {
          add(beforeRevision.getFile(), FileStatus.DELETED, key, beforeRevision.getRevisionNumber());
        }
      } else {
        add(beforeRevision.getFile(), change.getFileStatus(), key, beforeRevision.getRevisionNumber());
      }
    }
  }

  /**
   * this method is called after each local changes refresh and collects all:
   * - paths that are new in local changes
   * - paths that are no more changed locally
   * - paths that were and are changed, but base revision has changed (ex. external update)
   * (for RemoteRevisionsCache and annotation listener)
   */
  public void getDelta(final ChangeListsIndexes newIndexes,
                       final Set<BaseRevision> toRemove,
                       Set<BaseRevision> toAdd,
                       Set<BeforeAfter<BaseRevision>> toModify) {
    // this is old
    final Set<FilePath> oldKeySet = newHashSet(myFileToVcs.keySet());
    final Set<FilePath> toRemoveSet = newHashSet(oldKeySet);
    final Set<FilePath> newKeySet = newIndexes.myFileToVcs.keySet();
    final Set<FilePath> toAddSet = newHashSet(newKeySet);
    toRemoveSet.removeAll(newKeySet);
    toAddSet.removeAll(oldKeySet);
    // those that modified
    oldKeySet.removeAll(toRemoveSet);

    for (FilePath s : toRemoveSet) {
      final Pair<VcsKey, VcsRevisionNumber> pair = myFileToVcs.get(s);
      toRemove.add(fromPairAndPath(s, pair));
    }
    for (FilePath s : toAddSet) {
      final Pair<VcsKey, VcsRevisionNumber> pair = newIndexes.myFileToVcs.get(s);
      toAdd.add(fromPairAndPath(s, pair));
    }
    for (FilePath s : oldKeySet) {
      final Pair<VcsKey, VcsRevisionNumber> old = myFileToVcs.get(s);
      final Pair<VcsKey, VcsRevisionNumber> newOne = newIndexes.myFileToVcs.get(s);
      assert old != null && newOne != null;
      if (! old.equals(newOne)) {
        toModify.add(new BeforeAfter<BaseRevision>(fromPairAndPath(s, old), fromPairAndPath(s, newOne)));
      }
    }
  }

  private static BaseRevision fromPairAndPath(FilePath s, Pair<VcsKey, VcsRevisionNumber> pair) {
    return new BaseRevision(pair.getFirst(), pair.getSecond(), s);
  }

  public List<BaseRevision> getAffectedFilesUnderVcs() {
    final List<BaseRevision> result = new ArrayList<BaseRevision>();
    for (Map.Entry<FilePath, Pair<VcsKey, VcsRevisionNumber>> entry : myFileToVcs.entrySet()) {
      final Pair<VcsKey, VcsRevisionNumber> value = entry.getValue();
      result.add(fromPairAndPath(entry.getKey(), value));
    }
    return result;
  }

  @NotNull
  public NavigableSet<FilePath> getAffectedPaths() {
    return Sets.unmodifiableNavigableSet(myFileToStatus.navigableKeySet());
  }
}


text:
package storage

import (
	"context"
	"fmt"
	"net/url"
	"time"

	gax "github.com/googleapis/gax-go/v2"
	"google.golang.org/api/option"
	"google.golang.org/api/transport"
	storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1beta1"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/metadata"
)

// BigQueryStorageCallOptions contains the retry settings for each method of BigQueryStorageClient.
type BigQueryStorageCallOptions struct {
	CreateReadSession             []gax.CallOption
	ReadRows                      []gax.CallOption
	BatchCreateReadSessionStreams []gax.CallOption
	FinalizeStream                []gax.CallOption
	SplitReadStream               []gax.CallOption
}

func defaultBigQueryStorageClientOptions() []option.ClientOption {
	return []option.ClientOption{
		option.WithEndpoint("bigquerystorage.googleapis.com:443"),
		option.WithScopes(DefaultAuthScopes()...),
	}
}

func defaultBigQueryStorageCallOptions() *BigQueryStorageCallOptions {
	retry := map[[2]string][]gax.CallOption{
		{"create_read_session", "idempotent"}: {
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.DeadlineExceeded,
					codes.Unavailable,
				}, gax.Backoff{
					Initial:    100 * time.Millisecond,
					Max:        60000 * time.Millisecond,
					Multiplier: 1.3,
				})
			}),
		},
		{"default", "idempotent"}: {
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.DeadlineExceeded,
					codes.Unavailable,
				}, gax.Backoff{
					Initial:    100 * time.Millisecond,
					Max:        60000 * time.Millisecond,
					Multiplier: 1.3,
				})
			}),
		},
		{"read_rows", "unary_streaming"}: {
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.Unavailable,
				}, gax.Backoff{
					Initial:    100 * time.Millisecond,
					Max:        60000 * time.Millisecond,
					Multiplier: 1.3,
				})
			}),
		},
	}
	return &BigQueryStorageCallOptions{
		CreateReadSession:             retry[[2]string{"create_read_session", "idempotent"}],
		ReadRows:                      retry[[2]string{"read_rows", "unary_streaming"}],
		BatchCreateReadSessionStreams: retry[[2]string{"default", "idempotent"}],
		FinalizeStream:                retry[[2]string{"default", "idempotent"}],
		SplitReadStream:               retry[[2]string{"default", "idempotent"}],
	}
}

// BigQueryStorageClient is a client for interacting with BigQuery Storage API.
//
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type BigQueryStorageClient struct {
	// The connection to the service.
	conn *grpc.ClientConn

	// The gRPC API client.
	bigQueryStorageClient storagepb.BigQueryStorageClient

	// The call options for this service.
	CallOptions *BigQueryStorageCallOptions

	// The x-goog-* metadata to be sent with each request.
	xGoogMetadata metadata.MD
}

// NewBigQueryStorageClient creates a new big query storage client.
//
// BigQuery storage API.
//
// The BigQuery storage API can be used to read data stored in BigQuery.
func NewBigQueryStorageClient(ctx context.Context, opts ...option.ClientOption) (*BigQueryStorageClient, error) {
	conn, err := transport.DialGRPC(ctx, append(defaultBigQueryStorageClientOptions(), opts...)...)
	if err != nil {
		return nil, err
	}
	c := &BigQueryStorageClient{
		conn:        conn,
		CallOptions: defaultBigQueryStorageCallOptions(),

		bigQueryStorageClient: storagepb.NewBigQueryStorageClient(conn),
	}
	c.setGoogleClientInfo()
	return c, nil
}

// Connection returns the client's connection to the API service.
func (c *BigQueryStorageClient) Connection() *grpc.ClientConn {
	return c.conn
}

// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *BigQueryStorageClient) Close() error {
	return c.conn.Close()
}

// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *BigQueryStorageClient) setGoogleClientInfo(keyval ...string) {
	kv := append([]string{"gl-go", versionGo()}, keyval...)
	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
}

// CreateReadSession creates a new read session. A read session divides the contents of a
// BigQuery table into one or more streams, which can then be used to read
// data from the table. The read session also specifies properties of the
// data to be read, such as a list of columns or a push-down filter describing
// the rows to be returned.
//
// A particular row can be read by at most one stream. When the caller has
// reached the end of each stream in the session, then all the data in the
// table has been read.
//
// Read sessions automatically expire 24 hours after they are created and do
// not require manual clean-up by the caller.
func (c *BigQueryStorageClient) CreateReadSession(ctx context.Context, req *storagepb.CreateReadSessionRequest, opts ...gax.CallOption) (*storagepb.ReadSession, error) {
	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "table_reference.project_id", url.QueryEscape(req.GetTableReference().GetProjectId()), "table_reference.dataset_id", url.QueryEscape(req.GetTableReference().GetDatasetId())))
	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
	opts = append(c.CallOptions.CreateReadSession[0:len(c.CallOptions.CreateReadSession):len(c.CallOptions.CreateReadSession)], opts...)
	var resp *storagepb.ReadSession
	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
		var err error
		resp, err = c.bigQueryStorageClient.CreateReadSession(ctx, req, settings.GRPC...)
		return err
	}, opts...)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

// ReadRows reads rows from the table in the format prescribed by the read session.
// Each response contains one or more table rows, up to a maximum of 10 MiB
// per response; read requests which attempt to read individual rows larger
// than this will fail.
//
// Each request also returns a set of stream statistics reflecting the
// estimated total number of rows in the read stream. This number is computed
// based on the total table size and the number of active streams in the read
// session, and may change as other streams continue to read data.
func (c *BigQueryStorageClient) ReadRows(ctx context.Context, req *storagepb.ReadRowsRequest, opts ...gax.CallOption) (storagepb.BigQueryStorage_ReadRowsClient, error) {
	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "read_position.stream.name", url.QueryEscape(req.GetReadPosition().GetStream().GetName())))
	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
	opts = append(c.CallOptions.ReadRows[0:len(c.CallOptions.ReadRows):len(c.CallOptions.ReadRows)], opts...)
	var resp storagepb.BigQueryStorage_ReadRowsClient
	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
		var err error
		resp, err = c.bigQueryStorageClient.ReadRows(ctx, req, settings.GRPC...)
		return err
	}, opts...)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

// BatchCreateReadSessionStreams creates additional streams for a ReadSession. This API can be used to
// dynamically adjust the parallelism of a batch processing task upwards by
// adding additional workers.
func (c *BigQueryStorageClient) BatchCreateReadSessionStreams(ctx context.Context, req *storagepb.BatchCreateReadSessionStreamsRequest, opts ...gax.CallOption) (*storagepb.BatchCreateReadSessionStreamsResponse, error) {
	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "session.name", url.QueryEscape(req.GetSession().GetName())))
	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
	opts = append(c.CallOptions.BatchCreateReadSessionStreams[0:len(c.CallOptions.BatchCreateReadSessionStreams):len(c.CallOptions.BatchCreateReadSessionStreams)], opts...)
	var resp *storagepb.BatchCreateReadSessionStreamsResponse
	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
		var err error
		resp, err = c.bigQueryStorageClient.BatchCreateReadSessionStreams(ctx, req, settings.GRPC...)
		return err
	}, opts...)
	if err != nil {
		return nil, err
	}
	return resp, nil
}

// FinalizeStream triggers the graceful termination of a single stream in a ReadSession. This
// API can be used to dynamically adjust the parallelism of a batch processing
// task downwards without losing data.
//
// This API does not delete the stream -- it remains visible in the
// ReadSession, and any data processed by the stream is not released to other
// streams. However, no additional data will be assigned to the stream once
// this call completes. Callers must continue reading data on the stream until
// the end of the stream is reached so that data which has already been
// assigned to the stream will be processed.
//
// This method will return an error if there are no other live streams
// in the Session, or if SplitReadStream() has been called on the given
// Stream.
func (c *BigQueryStorageClient) FinalizeStream(ctx context.Context, req *storagepb.FinalizeStreamRequest, opts ...gax.CallOption) error {
	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "stream.name", url.QueryEscape(req.GetStream().GetName())))
	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
	opts = append(c.CallOptions.FinalizeStream[0:len(c.CallOptions.FinalizeStream):len(c.CallOptions.FinalizeStream)], opts...)
	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
		var err error
		_, err = c.bigQueryStorageClient.FinalizeStream(ctx, req, settings.GRPC...)
		return err
	}, opts...)
	return err
}

// SplitReadStream splits a given read stream into two Streams. These streams are referred to
// as the primary and the residual of the split. The original stream can still
// be read from in the same manner as before. Both of the returned streams can
// also be read from, and the total rows return by both child streams will be
// the same as the rows read from the original stream.
//
// Moreover, the two child streams will be allocated back to back in the
// original Stream. Concretely, it is guaranteed that for streams Original,
// Primary, and Residual, that Original[0-j] = Primary[0-j] and
// Original[j-n] = Residual[0-m] once the streams have been read to
// completion.
//
// This method is guaranteed to be idempotent.
func (c *BigQueryStorageClient) SplitReadStream(ctx context.Context, req *storagepb.SplitReadStreamRequest, opts ...gax.CallOption) (*storagepb.SplitReadStreamResponse, error) {
	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "original_stream.name", url.QueryEscape(req.GetOriginalStream().GetName())))
	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
	opts = append(c.CallOptions.SplitReadStream[0:len(c.CallOptions.SplitReadStream):len(c.CallOptions.SplitReadStream)], opts...)
	var resp *storagepb.SplitReadStreamResponse
	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
		var err error
		resp, err = c.bigQueryStorageClient.SplitReadStream(ctx, req, settings.GRPC...)
		return err
	}, opts...)
	if err != nil {
		return nil, err
	}
	return resp, nil
}