w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Spark Standalone Mode: How to compress spark output written to HDFS
The method saveAsTextFile takes an additional optional parameter of the codec class to use. So for your example it should be something like this to use gzip: someMap.saveAsTextFile("hdfs://HOST:PORT/out", classOf[GzipCodec]) UPDATE Since you're using 0.7.2 you might be able to port the compression code via configuration options that you set at startup. I'm not sure if this will work exactly, but you need to go from this: conf.setCompressMapOutput(true) conf.set("mapred.output.compress", "true") conf.setMapOutputCompressorClass(c) conf.set("mapred.output.compression.codec", c.getCanonicalName) conf.set("mapred.output.compression.type", CompressionType.BLOCK.toString) to something like this: System.setProperty("spark.hadoop.mapred.output.compress", "true") System.setProperty("spark.h

Categories : Scala

Most efficient way to test SQL connection string availibility
You're using connection.Open = true as if it were a property. It's a method: connection.Open() Use the ConnectionState enum to determine if the connection is open or not, eg: connection.State == ConnectionState.Open

Categories : C#

Test for empty Listobject header
As said by Doug Excel just creates a default header name of "Column1". If you want to read column header you can use the below code. Sub sample() Dim tbl As Object Set tbl = Sheets("sheet1").ListObjects("Table1") MsgBox Trim(tbl.ListRows(1).Range.Cells(0, 1)) End Sub

Categories : Excel

How-to Test if Umbraco property is empty
umbraco.library:GetMedia cannot return null, you may get an error back if no media was matched, in example <error>No media is maching '123123'</error> The thing is that your code works but you dont close the <xsl:attribute name="src"> as you should <xsl:attribute name="src"> <xsl:value-of select="$url" /> </xsl:attribute> If you for some reason really like to ensure that there is an image in there you should write a "test" and count values in the nodeTypeAlias <xsl:variable name="media" select="umbraco.library:GetMedia(sectionImage, 0)" /> <xsl:if test="count($media[@nodeTypeAlias='Image']) > 0"> <xsl:variable name="url" select="$media/umbracoFile" /> <xsl:element name="img"> <xsl:attribute name="src">

Categories : Xslt

PHP test if POST is empty from FORM fields
Empty isn't a particularly good validation tool when used blindly and on it's own. From the PHP manual page it will return true if: "" (an empty string) 0 (0 as an integer) 0.0 (0 as a float) "0" (0 as a string) NULL FALSE array() (an empty array) $var; (a variable declared, but without a value) Regarding the variables that you've used the likely values would pass as expected but I could just put some whitespace (" ") in the form fields and have it pass. You will want to trim($_POST["lastname"]) and others before you check it against empty(). One other thing to think about in the future is that empty() returns TRUE for 0 or 0.0 which is often undesirable behaviour. For example if your form asked me the age of my children and one of them was only recently born, I would put in 0 a

Categories : PHP

How do I test for an empty string in a Bash case statement?
Here's one workaround: case _${command} in _start) do_start ;; _stop) do_stop ;; _config) do_config ;; _) do_default ;; *) do_help ;; esac Obviously you can use whatever prefix you like.

Categories : String

How to test whether a command output is non-empty in POSIX shell?
You can check the exit status of the command also. Usually, commands if successfuly run, return an exit status of 0. git ls-files --killed > /dev/null if [ $? -eq 0 ] OR if you want to only depend on the output of the command , you can use the "head -1" along with you 1st option since anyway it looks you are not doing any processing with your command output apart from knowing the result.

Categories : Bash

ActionMailer::Base.deliveries always empty in RSpec model test in Rails 4
A combination of should_receive with and_return got my test to pass: it 'send email for an image not in Amazon that is in our table' do mailer = double mailer.should_receive(:deliver) ImageMailer.should_receive(:deleted_image).and_return(mailer) ImageMailer.deleted_image(Image.last.id).deliver end And when I comment out ImageMailer.deleted_image(Image.last.id).deliver, the test fails as expected. From this, I was able to replace ImageMailer.deleted_image(Image.last.id).deliver with my actual test where I check that calling a method on my model causes an email to be sent.

Categories : Ruby On Rails

Empty MVC4 application, how to create a simple test web api controller that returns json?
In the Web API, the name Post, Get, Put, Delete are (by default) mapped as request method name, not action name. Your API route being: api/{controller}/{id} And the request: api/test1/get/1 No suitable match will be found because the framework will try to match 4 tokens to the only existing route definitions, that contains 3 tokens (the literal api and two tokens: controller and id). If you try: api/test1/get The framework will find the Test1Controller correctly, but, based the route configuration, will bind the token "get" to the id parameter. When the framework try to find a suitable method based on your request (a GET request), it will find the Get(int id) and find a match but will not be able to convert the token "get" to an integer, which marks the method as not a good cand

Categories : C#

Nunit loads all test Test data for all the test before the test gets executed
I think that's by design. NUnit is designed to clean up the environment before any test, to generate same conditions for any test independent their execution order. If Test A would change the XDocument, Test B would be run with that changes. That might led to indeterminate test results. If Test B expects changes made from Test A, then your tests are not fully isolated, that's a bad practice. If you wan't to change that behaviour, implement a lazy field and load the test data only on first access. You can increase performance if you know that you are not changing data in any of your tests, but pay attention. private static Lazy<IEnumerable> testData = new Lazy<IEnumerable>(GetExample); private static IEnumerable GetExample() { var doc = XDocument.Load("Example.xml");

Categories : Xml

Which one is run-time efficient and storage efficient in alogarithm?
A linear search starts at the beginning and compares every element until it finds what you're looking for. A binary search splits the list in the middle and looks if your value is greater or smaller than the pivot value. Then it continues doing so recursively. For example in a list of people. You're looking for John. The binary search looks in the middle of the list and might find Mark. John is lower, so the search discards the upper half of the list, since John will not be in it, and repeats this on the lower half (recursion) A binary search is much more efficient but the list must be sorted. However - sorting a list is slower than a linear search. You won't win in efficiency by sorting a unsorted list first.

Categories : Algorithm

Getting empty data sets when creating test data [MongoDB]
Dropping the extra companies from your queries should work, as your documents are structured: { Company: "Company1", Employees: [], CEO: "" } By using syntax that is: db.companies.update({ "companies.company": "company1" }, ....) You'd need a document like this: { Companies: { Company: "Company1", Employees: [], CEO: "" } } By using db.companies.mongoDBFunction, you've specified the collection as companies already. Here's code that should work: for(var i=0; i < 1000; i++){ var name = "Company" + i; db.companies.insert({company: name, employees: [""], CEO: ""}); for(var j=0; j < 50; j++){ db.companies.update({"company": name }, {$push: {"employees": "Employee"+Math.floor(Math.random()*500)}}, f

Categories : Mongodb

Grails Spock integration test redirectedUrl different between localhost test-app and build server test-app
I've also just experienced this same issue, and it seems that it comes down to the test framework extracting the controller name from the the name of the testing class. The convention is that the test class is named <controller name>ControllerSpec In the above case, the test class should be named PriceTierControllerSpec so that the test framework will successfully resolve the controller to PriceTeir. Naming the class according to these guidelines seems to fix this problem. Further reference can be found here: https://jira.grails.org/browse/GRAILS-10962

Categories : Grails

VS2012: Clear the test results in Test Explorer when re-running a test that previously failed
You cant do that. Instead you can filter which test are shown to you, if that suits your needs. You can find more information about test here: http://msdn.microsoft.com/en-us/library/hh270865.aspx

Categories : Unit Testing

How to test single test modules in intellij in maven project having test dependency?
Got my answer there : http://youtrack.jetbrains.com/issue/IDEA-112978 That's because a run configuration is created by template. And that template has default setting to pick classes across module dependencies. For me in 132.46 the following helps: 1. Open Run Configuration dialog, Defaults section. 2. Find respective template. I tried JUnit. 3. "Test kind" combo, select All in package. 4. Set "In single module". 5. Apply to save the template. After that delete created configurations and repeat "Run All tests". It picks only classes from current module for me. The possible improvement in IDEA is to modify these defaults specially for Maven-based projects. Rather specific change...

Categories : Maven

Can you run two test cases simultaneously in a Test Suite in Microsoft Test Manager 2010?
Yes, you can with modified TestSettings file. http://blogs.msdn.com/b/vstsqualitytools/archive/2009/12/01/executing-unit-tests-in-parallel-on-a-multi-cpu-core-machine.aspx

Categories : Testing

What is more efficient: vector.clear() or if(vector.empty()) clear();?
An empty vector is a valid vector. So the operation a.clear(); is valid on an empty vector. Test for emptiness before clear is unnecessary and time consuming, so the first one is more efficient.

Categories : C++

How can i automate my test cases using test Microsoft Test Manager?
What you're looking for are called coded UI tests. You start by creating an action recording of your manual test and then creating a coded UI test from that action recording. Do a google search for "coded UI" and you'll find lots of information.

Categories : Misc

FB4Linux + Spark
Can't realize why it helps, but I repeat steps 4-7 - and in new project all goes ok. I create new project test, change options to MX + Spark and it does reset afterwards. Then I move src folder from first project - and option still doesn't reset.

Categories : Eclipse

Not able to add spark job on EC2 cluster
I suggest you try first to run it locally, once you achieve that you will have a better idea of the process involved. Follow the instructions here in the section "A standalone job in Scala". Then copy the script to the remote machine and run the script from there with: ./run spark.examples.SimpleJob IF you try to connect to your remote spark from the local script with: MASTER=spark://ec2-174-129-181-44.compute-1.amazonaws.com:7077 ./run spark.examples.SimpleJob the most probably result is that you will get a connection error as port 7077 is blocked by default in EC2.

Categories : Amazon

Spark: reduce causes StackOverflowError
I have tried to increase stack size, localize the utility functions, using spark.util.Vector, but unfortunately none of them work it out. Then I tried to downgrade Spark from 0.7.2 to 0.6.3 (https://github.com/mesos/spark/tree/branch-0.6). And it works and no more Stack Overflow even for a 10,000 by 10,000 matrix. I don't know how exactly it fix it, so I post the difference between the reduce function in RDD.scala: --- spark-0.6.3/core/src/main/scala/spark/RDD.scala 2013-06-27 11:31:12.628017194 -0700 +++ spark-0.7.2/core/src/main/scala/spark/RDD.scala 2013-06-27 13:42:22.844686240 -0700 @@ -316,39 +468,93 @@ def reduce(f: (T, T) => T): T = { val cleanF = sc.clean(f) + // println("RDD.reduce: after sc.clean") val reducePartition: Iterator[T] => Option[T] = iter =>

Categories : Java

Tests using rspec, capybara and poltergeist return empty html and empty screenshots
So eventually I got help from a colleague, and we managed to fix it. We used the lvh.me domain for this, as any request to that domain will resolve in localhost, allowing you to use subdomains without a problem. You could probably also use hostname. for this. Our spec_helper.rb now looks like this: # Use capybara in combination with poltergeist for integration tests require 'capybara/rails' require 'capybara/rspec' require 'capybara/poltergeist' require 'rack_session_access/capybara' Capybara.default_driver = :poltergeist Capybara.always_include_port = true Capybara.app_host = 'http://application-test.lvh.me' # Any lvh.me domain resolves to localhost Capybara.default_wait_time = 8 # How long capybara should look for html elements require 'vcr' VCR

Categories : Ruby On Rails

Force JAXB to Interpret Empty Element as Null not Empty String
Since this is just for one element, below is one way you could get this to work with any JAXB implementation. Java Model Foo Setup your class to use field access by leveraging the @XmlAccessorType annotation. Then initialize the field corresponding to the element as "". The implement the get/set methods to treat "" as null. import javax.xml.bind.annotation.*; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Foo { private String bar = ""; public String getBar() { if(bar.length() == 0) { return null; } else { return bar; } } public void setBar(String bar) { if(null == bar) { this.bar = ""; } else { this.bar = bar; } } } Demo Code Below is some de

Categories : Java

Why is a empty variable declaration of type String "null" and not "" (blank or empty)
It's not "null", it's null. But println displays it like that because it's defined to do so (see the Javadocs). As for why it's not initialized to an empty string, that's because String is a class type, and the default value for references to class instances is always null. There is a big difference between no object at all (i.e. null) and an object in an "empty" state.

Categories : Java

jQuery ajax call returns empty error if the content is empty
dataType: "json" means: give me json, nothing else. an empty string is not json, so recieving an empty string means that it wasn't a success... request = $.ajax({ type: "POST", url: url, data: { .... }, error: function() { console.log("error"); }, success: function(res) { var response=jQuery.parseJSON(res); if(typeof response =='object'){ if(response.reply=='2') { getResult(); } } else { //response is empty } } });

Categories : Jquery

Check if textbox is empty, and if it is empty I want plugin from bootstrap, to popover but it's not working
You're using the check variable inside your each, but that variable is still a reference to the entire set of inputs. You want to check this.value, which will be a reference to the element at the current step in the iteration (and similarly, $(this).popover()).

Categories : Javascript

PHP inserting empty row in mysql table when file upload is empty
If I recall correctly, the file upload field will create an entry in $_FILES whether it is empty or not. With that being the case, you're best to check either that $_FILES['fileupload']['size'][$key] is greater than zero OR that $_FILES['fileupload']['name'][$key] is not empty. That should give you an answer for each file upload you have on your form (even if you have many.)

Categories : PHP

Checking input type=date in if statement (empty or !empty)
$pattern = "^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$"; $date = $_POST['date']; if (!empty($username) && !empty($passwordone) && !empty($name) && !empty($email) && !empty($age) && !empty($country) && !preg_match($pattern, $date) Just add this to your validation and it should solved it

Categories : PHP

php empty check on param returns false on not empty variable
You could (should?) implement an __isset() method. The manual on empty() says: When using empty() on inaccessible object properties, the __isset() overloading method will be called, if declared.

Categories : PHP

GetContent() empty string and empty inputstream for "text/html"
Use the JavaMail demo program msgshow.java (download here) to read your test message file to make sure the file format is correct. (Copy/paste isn't the most reliable way to create a properly formatted file.) "java msgshow -m The JavaMail FAQ has additional debugging tips.

Categories : Java

error when reading from S3 using Spark/Hadoop
When you run a Hadoop job you have to set the Hadoop classpath Environmental Variable. Typically, this is done in the Hadoop startup script. export HADOOP_CLASSPATH=/path/to/yourlib:/path/to/your/other/lib replace the : with a ; if you are on windows.

Categories : Hadoop

Scala spark Matrix operations
This will be covered by the MLbase project and the MLI API which will integrated in Spark. This is still in early stage but you can find an example of Linear Regression here.

Categories : Scala

load extended controller from CI spark
Try to do something like that: class Wellcome extends CI_Controller { protected static $_nci = null; public function __construct(){ parent::__construct(); $this->_nci = $this->load->spark('nci-extensions/0.0.4'); } public function index(){ $result = $this->_nci->getSomething(); echo $result; } }

Categories : PHP

MX components in a spark container are null
I would have expected the Flex life cycle method createChildren() is where you could do your operations. But you'd want to only do this work AFTER the super class has executed createChildren(): override protected function createChildren():void { super.createChildren(); // now do your thing } Another thing is that in the commitProperties() method you show above, you are not calling the super class method. That is a big no-no. The commitProperties() method is invoked by the Flex framework AFTER createChildren(). So theoretically, your approach with commitProperties() should have worked -- you might go back and put a call to super.commitProperties() in that code and give it another go. Finally, if none of this works it may be due to the way Flex instantiates the children objects i

Categories : Misc

Spark Configuration: SPARK_MEM vs. SPARK_WORKER_MEMORY
A standalone cluster can host multiple Spark clusters (each "cluster" is tied to a particular SparkContext). i.e. you can have one cluster running kmeans, one cluster running Shark, and another one running some interactive data mining. In this case, the 22GB is the total amount of memory you allocated to the Spark standalone cluster, and your particular instance of SparkContext is using 3GB per node. So you can create 6 more SparkContext's using up to 21GB.

Categories : Scala

How to set up Spark cluster on Windows machines?
FYI, I got an answer in the user-group: https://groups.google.com/forum/#!topic/spark-users/SyBJhQXBqIs The standalone mode is indeed the way to go. Mesos does not work under Windows and YARN probably neither.

Categories : Apache

how to add for loop with spark view engine
No direct way, but several indirect methods are listed in this page: https://groups.google.com/forum/#!searchin/spark-dev/for$20loop/spark-dev/vfUUg2KUFk4/yqJ4iRUNYC4J

Categories : Misc

How to get loading gif when an html element is empty and remove when is not empty?
You don't need else if condition try this - $("#search").click(function() { if($.trim($("#results").html())=='') { $('#loading').show(); } else{ $('#loading').hide(); } });

Categories : Jquery

Subsetting on all but empty grep returns empty vector
It's because grep returns an integer vector, and when there's no match, it returns integer(0). > grep("d", vec) [1] 4 > grep("z", vec) integer(0) and the since the - operator works elementwise, and integer(0) has no elements, the negation doesn't change the integer vector: > -integer(0) integer(0) so vec[-grep("z", vec)] evaluates to vec[-integer(0)] which in turn evaluates to vec[integer(0)], which is character(0). You will get the behavior you expect with invert = TRUE: > vec[grep("d", vec, invert = TRUE)] [1] "a" "b" "c" "e" > vec[grep("z", vec, invert = TRUE)] [1] "a" "b" "c" "d" "e"

Categories : R

Get last non-empty cell in a row or get last column with a non-empty header in Excel
Do not click on row that is to be left completely blank. E.g.: If your data ends at row 8, do not click in row 9 or 10 or any row greater than that. As excel sheet counts these rows and sends blank. If you are using OLEDB connection it reads that blank row and column only if you have clicked on a single cell in that row or column or Check for null explicitly through your code.

Categories : C#

© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.