Java Code Examples for org.apache.hadoop.io.VLongWritable

The following examples show how to use org.apache.hadoop.io.VLongWritable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: datawave   Source File: IndexInfo.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
    VLongWritable count = new VLongWritable();
    count.readFields(in);
    this.count = count.get();
    
    VIntWritable nUidsReader = new VIntWritable();
    nUidsReader.readFields(in);
    final int nUids = nUidsReader.get();
    
    ImmutableSortedSet.Builder<IndexMatch> setBuilder = ImmutableSortedSet.naturalOrder();
    
    for (int i = 0; i < nUids; ++i) {
        IndexMatch index = new IndexMatch();
        index.readFields(in);
        setBuilder.add(index);
    }
    this.uids = setBuilder.build();
}
 
Example 2
Source Project: datawave   Source File: FileLatency.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
    areDurationsReady = false;
    fileName = in.readUTF();
    VLongWritable eventCount = new VLongWritable();
    eventCount.readFields(in);
    this.eventCount = eventCount.get();
    ArrayWritable phases = new ArrayWritable(Phase.class);
    phases.readFields(in);
    this.phases = makeList(phases.get());
}
 
Example 3
Source Project: datawave   Source File: Phase.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    out.writeUTF(name);
    VLongWritable vlaw = new VLongWritable();
    vlaw.set(start);
    vlaw.write(out);
    vlaw.set(end);
    vlaw.write(out);
}
 
Example 4
Source Project: datawave   Source File: Phase.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
    name = in.readUTF();
    VLongWritable vlaw = new VLongWritable();
    vlaw.readFields(in);
    start = vlaw.get();
    vlaw.readFields(in);
    end = vlaw.get();
}
 
Example 5
Source Project: datawave   Source File: DiscoveredThing.java    License: Apache License 2.0 5 votes vote down vote up
public DiscoveredThing(String term, String field, String type, String date, String columnVisibility, long count, MapWritable countsByColumnVisibility) {
    this.term = term;
    this.field = field;
    this.type = type;
    this.date = date;
    this.columnVisibility = columnVisibility;
    this.count = new VLongWritable(count);
    this.countsByColumnVisibility = countsByColumnVisibility;
}
 
Example 6
Source Project: datawave   Source File: IndexInfo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    new VLongWritable(count).write(out);
    new VIntWritable(uids.size()).write(out);
    for (IndexMatch uid : uids)
        uid.write(out);
}
 
Example 7
Source Project: datawave   Source File: StatsCounters.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a shard stats for a field name/datatype pair.
 *
 * @param sumCount
 *            total number of values
 * @param unique
 *            total number of unique values
 */
StatsCounters(long sumCount, long unique) {
    this.count = new VLongWritable(sumCount);
    int selVal;
    // hyperlog unique count could be greater than total count
    if (unique < sumCount) {
        this.uniqueCount = new VLongWritable(unique);
        selVal = (int) ((float) unique / (float) sumCount * SELECTIVITY_MULTIPLIER);
    } else {
        // use total count if unique is > total
        this.uniqueCount = new VLongWritable(sumCount);
        selVal = SELECTIVITY_MULTIPLIER;
    }
    this.selectivity = new VIntWritable(selVal);
}
 
Example 8
Source Project: hadoop   Source File: TypedBytesWritableOutput.java    License: Apache License 2.0 5 votes vote down vote up
public void write(Writable w) throws IOException {
  if (w instanceof TypedBytesWritable) {
    writeTypedBytes((TypedBytesWritable) w);
  } else if (w instanceof BytesWritable) {
    writeBytes((BytesWritable) w);
  } else if (w instanceof ByteWritable) {
    writeByte((ByteWritable) w);
  } else if (w instanceof BooleanWritable) {
    writeBoolean((BooleanWritable) w);
  } else if (w instanceof IntWritable) {
    writeInt((IntWritable) w);
  } else if (w instanceof VIntWritable) {
    writeVInt((VIntWritable) w);
  } else if (w instanceof LongWritable) {
    writeLong((LongWritable) w);
  } else if (w instanceof VLongWritable) {
    writeVLong((VLongWritable) w);
  } else if (w instanceof FloatWritable) {
    writeFloat((FloatWritable) w);
  } else if (w instanceof DoubleWritable) {
    writeDouble((DoubleWritable) w);
  } else if (w instanceof Text) {
    writeText((Text) w);
  } else if (w instanceof ArrayWritable) {
    writeArray((ArrayWritable) w);
  } else if (w instanceof MapWritable) {
    writeMap((MapWritable) w);
  } else if (w instanceof SortedMapWritable) {
    writeSortedMap((SortedMapWritable) w);
  } else if (w instanceof Record) {
    writeRecord((Record) w);
  } else {
    writeWritable(w); // last resort
  }
}
 
Example 9
Source Project: hadoop   Source File: TypedBytesWritableInput.java    License: Apache License 2.0 5 votes vote down vote up
public Class<? extends Writable> readType() throws IOException {
  Type type = in.readType();
  if (type == null) {
    return null;
  }
  switch (type) {
  case BYTES:
    return BytesWritable.class;
  case BYTE:
    return ByteWritable.class;
  case BOOL:
    return BooleanWritable.class;
  case INT:
    return VIntWritable.class;
  case LONG:
    return VLongWritable.class;
  case FLOAT:
    return FloatWritable.class;
  case DOUBLE:
    return DoubleWritable.class;
  case STRING:
    return Text.class;
  case VECTOR:
    return ArrayWritable.class;
  case MAP:
    return MapWritable.class;
  case WRITABLE:
    return Writable.class;
  default:
    throw new RuntimeException("unknown type");
  }
}
 
Example 10
Source Project: marklogic-contentpump   Source File: InternalUtilities.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create new XdmValue from value type and Writables.
 *  
 */
public static XdmValue newValue(ValueType valueType, Object value) {
    if (value instanceof Text) {
        return ValueFactory.newValue(valueType, ((Text)value).toString());
    } else if (value instanceof BytesWritable) {
        return ValueFactory.newValue(valueType, ((BytesWritable)value).getBytes());
    } else if (value instanceof IntWritable) {
        return ValueFactory.newValue(valueType, ((IntWritable)value).get());
    } else if (value instanceof LongWritable) {
        return ValueFactory.newValue(valueType, ((LongWritable)value).get());
    } else if (value instanceof VIntWritable) {
        return ValueFactory.newValue(valueType, ((VIntWritable)value).get());
    } else if (value instanceof VLongWritable) {
        return ValueFactory.newValue(valueType, ((VLongWritable)value).get());
    } else if (value instanceof BooleanWritable) {
        return ValueFactory.newValue(valueType, ((BooleanWritable)value).get());
    } else if (value instanceof FloatWritable) {
        return ValueFactory.newValue(valueType, ((FloatWritable)value).get());
    } else if (value instanceof DoubleWritable) {
        return ValueFactory.newValue(valueType, ((DoubleWritable)value).get());
    } else if (value instanceof MarkLogicNode) {
        return ValueFactory.newValue(valueType, ((MarkLogicNode)value).get());
    } else {
        throw new UnsupportedOperationException("Value " +  
                value.getClass().getName() + " is unsupported.");
    }
}
 
Example 11
Source Project: big-c   Source File: TypedBytesWritableOutput.java    License: Apache License 2.0 5 votes vote down vote up
public void write(Writable w) throws IOException {
  if (w instanceof TypedBytesWritable) {
    writeTypedBytes((TypedBytesWritable) w);
  } else if (w instanceof BytesWritable) {
    writeBytes((BytesWritable) w);
  } else if (w instanceof ByteWritable) {
    writeByte((ByteWritable) w);
  } else if (w instanceof BooleanWritable) {
    writeBoolean((BooleanWritable) w);
  } else if (w instanceof IntWritable) {
    writeInt((IntWritable) w);
  } else if (w instanceof VIntWritable) {
    writeVInt((VIntWritable) w);
  } else if (w instanceof LongWritable) {
    writeLong((LongWritable) w);
  } else if (w instanceof VLongWritable) {
    writeVLong((VLongWritable) w);
  } else if (w instanceof FloatWritable) {
    writeFloat((FloatWritable) w);
  } else if (w instanceof DoubleWritable) {
    writeDouble((DoubleWritable) w);
  } else if (w instanceof Text) {
    writeText((Text) w);
  } else if (w instanceof ArrayWritable) {
    writeArray((ArrayWritable) w);
  } else if (w instanceof MapWritable) {
    writeMap((MapWritable) w);
  } else if (w instanceof SortedMapWritable) {
    writeSortedMap((SortedMapWritable) w);
  } else if (w instanceof Record) {
    writeRecord((Record) w);
  } else {
    writeWritable(w); // last resort
  }
}
 
Example 12
Source Project: big-c   Source File: TypedBytesWritableInput.java    License: Apache License 2.0 5 votes vote down vote up
public Class<? extends Writable> readType() throws IOException {
  Type type = in.readType();
  if (type == null) {
    return null;
  }
  switch (type) {
  case BYTES:
    return BytesWritable.class;
  case BYTE:
    return ByteWritable.class;
  case BOOL:
    return BooleanWritable.class;
  case INT:
    return VIntWritable.class;
  case LONG:
    return VLongWritable.class;
  case FLOAT:
    return FloatWritable.class;
  case DOUBLE:
    return DoubleWritable.class;
  case STRING:
    return Text.class;
  case VECTOR:
    return ArrayWritable.class;
  case MAP:
    return MapWritable.class;
  case WRITABLE:
    return Writable.class;
  default:
    throw new RuntimeException("unknown type");
  }
}
 
Example 13
Source Project: incubator-hivemall   Source File: WritableUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Writable toWritable(Object object) {
    if (object == null) {
        return null; //return NullWritable.get();
    }
    if (object instanceof Writable) {
        return (Writable) object;
    }
    if (object instanceof String) {
        return new Text((String) object);
    }
    if (object instanceof Long) {
        return new VLongWritable((Long) object);
    }
    if (object instanceof Integer) {
        return new VIntWritable((Integer) object);
    }
    if (object instanceof Byte) {
        return new ByteWritable((Byte) object);
    }
    if (object instanceof Double) {
        return new DoubleWritable((Double) object);
    }
    if (object instanceof Float) {
        return new FloatWritable((Float) object);
    }
    if (object instanceof Boolean) {
        return new BooleanWritable((Boolean) object);
    }
    if (object instanceof byte[]) {
        return new BytesWritable((byte[]) object);
    }
    return new BytesWritable(object.toString().getBytes());
}
 
Example 14
Source Project: datawave   Source File: FileLatency.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    out.writeUTF(getFileName());
    new VLongWritable(getEventCount()).write(out);
    makeWritable(phases, Phase.class).write(out);
}
 
Example 15
Source Project: datawave   Source File: DiscoveredThing.java    License: Apache License 2.0 4 votes vote down vote up
public DiscoveredThing() {
    count = new VLongWritable();
    countsByColumnVisibility = new MapWritable();
}
 
Example 16
Source Project: datawave   Source File: IndexStatsRecord.java    License: Apache License 2.0 4 votes vote down vote up
public IndexStatsRecord() {
    numberUnique = new VLongWritable();
    count = new VLongWritable();
    averageWordLength = new FloatWritable();
}
 
Example 17
Source Project: datawave   Source File: IndexStatsRecord.java    License: Apache License 2.0 4 votes vote down vote up
public VLongWritable getNumberOfUniqueWords() {
    return numberUnique;
}
 
Example 18
Source Project: datawave   Source File: IndexStatsRecord.java    License: Apache License 2.0 4 votes vote down vote up
public VLongWritable getWordCount() {
    return count;
}
 
Example 19
Source Project: datawave   Source File: StatsCounters.java    License: Apache License 2.0 4 votes vote down vote up
public StatsCounters() {
    this.count = new VLongWritable();
    this.uniqueCount = new VLongWritable();
    this.selectivity = new VIntWritable();
}
 
Example 20
Source Project: datawave   Source File: StatsHyperLogSummary.java    License: Apache License 2.0 4 votes vote down vote up
StatsHyperLogSummary() {
    this.count = new VLongWritable();
    this.hyperLog = new BytesWritable();
    this.uniqueCount = new VIntWritable();
}
 
Example 21
Source Project: hadoop   Source File: TypedBytesWritableOutput.java    License: Apache License 2.0 4 votes vote down vote up
public void writeVLong(VLongWritable vlw) throws IOException {
  out.writeLong(vlw.get());
}
 
Example 22
Source Project: hadoop   Source File: TypedBytesWritableInput.java    License: Apache License 2.0 4 votes vote down vote up
public VLongWritable readVLong() throws IOException {
  return readVLong(null);
}
 
Example 23
Source Project: big-c   Source File: TypedBytesWritableOutput.java    License: Apache License 2.0 4 votes vote down vote up
public void writeVLong(VLongWritable vlw) throws IOException {
  out.writeLong(vlw.get());
}
 
Example 24
Source Project: big-c   Source File: TypedBytesWritableInput.java    License: Apache License 2.0 4 votes vote down vote up
public VLongWritable readVLong() throws IOException {
  return readVLong(null);
}
 
Example 25
@Test
public void testVLong() {
    writableTypeToJson(new VLongWritable(Long.MAX_VALUE));
}
 
Example 26
Source Project: datawave   Source File: StatsHyperLogSummary.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a stats HyperLog summary object.
 * 
 * @param sumCount
 *            total number of field name/dataype pair entries
 * @param logPlus
 *            populated hyperlog object
 * @param uniqueCount
 *            actual count of unique values (debug only)
 * @throws IOException
 *             serialization error
 */
StatsHyperLogSummary(long sumCount, HyperLogLogPlus logPlus, int uniqueCount) throws IOException {
    this.count = new VLongWritable(sumCount);
    this.hyperLog = new BytesWritable(logPlus.getBytes());
    this.uniqueCount = new VIntWritable(uniqueCount);
}