Category: latest in tech. world

Here is a short intro on using elasticsearch filters with java.

Combining filters

        XContentFilterBuilder filter1 = FilterBuilders.orFilter(
				FilterBuilders.termsFilter("foootnote", "searchKeyword"))
//filter name can be used later to find matched filter
		XContentFilterBuilder filter2 = FilterBuilders.orFilter(
				FilterBuilders.termsFilter("receiverNumber", "searchKeyword"))

        XContentFilterBuilder filter33 = FilterBuilders.orFilter(
        		FilterBuilders.termFilter("messageText", "searchKeyword"),
        		FilterBuilders.termFilter("messageSubject", "searchKeyword").

        // These filter can then be combined using one more filter
        XContentFilterBuilder messageFilter = FilterBuilders.orFilter(filter1, filter2, filter3);

Checking for presence of a keyword( i.e. NOT NULL)

Here’s an example in which a filter is created to check for the existence of a keyword “hiddenTag”.

XContentFilterBuilder existsFilter = FilterBuilders.notFilter(
//This filter can then be combined with other filters like below
messageFilter = FilterBuilders.andFilter(messageFilter, notExistsFilter);


By default only 10 results are returned. To return more results and apply pagination we can build our query like this :

qb = QueryBuilders.filteredQuery(qb, messageFilter);

Vinay Deolalikar at HP Labs claim to have proved that P != NP . According to his paper…polynomial time algorithms succeed by successively “breaking up” the problem into smaller subproblems that are joined to each other through conditional independence. Consequently, polynomial time algorithms cannot solve problems in regimes where blocks whose order is the same as the underlying problem instance require simultaneous resolution. As anyone could predict, the alleged proof of one of the thorniest problems in CS has already been Slashdotted. As i’m not a hardcore mathematician, i’ll not go into details of this…but what is this P vs NP thing all about…lets explore !!

First of all P stands for polynomial time. NP stands for non-deterministic polynomial time. As the name implies, Polynomial time means that the complexity of the algorithm is O(n^k), where n is the size of your data and k is a constant.Complexity is time measured in the number of operations(e.g. comparisons in case of sorting)  it would take, as a function of the number of data items. Now we basically narrowed our discussion to deterministic vs non deterministic (gosh…i luv abstraction) . There is an abstract computational model, an imaginary computer called a Turing machine (TM).A Turing machine is a kind of state machine. At any time the machine is in any one of a finite number of states. Instructions for a Turing machine consist in specified conditions under which the machine will transition between one state and another. At any given time, the Turing Machine is in one of its states, and it is looking at a particular cell on the tape. Depending on what it reads from that cell, it can write a new symbol into that cell, move the tape one cell forward or backward, and go into a different state. This is called a state transition.Despite its simplicity, a Turing machine can be adapted to simulate the logic of any computer algorithm, and is particularly useful in explaining the functions of a CPU inside a computer.

We are basically concerned about 2 types of turing machines i) deterministic ii) non-deterministic

A deterministic Turing Machine only has one transition from each state for each symbol that it is reading off the tape, in contrast a non-deterministic Turing Machine may have several such transition, i.e. it is able to check several possibilities simultaneously. It has been proven that any problem that can be solved by a non-deterministic TM can be solved by a deterministic TM.When someone says P = NP , he means that one can build a deterministic TM for solving same problem in polynomial time which takes polynomial time in non-deterministic TM.So far nobody have been able to show that it can be done, but nobody has been able to prove that it cannot be done, either…lets  see Vinay Deolalikar’s claim get acceptance or not !!

Also, 2 terms most programmers come across are NP-complete and NP-hard. If someone tells you  that a problem is NP-complete, he basically means that it can be done in polynomial time on a non-deterministic TM, but it will take exponential time on a real computer. NP-hard ( non deterministic polynomial time hard), on the other hand, is a class of problems that are, informally, “at least as hard as the hardest problems in NP”.The precise definition here is that a problem X is NP-hard if there is an NP-complete problem Y such that Y is reducible to X in polynomial time. But since any NP-complete problem can be reduced to any other NP-complete problem in polynomial time, all NP-complete problems can be reduced to any NP-hard problem in polynomial time. Then if there is a solution to one NP-hard problem in polynomial time, there is a solution to all NP problems in polynomial time. Confusing…right ??….don’t go into details…jus pick the essential things  😉

credits :: google


The tension between Apple and Adobe was simmering for quite a while and the new SDK agreement seems like a breakpoint.Adobe, Microsoft, not only can you not have Adobe Flash or Microsoft Silverlight running natively on an iPod Touch,iPhone, or iPad, you can also forget about creating an iWhatever program that can get around that requirement.

According to new licensing agreement  ::   Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs.Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine,and only code written in C, C++, and Objective-C may compile and directly link against  the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).

This seems to mean that cross-compilers, which let you develop in the Adobe Flash CS5, the C# and .NET-based Mono Touch, or similar environments and spit out iPhone-compatible binaries at the end, are being prohibited.Apple is being portraited as evil…and adobe is getting a lot of sympathy.

Lets try to answer the question of who is to blame and who is trying to do the right thing.

If we see things from Apple’s perspective Apple has its reasons.Flash on a base level provides a very real threat to Apple’s  lucrative App Store, one of the key things that it uses to differentiate the iPod Touch/iPhone/iPad from its competitors. If Apple adopted Flash, many of its developers could move to Flash which would free them of the restrictions of Apple’s App Store approval process. And that would ultimately ruin the exclusivity of Apple’s app catalog and make Apple vulnerable to handsets with superior hardware.Also, with Flash customers could simply view TV episodes for free rather than buy them from Apple’s iTunes store.

Apple CEO Steven P. Jobs argues that Flash, is simply no good. It crashes Mac and runs too slow for his tastes.He also claims that Flash would reduce the iPad’s battery life from 10 hours to 1.5 hours.

Adobe, the king of Internet video with 95% Web browser market penetration, is not one bit happy about being locked out of Apple’s lucrative mobile device market.The reason Adobe is talking is because that’s all it can do at this point after screwing up its mobile strategy and failing to anticipate years ago where computing was headed and what changes it needed to make. It’s not Apple’s job to keep Adobe in business.Adobe’s CTO Kevin Lynch himself acknowledged that Flash has typically run faster in Microsoft Windows than in Apple’s Macintosh OS, from which the iPhone OS is derived.

Frankly speaking, Once you get used to getting paid to do next to nothing,it’s a brutal shock when somebody stands up and refuses to play along with your ridiculous game and this is what happening with Adobe.The ubiquitousness of Flash is like a cancer, they are even now building it into the heart of all their flagship products.Yes, Adobe is adopting the write once, run anywhere philosophy that even Microsoft abandoned years ago.Flash programmers need to understand that using Flash for everything is poor practice.

Apple don’t want Windows-like share of the mobile market, they want quality( that’s what seems frm their strategy so far).They want to give people a reason to prefer the iPhone. Imagine, a major new features in iPhone OS are released by Apple but the other company’s toolkit is slow to adapt them. At that point, it’s the other company that controls when third party apps can make use of these features. So all this make sense from apple’s point of view.

But the main thing that bugs me is Apple is changing the rules in the middle of the game.Some of developers have significant investments in tool sets that were previously allowed and are now banned.Changing the rules on developers in ways that will cost them $$$ of dollars is extremely frustrating. This erodes developer trust.And the one most important thing i learned from the movie “The Godfather”(undoubtedly my fav. movie ^^)  is  “to be on top u need to have trust and honour”and saying to vendors “It’s  my house if you don’t like it leave” doesn’t help it.

Apple will also lose the users that see Flash is an important content and the users who do not like to lose the ability to view Flash content on the web.Furthermore, Apple will lose Adobe users, developers who seek to build applications on Apple devices forever. Now that Google has a version of their Android OS that’s better than iPhone OS 4 (Android 2.1) developers are finally beginning a gradual move away from Apple over to Android. Many developers feel that Apple knows exactly  “How To Be A Douchebag”. It will be interesting to see how Apple fares with this in its competition against Google longer term.

So if we think of present, this decision is a lose-lose situation for both Apple and Adobe. But considering the future,for Apple it can either prove to be a big asset or their worst decision ever, and for adobe…Sorry, Adobe, you screwed yourself !!

I’m glad Apple brought some dynamic to this market.I think they deserve every credit for pushing the smarthphone industry to the mainstream but i guess they took the right decision at the wrong time.This decision will give a big push to HTML5 revolution but they don’t seem to be replacing each other, certainly not today nor even in foreseeable future.Looking at the iPhone OS 4.0 and Apple’s mentality of keeping the platform closed I think they’ll loose their top spot and perhaps fall behind Google and even Microsoft.

The Italian cartoonist,Federico Fieni, cleverly portrays hw Google first pondered how to challenge Windows, put its heads together, and ultimately came up with Chrome.Who knows may be this is the future of windows !!!

gg microsoft