在HBASE中将XML存储为平面文件

时间:2016-05-16 21:42:31

标签: java xml parsing hadoop hbase

我是HBase的新手,我想知道如何做到这一点。我有以下xml文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<interestRateCurve>
<effectiveasof>2016-04-27</effectiveasof>
<currency>JPY</currency>
<baddayconvention>M</baddayconvention>

<deposits>
<daycountconvention>ACT/360</daycountconvention>
<snaptime>2016-04-26T07:00:00.000Z</snaptime>
<spotdate>2016-04-29</spotdate>

<calenders>
<calender>TYO</calender>
</calenders>

<curvepoint>
<tenor>1M</tenor>
<maturitydate>2016-05-30</maturitydate>
<parrate>-0.00066</parrate>
</curvepoint>

<curvepoint>
<tenor>2M</tenor>
<maturitydate>2016-06-29</maturitydate>
<parrate>-0.00042</parrate>
</curvepoint>

<curvepoint>
<tenor>3M</tenor>
<maturitydate>2016-07-29</maturitydate>
<parrate>-0.000386</parrate>
</curvepoint>

<curvepoint>
<tenor>6M</tenor>
<maturitydate>2016-10-31</maturitydate>
<parrate>-0.000114</parrate>
</curvepoint>

<curvepoint>
<tenor>1Y</tenor>
<maturitydate>2017-04-28</maturitydate>o
<parrate>0.000758</parrate>
</curvepoint>

</deposits>

<swaps>
<fixeddaycountconvention>ACT/365</fixeddaycountconvention>
<floatingdaycountconvention>ACT/360</floatingdaycountconvention>
<fixedpaymentfrequency>6M</fixedpaymentfrequency>
<floatingpaymentfrequency>6M</floatingpaymentfrequency>
<snaptime>2016-04-26T07:00:00.000Z</snaptime>
<spotdate>2016-04-29</spotdate>

<calenders>
<calendar>TYO</calendar>
</calenders>

<curvepoint>
<tenor>2Y</tenor>
<maturitydate>2018-04-29</maturitydate>
<parrate>-0.0016</parrate>
</curvepoint>

<curvepoint>
<tenor>3Y</tenor>
<maturitydate>2019-04-29</maturitydate>
<parrate>-0.001663</parrate>
</curvepoint>

<curvepoint>
<tenor>4Y</tenor>
<maturitydate>2020-04-29</maturitydate>
<parrate>-0.001388</parrate>
</curvepoint>

<curvepoint>
<tenor>5Y</tenor>
<maturitydate>2021-04-29</maturitydate>
<parrate>-0.000963</parrate>
</curvepoint>

<curvepoint>
<tenor>6Y</tenor>
<maturitydate>2022-04-29</maturitydate>
<parrate>-0.000475</parrate>
</curvepoint>

<curvepoint>
<tenor>7Y</tenor>
<maturitydate>2023-04-29</maturitydate>
<parrate>-0.0000063</parrate>
</curvepoint>

<curvepoint>
<tenor>8Y</tenor>
<maturitydate>2024-04-29</maturitydate>
<parrate>0.000425</parrate>
</curvepoint>
<curvepoint>
<tenor>9Y</tenor>
<maturitydate>2025-04-29</maturitydate>
<parrate>0.000813</parrate>
</curvepoint>
<curvepoint>
<tenor>10Y</tenor>
<maturitydate>2026-04-29</maturitydate>
<parrate>0.0012</parrate>
</curvepoint>

<curvepoint>
<tenor>12Y</tenor>
<maturitydate>2028-04-29</maturitydate>
<parrate>0.002038</parrate>
</curvepoint>

<curvepoint>
<tenor>15Y</tenor>
<maturitydate>2031-04-29</maturitydate>
<parrate>0.00315</parrate>
</curvepoint>
<curvepoint>
<tenor>20Y</tenor>
<maturitydate>2036-04-29</maturitydate>
<parrate>0.004588</parrate>
</curvepoint>

<curvepoint>
<tenor>30Y</tenor>
<maturitydate>2046-04-29</maturitydate>
<parrate>0.005688</parrate>
</curvepoint>
</swaps>
</interestRateCurve>

我希望将其作为HBase中的表格存储为以下格式:

RowID      |  Deposit-1M | Deposit-2M |....| Swaps-2Y| Swaps-3Y | ....|Swaps-30Y
2016-04-27_JPY | val1 | val2 |.......

因此,我希望将其存储为单个列,其中<curvepoint>下的每个标记的值均为Deposits-1M(其中1M<tenor>值)。同样适用于Swaps

请告诉我如何用Java做到这一点。我只是无法理解!!

0 个答案:

没有答案