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


Java TString类代码示例

本文整理汇总了Java中nl.vu.cs.ajira.data.types.TString的典型用法代码示例。如果您正苦于以下问题:Java TString类的具体用法?Java TString怎么用?Java TString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: isSatisfiedBy

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
public boolean isSatisfiedBy(StreamTuple tuple) {
  SimpleData tupleSimpleDataValue = tuple.getValueFor(name);
  if (tupleSimpleDataValue == null) return false;
  switch (type) {
  case NUMERIC:
    long tupleNumVal = 0;
    if (tupleSimpleDataValue instanceof TInt) {
      tupleNumVal = ((TInt) tupleSimpleDataValue).getValue();
    } else if (tupleSimpleDataValue instanceof TLong) {
      tupleNumVal = ((TLong) tupleSimpleDataValue).getValue();
    } else {
      return false;
    }
    return (op == Op.EQ && tupleNumVal == numericVal) || (op == Op.GT && tupleNumVal > numericVal) || (op == Op.LT && tupleNumVal < numericVal) || (op == Op.DF && tupleNumVal != numericVal);
  case STRING:
    if (!(tupleSimpleDataValue instanceof TString)) return false;
    String tupleStringVal = ((TString) tupleSimpleDataValue).getValue();
    return (op == Op.EQ && tupleStringVal.equals(stringValue)) || (op == Op.PF && tupleStringVal.startsWith(stringValue)) || (op == Op.IN && tupleStringVal.contains(stringValue)) || (op == Op.DF && !tupleStringVal.equals(stringValue));
  }
  return false;
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:22,代码来源:Constraint.java

示例2: getSize

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
private static final int getSize(Tuple tuple) {
  int count = 1; // One byte for the number of elements
  for (int i = 0; i < tuple.getNElements(); i++) {
    SimpleData val = tuple.get(i);
    if (val instanceof TString) {
      count += getSize((TString) val);
    } else if (val instanceof TInt) {
      count += getSize((TInt) val);
    } else if (val instanceof TLong) {
      count += getSize((TLong) val);
    } else if (val instanceof TBoolean) {
      count += getSize((TBoolean) val);
    }
  }
  return count;
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:17,代码来源:TupleSerializer.java

示例3: encodeTuple

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
public static final byte[] encodeTuple(Tuple tuple) {
  int size = getSize(tuple);
  int numElements = tuple.getNElements();
  int start = 0;
  byte[] bytes = new byte[size];
  bytes[start++] = (byte) numElements;
  for (int i = 0; i < numElements; i++) {
    SimpleData val = tuple.get(i);
    if (val instanceof TInt) {
      start = encodeInt(bytes, start, (TInt) val);
    } else if (val instanceof TLong) {
      start = encodeLong(bytes, start, (TLong) val);
    } else if (val instanceof TString) {
      start = encodeString(bytes, start, (TString) val);
    } else if (val instanceof TBoolean) {
      start = encodeBoolean(bytes, start, (TBoolean) val);
    }
  }
  return bytes;
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:21,代码来源:TupleSerializer.java

示例4: isSatisfiedBy

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
boolean isSatisfiedBy(Tuple tuple) {
  if (position == -1) return false;
  SimpleData tupleSimpleDataValue = tuple.get(position);
  switch (type) {
  case NUMERIC:
    long tupleNumVal = 0;
    if (tupleSimpleDataValue instanceof TInt) {
      tupleNumVal = ((TInt) tupleSimpleDataValue).getValue();
    } else if (tupleSimpleDataValue instanceof TLong) {
      tupleNumVal = ((TLong) tupleSimpleDataValue).getValue();
    } else {
      return false;
    }
    return (op == Op.EQ && tupleNumVal == numericVal) || (op == Op.GT && tupleNumVal > numericVal) || (op == Op.LT && tupleNumVal < numericVal) || (op == Op.DF && tupleNumVal != numericVal);
  case STRING:
    if (!(tupleSimpleDataValue instanceof TString)) return false;
    String tupleStringVal = ((TString) tupleSimpleDataValue).getValue();
    return (op == Op.EQ && tupleStringVal.equals(stringValue)) || (op == Op.PF && tupleStringVal.startsWith(stringValue)) || (op == Op.IN && tupleStringVal.contains(stringValue)) || (op == Op.DF && !tupleStringVal.equals(stringValue));
  }
  return false;
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:22,代码来源:FilterHelper.java

示例5: getTuple

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
public void getTuple(Tuple tuple) {
  SimpleData[] content = new SimpleData[data.size() * 2];
  int pos = 0;
  for (String name : data.keySet()) {
    content[pos++] = new TString(name);
    NetworkTupleValue value = data.get(name);
    switch (value.getType()) {
    case STRING:
      content[pos++] = new TString(value.getStringVal());
      break;
    case INT:
      content[pos++] = new TInt(value.getIntVal());
      break;
    case LONG:
      content[pos++] = new TLong(value.getLongVal());
      break;
    case BOOLEAN:
      content[pos++] = new TBoolean(value.getBooleanVal());
      break;
    }
  }
  tuple.set(content);
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:24,代码来源:NetworkTuple.java

示例6: generateIteratorFor

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
private void generateIteratorFor(Tuple tuple) {
	int id = ((TInt) tuple.get(0)).getValue();
	int numThreads = ((TInt) tuple.get(1)).getValue();
	int numTuples = ((TInt) tuple.get(2)).getValue();
	int minValue = ((TInt) tuple.get(3)).getValue();
	int maxValue = ((TInt) tuple.get(4)).getValue();
	int seed = ((TInt) tuple.get(5)).getValue();
	List<String> attributes = new ArrayList<String>();
	for (int i = 6; i < tuple.getNElements(); i++) {
		String attr = ((TString) tuple.get(i)).getValue();
		attributes.add(attr);
	}
	Map<Integer, List<Tuple>> tupleMap = new HashMap<Integer, List<Tuple>>();
	Random r = new Random(seed);
	for (int t = 0; t < numThreads; t++) {
		List<Tuple> tupleList = generateTuples(numTuples / numThreads,
				minValue, maxValue, r, attributes);
		tupleMap.put(t, tupleList);
	}
	tuples.remove(id);
	tuples.put(id, tupleMap);
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:23,代码来源:RandomGeneratorInputLayer.java

示例7: generateTuples

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
private List<Tuple> generateTuples(int numTuples, int minValue,
		int maxValue, Random r, List<String> attributes) {
	List<Tuple> result = new ArrayList<Tuple>();
	int tupleSize = attributes.size() * 2;
	for (int i = 0; i < numTuples; i++) {
		SimpleData[] data = new SimpleData[tupleSize];
		int pos = 0;
		for (String attr : attributes) {
			data[pos++] = new TString(attr);
			data[pos++] = new TInt(minValue
					+ r.nextInt(maxValue - minValue));
		}
		result.add(TupleFactory.newTuple(data));
	}
	return result;
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:17,代码来源:RandomGeneratorInputLayer.java

示例8: setupAction

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
@Override
public void setupAction(InputQuery query, Object[] params,
		ActionController controller, ActionContext context)
		throws Exception {
	query.setInputLayer(RandomGeneratorInputLayer.class);
	String[] attributes = ((TStringArray) params[SA_ATTRIBUTES])
			.getArray();
	SimpleData[] data = new SimpleData[6 + attributes.length];
	data[0] = new TInt((Integer) params[I_ID]);
	data[1] = new TInt((Integer) params[I_NUM_THREADS]);
	data[2] = new TInt((Integer) params[I_NUM_TUPLES]);
	data[3] = new TInt((Integer) params[I_ATTR_MIN_VAL]);
	data[4] = new TInt((Integer) params[I_ATTR_MAX_VAL]);
	data[5] = new TInt((Integer) params[I_RANDOM_SEED]);
	for (int i = 0; i < attributes.length; i++) {
		data[6 + i] = new TString(attributes[i]);
	}
	Query q = new Query(data);
	query.setQuery(q);
	controller.doNotAddCurrentAction();
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:22,代码来源:RandomTupleGeneratorAction.java

示例9: startProcess

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
@Override
public void startProcess(ActionContext context) throws Exception {
	int c = (int) context.getCounter("tripleCounter") + 1;
	if (c > 0xFFFF) {
		// Takes more than 2 bytes to store. This case is not supported.
		throw new Exception("Not supported");
	}
	tripleCounter = (long) c << 48;

	commonValues = new HashMap<Long, String>();
	@SuppressWarnings("unchecked")
	Map<Long, String> popularURIs = (Map<Long, String>) context
			.getObjectFromCache("popularTextURIs");
	if (popularURIs != null) {
		commonValues.putAll(popularURIs);
	}
	commonValues.putAll(StandardTerms.getNumberToText());

	statsTriples = statsDict = 0;
	txtValue = new TString(null);
}
 
开发者ID:jrbn,项目名称:dynamite,代码行数:22,代码来源:DeconstructTriples.java

示例10: process

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
@Override
public void process(Tuple inputTuple, ActionContext context,
		ActionOutput output) throws Exception {
	// Read the triple
	triple[0] = (TString) inputTuple.get(0);
	triple[1] = (TString) inputTuple.get(1);
	triple[2] = (TString) inputTuple.get(2);

	if (!alreadyExistingValues.containsKey(triple[0].getValue())) {
		output.output(triple[0]);
	}

	if (!alreadyExistingValues.containsKey(triple[1].getValue())) {
		output.output(triple[1]);
	}

	if (!alreadyExistingValues.containsKey(triple[2].getValue())) {
		output.output(triple[2]);
	}
}
 
开发者ID:jrbn,项目名称:dynamite,代码行数:21,代码来源:DeconstructSampleTriples.java

示例11: process

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
@Override
public void process(Tuple inputTuple, ActionContext context,
		ActionOutput output) throws Exception {

	uri = (TString) inputTuple.get(0);

	if (currentURI == null || !uri.getValue().equals(currentURI)) {
		potentiallyAddPopularURI();

		// Reset counter
		counter = 0;
		currentURI = uri.getValue();
	}

	// Count the popular URIs
	counter++;
}
 
开发者ID:jrbn,项目名称:dynamite,代码行数:18,代码来源:ProcessCommonURIs.java

示例12: process

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
@Override
public void process(Tuple inputTuple, ActionContext context,
		ActionOutput output) throws Exception {
	// Read the triple
	triple[0] = (TString) inputTuple.get(0);
	triple[1] = (TString) inputTuple.get(1);
	triple[2] = (TString) inputTuple.get(2);

	tripleId.setValue(counter);
	counter += incr;

	processString(triple[0].getValue());
	position.setValue(1);
	output.output(tuple);

	processString(triple[1].getValue());
	position.setValue(2);
	output.output(tuple);

	processString(triple[2].getValue());
	position.setValue(3);
	output.output(tuple);
}
 
开发者ID:jrbn,项目名称:dynamite,代码行数:24,代码来源:DeconstructTriples.java

示例13: getLocations

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
/**
 * Depending on the first value of the tuple it returns the ChainLocation of
 * this node or a new ChainLocation whose id is formed from a substring of
 * the second value of the tuple.
 */
@Override
public Location getLocations(Tuple tuple, ActionContext context) {
	if (((TInt) tuple.get(0)).getValue() == OP_LS) {
		return Location.THIS_NODE;
	} else {
		String s = ((TString) tuple.get(1)).getValue();
		int index = Integer.valueOf(s.substring(s.indexOf('-') + 1));
		return new Location(index % numberNodes);
	}
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:16,代码来源:FileLayer.java

示例14: process

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
@Override
public void process(Tuple tuple, ActionContext context,
		ActionOutput actionOutput) throws Exception {
	String line = ((TString) tuple.get(0)).getValue();
	double[] vector = parseVector(line);
	array.setArray(vector);
	actionOutput.output(array);
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:9,代码来源:KMeans.java

示例15: process

import nl.vu.cs.ajira.data.types.TString; //导入依赖的package包/类
@Override
public void process(Tuple tuple, ActionContext context,
		ActionOutput actionOutput) throws Exception {
	TString iText = (TString) tuple.get(0);
	String sText = iText.getValue();
	if (sText != null && sText.length() > 0) {
		String[] words = sText.split("\\s+");
		for (String word : words) {
			if (word.length() > 0) {
				TString oWord = new TString(word);
				actionOutput.output(oWord, new TInt(1));
			}
		}
	}
}
 
开发者ID:jrbn,项目名称:ajira,代码行数:16,代码来源:WordCount.java


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