You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2022/01/19 22:32:42 UTC
[cassandra] 01/02: Revert "Add unix time conversion functions"
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit e0a61f73b9b9d14db3e68aafb38257a7689557b9
Author: Francisco Guerrero <fr...@gmail.com>
AuthorDate: Fri Jan 14 15:36:35 2022 -0800
Revert "Add unix time conversion functions"
This reverts commit 8ddcd43b0cfcebfda882a238532d00905fe85eb8.
---
.../apache/cassandra/cql3/functions/TimeFcts.java | 79 +---------------------
.../org/apache/cassandra/db/marshal/LongType.java | 2 +-
.../cassandra/cql3/functions/TimeFctsTest.java | 39 -----------
.../cql3/validation/entities/TimeuuidTest.java | 2 +-
4 files changed, 3 insertions(+), 119 deletions(-)
diff --git a/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java b/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java
index 331eaa1..f029e59 100644
--- a/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java
@@ -42,18 +42,14 @@ public abstract class TimeFcts
now("currentdate", SimpleDateType.instance),
now("currenttime", TimeType.instance),
minTimeuuidFct,
- minTimeuuidFct(LongType.instance),
maxTimeuuidFct,
- maxTimeuuidFct(LongType.instance),
dateOfFct,
unixTimestampOfFct,
toDate(TimeUUIDType.instance),
toTimestamp(TimeUUIDType.instance),
- toTimestamp(LongType.instance),
toUnixTimestamp(TimeUUIDType.instance),
toUnixTimestamp(TimestampType.instance),
toDate(TimestampType.instance),
- toDate(LongType.instance),
toUnixTimestamp(SimpleDateType.instance),
toTimestamp(SimpleDateType.instance));
}
@@ -68,7 +64,7 @@ public abstract class TimeFcts
return type.now();
}
};
- }
+ };
public static final Function minTimeuuidFct = new NativeScalarFunction("mintimeuuid", TimeUUIDType.instance, TimestampType.instance)
{
@@ -82,21 +78,6 @@ public abstract class TimeFcts
}
};
- public static final NativeScalarFunction minTimeuuidFct(final LongType type)
- {
- return new NativeScalarFunction("mintimeuuid", TimeUUIDType.instance, type)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- ByteBuffer bb = parameters.get(0);
- if (bb == null)
- return null;
-
- return UUIDGen.toByteBuffer(UUIDGen.minTimeUUID(LongType.instance.toLong(bb)));
- }
- };
- }
-
public static final Function maxTimeuuidFct = new NativeScalarFunction("maxtimeuuid", TimeUUIDType.instance, TimestampType.instance)
{
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
@@ -109,21 +90,6 @@ public abstract class TimeFcts
}
};
- public static NativeScalarFunction maxTimeuuidFct(final LongType type)
- {
- return new NativeScalarFunction("maxtimeuuid", TimeUUIDType.instance, type)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- ByteBuffer bb = parameters.get(0);
- if (bb == null)
- return null;
-
- return UUIDGen.toByteBuffer(UUIDGen.maxTimeUUID(LongType.instance.toLong(bb)));
- }
- };
- }
-
/**
* Function that convert a value of <code>TIMEUUID</code> into a value of type <code>TIMESTAMP</code>.
* @deprecated Replaced by the {@link #timeUuidToTimestamp} function
@@ -196,28 +162,6 @@ public abstract class TimeFcts
};
}
- /**
- * Creates a function that convert a value of CQL(bigint) into a <code>DATE</code>.
- * @param type the temporal type
- * @return a function that convert CQL(bigint) into a <code>DATE</code>.
- */
- public static NativeScalarFunction toDate(final LongType type)
- {
- return new NativeScalarFunction("todate", SimpleDateType.instance, type)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- ByteBuffer bb = parameters.get(0);
- if (bb == null || !bb.hasRemaining())
- return null;
-
- long millis = LongType.instance.toLong(bb);
- return SimpleDateType.instance.fromTimeInMillis(millis);
- }
- };
- }
-
-
/**
* Creates a function that convert a value of the specified type into a <code>TIMESTAMP</code>.
* @param type the temporal type
@@ -240,27 +184,6 @@ public abstract class TimeFcts
}
/**
- * Creates a function that convert a value of the specified type into a <code>TIMESTAMP</code>.
- * @param type the temporal type
- * @return a function that convert a value of the specified type into a <code>TIMESTAMP</code>.
- */
- public static NativeScalarFunction toTimestamp(final LongType type)
- {
- return new NativeScalarFunction("totimestamp", TimestampType.instance, type)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- ByteBuffer bb = parameters.get(0);
- if (bb == null || !bb.hasRemaining())
- return null;
-
- long millis = LongType.instance.toLong(bb);
- return TimestampType.instance.fromTimeInMillis(millis);
- }
- };
- }
-
- /**
* Creates a function that convert a value of the specified type into an UNIX timestamp.
* @param type the temporal type
* @return a function that convert a value of the specified type into an UNIX timestamp.
diff --git a/src/java/org/apache/cassandra/db/marshal/LongType.java b/src/java/org/apache/cassandra/db/marshal/LongType.java
index d4b1400..ad539f7 100644
--- a/src/java/org/apache/cassandra/db/marshal/LongType.java
+++ b/src/java/org/apache/cassandra/db/marshal/LongType.java
@@ -139,7 +139,7 @@ public class LongType extends NumberType<Long>
}
@Override
- public long toLong(ByteBuffer value)
+ protected long toLong(ByteBuffer value)
{
return ByteBufferUtil.toLong(value);
}
diff --git a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java
index 25fb290..b0a4bb9 100644
--- a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java
@@ -26,7 +26,6 @@ import java.util.List;
import org.junit.Test;
-import org.apache.cassandra.db.marshal.IntegerType;
import org.apache.cassandra.db.marshal.LongType;
import org.apache.cassandra.db.marshal.SimpleDateType;
import org.apache.cassandra.db.marshal.TimeUUIDType;
@@ -61,15 +60,6 @@ public class TimeFctsTest
}
@Test
- public void testMinTimeUuidFromBigInt()
- {
- long timeInMillis = DATE_TIME.toInstant().toEpochMilli();
- ByteBuffer input = LongType.instance.decompose(timeInMillis);
- ByteBuffer output = executeFunction(TimeFcts.minTimeuuidFct(LongType.instance), input);
- assertEquals(UUIDGen.minTimeUUID(timeInMillis), TimeUUIDType.instance.compose(output));
- }
-
- @Test
public void testMaxTimeUuid()
{
long timeInMillis = DATE_TIME.toInstant().toEpochMilli();
@@ -79,15 +69,6 @@ public class TimeFctsTest
}
@Test
- public void testMaxTimeUuidFromBigInt()
- {
- long timeInMillis = DATE_TIME.toInstant().toEpochMilli();
- ByteBuffer input = LongType.instance.decompose(timeInMillis);
- ByteBuffer output = executeFunction(TimeFcts.maxTimeuuidFct(LongType.instance), input);
- assertEquals(UUIDGen.maxTimeUUID(timeInMillis), TimeUUIDType.instance.compose(output));
- }
-
- @Test
public void testDateOf()
{
@@ -161,16 +142,6 @@ public class TimeFctsTest
}
@Test
- public void testBigIntegerToDate()
- {
- long millis = DATE.toInstant().toEpochMilli();
-
- ByteBuffer input = LongType.instance.decompose(millis);
- ByteBuffer output = executeFunction(toDate(LongType.instance), input);
- assertEquals(DATE.toInstant().toEpochMilli(), SimpleDateType.instance.toTimeInMillis(output));
- }
-
- @Test
public void testTimestampToDateWithEmptyInput()
{
ByteBuffer output = executeFunction(toDate(TimestampType.instance), ByteBufferUtil.EMPTY_BYTE_BUFFER);
@@ -186,16 +157,6 @@ public class TimeFctsTest
}
@Test
- public void testBigIntegerToTimestamp()
- {
- long millis = DATE_TIME.toInstant().toEpochMilli();
-
- ByteBuffer input = LongType.instance.decompose(millis);
- ByteBuffer output = executeFunction(toTimestamp(LongType.instance), input);
- assertEquals(DATE_TIME.toInstant().toEpochMilli(), LongType.instance.compose(output).longValue());
- }
-
- @Test
public void testTimestampToUnixTimestampWithEmptyInput()
{
ByteBuffer output = executeFunction(TimeFcts.toUnixTimestamp(TimestampType.instance), ByteBufferUtil.EMPTY_BYTE_BUFFER);
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
index 40ab479..0f1f8f0 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
@@ -64,7 +64,7 @@ public class TimeuuidTest extends CQLTester
row(new Date(timestamp), timestamp));
}
- assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > maxTimeuuid(1564830182000) AND t < minTimeuuid('2012-11-07 18:18:22-0800')"));
+ assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > maxTimeuuid(1234567) AND t < minTimeuuid('2012-11-07 18:18:22-0800')"));
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org