[
https://issues.apache.org/jira/browse/PHOENIX-6429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17309824#comment-17309824
]
ASF GitHub Bot commented on PHOENIX-6429:
-----------------------------------------
ChinmaySKulkarni commented on a change in pull request #1185:
URL: https://github.com/apache/phoenix/pull/1185#discussion_r602636895
##########
File path:
phoenix-pherf/src/main/java/org/apache/phoenix/pherf/rules/SequentialDateDataGenerator.java
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.phoenix.pherf.rules;
+
+import com.google.common.base.Preconditions;
+import org.apache.phoenix.pherf.configuration.Column;
+import org.apache.phoenix.pherf.configuration.DataSequence;
+import org.apache.phoenix.pherf.configuration.DataTypeMapping;
+
+import org.joda.time.LocalDateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class SequentialDateDataGenerator implements RuleBasedDataGenerator {
+ private static DateTimeFormatter FMT =
DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
+ private final Column columnRule;
+ private final AtomicInteger counter;
+ private final LocalDateTime startDateTime = new LocalDateTime();
+
+ public SequentialDateDataGenerator(Column columnRule) {
+ Preconditions.checkArgument(columnRule.getDataSequence() ==
DataSequence.SEQUENTIAL);
+ Preconditions.checkArgument(isDateType(columnRule.getType()));
+ this.columnRule = columnRule;
+ counter = new AtomicInteger(0);
+ }
+
+ /**
+ * Note that this method rolls over for attempts to get larger than
maxValue
+ * @return new DataValue
+ */
+ @Override
+ public DataValue getDataValue() {
+ LocalDateTime newDateTime =
startDateTime.plusSeconds(counter.getAndIncrement());
Review comment:
since we are using an AtomicInteger for counter, looks like we will be
accessing this concurrently. In that case, we should probably also ensure
atomic updates to `startDateTime` right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Add support for global connections and sequential data generators
> -----------------------------------------------------------------
>
> Key: PHOENIX-6429
> URL: https://issues.apache.org/jira/browse/PHOENIX-6429
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Jacob Isaac
> Priority: Major
>
> We may at times want to upsert or query using global connections.
> Also add additional sequential data generators in addition to INTEGER and
> VARCHAR data types.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)