Ejemplo n.º 1
0
 /**
  * Is this stream part of a dictionary?
  * @return is this part of a dictionary?
  */
 public static bool isDictionary(OrcProto.Stream.Types.Kind kind,
                                 OrcProto.ColumnEncoding encoding)
 {
     Debug.Assert(kind != OrcProto.Stream.Types.Kind.DICTIONARY_COUNT);
     OrcProto.ColumnEncoding.Types.Kind encodingKind = encoding.Kind;
     return(kind == OrcProto.Stream.Types.Kind.DICTIONARY_DATA ||
            (kind == OrcProto.Stream.Types.Kind.LENGTH &&
             (encodingKind == OrcProto.ColumnEncoding.Types.Kind.DICTIONARY ||
              encodingKind == OrcProto.ColumnEncoding.Types.Kind.DICTIONARY_V2)));
 }
Ejemplo n.º 2
0
        /**
         * Get the offset in the index positions for the column that the given
         * stream starts.
         * @param columnEncoding the encoding of the column
         * @param columnType the type of the column
         * @param streamType the kind of the stream
         * @param isCompressed is the file compressed
         * @param hasNulls does the column have a PRESENT stream?
         * @return the number of positions that will be used for that stream
         */
        public static int getIndexPosition(OrcProto.ColumnEncoding.Types.Kind columnEncoding,
                                           OrcProto.Type.Types.Kind columnType,
                                           OrcProto.Stream.Types.Kind streamType,
                                           bool isCompressed,
                                           bool hasNulls)
        {
            if (streamType == OrcProto.Stream.Types.Kind.PRESENT)
            {
                return(0);
            }
            int compressionValue = isCompressed ? 1 : 0;
            int @base            = hasNulls ? (BITFIELD_POSITIONS + compressionValue) : 0;

            switch (columnType)
            {
            case OrcProto.Type.Types.Kind.BOOLEAN:
            case OrcProto.Type.Types.Kind.BYTE:
            case OrcProto.Type.Types.Kind.SHORT:
            case OrcProto.Type.Types.Kind.INT:
            case OrcProto.Type.Types.Kind.LONG:
            case OrcProto.Type.Types.Kind.FLOAT:
            case OrcProto.Type.Types.Kind.DOUBLE:
            case OrcProto.Type.Types.Kind.DATE:
            case OrcProto.Type.Types.Kind.STRUCT:
            case OrcProto.Type.Types.Kind.MAP:
            case OrcProto.Type.Types.Kind.LIST:
            case OrcProto.Type.Types.Kind.UNION:
                return(@base);

            case OrcProto.Type.Types.Kind.CHAR:
            case OrcProto.Type.Types.Kind.VARCHAR:
            case OrcProto.Type.Types.Kind.STRING:
                if (columnEncoding == OrcProto.ColumnEncoding.Types.Kind.DICTIONARY ||
                    columnEncoding == OrcProto.ColumnEncoding.Types.Kind.DICTIONARY_V2)
                {
                    return(@base);
                }
                else
                {
                    if (streamType == OrcProto.Stream.Types.Kind.DATA)
                    {
                        return(@base);
                    }
                    else
                    {
                        return(@base + BYTE_STREAM_POSITIONS + compressionValue);
                    }
                }

            case OrcProto.Type.Types.Kind.BINARY:
                if (streamType == OrcProto.Stream.Types.Kind.DATA)
                {
                    return(@base);
                }
                return(@base + BYTE_STREAM_POSITIONS + compressionValue);

            case OrcProto.Type.Types.Kind.DECIMAL:
                if (streamType == OrcProto.Stream.Types.Kind.DATA)
                {
                    return(@base);
                }
                return(@base + BYTE_STREAM_POSITIONS + compressionValue);

            case OrcProto.Type.Types.Kind.TIMESTAMP:
                if (streamType == OrcProto.Stream.Types.Kind.DATA)
                {
                    return(@base);
                }
                return(@base + RUN_LENGTH_INT_POSITIONS + compressionValue);

            default:
                throw new ArgumentException("Unknown type " + columnType);
            }
        }