blob: 08d1ecdc7c74ff6f1a034fddd9d7090a685da169 [file] [log] [blame]
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Untitled Document.md</title><style></style></head><body id="preview">
<p>&lt;!–<br>
Licensed to the Apache Software Foundation (ASF) under one<br>
or more contributor license agreements. See the NOTICE file<br>
distributed with this work for additional information<br>
regarding copyright ownership. The ASF licenses this file<br>
to you under the Apache License, Version 2.0 (the<br>
“License”); you may not use this file except in compliance<br>
with the License. You may obtain a copy of the License at</p>
<pre><code> http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
&quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
</code></pre>
<p>–&gt;</p>
<h1><a id="Data_Management_19"></a>Data Management</h1>
<p>This tutorial is going to introduce you to the conceptual details of data management like :</p>
<ul>
<li><a href="#loading-data">Loading Data</a></li>
<li><a href="#deleting-data">Deleting Data</a></li>
<li><a href="#compacting-data">Compacting data</a></li>
</ul>
<h2><a id="Loading_Data_26"></a>Loading Data</h2>
<ul>
<li>
<p><strong>Scenario</strong></p>
<p>Once the table is created, data can be loaded into table using <a href="">LOAD DATA</a> command and will be available for query.<br>
When data load is triggered, the data is encoded in Carbon format and copied into HDFS Carbon store path(specified in carbon.properties file)<br>
in compressed, multi dimensional columnar format for quick analysis queries. The same command can be used to load new data or to<br>
update the existing data. Only one data load can be triggered for one table. The high cardinality columns of the dictionary encoding are<br>
automatically recognized and these columns will not be used for dictionary encoding.</p>
</li>
<li>
<p><strong>Procedure</strong></p>
<p>Data loading is a process that involves execution of multiple steps to read, sort, and encode the date in Carbon store format.<br>
Each step is executed on different threads. After data loading process is complete, the status (success/partial success) is updated to<br>
Carbon store metadata. The table below lists the possible load status</p>
</li>
</ul>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Status</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Success</td>
<td>All the data is loaded into table and no bad records found.</td>
</tr>
<tr>
<td>Partial Success</td>
<td>Data is loaded into table and bad records are found. Bad records are stored at carbon.badrecords.location.</td>
</tr>
</tbody>
</table>
<p>In case of failure, the error will be logged in error log. Details of loads can be seen with <a href="">SHOW SEGMENTS</a> command. The show segment command output consists of :</p>
<ul>
<li>SegmentSequenceID</li>
<li>START_TIME OF LOAD</li>
<li>END_TIME OF LOAD</li>
<li>LOAD STATUS</li>
</ul>
<p>The latest load will be displayed first in the output.</p>
<p>For load commands refer to <a href="">DML operations on Carbon Data</a></p>
<p>##Deleting Data</p>
<ul>
<li>
<p><strong>Scenario</strong></p>
<p>If you have loaded wrong data into the table, or too many bad records and want to modify and reload the data, you can delete required data loads.<br>
The load can be deleted using the Segment Sequence Id or if the table contains date field then the data can be deleted using the date field.</p>
</li>
<li>
<p><strong>Procedure</strong></p>
<p>The loaded data can be deleted in the following two ways :</p>
<ol>
<li>
<p>Delete by Segment ID</p>
<p>After you get the segment ID of the segment that you want to delete, execute the <a href="">DELETE</a> Command for the selected segment.<br>
The Status of deleted segment is updated to Marked for delete / Marked for Update</p>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>SegmentSequenceId</th>
<th>Status</th>
<th>Load Start Time</th>
<th>Load End Time</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>Success</td>
<td>2015-11-19 19:14:…</td>
<td>2015-11-19 19:14:…</td>
</tr>
<tr>
<td>1</td>
<td>Marked for Update</td>
<td>2015-11-19 19:54:…</td>
<td>2015-11-19 20:08:…</td>
</tr>
<tr>
<td>2</td>
<td>Marked for Delete</td>
<td>2015-11-19 20:25:…</td>
<td>2015-11-19 20:49:…</td>
</tr>
</tbody>
</table>
</li>
<li>
<p>Delete by Date Field</p>
<p>If the table contains date field, you can delete the data based on a specific date.</p>
<p>For delete commands refer to <a href="">DML operations on Carbon Data</a></p>
</li>
</ol>
<p>Note :</p>
<ul>
<li>
<p>When the delete segment DML is called, segment will not be deleted physically from the file system. Instead the segment status will be marked as “Marked for Delete”. For the query execution, this deleted segment will be excluded.</p>
</li>
<li>
<p>The deleted segment will be deleted physically during the next load operation and only after the maximum query execution time configured using “max.query.execution.time”. By default it is 60 minutes.</p>
</li>
<li>
<p>If the user wants to force delete the segment physically then he can use <a href="">CLEAN FILES</a> Command. This DML will physically delete the segment which are “Marked for delete” immediately.</p>
</li>
</ul>
</li>
</ul>
<p>##Compacting Data</p>
<ul>
<li>
<p><strong>Scenario</strong></p>
<p>Frequent data ingestion results in several fragmented carbon files in the store directory. Since data is sorted only within each load, the indices perform only within each<br>
load. This mean that there will be one index for each load and as number of data load increases, the number of indices also increases. As each index works only on one load,<br>
the performance of indices is reduced. Carbon provides provision for compacting the loads. Compaction process combines several segments into one large segment by merge sorting the data from across the segments.</p>
</li>
<li>
<p><strong>Procedure</strong></p>
<p>There are two types of compaction Minor and Major compaction.</p>
<ul>
<li>
<p><strong>Minor Compaction</strong></p>
<p>In minor compaction the user can specify how many loads to be merged. Minor compaction triggers for every data load if the parameter carbon.enable.auto.load.merge is set. If any segments are available to be merged, then compaction will<br>
run parallel with data load. There are 2 levels in minor compaction.</p>
<ul>
<li>Level 1: Merging of the segments which are not yet compacted.</li>
<li>Level 2: Merging of the compacted segments again to form a bigger segment.</li>
</ul>
</li>
<li>
<p><strong>Major Compaction</strong></p>
<p>In Major compaction, many segments can be merged into one big segment. User will specify the compaction size until which segments can be merged. Major compaction is usually done during the off-peak time.</p>
</li>
</ul>
<p>There are number of parameters related to Compaction that can be set in carbon.properties file</p>
</li>
</ul>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Parameter</th>
<th>Default</th>
<th>Application</th>
<th>Description</th>
<th>Valid Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>carbon.compaction.level.threshold</td>
<td>4,3</td>
<td>Minor</td>
<td>Thisproperty is for minor compaction which decides how many segments to be merged.Example: if it is set as 2,3 then minor compaction will be triggered for every 2 segments. 3 is the number of level 1 compacted segment which is further compacted to new segment.</td>
<td>NA</td>
</tr>
<tr>
<td>carbon.major.compaction.size</td>
<td>1024 MB</td>
<td>Major</td>
<td>Major compaction size can be configured using this parameter. Sum of the segments which is below this threshold will be merged.</td>
<td>NA</td>
</tr>
<tr>
<td>carbon.numberof.preserve.segments</td>
<td>0</td>
<td>Minor/Major</td>
<td>If the user wants to preserve some number of segments from being compacted then he can set this property.Example: carbon.numberof.preserve.segments=2 then 2 latest segments will always be excluded from the <a href="http://compaction.No">compaction.No</a> segments will be preserved by default.</td>
<td>0-100.</td>
</tr>
<tr>
<td>carbon.allowed.compaction.days</td>
<td>0</td>
<td>Minor/Major</td>
<td>Compaction will merge the segments which are loaded with in the specific number of days configured.Example: if the configuration is 2, then the segments which are loaded in the time frame of 2 days only will get merged. Segments which are loaded 2 days apart will not be merged.This is disabled by default.</td>
<td>0-100.</td>
</tr>
<tr>
<td>carbon.number.of.cores.while.compacting</td>
<td>2</td>
<td>Minor/Major</td>
<td>Number of cores which is used to write data during compaction.</td>
<td>0-100.</td>
</tr>
</tbody>
</table>
<p>For compaction commands refer to <a href="">DDL operations on Carbon Data</a></p>
</body></html>