本文整理汇总了Java中nl.vu.cs.ajira.data.types.TupleFactory.newTuple方法的典型用法代码示例。如果您正苦于以下问题:Java TupleFactory.newTuple方法的具体用法?Java TupleFactory.newTuple怎么用?Java TupleFactory.newTuple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.vu.cs.ajira.data.types.TupleFactory
的用法示例。
在下文中一共展示了TupleFactory.newTuple方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Tuples
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
public Tuples(List<Tuple> tuples, int tuplesLength, List<Integer> steps) {
this.tuplesLength = tuplesLength;
rows = new ArrayList<Row>();
for (int i = 0; i < tuples.size(); ++i) {
Tuple t = tuples.get(i);
TLong[] signature = new TLong[tuplesLength];
for (int j = 0; j < tuplesLength; ++j) {
signature[j] = new TLong();
}
Tuple resultTuple = TupleFactory.newTuple(signature);
for (int j = 0; j < tuplesLength; j++) {
SimpleData data = t.get(j);
resultTuple.set(data, j);
}
int step = steps.get(i);
rows.add(new Row(step, resultTuple));
}
}
示例2: startProcess
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
@Override
public void startProcess(ActionContext context) throws Exception {
tl1 = new TLong();
tl2 = new TLong();
tl3 = new TLong();
step = new TInt();
count = new TInt();
previousTuple = TupleFactory.newTuple(tl1, tl2, tl3);
outputTuple = new SimpleData[5];
for (int i = 0; i < 3; ++i) {
outputTuple[i] = previousTuple.get(i);
}
outputTuple[3] = step;
outputTuple[4] = count;
currentCount = 0;
minStep = Integer.MAX_VALUE;
stepToCount = getParamInt(I_MIN_STEP);
}
示例3: WritableTuple
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
/**
* Copying constructor.
*/
public WritableTuple(WritableTuple w) {
shouldSort = w.shouldSort;
fieldsToSort = w.fieldsToSort;
otherFields = w.otherFields;
nFields = w.nFields;
tuple = TupleFactory.newTuple();
if (w.lengths != null) {
lengths = new int[w.lengths.length];
}
}
示例4: getSpot
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
private synchronized void getSpot() {
while (bufferFull()) {
try {
wait();
} catch (InterruptedException e) {
// ignore
}
}
if (head == tail) {
notify();
}
if (data[tail] == null) {
data[tail] = TupleFactory.newTuple();
}
}
示例5: emitCurrentWindowCounts
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
private final void emitCurrentWindowCounts(ActionOutput output)
throws Exception {
lastModifiedTracker.markAsModified();
Map<String, Long> counts = counter.getCountsThenAdvanceWindow();
for (Entry<String, Long> entry : counts.entrySet()) {
String str = entry.getKey();
Long count = entry.getValue();
Tuple tuple = TupleFactory.newTuple(new TString(str), new TLong(
count));
output.output(tuple);
}
}
示例6: StreamTuple
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
public StreamTuple(LinkedHashMap<String, SimpleData> attributes) {
int numElements = attributes.size() * 2;
SimpleData[] data = new SimpleData[numElements];
int pos = 0;
for (String name : attributes.keySet()) {
data[pos++] = new TString(name);
data[pos++] = attributes.get(name);
}
tuple = TupleFactory.newTuple(data);
this.attributes = attributes;
}
示例7: getTuple
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
public static final Tuple getTuple(byte[] bytes) {
int pos = 0;
int numElements = bytes[pos++];
SimpleData[] data = new SimpleData[numElements];
for (int i = 0; i < numElements; i++) {
byte type = bytes[pos++];
switch (type) {
case INT:
data[i] = getInt(bytes, pos);
pos += 4;
break;
case LONG:
data[i] = getLong(bytes, pos);
pos += 8;
break;
case STRING:
int stringLen = bytes[pos++];
data[i] = getString(bytes, pos, stringLen);
pos += stringLen;
break;
case BOOLEAN:
data[i] = getBoolean(bytes, pos);
pos++;
break;
}
}
return TupleFactory.newTuple(data);
}
示例8: generateOutput
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
private Tuple generateOutput(StatQueue queue) {
if (queue.isEmpty()) {
return null;
}
StreamTuple tupleToCopy = queue.peek();
int pos = 0;
Tuple t = tupleToCopy.getTuple();
template[pos++] = t.get(aggregatePosition);
template[pos++] = queue.getAggrValue();
for (Integer i : attributesPositions) {
template[pos++] = t.get(i);
template[pos++] = t.get(i + 1);
}
return TupleFactory.newTuple(template);
}
示例9: process
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
@Override
public void process(Tuple tuple, ActionContext context, ActionOutput actionOutput) throws Exception {
Tuple tupleCopy = TupleFactory.newTuple();
tuple.copyTo(tupleCopy);
inMemorySet.add(tupleCopy);
actionOutput.output(tuple);
}
示例10: processSplit
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
private void processSplit(ActionContext context, ActionOutput output)
throws Exception {
if (baseSplit == null) {
synchronized(this.getClass()) {
baseSplit = "split" + splitCounter++ + "-";
}
}
String key = baseSplit + splitId++;
context.putObjectInCache(key, currentFileSplit);
Tuple tuple = TupleFactory.newTuple();
if (customReader == null) {
tuple.set(new TInt(FileLayer.OP_READ), new TString(key), new TInt(
context.getMyNodeId()));
} else {
tuple.set(new TInt(FileLayer.OP_READ), new TString(key), new TInt(
context.getMyNodeId()), new TString(customReader));
}
ActionConf c = ActionFactory.getActionConf(QueryInputLayer.class);
c.setParamString(QueryInputLayer.S_INPUTLAYER,
FileLayer.class.getName());
c.setParamWritable(QueryInputLayer.W_QUERY, new Query(tuple));
output.branch(new ActionSequence(c));
currentFileSplit = new FileCollection();
}
示例11: startProcess
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
@Override
public void startProcess(ActionContext context) throws Exception {
currentDelta = new TupleSetImpl();
currentTuple = TupleFactory.newTuple(new TLong(), new TLong(),
new TLong());
firstIteration = getParamBoolean(B_FIRST_ITERATION);
countingAlgo = getParamBoolean(B_IS_COUNTING);
}
示例12: process
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
@Override
public void process(Tuple tuple, ActionContext context,
ActionOutput actionOutput) throws Exception {
if (!firstIteration) {
TupleSet completeDelta = (TupleSet) context
.getObjectFromCache(Consts.COMPLETE_DELTA_KEY);
tuple.copyTo(currentTuple);
if (!countingAlgo) {
if (completeDelta.add(currentTuple)) {
currentDelta.add(currentTuple);
currentTuple = TupleFactory.newTuple();
}
} else {
if (log.isDebugEnabled()) {
log.debug("Processing tuple " + tuple);
}
if (!completeDelta.contains(tuple)) {
if (log.isDebugEnabled()) {
log.debug("Not in completeDelta");
}
if (log.isDebugEnabled()) {
log.debug("Current count is "
+ ReasoningContext.getInstance().getDBHandler()
.getCount(context, currentTuple));
}
if (ReasoningContext
.getInstance()
.getDBHandler()
.decreaseAndRemoveTriple(context, currentTuple, 1 /* FIXME */)) {
if (log.isDebugEnabled()) {
log.debug("Removed from database!");
}
currentDelta.add(currentTuple);
completeDelta.add(currentTuple);
currentTuple = TupleFactory.newTuple();
}
}
}
}
}
示例13: startProcess
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
@Override
public void startProcess(ActionContext context) throws Exception {
step = getParamInt(I_STEP);
firstIteration = getParamBoolean(B_FIRST_ITERATION);
currentDelta = new TupleSetImpl();
currentTuple = TupleFactory.newTuple(new TLong(), new TLong(),
new TLong(), new TInt());
}
示例14: getFlaggedTuples
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
private Tuples getFlaggedTuples(Pattern p, ActionContext context) {
TupleSet inMemorySet = (TupleSet) context
.getObjectFromCache(Consts.CURRENT_DELTA_KEY);
if (inMemorySet == null) {
return null;
}
Set<Tuple> result = null;
try {
result = inMemorySet.getSubset(p);
} catch (Exception e) {
log.error("Error", e);
}
// Determine position of variables
int[] pos_vars = p.getPositionVariables();
List<Tuple> resultList = new ArrayList<Tuple>();
List<Integer> steps = new ArrayList<Integer>();
for (Tuple t : result) {
SimpleData[] data = new SimpleData[pos_vars.length];
for (int i = 0; i < pos_vars.length; ++i) {
data[i] = t.get(pos_vars[i]);
}
Tuple resultTuple = TupleFactory.newTuple(data);
resultList.add(resultTuple);
steps.add(Integer.MAX_VALUE);
}
return new Tuples(resultList, pos_vars.length, steps);
}
示例15: generateTuple
import nl.vu.cs.ajira.data.types.TupleFactory; //导入方法依赖的package包/类
private final Tuple generateTuple() {
String phraseString = phrases.get(r.nextInt(phrases.size()));
TString word = new TString(phraseString);
return TupleFactory.newTuple(word);
}