This is an automated email from the ASF dual-hosted git repository.
ilyak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 72eecac IGNITE-12233 Added IgniteSqlInsertIndexed* and
IgniteSqlUpdateFiltered benchmarks - Fixes #6913.
72eecac is described below
commit 72eecac6989c005dc986dacd45e72943df3962a4
Author: Ilya Sunstsov <[email protected]>
AuthorDate: Thu Oct 10 16:25:05 2019 +0300
IGNITE-12233 Added IgniteSqlInsertIndexed* and IgniteSqlUpdateFiltered
benchmarks - Fixes #6913.
Signed-off-by: Ilya Kasnacheev <[email protected]>
---
.../dml/IgniteSqlInsertIndexedValue1Benchmark.java | 47 ++++++++++++
.../dml/IgniteSqlInsertIndexedValue2Benchmark.java | 47 ++++++++++++
.../dml/IgniteSqlInsertIndexedValue8Benchmark.java | 48 ++++++++++++
.../dml/IgniteSqlUpdateFilteredBenchmark.java | 89 ++++++++++++++++++++++
4 files changed, 231 insertions(+)
diff --git
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue1Benchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue1Benchmark.java
new file mode 100644
index 0000000..6caa76a
--- /dev/null
+++
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue1Benchmark.java
@@ -0,0 +1,47 @@
+/*
+ * 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.ignite.yardstick.cache.dml;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.yardstick.cache.IgniteCacheAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs SQL INSERT operations for entity with 1
indexed field.
+ */
+public class IgniteSqlInsertIndexedValue1Benchmark extends
IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** */
+ private final AtomicInteger insCnt = new AtomicInteger();
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ int key = insCnt.getAndIncrement();
+
+ cache.query(new SqlFieldsQuery("insert into Person1(_key, val1) values
(?, ?)")
+ .setArgs(key, key));
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("atomic-index-with-eviction");
+ }
+}
diff --git
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue2Benchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue2Benchmark.java
new file mode 100644
index 0000000..139dad1
--- /dev/null
+++
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue2Benchmark.java
@@ -0,0 +1,47 @@
+/*
+ * 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.ignite.yardstick.cache.dml;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.yardstick.cache.IgniteCacheAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs SQL INSERT operations for entity with 2
indexed fields.
+ */
+public class IgniteSqlInsertIndexedValue2Benchmark extends
IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** */
+ private final AtomicInteger insCnt = new AtomicInteger();
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ int key = insCnt.getAndIncrement();
+
+ cache.query(new SqlFieldsQuery("insert into Person2(_key, val1, val2)
values (?, ?, ?)")
+ .setArgs(key, key, key+1));
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("atomic-index-with-eviction");
+ }
+}
diff --git
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue8Benchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue8Benchmark.java
new file mode 100644
index 0000000..da80a1a
--- /dev/null
+++
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlInsertIndexedValue8Benchmark.java
@@ -0,0 +1,48 @@
+/*
+ * 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.ignite.yardstick.cache.dml;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.yardstick.cache.IgniteCacheAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs SQL INSERT operations for entity with 8
indexed fields.
+ */
+public class IgniteSqlInsertIndexedValue8Benchmark extends
IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** */
+ private final AtomicInteger insCnt = new AtomicInteger();
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ int key = insCnt.incrementAndGet();
+
+ cache.query(new SqlFieldsQuery("insert into Person8(_key, val1, val2,
val3, val4, val5, val6, val7, val8) " +
+ "values (?, ?, ?, ?, ?, ?, ?, ?, ?)")
+ .setArgs(key, key, key+1, key+2, key+3, key+4, key+5, key+6,
key+7));
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("atomic-index-with-eviction");
+ }
+}
diff --git
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlUpdateFilteredBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlUpdateFilteredBenchmark.java
new file mode 100644
index 0000000..4098122
--- /dev/null
+++
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/dml/IgniteSqlUpdateFilteredBenchmark.java
@@ -0,0 +1,89 @@
+/*
+ * 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.ignite.yardstick.cache.dml;
+
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.yardstick.cache.IgniteCacheAbstractBenchmark;
+import org.apache.ignite.yardstick.cache.model.Person;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Ignite benchmark that performs put and SQL UPDATE operations.
+ */
+public class IgniteSqlUpdateFilteredBenchmark extends
IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** */
+ private AtomicInteger putCnt = new AtomicInteger();
+
+ /** */
+ private AtomicInteger updCnt = new AtomicInteger();
+
+ /** */
+ private AtomicLong updItemsCnt = new AtomicLong();
+
+ /** {@inheritDoc} */
+ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ if (rnd.nextBoolean()) {
+ double salary = rnd.nextDouble() * args.range() * 1000;
+
+ double maxSalary = salary + 1000;
+
+ Long res = (Long)cache().query(new SqlFieldsQuery("update Person
set salary = (salary - ?1 + ?2) / 2 " +
+ "where salary >= ?1 and salary <= ?2").setArgs(salary,
maxSalary)).getAll().get(0).get(0);
+
+ updItemsCnt.getAndAdd(res);
+
+ updCnt.getAndIncrement();
+ }
+ else {
+ int i = rnd.nextInt(args.range());
+
+ cache.put(i, new Person(i, "firstName" + i, "lastName" + i, i *
1000));
+
+ putCnt.getAndIncrement();
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("query");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void tearDown() throws Exception {
+ println(cfg, "Finished SQL UPDATE query benchmark [putCnt=" +
putCnt.get() + ", updCnt=" + updCnt.get() +
+ ", updItemsCnt=" + updItemsCnt.get() + ']');
+
+ super.tearDown();
+ }
+}