'ITWeb/개발일반'에 해당되는 글 490건

  1. 2014.11.03 [Maven] 콘솔 빌드 시 JAVA_HOME 확인.
  2. 2014.11.03 MacBook JAVA_HOME 설정.
  3. 2014.10.06 bash for loop...
  4. 2014.09.25 [TPC-H] Schema 그림.
  5. 2014.09.24 TPC-H 데이터 생성.
  6. 2014.09.18 process id 구해와서 죽이기. 1
  7. 2014.08.18 apache commons cli maven
  8. 2014.07.07 [Java] Custom JDBC Driver mybatis 연동 시 주의사항.
  9. 2014.07.02 [Java] JDBC Driver 만들기 참고
  10. 2014.03.07 11.6 Data Type Storage Requirements

[Maven] 콘솔 빌드 시 JAVA_HOME 확인.

ITWeb/개발일반 2014. 11. 3. 12:01

eclipse 로 빌드 하다 console 에서 빌드 할떄가 있습니다.

eclipse 에서는 빌드가 잘되는데 console 에서 안될때 먼저 mvn 의 JAVA_HOME 이 어떻게 되어 있는지 확인해보는게 좋습니다.


지금은 JDK7을 많이 사용하실 텐데 확인해 보면 JDK6 으로 설정된경우 에러가 발생을 합니다.


$ mvn -version

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T02:37:52+09:00)

Maven home: /Users/hwjeong/Desktop/Applications/apache-maven-3.2.1

Java version: 1.6.0_65, vendor: Apple Inc.

Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Default locale: ko_KR, platform encoding: EUC_KR

OS name: "mac os x", version: "10.10", arch: "x86_64", family: "mac"


mvn 파일 열어서 JAVA_HOME 부분 찾아서 고쳐 주신 후 빌드 하면 끝.

:

MacBook JAVA_HOME 설정.

ITWeb/개발일반 2014. 11. 3. 11:57


# JDK6

export JAVA_HOME=`/usr/libexec/java_home -v 1.6`


# JDK7

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`


# JDK8

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

:

bash for loop...

ITWeb/개발일반 2014. 10. 6. 12:17

머리가 나빠서 맨날 까먹어요...ㅡ.ㅡ;;


일반적인 bash for loop..

for i in 1 2 3 4 5

do

    echo $i

done


start, end 를 가지는 for loop

START=1

END=5

for (( i=$START; i<=$END; i++ ))

do

    echo $i

done


while 문은 그냥 귀찮아서 pass, 필요 하면 구글링에게... ^^;

:

[TPC-H] Schema 그림.

ITWeb/개발일반 2014. 9. 25. 11:00

TPC-H 스키마...

in http://www.tpc.org/tpch/spec/tpch2.16.0v1.pdf



lineitem 테이블 필드가 16개....

:

TPC-H 데이터 생성.

ITWeb/개발일반 2014. 9. 24. 13:58

http://www.tpc.org/tpch/default.asp

다운로드 : http://www.tpc.org/tpch/spec/tpch_2_17_0.zip

설치 : 

cp makefile.suite makefile

vi makefile

CC      = gcc

DATABASE=ORACLE

MACHINE =LINUX

WORKLOAD =TPCH

make


./dbgen -s 10 -S 1 -C 5 -T L -v


-h 도움말

-s 데이터 원본 크기

-C 데이터 원본에 대한 split 크기 ( 원본 / split )

-S 생성할 데이터 offset

-T L 라인아이템 only

-v verbose

:

process id 구해와서 죽이기.

ITWeb/개발일반 2014. 9. 18. 18:45

process id 구해와서 죽이기.


#!/bin/bash


getprocess=`ps -ef|grep PROCESS`

set $getprocess

pid=$2

kill -9 $pid


:

apache commons cli maven

ITWeb/개발일반 2014. 8. 18. 14:23

elasticsearch cli 기능 구현을 위해서 아래 라이브러리 사용.


<!-- apache commons cli -->

<dependency>

<groupId>commons-cli</groupId>

<artifactId>commons-cli</artifactId>

<version>1.2</version>

</dependency>


:

[Java] Custom JDBC Driver mybatis 연동 시 주의사항.

ITWeb/개발일반 2014. 7. 7. 18:29

주의사항이라고 까지 할건 없지만.

제가 경험한 내용을 공유 차원에서 올려 봅니다.


처음에 elasticsearch 용 jdbc driver 를 만들고 나서 그냥 생으로..


[java.sql.* 로 코딩]

Connection conn = null;

EsStatement stmt = null;


Class.forName("com.gruter.elasticsearch.jdbc.EsDriver");

conn = DriverManager.getConnection("jdbc:es://localhost:9300/henry?......", ".....", ".....");

stmt = (EsStatement) conn.createStatement();


String sql = "select * from transactions where buyer_id='henry' and item_category in ('1A', '8A')  and price > 20000 order by reg_dt desc limit 0, 20";

ResultSet rs = stmt.executeQuery(sql);


while (rs.next()) {

    int tx_id = rs.getInt("tx_id");

    String buyer_id = rs.getString("buyer_id");

    System.out.println("tx_id : " + tx_id + ", buyer_id : " + buyer_id);

}


rs.close();

stmt.close();

conn.close();


이렇게 하면 잘 됩니다.

근데 mybatis를 이용해서 하니까 에러가 발생을 하더라구요.

에러를 확인해보니.. 제가 jdbc driver 를 덜 구현해 줬더라구요.

위에 처럼 할 경우 ResultSetMetaData 구현을 안해도 동작 하는데 문제가 없는데 mybatis 랑 쓸려면 구현을 꼭 해주셔야 합니다.


참고하세요 ㅎㅎ.

:

[Java] JDBC Driver 만들기 참고

ITWeb/개발일반 2014. 7. 2. 10:25

아래 URL 보고 만들면 됩니다.

http://www.oracle.com/technetwork/java/javase/jdbc/index.html

https://github.com/jprante/jdbc-csv

http://www.docjar.com/projects/MySQL-JDBC-5.1.11-code.html

http://www.javaworld.com/article/2074249/data-storage/create-your-own-type-3-jdbc-driver--part-1.html

:

11.6 Data Type Storage Requirements

ITWeb/개발일반 2014. 3. 7. 17:27

http://dev.mysql.com/doc/refman/5.1/en/storage-requirements.html


11.6 Data Type Storage Requirements

The storage requirements for data vary, according to the storage engine being used for the table in question. Different storage engines use different methods for recording the raw data and different data types. In addition, some engines may compress the information in a given row, either on a column or entire row basis, making calculation of the storage requirements for a given table or column structure.

However, all storage engines must communicate and exchange information on a given row within a table using the same structure, and this information is consistent, irrespective of the storage engine used to write the information to disk.

This sections includes some guideliness and information for the storage requirements for each data type supported by MySQL, including details for the internal format and the sizes used by storage engines that used a fixed size representation for different types. Information is listed by category or storage engine.

The internal representation of a table has a maximum row size of 65,535 bytes, even if the storage engine is capable of supporting larger rows. This figure excludes BLOB or TEXT columns, which contribute only 9 to 12 bytes toward this size. For BLOB and TEXT data, the information is stored internally in a different area of memory than the row buffer. Different storage engines handle the allocation and storage of this data in different ways, according to the method they use for handling the corresponding types. For more information, see Chapter 14, Storage Engines, and Section E.7.4, “Limits on Table Column Count and Row Size”.

Storage Requirements for InnoDB Tables

See Section 14.6.3.12.5, “Physical Row Structure” for information about storage requirements for InnoDB tables.

Storage Requirements for NDBCLUSTER Tables

Important

For tables using the NDBCLUSTER storage engine, there is the factor of 4-byte alignment to be taken into account when calculating storage requirements. This means that all NDB data storage is done in multiples of 4 bytes. Thus, a column value that would take 15 bytes in a table using a storage engine other than NDB requires 16 bytes in an NDB table. This requirement applies in addition to any other considerations that are discussed in this section. For example, in NDBCLUSTER tables, the TINYINT, SMALLINT, MEDIUMINT, and INTEGER (INT) column types each require 4 bytes storage per record due to the alignment factor.

An exception to this rule is the BIT type, which is not 4-byte aligned. In MySQL Cluster tables, a BIT(M) column takes M bits of storage space. However, if a table definition contains 1 or more BIT columns (up to 32 BIT columns), then NDBCLUSTER reserves 4 bytes (32 bits) per row for these. If a table definition contains more than 32 BIT columns (up to 64 such columns), then NDBCLUSTER reserves 8 bytes (that is, 64 bits) per row.

In addition, while a NULL itself does not require any storage space, NDBCLUSTER reserves 4 bytes per row if the table definition contains any columns defined as NULL, up to 32 NULL columns. (If a MySQL Cluster table is defined with more than 32 NULL columns up to 64 NULL columns, then 8 bytes per row is reserved.)

When calculating storage requirements for MySQL Cluster tables, you must also remember that every table using the NDBCLUSTER storage engine requires a primary key; if no primary key is defined by the user, then a hidden primary key will be created by NDB. This hidden primary key consumes 31-35 bytes per table record.

You may find the ndb_size.pl utility to be useful for estimating NDB storage requirements. This Perl script connects to a current MySQL (non-Cluster) database and creates a report on how much space that database would require if it used the NDBCLUSTER storage engine. See Section 17.4.23, “ndb_size.pl — NDBCLUSTER Size Requirement Estimator”, for more information.

Storage Requirements for Numeric Types

Data TypeStorage Required
TINYINT1 byte
SMALLINT2 bytes
MEDIUMINT3 bytes
INT, INTEGER4 bytes
BIGINT8 bytes
FLOAT(p)4 bytes if 0 <= p <= 24, 8 bytes if 25 <= p <= 53
FLOAT4 bytes
DOUBLE [PRECISION], REAL8 bytes
DECIMAL(M,D), NUMERIC(M,D)Varies; see following discussion
BIT(M)approximately (M+7)/8 bytes

Values for DECIMAL (and NUMERIC) columns are represented using a binary format that packs nine decimal (base 10) digits into four bytes. Storage for the integer and fractional parts of each value are determined separately. Each multiple of nine digits requires four bytes, and the leftover digits require some fraction of four bytes. The storage required for excess digits is given by the following table.

Leftover DigitsNumber of Bytes
00
11
21
32
42
53
63
74
84

Storage Requirements for Date and Time Types

Data TypeStorage Required
DATE3 bytes
TIME3 bytes
DATETIME8 bytes
TIMESTAMP4 bytes
YEAR1 byte

For details about internal representation of temporal values, see MySQL Internals: Important Algorithms and Structures.

Storage Requirements for String Types

In the following table, M represents the declared column length in characters for nonbinary string types and bytes for binary string types. L represents the actual length in bytes of a given string value.

Data TypeStorage Required
CHAR(M)M × w bytes, 0 <= M <= 255, where w is the number of bytes required for the maximum-length character in the character set. See Section 14.6.3.12.5, “Physical Row Structure” for information about CHAR data type storage requirements for InnoDB tables.
BINARY(M)M bytes, 0 <= M <= 255
VARCHAR(M), VARBINARY(M)L + 1 bytes if column values require 0 – 255 bytes, L + 2 bytes if values may require more than 255 bytes
TINYBLOB, TINYTEXTL + 1 bytes, where L < 28
BLOB, TEXTL + 2 bytes, where L < 216
MEDIUMBLOB, MEDIUMTEXTL + 3 bytes, where L < 224
LONGBLOB, LONGTEXTL + 4 bytes, where L < 232
ENUM('value1','value2',...)1 or 2 bytes, depending on the number of enumeration values (65,535 values maximum)
SET('value1','value2',...)1, 2, 3, 4, or 8 bytes, depending on the number of set members (64 members maximum)

Variable-length string types are stored using a length prefix plus data. The length prefix requires from one to four bytes depending on the data type, and the value of the prefix is L (the byte length of the string). For example, storage for a MEDIUMTEXT value requires L bytes to store the value plus three bytes to store the length of the value.

To calculate the number of bytes used to store a particular CHAR, VARCHAR, or TEXT column value, you must take into account the character set used for that column and whether the value contains multi-byte characters. In particular, when using the utf8 Unicode character set, you must keep in mind that not all characters use the same number of bytes and can require up to three bytes per character. For a breakdown of the storage used for different categories of utf8 characters, see Section 10.1.10, “Unicode Support”.

VARCHAR, VARBINARY, and the BLOB and TEXT types are variable-length types. For each, the storage requirements depend on these factors:

  • The actual length of the column value

  • The column's maximum possible length

  • The character set used for the column, because some character sets contain multi-byte characters

For example, a VARCHAR(255) column can hold a string with a maximum length of 255 characters. Assuming that the column uses the latin1 character set (one byte per character), the actual storage required is the length of the string (L), plus one byte to record the length of the string. For the string 'abcd', L is 4 and the storage requirement is five bytes. If the same column is instead declared to use the ucs2 double-byte character set, the storage requirement is 10 bytes: The length of 'abcd' is eight bytes and the column requires two bytes to store lengths because the maximum length is greater than 255 (up to 510 bytes).

The effective maximum number of bytes that can be stored in a VARCHAR or VARBINARY column is subject to the maximum row size of 65,535 bytes, which is shared among all columns. For a VARCHAR column that stores multi-byte characters, the effective maximum number of characters is less. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters. See Section E.7.4, “Limits on Table Column Count and Row Size”.

The NDBCLUSTER storage engine in MySQL 5.1 supports variable-width columns. This means that a VARCHAR column in a MySQL Cluster table requires the same amount of storage as it would using any other storage engine, with the exception that such values are 4-byte aligned. Thus, the string 'abcd' stored in a VARCHAR(50) column using the latin1 character set requires 8 bytes (rather than 6 bytes for the same column value in a MyISAM table). This represents a change in behavior from earlier versions of NDBCLUSTER, where a VARCHAR(50) column would require 52 bytes storage per record regardless of the length of the string being stored.

TEXT and BLOB columns are implemented differently in the NDB Cluster storage engine, wherein each row in a TEXT column is made up of two separate parts. One of these is of fixed size (256 bytes), and is actually stored in the original table. The other consists of any data in excess of 256 bytes, which is stored in a hidden table. The rows in this second table are always 2,000 bytes long. This means that the size of a TEXT column is 256 if size <= 256 (where size represents the size of the row); otherwise, the size is 256 + size + (2000 – (size – 256) % 2000).

The size of an ENUM object is determined by the number of different enumeration values. One byte is used for enumerations with up to 255 possible values. Two bytes are used for enumerations having between 256 and 65,535 possible values. See Section 11.4.4, “The ENUM Type”.

The size of a SET object is determined by the number of different set members. If the set size is N, the object occupies (N+7)/8 bytes, rounded up to 1, 2, 3, 4, or 8 bytes. A SET can have a maximum of 64 members. See Section 11.4.5, “The SET Type”.

: