• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BaseWriter类的典型用法和代码示例

java 2次浏览

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

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

示例1: ensureAtLeastOneField

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
@Override
public void ensureAtLeastOneField(ComplexWriter writer) {
  if (!atLeastOneWrite) {
    // if we had no columns, create one empty one so we can return some data for count purposes.
    SchemaPath sp = columns.get(0);
    PathSegment root = sp.getRootSegment();
    BaseWriter.MapWriter fieldWriter = writer.rootAsMap();
    while (root.getChild() != null && !root.getChild().isArray()) {
      fieldWriter = fieldWriter.map(root.getNameSegment().getPath());
      root = root.getChild();
    }
    fieldWriter.integer(root.getNameSegment().getPath());
  }
}
 

开发者ID:skhalifa,
项目名称:QDrill,
代码行数:15,
代码来源:JsonReader.java

示例2: write

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
@Override
public ReadState write(BaseWriter.ComplexWriter writer) throws IOException {
  final JsonToken token = parser.nextToken();
  if (!parser.hasCurrentToken()) {
    return ReadState.END_OF_STREAM;
  } else if (token != JsonToken.START_OBJECT) {
    throw new IllegalStateException(String.format("Cannot read from the middle of a record. Current token was %s", token));
  }
  writer.rootAsMap().bit("count").writeBit(1);
  parser.skipChildren();
  return ReadState.WRITE_SUCCEED;
}
 

开发者ID:skhalifa,
项目名称:QDrill,
代码行数:13,
代码来源:CountingJsonReader.java

示例3: write

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
@Override
public ReadState write(BaseWriter.ComplexWriter writer) throws IOException {
  try {
    JsonToken token = lastSeenJsonToken;
    if (token == null || token == JsonToken.END_OBJECT){
      token = parser.nextToken();
    }
    lastSeenJsonToken = null;
    if (!parser.hasCurrentToken()) {
      return ReadState.END_OF_STREAM;
    } else if (token != JsonToken.START_OBJECT) {
      throw new com.fasterxml.jackson.core.JsonParseException(
          parser,
          String
              .format(
                  "Cannot read from the middle of a record. Current token was %s ",
                  token));
      // throw new
      // IllegalStateException(String.format("Cannot read from the middle of a record. Current token was %s",
      // token));
    }
    writer.rootAsMap().bit("count").writeBit(1);
    parser.skipChildren();
  } catch (com.fasterxml.jackson.core.JsonParseException ex) {
    if (ignoreJSONParseError()) {
      if (processJSONException() == JsonExceptionProcessingState.END_OF_STREAM){
        return ReadState.JSON_RECORD_PARSE_EOF_ERROR;
      }
      else{
        return ReadState.JSON_RECORD_PARSE_ERROR;
      }
    } else {
      throw ex;
    }
  }
  return ReadState.WRITE_SUCCEED;
}
 

开发者ID:axbaretto,
项目名称:drill,
代码行数:38,
代码来源:CountingJsonReader.java

示例4: ensureAtLeastOneField

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public void ensureAtLeastOneField(ComplexWriter writer) {
  if (!atLeastOneWrite) {
    // if we had no columns, create one empty one so we can return some data
    // for count purposes.
    SchemaPath sp = columns.get(0);
    PathSegment root = sp.getRootSegment();
    BaseWriter.MapWriter fieldWriter = writer.rootAsMap();
    while (root.getChild() != null && !root.getChild().isArray()) {
      fieldWriter = fieldWriter.map(root.getNameSegment().getPath());
      root = root.getChild();
    }
    fieldWriter.integer(root.getNameSegment().getPath());
  }
}
 

开发者ID:axbaretto,
项目名称:drill,
代码行数:15,
代码来源:BsonRecordReader.java

示例5: writeInt

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public void writeInt(BaseWriter.ComplexWriter writer, RepeatedIntHolder ... in) {
    int n = -1;
    for (RepeatedIntHolder input : in) {
        if (n != -1 && n != input.end - input.start) {
            throw new IllegalArgumentException("Arguments to zip must all be same length");
        }
        n = input.end - input.start;
    }
    if (n == -1) {
        throw new IllegalArgumentException("Must have at least one argument to zip");
    }

    IntVector.Accessor[] v = new IntVector.Accessor[in.length];
    for (int i = 0; i < in.length; i++) {
        v[i] = in[i].vector.getAccessor();
    }

    writer.setValueCount(n);
    BaseWriter.ListWriter outer = writer.rootAsList();
    outer.startList(); // [ outer list

    for (int i = 0; i < n; i++) {
        BaseWriter.ListWriter inner = outer.list();
        inner.startList();
        for (IntVector.Accessor accessor : v) {
            inner.integer().writeInt(accessor.get(i));
        }
        inner.endList();   // ] inner list
    }

    outer.endList(); // ] outer list
}
 

开发者ID:mapr-demos,
项目名称:simple-drill-functions,
代码行数:33,
代码来源:ZipWriter.java

示例6: writeFloat8

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public void writeFloat8(BaseWriter.ComplexWriter writer, RepeatedFloat8Holder... in) {
    int n = -1;
    for (RepeatedFloat8Holder input : in) {
        if (n != -1 && n != input.end - input.start) {
            throw new IllegalArgumentException("Arguments to zip must all be same length");
        }
        n = input.end - input.start;
    }
    if (n == -1) {
        throw new IllegalArgumentException("Must have at least one argument to zip");
    }

    Float8Vector.Accessor[] v = new Float8Vector.Accessor[in.length];
    for (int i = 0; i < in.length; i++) {
        v[i] = in[i].vector.getAccessor();
    }

    writer.setValueCount(n);
    BaseWriter.ListWriter outer = writer.rootAsList();
    outer.startList(); // [ outer list

    for (int i = 0; i < n; i++) {
        BaseWriter.ListWriter inner = outer.list();
        inner.startList();
        for (Float8Vector.Accessor accessor : v) {
            inner.float8().writeFloat8(accessor.get(i));
        }
        inner.endList();   // ] inner list
    }

    outer.endList(); // ] outer list
}
 

开发者ID:mapr-demos,
项目名称:simple-drill-functions,
代码行数:33,
代码来源:ZipWriter.java

示例7: mappify

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public static DrillBuf mappify(FieldReader reader, BaseWriter.ComplexWriter writer, DrillBuf buffer) {
  // Currently we expect single map as input
  if (DataMode.REPEATED == reader.getType().getMode() || !(reader.getType().getMinorType() == TypeProtos.MinorType.MAP)) {
    throw new DrillRuntimeException("kvgen function only supports Simple maps as input");
  }
  BaseWriter.ListWriter listWriter = writer.rootAsList();
  listWriter.start();
  BaseWriter.MapWriter mapWriter = listWriter.map();

  // Iterate over the fields in the map
  Iterator<String> fieldIterator = reader.iterator();
  while (fieldIterator.hasNext()) {
    String str = fieldIterator.next();
    FieldReader fieldReader = reader.reader(str);

    // Skip the field if its null
    if (fieldReader.isSet() == false) {
      mapWriter.end();
      continue;
    }

    // writing a new field, start a new map
    mapWriter.start();

    // write "key":"columnname" into the map
    VarCharHolder vh = new VarCharHolder();
    byte[] b = str.getBytes(Charsets.UTF_8);
    buffer = buffer.reallocIfNeeded(b.length);
    buffer.setBytes(0, b);
    vh.start = 0;
    vh.end = b.length;
    vh.buffer = buffer;
    mapWriter.varChar(fieldKey).write(vh);

    // Write the value to the map
    MapUtility.writeToMapFromReader(fieldReader, mapWriter);

    mapWriter.end();
  }
  listWriter.end();

  return buffer;
}
 

开发者ID:skhalifa,
项目名称:QDrill,
代码行数:44,
代码来源:MappifyUtility.java

示例8: MapOrListWriter

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
MapOrListWriter(final BaseWriter.MapWriter writer) {
  this.map = writer;
  this.list = null;
}
 

开发者ID:skhalifa,
项目名称:QDrill,
代码行数:5,
代码来源:MapOrListWriter.java

示例9: mappify

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public static DrillBuf mappify(FieldReader reader, BaseWriter.ComplexWriter writer, DrillBuf buffer) {
  // Currently we expect single map as input
  if (DataMode.REPEATED == reader.getType().getMode() || !(reader.getType().getMinorType() == TypeProtos.MinorType.MAP)) {
    throw new DrillRuntimeException("kvgen function only supports Simple maps as input");
  }
  BaseWriter.ListWriter listWriter = writer.rootAsList();
  listWriter.startList();
  BaseWriter.MapWriter mapWriter = listWriter.map();

  // Iterate over the fields in the map
  Iterator<String> fieldIterator = reader.iterator();
  while (fieldIterator.hasNext()) {
    String str = fieldIterator.next();
    FieldReader fieldReader = reader.reader(str);

    // Skip the field if its null
    if (fieldReader.isSet() == false) {
      mapWriter.end();
      continue;
    }

    // writing a new field, start a new map
    mapWriter.start();

    // write "key":"columnname" into the map
    VarCharHolder vh = new VarCharHolder();
    byte[] b = str.getBytes(Charsets.UTF_8);
    buffer = buffer.reallocIfNeeded(b.length);
    buffer.setBytes(0, b);
    vh.start = 0;
    vh.end = b.length;
    vh.buffer = buffer;
    mapWriter.varChar(fieldKey).write(vh);

    // Write the value to the map
    MapUtility.writeToMapFromReader(fieldReader, mapWriter);

    mapWriter.end();
  }
  listWriter.endList();

  return buffer;
}
 

开发者ID:axbaretto,
项目名称:drill,
代码行数:44,
代码来源:MappifyUtility.java

示例10: MapOrListWriterImpl

点赞 2

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public MapOrListWriterImpl(final BaseWriter.MapWriter writer) {
  this.map = writer;
  this.list = null;
}
 

开发者ID:axbaretto,
项目名称:drill,
代码行数:5,
代码来源:MapOrListWriterImpl.java

示例11: eval

点赞 1

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public void eval() {

        org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter queryMapWriter = outWriter.rootAsMap();

        String userAgentString = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer);

        if( userAgentString.isEmpty() || userAgentString.equals("null")){
            userAgentString = "";
        }

        nl.basjes.parse.useragent.UserAgent agent = uaa.parse(userAgentString);

        for (String fieldName: agent.getAvailableFieldNamesSorted()) {

            org.apache.drill.exec.expr.holders.VarCharHolder rowHolder = new org.apache.drill.exec.expr.holders.VarCharHolder();
            String field = agent.getValue(fieldName);

            byte[] rowStringBytes = field.getBytes();
            outBuffer.reallocIfNeeded(rowStringBytes.length);
            outBuffer.setBytes(0, rowStringBytes);

            rowHolder.start = 0;
            rowHolder.end = rowStringBytes.length;
            rowHolder.buffer = outBuffer;

            queryMapWriter.varChar(fieldName).write(rowHolder);
        }
    }
 

开发者ID:cgivre,
项目名称:drill-useragent-function,
代码行数:29,
代码来源:ParseUserAgentFunction.java

示例12: eval

点赞 1

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
public void eval() {

        org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter queryMapWriter = outWriter.rootAsMap();

        String queryString = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer);

        if( queryString.isEmpty() || queryString.equals("null")){
            queryString = "";
        }

        String firstLetter = queryString.substring(0, 1);

        //If the first character is a &, it doesn't split properly.  This checks to see if the first character is an & and if so, removes it.
        if(firstLetter.equals("&")){
            queryString = queryString.substring(1);
        }

        String[] arguments = queryString.split("&");

        for (int i = 0; i < arguments.length; i++) {
            String[] queryParts = arguments[i].split("=");

            org.apache.drill.exec.expr.holders.VarCharHolder rowHolder = new org.apache.drill.exec.expr.holders.VarCharHolder();

            byte[] rowStringBytes = queryParts[1].getBytes();

            outBuffer.reallocIfNeeded(rowStringBytes.length);
            outBuffer.setBytes(0, rowStringBytes);

            rowHolder.start = 0;
            rowHolder.end = rowStringBytes.length;
            rowHolder.buffer = outBuffer;

            queryMapWriter.varChar(queryParts[0]).write(rowHolder);

        }
    }
 

开发者ID:axbaretto,
项目名称:drill,
代码行数:38,
代码来源:ParseQueryFunction.java

示例13: ensureAtLeastOneField

点赞 1

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
@Override
public void ensureAtLeastOneField(BaseWriter.ComplexWriter writer) {

}
 

开发者ID:skhalifa,
项目名称:QDrill,
代码行数:5,
代码来源:CountingJsonReader.java

示例14: write

点赞 1

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
ReadState write(BaseWriter.ComplexWriter writer) throws IOException; 

开发者ID:skhalifa,
项目名称:QDrill,
代码行数:2,
代码来源:JsonProcessor.java

示例15: ensureAtLeastOneField

点赞 1

import org.apache.drill.exec.vector.complex.writer.BaseWriter; //导入依赖的package包/类
void ensureAtLeastOneField(BaseWriter.ComplexWriter writer); 

开发者ID:skhalifa,
项目名称:QDrill,
代码行数:2,
代码来源:JsonProcessor.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)