-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented support for preserving writetimes & TTL on tables with on…
…ly collection
- Loading branch information
1 parent
efb1558
commit 6eaa55a
Showing
14 changed files
with
458 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/com/datastax/cdm/cql/codec/BIGINT_BigIntegerCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright DataStax, 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, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.datastax.cdm.cql.codec; | ||
|
||
import java.math.BigInteger; | ||
import java.nio.ByteBuffer; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.datastax.cdm.properties.PropertyHelper; | ||
import com.datastax.oss.driver.api.core.ProtocolVersion; | ||
import com.datastax.oss.driver.api.core.type.DataType; | ||
import com.datastax.oss.driver.api.core.type.DataTypes; | ||
import com.datastax.oss.driver.api.core.type.codec.TypeCodecs; | ||
import com.datastax.oss.driver.api.core.type.reflect.GenericType; | ||
|
||
public class BIGINT_BigIntegerCodec extends AbstractBaseCodec<BigInteger> { | ||
|
||
public BIGINT_BigIntegerCodec(PropertyHelper propertyHelper) { | ||
super(propertyHelper); | ||
} | ||
|
||
@Override | ||
public @NotNull GenericType<BigInteger> getJavaType() { | ||
return GenericType.BIG_INTEGER; | ||
} | ||
|
||
@Override | ||
public @NotNull DataType getCqlType() { | ||
return DataTypes.BIGINT; | ||
} | ||
|
||
@Override | ||
public ByteBuffer encode(BigInteger value, @NotNull ProtocolVersion protocolVersion) { | ||
if (value == null) { | ||
return null; | ||
} else { | ||
return TypeCodecs.BIGINT.encode(value.longValue(), protocolVersion); | ||
} | ||
} | ||
|
||
@Override | ||
public BigInteger decode(ByteBuffer bytes, @NotNull ProtocolVersion protocolVersion) { | ||
return BigInteger.valueOf(TypeCodecs.BIGINT.decode(bytes, protocolVersion)); | ||
} | ||
|
||
@Override | ||
public @NotNull String format(BigInteger value) { | ||
return TypeCodecs.BIGINT.format(value.longValue()); | ||
} | ||
|
||
@Override | ||
public BigInteger parse(String value) { | ||
return BigInteger.valueOf(TypeCodecs.BIGINT.parse(value)); | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/datastax/cdm/cql/codec/BigInteger_BIGINTCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright DataStax, 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, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.datastax.cdm.cql.codec; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.datastax.cdm.properties.PropertyHelper; | ||
import com.datastax.oss.driver.api.core.ProtocolVersion; | ||
import com.datastax.oss.driver.api.core.type.DataType; | ||
import com.datastax.oss.driver.api.core.type.DataTypes; | ||
import com.datastax.oss.driver.api.core.type.codec.TypeCodecs; | ||
import com.datastax.oss.driver.api.core.type.reflect.GenericType; | ||
|
||
public class BigInteger_BIGINTCodec extends AbstractBaseCodec<Integer> { | ||
|
||
public BigInteger_BIGINTCodec(PropertyHelper propertyHelper) { | ||
super(propertyHelper); | ||
} | ||
|
||
@Override | ||
public @NotNull GenericType<Integer> getJavaType() { | ||
return GenericType.INTEGER; | ||
} | ||
|
||
@Override | ||
public @NotNull DataType getCqlType() { | ||
return DataTypes.INT; | ||
} | ||
|
||
@Override | ||
public ByteBuffer encode(Integer value, @NotNull ProtocolVersion protocolVersion) { | ||
if (value == null) { | ||
return null; | ||
} else { | ||
return TypeCodecs.INT.encode(value, protocolVersion); | ||
} | ||
} | ||
|
||
@Override | ||
public Integer decode(ByteBuffer bytes, @NotNull ProtocolVersion protocolVersion) { | ||
return TypeCodecs.INT.decode(bytes, protocolVersion); | ||
} | ||
|
||
@Override | ||
public @NotNull String format(Integer value) { | ||
return TypeCodecs.INT.format(value); | ||
} | ||
|
||
@Override | ||
public Integer parse(String value) { | ||
return TypeCodecs.INT.parse(value); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.