本文整理汇总了Java中org.apache.hadoop.io.BooleanWritable.get方法的典型用法代码示例。如果您正苦于以下问题:Java BooleanWritable.get方法的具体用法?Java BooleanWritable.get怎么用?Java BooleanWritable.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.io.BooleanWritable
的用法示例。
在下文中一共展示了BooleanWritable.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseBooleanColumn
import org.apache.hadoop.io.BooleanWritable; //导入方法依赖的package包/类
private void parseBooleanColumn(int column)
{
// don't include column number in message because it causes boxing which is expensive here
checkArgument(!isPartitionColumn[column], "Column is a partition key");
loaded[column] = true;
Object object = getMaterializedValue(column);
if (object == null) {
nulls[column] = true;
}
else {
nulls[column] = false;
BooleanWritable booleanWritable = checkWritable(object, BooleanWritable.class);
booleans[column] = booleanWritable.get();
}
}
示例2: reduce
import org.apache.hadoop.io.BooleanWritable; //导入方法依赖的package包/类
/***
* reduce function estimates the value of PI.
*/
@Override
protected void reduce(Text key, Iterable<BooleanWritable> values,
Context context) throws IOException, InterruptedException {
if(key.toString().equalsIgnoreCase("monte-carlo")){
MonteCarloReducer.TOTAL_NO_POINTS = MonteCarloReducer.TOTAL_NO_POINTS + 1;
for(BooleanWritable value : values){
if(value.get()){
MonteCarloReducer.TOTAL_POINTS_INSIDE_CIRCLE = MonteCarloReducer.TOTAL_POINTS_INSIDE_CIRCLE + 1;
}
}
}
//Estimate the value of PI and write it to the output file.
float pi = 4*(TOTAL_POINTS_INSIDE_CIRCLE/TOTAL_NO_POINTS);
context.write(new Text("Value of PI:"), new DoubleWritable(pi));
}
示例3: reduce
import org.apache.hadoop.io.BooleanWritable; //导入方法依赖的package包/类
@Override
protected void reduce(BytesWritable wordtimeb, Iterable<BooleanWritable> wordBools, Reducer<BytesWritable,BooleanWritable,LongWritable,BytesWritable>.Context context) throws IOException ,InterruptedException {
ReadWritableStringLong wordtime = IOUtils.deserialize(wordtimeb.getBytes(), ReadWritableStringLong.class);
long time = wordtime.secondObject();
boolean seenInPresent = false;
boolean seenInPast = false;
for (BooleanWritable isfrompast: wordBools) {
boolean frompast = isfrompast.get();
seenInPresent |= !frompast;
seenInPast |= frompast;
if(seenInPast && seenInPresent){
// then we've seen all the ones from this time if we were to see them, so we can break early. MASSIVE SAVINGS HERE
break;
}
}
ReadWritableBooleanBoolean intersectionUnion = new ReadWritableBooleanBoolean(seenInPast && seenInPresent,seenInPast || seenInPresent);
context.write(new LongWritable(time), new BytesWritable(IOUtils.serialize(intersectionUnion)));
}
示例4: reduce
import org.apache.hadoop.io.BooleanWritable; //导入方法依赖的package包/类
/**
* Accumulate number of points inside/outside results from the mappers.
* @param isInside Is the points inside?
* @param values An iterator to a list of point counts
* @param output dummy, not used here.
* @param reporter
*/
public void reduce(BooleanWritable isInside,
Iterator<LongWritable> values,
Context context) throws IOException {
if (isInside.get()) {
for(; values.hasNext(); numInside += values.next().get());
} else {
for(; values.hasNext(); numOutside += values.next().get());
}
}
示例5: getConstBoolean
import org.apache.hadoop.io.BooleanWritable; //导入方法依赖的package包/类
public static boolean getConstBoolean(@Nonnull final ObjectInspector oi)
throws UDFArgumentException {
if (!isBooleanOI(oi)) {
throw new UDFArgumentException("argument must be a Boolean value: "
+ TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
}
BooleanWritable v = getConstValue(oi);
return v.get();
}
示例6: reduce
import org.apache.hadoop.io.BooleanWritable; //导入方法依赖的package包/类
/**
* Accumulate number of points inside/outside results from the mappers.
* @param isInside Is the points inside?
* @param values An iterator to a list of point counts
* @param output dummy, not used here.
* @param reporter
*/
public void reduce(BooleanWritable isInside,
Iterator<LongWritable> values,
OutputCollector<WritableComparable<?>, Writable> output,
Reporter reporter) throws IOException {
if (isInside.get()) {
for(; values.hasNext(); numInside += values.next().get());
} else {
for(; values.hasNext(); numOutside += values.next().get());
}
}
示例7: readBoolean
import org.apache.hadoop.io.BooleanWritable; //导入方法依赖的package包/类
/** read the boolean value */
static boolean readBoolean(DataInput in) throws IOException {
BooleanWritable uBoolean = TL_DATA.get().U_BOOLEAN;
uBoolean.readFields(in);
return uBoolean.get();
}