archive-cr.com » CR » I » INFORMATECH.CR

Total: 292

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • facebook | Informatech CR Blog
    MySQL Scale How do you get MySQL to process 13 million queries per second Check it out here 9 933333 84 083333 Share this Email Facebook Twitter Like this Like Loading November 5 2010 by pjpalm801 Categories Programming Web Tags facebook mysql Leave a comment Post navigation Create a free website or blog at WordPress com The Ari Theme Informatech CR Blog Blog at WordPress com The Ari Theme Follow

    Original URL path: http://blog.informatech.cr/tag/facebook/ (2015-08-19)
    Open archived version from archive


  • About Us | Informatech CR Blog
    it would be easier to follow via rss if you could publish summary feeds instead of all of articles Reply Leave a Reply Cancel reply Enter your comment here Please log in using one of these methods to post your comment Email required Address never made public Name required Website You are commenting using your WordPress com account Log Out Change You are commenting using your Twitter account Log Out

    Original URL path: http://blog.informatech.cr/about/?shared=email&msg=fail (2015-08-19)
    Open archived version from archive

  • Java 8 Streams and JPA | Informatech CR Blog
    defined above and transform it into a Spliterator by doing private Spliterator T toSplitIterator ScrollableResults scroll Class T type return Spliterators spliteratorUnknownSize new ScrollableResultIterator scroll type Spliterator DISTINCT Spliterator NONNULL Spliterator CONCURRENT Spliterator IMMUTABLE This Splititerator is an intermediate product that we can now use to create a Java 8 stream out of it StreamSupport stream spliterator false At this point we have built enough to create our first stream out of a JPQL query We can do it as follows public Stream T getResultStream String sql Integer fetchSize Map String Object parameters Query query session createQuery sql if fetchSize null query setFetchSize fetchSize for Map Entry String Object parameter parameters entrySet query setParameter parameter getKey parameter getValue query setReadOnly true ScrollableResults scroll query scroll ScrollMode FORWARD ONLY return StreamSupport stream toSplitIterator scroll type false onClose scroll close A JPA Stream API We can do a little bit better by defining the basics of the type of query object we are currently missing in JPA Standard API public interface StreamQuery T Stream T getResultStream StreamQuery T setParameter String name Object value StreamQuery T setFetchSize int fetchSize And putting together all we have learned so far we could create this implementation of our new StreamQuery interface public class HibernateQueryStream T implements StreamQuery T private final Session session private final String sql private final Class T type private final Map String Object parameters new HashMap private Integer fetchSize public HibernateQueryStream EntityManager entityManager String sql Class T type this session entityManager unwrap Session class this sql sql this type type Override public StreamQuery T setParameter String name Object value parameters put name value return this Override public StreamQuery T setFetchSize int fetchSize this fetchSize fetchSize return this Override public Stream T getResultStream Query query session createQuery sql if fetchSize null query setFetchSize fetchSize query setReadOnly true for Map Entry String Object parameter parameters entrySet query setParameter parameter getKey parameter getValue ScrollableResults scroll query scroll ScrollMode FORWARD ONLY return StreamSupport stream toSplitIterator scroll type false onClose scroll close private Spliterator T toSplitIterator ScrollableResults scroll Class T type return Spliterators spliteratorUnknownSize new ScrollableResultIterator scroll type Spliterator DISTINCT Spliterator NONNULL Spliterator CONCURRENT Spliterator IMMUTABLE private static class ScrollableResultIterator T implements Iterator T private final ScrollableResults results private final Class T type ScrollableResultIterator ScrollableResults results Class T type this results results this type type Override public boolean hasNext return results next Override public T next return type cast results get 0 The Repository Layer On top of this component we can now build our repository layer Repository public class StreamRepository PersistenceContext unitName demo private EntityManager entityManager public Stream Order getOrderHistory String email String jpql SELECT o FROM Order o WHERE o customer email email StreamQuery Order query new HibernateQueryStream entityManager jpql Order class return query getResultStream And from here the rest is a piece of cake orderRepository findOrderHistory email filter order order total 100 map Order getOrderLines flatMap List stream map OrderLine getTotal reduce 0 x y x y It is important to highlight that the Hibernate

    Original URL path: http://blog.informatech.cr/2014/12/17/java8-jpa-streams/?shared=email&msg=fail&replytocom=2526 (2015-08-19)
    Open archived version from archive

  • Review of Programming Languages Course from Coursera | Informatech CR Blog
    8 the students take an online exam consisting in questions with multiple selection answers The questions are based on the topics covered in previous weeks Some of the questions could be based on understanding of the theoretical concepts and some question consist in practical applications of those concepts Once the student starts the exam there is a time limit to complete it I think something around 90 minutes The following is detailed outline of the topics covered every week Week 1 SML ML Expressions and Variable Bindings Variables are Immutable Function Bindings Pairs and Other Tuples Lists Let Expressions Options Some Other Expressions and Operators Lack of Mutation and Benefits Thereof The Pieces of a Programming Language The homework consisted in the development of series of functions to deal with dates Week 2 SML Conceptual Ways to Build New Types Records By Name vs By Position Syntactic Sugar and the Truth about Tuples Datatype Bindings How ML Does Not Provide Access to Data Type Values How ML Provides Access to Datatype Values Case Expressions Type Synonyms Lists and Options Are Datatypes Polymorphic Datatypes Pattern Matching Type Inference Polymorphic Types and Equality Types Nested Patterns Exceptions Tail Recursion and Accumulators The homework consisted in a series of exercises related to a card game a variation of solitaire Week 3 SML Functions as Arguments Polymorphic Types and Functions as Arguments Anonymous Functions Unnecessary Function Wrapping Maps and Filters Returning Functions Lexical Scope Environments and Closures Fold Combining Functions Currying and Partial Application The Value Restriction Mutation via ML References Callbacks Abstract Datatypes Closures in Other Languages The homework consisted in a series of exercises related to the implementation of pattern matching and type inference Week 4 SML What is Type Inference Overview of ML Type Inference Mutual Recursion Modules for Namespace Management Signatures Hiding Things Equivalent Implementations Benefits of Side Effect Free Programming Standard Equivalences There was not homework because this week was the week of the midterm exam Week 5 Racket Racket vs Scheme Functions Lists Syntax and Parentheses Dynamic Typing Local Bindings Top Level Definitions Mutability Immutability Delayed Evaluation with Thunks Lazy Evaluation Streams Memoization Macros The homework consisted in the implementation of exercises related to streams and the challenge was about defining macros Week 6 Racket Datatype Programming without Datatypes Recursive Datatypes via Racket Lists Recursive Datatypes via Racket s struc Implementing Programming Languages Interpreters and Compilers Implementing Closures Defining Macros via Functions in the Metalanguage ML versus Racket What Is Static Checking Correctness Soundness Completeness Undecidability Weak Typing Advantages and Disadvantages of Static Checking The homework consisted in the implementation of an interpreter for small programming language called MUPL Made Up Programming Language Week 7 Ruby Objects Classes Methods Variables Visibility and Getters Setters Everything is an Object Duck Typing Arrays Blocks Hashes and Ranges Subclassing and Inheritance Overriding and Dynamic Dispatch Method Lookup Definition Dynamic Dispatch versus Closures The homework consisted in the implementation of a tetris game Week 8 Ruby OOP Versus Functional Decomposition Multimethods Mutiple

    Original URL path: http://blog.informatech.cr/2013/03/25/review-of-programming-languages-course-from-coursera/?replytocom=757 (2015-08-19)
    Open archived version from archive

  • Review of Programming Languages Course from Coursera | Informatech CR Blog
    and week 8 the students take an online exam consisting in questions with multiple selection answers The questions are based on the topics covered in previous weeks Some of the questions could be based on understanding of the theoretical concepts and some question consist in practical applications of those concepts Once the student starts the exam there is a time limit to complete it I think something around 90 minutes The following is detailed outline of the topics covered every week Week 1 SML ML Expressions and Variable Bindings Variables are Immutable Function Bindings Pairs and Other Tuples Lists Let Expressions Options Some Other Expressions and Operators Lack of Mutation and Benefits Thereof The Pieces of a Programming Language The homework consisted in the development of series of functions to deal with dates Week 2 SML Conceptual Ways to Build New Types Records By Name vs By Position Syntactic Sugar and the Truth about Tuples Datatype Bindings How ML Does Not Provide Access to Data Type Values How ML Provides Access to Datatype Values Case Expressions Type Synonyms Lists and Options Are Datatypes Polymorphic Datatypes Pattern Matching Type Inference Polymorphic Types and Equality Types Nested Patterns Exceptions Tail Recursion and Accumulators The homework consisted in a series of exercises related to a card game a variation of solitaire Week 3 SML Functions as Arguments Polymorphic Types and Functions as Arguments Anonymous Functions Unnecessary Function Wrapping Maps and Filters Returning Functions Lexical Scope Environments and Closures Fold Combining Functions Currying and Partial Application The Value Restriction Mutation via ML References Callbacks Abstract Datatypes Closures in Other Languages The homework consisted in a series of exercises related to the implementation of pattern matching and type inference Week 4 SML What is Type Inference Overview of ML Type Inference Mutual Recursion Modules for Namespace Management Signatures Hiding Things Equivalent Implementations Benefits of Side Effect Free Programming Standard Equivalences There was not homework because this week was the week of the midterm exam Week 5 Racket Racket vs Scheme Functions Lists Syntax and Parentheses Dynamic Typing Local Bindings Top Level Definitions Mutability Immutability Delayed Evaluation with Thunks Lazy Evaluation Streams Memoization Macros The homework consisted in the implementation of exercises related to streams and the challenge was about defining macros Week 6 Racket Datatype Programming without Datatypes Recursive Datatypes via Racket Lists Recursive Datatypes via Racket s struc Implementing Programming Languages Interpreters and Compilers Implementing Closures Defining Macros via Functions in the Metalanguage ML versus Racket What Is Static Checking Correctness Soundness Completeness Undecidability Weak Typing Advantages and Disadvantages of Static Checking The homework consisted in the implementation of an interpreter for small programming language called MUPL Made Up Programming Language Week 7 Ruby Objects Classes Methods Variables Visibility and Getters Setters Everything is an Object Duck Typing Arrays Blocks Hashes and Ranges Subclassing and Inheritance Overriding and Dynamic Dispatch Method Lookup Definition Dynamic Dispatch versus Closures The homework consisted in the implementation of a tetris game Week 8 Ruby OOP Versus Functional Decomposition

    Original URL path: http://blog.informatech.cr/2013/03/25/review-of-programming-languages-course-from-coursera/?replytocom=1171 (2015-08-19)
    Open archived version from archive

  • Review of Programming Languages Course from Coursera | Informatech CR Blog
    4 and week 8 the students take an online exam consisting in questions with multiple selection answers The questions are based on the topics covered in previous weeks Some of the questions could be based on understanding of the theoretical concepts and some question consist in practical applications of those concepts Once the student starts the exam there is a time limit to complete it I think something around 90 minutes The following is detailed outline of the topics covered every week Week 1 SML ML Expressions and Variable Bindings Variables are Immutable Function Bindings Pairs and Other Tuples Lists Let Expressions Options Some Other Expressions and Operators Lack of Mutation and Benefits Thereof The Pieces of a Programming Language The homework consisted in the development of series of functions to deal with dates Week 2 SML Conceptual Ways to Build New Types Records By Name vs By Position Syntactic Sugar and the Truth about Tuples Datatype Bindings How ML Does Not Provide Access to Data Type Values How ML Provides Access to Datatype Values Case Expressions Type Synonyms Lists and Options Are Datatypes Polymorphic Datatypes Pattern Matching Type Inference Polymorphic Types and Equality Types Nested Patterns Exceptions Tail Recursion and Accumulators The homework consisted in a series of exercises related to a card game a variation of solitaire Week 3 SML Functions as Arguments Polymorphic Types and Functions as Arguments Anonymous Functions Unnecessary Function Wrapping Maps and Filters Returning Functions Lexical Scope Environments and Closures Fold Combining Functions Currying and Partial Application The Value Restriction Mutation via ML References Callbacks Abstract Datatypes Closures in Other Languages The homework consisted in a series of exercises related to the implementation of pattern matching and type inference Week 4 SML What is Type Inference Overview of ML Type Inference Mutual Recursion Modules for Namespace Management Signatures Hiding Things Equivalent Implementations Benefits of Side Effect Free Programming Standard Equivalences There was not homework because this week was the week of the midterm exam Week 5 Racket Racket vs Scheme Functions Lists Syntax and Parentheses Dynamic Typing Local Bindings Top Level Definitions Mutability Immutability Delayed Evaluation with Thunks Lazy Evaluation Streams Memoization Macros The homework consisted in the implementation of exercises related to streams and the challenge was about defining macros Week 6 Racket Datatype Programming without Datatypes Recursive Datatypes via Racket Lists Recursive Datatypes via Racket s struc Implementing Programming Languages Interpreters and Compilers Implementing Closures Defining Macros via Functions in the Metalanguage ML versus Racket What Is Static Checking Correctness Soundness Completeness Undecidability Weak Typing Advantages and Disadvantages of Static Checking The homework consisted in the implementation of an interpreter for small programming language called MUPL Made Up Programming Language Week 7 Ruby Objects Classes Methods Variables Visibility and Getters Setters Everything is an Object Duck Typing Arrays Blocks Hashes and Ranges Subclassing and Inheritance Overriding and Dynamic Dispatch Method Lookup Definition Dynamic Dispatch versus Closures The homework consisted in the implementation of a tetris game Week 8 Ruby OOP Versus Functional

    Original URL path: http://blog.informatech.cr/2013/03/25/review-of-programming-languages-course-from-coursera/?shared=email&msg=fail (2015-08-19)
    Open archived version from archive

  • Java Streams API Preview | Informatech CR Blog
    getKey findFirst if mostBought isPresent System out println mostBought get Related Posts Java Streams Preview vs Net High Order Programming with LINQ Java Infinite Streams Futher Reading JDK 8 Early Access Project Lambda JEP 107 Bulk Data Operations for Collections Where is the Java Collections Framework Going Share this Email Facebook Twitter Like this Like Loading Related March 25 2013 by Edwin Dalorzo Categories Java Programming Tags jdk8 lambda programming streams 16 Comments About Edwin Dalorzo Software Engineer View all posts by Edwin Dalorzo Post navigation Java Streams Preview vs Net High Order Programming with LINQ Review of Programming Languages Course from Coursera 16 thoughts on Java Streams API Preview Pingback Java Streams Preview vs Net LINQ Informatech CR Blog Pingback Java Infinite Streams Informatech CR Blog Maurice Naftalin says March 29 2013 at 4 12 am There s a problem with the solution to No 3 if you have more than one equally youngest buyers the addition to TreeMap won t work the way you expect key equality for a TreeMap is defined by the compare or compareTo method so you get a list of sales for all the equally youngest buyers You can fix this by including extra sort keys in the Comparator byAge to resolve ties between equally youngest buyers assuming you ve done that there is a slightly neater solution than yours available byYoungest sales collect groupingBy Sale getBuyer new TreeMap byAge values stream findFirst An alternative fix is not to use TreeMap byYoungest sales collect groupingBy Sale getBuyer entrySet stream sorted comparing Entry Person List e e getKey getAge map Entry getValue findFirst Reply Edwin Dalorzo says March 29 2013 at 11 08 am Thanks for your comments Maurice This is great I will try to update the article with all your recommendations Man I ve got to tell you I just can t believe you dropped by my blog You just made my day Reply mauricen says March 29 2013 at 11 50 am You re welcome I enjoyed reading your post and working through the examples mauricen says March 29 2013 at 4 22 am There s a problem with No 3 if you have more than one equally youngest buyer Addition to a TreeMap is done using byAge compare as the key equality function so the sales of all the buyers of any age are added to the sales of the first buyer of that age You can fix this by adding extra sort keys to the Comparator byAge in which case there is a slightly neater solution than yours available byYoungest sales collect groupingBy Sale getBuyer new TreeMap byAge values stream findFirst or longer but clearer you can avoid using TreeMap altogether byYoungest sales collect groupingBy Sale getBuyer entrySet stream sorted comparing Entry Person List e e getKey getAge map Entry getValue findFirst The problem should probably be improved to specify exactly what behaviour is required when there is more than one equally youngest buyer Reply mauricen says March 29 2013

    Original URL path: http://blog.informatech.cr/2013/03/25/java-streams-api-preview/?shared=email&msg=fail (2015-08-19)
    Open archived version from archive

  • functional interfaces | Informatech CR Blog
    syntax with the static method references was more succinct Constructor Method References Let s consider now the existence of a functional interface named Function as follows public interface Function T R public R apply T t Based on it we could define a method map that converts the elements from a source list from certain value T to certain value R as follows static T R List R map Function T R function List T source List R destiny new ArrayList for T item source R value function apply item destiny add value return destiny Now imagine that we had a list of strings containing numbers that we would like to transform to integer values We could do it using a lambda expression to provide an implementation for the Function interface more or less like this List String digits asList 1 2 3 4 5 List Integer numbers map s new Integer s digits However we can clearly infer that the constructor Integer String has the same signature as the apply method in the Function reference required here namely it receives a string as argument and returns an integer So in this case we simplify the implementation of the functional interface by means of using a constructor reference as follows List String digits asList 1 2 3 4 5 List Integer numbers map Integer new digits This conveys the same meaning take a string and make me an integer out of it It is the perfect task for our Integer String constructor Instance Method Reference to Arbitrary Objects Consider now the existence of a class named Jedi defined as follows public class Jedi private String name private int power public Jedi String name int power this name name this power power public String getName return name public int getPower return power equals hashCode toString Now consider that we had a list of jedis and we would like to use our previous function map to extract the name from every jedi and generate a list of names out of the list of jedis Somewhat like this using lambda expressions List Jedi jedis asList new Jedi Obi wan 80 new Jedi Anakin 25 new Jedi Yoda 500 List String names map jedi jedi getName jedis The interesting observation here is that the parameter jedi is the argument for the apply method in the Function reference And we use that reference to a jedi to invoke on it the method getName In other words we invoke a method on the reference we receive as argument So we could simplify this implementation by using an instance method reference as follows List Jedi jedi asList new Jedi Obi wan 80 new Jedi Anakin 25 new Jedi Yoda 500 List String names map Jedi getName jedi Again the interesting aspect of this type of method reference is that the method getName is an instance method Therefore the target of its invocation must be an instance which in this case is an arbitrary object being provided as

    Original URL path: http://blog.informatech.cr/tag/functional-interfaces/ (2015-08-19)
    Open archived version from archive