ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ght230 <ght...@163.com>
Subject Re: How to accelerate the query speed in Partitioned Mode
Date Wed, 06 Jul 2016 09:24:59 GMT
I had tested again using "AffinityMapper".

According to the result, It seems the effect of AffinityMapper is not very
obvious.

Can you help me to confirm whether my test method is correct?

And can I observe that AffinityMapper has correctly setted from
ignitevisorcmd?

Test result as following:
**********************************************
using AffinityMapper
node(2) record number(300000)  query times(50000) TPS(10301)
node(3) record number(300000)  query times(50000) TPS(10910)
node(4) record number(300000)  query times(50000) TPS(10670)
node(5) record number(300000)  query times(50000) TPS(11518)
**********************************************
Not using AffinityMapper
node(2) record number(300000)  query times(50000) TPS(11908)
node(3) record number(300000)  query times(50000) TPS(11699)
node(4) record number(300000)  query times(50000) TPS(11893)
node(5) record number(300000)  query times(50000) TPS(11011)

The test code as following:

public class Person2 implements Serializable {

	public Object ak;

	/** Person ID (indexed). */
	@QuerySqlField(index = true)
	public Long id;

	/** Organization ID (indexed). */
	@QuerySqlField(index = true)
	public Long orgId;

	/** First name (not-indexed). */
	@QuerySqlField
	public String firstName;

	/** Last name (not indexed). */
	@QuerySqlField
	public String lastName;

	/**
	 * Default constructor.
	 */

	public Person2() {
		// No-op.
	}

	public Object getAk() {
		return ak;
	}

	public void setAk(Object ak) {
		this.ak = ak;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Person2(Object ak, Long id, Long orgId, String firstName, String
lastName) {
		super();
		this.ak = ak;
		this.id = id;
		this.orgId = orgId;
		this.firstName = firstName;
		this.lastName = lastName;
	}

	@Override
	public String toString() {
		return "Person2 [ak=" + ak + ", id=" + id + ", orgId=" + orgId + ",
firstName=" + firstName + ", lastName="
				+ lastName + "]";
	}

}

public class PersonKey {

	private Long id;
	@AffinityKeyMapped
	private Long orgId;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}

	public PersonKey(Long id, Long orgId) {
		super();
		this.id = id;
		this.orgId = orgId;
	}

}

public class Test3 {

	public static void main(String[] args) { 
		// TODO Auto-generated method stub

		String personsCache = "personsCache";

		Ignition.setClientMode(true);
		Ignite ignite = Ignition.start();

		CacheConfiguration<Object, Person2> cacheCfg = new
CacheConfiguration<Object, Person2>(personsCache);
		cacheCfg.setCacheMode(CacheMode.PARTITIONED);
		cacheCfg.setIndexedTypes(Object.class, Person2.class);

		cacheCfg.setAffinityMapper(new AffinityKeyMapper() {
			@Override
			public Object affinityKey(Object key) {
				if (key instanceof PersonKey) {
					PersonKey det = (PersonKey) key;

					return det.getOrgId();
				}
				return key;
			}

			@Override
			public void reset() {
				// TODO Auto-generated method stub

			}
		});

		IgniteCache<Object, Person2> cachePerson =
ignite.getOrCreateCache(cacheCfg);

		cachePerson.clear();

		int personId = 0;
		int size = 10000;
		int groupsize = 6;

		for (int gi = 0; gi < groupsize; gi++) {
			Long orgId = Long.valueOf(gi);
			for (int pi = gi * size; pi < (gi + 1) * size; pi++) {
				personId = pi;
				Object personKey1 = new PersonKey(Long.valueOf(personId), orgId);
				Person2 p = new Person2(personKey1, Long.valueOf(personId), orgId,
"FN123", "LN456");
				cachePerson.put(personId, p);
			}
		}

		SqlQuery sqlPer = new SqlQuery(Person2.class, "orgId=?");

		Long st = System.currentTimeMillis();
		int cnt = 0;
		Person2 rp = null;
		try (QueryCursor<Entry&lt;Object, Person2>> cursor =
cachePerson.query(sqlPer.setArgs("2"))) {

			for (Entry<Object, Person2> e : cursor) {
				rp = e.getValue();
				cnt++;
			}
			System.out.println("return rownum:=" + cnt);
		}

		cachePerson.clear();
		cachePerson.destroy();
		ignite.close();

	}

}




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-accelerate-the-query-speed-in-Partitioned-Mode-tp5826p6128.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message