Skip to content
This repository has been archived by the owner on Dec 28, 2017. It is now read-only.

Commit

Permalink
[Fix]Add bit type (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Novemser authored and ilovesoup committed Nov 16, 2017
1 parent 5c88e0e commit 05a1f6a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
29 changes: 29 additions & 0 deletions src/main/java/com/pingcap/tikv/types/BitType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* Copyright 2017 PingCAP, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.pingcap.tikv.types;

import com.pingcap.tikv.meta.TiColumnInfo;

/**
* We add this type in order to recognize BitType in spark strategy
*/
public class BitType extends IntegerType {
protected BitType(TiColumnInfo.InternalTypeHolder holder) {
super(holder);
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/pingcap/tikv/types/DataTypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

package com.pingcap.tikv.types;

import static com.pingcap.tikv.types.Types.*;

import com.google.common.collect.ImmutableMap;
import com.pingcap.tikv.meta.TiColumnInfo.InternalTypeHolder;

import java.util.Map;
import java.util.function.Function;

import static com.pingcap.tikv.types.Types.*;

/** Create DataType according to Type Flag. */
public class DataTypeFactory {
// TODO: the type system still needs another overhaul
Expand All @@ -35,7 +36,7 @@ public class DataTypeFactory {
.put(TYPE_INT24, IntegerType.of(TYPE_INT24))
.put(TYPE_LONG_LONG, IntegerType.of(TYPE_LONG_LONG))
.put(TYPE_YEAR, IntegerType.of(TYPE_YEAR))
.put(TYPE_BIT, IntegerType.of(TYPE_BIT))
.put(TYPE_BIT, BitType.of(TYPE_BIT))
.put(TYPE_NEW_DECIMAL, DecimalType.of(TYPE_NEW_DECIMAL))
.put(TYPE_FLOAT, RealType.of(TYPE_FLOAT))
.put(TYPE_DOUBLE, RealType.of(TYPE_DOUBLE))
Expand Down Expand Up @@ -65,7 +66,7 @@ public class DataTypeFactory {
.put(TYPE_INT24, IntegerType::new)
.put(TYPE_LONG_LONG, IntegerType::new)
.put(TYPE_YEAR, IntegerType::new)
.put(TYPE_BIT, IntegerType::new)
.put(TYPE_BIT, BitType::new)
.put(TYPE_NEW_DECIMAL, DecimalType::new)
.put(TYPE_FLOAT, RealType::new)
.put(TYPE_DOUBLE, RealType::new)
Expand Down

0 comments on commit 05a1f6a

Please sign in to comment.