本文整理汇总了Java中org.apache.mahout.math.list.IntArrayList.add方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList.add方法的具体用法?Java IntArrayList.add怎么用?Java IntArrayList.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mahout.math.list.IntArrayList
的用法示例。
在下文中一共展示了IntArrayList.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map
import org.apache.mahout.math.list.IntArrayList; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void map(LongWritable key, Text value, Mapper.Context context) throws IOException, InterruptedException {
int sid = 0;
for (String sentence : value.toString().split("\n")) {
// do nothing, if maximum number of documents has been seen
if (--maxdocs < 0) {
return;
}
IntArrayList tids = new IntArrayList();
for (String term : sentence.split("\\s+")) {
tids.add(termTIdMap.get(term));
}
long did = key.hashCode() * 10000L + (long) sid++;
outKey.set(did);
outValue.setContents(tids.toArray(new int[0]));
context.write(outKey, outValue);
}
}
示例2: readFields
import org.apache.mahout.math.list.IntArrayList; //导入方法依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
int len = in.readInt();
tuple = new IntArrayList(len);
IntWritable value = new IntWritable();
for (int i = 0; i < len; i++) {
value.readFields(in);
tuple.add(value.get());
}
}
示例3: map
import org.apache.mahout.math.list.IntArrayList; //导入方法依赖的package包/类
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String[] items = value.toString().split(itemSeparator);
IntArrayList itemIds = new IntArrayList();
String sequenceId = items[0];
long id = 0;
try {
id = Long.parseLong(sequenceId);
} catch (NumberFormatException e) {
// if this is not a number, hash it
id = sequenceId.hashCode();
}
// ignore pos 0 which contains a sequence identifier
for (int i = 1; i < items.length; i++) {
// System.out.println(itemTIdMap.get(items[i]));
itemIds.add(itemTIdMap.get(items[i]));
}
if (itemIds.size() > 0) {
outKey.set(id);
outValue.setContents(itemIds.toArray(new int[0]));
// System.out.println(itemIds.toString());
context.write(outKey, outValue);
}
}
示例4: getGroupMembers
import org.apache.mahout.math.list.IntArrayList; //导入方法依赖的package包/类
public static IntArrayList getGroupMembers(int groupId, int maxPerGroup,
int numFeatures) {
IntArrayList ret = new IntArrayList();
int start = groupId * maxPerGroup;
int end = start + maxPerGroup;
if (end > numFeatures) {
end = numFeatures;
}
for (int i = start; i < end; i++) {
ret.add(i);
}
return ret;
}
示例5: map
import org.apache.mahout.math.list.IntArrayList; //导入方法依赖的package包/类
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String[] terms = value.toString().split(itemSeparator);
IntArrayList tids = new IntArrayList();
for (int i = 1; i < terms.length; ++i) {
tids.add(termTIdMap.get(terms[i]));
}
if (tids.size() > 0) {
outValue.setContents(tids.toArray(new int[0]));
context.write(outKey, outValue);
}
}