objc NSData vs. Swift Data when bridging failing - objective-c-swift-bridge

I’m not so sure this is a dumb newbie question so I kept that out of the subject line ;-) My app has a few objC frameworks that are being bridged in via the bridging header. One issue I’m seeing at runtime has to do with the objC NSData object length property vs. the Swift Data count property.
The line of code from the framework in this case looks like this
if([request.requestBody length] > 0){
and the interface for request object looks like this…
interface AEServiceRequest : NSObject
property(nonatomic, readonly, strong, nullable) NSData *requestBody;
when the app is run and it interrogates the length method (also was .length) the exception thrown below as if the length call did not get converted into count but the NSData object did get converted into Data. Just a guess. Has anyone seen this type of thing in their experience ? Is there a fix for it that I’m missing ?
I add in some NSLogs into the framework code for tracing...
AEDAService: AEService 1.4.2 init started...
2016-08-25 14:12:44.592 AEDemoApp_Swift_OSX[24703:4124653] Entering: _urlRequest
2016-08-25 14:12:44.592 AEDemoApp_Swift_OSX[24703:4124653] Start call: if(request.requestBody.length > 0
2016-08-25 14:12:44.592 AEDemoApp_Swift_OSX[24703:4124653] -[_SwiftValue length]: unrecognized selector sent to instance 0x61800004c480
2016-08-25 14:12:44.593 AEDemoApp_Swift_OSX[24703:4124653] An uncaught exception was raised
2016-08-25 14:12:44.593 AEDemoApp_Swift_OSX[24703:4124653] -[_SwiftValue length]: unrecognized selector sent to instance 0x61800004c480
2016-08-25 14:12:44.593 AEDemoApp_Swift_OSX[24703:4124653] (
0 CoreFoundation 0x00007fff942d04f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8c9a873c objc_exception_throw + 48
2 CoreFoundation 0x00007fff9433a1ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
Anyone seen this type of behavior before. BTW Using xCode 8 beta 6 w/ Swift 3

Related

Magento 2 : Exception #0 (Exception): Recoverable Error:

I have moved one magento 2 website from one server to another, after configuration, I got below error on category pages:
1 exception(s):
Exception #0 (Exception): Recoverable Error: Argument 1 passed to Mageplaza\Core\Helper\AbstractData::__construct() must be an instance of Magento\Framework\App\Helper\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /SOME_PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /SOME_PATH/app/code/Mageplaza/Core/Helper/AbstractData.php on line 56
Exception #0 (Exception): Recoverable Error: Argument 1 passed to Mageplaza\Core\Helper\AbstractData::__construct() must be an instance of Magento\Framework\App\Helper\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /SOME_PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /SOME_PATH/app/code/Mageplaza/Core/Helper/AbstractData.php on line 56
I have tried below things to resolve above:
Reindexing
Re-save category pages from backend
Created new category, and found its page working fine.
It seems there is a problem with database where old category urls need to be reindexed/rewritten or processed some way.
Can anyone help me to resolve this or any guide how I can troubleshoot this further?
Any help is appreciated!
Thanks
Deleting var/di directory resolves the problem. I didn't need to run any CLI command nor I need to do any cache clear stuff!

Java out of memory error when I import data from json file in Kettle

I try to import data from a json file in kettle,but unfortunately I encountered a java error : java.lang.OutOfMemoryError: Java heap space.
The build version of my kettle is 5.4.0.1-130 and the format of my data looks like this :
[{"movie_title": "Carmen (English Subtitled)"},
{"movie_title": "Sugar Valentine"},
{"movie_title": "Segovia at Los Olivos [VHS]"},
{"movie_title": "Lost Boys of Sudan [VHS]"},
{"movie_title": "The Virgin of Juarez"},
{"movie_title": "Red Dawn ('84)"},
{"movie_title": "The Complete Story Deftones"},
{"movie_title": "It Came From Somewhere Else"},
{"movie_title": "Rubi"},
{"movie_title": "Fushigi Yugi - The Mysterious Play (Vol. 1)"},
{"movie_title": "Tenchi Universe, Vol. 4"}]
And this is a json file with 210000+ records actually.
I try to import all the movie_titles and I chose the 'Json Input' step in kettle.
The configuration of fields looks like this :
Name : movie_title
Path : [*].movie_title
Type : String
Trim type : none
Repeat : N
After I clicked Preview rows , an error occurs with information like
2015/10/25 11:45:45 - Version checker - OK
2015/10/25 15:10:23 - /Users/Chris/Desktop/exercise_2/Exercise_2_Step3.ktr : Exercise_2_Step3 - Dispatching started for transformation [/Users/Chris/Desktop/exercise_2/Exercise_2_Step3.ktr : Exercise_2_Step3]
2015/10/25 15:10:31 - Json Input.0 - ERROR (version 5.4.0.1-130, build 1 from 2015-06-14_12-34-55 by buildguy) : UnexpectedError:
2015/10/25 15:10:31 - Json Input.0 - ERROR (version 5.4.0.1-130, build 1 from 2015-06-14_12-34-55 by buildguy) : java.lang.OutOfMemoryError: Java heap space
2015/10/25 15:10:31 - Json Input.0 - Finished processing (I=0, O=0, R=0, W=0, U=0, E=1)
2015/10/25 15:10:31 - /Users/Chris/Desktop/exercise_2/Exercise_2_Step3.ktr : Exercise_2_Step3 - Transformation detected one or more steps with errors.
2015/10/25 15:10:31 - /Users/Chris/Desktop/exercise_2/Exercise_2_Step3.ktr : Exercise_2_Step3 - Transformation is killing the other steps!
Does anyone know how to solve this problem?
I did some tests and got the same result - OutOfMemoryError.
I generate sample of json file to experiment.
JSON file with array, contains 300000 elements. Each element with movie_title field equal to 60 symbol.
Whole file in total takes 22MB space.
Kettle use javascript engine in jvm to parse json becouse error thrown in class
sun.org.mozilla.javascript.internal.Parser
It looks like that it tries to parse and load whole json file into memory before to apply any JsonPath expressions. Result is OutOfMemoryErrror.
What actually u can do is to use JavaScript step or User Defined Java Class to load json file into memory and use Java Api to parse json.
This might help
Nashorn JSON.parse() - java.lang.OutOfMemoryError: Java heap space - JDK8u60

Get Exceptions: 1 when running nodetool info?

When running nodetool info in Cassandra get below output:
----------
Gossip active : true
Thrift active : true
Load : 423.25 GB
Generation No : 1371022989
Uptime (seconds) : 514706
Heap Memory (MB) : 4148.05 / 7987.25
Data Center : datacenter1
Rack : rack1
Exceptions : 1
----------
please note : Exceptions : 1
would like to know exactly what it means and how to resolve (if there is any need to resolve)
The exceptions count gets incremented when there is an uncaught exception in the Cassandra daemon. When this happens it also logs the error like this:
logger.error("Exception in thread {}", t, e);
So to see what the actual error was, you'd need to check the Cassandra log file.
A count of 1 is not particularly worrisome since it may have just been a glitch of some kind. If it happens consistently or more frequently, then it would be more concerning.

Jasper string functions method undefined error

Using Jasper Reports 5.6.1. Added some text functions to a previously working text field jrxml (just want to truncate if longer than 75 chars). Works in iReport Studio, but not in Java.
<textFieldExpression><![CDATA[IF(LEN($F{AccountName})<75,$F{AccountName},LEFT($F{AccountName},75)+"...")]]></textFieldExpression>
Error message:
Error occured while trying to fetch the HTML Output from the Jasper Service (Errors were encountered when compiling report expressions class file:
1. The method LEN(String) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
<->
2. The method LEFT(String, int) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
<-->
3. The method LEN(String) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getOldValue()))<75,((java.lang.String)field_AccountName.getOldValue()),LEFT(((java.lang.String)field_AccountName.getOldValue()),75)+"..."); //$JR_EXPR_ID=9$
<->
4. The method LEFT(String, int) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getOldValue()))<75,((java.lang.String)field_AccountName.getOldValue()),LEFT(((java.lang.String)field_AccountName.getOldValue()),75)+"..."); //$JR_EXPR_ID=9$
<-->
5. The method LEN(String) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
<->
6. The method LEFT(String, int) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
<-->
6 errors
)
I checked packages in jasperreports-5.6.1.jar file, includes functions package. Exhaustive web search turned up nothing. What could it be?
I have a similar error message. Where you able to resolve this? Works fine in Jaspersoft Studio 6.0.1, but throws this when compiling w/ Java:
The method IF(boolean, BigDecimal, BigDecimal) is undefined for the type Blank_A4_1_1423164610392_674232
Update: I was able to solve this by including the functions jar on my classpath. See that if that works for you. See jasperreports-functions-5.6.1.jar at http://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%205.6.1/
When using GlassFish, verify that you have all jasper libraries on your production server. They should be under glassfish/domains/domain1/lib/ext. If the jars are not there (or some of them, such as the fonts or some other not non-requisite lib) you might experience the behavior you are describing.

The difference between parsing using a string or a stream (Poco c++)

I have written a simple hierarchical json-parser, using POCO JSON, to be used as a sax parser.
Is their any difference in the result if i use a string or a stream as input to the parse method, see call below, or are the different constructors equivalent?
Parser parser;
DefaultHandler handler;
parser.setHandler(&handler);
parser.parse(input);
In terms of memory consumption, speed etc?
std::string version is just a wrapper that creates stream on your behalf, so at the end the total will be roughly the same, string is just more convenient for user.
[EDIT]
This was changed for 1.5.2 - wrapping was removed so that now both (stream and string) versions iterate. The Benchmark Example can be used to determine how much is stream slower than string.
[/EDIT]
Please note that there are some breaking changes coming in 1.5.2 - DefaultHandler name was removed and internally handler has been turned into auto-created smart pointer (that's the main reason we had to obsolete DefaultHandler so existing code would not pass stack-created handler to the smart pointer, it was not a good design to start with). So, in 1.5.2, explicit handler creation will not be needed anymore for default parsing:
std::string json = "{ \"test\" : null }";
Parser parser;
Var result = parser.parse(json);
If you are concerned with performance, note also that Poco::JSON parser speed, as it stands now, is poor and we will be using either the very fast parser from Poco::Web::JSON or something faster (if we can find/write it). Bottom line, 1.5.x is still W.I.P.
Hope this helps.
EDIT:
Benchmarks on Windows and Mac (~15MB JSON file):
Windows
Poco::JSON: 1 195 313 [us]
Poco::Web::JSON: 403 320 [us]
json-parser: 321 289 [us]
libjson: 610 352 [us]
MAC (clang)
Poco::JSON: 480 965 [us]
Poco::Web::JSON: 176 297 [us]
json-parser: 220 172 [us]