/** * Reads WALEdit from cells. * @param cellDecoder Cell decoder. * @param expectedCount Expected cell count. * @return Number of KVs read. */ public int readFromCells(Codec.Decoder cellDecoder, int expectedCount) throws IOException { cells.clear(); cells.ensureCapacity(expectedCount); while (cells.size() < expectedCount && cellDecoder.advance()) { cells.add(cellDecoder.current()); } return cells.size(); }
Codec.Decoder decoder = cmc.getDecoder(dis); assertTrue(decoder.advance()); Cell c = decoder.current(); assertTrue(CellUtil.equals(c, kv1)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv2)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv3)); assertFalse(decoder.advance());
Codec.Decoder decoder = codec.getDecoder(dis); assertTrue(decoder.advance()); Cell c = decoder.current(); assertTrue(CellUtil.equals(c, kv1)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv2)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv3)); assertFalse(decoder.advance());
Codec.Decoder decoder = kvc.getDecoder(dis); assertTrue(decoder.advance()); KeyValue kv = (KeyValue)decoder.current(); assertTrue(kv1.equals(kv)); assertTrue(decoder.advance()); kv = (KeyValue)decoder.current(); assertTrue(kv2.equals(kv)); assertTrue(decoder.advance()); kv = (KeyValue)decoder.current(); assertTrue(kv3.equals(kv)); assertFalse(decoder.advance());
Codec.Decoder decoder = kvc.getDecoder(dis); assertTrue(decoder.advance()); KeyValue kv = (KeyValue)decoder.current(); assertTrue(kv1.equals(kv)); assertTrue(decoder.advance()); kv = (KeyValue)decoder.current(); assertTrue(kv2.equals(kv)); assertTrue(decoder.advance()); kv = (KeyValue)decoder.current(); assertTrue(kv3.equals(kv)); assertFalse(decoder.advance());
Codec.Decoder decoder = codec.getDecoder(dis); assertTrue(decoder.advance()); Cell c = decoder.current(); assertTrue(CellUtil.equals(c, kv1)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv2)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv3)); assertFalse(decoder.advance());
Decoder decoder = codec.getDecoder(is); decoder.advance(); KeyValue kv = (KeyValue) decoder.current(); List<Tag> tags = PrivateCellUtil.getTags(kv); assertEquals(1, tags.size()); assertEquals("tagValue1", Bytes.toString(Tag.cloneValue(tags.get(0)))); decoder.advance(); kv = (KeyValue) decoder.current(); tags = PrivateCellUtil.getTags(kv); assertEquals(0, tags.size()); decoder.advance(); kv = (KeyValue) decoder.current(); tags = PrivateCellUtil.getTags(kv); assertEquals(2, tags.size());
Codec.Decoder decoder = cmc.getDecoder(dis); assertTrue(decoder.advance()); Cell c = decoder.current(); assertTrue(CellUtil.equals(c, kv1)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv2)); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv3)); assertFalse(decoder.advance());
@Override protected Cell parseCell() throws IOException { // reader the marker int marker = this.in.read(); if (marker < 0) { throw new EOFException( "Unexepcted end of stream found while reading next (Indexed) KeyValue"); } // do the normal thing, if its a regular kv if (marker == REGULAR_KEY_VALUE_MARKER) { if (!this.decoder.advance()) { throw new IOException("Could not read next key-value from generic KeyValue Decoder!"); } return this.decoder.current(); } // its an indexedKeyValue, so parse it out specially return KeyValueCodec.readKeyValue(this.dataInput); } }
@Override protected Cell parseCell() throws IOException { // reader the marker int marker = this.in.read(); if (marker < 0) { throw new EOFException( "Unexepcted end of stream found while reading next (Indexed) KeyValue"); } // do the normal thing, if its a regular kv if (marker == REGULAR_KEY_VALUE_MARKER) { if (!this.decoder.advance()) { throw new IOException("Could not read next key-value from generic KeyValue Decoder!"); } return this.decoder.current(); } // its an indexedKeyValue, so parse it out specially return KeyValueCodec.readKeyValue(this.dataInput); } }
@Override protected Cell parseCell() throws IOException { // reader the marker int marker = this.in.read(); if (marker < 0) { throw new EOFException( "Unexepcted end of stream found while reading next (Indexed) KeyValue"); } // do the normal thing, if its a regular kv if (marker == REGULAR_KEY_VALUE_MARKER) { if (!this.decoder.advance()) { throw new IOException("Could not read next key-value from generic KeyValue Decoder!"); } return this.decoder.current(); } // its an indexedKeyValue, so parse it out specially return KeyValueCodec.readKeyValue(this.dataInput); } }
@Override protected Cell parseCell() throws IOException { // reader the marker int marker = this.in.read(); if (marker < 0) { throw new EOFException( "Unexepcted end of stream found while reading next (Indexed) KeyValue"); } // do the normal thing, if its a regular kv if (marker == REGULAR_KEY_VALUE_MARKER) { if (!this.decoder.advance()) { throw new IOException("Could not read next key-value from generic KeyValue Decoder!"); } return this.decoder.current(); } // its an indexedKeyValue, so parse it out specially return KeyValueCodec.readKeyValue(this.dataInput); } }
/** * Reads WALEdit from cells. * @param cellDecoder Cell decoder. * @param expectedCount Expected cell count. * @return Number of KVs read. */ public int readFromCells(Codec.Decoder cellDecoder, int expectedCount) throws IOException { cells.clear(); cells.ensureCapacity(expectedCount); while (cells.size() < expectedCount && cellDecoder.advance()) { cells.add(cellDecoder.current()); } return cells.size(); }
@Override protected Cell parseCell() throws IOException { // reader the marker int marker = this.in.read(); if (marker < 0) { throw new EOFException( "Unexepcted end of stream found while reading next (Indexed) KeyValue"); } // do the normal thing, if its a regular kv if (marker == REGULAR_KEY_VALUE_MARKER) { if (!this.decoder.advance()) { throw new IOException("Could not read next key-value from generic KeyValue Decoder!"); } return this.decoder.current(); } // its an indexedKeyValue, so parse it out specially return KeyValueCodec.readKeyValue(this.dataInput); } }
@Override protected Cell parseCell() throws IOException { // reader the marker int marker = this.in.read(); if (marker < 0) { throw new EOFException( "Unexepcted end of stream found while reading next (Indexed) KeyValue"); } // do the normal thing, if its a regular kv if (marker == REGULAR_KEY_VALUE_MARKER) { if (!this.decoder.advance()) { throw new IOException("Could not read next key-value from generic KeyValue Decoder!"); } return this.decoder.current(); } // its an indexedKeyValue, so parse it out specially return KeyValueCodec.readKeyValue(this.dataInput); } }
Codec.Decoder decoder = codec.getDecoder(dis); assertTrue(decoder.advance()); Cell c = decoder.current(); assertTrue(CellUtil.equals(c, cell1)); List<Tag> tags = assertTrue(Bytes.equals(Bytes.toBytes("teststring2"), Tag.cloneValue(tag))); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, cell2)); tags = PrivateCellUtil.getTags(c); assertTrue(Bytes.equals(Bytes.toBytes("teststring3"), Tag.cloneValue(tag))); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, cell3)); tags = PrivateCellUtil.getTags(c);
Codec.Decoder decoder = codec.getDecoder(dis); assertTrue(decoder.advance()); Cell c = decoder.current(); assertTrue(CellUtil.equals(c, kv1)); List<Tag> tags = assertTrue(Bytes.equals(Bytes.toBytes("teststring2"), Tag.cloneValue(tag))); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv2)); tags = PrivateCellUtil.getTags(c); assertTrue(Bytes.equals(Bytes.toBytes("teststring3"), Tag.cloneValue(tag))); assertTrue(decoder.advance()); c = decoder.current(); assertTrue(CellUtil.equals(c, kv3)); tags = PrivateCellUtil.getTags(c);
Decoder decoder = codec.getDecoder(is); assertTrue(decoder.advance()); assertTrue(CellUtil.equals(c1, decoder.current())); assertTrue(decoder.advance()); assertTrue(CellUtil.equals(c2, decoder.current())); assertTrue(decoder.advance()); assertTrue(CellUtil.equals(c3, decoder.current())); assertFalse(decoder.advance());
Codec.Decoder decoder = kvc.getDecoder(dis); assertTrue(decoder.advance()); KeyValue kv = (KeyValue)decoder.current(); assertTrue(kv1.equals(kv)); assertTrue(decoder.advance()); kv = (KeyValue)decoder.current(); assertTrue(kv2.equals(kv)); assertTrue(decoder.advance()); kv = (KeyValue)decoder.current(); assertTrue(kv3.equals(kv)); assertFalse(decoder.advance());
Decoder decoder = codec.getDecoder(is); decoder.advance(); KeyValue kv = (KeyValue) decoder.current(); List<Tag> tags = PrivateCellUtil.getTags(kv); assertEquals(1, tags.size()); assertEquals("tagValue1", Bytes.toString(Tag.cloneValue(tags.get(0)))); decoder.advance(); kv = (KeyValue) decoder.current(); tags = PrivateCellUtil.getTags(kv); assertEquals(0, tags.size()); decoder.advance(); kv = (KeyValue) decoder.current(); tags = PrivateCellUtil.getTags(kv); assertEquals(2, tags.size());