Search in sources :

Example 1 with LongUpdater

use of org.apache.geode.internal.HeapDataOutputStream.LongUpdater in project geode by apache.

the class NWayMergeResults method toData.

// TODO : optimize for struct elements , by directly writing the fields
// instead
// of struct
@Override
public void toData(DataOutput out) throws IOException {
    boolean isStruct = this.collectionType.getElementType().isStructType();
    DataSerializer.writeObject(this.collectionType.getElementType(), out);
    DataSerializer.writePrimitiveBoolean(this.isDistinct, out);
    HeapDataOutputStream hdos = new HeapDataOutputStream(1024, null);
    LongUpdater lu = hdos.reserveLong();
    Iterator<E> iter = this.iterator();
    int numElements = 0;
    while (iter.hasNext()) {
        E data = iter.next();
        if (isStruct) {
            Object[] fields = ((Struct) data).getFieldValues();
            DataSerializer.writeObjectArray(fields, out);
        } else {
            DataSerializer.writeObject(data, hdos);
        }
        ++numElements;
    }
    lu.update(numElements);
    hdos.sendTo(out);
}
Also used : LongUpdater(org.apache.geode.internal.HeapDataOutputStream.LongUpdater) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) Struct(org.apache.geode.cache.query.Struct)

Example 2 with LongUpdater

use of org.apache.geode.internal.HeapDataOutputStream.LongUpdater in project geode by apache.

the class CumulativeNonDistinctResults method toData.

// TODO : optimize for struct elements , by directly writing the fields
// instead
// of struct
@Override
public void toData(DataOutput out) throws IOException {
    boolean isStruct = this.collectionType.getElementType().isStructType();
    DataSerializer.writeObject(this.collectionType.getElementType(), out);
    HeapDataOutputStream hdos = new HeapDataOutputStream(1024, null);
    LongUpdater lu = hdos.reserveLong();
    Iterator<E> iter = this.iterator();
    int numElements = 0;
    while (iter.hasNext()) {
        E data = iter.next();
        if (isStruct) {
            Object[] fields = ((Struct) data).getFieldValues();
            DataSerializer.writeObjectArray(fields, out);
        } else {
            DataSerializer.writeObject(data, hdos);
        }
        ++numElements;
    }
    lu.update(numElements);
    hdos.sendTo(out);
}
Also used : LongUpdater(org.apache.geode.internal.HeapDataOutputStream.LongUpdater) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) Struct(org.apache.geode.cache.query.Struct)

Aggregations

Struct (org.apache.geode.cache.query.Struct)2 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)2 LongUpdater (org.apache.geode.internal.HeapDataOutputStream.LongUpdater)2