Some knowledge that seems easy but ignores the principle

Source: Internet
Author: User

1.hashcode

Hashcode is an int value that is put back by the hash function, and the equals of the object must be overridden by hashcode. Because the object's hashcode is similar to a MD5 encryption value, as long as the value is equal, the object must be equal, rather than through the equal comparison (equals comparison is a property of a property of the alignment, efficiency is too low, and hashcode is the calculation of a hash, one step can be compared). But the premise is to generate hashcode hash function to have no conflict, so, in general, re equals, in order to better generate the corresponding unique hashcode, override the Hashcode method.

2.char is based on Uncode character encoding, which accounts for 2 bytes, while a Chinese character can be represented by a char. Second, the string is not to be made, and the string corresponds to a constant pool.

3. Blocking operations

Socket.accept,inputstrum.read,futre.get and so on, because these methods all require a return value, if not put back, the program is blocked, cannot continue execution.

The mechanism of NIO processing is through the polling mechanism, and the event monitoring mechanism, to achieve the reuse of channel, that is, selector can listen to a plurality of channel, which has data, that is executed.

The basis of NIO advantage is buffer, programming interface Bufferfull () polling listener is full, this method does not block, and Reader.readline () is blocked, second NIO single-threaded processing multiple connection, and Io is multiple

Threads handle multiple connection because there are more threads and more resources are consumed.

  

NIO allows you to manage multiple channels (network connections or files) using only one (or several) single threads, but the cost is that parsing data can be more complex than reading data from a blocking stream.
If you need to manage thousands of connections that are open at the same time, these connections can only send a small amount of data, such as a chat server, to implement NIO's servers as an advantage. Similarly, if you need to maintain many open connections to other computers, such as a peer-to network, using a separate thread to manage all your outbound connections may be an advantage. The design of multiple connections for a thread, such as

If you have a small number of connections that use very high bandwidth and send a large amount of data at once, perhaps a typical IO server implementation might be very fit. Illustrates a typical IO server design:

See: Http://www.jb51.net/article/50621.htm

3. What is the principle of the caching mechanism?

In the development, we will basically use the cache, the essence is to cache the processing object in memory, reduce the pressure on the server (such as 2 times the same SQL query, etc.), but the difficulty of cache management is that the size of the cache is fixed, then

How to swap in and out, the basic algorithm is FIFO and so on. Common caches are distributed caches and stand-alone caches. The implementation of each cache is efficient in the management of cache space and memory allocation.

So, it involves the allocation of memory or disk and management, basic Datong small easy, such as Oracle data disk and memory management, but based on the principle is to the disk memory space corresponding to the data structure for management, here is not very deep understanding, temporarily recorded.

4.SQL Execution Plan

After the SQL is written, the basic is optimization, and the premise of optimization is to understand the execution plan, the execution plan is SQL into a function call, in fact, the RDBMS SQL execution plan is similar to the conversion of hive to MapReduce, the following is the table link execution plan

NESTED LOOPS Correspondence exists

HASH JOIN corresponds to Join/in

MERGE JOIN

Some knowledge that seems easy but ignores the principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.