id int64 0 1.29M | original_id stringlengths 32 32 | swhid stringlengths 100 170 | sha1 stringlengths 40 40 | repo_name stringlengths 2 45 | repo_group stringclasses 12
values | filepath stringlengths 5 153 | name stringlengths 1 14.9k | type stringclasses 3
values | code stringlengths 7 2.12M |
|---|---|---|---|---|---|---|---|---|---|
2,500 | 5e49797cf6c65eb2836cfc599beed7be | swh:1:cnt:d46bbf6d5f81a9adad2b2e82032fd2dd4c0cf35c;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=30-46/ | 32fbaa798e321340bd4d9473b05ea16a47eee6a2 | spark8s | analytics | spark-delegation-token/src/main/java/org/wikimedia/kubernetes/hadoop/security/Main.java | Main::main(String[] args) | function | public static void main(String[] args) throws IOException, InterruptedException {
if (args.length == 0) {
logger.error("Proper Usage is: java -cp spark-delegation-token.jar:<hadoop classpath>:<hive classpath> " +
"org.wikimedia.kubernetes.hadoop.security.Main token_file_path");
... |
2,501 | 1f0684805230cf8f288f1dfebf60c576 | swh:1:cnt:29b1f4f59fc5f3fc7c25b5188661d7f7e204760c;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=29-53/ | 7fe1c4d61a000de7babd4654fc561c52986717a2 | spark8s | analytics | spark-delegation-token/src/test/java/org/wikimedia/kubernetes/hadoop/security/CredentialHelperTest.java | CredentialHelperTest | type | public class CredentialHelperTest {
CredentialHelper credsHelper;
Path tempTokenFile;
@BeforeEach
public void setUp() throws IOException {
String tmpdir = Files.createTempDirectory("hdt").toFile().getAbsolutePath();
System.setProperty("user.dir", tmpdir);
tempTokenFile = Files.c... |
2,502 | ad9166dac8657715cebb7aaad346c0b5 | swh:1:cnt:29b1f4f59fc5f3fc7c25b5188661d7f7e204760c;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=33-39/ | 7fe1c4d61a000de7babd4654fc561c52986717a2 | spark8s | analytics | spark-delegation-token/src/test/java/org/wikimedia/kubernetes/hadoop/security/CredentialHelperTest.java | CredentialHelperTest::setUp() | function | @BeforeEach
public void setUp() throws IOException {
String tmpdir = Files.createTempDirectory("hdt").toFile().getAbsolutePath();
System.setProperty("user.dir", tmpdir);
tempTokenFile = Files.createTempFile("", ".tmp");
this.credsHelper = new CredentialHelper(tempTokenFile.toString()... |
2,503 | 801fbb5b37c89c60ad770d8a49626434 | swh:1:cnt:29b1f4f59fc5f3fc7c25b5188661d7f7e204760c;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=41-45/ | 7fe1c4d61a000de7babd4654fc561c52986717a2 | spark8s | analytics | spark-delegation-token/src/test/java/org/wikimedia/kubernetes/hadoop/security/CredentialHelperTest.java | CredentialHelperTest::throw_exception_token_exist_but_not_a_file() | function | @Test
public void throw_exception_token_exist_but_not_a_file() throws IOException {
String tmpdir = Files.createTempDirectory("hdt").toFile().getAbsolutePath();
assertThrows(IOException.class, () -> new CredentialHelper(tmpdir));
} |
2,504 | 6193a244da60dd150548e6be24630b09 | swh:1:cnt:29b1f4f59fc5f3fc7c25b5188661d7f7e204760c;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=47-51/ | 7fe1c4d61a000de7babd4654fc561c52986717a2 | spark8s | analytics | spark-delegation-token/src/test/java/org/wikimedia/kubernetes/hadoop/security/CredentialHelperTest.java | CredentialHelperTest::token_file_is_well_created() | function | @Test
public void token_file_is_well_created() throws IOException {
this.credsHelper.writeTokenStorageFile();
assertTrue(tempTokenFile.toFile().isFile());
} |
2,505 | 432df0dcffe092beb57057358c4b4e28 | swh:1:cnt:1c49da81a4e88f0190e37935f0dd564830d90748;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=20-22/ | 4d8a38f83b9a48fa3d4388b94e49038ecd62f374 | spark8s | analytics | spark8s/main.go | main | function | func main() {
cmd.Execute()
} |
2,506 | d11aa6cd77ae316110cb0dcc99b5d21b | swh:1:cnt:d4a3dedc3c7aa57858b816917a62085b5ef17e5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=25-31/ | adfc16e9dbd60f128f1da7a1d785df1996889225 | spark8s | analytics | spark8s/cmd/root.go | getKubeConfigPath | function | func getKubeConfigPath() string {
var kubeConfigEnv = os.Getenv("KUBECONFIG")
if len(kubeConfigEnv) == 0 {
return "/etc/kubernetes/spark-deploy-dse-k8s-eqiad.config"
}
return kubeConfigEnv
} |
2,507 | a514936ee3556f3bfd0326eaeec18962 | swh:1:cnt:d4a3dedc3c7aa57858b816917a62085b5ef17e5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=44-48/ | adfc16e9dbd60f128f1da7a1d785df1996889225 | spark8s | analytics | spark8s/cmd/root.go | init | function | func init() {
rootCmd.PersistentFlags().StringVarP(&KubeConfig, "kubeconfig", "k", defaultKubeConfig,
"The path to the local Kubernetes configuration file")
rootCmd.PersistentFlags().BoolVar(&DebugLog, "debug", false, "Print debug logs")
} |
2,508 | b0e2da8eff3ef7f4c0633174684ad4a6 | swh:1:cnt:d4a3dedc3c7aa57858b816917a62085b5ef17e5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=50-64/ | adfc16e9dbd60f128f1da7a1d785df1996889225 | spark8s | analytics | spark8s/cmd/root.go | Execute | function | func Execute() {
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
log.SetLevel(log.InfoLevel)
if DebugLog {
log.SetLevel(log.DebugLevel)
}
err := rootCmd.Execute()
if err != nil {
log.Fatal("Failed to execute spark8s cli.", err)
os.Exit(1)
}
} |
2,509 | e55f399552288a4b183a46988516ccb4 | swh:1:cnt:cfb01ab3b86b262cb00263695e912c678182546e;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=23-25/ | f71a7ad62289ae4a8bdb0ce79d6fa349eb1266d0 | spark8s | analytics | spark8s/cmd/root_test.go | TestGetKubeConfigPath | function | func TestGetKubeConfigPath(t *testing.T) {
assert.Equal(t, getKubeConfigPath(), "/etc/kubernetes/spark-deploy-dse-k8s-eqiad.config")
} |
2,510 | b38e6e95fe21d6e8e9081fbe708bcb20 | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=35-37/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | getRootTempPath | function | func getRootTempPath() string {
return fmt.Sprintf("%s/.spark8s", os.Getenv("HOME"))
} |
2,511 | e0835bb0cdbee8bdf5633f21843ddf38 | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=74-102/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | init | function | func init() {
rootCmd.AddCommand(submitCmd)
// Set flags
rootCmd.PersistentFlags().StringVar(&RootTempPath, "root-temp-dir", DefaultRootTempPath,
"Root folder where temporary folder will be created with credentials, sparkapplication yaml, ...")
rootCmd.PersistentFlags().StringVar(&Type, "type", "Scala", "Type o... |
2,512 | bee4eaecb56a64a36e3b55b58a7725cb | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=104-154/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | submitSparkApplication | function | func submitSparkApplication() error {
// Validate Flag
if err := validateFlag(); err != nil {
return err
}
log.WithFields(log.Fields{"name": SparkAppName}).Info("Creating SparkApplication")
// Build kube config
config, err := clientcmd.BuildConfigFromFlags("", KubeConfig)
if err != nil {
return fmt.Errorf("... |
2,513 | 99fa7abaa93257da2c81362fe2a30f8d | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=172-194/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | createTemporaryFolder | function | func createTemporaryFolder(rootTempPath string) (string, error) {
// Create root temp folder
stat, err := os.Stat(rootTempPath)
if os.IsNotExist(err) {
log.WithFields(log.Fields{"root_temp": rootTempPath}).Info("Create root temporary folders")
if err := os.MkdirAll(rootTempPath, os.ModePerm); err != nil {
ret... |
2,514 | 3f16c6848edbbd6cdfdbca08fe5fe35a | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=156-170/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | validateFlag | function | func validateFlag() error {
if !utils.Contains(Type, Types) {
return fmt.Errorf("define type is not authorized: %s - %v", Type, Types)
}
if !utils.Contains(Mode, Modes) {
return fmt.Errorf("define more is not authorized: %s - %v", Mode, Modes)
}
if !utils.Contains(Type, []string{"Java", "Scala"}) {
// Main c... |
2,515 | 5bd18ba1fd8477aa8407957d70a549a4 | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=196-210/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | createHadoopDelegationTokenCredentialFile | function | func createHadoopDelegationTokenCredentialFile(hdtCredentialPath string) error {
log.Debug("Get hadoop classpath")
hadoopClassPath, err := utils.RunCommand("hadoop", "classpath")
if err != nil {
return fmt.Errorf("failed to get hadoop classpath: %v", err)
}
log.WithFields(log.Fields{"creds": hdtCredentialPath})... |
2,516 | b5ae4d62b5ddeb8f0acf374813a3ed41 | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=212-254/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | getSparkApplicationObject | function | func getSparkApplicationObject(hdtCredentialPath string) (*utils.SparkApp, error) {
log.Info("Get internal SparkApp object for template rendering")
credsBase64Enc, err := utils.GetBase64EncodedFileData(hdtCredentialPath)
if err != nil {
return &utils.SparkApp{}, fmt.Errorf("failed to base64 encode hadoop delegati... |
2,517 | d6b989df0ad0b30f2f6d7fbe402fdd39 | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=256-268/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | createSecret | function | func createSecret(kubeClientSet *kubernetes.Clientset, sparkApp *utils.SparkApp) error {
secret := &apiv1.Secret{}
if err := utils.CreateObjectFromTemplate(sparkApp, utils.SecretTemplate, secret); err != nil {
return fmt.Errorf("failed to create Secret object : %v", err)
}
log.WithFields(log.Fields{"name": Spark... |
2,518 | e4751894005afe58605fa3693422fe40 | swh:1:cnt:717a030dd81f9a2cb2b33caf91edc6497f2367b9;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=270-282/ | a8733e318d0e568cf58102ae6b8a08e5228039ba | spark8s | analytics | spark8s/cmd/submit.go | createSparkApplication | function | func createSparkApplication(sparkClientSet *sparkclientset.Clientset, sparkApp *utils.SparkApp) error {
sparkApplication := &v1beta2.SparkApplication{}
if err := utils.CreateObjectFromTemplate(sparkApp, utils.SparkApplicationTemplate, sparkApplication); err != nil {
return fmt.Errorf("failed to create SparkApplicat... |
2,519 | 4933ddfa7e4271a38178f5bb776a42bc | swh:1:cnt:9ea08b60f40a128ad83e7456432156dd21402157;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=25-29/ | 9fee8038ea697d33c021c1be2d496cf3c6e847d9 | spark8s | analytics | spark8s/cmd/submit_test.go | TestGetRootTempPath | function | func TestGetRootTempPath(t *testing.T) {
home := "/home/sparkuser"
os.Setenv("HOME", home)
assert.Equal(t, getRootTempPath(), fmt.Sprintf("%s/.spark8s", home))
} |
2,520 | 9741dc23b4f593201a314d2f3028367e | swh:1:cnt:9ea08b60f40a128ad83e7456432156dd21402157;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=31-51/ | 9fee8038ea697d33c021c1be2d496cf3c6e847d9 | spark8s | analytics | spark8s/cmd/submit_test.go | TestCreateTemporaryFolder | function | func TestCreateTemporaryFolder(t *testing.T) {
rootTempPath, err := os.MkdirTemp(os.TempDir(), "spark_test")
if err != nil {
t.Fatalf("Failed to create root temporary folder %v", err)
}
defer os.RemoveAll(rootTempPath)
tempPath, err := createTemporaryFolder(rootTempPath)
if err != nil {
t.Fatalf("Failed to c... |
2,521 | 9bef9a76edcdb646d27c794d1f802ea3 | swh:1:cnt:9d3520090087ddd141e4c63af2b7f67b363e2311;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=20-28/ | b32edc593ba4d78ffd20ac7f151cad29e1f44404 | spark8s | analytics | spark8s/pkg/utils/types.go | SparkApp | type | type SparkApp struct {
Name string
NameSpace string
Image string
Version string
Spec SparkAppSpec
Secret Secret
SparkApplication v1beta2.SparkApplication
} |
2,522 | 3e8ec26e0b8b11e767a24b3fdb79a091 | swh:1:cnt:9d3520090087ddd141e4c63af2b7f67b363e2311;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=46-50/ | b32edc593ba4d78ffd20ac7f151cad29e1f44404 | spark8s | analytics | spark8s/pkg/utils/types.go | PodSpec | type | type PodSpec struct {
Cores float32
CoresLimit string
Memory string
} |
2,523 | f8366f078e59e80e8b8924b183af3848 | swh:1:cnt:9d3520090087ddd141e4c63af2b7f67b363e2311;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=35-44/ | b32edc593ba4d78ffd20ac7f151cad29e1f44404 | spark8s | analytics | spark8s/pkg/utils/types.go | SparkAppSpec | type | type SparkAppSpec struct {
Type string
Mode string
MainClass string
MainApplicationFile string
Arguments []string
Driver PodSpec
Executor PodSpec
ExecutorInstances int32
} |
2,524 | c843190949e2e0a2e2a7e14cc319ac56 | swh:1:cnt:9d3520090087ddd141e4c63af2b7f67b363e2311;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=30-33/ | b32edc593ba4d78ffd20ac7f151cad29e1f44404 | spark8s | analytics | spark8s/pkg/utils/types.go | Secret | type | type Secret struct {
Name string
Data string
} |
2,525 | b098f8be5c8dfc172b90e46347469d81 | swh:1:cnt:4d1ee53c89464f755544a8841652c896ac7ec3ca;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=31-34/ | 4c047a79f0d660016557e783251cdf87f14f266b | spark8s | analytics | spark8s/pkg/utils/utils.go | GetUuid | function | func GetUuid() string {
id := uuid.New()
return id.String()
} |
2,526 | ce5ed3f6a3f3a3b3b8814afe46680ce3 | swh:1:cnt:4d1ee53c89464f755544a8841652c896ac7ec3ca;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=58-76/ | 4c047a79f0d660016557e783251cdf87f14f266b | spark8s | analytics | spark8s/pkg/utils/utils.go | CreateObjectFromTemplate | function | func CreateObjectFromTemplate(sparkApp *SparkApp, templateToRender string, into interface{}) error {
log.WithFields(log.Fields{"template": templateToRender}).Debug("Render template")
tmpl := template.New("SparkApplication")
parsedTemplate, err := tmpl.Parse(templateToRender)
if err != nil {
return fmt.Errorf("fai... |
2,527 | 6e711dd761205a5a338b41ac9c4a94ca | swh:1:cnt:4d1ee53c89464f755544a8841652c896ac7ec3ca;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=36-38/ | 4c047a79f0d660016557e783251cdf87f14f266b | spark8s | analytics | spark8s/pkg/utils/utils.go | GetNewSparkApplicationName | function | func GetNewSparkApplicationName(uuid string) string {
return fmt.Sprintf("%s-%s-%s", RootSparkAppName, os.Getenv("USER"), uuid)
} |
2,528 | c1e0378d023ca3dc46e502230907d3d1 | swh:1:cnt:4d1ee53c89464f755544a8841652c896ac7ec3ca;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=49-56/ | 4c047a79f0d660016557e783251cdf87f14f266b | spark8s | analytics | spark8s/pkg/utils/utils.go | Contains | function | func Contains(item string, list []string) bool {
for _, b := range list {
if b == item {
return true
}
}
return false
} |
2,529 | 7622c5b1e7111e6683531609b68d8384 | swh:1:cnt:4d1ee53c89464f755544a8841652c896ac7ec3ca;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=40-47/ | 4c047a79f0d660016557e783251cdf87f14f266b | spark8s | analytics | spark8s/pkg/utils/utils.go | GetBase64EncodedFileData | function | func GetBase64EncodedFileData(filePath string) (string, error) {
creds, err := os.ReadFile(filePath) // #nosec G304
if err != nil {
return "", fmt.Errorf("failed to read file %s: %v", filePath, err)
}
credsBase64Enc := base64.StdEncoding.EncodeToString(creds)
return credsBase64Enc, nil
} |
2,530 | a05f6c86d823c0cbce49219dad278cda | swh:1:cnt:4d1ee53c89464f755544a8841652c896ac7ec3ca;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=78-90/ | 4c047a79f0d660016557e783251cdf87f14f266b | spark8s | analytics | spark8s/pkg/utils/utils.go | RunCommand | function | func RunCommand(name string, arg ...string) (string, error) {
cmd := exec.Command(name, arg...) // #nosec G204
stdout, err := cmd.Output()
if err != nil {
errorMsg := err.Error()
if e, ok := err.(*exec.ExitError); ok {
errorMsg = string(e.Stderr)
}
return "", fmt.Errorf("failed to execute command (%v):\n%... |
2,531 | f2a7f1d0c9fa17a264275ef3b6e9c873 | swh:1:cnt:00bf409edca6a6b5c63aa3636745c6cab26f4fb4;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=26-30/ | a5178b1910fe893639d094344f11e8a196a6d2a9 | spark8s | analytics | spark8s/pkg/utils/utils_test.go | TestGetNewSparkApplicationName | function | func TestGetNewSparkApplicationName(t *testing.T) {
uuid := "uuid-1"
sparkAppName := GetNewSparkApplicationName(uuid)
assert.Equal(t, sparkAppName, fmt.Sprintf("%s-%s-%s", RootSparkAppName, os.Getenv("USER"), uuid))
} |
2,532 | 01bf9208adda11206be9174605caa940 | swh:1:cnt:00bf409edca6a6b5c63aa3636745c6cab26f4fb4;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=65-85/ | a5178b1910fe893639d094344f11e8a196a6d2a9 | spark8s | analytics | spark8s/pkg/utils/utils_test.go | TestCreateObjectFromTemplate | function | func TestCreateObjectFromTemplate(t *testing.T) {
sparkApp := SparkApp{
Name: "spark",
NameSpace: NameSpace,
Image: Image,
Version: Version,
Secret: Secret{
Name: "secret",
Data: "ZGF0YQo=",
},
}
secret := &apiv1.Secret{}
CreateObjectFromTemplate(&sparkApp, SecretTemplate, secret)
asse... |
2,533 | 07107bc170c5699f6b50e37e7d6add19 | swh:1:cnt:00bf409edca6a6b5c63aa3636745c6cab26f4fb4;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=32-47/ | a5178b1910fe893639d094344f11e8a196a6d2a9 | spark8s | analytics | spark8s/pkg/utils/utils_test.go | TestGetBase64EncodedFileData | function | func TestGetBase64EncodedFileData(t *testing.T) {
file, err := os.CreateTemp(os.TempDir(), "base64")
if err != nil {
t.Fatalf("Failed to create temporary file %v", err)
}
defer os.Remove(file.Name())
file.WriteString("test base64 encoding")
base6AEncodedData, err := GetBase64EncodedFileData(file.Name())
if ... |
2,534 | cedd050e4aa4d11027dec8ff077c9df7 | swh:1:cnt:00bf409edca6a6b5c63aa3636745c6cab26f4fb4;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=49-54/ | a5178b1910fe893639d094344f11e8a196a6d2a9 | spark8s | analytics | spark8s/pkg/utils/utils_test.go | TestGetBase64EncodedFileDataFailedOnNonExistingFile | function | func TestGetBase64EncodedFileDataFailedOnNonExistingFile(t *testing.T) {
_, err := GetBase64EncodedFileData("non_existing_file")
if err == nil {
t.Fatal("Must failed as the file non_existing_file doesn't exist")
}
} |
2,535 | d44937a0246b42fe05e80db11ed79385 | swh:1:cnt:00bf409edca6a6b5c63aa3636745c6cab26f4fb4;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=56-63/ | a5178b1910fe893639d094344f11e8a196a6d2a9 | spark8s | analytics | spark8s/pkg/utils/utils_test.go | TestContains | function | func TestContains(t *testing.T) {
item := "item1"
items := []string{"item1", "item2"}
assert.True(t, Contains(item, items))
item = "not_in_the_list"
assert.False(t, Contains(item, items))
} |
2,536 | 8d2296921312e4dad2cea7c97a03f8e0 | swh:1:cnt:00bf409edca6a6b5c63aa3636745c6cab26f4fb4;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=87-97/ | a5178b1910fe893639d094344f11e8a196a6d2a9 | spark8s | analytics | spark8s/pkg/utils/utils_test.go | TestRunCommandSucceed | function | func TestRunCommandSucceed(t *testing.T) {
rootTempPath, err := os.MkdirTemp(os.TempDir(), "spark_test")
if err != nil {
t.Fatalf("Failed to create root temporary folder %v", err)
}
// Command run succeed
if _, err = RunCommand("ls", rootTempPath); err != nil {
t.Fatalf("Failed to execute ls command %v", err)... |
2,537 | 5f4ed773e834a134dc6f1480c3e196ef | swh:1:cnt:00bf409edca6a6b5c63aa3636745c6cab26f4fb4;origin=https://gitlab.wikimedia.org/repos/data-engineering/spark8s.git;lines=99-103/ | a5178b1910fe893639d094344f11e8a196a6d2a9 | spark8s | analytics | spark8s/pkg/utils/utils_test.go | TestRunCommandFailed | function | func TestRunCommandFailed(t *testing.T) {
if _, err := RunCommand("not_existing_command"); err == nil {
t.Fatalf("Command run should failed %v", err)
}
} |
2,538 | 28d9891c28c07a78ea075eee5ebc6c27 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=51-84/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | set_stage(stage='staging') | function | def set_stage(stage='staging'):
"""
Sets the stage and populate the environment with the necessary
config. Doing this allows accessing from anywhere stage related
details by simply doing something like env.source_dir etc
It also uses the values defined in the secrets directories
to substitute t... |
2,539 | 95388dc948131d833eb7383740ff883e | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=189-197/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | upload_file(config, dest) | function | def upload_file(config, dest):
"""
Converts config file contents from string to file buffer using StringIO
and uploads to remote server
"""
buffer = StringIO.StringIO()
buffer.write(config)
put(buffer, dest, use_sudo=True)
buffer.close() |
2,540 | 822811e9f2819c751912ce044d2c3456 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=212-219/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | upgrade_wikimetrics() | function | def upgrade_wikimetrics():
"""
Installs upgraded versions of requirements (if applicable)
"""
print 'Upgrading requirements'
with cd(VENV_DIR):
sr(VENV_DIR + '/bin/pip', 'install', '--upgrade', '-r',
os.path.join(CONFIG_DIR, 'requirements.txt')) |
2,541 | 947610c3dfbb8582a7d601b313ccb12c | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=248-262/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | setup_db() | function | def setup_db():
"""
Creates the database and grants access to the wikimetrics user
"""
print 'Setting up database and access'
# Convert db config to yaml
db_config = yaml.load(env.db_config)
# Setup wikimetrics DB
create_db_and_user(db_config['DB_NAME_WIKIMETRICS'], db_config)
if e... |
2,542 | bad54c5dcafacdf11d2e64ccf131fa8b | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=223-244/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | create_db_and_user(db_name, db_config) | function | def create_db_and_user(db_name, db_config):
"""
Creates the database db_name and grants access to the
user, as defined by the db_config, on the given remote mysql server
"""
db_user = db_config['DB_USER_WIKIMETRICS']
db_password = db_config['DB_PASSWORD_WIKIMETRICS']
db_host = db_config['DB_... |
2,543 | ff7f8a8a589da45e331b2ff441f56128 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=42-48/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | sr(*cmd) | function | def sr(*cmd):
"""
Sudo Run - Wraps a given command around sudo and runs it as the
wikimetrics user
"""
with shell_env(HOME='/srv/wikimetrics'):
return sudo(' '.join(cmd), user='wikimetrics') |
2,544 | 05d4477f0b6da3ba582e95bfa9a391fe | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=101-102/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | production() | function | def production():
set_stage('production') |
2,545 | cabb03f5a290749f1a545481760c2a73 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=87-97/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | ensure_stage(fn) | function | def ensure_stage(fn):
"""
Decorator to ensure the stage is set
"""
@wraps(fn)
def wrapper(*args, **kwargs):
# The require operation will abort if the key stage
# is not set in the environment
require('stage', provided_by=(staging, production,))
return fn(*args, **kwar... |
2,546 | 5d780fbbf70989bbae30274674c9d6da | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=92-96/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | ensure_stage::wrapper(*args, **kwargs) | function | def wrapper(*args, **kwargs):
# The require operation will abort if the key stage
# is not set in the environment
require('stage', provided_by=(staging, production,))
return fn(*args, **kwargs) |
2,547 | 9de2c819ca593079de99cc13c84126d4 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=106-107/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | staging() | function | def staging():
set_stage('staging') |
2,548 | 6cbfeaec0a2d794bee91da14117c5fa7 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=112-137/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | initialize_server() | function | def initialize_server():
"""
Setup an initial deployment on a fresh host.
"""
print 'Setting up the ' + env.stage + ' server'
# Sets up a virtualenv directory
sr('mkdir', '-p', VENV_DIR)
sr('virtualenv', '--python', 'python2', VENV_DIR)
# Updates current version of wikimetrics-deploy
... |
2,549 | 4386331e055ab16ab99a4f8537a33125 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=142-164/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | deploy() | function | def deploy():
"""
Deploys updated code to the web server
"""
print 'Deploying to ' + env.stage
# Updates current version of wikimetrics-deploy
update_deploy_repo()
# Updates current version of wikimetrics source
update_source_repo()
# Updates the virtualenv with new wikimetrics co... |
2,550 | 69527b6af826dca870832c7c9eb90b7b | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=168-175/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | update_source_repo() | function | def update_source_repo():
"""
Update the wikimetrics source repo
"""
print 'Updating wikimetrics source repo'
with cd(SOURCE_DIR):
sr('git', 'fetch', 'origin', env.source_branch)
sr('git', 'reset', '--hard', 'FETCH_HEAD') |
2,551 | 4f28275652cfb30f95f379b21205106e | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=179-186/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | update_deploy_repo() | function | def update_deploy_repo():
"""
Updates the deployment repo
"""
print 'Updating wikimetrics-deploy repo'
with cd(CONFIG_DIR):
sr('git', 'fetch', 'origin', env.deploy_branch)
sr('git', 'reset', '--hard', 'FETCH_HEAD') |
2,552 | 0034d4ede12d504c5be3e6cdcca177d7 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=201-208/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | upload_config() | function | def upload_config():
"""
Upload the queue, web and db configs to the remote host
"""
print 'Uploading config files to remote host(s)'
upload_file(env.web_config, CONFIG_DIR + '/' + WEB_CONFIG_FILE)
upload_file(env.db_config, CONFIG_DIR + '/' + DB_CONFIG_FILE)
upload_file(env.queue_config, CO... |
2,553 | 66a66e21e8f48c95efa912e5c31be21a | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=266-272/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | update_db() | function | def update_db():
"""
Creates and updates all tables by running migrations
"""
print 'Bringing database uptodate by running migrations'
with cd(SOURCE_DIR):
run(VENV_DIR + '/bin/alembic upgrade head') |
2,554 | 2bcb9cb89b3b695b4d221b73916d9ac2 | swh:1:cnt:3cba61db1bfd8bf25856f98c28746b702b954e05;origin=https://gerrit.wikimedia.org/r/analytics/wikimetrics-deploy.git;lines=277-287/ | 0592b1e26ffa881f070137a4a17de48cc483a39a | wikimetrics-deploy | analytics | fabfile.py | restart_wikimetrics() | function | def restart_wikimetrics():
"""
Restarts the wikimetrics queue, scheduler and web server
"""
print 'Restarting queue, scheduler and web server'
# Doing uwsgi stop and start due to a known bug in our uwsgi puppet module
sudo('service uwsgi-wikimetrics-web stop')
sudo('service uwsgi-wikimetric... |
2,555 | 829c12bc172b9751197097a49d25eca1 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=39-156/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem | type | // Below is a (mostly) verbatim copy of org.apache.hadoop.fs.http.AbstractHttpFileSystem
// Had to copy because Java was not happy, giving me java.lang.IllegalAccessError
// The only change to this code is making HttpDataInputStream accessible from a subclass.
abstract class CopiedAbstractHttpFileSystem extends FileSys... |
2,556 | b8cb0c457956bb80b672d5378cf726b5 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=117-155/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::HttpDataInputStream | type | static class HttpDataInputStream extends FilterInputStream
implements Seekable, PositionedReadable {
HttpDataInputStream(InputStream in) {
super(in);
}
@Override
public int read(long position, byte[] buffer, int offset, int length)
throws IOExcep... |
2,557 | b06fe11bb300982570ddc2bf93a406f0 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=97-99/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::setWorkingDirectory(Path path) | function | @Override
public void setWorkingDirectory(Path path) {
} |
2,558 | a5bce09645c204f20fd6e0d823720085 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=106-110/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::mkdirs(Path path, FsPermission fsPermission) | function | @Override
public boolean mkdirs(Path path, FsPermission fsPermission)
throws IOException {
return false;
} |
2,559 | b231bb6899021dba3cec3036fab1fde4 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=101-104/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::getWorkingDirectory() | function | @Override
public Path getWorkingDirectory() {
return WORKING_DIR;
} |
2,560 | 78fa5ac6b9e2223568cc6c150529530c | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=112-115/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::getFileStatus(Path path) | function | @Override
public FileStatus getFileStatus(Path path) throws IOException {
return new FileStatus(-1, false, 1, DEFAULT_BLOCK_SIZE, 0, path);
} |
2,561 | 49b5325bd3732588e74b006891bab8de | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=151-154/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::HttpDataInputStream::seekToNewSource(long targetPos) | function | @Override
public boolean seekToNewSource(long targetPos) throws IOException {
throw new UnsupportedOperationException();
} |
2,562 | 8d1a048d72526e4206f620d689ecff49 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=76-80/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::append(Path path, int i, Progressable progressable) | function | @Override
public FSDataOutputStream append(Path path, int i, Progressable progressable)
throws IOException {
throw new UnsupportedOperationException();
} |
2,563 | 1ffafc4645a565c2930f5c519c3df10e | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=48-52/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::initialize(URI name, Configuration conf) | function | @Override
public void initialize(URI name, Configuration conf) throws IOException {
super.initialize(name, conf);
this.uri = name;
} |
2,564 | f73745b8c59456f00e7bc89f3febadcf | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=82-85/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::rename(Path path, Path path1) | function | @Override
public boolean rename(Path path, Path path1) throws IOException {
throw new UnsupportedOperationException();
} |
2,565 | a84186fc212cb80df8254cfea925d9cb | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=54-54/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::getScheme() | function | public abstract String getScheme(); |
2,566 | e88bc88bbf95579c0eb0825ee2171416 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=87-90/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::delete(Path path, boolean b) | function | @Override
public boolean delete(Path path, boolean b) throws IOException {
throw new UnsupportedOperationException();
} |
2,567 | 3068616d6d05dea11a22c0ca1f90a2de | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=141-144/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::HttpDataInputStream::seek(long pos) | function | @Override
public void seek(long pos) throws IOException {
throw new UnsupportedOperationException();
} |
2,568 | 7bce229ec00fb9bac730e1ed48306032 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=56-59/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::getUri() | function | @Override
public URI getUri() {
return uri;
} |
2,569 | 9f4b17f96f0cbfb0bb2a0a83a7d8157d | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=92-95/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::listStatus(Path path) | function | @Override
public FileStatus[] listStatus(Path path) throws IOException {
throw new UnsupportedOperationException();
} |
2,570 | ddeccd2c42bbb088cb3aee6a208ced37 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=124-128/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::HttpDataInputStream::read(long position, byte[] buffer, int offset, int length) | function | @Override
public int read(long position, byte[] buffer, int offset, int length)
throws IOException {
throw new UnsupportedOperationException();
} |
2,571 | 0b61c067c60651eb69a543f7b9f23550 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=146-149/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::HttpDataInputStream::getPos() | function | @Override
public long getPos() throws IOException {
throw new UnsupportedOperationException();
} |
2,572 | c7adccb9ab57d440d84d76792c5927f5 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=61-66/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::open(Path path, int bufferSize) | function | @Override
public FSDataInputStream open(Path path, int bufferSize) throws IOException {
URLConnection conn = path.toUri().toURL().openConnection();
InputStream in = conn.getInputStream();
return new FSDataInputStream(new HttpDataInputStream(in));
} |
2,573 | 1327c560eb88773fc5dd1c07d6514501 | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=130-134/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::HttpDataInputStream::readFully(long position, byte[] buffer, int offset, int length) | function | @Override
public void readFully(long position, byte[] buffer, int offset, int length)
throws IOException {
throw new UnsupportedOperationException();
} |
2,574 | c833b55e7057183e266099e45ffb96ca | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=68-74/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::create(Path path, FsPermission fsPermission,
boolean b, int i, short i1, long l,
Progressable progressable) | function | @Override
public FSDataOutputStream create(Path path, FsPermission fsPermission,
boolean b, int i, short i1, long l,
Progressable progressable)
throws IOException {
throw new UnsupportedOperationException();
} |
2,575 | 922d08ec0dd8838b382801be03c3cf0b | swh:1:cnt:b72a897d8ca2cff7dbc81950c99c800a680fdd0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=136-139/ | 6a90614ca38c36fbb715ca17c27671087c29815a | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/CopiedAbstractHttpFileSystem.java | CopiedAbstractHttpFileSystem::HttpDataInputStream::readFully(long position, byte[] buffer) | function | @Override
public void readFully(long position, byte[] buffer) throws IOException {
throw new UnsupportedOperationException();
} |
2,576 | 024658d59c9b23acb742021a6f34a8ee | swh:1:cnt:0c0d65c0281292a35e95c1a5e1856d1a3859aa25;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=26-45/ | d7b17f555af79302d8950c9f74bcf660b4044c80 | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/WmfHttpsFileSystem.java | WmfHttpsFileSystem | type | /**
* A Filesystem that reads from HTTPS endpoint, without mangling the URL by calling toUri() on it.
*/
public class WmfHttpsFileSystem extends CopiedAbstractHttpFileSystem {
@Override
public String getScheme() {
return "https";
}
@Override
public FSDataInputStream open(Path path, int bufferSize) thro... |
2,577 | 74aa82429cee0e4d82ef52b577f245e8 | swh:1:cnt:0c0d65c0281292a35e95c1a5e1856d1a3859aa25;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=30-33/ | d7b17f555af79302d8950c9f74bcf660b4044c80 | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/WmfHttpsFileSystem.java | WmfHttpsFileSystem::getScheme() | function | @Override
public String getScheme() {
return "https";
} |
2,578 | 63d43e3203d59fab75445c07648dd9b4 | swh:1:cnt:0c0d65c0281292a35e95c1a5e1856d1a3859aa25;origin=https://gitlab.wikimedia.org/repos/data-engineering/patches/wmf-sparksqlclidriver.git;lines=35-44/ | d7b17f555af79302d8950c9f74bcf660b4044c80 | wmf-sparksqlclidriver | analytics | src/main/java/org/apache/hadoop/fs/http/WmfHttpsFileSystem.java | WmfHttpsFileSystem::open(Path path, int bufferSize) | function | @Override
public FSDataInputStream open(Path path, int bufferSize) throws IOException {
// Original code at org.apache.hadoop.fs.http.AbstractHttpFileSystem.open
// uses path.toUri() which, for some reason, tries to url-encode our already url-encoded URL.
// Here we avoid that by going directly from Path ... |
2,579 | 30612637740edc18409954c2a60a679c | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=33-1899/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch | type | class diff_match_patch:
"""Class containing the diff, match and patch methods.
Also contains the behaviour settings.
"""
def __init__(self):
"""Inits a diff_match_patch object with default settings.
Redefine these in your program to override the defaults.
"""
# Number of seconds to map a diff... |
2,580 | 8f103587fbe2816618161a9141bd20e9 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1902-1947/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | patch_obj | type | class patch_obj:
"""Class representing one patch operation.
"""
def __init__(self):
"""Initializes with an empty list of diffs.
"""
self.diffs = []
self.start1 = None
self.start2 = None
self.length1 = 0
self.length2 = 0
def __str__(self):
"""Emmulate GNU diff's format.
Head... |
2,581 | c96b2a6a4224b04963fc21485cfa6432 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=137-195/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_compute(self, text1, text2, checklines, deadline) | function | def diff_compute(self, text1, text2, checklines, deadline):
"""Find the differences between two texts. Assumes that the texts do not
have any common prefix or suffix.
Args:
text1: Old string to be diffed.
text2: New string to be diffed.
checklines: Speedup flag. If false, then don't r... |
2,582 | dc053edcfff030feb28449fb280e2664 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=497-509/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_charsToLines(self, diffs, lineArray) | function | def diff_charsToLines(self, diffs, lineArray):
"""Rehydrate the text in a diff from a string of line hashes to real lines
of text.
Args:
diffs: Array of diff tuples.
lineArray: Array of unique strings.
"""
for x in xrange(len(diffs)):
text = []
for char in diffs[x][1]:
... |
2,583 | 6603e97e86811081eff149e51f960880 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=539-566/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_commonSuffix(self, text1, text2) | function | def diff_commonSuffix(self, text1, text2):
"""Determine the common suffix of two strings.
Args:
text1: First string.
text2: Second string.
Returns:
The number of characters common to the end of each string.
"""
# Quick check for common null cases.
if not text1 or not text2 or... |
2,584 | eb07c7649d82ca3e43bc1b69a2d53679 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=610-692/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_halfMatch(self, text1, text2) | function | def diff_halfMatch(self, text1, text2):
"""Do the two texts share a substring which is at least half the length of
the longer text?
This speedup can produce non-minimal diffs.
Args:
text1: First string.
text2: Second string.
Returns:
Five element Array, containing the prefix of t... |
2,585 | 8911f0c13402a0596845fe7391bbb45a | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=773-871/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_cleanupSemanticLossless(self, diffs) | function | def diff_cleanupSemanticLossless(self, diffs):
"""Look for single edits surrounded on both sides by equalities
which can be shifted sideways to align the edit to a word boundary.
e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
Args:
diffs: Array of diff tuples.
"""
def diff_cle... |
2,586 | 9d061a9a1f139e6f87bfba188589bc7d | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1087-1109/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_prettyHtml(self, diffs) | function | def diff_prettyHtml(self, diffs):
"""Convert a diff array into a pretty HTML report.
Args:
diffs: Array of diff tuples.
Returns:
HTML representation.
"""
html = []
i = 0
for (op, data) in diffs:
text = (data.replace("&", "&").replace("<", "<")
.rep... |
2,587 | 2e51b8d9c7de748919b6296427e8ee74 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1167-1189/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_toDelta(self, diffs) | function | def diff_toDelta(self, diffs):
"""Crush the diff into an encoded string which describes the operations
required to transform text1 into text2.
E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'.
Operations are tab-separated. Inserted text is escaped using %xx notation.
Args:
di... |
2,588 | 60ff4d1190790a1baf84e8f613bbdff0 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=197-252/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_lineMode(self, text1, text2, deadline) | function | def diff_lineMode(self, text1, text2, deadline):
"""Do a quick line-level diff on both strings, then rediff the parts for
greater accuracy.
This speedup can produce non-minimal diffs.
Args:
text1: Old string to be diffed.
text2: New string to be diffed.
deadline: Time when the dif... |
2,589 | 434ba452c0c884c46a46ae7db898fae4 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=511-537/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_commonPrefix(self, text1, text2) | function | def diff_commonPrefix(self, text1, text2):
"""Determine the common prefix of two strings.
Args:
text1: First string.
text2: Second string.
Returns:
The number of characters common to the start of each string.
"""
# Quick check for common null cases.
if not text1 or not text2 ... |
2,590 | cdcfc39f14bbe0eeb98d315a0b3205d7 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=568-608/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_commonOverlap(self, text1, text2) | function | def diff_commonOverlap(self, text1, text2):
"""Determine if the suffix of one string is the prefix of another.
Args:
text1 First string.
text2 Second string.
Returns:
The number of characters common to the end of the first
string and the start of the second string.
"""
# Ca... |
2,591 | 7214e955c2f9bf17af084b1131a984ea | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=694-771/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_cleanupSemantic(self, diffs) | function | def diff_cleanupSemantic(self, diffs):
"""Reduce the number of edits by eliminating semantically trivial
equalities.
Args:
diffs: Array of diff tuples.
"""
changes = False
equalities = [] # Stack of indices where equalities are found.
lastequality = None # Always equal to equalities... |
2,592 | 10ab37e006d7db624188fd4f9bd6f5b5 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=873-942/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_cleanupEfficiency(self, diffs) | function | def diff_cleanupEfficiency(self, diffs):
"""Reduce the number of edits by eliminating operationally trivial
equalities.
Args:
diffs: Array of diff tuples.
"""
changes = False
equalities = [] # Stack of indices where equalities are found.
lastequality = '' # Always equal to equalitie... |
2,593 | 122b4fa706291826ec038a2dd8cd27f5 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1111-1124/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_text1(self, diffs) | function | def diff_text1(self, diffs):
"""Compute and return the source text (all equalities and deletions).
Args:
diffs: Array of diff tuples.
Returns:
Source text.
"""
text = []
for (op, data) in diffs:
if op != self.DIFF_INSERT:
text.append(data)
return "".join(text) |
2,594 | 90953cc71c825484cedb426d68c57ee4 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1191-1243/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_fromDelta(self, text1, delta) | function | def diff_fromDelta(self, text1, delta):
"""Given the original text1, and an encoded string which describes the
operations required to transform text1 into text2, compute the full diff.
Args:
text1: Source string for the diff.
delta: Delta text.
Returns:
Array of diff tuples.
Rai... |
2,595 | 80e9b7f16fccfb73af2d4c285b0c2328 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1915-1947/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | patch_obj::__str__(self) | function | def __str__(self):
"""Emmulate GNU diff's format.
Header: @@ -382,8 +481,9 @@
Indicies are printed as 1-based, not 0-based.
Returns:
The GNU diff string.
"""
if self.length1 == 0:
coords1 = str(self.start1) + ",0"
elif self.length1 == 1:
coords1 = str(self.start1 + 1)
... |
2,596 | bee2edf4f70094878d4c7279aae08ac2 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1126-1139/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::diff_text2(self, diffs) | function | def diff_text2(self, diffs):
"""Compute and return the destination text (all equalities and insertions).
Args:
diffs: Array of diff tuples.
Returns:
Destination text.
"""
text = []
for (op, data) in diffs:
if op != self.DIFF_DELETE:
text.append(data)
return "".joi... |
2,597 | 373b7ce9ee60ebb072f0d2a7169e8d76 | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1577-1663/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::patch_apply(self, patches, text) | function | def patch_apply(self, patches, text):
"""Merge a set of patches onto the text. Return a patched text, as well
as a list of true/false values indicating which patches were applied.
Args:
patches: Array of patch objects.
text: Old text.
Returns:
Two element Array, containing the new t... |
2,598 | 643694941b68e6e8120d2f21d0d5f80e | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=1723-1808/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::patch_splitMax(self, patches) | function | def patch_splitMax(self, patches):
"""Look through the patches and break up any which are longer than the
maximum limit of the match algorithm.
Intended to be called only from within patch_apply.
Args:
patches: Array of patch objects.
"""
patch_size = self.Match_MaxBits
if patch_size ... |
2,599 | 8cc3e5534b0d910b64a4c0c1ea1f1a2e | swh:1:cnt:0ad37c0bf672a3e86b5945605616f5177410fef3;origin=https://gerrit.wikimedia.org/r/analytics/wikihadoop.git;lines=39-66/ | 980ff5ae28069772eca9101a836b46bb2481463e | wikihadoop | analytics | python/diff_match_patch.py | diff_match_patch::__init__(self) | function | def __init__(self):
"""Inits a diff_match_patch object with default settings.
Redefine these in your program to override the defaults.
"""
# Number of seconds to map a diff before giving up (0 for infinity).
self.Diff_Timeout = 1.0
# Cost of an empty edit operation in terms of edit characters.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.