Java Code Examples for org.apache.orc.OrcProto#ColumnEncoding

The following examples show how to use org.apache.orc.OrcProto#ColumnEncoding . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 6 votes vote down vote up
protected StringDictionaryTreeReader(int columnId, InStream present, InStream data,
                                     InStream length, InStream dictionary, OrcProto.ColumnEncoding encoding)
    throws IOException {
  super(columnId, present);
  scratchlcv = new LongColumnVector();
  if (data != null && encoding != null) {
    this.reader = createIntegerReader(encoding.getKind(), data, false, false);
  }

  if (dictionary != null && encoding != null) {
    readDictionaryStream(dictionary);
  }

  if (length != null && encoding != null) {
    readDictionaryLengthStream(length, encoding);
  }
}
 
Example 2
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 6 votes vote down vote up
protected StringTreeReader(int columnId, InStream present, InStream data, InStream length,
                           InStream dictionary, OrcProto.ColumnEncoding encoding) throws IOException {
  super(columnId, present);
  if (encoding != null) {
    switch (encoding.getKind()) {
      case DIRECT:
      case DIRECT_V2:
        reader = new StringDirectTreeReader(columnId, present, data, length,
            encoding.getKind());
        break;
      case DICTIONARY:
      case DICTIONARY_V2:
        reader = new StringDictionaryTreeReader(columnId, present, data, length, dictionary,
            encoding);
        break;
      default:
        throw new IllegalArgumentException("Unsupported encoding " +
            encoding.getKind());
    }
  }
}
 
Example 3
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 6 votes vote down vote up
protected CharTreeReader(int columnId, InStream present, InStream data, InStream length,
                         InStream dictionary, OrcProto.ColumnEncoding encoding, int maxLength) throws IOException {
  super(columnId, present);
  this.maxLength = maxLength;
  if (encoding != null) {
    switch (encoding.getKind()) {
      case DIRECT:
      case DIRECT_V2:
        reader = new StringDirectTreeReader(columnId, present, data, length,
            encoding.getKind());
        break;
      case DICTIONARY:
      case DICTIONARY_V2:
        reader = new StringDictionaryTreeReader(columnId, present, data, length, dictionary,
            encoding);
        break;
      default:
        throw new IllegalArgumentException("Unsupported encoding " +
            encoding.getKind());
    }
  }
}
 
Example 4
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 6 votes vote down vote up
protected TimestampTreeReader(TimeZone timeZone, int columnId, InStream presentStream, InStream dataStream,
                              InStream nanosStream, OrcProto.ColumnEncoding encoding, boolean skipCorrupt)
    throws IOException {
  super(columnId, presentStream);
  this.skipCorrupt = skipCorrupt;
  this.baseTimestampMap = new HashMap<>();
  this.readerTimeZone = timeZone;
  this.writerTimeZone = TimeZone.getDefault();
  this.hasSameTZRules = writerTimeZone.hasSameRules(readerTimeZone);
  this.base_timestamp = getBaseTimestamp(readerTimeZone.getID());
  if (encoding != null) {
    checkEncoding(encoding);

    if (dataStream != null) {
      this.data = createIntegerReader(encoding.getKind(), dataStream, true, skipCorrupt);
    }

    if (nanosStream != null) {
      this.nanos = createIntegerReader(encoding.getKind(), nanosStream, false, skipCorrupt);
    }
  }
}
 
Example 5
Source File: RecordReaderUtils.java    From tajo with Apache License 2.0 6 votes vote down vote up
public static void addRgFilteredStreamToRanges(OrcProto.Stream stream,
                                               boolean[] includedRowGroups, boolean isCompressed, OrcProto.RowIndex index,
                                               OrcProto.ColumnEncoding encoding, OrcProto.Type type, int compressionSize, boolean hasNull,
                                               long offset, long length, DiskRangeList.CreateHelper list, boolean doMergeBuffers) {
  for (int group = 0; group < includedRowGroups.length; ++group) {
    if (!includedRowGroups[group]) continue;
    int posn = getIndexPosition(
        encoding.getKind(), type.getKind(), stream.getKind(), isCompressed, hasNull);
    long start = index.getEntry(group).getPositions(posn);
    final long nextGroupOffset;
    boolean isLast = group == (includedRowGroups.length - 1);
    nextGroupOffset = isLast ? length : index.getEntry(group + 1).getPositions(posn);

    start += offset;
    long end = offset + estimateRgEndOffset(
        isCompressed, isLast, nextGroupOffset, length, compressionSize);
    list.addOrMerge(start, end, doMergeBuffers, true);
  }
}
 
Example 6
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if ((encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT) &&
      (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT_V2)) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}
 
Example 7
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DICTIONARY &&
      encoding.getKind() != OrcProto.ColumnEncoding.Kind.DICTIONARY_V2) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}
 
Example 8
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT &&
      encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT_V2) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}
 
Example 9
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if ((encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT) &&
      (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT_V2)) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}
 
Example 10
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if ((encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT) &&
      (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT_V2)) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}
 
Example 11
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
protected BinaryTreeReader(int columnId, InStream present, InStream data, InStream length,
                           OrcProto.ColumnEncoding encoding) throws IOException {
  super(columnId, present);
  scratchlcv = new LongColumnVector();
  this.stream = data;
  if (length != null && encoding != null) {
    checkEncoding(encoding);
    this.lengths = createIntegerReader(encoding.getKind(), length, false, false);
  }
}
 
Example 12
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if ((encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT) &&
      (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT_V2)) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}
 
Example 13
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
protected LongTreeReader(int columnId, InStream present, InStream data,
                         OrcProto.ColumnEncoding encoding,
                         boolean skipCorrupt)
    throws IOException {
  super(columnId, present);
  if (data != null && encoding != null) {
    checkEncoding(encoding);
    this.reader = createIntegerReader(encoding.getKind(), data, true, skipCorrupt);
  }
}
 
Example 14
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
protected IntTreeReader(int columnId, InStream present, InStream data,
                        OrcProto.ColumnEncoding encoding)
    throws IOException {
  super(columnId, present);
  if (data != null && encoding != null) {
    checkEncoding(encoding);
    this.reader = createIntegerReader(encoding.getKind(), data, true, false);
  }
}
 
Example 15
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if ((encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT) &&
      (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT_V2)) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}
 
Example 16
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 5 votes vote down vote up
protected ShortTreeReader(int columnId, InStream present, InStream data,
                          OrcProto.ColumnEncoding encoding)
    throws IOException {
  super(columnId, present);
  if (data != null && encoding != null) {
    checkEncoding(encoding);
    this.reader = createIntegerReader(encoding.getKind(), data, true, false);
  }
}
 
Example 17
Source File: RecordReaderUtils.java    From tajo with Apache License 2.0 5 votes vote down vote up
/**
 * Is this stream part of a dictionary?
 * @return is this part of a dictionary?
 */
public static boolean isDictionary(OrcProto.Stream.Kind kind,
                                   OrcProto.ColumnEncoding encoding) {
  assert kind != OrcProto.Stream.Kind.DICTIONARY_COUNT;
  OrcProto.ColumnEncoding.Kind encodingKind = encoding.getKind();
  return kind == OrcProto.Stream.Kind.DICTIONARY_DATA ||
      (kind == OrcProto.Stream.Kind.LENGTH &&
          (encodingKind == OrcProto.ColumnEncoding.Kind.DICTIONARY ||
              encodingKind == OrcProto.ColumnEncoding.Kind.DICTIONARY_V2));
}
 
Example 18
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 4 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  reader.checkEncoding(encoding);
}
 
Example 19
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 4 votes vote down vote up
@Override
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  reader.checkEncoding(encoding);
}
 
Example 20
Source File: TreeReaderFactory.java    From tajo with Apache License 2.0 4 votes vote down vote up
void checkEncoding(OrcProto.ColumnEncoding encoding) throws IOException {
  if (encoding.getKind() != OrcProto.ColumnEncoding.Kind.DIRECT) {
    throw new IOException("Unknown encoding " + encoding + " in column " +
        columnId);
  }
}