Warning
This component will be available in the Palette of the studio on the condition that you have subscribed to
one of the Talend solutions with Big
Data.
Component family |
Big Data / Cassandra |
|
Function |
tCassandraInput allows you to |
|
Purpose |
tCassandraInput allows you to |
|
Basic settings |
Use existing connection |
Select this check box and in the Component List click the |
DB Version |
Select the Cassandra version you are using. |
|
Host |
Hostname or IP address of the Cassandra server. |
|
Port |
Listening port number of the Cassandra server. |
|
Required authentication |
Select this check box to provide credentials for the Cassandra This check box appears only if you do not select the Use existing connection check box. |
|
Username |
Fill in this field with the username for the Cassandra |
|
Password |
Fill in this field with the password for the Cassandra To enter the password, click the […] button next to the |
|
Keyspace configuration |
Keyspace |
Type in the name of the keyspace from which you want to read |
Column family |
Column family |
Type in the name of the column family from which you want to read |
Column family type |
Standard: Column family is of Super: Column family is of super |
|
Include key in output |
Select this check box to include the key of the column family in
|
|
Row key type |
Select the appropriate Talend data type for the row key from the |
|
Row key Cassandra type |
Select the corresponding Cassandra type for the row key from the WarningThe value of the Default For more information about the mapping table between Cassandra |
|
Include super key output |
Select this check box to include the super key of the column
This check box appears only if you select Super from the Column family |
|
Super column type |
Select the type of the super column from the list. |
|
Super column Cassandra |
Select the corresponding Cassandra type for the super column from For more information about the mapping table between Cassandra |
|
Query configuration |
Specify row keys |
Select this check box to specify the row keys of the column family |
Row Keys |
Type in the specific row keys of the column family in the correct This field appears only if you select the Specify row keys check box. |
|
Key start |
Type in the start row key of the correct data type. |
|
Key end |
Type in the end row key of the correct data type. |
|
Key limit |
Type in the number of rows to be read between the start row key |
|
Specify columns |
Select this check box to specify the column names of the column |
|
Columns |
Type in the specific column names of the column family in the This field appears only if you select the Specify columns check box. |
|
Columns range start |
Type in the start column name of the correct data type. |
|
Columns range end |
Type in the end column name of the correct data type. |
|
Columns range limit |
Type in the number of columns to be read between the start column |
|
Schema and Edit Schema |
A schema is a row description. It defines the number of fields to be processed and passed on Since version 5.6, both the Built-In mode and the Repository mode are Click Edit schema to make changes to the schema. If the
|
|
Advanced settings |
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at the |
Global Variables |
NB_LINE: the number of rows read by an input component or ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see Talend Studio |
|
Usage |
This component always needs an output link. |
|
Log4j |
The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html. |
|
Limitation |
n/a |
The following table presents the mapping relationships between Cassandra type and
Talend data type.
Cassandra Type |
Talend Data Type |
---|---|
BytesType |
byte[] |
AsciiType |
String |
UTF8Type |
String |
IntegerType |
Object |
Int32Type |
Integer |
LongType |
Long |
UUIDType |
String |
TimeUUIDType |
String |
DateType |
Date |
BooleanType |
Boolean |
FloatType |
Float |
DoubleType |
Double |
DecimalType |
BigDecimal |
This scenario describes a simple Job that reads the employee data from a CSV file,
writes the data to a Cassandra keyspace, then extracts the personal information of some
employees and displays the information on the console.
This scenario requires six components, which are:
-
tCassandraConnection: opens a connection
to the Cassandra server. -
tFileInputDelimited: reads the input
file, defines the data structure and sends it to the next component. -
tCassandraOutput: writes the data it
receives from the preceding component into a Cassandra keyspace. -
tCassandraInput: reads the data from the
Cassandra keyspace. -
tLogRow: displays the data it receives
from the preceding component on the console. -
tCassandraClose: closes the connection to
the Cassandra server.
-
Drop the following components from the Palette onto the design workspace: tCassandraConnection, tFileInputDelimited, tCassandraOutput, tCassandraInput, tLogRow
and tCassandraClose. -
Connect tFileInputDelimited to tCassandraOutput using a Row > Main link.
-
Do the same to connect tCassandraInput to
tLogRow. -
Connect tCassandraConnection to tFileInputDelimited using a Trigger > OnSubjobOk
link. -
Do the same to connect tFileInputDelimited to tCassandraInput and tCassandraInput to tCassandraClose.
-
Label the components to better identify their functions.
Opening a Cassandra connection
-
Double-click the tCassandraConnection
component to open its Basic settings view
in theComponent tab. -
Select the Cassandra version that you are using from the DB Version list. In this example, it is Cassandra 1.1.2.
-
In the Server field, type in the hostname
or IP address of the Cassandra server. In this example, it is localhost. -
In the Port field, type in the listening
port number of the Cassandra server. -
If required, type in the authentication information for the Cassandra
connection: Username and Password.
Reading the input data
-
Double-click the tFileInputDelimited
component to open its Component view. -
Click the […] button next to the
File Name/Stream field to browse to the
file that you want to read data from. In this scenario, the directory is
D:/Input/Employees.csv. The CSV file
contains four columns: id, age, name
and ManagerID.1234567891011id;age;name;ManagerID1;20;Alex;12;40;Peter;13;25;Mark;14;26;Michael;15;30;Christophe;26;26;Stephane;37;37;Cedric;38;52;Bill;49;43;Jack;210;28;Andrews;4 -
In the Header field, enter 1 so that the first row in the CSV file will be
skipped. -
Click Edit schema to define the data to
pass on to the tCassandraOutput component.
Writing data to a Cassandra keyspace
-
Double-click the tCassandraOutput
component to open its Basic settings view
in the Component tab. -
Type in required information for the connection or use the existing
connection you have configured before. In this scenario, the Use existing connection check box is
selected. -
In the Keyspace configuration area, type
in the name of the keyspace: Employee in
this example, and select Drop keyspace if exists and
create from the Action on
keyspace list. -
In the Column family configuration area,
type in the name of the column family: Employee_Info in this example, and select Drop column family if exists and create from
the Action on column family list.The Define column family structure check
box appears. In this example, clear this check box. -
In the Action on data list, select the
action you want to carry on, Upsert in
this example. -
Click Sync columns to retrieve the schema
from the preceding component. -
Select the key column of the column family from the Key column list. In this example, it is id.
If needed, select the Include key in
columns check box.
Reading data from the Cassandra keyspace
-
Double-click the tCassandraInput
component to open its Component
view. -
Type in required information for the connection or use the existing
connection you have configured before. In this scenario, the Use existing connection check box is
selected. -
In the Keyspace configuration area, type
in the name of the keyspace: Employee in
this example. -
In the Column family configuration area,
type in the name of the column family: Employee_Info in this example. -
Select Edit schema to define the data
structure to be read from the Cassandra keyspace. In this example, three
columns id, name and age are
defined. -
If needed, select the Include key in output
columns check box, and then select the key column of the
column family you want to include from the Key
column list. -
From the Row key type list, select
Integer because id is of integer type in this example.Keep the Default option for the row key
Cassandra type because its value will become the corresponding Cassandra
type Int32 automatically. -
In the Query configuration area, select
the Specify row keys check box and specify
the row keys directly. In this example, three rows will be read. Next,
select the Specify columns check box and
specify the column names of the column family directly. This scenario will
read three columns from the keyspace: id,
name and age. -
If needed, the Key start and the
Key end fields allow you to define the
range of rows, and the Key limit field
allows you to specify the number of rows within the range of rows to be
read. Similarly, the Columns range start
and the Columns range end fields allow you
to define the range of columns of the column family, and the Columns range limit field allows you to specify
the number of columns within the range of columns to be read.