@Override public T getPrimitiveWritableObject(Object o) { return o == null ? null : ((LazyPrimitive<?, T>) o).getWritableObject(); }
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); byte[] recv = new byte[length]; System.arraycopy(bytes.getData(), start, recv, 0, length); byte[] decoded = decodeIfNeeded(recv); // use the original bytes in case decoding should fail decoded = decoded.length > 0 ? decoded : recv; data.set(decoded, 0, decoded.length); }
/** * Return the map object representing this LazyMap. Note that the keyObjects * will be Writable primitive objects. * * @return the map object */ public Map<Object, Object> getMap() { if (!parsed) { parse(); } if (cachedMap != null) { return cachedMap; } // Use LinkedHashMap to provide deterministic order cachedMap = new LinkedHashMap<Object, Object>(); // go through each element of the map for (int i = 0; i < mapSize; i++) { LazyPrimitive<?, ?> lazyKey = uncheckedGetKey(i); if (lazyKey == null) { continue; } Object key = lazyKey.getObject(); // do not overwrite if there are duplicate keys if (key != null && !cachedMap.containsKey(key)) { cachedMap.put(key, uncheckedGetValue(i)); } } return cachedMap; }
Object key = lazyKey.getObject(); if(!keySet.contains(key)) { mapSize++;
@Override public boolean equals(Object obj) { if (!(obj instanceof LazyPrimitive<?, ?>)) { return false; } if (data == obj) { return true; } if (data == null || obj == null) { return false; } return data.equals(((LazyPrimitive<?, ?>) obj).getWritableObject()); }
/** * Get the key object with the index without checking parsed. * * @param index * The index into the array starting from 0 */ private LazyPrimitive<?, ?> uncheckedGetKey(int index) { if (keyInited[index]) { return keyObjects[index]; } int keyIBegin = keyStart[index]; int keyILength = keyEnd[index] - keyStart[index]; if (isNull(oi.getNullSequence(), bytes, keyIBegin, keyILength)) { return null; } keyInited[index] = true; if (keyObjects[index] == null) { keyObjects[index] = LazyFactory.createLazyPrimitiveClass( (PrimitiveObjectInspector) oi.getMapKeyObjectInspector()); } keyObjects[index].init(bytes, keyIBegin, keyILength); return keyObjects[index]; }
Object primitiveObject = ((LazyPrimitive) lazyObject).getObject(); PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; switch (primitiveTypeInfo.getPrimitiveCategory()) {
Object keyI = lazyKeyI.getWritableObject(); if (keyI == null) { continue;
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); byte[] recv = new byte[length]; System.arraycopy(bytes.getData(), start, recv, 0, length); byte[] decoded = decodeIfNeeded(recv); // use the original bytes in case decoding should fail decoded = decoded.length > 0 ? decoded : recv; data.set(decoded, 0, decoded.length); }
/** * Return the map object representing this LazyMap. Note that the keyObjects * will be Writable primitive objects. * * @return the map object */ public Map<Object, Object> getMap() { if (!parsed) { parse(); } if (cachedMap != null) { return cachedMap; } // Use LinkedHashMap to provide deterministic order cachedMap = new LinkedHashMap<Object, Object>(); // go through each element of the map for (int i = 0; i < mapSize; i++) { LazyPrimitive<?, ?> lazyKey = uncheckedGetKey(i); if (lazyKey == null) { continue; } Object key = lazyKey.getObject(); // do not overwrite if there are duplicate keys if (key != null && !cachedMap.containsKey(key)) { cachedMap.put(key, uncheckedGetValue(i)); } } return cachedMap; }
totalVariableSize += ((LazyPrimitive<LazyStringObjectInspector, Text>) key). getWritableObject().getLength(); } else if (key instanceof String) { totalVariableSize += ((String) key).length(); totalVariableSize += ((LazyPrimitive<LazyBinaryObjectInspector, BytesWritable>) key). getWritableObject().getLength(); } else if (key instanceof BytesWritable) { totalVariableSize += ((BytesWritable) key).getLength();
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); byte[] recv = new byte[length]; System.arraycopy(bytes.getData(), start, recv, 0, length); byte[] decoded = decodeIfNeeded(recv); // use the original bytes in case decoding should fail decoded = decoded.length > 0 ? decoded : recv; data.set(decoded, 0, decoded.length); }
/** * Return the map object representing this LazyMap. Note that the keyObjects * will be Writable primitive objects. * * @return the map object */ public Map<Object, Object> getMap() { if (!parsed) { parse(); } if (cachedMap != null) { return cachedMap; } // Use LinkedHashMap to provide deterministic order cachedMap = new LinkedHashMap<Object, Object>(); // go through each element of the map for (int i = 0; i < mapSize; i++) { LazyPrimitive<?, ?> lazyKey = uncheckedGetKey(i); if (lazyKey == null) { continue; } Object key = lazyKey.getObject(); // do not overwrite if there are duplicate keys if (key != null && !cachedMap.containsKey(key)) { cachedMap.put(key, uncheckedGetValue(i)); } } return cachedMap; }
Object keyI = lazyKeyI.getWritableObject(); if (keyI == null) { continue;
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); byte[] recv = new byte[length]; System.arraycopy(bytes.getData(), start, recv, 0, length); byte[] decoded = decodeIfNeeded(recv); // use the original bytes in case decoding should fail decoded = decoded.length > 0 ? decoded : recv; data.set(decoded, 0, decoded.length); }
/** * Return the map object representing this LazyMap. Note that the keyObjects * will be Writable primitive objects. * * @return the map object */ public Map<Object, Object> getMap() { if (!parsed) { parse(); } if (cachedMap != null) { return cachedMap; } // Use LinkedHashMap to provide deterministic order cachedMap = new LinkedHashMap<Object, Object>(); // go through each element of the map for (int i = 0; i < mapSize; i++) { LazyPrimitive<?, ?> lazyKey = uncheckedGetKey(i); if (lazyKey == null) { continue; } Object key = lazyKey.getObject(); // do not overwrite if there are duplicate keys if (key != null && !cachedMap.containsKey(key)) { cachedMap.put(key, uncheckedGetValue(i)); } } return cachedMap; }
totalVariableSize += ((LazyPrimitive<LazyStringObjectInspector, Text>) key). getWritableObject().getLength(); } else if (key instanceof String) { totalVariableSize += ((String) key).length(); totalVariableSize += ((LazyPrimitive<LazyBinaryObjectInspector, BytesWritable>) key). getWritableObject().getLength(); } else if (key instanceof BytesWritable) { totalVariableSize += ((BytesWritable) key).getLength();