当前位置: 首页>>代码示例>>Java>>正文


Java IndexType类代码示例

本文整理汇总了Java中com.aerospike.client.query.IndexType的典型用法代码示例。如果您正苦于以下问题:Java IndexType类的具体用法?Java IndexType怎么用?Java IndexType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexType类属于com.aerospike.client.query包,在下文中一共展示了IndexType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectOnIndex

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
@Test
public void selectOnIndex() throws IOException {
	IndexTask task = this.client.createIndex(null, TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, "age_index", "age", IndexType.NUMERIC);
	task.waitTillComplete(50);
	Filter filter = Filter.range("age", 28, 29);
	KeyRecordIterator it = queryEngine.select(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, filter);
	try{
		while (it.hasNext()){
			KeyRecord rec = it.next();
			int age = rec.record.getInt("age");
			Assert.assertTrue(age >= 28 && age <= 29);
		}
	} finally {
		it.close();
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:17,代码来源:SelectorTests.java

示例2: selectOnIndexWithQualifiers

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
@Test
public void selectOnIndexWithQualifiers() throws IOException {
	IndexTask task = this.client.createIndex(null, TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, "age_index_selector", "age", IndexType.NUMERIC);
	task.waitTillComplete(50);
	Filter filter = Filter.range("age", 25, 29);
	Qualifier qual1 = new Qualifier("color", Qualifier.FilterOperation.EQ, Value.get("blue"));
	KeyRecordIterator it = queryEngine.select(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, filter, qual1);
	try{
		while (it.hasNext()){
			KeyRecord rec = it.next();
			Assert.assertEquals("blue", rec.record.getString("color"));
			int age = rec.record.getInt("age");
			Assert.assertTrue(age >= 25 && age <= 29);
		}
	} finally {
		it.close();
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:19,代码来源:SelectorTests.java

示例3: selectWithQualifiersOnly

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
@Test
public void selectWithQualifiersOnly() throws IOException {
	IndexTask task = this.client.createIndex(null, TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, "age_index", "age", IndexType.NUMERIC);
	task.waitTillComplete(50);
	queryEngine.refreshCluster();
	Qualifier qual1 = new Qualifier("color", Qualifier.FilterOperation.EQ, Value.get("green"));
	Qualifier qual2 = new Qualifier("age", Qualifier.FilterOperation.BETWEEN, Value.get(28), Value.get(29));
	KeyRecordIterator it = queryEngine.select(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, null, qual1, qual2);
	try{
		while (it.hasNext()){
			KeyRecord rec = it.next();
			Assert.assertEquals("green", rec.record.getString("color"));
			int age = rec.record.getInt("age");
			Assert.assertTrue(age >= 28 && age <= 29);
		}
	} finally {
		it.close();
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:20,代码来源:SelectorTests.java

示例4: selectWithOrQualifiers

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
@Test
public void selectWithOrQualifiers() throws IOException {
	IndexTask task = this.client.createIndex(null, TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, "age_index", "age", IndexType.NUMERIC);
	task.waitTillComplete(50);
	queryEngine.refreshCluster();
	Qualifier qual1 = new Qualifier("color", Qualifier.FilterOperation.EQ, Value.get("green"));
	Qualifier qual2 = new Qualifier("age", Qualifier.FilterOperation.BETWEEN, Value.get(28), Value.get(29));
	Qualifier or = new Qualifier(Qualifier.FilterOperation.OR, qual1, qual2);
	KeyRecordIterator it = queryEngine.select(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, null, or);
	try{
		while (it.hasNext()){
			KeyRecord rec = it.next();
			int age = rec.record.getInt("age");
			Assert.assertTrue("green"==rec.record.getString("color") ||(age >= 28 && age <= 29));
		}
	} finally {
		it.close();
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:20,代码来源:SelectorTests.java

示例5: dataSetImport

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
/**
 * Imports dataset.
 *
 * @throws java.io.IOException
 */
private static void dataSetImport() throws IOException, ParseException {
    URL url = Resources.getResource(DATA_SET_NAME);
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(new FileReader(url.getFile()));
    JSONObject jsonObject = (JSONObject) obj;

    String id = (String) jsonObject.get("id");
    JSONObject metadata = (JSONObject) jsonObject.get("metadata");
    JSONArray cantos = (JSONArray) jsonObject.get("cantos");

    Key key = new Key(NAMESPACE_ENTITY, SET_NAME, id);
    Bin binId = new Bin("id", id);
    Bin binMetadata = new Bin("metadata", metadata);
    Bin binCantos = new Bin("cantos", cantos);
    aerospike.put(null, key, binId, binMetadata, binCantos);
    aerospike.createIndex(null, NAMESPACE_ENTITY, SET_NAME, "id_idx", "id", IndexType.STRING);

    Key key2 = new Key(NAMESPACE_CELL, SET_NAME, 3);
    Bin bin_id = new Bin("_id", "3");
    Bin bin_number = new Bin("number", 3);
    Bin bin_text = new Bin("message", "new message test");
    aerospike.put(null, key2, bin_id, bin_number, bin_text);
    aerospike.createIndex(null, NAMESPACE_CELL, SET_NAME, "num_idx", "number", IndexType.NUMERIC);
    aerospike.createIndex(null, NAMESPACE_CELL, SET_NAME, "_id_idx", "_id", IndexType.STRING);
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:31,代码来源:AerospikeJavaRDDFT.java

示例6: createIndexes

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
private void createIndexes()
{
  IndexTask task;
  try {
    task = client.createIndex(null, namespace, metaSet,
        "operatorIdIndex", metaTableOperatorIdColumn, IndexType.NUMERIC);
    task.waitTillComplete();
    task = client.createIndex(null, namespace, metaSet,
        "appIdIndex", metaTableAppIdColumn, IndexType.STRING);
    task.waitTillComplete();
  } catch (AerospikeException ex) {
    throw new RuntimeException(ex);
  }

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:16,代码来源:AerospikeTransactionalStore.java

示例7: createIndexes

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
private static void createIndexes(Parameters params,
								  AerospikeClient client) throws Exception {
	Policy policy = new Policy();
	policy.timeout = 0; // Do not timeout on index create.
	IndexTask task =
		client.createIndex(policy, params.namespace, params.set,
						   params.locndx, params.locbin,
						   IndexType.GEO2DSPHERE);
	task.waitTillComplete();
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:11,代码来源:Load.java

示例8: createIndex

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
private void createIndex() {
  Policy policy = new Policy();
  policy.timeout = 0; // Do not timeout on index create.
  String binName   = "Waiting";
  String indexName = "jobLocations";
  try {
    IndexTask task = database.client.createIndex(policy, database.namespace, setName, indexName, binName, IndexType.GEO2DSPHERE);
    task.waitTillComplete();
  } catch (AerospikeException e) {
    e.printStackTrace();
  }
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:13,代码来源:AerospikeJobs.java

示例9: getType

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
public IndexType getType() {
	String indexTypeString = values.get("type");
	if (indexTypeString.equalsIgnoreCase("TEXT"))
		return IndexType.STRING;
	else
		return IndexType.NUMERIC;
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:8,代码来源:Index.java

示例10: selectWithBetweenAndOrQualifiers

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
@Test
public void selectWithBetweenAndOrQualifiers() throws IOException {
	IndexTask task = this.client.createIndex(null, TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, "age_index", "age", IndexType.NUMERIC);
	task.waitTillComplete(50);
	queryEngine.refreshCluster();
	Qualifier qual1 = new Qualifier("color", Qualifier.FilterOperation.EQ, Value.get("green"));
	Qualifier qual2 = new Qualifier("age", Qualifier.FilterOperation.BETWEEN, Value.get(28), Value.get(29));
	Qualifier qual3 = new Qualifier("age", Qualifier.FilterOperation.EQ, Value.get(25));
	Qualifier qual4 = new Qualifier("name", Qualifier.FilterOperation.EQ, Value.get("name:696"));
	Qualifier or = new Qualifier(Qualifier.FilterOperation.OR, qual3, qual2, qual4);
	Qualifier or2 = new Qualifier(Qualifier.FilterOperation.OR, qual1, qual4);
	Qualifier and = new Qualifier(Qualifier.FilterOperation.AND, or, or2);
	
	KeyRecordIterator it = queryEngine.select(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, null, and);
	try{
		boolean has25=false;
		while (it.hasNext()){
			KeyRecord rec = it.next();
			int age = rec.record.getInt("age");
			if(age==25) has25=true;
			else Assert.assertTrue("green".equals(rec.record.getString("color")) && (age == 25 || (age>=28 && age<=29)));
		}
		Assert.assertTrue(has25);
	} finally {
		it.close();
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:28,代码来源:SelectorTests.java

示例11: addIndex

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
@Override
public void addIndex(Policy policy, String namespace, String set, String binName, String indexName, IndexType indexType) {
	client.getAerospikeClient().createIndex(policy, namespace, set, indexName, binName, indexType);
}
 
开发者ID:fanendra22,项目名称:spring-data-aerospike,代码行数:5,代码来源:AerospikeOperationsImpl.java

示例12: Index

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
public Index(String indexName, IndexType indexType) {
	this.indexName = indexName;
	this.indexType = indexType;
}
 
开发者ID:fanendra22,项目名称:spring-data-aerospike,代码行数:5,代码来源:EntityStructure.java

示例13: getIndexType

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
public IndexType getIndexType() {
	return indexType;
}
 
开发者ID:fanendra22,项目名称:spring-data-aerospike,代码行数:4,代码来源:EntityStructure.java

示例14: createIndex

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
/**
 * Create secondary index.
 * This asynchronous server call will return before command is complete.
 * The user can optionally wait for command completion by using the returned
 * IndexTask instance.
 * <p>
 * This method is only supported by Aerospike 3 servers.
 * 
 * @param policy				generic configuration parameters, pass in null for defaults
 * @param namespace				namespace - equivalent to database name
 * @param setName				optional set name - equivalent to database table
 * @param indexName				name of secondary index
 * @param binName				bin name that data is indexed on
 * @param indexType				type of secondary index
 * @throws AerospikeException	if index create fails
 */
public final IndexTask createIndex(
	Policy policy, 
	String namespace, 
	String setName, 
	String indexName, 
	String binName,
	IndexType indexType
) throws AerospikeException {
					
	StringBuilder sb = new StringBuilder(500);
	sb.append("sindex-create:ns=");
	sb.append(namespace);
	
	if (setName != null && setName.length() > 0) {
		sb.append(";set=");
		sb.append(setName);
	}
	
	sb.append(";indexname=");
	sb.append(indexName);
	sb.append(";numbins=1");
	sb.append(";indexdata=");
	sb.append(binName);
	sb.append(",");
	sb.append(indexType);
	sb.append(";priority=normal");

	// Send index command to one node. That node will distribute the command to other nodes.
	String response = sendInfoCommand(policy, sb.toString());
	
	if (response.equalsIgnoreCase("OK")) {
		// Return task that could optionally be polled for completion.
		return new IndexTask(cluster, namespace, indexName);
	}
	
	if (response.startsWith("FAIL:200")) {
		// Index has already been created.  Do not need to poll for completion.
		return new IndexTask();
	}
		
	throw new AerospikeException("Create index failed: " + response);
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:59,代码来源:AerospikeClient.java

示例15: runSeqInt

import com.aerospike.client.query.IndexType; //导入依赖的package包/类
public static void runSeqInt(String[] args, int argi) throws Exception {

        int offset = Integer.parseInt(args[argi++]);
        int nrecs = Integer.parseInt(args[argi++]);

        String ndxname = binName + "ndx";
        
        IndexTask task =
            client.createIndex(null, namespace, setName,
                               ndxname, binName, IndexType.NUMERIC);

        task.waitTillComplete();
        log.info("created secondary index on " + binName);

        for (long ll = offset; ll < offset + nrecs; ++ll) {

            String keystr = "key-" + ll;

            Key key = new Key(namespace, setName, keystr);
            Bin bin1 = new Bin(binName, ll);
            Bin bin2 = new Bin("bin2", "value2");

            client.put(writePolicy, key, bin1, bin2);
        }

        log.info("inserted " + nrecs + " records");
    }
 
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:28,代码来源:SampleData.java


注:本文中的com.aerospike.client.query.IndexType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。