List of usage examples for java.util Arrays fill
public static void fill(Object[] a, int fromIndex, int toIndex, Object val)
From source file:com.ebay.nest.io.sede.lazybinary.LazyBinaryMap.java
/** * Parse the byte[] and fill keyStart, keyLength, keyIsNull valueStart, valueLength and valueIsNull. *//* w w w . j av a 2 s .c o m*/ private void parse() { byte[] bytes = this.bytes.getData(); // get the VInt that represents the map size LazyBinaryUtils.readVInt(bytes, start, vInt); mapSize = vInt.value; if (0 == mapSize) { parsed = true; return; } // adjust arrays adjustArraySize(mapSize); // find out the null-bytes int mapByteStart = start + vInt.length; int nullByteCur = mapByteStart; int nullByteEnd = mapByteStart + (mapSize * 2 + 7) / 8; int lastElementByteEnd = nullByteEnd; // parsing the keys and values one by one for (int i = 0; i < mapSize; i++) { // parse a key keyIsNull[i] = true; if ((bytes[nullByteCur] & (1 << ((i * 2) % 8))) != 0) { keyIsNull[i] = false; LazyBinaryUtils.checkObjectByteInfo(((MapObjectInspector) oi).getMapKeyObjectInspector(), bytes, lastElementByteEnd, recordInfo); keyStart[i] = lastElementByteEnd + recordInfo.elementOffset; keyLength[i] = recordInfo.elementSize; lastElementByteEnd = keyStart[i] + keyLength[i]; } else if (!nullMapKey) { nullMapKey = true; LOG.warn("Null map key encountered! Ignoring similar problems."); } // parse a value valueIsNull[i] = true; if ((bytes[nullByteCur] & (1 << ((i * 2 + 1) % 8))) != 0) { valueIsNull[i] = false; LazyBinaryUtils.checkObjectByteInfo(((MapObjectInspector) oi).getMapValueObjectInspector(), bytes, lastElementByteEnd, recordInfo); valueStart[i] = lastElementByteEnd + recordInfo.elementOffset; valueLength[i] = recordInfo.elementSize; lastElementByteEnd = valueStart[i] + valueLength[i]; } // move onto the next null byte if (3 == (i % 4)) { nullByteCur++; } } Arrays.fill(keyInited, 0, mapSize, false); Arrays.fill(valueInited, 0, mapSize, false); parsed = true; }