/** * @return compressed object size */ public final int getCompactObjectSize() { assert getSerializedSize() % getTupleSize() == 0; return getSerializedSize() / getTupleSize(); }
/** * @return uncompressed object size */ public final int getTotalObjectSize() { assert getSerializedSize() % getTupleSize() == 0; return index != null ? index.length : getSerializedSize() / getTupleSize(); }
/** * serialize this compact array */ public final void serialize() { if (invalid) { int newSize = indexPool.size() * getTupleSize(); if (array == null || Array.getLength(array) < newSize) { array = ensureCapacity(array, newSize); for (Map.Entry<T, Integer> entry : indexPool.entrySet()) { int i = entry.getValue(); T obj = entry.getKey(); serialize(i, obj); } } invalid = false; } }
/** * decompress and return object array * @return decompress and return object array */ @SuppressWarnings("unchecked") public final T[] toObjectArray() { try { T[] compactArr = (T[]) Array.newInstance(getElementClass(), getSerializedSize() / getTupleSize()); for (int i = 0; i < compactArr.length; i++) { compactArr[i] = getElementClass().newInstance(); deserialize(i, compactArr[i]); } T[] objArr = (T[]) Array.newInstance(getElementClass(), getTotalObjectSize()); for (int i = 0; i < objArr.length; i++) { int compactIndex = getCompactIndex(i); objArr[i] = compactArr[compactIndex]; } return objArr; } catch (Exception e) { return null; } }
/** * @return compressed object size */ public final int getCompactObjectSize() { assert getSerializedSize() % getTupleSize() == 0; return getSerializedSize() / getTupleSize(); }
/** * @return compressed object size */ public final int getCompactObjectSize() { assert getSerializedSize() % getTupleSize() == 0; return getSerializedSize() / getTupleSize(); }
/** * @return uncompressed object size */ public final int getTotalObjectSize() { assert getSerializedSize() % getTupleSize() == 0; return index != null ? index.length : getSerializedSize() / getTupleSize(); }
/** * @return uncompressed object size */ public final int getTotalObjectSize() { assert getSerializedSize() % getTupleSize() == 0; return index != null ? index.length : getSerializedSize() / getTupleSize(); }
/** * serialize this compact array */ public final void serialize() { if (invalid) { int newSize = indexPool.size() * getTupleSize(); if (array == null || Array.getLength(array) < newSize) { array = ensureCapacity(array, newSize); for (Map.Entry<T, Integer> entry : indexPool.entrySet()) { int i = entry.getValue(); T obj = entry.getKey(); serialize(i, obj); } } invalid = false; } }
/** * serialize this compact array */ public final void serialize() { if (invalid) { int newSize = indexPool.size() * getTupleSize(); if (array == null || Array.getLength(array) < newSize) { array = ensureCapacity(array, newSize); for (Map.Entry<T, Integer> entry : indexPool.entrySet()) { int i = entry.getValue(); T obj = entry.getKey(); serialize(i, obj); } } invalid = false; } }
/** * decompress and return object array * @return decompress and return object array */ public final T[] toObjectArray() { try { T[] compactArr = (T[]) Array.newInstance(getElementClass(), getSerializedSize() / getTupleSize()); for (int i = 0; i < compactArr.length; i++) { compactArr[i] = getElementClass().newInstance(); deserialize(i, compactArr[i]); } T[] objArr = (T[]) Array.newInstance(getElementClass(), getTotalObjectSize()); for (int i = 0; i < objArr.length; i++) { int compactIndex = getCompactIndex(i); objArr[i] = compactArr[compactIndex]; } return objArr; } catch (Exception e) { return null; } }
/** * decompress and return object array * @return decompress and return object array */ @SuppressWarnings("unchecked") public final T[] toObjectArray() { try { T[] compactArr = (T[]) Array.newInstance(getElementClass(), getSerializedSize() / getTupleSize()); for (int i = 0; i < compactArr.length; i++) { compactArr[i] = getElementClass().newInstance(); deserialize(i, compactArr[i]); } T[] objArr = (T[]) Array.newInstance(getElementClass(), getTotalObjectSize()); for (int i = 0; i < objArr.length; i++) { int compactIndex = getCompactIndex(i); objArr[i] = compactArr[compactIndex]; } return objArr; } catch (Exception e) { return null; } }