Yang, Tong 6182f91ba8 MRS component operation guide_normal 2.0.38.SP20 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Yang, Tong <yangtong2@huawei.com>
Co-committed-by: Yang, Tong <yangtong2@huawei.com>
2022-12-09 14:55:21 +00:00

59 lines
5.0 KiB
HTML

<a name="mrs_01_2211"></a><a name="mrs_01_2211"></a>
<h1 class="topictitle1">How Do I Deal with the Restrictions of the Phoenix BulkLoad Tool?</h1>
<div id="body0000001136382301"><div class="section" id="mrs_01_2211__section132901917352"><h4 class="sectiontitle">Question</h4><p id="mrs_01_2211__p115714455464">When the indexed field data is updated, if a batch of data exists in the user table, the BulkLoad tool cannot update the global and partial mutable indexes.</p>
</div>
<div class="section" id="mrs_01_2211__section523631285214"><h4 class="sectiontitle">Answer</h4><p id="mrs_01_2211__p16212883715"><strong id="mrs_01_2211__b0520926133717">Problem Analysis</strong></p>
<ol id="mrs_01_2211__ol18902204474620"><li id="mrs_01_2211__li6902144417464">Create a table.<pre class="screen" id="mrs_01_2211__screen997154317389">CREATE TABLE TEST_TABLE(
DATE varchar not null,
NUM integer not null,
SEQ_NUM integer not null,
ACCOUNT1 varchar not null,
ACCOUNTDES varchar,
FLAG varchar,
SALL double,
CONSTRAINT PK PRIMARY KEY (DATE,NUM,SEQ_NUM,ACCOUNT1)
);</pre>
</li><li id="mrs_01_2211__li199028444468">Create a global index.<p id="mrs_01_2211__p7241850104615"><a name="mrs_01_2211__li199028444468"></a><a name="li199028444468"></a><strong id="mrs_01_2211__b1322120528385">CREATE INDEX TEST_TABLE_INDEX ON TEST_TABLE(ACCOUNT1,DATE,NUM,ACCOUNTDES,SEQ_NUM)</strong>;</p>
</li><li id="mrs_01_2211__li1790234444611">Insert data.<p id="mrs_01_2211__p6607125334610"><a name="mrs_01_2211__li1790234444611"></a><a name="li1790234444611"></a><strong id="mrs_01_2211__b28427053920">UPSERT INTO TEST_TABLE (DATE,NUM,SEQ_NUM,ACCOUNT1,ACCOUNTDES,FLAG,SALL) values ('20201001',30201001,13,'367392332','sffa1','','');</strong></p>
</li><li id="mrs_01_2211__li149022447468">Execute the BulkLoad task to update data.<div class="p" id="mrs_01_2211__p1426910571469"><a name="mrs_01_2211__li149022447468"></a><a name="li149022447468"></a><strong id="mrs_01_2211__b11375910113917">hbase org.apache.phoenix.mapreduce.CsvBulkLoadTool -t TEST_TABLE -i /tmp/test.csv</strong>, where the content of <strong id="mrs_01_2211__b147772055172312">test.csv</strong> is as follows:
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_2211__table6387713193817" frame="border" border="1" rules="all"><tbody><tr id="mrs_01_2211__row183873137381"><td class="cellrowborder" valign="top" width="12.040000000000001%"><p id="mrs_01_2211__p9387101317387">20201001</p>
</td>
<td class="cellrowborder" valign="top" width="12.040000000000001%"><p id="mrs_01_2211__p1738713130389">30201001</p>
</td>
<td class="cellrowborder" valign="top" width="12.040000000000001%"><p id="mrs_01_2211__p173871913173818">13</p>
</td>
<td class="cellrowborder" valign="top" width="27.760000000000005%"><p id="mrs_01_2211__p193871713193818">367392332</p>
</td>
<td class="cellrowborder" valign="top" width="12.040000000000001%"><p id="mrs_01_2211__p9387181373818">sffa888</p>
</td>
<td class="cellrowborder" valign="top" width="12.040000000000001%"><p id="mrs_01_2211__p3387111363818">1231243</p>
</td>
<td class="cellrowborder" valign="top" width="12.040000000000001%"><p id="mrs_01_2211__p0387813143815">23</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</li><li id="mrs_01_2211__li159021244104613">Symptom: The existing index data cannot be directly updated. As a result, two pieces of index data exist.<pre class="screen" id="mrs_01_2211__screen148006309436">+------------+-----------+-----------+---------------+----------------+
| :ACCOUNT1 | :DATE | :NUM | 0:ACCOUNTDES | :SEQ_NUM |
+------------+-----------+-----------+---------------+----------------+
| 367392332 | 20201001 | 30201001 | sffa1 | 13 |
| 367392332 | 20201001 | 30201001 | sffa888 | 13 |
+------------+-----------+-----------+---------------+----------------+</pre>
</li></ol>
<p id="mrs_01_2211__p1397720289376"><strong id="mrs_01_2211__b67025425374">Solution</strong></p>
<ol id="mrs_01_2211__ol19609395714"><li id="mrs_01_2211__li1596122919812"><span>Delete the old index table.</span><p><p id="mrs_01_2211__p139021306814"><strong id="mrs_01_2211__b16643294473">DROP INDEX TEST_TABLE_INDEX ON TEST_TABL</strong><strong id="mrs_01_2211__b3188114318810">E;</strong></p>
</p></li><li id="mrs_01_2211__li10562544717"><span>Create an index table in asynchronous mode.</span><p><p id="mrs_01_2211__p59031738781"><strong id="mrs_01_2211__b1737614343470">CREATE INDEX TEST_TABLE_INDEX ON TEST_TABLE(ACCOUNT1,DATE,NUM,ACCOUNTDES,SEQ_NUM) ASYNC;</strong></p>
</p></li><li id="mrs_01_2211__li650311332817"><span>Recreate a index.</span><p><p id="mrs_01_2211__p19799341994"><strong id="mrs_01_2211__b1832624017473">hbase org.apache.phoenix.mapreduce.index.IndexTool --data-table TEST_TABLE --index-table TEST_TABLE_INDEX --output-path /user/test_table</strong></p>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_1638.html">Common Issues About HBase</a></div>
</div>
</div>