TypeError: ‘RDD’ object does not support indexing [on hold]

I am working on the optimization of an algorithm which is implemented in python and Now I want to optimize it using Pyspark. I have checked my code and works fine however there is an error in the last line stating @TypeError: ‘RDD’ object does not support indexing”. I need help to solve the error or suggest an alternative to do it. Thanks. Snapshots of code are attached.

Code showing value for variables Error

Update the index of the related object after spice in an object using JavaScript

There are 2 variables:

var brands =  [     {Brand: "Hyundai"},     {Brand: "Toyota"},     {Brand: "Honda"},     {Brand: "Volkswagen"} ]  var cars =[     {Car: "Elantra", BrandIndex = 0},     {Car: "Tucson", BrandIndex = 0},     {Car: "Creta", BrandIndex = 0},     {Car: "Verna", BrandIndex = 0},     {Car: "Camry", BrandIndex = 1},     {Car: "Fortuner", BrandIndex = 1},     {Car: "Corolla", BrandIndex = 1},     {Car: "Civic", BrandIndex = 2},     {Car: "CR-V", BrandIndex = 2},     {Car: "City", BrandIndex = 2},     {Car: "Polo", BrandIndex = 3},     {Car: "Passat", BrandIndex = 3},     {Car: "Beatle", BrandIndex = 3},     {Car: "Vento", BrandIndex = 3} ] 

BrandIndex is the index of the Brand variable items.

The code is written as such that when a Brand is deleted (spliced from Brands variable), its corresponding car are spliced as well which is identified by BrandIndex.

Now the issue is that we need to update the BrandIndex of the other cars. eg.

If Toyota is deleted, the cars variable looks like

cars =[     {Car: "Elantra", BrandIndex = 0},     {Car: "Tucson", BrandIndex = 0},     {Car: "Creta", BrandIndex = 0},     {Car: "Verna", BrandIndex = 0},     {Car: "Civic", BrandIndex = 2},     {Car: "CR-V", BrandIndex = 2},     {Car: "City", BrandIndex = 2},     {Car: "Polo", BrandIndex = 3},     {Car: "Passat", BrandIndex = 3},     {Car: "Beatle", BrandIndex = 3},     {Car: "Vento", BrandIndex = 3} ] 

How do we update the brand Index of Honda as 1 and Volkswagen as 2 for all the cars on deletion?

Magento 2: How to load data by Page using same collection object again?

I am using \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory and loading data by creating objects.

$  collection = $  this->collectionFactory->create()                     ->addAttributeToSelect('*')                     ->addAttributeToFilter('type_id',  array('simple', 'configurable'))                     ->setPageSize($  limit)                     ->setCurPage(1); $  result = $  collection->getData();  

The $ result contains the first-page result. Can I use the same object to render the second-page result?.

Best way to let user select something underneath another an object

For an application I’m developing I’ve been thinking about an aspect of the UI. Imagine I have an application that lets me draw shapes. I can select drawn shapes by clicking inside of them. But there’s a major problem: overlapping shapes are allowed. If one shape completely overlaps the other, a user can still see it because the shape is transparent but there is no way for her to select it. Being able to still somehow select it is required.

Apart from having a list of shapes wherein the overlapped shape can be selected, is there a mechanism that is commonly employed or considered intuitive? I’ve been thinking about this for a while and googling around. I can think of one option: when a shape is clicked I could display little buttons next to the shape that hide the shape or show the overlapping shape again. But I feel this is not really ideal because it might be unintuitive/undiscoverable.

Any ideas?

Thanks in advance, Joshua

How to fix my code from the tutorial, Training YOLOv3 : Deep Learning based Custom Object Detector?

So I have tried the tutorial Training YOLOv3 : Deep Learning based Custom Object Detector from learnopencv, but I cannot manage to correctly implement it. I have correctly followed all the steps from 1-6. But I have a problem at step 7. When I train the darknet model, I get the following reply Loading weights from ./darknet53.conv.74...Done!

But after that, nothing happens. I have let it run for an hour but I see no result, and there is no change to my train.log file. How should I fix this? Also, I am running this code on my Macbook terminal(would I need to use a VM instead?).

Thanks for your help, Hernades Freeman

Чем класс Object отличается от других родительских классов?

Есть классы:

class Monster{ //Родительский класс           public void eat(){             System.out.println("Есть всё!");         }       }      public class Smm extends Monster {         public static void main(String[] args) {             Monster[] monster  = new Monster[3];             monster[0]=new Monster();             monster[1]=new Smm();             monster[2]=new Vurdalak();             for (int i=0; i<monster.length;i++){                 monster[i].eat();             }         }         public void eat(){             System.out.println("Никто не знает, что я ем!");         }          }       public class Vurdalak extends Monster {         public void eat(){             System.out.println("Есть мясо!");         }     } 

После выполнения данной программы, получаем следующий результат: введите сюда описание изображения

Но почему, если в качестве родительского класса использовать класс Objekt, ничего не получиться?

Attempt to invoke virtual method ‘boolean android.widget.CheckBox.isChecked()’ on a null object reference, if com CheckBox não funciona, o que faço?

Estou com um erro que ridiculamente parece facil, mas não consigo resolver. -No meu xml tem um CheckBox retornando false(desativada), no meu java tem um simples if(termosUso.isChecked()){}, em tese era para que quando o CheckBox estivesse retornando true(selecionado), ele execultar oq estiver dentro do if ou no simplesmente dar continuidade ao programa, quando eu do um ‘Run’ ele execulta no celular mas o CheckBox não funciona, quando debugo o app aparece no console o seguinte erro quando clico no botão de registrar:


E/AndroidRuntime: FATAL EXCEPTION: main Process: app.conect.medicconect1, PID: 12972 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.CheckBox.isChecked()' on a null object reference     at app.conect.medicconect1.LoginActivity$  4.onClick(LoginActivity.java:178)     at android.view.View.performClick(View.java:6600)     at android.view.View.performClickInternal(View.java:6577)     at android.view.View.access$  3100(View.java:781)     at android.view.View$  PerformClick.run(View.java:25912)     at android.os.Handler.handleCallback(Handler.java:873)     at android.os.Handler.dispatchMessage(Handler.java:99)     at android.os.Looper.loop(Looper.java:193)     at android.app.ActivityThread.main(ActivityThread.java:6923)     at java.lang.reflect.Method.invoke(Native Method)     at com.android.internal.os.RuntimeInit$  MethodAndArgsCaller.run(RuntimeInit.java:493)     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) 


 <CheckBox             android:id="@+id/termosUso2"             android:layout_width="314dp"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:checked="false"             android:drawableRight="@drawable/icon_termo_uso"             android:text="Li e Concordo com os Termos de Uso."             android:textStyle="italic" /> 


package app.conect.medicconect1; 

import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import com.google.android.material.snackbar.Snackbar; import com.google.android.material.textfield.TextInputLayout; import com.google.gson.JsonObject; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion;

public class LoginActivity extends AppCompatActivity {

protected EditText emaillog, password;//Parte de Login protected Button login, cadastreSe, desn;//Tela de Login protected TextInputLayout txtInLayoutUsername, txtInLayoutPassword, txtInLayoutRegPassword;//2 telas (LAYOUT) protected CheckBox rememberMe;//Tela de Login private String HOST = "";//HOST da pasta do mysql para ter acesso aos arquivos protected EditText nomeCad, apelidoCad, emailCad, passwordCad, passwordConfCad;//Parte de cadastro protected Button cadastroCad;//Tela de cadastro protected CheckBox termosUso;//Tela de cadastro  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_login);      emaillog = findViewById(R.id.emaillog2);     password = findViewById(R.id.password2);     login = findViewById(R.id.login2);     cadastreSe = findViewById(R.id.cadastreSe2);     desn = findViewById(R.id.desenvolvedor2);     termosUso = (CheckBox) findViewById(R.id.termosUso2);     txtInLayoutUsername = findViewById(R.id.txtInLayoutUsername);     txtInLayoutPassword = findViewById(R.id.txtInLayoutPassword);     rememberMe = findViewById(R.id.rememberMe);      ClickLogin();      cadastreSe.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View view) {             ClickSignUp();         }     });     desn.setOnClickListener(new View.OnClickListener(){...}); }  private void ClickLogin() {...}  private void ClickSignUp() {      AlertDialog.Builder dialog = new AlertDialog.Builder(this);     LayoutInflater inflater = getLayoutInflater();     View dialogView = inflater.inflate(R.layout.register, null);     dialog.setView(dialogView);      nomeCad = dialogView.findViewById(R.id.nomeCad2);     apelidoCad = dialogView.findViewById(R.id.apelidoCad2);     passwordCad = dialogView.findViewById(R.id.passwordCad2);     passwordConfCad = dialogView.findViewById(R.id.passwordConfCad2);     emailCad = dialogView.findViewById(R.id.emailCad2);     cadastroCad = dialogView.findViewById(R.id.cadastroCad2);     txtInLayoutRegPassword = dialogView.findViewById(R.id.txtInLayoutRegPassword);      cadastroCad.setOnClickListener(new View.OnClickListener(){         @Override         public void onClick(View view) {             String nome = nomeCad.getText().toString();             String apelido = apelidoCad.getText().toString();             String email = emailCad.getText().toString();             String senha = passwordCad.getText().toString();             String senhaConf = passwordConfCad.getText().toString();             String URL = HOST + "cadastrar.php";                 if (nomeCad.getText().toString().trim().isEmpty())         {                 nomeCad.setError("Por favor, preencha este campo");             }  if (passwordCad.getText().toString().trim().isEmpty())     {                 passwordCad.setError("Por favor, preencha este campo");             }  if (apelidoCad.getText().toString().trim().isEmpty())      {                 apelidoCad.setError("Por favor, preencha este campo");             }  if (emailCad.getText().toString().trim().isEmpty())        {                 emailCad.setError("Por favor, preencha este campo");             }  if (passwordConfCad.getText().toString().trim().isEmpty()) {                 passwordConfCad.setError("Por favor, preencha este campo");             }                 if (senhaConf.equals(senha)){                 if (nome.trim().isEmpty() || apelido.trim().isEmpty() || email.trim().isEmpty() || senha.trim().isEmpty() || senhaConf.trim().isEmpty()) {                     Toast.makeText(LoginActivity.this, "Por Favor verifique se os campos estão preenchidos corretamente.", Toast.LENGTH_LONG).show();                 }else {                     if (termosUso.isChecked()) {//está é a linha 178 no java e aparecentemente a que está errada!                          Ion.with(LoginActivity.this)                                 .load(URL)                                 .setBodyParameter("nome_app", nome)                                 .setBodyParameter("apelido_app", apelido)                                 .setBodyParameter("email_app", email)                                 .setBodyParameter("senha_app", senha)                                 .asJsonObject()                                 .setCallback(new FutureCallback<JsonObject>() {                                     @Override                                     public void onCompleted(Exception e, JsonObject result) {                                         try {                                             //   Toast.makeText(cadastroActivity.this, "Nome: " + result.get("NOME").getAsString(), Toast.LENGTH_LONG).show();                                             String RETORNO = result.get("CADASTRO").getAsString();                                              if (RETORNO.equals("EMAIL_ERRO")) {                                                 Toast.makeText(LoginActivity.this, "Ops! Este email já está cadastrado", Toast.LENGTH_LONG).show();                                             } else if (RETORNO.equals("SUCESSO")) {                                                 // Toast.makeText(cadastroActivity.this, "Cadastrado com sucesso", Toast.LENGTH_LONG).show();                                                 Intent abreHome = new Intent(LoginActivity.this, homeActivity.class);                                                 startActivity(abreHome);                                             } else {                                                 Toast.makeText(LoginActivity.this, "Ops! Ocorreu um erro", Toast.LENGTH_LONG).show();                                             }                                         } catch (Exception erro) {                                             Toast.makeText(LoginActivity.this, "ops! Ocorreu um erro, " + erro, Toast.LENGTH_LONG).show();                                          }                                     }                                 });                     }else{                         Toast.makeText(LoginActivity.this, "Para continuar é preciso concordar com os termos de uso!", Toast.LENGTH_LONG).show();                     }                 } //fecha else dos camposvazios             }else {                 Toast.makeText(LoginActivity.this, "Senhas Diferentes!", Toast.LENGTH_LONG).show();                    passwordConfCad.setError("Por favor, preencha este campo");             }         }     });     dialog.show(); } 


Why all classes in .NET globally inherits from Object class?

Its very interesting for me which advantages gives “global root class” approach for framework. In simple words what reasons resulted the .NET framework was designed to have one root object class with general functionality suitable for all classes.

Nowadays we are designing new framework for internal use (the framework under SAP platform) and we all divided into two camps – first who thinks that framework should have global root, and the second – who thinks opposite.

I am at “global root” camp. And my reasons what such approach would yields good flexibility and development costs reduction cause we will not develop general functionality any more.

So, I’m very interested to know what reasons really push .NET architects to design framework in such way.

How can OnMouseDown in the parent object be triggered from the child placed on top of it?

I am learning Unity from a book. The example is to create a 2D memory game as follows (viewed in perspective view).

enter image description here

The green (background) at z=5, the purple diamond (front card) at z=0 and the red (back card) at z=-5 for example. The front card is set as the parent of the back card in the hierarchy window.

A box collider (2D) component and a script below are attached only to the parent.

public class FrontCard: MonoBehaviour {     public void OnMouseDown()     {         Debug.Log("testing 1, 2, 3!");     } } 

When I play the game and click the back card, the OnMouseDown gets invoked.


How can the OnMouseDown get invoked when I click the back card by considering the script is attached to the front card game object that is placed below the back card?