A confusion about import in Spark - scala

I read the source code of KMeans.scala in spark and it confused me with the following code:
import org.apache.spark.Logging
import org.apache.spark.annotation.Experimental
import org.apache.spark.mllib.linalg.{Vector, Vectors}
import org.apache.spark.mllib.linalg.BLAS.{axpy, scal}
import org.apache.spark.mllib.util.MLUtils
import org.apache.spark.rdd.RDD
import org.apache.spark.storage.StorageLevel
import org.apache.spark.util.Utils
import org.apache.spark.util.random.XORShiftRandom
I found the file RDD is in the path "spark-1.4.0\core\src\main\scala\org\apache\spark\rdd" which corresponds to import org.apache.spark.rdd.RDD. But the file MLUtils is in the path "spark-1.4.0\mllib\src\main\scala\org\apache\spark\mllib\util" which corresponds to import org.apache.spark.mllib.util.MLUtils.
Why their import paths start with "org.apache.spark"? It seems they are in the same folder "spark".

Why do their import paths start with "org.apache.spark"?
Path to the source file doesn't determine the package it belongs to, package declarations in it do. Nonetheless, it's standard (and useful in some ways) to put source files in the directory corresponding to the package, under src/main/scala or <subproject(core and mllib in these two cases)>/src/main/scala. Relative to it you can see the directories are org/apache/spark/rdd and org/apache/spark/mllib/util, just as in imports.

Related

ImportError: cannot import name 'compute_associations' from 'dython.nominal'

I just installed dython using pip install dython to use the tabsyndex. Here is the block of import
import pandas as pd
from tabsyndex import tabsyndex
from sklearn.model_selection import train_test_split
and it always shows
ImportError: cannot import name 'compute_associations' from 'dython.nominal'
Are there any way to import compute associations?
So far I tried reinstalling dython, but it always show the same error.

import com. ... cannot be resolved issue

I found a carousel source code from internet.
Instead of importing project, I copied it to my project and pasted in the library files.
However, I still have an error on the line:
import com.arduandro.CarouselView.R;
How can I fix it?
Problem occurs on the second line of the following code:
import com.nineoldandroids.view.ViewHelper;
import com.arduandro.CarouselView.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
Are you using Eclipse? If yes, you have to import the .jar and add it to the build path

Error in compilation of scala file in play

I have a Scala file and I am using Play Framework 2.0.4 to compile it. Here is a part of it
import play.api.templates.Html;
import play.api.templates.Txt;
import securesocial.controllers.Registration.RegistrationInfo;
import securesocial.controllers.TemplatesPlugin.
import securesocial.core.{SecuredRequest, SocialUser};
import play.api.data.Form;
import securesocial.core.Identity;
import securesocial.core.SecureSocial._;
import securesocial.controllers.PasswordChange.ChangeInfo;
At compile time I get this error
identifier expected but 'import' found.
What is the issue here?
Could it be import securesocial.controllers.TemplatesPlugin.: the trailing dot?
Either remove the dot or make it import securesocial.controllers.TemplatesPlugin._

The import com.interwoven cannot be resolved

I am new to Teamsite and a not sure which jar file to use for resolving the issue that I get while trying to write a Java Datasource in Eclipse.
The list of imports I am using are:
import com.interwoven.datasource.MapDataSource;
import com.interwoven.datasource.core.DataSourceContext;
import com.interwoven.livesite.dom4j.Dom4jUtils;
import com.interwoven.serverutils100.InstalledLocations;
import com.interwoven.cssdk.filesys.CSVPath;
All these imports show the same error
The import com.interwoven cannot be resolved.
Can anyone please tell me which jar files should I add?

Problem when importing package in scala

Suppose I have such packages:
package test
package test.views
package test.others
package views
Now in a scala file, I want to import test._ and views._(not test.views._), so I write:
import test._
import views._
But when I use some classes under views._, it reports type xxx not found, unless I change views package to another name.
What should I do now?
You can switch package import order (theoretically it should work):
import views._
import test._
Or you can be more precise in views import:
import _root_.views._
Here's yet another way (though using _root_ is the surest way to go):
import test.{views => testviews, _}
import views._