首页 \ 问答 \ 解析并加载到Hive / Hadoop中(Parsing and loading into Hive/Hadoop)

解析并加载到Hive / Hadoop中(Parsing and loading into Hive/Hadoop)

我是hadoop map reduce框架的新手,我正在考虑使用hadoop map reduce来解析我的数据。 我有成千上万的大分隔文件,我正在考虑编写一个map reduce work来解析这些文件并将它们加载到hive datawarehouse中。 我在perl中编写了一个可以解析这些文件的解析器。 但我坚持用Hadoop map reduce做同样的事情

例如:我有一个像x = ay = bz = c ..... x = py = qz = s ..... x = 1 z = 2 ....等文件

现在我必须在hive表中将此文件作为列(x,y,z)加载,但我无法弄清楚是否可以继续使用它。 任何指导都非常有用。

这样做的另一个问题是有一些文件缺少字段y。 我必须在map reduce工作中包含该条件。 到目前为止,我已经尝试使用streaming.jar并将我的parser.pl作为mapper作为该jar文件的输入。 我认为这不是这样做的方法:),但我只是想尝试,如果这样做。 另外,我想过使用Hive的加载功能,但如果我在hive表中指定regexserde,则缺少的列会产生问题。

我现在迷失了,如果有人可以指导我,我会感激:)

此致,Atul


i am new to hadoop map reduce framework, and I am thinking of using hadoop map reduce to parse my data. I have thousands of big delimited files for which I am thinking of writing a map reduce job to parse those files and load them into hive datawarehouse. I have written a parser in perl which can parse those files. But I am stuck at doing the same with Hadoop map reduce

For example: I have a file like x=a y=b z=c..... x=p y=q z=s..... x=1 z=2 .... and so on

Now I have to load this file as columns (x,y,z) in hive table, but I am not able to figure out can I proceed with it. Any guidance with this would be really helpful.

Another problem in doing this is there are some files where the field y is missing. I have to include that condition in the map reduce job. So far, I have tried using streaming.jar and giving my parser.pl as mapper as input to that jar file. I think that is not the way to do it :), but I was just trying if that would work. Also, I thought of using load function of Hive, but the missing column will create problem if I will specify regexserde in hive table.

I am lost in this now, if any one could guide me with this I would be thankful :)

Regards, Atul


原文:https://stackoverflow.com/questions/6600843
更新时间:2023-12-10 12:12

最满意答案

两者都不是特别好。

  • 第一个缺点是您长时间握住锁。
  • 第二个缺点是检查后状态会发生变化。

而是尝试将不可变参数传递给您的方法(例如数据的副本)。 你可能仍然需要锁定构造参数和收集结果,但希望这个时间要短得多。


Neither is particularly good.

  • The first has the disadvantage that you hold the lock for a long time.
  • The second has the disadvantage that the state can change after you check it.

Instead try to pass immutable arguments to your method (for example a copy of the data). You will probably still need to lock for constructing the arguments and for collecting the results but this is hopefully a much shorter period of time.

相关问答

更多
  • 非泛型类型的静态字段(它本身不嵌套在泛型类型等中)只存在一次,所以所有的锁都会发生冲突。 如果(评论)你的目标是按照每种类型(从通用方法)制作锁,那么也许最好的方法是: public static class CacheManager { static class TypeLock { public static readonly object SyncLock = new object(); } ... void SomeGenericMethod
  • 看看新的.NET 4.0 Framework功能SemaphoreSlim类 。 它提供了SemaphoreSlim.Wait(CancellationToken)方法。 阻止当前线程,直到它可以进入SemaphoreSlim,同时观察CancellationToken 从某种角度来看,在这种简单的情况下使用Semaphore可能是一种开销,因为它最初的目的是为多线程提供访问权限,但也许您可能会觉得它很有用。 编辑:代码片段 CancellationToken token = new Cancellatio ...
  • 什么时候应该使用锁? 应该使用锁来保护多线程代码中的共享资源。 不是别的什么 但是当应用程序不脱离任何其他线程时,是否有必要? 绝对不。 这只是一个时间浪费。 但是请确保您不会隐式使用系统线程。 例如,如果您使用异步I / O,您可能会收到随机线程的回调,而不是原始线程。 使用锁是否存在性能问题? 是。 它们在单线程应用程序中不是很大,但是为什么不需要呼叫? ...如果这是未来好的设计模式[?] 锁定一切都是可怕的设计模式。 如果您的代码被随机锁定杂乱,那么您决定使用后台线程进行某些工作,您可能会遇到死锁。 ...
  • 我相信可以使用Monitor.TryEnter() 。 lock语句只是转换成一个Monitor.Enter()调用和一个try catch块。 I believe that you can use Monitor.TryEnter(). The lock statement just translates to a Monitor.Enter() call and a try catch block.
  • 我认为你使用BackgroundWorker走在正确的轨道上。 我发现以下模式对我有用。 在主窗体中,您需要执行以下步骤。 创建BackgroundWorker以执行长时间运行的操作。 启动BackgroundWorker。 将等待表单显示为模式对话框。 // Step 1: BackgroundWorker bg = new BackgroundWorker() bg.DoWork += new DoWorkEventHandler(bg_DoWork); bg.RunWorkerCompleted += ...
  • 两者都不是特别好。 第一个缺点是您长时间握住锁。 第二个缺点是检查后状态会发生变化。 而是尝试将不可变参数传递给您的方法(例如数据的副本)。 你可能仍然需要锁定构造参数和收集结果,但希望这个时间要短得多。 Neither is particularly good. The first has the disadvantage that you hold the lock for a long time. The second has the disadvantage that the state can c ...
  • 与两个(或更多)不同对象一起使用的语法如下。 lock (a) lock (b) { } 但是,这种用法通常是不鼓励的。 这有几个原因。 锁声明的顺序必须保持一致,否则可能会发生死锁。 这几乎总是不必要的。 这是一种代码味道。 在我看来,第一个原因确实是一个阴谋。 有很多方法可以在开发过程中犯一个错误。 这仅仅是其中之一。 而且,事实上,它确实很容易(相对于其他类型的错误可以做到)才能正确对待。 只要确保锁定总是以相同的顺序获取。 另外,使用嵌套锁定没有任何内在危险(只要正确完成)。 嵌套锁始终被获取。 ...
  • 不, 自动属性不是线程安全的。 它们不过是句法糖; 编译器会自动生成专用的后备字段,就像你手动写出它们一样。 但是,除非您的应用程序正在从多个线程访问属性,否则没有理由首先担心这一点。 从您的问题中很难判断您的应用程序是否是多线程的。 No, automatic properties are not thread-safe. They are nothing more than syntactic sugar; the compiler automatically generates the private ...
  • 如果您正在设计需要保证线程安全的数据结构和类型,那么请确保将锁和其他构造放入这些类型中以维护这些保证。 但是,单靠锁是不够的。 拿一本简单的字典。 假设您要确保字典内的内部数据结构不会被多个线程损坏,因此您需要引入锁。 但是,如果外部代码执行此操作: if (!dict.ContainsKey(key)) dict.Add(key, value); 然后在这里不能保证在调用ContainsKey和Add ,其他一些线程还没有将该键添加到字典中。 因此,线程安全类型可能需要比简单锁定更多的东西。 可 ...
  • 我假设“伪设计模式”意味着您的应用程序处于运行时状态,并且最终用户正在体验“虚拟设计模式”:请纠正我,如果我错了。 但是,我假设您指的是设计时间'控件的锁定属性,并且您希望在运行时“模拟”这个...正确的? 我还假设您将鼠标上/下/移动处理程序附加到允许移动的控件上,可能是通过循环遍历表单上的控件或控件的控件集合的子集允许移动)。 如果我的假设是正确的,那么我会去除事件处理程序,它们在需要禁用控件移动时启用移动,然后在需要允许控件再次移动时恢复这些事件处理程序。 一个主要原因是,imho是严格控制事件处理的 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)