Claude Moore

Bartender
+ Follow
since Jun 24, 2005
Claude likes ...
IBM DB2 Netbeans IDE Spring Java
Italy
Cows and Likes
Cows
Total received
39
In last 30 days
0
Total given
13
Likes
Total received
148
Received in last 30 days
0
Total given
295
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Claude Moore

I'm afraid there's no much hope for getting specs. The data are exported 'as are', from a legacy API.

D. Wizard Mutansan wrote:

Campbell Ritchie wrote:Adding you to our jobs forum.

More to the point, what do you know about machine learning? How do you think you could learn more?



I nearly know nothing yet.  All I have done is I spent few hours and learned some basic concepts like data mining, supervised learning, linear regression, gradient descent. That's it.  Even that was at concept and math level.  I was able to understand it sine my math is ok.  Other than that I don't know anything.



Dealing with gradient descent, linear regression and so on it's something that modern ML frameworks do for you automatically. Don't misunderstand me: I think that knowing what's going under the hood in ML is a MUST, if you want really achive knowledge of the theorical aspects of the matter.
If you're not aiming to work at a research facility, it's unlikely that you will develop a ML framework from scratch.
This said, ML is an HUGE field. Which sector of ML (if it could be named so) would you like to work in ? As a data scientist ? Big Data ? Artificial vision ?

Tim Holloway wrote:It depends on your datatype in the database AND in the application.
If you define a numeric value in your database as NUMERIC(6,2), then it should always be accurate to 2 decimal places. If you do database calculations on the database server, the standard math rules about precision apply.
However, if you pull values and compute them in a Java application you may have a problem, since there is no "normal" datatype for decimal values except for floating-point, and so if you pull your JDBC/ORM values as float or double, you'll get the standard floating-point fuzz. To get around that, you'd have to either scale the numbers or use a decimal-friendly class like BigDecimal. Which, alas, doesn't have operators, so it's cumbersome to work with.



Well, the complete scenario is pretty... insane. I will receive the data via an XML file, from an application A. This application will compute the total amount of the order and will send this information to a third party application C. For some obscure reason, A isn't able to tell my application the total amount  of the order in
the XML file it will exchange with me, so that I need to re-calculate the total and send to the very same application C.
Now, I don't know anything about the A application, and my experience tells me that when you have two applications calculating the very same value, there's a chance than soon or later you'll get different results.
Using BigDecimal... yes, it may be a solution, but it involves rounding mode and I cant' say which rounding mode application A would apply. For this reason, I was wondering if I can use the database server - which DOES have decimal type, and I can assume it would work like in COBOL - all operation performed with a given precision.
Obviously, the right thing should be force Application A to expose directly its summation, so that there's no chance of changing rounding.
Simple question: is it safe to use a DBMS (such SQL Server or MySql) Decimal(a,b) type to perform financial calculations (multiplications and sums) without incurring in any rounding problem ?
Suppose I have a table like this:

ORDER             ARTICLE       QTY          PRICE       VAT        LINE_AMOUNT

XYZ                  ABC              1              2.03         10           ------
XYZ                  DEF              2              7.22         10           ------
XYZ                  GHI              3              5.04         10           ------


Suppose that PRICE is the unit price, defined as decimal (6,2).  Is it safe to calculate the total amount of each row  as  UPDATE MYTABLE   SET LINE_AMOUNT =  QTY * PRICE * (1 + VAT / 100.00) and derive the total amount of   an order, let's say XYZ, as SELECT SUM(LINE_AMOUNT) WHERE ORDER = 'XYZ', or any
rounding loss may occour ?
The first thing you have to look at when something goes wrong, is the stack trace of the exception you get. In this case, you have imported the wrong Statement class (java.beans.Statement instead of , presumably, java.sql.Statement or some concrete implementation).
Fix it - Ide should assist you with some feature like 'Fix Imports'.
1 month ago
Thanks for your reply Marten ! Does it apply also for JPA ? I think that the short answer is 'no', I heard about an Hibernate project aimed to introduce support to Reactive DBMS, but I don't know what's the state of the art of such project...
4 months ago
Hi authors,

first of all, good luck for your book ! I wish to ask you a question about WebFlux and, more generally, about reactive approach in Java.
I'm just approaching to this programming style, and at the moment the most important problem I can see in adopting reactive approach is the lack of (wide) support for relational databases.
Also , we have a number of already well established  application @Services in our programs, most of which  perform somehow data access, in a transactional way.  
As far as I know, a number of annotations like @Transactional rely upon ThreadLocal variables, and ThreadLocal doesn't cope well with reactive approach.
Is there a way to avoid throwing away all good old style code and somehow get any of the benefits of the reactive approach ? A better multi-threading without callback hell approach would be enough, at least as a first step.

Thanks in advance !
4 months ago

Ron McLeod wrote:I've never heard of application/x-ndjson (newline-delimited JSON) before - it is something specific to Spring?



I dont' think it's spring-specific, but to be honest I've also never heard of it before.

Ron McLeod wrote:For streaming, I would normally use SSE or WebSockets to a browser, or gRPC (HTTP/2) to stream between services.



Yes, I also used to use websockets. I'm just doing some experiments with webflux. This is a code snipped of which I've done so far :



Please note that I'm not even sure if in a Rest Api we could use streaming. On the opposite, I'm afraid that, even if a similar approach will work, it would be against any REST principle.

Here Customer is a simple bean, irrelevant with respect the specific use case (it's just a plain bean). I would expect to get a bean every 1 second, but as I described above, I can only get the whole bunch of 10 customers.

Ron McLeod wrote:
There was an issue opened almost 4 years ago regarding streaming result support in Postman (specifically SSE) - looks like it still has not been addressed.



At the moment I tried also Google ARC (advanced rest client),  with no better luck; honestly I didn't investigate ARC further, normally I use Postman even for work and I'd prefer keep focused on a single testing tool.



4 months ago
I'm playing a bit with WebFlux and Spring 5 just to get acquainted with reactive paradigm... it's something I'm not used to use, I think it will take a fairly amount of time to be really mastered.
My first question: I developed a REST endpoint using Flux and FluxSink to dinamically generate data to be sent to the client. I developed the endpoint so that a random amount of time elapses between two subsequent calls of fluxsink.next(item) method.
As expected, if i issue a GET on the enpoint via CURL, I see that JSON entities are "streamed"  as soon as they're created in the flux; I'd like to get the same effect via PostMan, but at the moment I've only been able to get all the data all together, when the fluxsing.complete() method is invoked.
REST endpoint is declared to produce an 'application/x-ndjson' mime type.
Any suggestion ?
TIA
4 months ago
Welcome to the ranch ! I'm not an Android expert, but the first thing I suggest you to to is to clearly separate object detection task from image acquiring.
Google ML Kit you're using is unlikely to be buggy. I'd try to create a plain Java SE regular program and experiment with it passing to the kit static images from some folder; I would put the whole process of recognizing images in a separate helper class to be used later on Android app.
Once you verified that you're using Google ML Kit correctly - sorry to say that, but with ML very often the devil is in little details , I would try to use the same helper class on Android.
This way you should be able to isolate the culprit.
6 months ago

Stephan van Hulst wrote:As far as C# libraries go, I'm aware of iText and PDFsharp. I don't have experience with them so I can't give a recommendation.



I used to use iText with Java, and, to a lesser extend, with C#. It's a very good library, well documented, honestly a bit low level - you have to directly deal with Chunks, Phrases, Paragraph and so on.
6 months ago
Mike, let me tell you that the code you wrote is beautiful. But I wonder, using your approach, you could write a utility class to "mappify" (converting to a map) an object  and vice versa.
What would you think ?
Have a look at Jython library - it allows you to execute Python code within a java program.
Maybe you can work with it to extract the info you need.
6 months ago

Yehonathan Sharvit wrote:Based on your reactions in this thread, I wrote a blog post to illustrate various ways of providing dynamic data access in Java.

Looking forward to get your feedback.



There's another topic, related to Data-oriented programming, you should elaborate further: persistence.
All your examples are related to accessing data once they're in memory, but any serious program needs to persist the data it handles. JPA (and Hibernate, the de facto standard implementation) cannot handle record directly as entities.
So, if we need to use record not only to represent custom data types (like the forementioned C-struct like construct) or to use them as DTOs (data transfer objects), we need a way to work with JPA.
6 months ago