public void init(BytesRefArrayWritable cols) { for (int i = 0; i < prjColIDs.length; ++i) { int fieldIndex = prjColIDs[i]; if (fieldIndex < cols.size()) { fieldInfoList[fieldIndex].init(cols.unCheckedGet(fieldIndex)); } else { // select columns that actually do not exist in the file. fieldInfoList[fieldIndex].init(null); } } }
/** * {@inheritDoc} */ @Override public boolean equals(Object o) { if (o == null || !(o instanceof BytesRefArrayWritable)) { return false; } return compareTo((BytesRefArrayWritable) o) == 0; }
public long getRawDataSerializedSize() { long serializedSize = 0; for (int i = 0; i < fieldInfoList.length; ++i) { serializedSize += fieldInfoList[i].getSerializedSize(); } return serializedSize; }
@Override public Writable newInstance() { return new BytesRefArrayWritable(); }
/** * Return the uncompressed size of this field */ public long getSerializedSize() { if (rawBytesField == null) { return 0; } return rawBytesField.getLength(); }
protected void initialize(int size) throws SerDeException { field = new BytesRefWritable[size]; for (int i = 0; i < size; i++) { field[i] = new BytesRefWritable(); serializeCache.set(i, field[i]); } serializedSize = 0; stats = new SerDeStats(); lastOperationSerialize = false; lastOperationDeserialize = false; }
@Override public Writable newInstance() { return new BytesRefWritable(); }
/** * {@inheritDoc} */ @Override public void readFields(DataInput in) throws IOException { int count = in.readInt(); ensureCapacity(count); for (int i = 0; i < count; i++) { bytesRefWritables[i].readFields(in); } valid = count; }
/** * Returns the underlying bytes. * * @throws IOException */ public byte[] getData() throws IOException { lazyDecompress(); return bytes; }
/** * enlarge the capacity if necessary, to ensure that it can hold the number of * elements specified by newValidCapacity argument. It will also narrow the * valid capacity when needed. Notice: it only enlarge or narrow the valid * capacity with no care of the already stored invalid BytesRefWritable. * * @param newValidCapacity * the desired capacity */ public void resetValid(int newValidCapacity) { ensureCapacity(newValidCapacity); valid = newValidCapacity; }
private void lazyDecompress() throws IOException { if (bytes == null && lazyDecompressObj != null) { bytes = lazyDecompressObj.decompress(); } }
/** {@inheritDoc} */ @Override public boolean equals(Object right_obj) { if (right_obj == null || !(right_obj instanceof BytesRefWritable)) { return false; } return compareTo((BytesRefWritable) right_obj) == 0; }
/** * {@inheritDoc} */ @Override public void write(DataOutput out) throws IOException { out.writeInt(valid); for (int i = 0; i < valid; i++) { BytesRefWritable cu = bytesRefWritables[i]; cu.write(out); } }
@Override public List<Object> getStructFieldsDataAsList(Object data) { if (data == null) { return null; } ColumnarStructBase struct = (ColumnarStructBase) data; return struct.getFieldsAsList(); } }
@Override public SerDeStats getSerDeStats() { // must be different assert (lastOperationSerialize != lastOperationDeserialize); if (lastOperationSerialize) { stats.setRawDataSize(serializedSize); } else { stats.setRawDataSize(cachedLazyStruct.getRawDataSerializedSize()); } return stats; }
@Override @SuppressWarnings("deprecation") public Serializer createSerializer() { return new LazyBinaryColumnarSerDe(); }
protected void ensureCapacity(int newCapacity) { int size = bytesRefWritables.length; if (size < newCapacity) { bytesRefWritables = Arrays.copyOf(bytesRefWritables, newCapacity); while (size < newCapacity) { bytesRefWritables[size] = new BytesRefWritable(); size++; } } }
/** * Returns a copy of the underlying bytes referenced by this instance. * * @return a new copied byte array * @throws IOException */ public byte[] getBytesCopy() throws IOException { lazyDecompress(); byte[] bb = new byte[length]; System.arraycopy(bytes, start, bb, 0, length); return bb; }
/** * Set the BytesRefWritable at the specified position with the specified * BytesRefWritable. * * @param index * index position * @param bytesRefWritable * the new element * @throws IllegalArgumentException * if the specified new element is null */ public void set(int index, BytesRefWritable bytesRefWritable) { ensureCapacity(index + 1); bytesRefWritables[index] = bytesRefWritable; if (valid <= index) { valid = index + 1; } }
/** {@inheritDoc} */ public void write(DataOutput out) throws IOException { lazyDecompress(); out.writeInt(length); out.write(bytes, start, length); }