[
https://issues.apache.org/jira/browse/HBASE-10385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13890006#comment-13890006
]
Hadoop QA commented on HBASE-10385:
-----------------------------------
{color:red}-1 overall{color}. Here are the results of testing the latest
attachment
http://issues.apache.org/jira/secure/attachment/12624051/HBASE-10385.patch
against trunk revision .
ATTACHMENT ID: 12624051
{color:green}+1 @author{color}. The patch does not contain any @author
tags.
{color:red}-1 tests included{color}. The patch doesn't appear to include
any new or modified tests.
Please justify why no new tests are needed for this
patch.
Also please list what manual steps were performed to
verify this patch.
{color:red}-1 patch{color}. The patch command could not apply the patch.
Console output:
https://builds.apache.org/job/PreCommit-HBASE-Build/8582//console
This message is automatically generated.
> ImportTsv to parse date time from typical loader formats
> --------------------------------------------------------
>
> Key: HBASE-10385
> URL: https://issues.apache.org/jira/browse/HBASE-10385
> Project: HBase
> Issue Type: New Feature
> Components: mapreduce
> Affects Versions: 0.96.1.1
> Reporter: Vijay Sarvepali
> Priority: Minor
> Labels: importtsv
> Attachments: HBASE-10385.patch
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Simple patch to enable parsing of standard date time fields from TSV files
> into Hbase.
> ***************
> *** 57,62 ****
> --- 57,70 ----
> import com.google.common.base.Splitter;
> import com.google.common.collect.Lists;
>
> + //2013-08-19T04:39:07
> + import java.text.DateFormat;
> + import java.util.*;
> + import java.text.SimpleDateFormat;
> + import java.text.ParseException;
> +
> +
> +
> /**
> * Tool to import data from a TSV file.
> *
> ***************
> *** 220,229 ****
> getColumnOffset(timestampKeyColumnIndex),
> getColumnLength(timestampKeyColumnIndex));
> try {
> ! return Long.parseLong(timeStampStr);
> } catch (NumberFormatException nfe) {
> // treat this record as bad record
> ! throw new BadTsvLineException("Invalid timestamp " +
> timeStampStr);
> }
> }
>
> --- 228,239 ----
> getColumnOffset(timestampKeyColumnIndex),
> getColumnLength(timestampKeyColumnIndex));
> try {
> ! return Long.parseLong(timeStampStr);
> } catch (NumberFormatException nfe) {
> + // Try this record with string to date in mseconds long
> + return extractTimestampInput(timeStampStr);
> // treat this record as bad record
> ! //throw new BadTsvLineException("Invalid timestamp " +
> timeStampStr);
> }
> }
>
> ***************
> *** 243,248 ****
> --- 253,274 ----
> return lineBytes;
> }
> }
> + public static long extractTimestampInput(String strDate) throws
> BadTsvLineException{
> + final List<String> dateFormats = Arrays.asList("yyyy-MM-dd
> HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss");
> +
> + for(String format: dateFormats){
> + SimpleDateFormat sdf = new SimpleDateFormat(format);
> + try{
> + Date d= sdf.parse(strDate);
> + long msecs = d.getTime();
> + return msecs;
> + } catch (ParseException e) {
> + //intentionally empty
> + }
> + }
> + // If we come here we have a problem with converting timestamps for
> this row.
> + throw new BadTsvLineException("Invalid timestamp " + strDate);
> + }
>
> public static class BadTsvLineException extends Exception {
> public BadTsvLineException(String err) {
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)