• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EventDeserializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.flume.serialization.EventDeserializer的典型用法代码示例。如果您正苦于以下问题:Java EventDeserializer类的具体用法?Java EventDeserializer怎么用?Java EventDeserializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EventDeserializer类属于org.apache.flume.serialization包,在下文中一共展示了EventDeserializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: validateMiniParse

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private void validateMiniParse(EventDeserializer des) throws IOException {
  Event evt;

  des.mark();
  evt = des.readEvent();
  assertEquals(new String(evt.getBody()), mini);
  des.reset(); // reset!

  evt = des.readEvent();
  assertEquals("data should be repeated, " +
      "because we reset() the stream", new String(evt.getBody()), mini);

  evt = des.readEvent();
  assertNull("Event should be null because there are no lines " +
      "left to read", evt);

  des.mark();
  des.close();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestBlobDeserializer.java


示例2: build

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Override
public EventDeserializer build(Context context, ResettableInputStream resettableInputStream) {
    Settings settings = createSettings(context);
    LDVFactory factory = new LDVFactory(settings);
    ResettableInputStreamWrapper wrapper = new ResettableInputStreamWrapper(resettableInputStream);
    LDVReader reader = factory.openReader(wrapper);

    Map<String, String> additionalHeaders = context.getSubProperties(Builder.HEADERS);
    boolean lowerCaseSchemaHeader=context.getBoolean("lowercase.header.schema", true);
    boolean lowerCaseTableHeader=context.getBoolean("lowercase.header.table", true);
    int bufferSize = context.getInteger("buffer.size", 256 * 1024);

    LDVEventBuilder eventBuilder = new LDVEventBuilder(additionalHeaders,
            bufferSize,
            lowerCaseSchemaHeader,
            lowerCaseTableHeader);

    return new LDVEventDeserializer(resettableInputStream, reader, eventBuilder);
}
 
开发者ID:jcustenborder,项目名称:hadoop-goldengate,代码行数:20,代码来源:LDVEventDeserializer.java


示例3: readEvents

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void readEvents() throws Exception {
    Context context = new Context(params);
    LDVEventDeserializer.Builder builder = new LDVEventDeserializer.Builder();
    EventDeserializer eventDeserializer = builder.build(context, resettableFileInputStream);
    Assert.assertNotNull("eventDeserializer should not be null", eventDeserializer);
    List<Event> events = eventDeserializer.readEvents(expected.length * 2);
    Assert.assertEquals("expected array does not match events list",  expected.length, events.size());
    for(int i=0;i<expected.length;i++){
        Message message = expected[i];
        Event event = events.get(i);

        //Header size needs to account for the schema literal
        Assert.assertEquals(message.getMetadata().size() + 1, event.getHeaders().size());

        for(CharSequence key:message.getMetadata().keySet()){
            Assert.assertEquals(
                    String.format("Message at index %s: key %s does not match.", i, key),
                    message.getMetadata().get(key),
                    event.getHeaders().get(key)
            );
        }
    }
}
 
开发者ID:jcustenborder,项目名称:hadoop-goldengate,代码行数:25,代码来源:LDVEventDeserializerTest.java


示例4: validateReadAndMark

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private void validateReadAndMark(EventDeserializer des) throws IOException {
    Event evt;

    evt = des.readEvent();
    assertTrue(new String(evt.getBody()).contains("Giada De Laurentiis"));
    des.mark();

    evt = des.readEvent();
    assertTrue(new String(evt.getBody()).contains("J K. Rowling"));
    des.mark(); // reset!

    List<Event> readEvents = des.readEvents(2);
    assertEquals(2, readEvents.size());

    evt = des.readEvent();
    assertNull("Event should be null because there are no more books " + "left to read", evt);

    des.mark();
    des.mark();
    des.close();
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:22,代码来源:XmlXpathDeserializerTest.java


示例5: validateReadAndMarkWithHeader

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private void validateReadAndMarkWithHeader(EventDeserializer des) throws IOException {
    Event evt;

    evt = des.readEvent();
    System.out.println(evt.getHeaders().get("myHeader"));
    assertTrue(evt.getHeaders().get("myHeader").contains("Giada De Laurentiis"));
    des.mark();

    evt = des.readEvent();
    assertTrue(evt.getHeaders().get("myHeader").contains("J K. Rowling"));
    des.mark(); // reset!

    List<Event> readEvents = des.readEvents(2);
    assertEquals(2, readEvents.size());

    evt = des.readEvent();
    assertNull("Event should be null because there are no more books " + "left to read", evt);

    des.mark();
    des.mark();
    des.close();
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:23,代码来源:XmlXpathDeserializerTest.java


示例6: validateReset

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private void validateReset(EventDeserializer des) throws IOException {
    Event evt = des.readEvent();
    assertEquals("Everyday Italian", new String(evt.getBody()));
    des.mark();

    List<Event> events = des.readEvents(3);
    assertEquals(3, events.size());
    assertEquals("Harry Potter", new String(events.get(0).getBody()));
    assertEquals("XQuery Kick Start", new String(events.get(1).getBody()));
    assertEquals("Learning XML", new String(events.get(2).getBody()));

    des.reset(); // reset!

    events = des.readEvents(3);
    assertEquals(3, events.size());
    assertEquals("Harry Potter", new String(events.get(0).getBody()));
    assertEquals("XQuery Kick Start", new String(events.get(1).getBody()));
    assertEquals("Learning XML", new String(events.get(2).getBody()));

    evt = des.readEvent();
    Assert.assertNull("Event should be null because there are no more books " + "left to read", evt);

}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:24,代码来源:XmlXpathDeserializerTest.java


示例7: readDeserializerEvents

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private List<Event> readDeserializerEvents(int numEvents) throws IOException {
  EventDeserializer des = currentFile.get().getDeserializer();
  List<Event> events = des.readEvents(numEvents);
  if (events.isEmpty() && firstTimeRead) {
    events.add(EventBuilder.withBody(new byte[0]));
  }
  firstTimeRead = false;
  return events;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:ReliableSpoolingFileEventReader.java


示例8: testSimpleViaBuilder

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testSimpleViaBuilder() throws IOException {
  ResettableInputStream in = new ResettableTestStringInputStream(mini);
  EventDeserializer.Builder builder = new BlobDeserializer.Builder();
  EventDeserializer des = builder.build(new Context(), in);
  validateMiniParse(des);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:8,代码来源:TestBlobDeserializer.java


示例9: testSimpleViaFactory

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testSimpleViaFactory() throws IOException {
  ResettableInputStream in = new ResettableTestStringInputStream(mini);
  EventDeserializer des;
  des = EventDeserializerFactory.getInstance(BlobDeserializer.Builder.class.getName(),
                                             new Context(), in);
  validateMiniParse(des);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:9,代码来源:TestBlobDeserializer.java


示例10: testBatch

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testBatch() throws IOException {
  ResettableInputStream in = new ResettableTestStringInputStream(mini);
  EventDeserializer des = new BlobDeserializer(new Context(), in);
  List<Event> events;

  events = des.readEvents(10); // try to read more than we should have
  assertEquals(1, events.size());
  assertEventBodyEquals(mini, events.get(0));

  des.mark();
  des.close();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:14,代码来源:TestBlobDeserializer.java


示例11: testMaxLineLength

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testMaxLineLength() throws IOException {
  String longLine = "abcdefghijklmnopqrstuvwxyz\n";
  Context ctx = new Context();
  ctx.put(BlobDeserializer.MAX_BLOB_LENGTH_KEY, "10");

  ResettableInputStream in = new ResettableTestStringInputStream(longLine);
  EventDeserializer des = new BlobDeserializer(ctx, in);

  assertEventBodyEquals("abcdefghij", des.readEvent());
  assertEventBodyEquals("klmnopqrst", des.readEvent());
  assertEventBodyEquals("uvwxyz\n", des.readEvent());
  assertNull(des.readEvent());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:15,代码来源:TestBlobDeserializer.java


示例12: build

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Override
public EventDeserializer build(Context context, ResettableInputStream in) {
    if (!(in instanceof Seekable)) {
        throw new IllegalArgumentException(
                "Cannot use this deserializer without a Seekable input stream");
    }
    try {
        return new XmlXpathDeserializer(context, in);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:13,代码来源:XmlXpathDeserializer.java


示例13: testReadsAndMark

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testReadsAndMark() throws IOException {
    Context context = new Context();
    context.put("expression", "/bookstore/book");
    EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream());
    validateReadAndMark(des);
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:8,代码来源:XmlXpathDeserializerTest.java


示例14: testReset

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testReset() throws IOException {
    Context context = new Context();
    context.put("expression", "/bookstore/book/title/text()");
    EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream());
    validateReset(des);
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:8,代码来源:XmlXpathDeserializerTest.java


示例15: testHeader

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testHeader() throws IOException {
  Context context = new Context();
  context.put("expression", "/bookstore/book");
  context.put("outputHeader", "myHeader");
  context.put("outputBody", "false");
  EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream());
  validateReadAndMarkWithHeader(des);
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:10,代码来源:XmlXpathDeserializerTest.java


示例16: testXPathWithNS

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test()
public void testXPathWithNS() throws IOException {
  Context context = new Context();
  context.put("expression", "/bookstore/book");
  EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream("ns.xml"));
  List<Event> events = des.readEvents(4);
  assertEquals(4, events.size());
  for (final Event event : events) {
    assertNotNull(event);
  }
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:12,代码来源:XmlXpathDeserializerTest.java


示例17: validateHeaders

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private void validateHeaders(EventDeserializer des) throws IOException {
    List<Event> events = des.readEvents(4);
    Assert.assertTrue(events.size() == 4);

    for (Event evt : events) {
        Assert.assertEquals(evt.getHeaders().get("author"), "J K. Rowling");
    }
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:9,代码来源:XmlXpathDeserializerTest.java


示例18: FileInfo

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
public FileInfo(File file, EventDeserializer deserializer) {
  this.file = file;
  this.length = file.length();
  this.lastModified = file.lastModified();
  this.deserializer = deserializer;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:7,代码来源:ReliableSpoolingFileEventReader.java


示例19: getDeserializer

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
public EventDeserializer getDeserializer() {
  return deserializer;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:4,代码来源:ReliableSpoolingFileEventReader.java


示例20: testSimple

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testSimple() throws IOException {
  ResettableInputStream in = new ResettableTestStringInputStream(mini);
  EventDeserializer des = new BlobDeserializer(new Context(), in);
  validateMiniParse(des);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:7,代码来源:TestBlobDeserializer.java



注:本文中的org.apache.flume.serialization.EventDeserializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PurchaseUpdatesResponse类代码示例发布时间:2022-05-22
下一篇:
Java RoleConstants类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap