Beispiel #1
0
// NewDictionaryPage
func NewDictionaryPage(schema *thrift.SchemaElement, header *thrift.DictionaryPageHeader) *DictionaryPage {
	count := uint(header.NumValues)

	t := schema.GetType()
	switch t {
	case thrift.Type_BOOLEAN:
		return &DictionaryPage{
			t:          t,
			header:     header,
			valuesBool: make([]bool, count),
			count:      count,
		}
	case thrift.Type_INT32:
		return &DictionaryPage{
			t:           t,
			header:      header,
			valuesInt32: make([]int32, count),
			count:       count,
		}
	case thrift.Type_INT64:
		return &DictionaryPage{t: t, header: header, valuesInt64: make([]int64, count), count: count}
	case thrift.Type_BYTE_ARRAY:
		return &DictionaryPage{t: t, header: header, valuesByteArray: make([][]byte, count), count: count}
	case thrift.Type_FIXED_LEN_BYTE_ARRAY:
		return &DictionaryPage{t: t, header: header, valuesByteArray: make([][]byte, count), typeLength: uint(schema.GetTypeLength()), count: count}
	case thrift.Type_FLOAT:
		return &DictionaryPage{t: t, header: header, valuesFloat32: make([]float32, count), count: count}
	case thrift.Type_DOUBLE:
		return &DictionaryPage{t: t, header: header, valuesFloat64: make([]float64, count), count: count}
	case thrift.Type_INT96:
		return &DictionaryPage{
			t:           t,
			header:      header,
			valuesInt96: make([]datatypes.Int96, count),
			count:       count,
		}
	default:
		panic("Warning: not supported type " + t.String() + " in plain encoding dictionaryPage")
	}

	return nil
}
Beispiel #2
0
func NewSimpleAccumulator(e *thrift.SchemaElement) Accumulator {
	t := e.GetType()
	switch t {
	case thrift.Type_BOOLEAN:
		return new(boolAccumulator)
	case thrift.Type_INT32:
		return new(int32Accumulator)
	case thrift.Type_INT64:
		return new(int64Accumulator)
	case thrift.Type_INT96:
		return new(int64Accumulator)
	case thrift.Type_FLOAT:
		return new(float32Accumulator)
	case thrift.Type_DOUBLE:
		return new(float64Accumulator)
	case thrift.Type_BYTE_ARRAY:
		return new(byteAccumulator)
	case thrift.Type_FIXED_LEN_BYTE_ARRAY:
		return &byteAccumulator{}
	default:
		panic("unknown type " + t.String())
	}
}
Beispiel #3
0
func NewBufferWithType(e *thrift.SchemaElement, size int) *Buffer {
	t := e.GetType()

	switch t {
	case thrift.Type_BOOLEAN:
		return &Buffer{t: thrift.Type_BOOLEAN, valuesBool: make([]bool, 0, size)}
	case thrift.Type_INT32:
		return &Buffer{t: thrift.Type_INT32, valuesInt32: make([]int32, 0, size)}
	case thrift.Type_INT64:
		return &Buffer{t: thrift.Type_INT64, valuesInt64: make([]int64, 0, size)}
	case thrift.Type_BYTE_ARRAY:
		return &Buffer{t: thrift.Type_BYTE_ARRAY, valuesByteArray: make([][]byte, 0, size)}
	case thrift.Type_FIXED_LEN_BYTE_ARRAY:
		return &Buffer{t: thrift.Type_BYTE_ARRAY, valuesByteArray: make([][]byte, 0, size), typeLength: uint(e.GetTypeLength())}
	case thrift.Type_FLOAT:
		return &Buffer{t: thrift.Type_FLOAT, valuesFloat32: make([]float32, 0, size)}
	case thrift.Type_DOUBLE:
		return &Buffer{t: thrift.Type_DOUBLE, valuesFloat64: make([]float64, 0, size)}
	case thrift.Type_INT96:
		return &Buffer{t: thrift.Type_INT96, valuesInt96: make([]Int96, 0, size)}
	default:
		panic(fmt.Sprintf("Warning: not supported type %#v in plain encoding dictionaryPage", t))
	}
}