Java Code Examples for org.apache.hadoop.hbase.KeyValue#createFirstOnRow()
The following examples show how to use
org.apache.hadoop.hbase.KeyValue#createFirstOnRow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CellSkipFilter.java From phoenix-tephra with Apache License 2.0 | 6 votes |
@Override public ReturnCode filterKeyValue(Cell cell) throws IOException { if (skipCellVersion(cell)) { return ReturnCode.NEXT_COL; } ReturnCode code = filter.filterKeyValue(cell); if (code == ReturnCode.NEXT_COL || code == ReturnCode.INCLUDE_AND_NEXT_COL) { // only store the reference to the keyvalue if we are returning NEXT_COL or INCLUDE_AND_NEXT_COL skipColumn = KeyValue.createFirstOnRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } else { skipColumn = null; } return code; }
Example 2
Source File: CellSkipFilter.java From phoenix-tephra with Apache License 2.0 | 6 votes |
@Override public ReturnCode filterKeyValue(Cell cell) throws IOException { if (skipCellVersion(cell)) { return ReturnCode.NEXT_COL; } ReturnCode code = filter.filterKeyValue(cell); if (code == ReturnCode.NEXT_COL || code == ReturnCode.INCLUDE_AND_NEXT_COL) { // only store the reference to the keyvalue if we are returning NEXT_COL or INCLUDE_AND_NEXT_COL skipColumn = KeyValue.createFirstOnRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } else { skipColumn = null; } return code; }
Example 3
Source File: ApplyAndFilterDeletesFilter.java From phoenix with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Override public KeyValue getHint(KeyValue peeked) { // check to see if we have another column to seek ImmutableBytesPtr nextFamily = getNextFamily(new ImmutableBytesPtr(peeked.getBuffer(), peeked.getFamilyOffset(), peeked.getFamilyLength())); if (nextFamily == null) { // no known next family, so we can be completely done done = true; return KeyValue.LOWESTKEY; } // there is a valid family, so we should seek to that return KeyValue.createFirstOnRow(peeked.getRow(), nextFamily.copyBytesIfNecessary(), HConstants.EMPTY_BYTE_ARRAY); }
Example 4
Source File: TestIndexMemStore.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testCorrectOverwritting() throws Exception { IndexMemStore store = new IndexMemStore(IndexMemStore.COMPARATOR); long ts = 10; KeyValue kv = new KeyValue(row, family, qual, ts, Type.Put, val); kv.setSequenceId(2); KeyValue kv2 = new KeyValue(row, family, qual, ts, Type.Put, val2); kv2.setSequenceId(0); store.add(kv, true); // adding the exact same kv shouldn't change anything stored if not overwritting store.add(kv2, false); KeyValueScanner scanner = store.getScanner(); KeyValue first = KeyValue.createFirstOnRow(row); scanner.seek(first); assertTrue("Overwrote kv when specifically not!", kv == scanner.next()); scanner.close(); // now when we overwrite, we should get the newer one store.add(kv2, true); scanner = store.getScanner(); scanner.seek(first); assertTrue("Didn't overwrite kv when specifically requested!", kv2 == scanner.next()); scanner.close(); }
Example 5
Source File: TestIndexMemStore.java From phoenix with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testCorrectOverwritting() throws Exception { IndexMemStore store = new IndexMemStore(IndexMemStore.COMPARATOR); long ts = 10; KeyValue kv = new KeyValue(row, family, qual, ts, Type.Put, val); kv.setMemstoreTS(2); KeyValue kv2 = new KeyValue(row, family, qual, ts, Type.Put, val2); kv2.setMemstoreTS(0); store.add(kv, true); // adding the exact same kv shouldn't change anything stored if not overwritting store.add(kv2, false); KeyValueScanner scanner = store.getScanner(); KeyValue first = KeyValue.createFirstOnRow(row); scanner.seek(first); assertTrue("Overwrote kv when specifically not!", kv == scanner.next()); scanner.close(); // now when we overwrite, we should get the newer one store.add(kv2, true); scanner = store.getScanner(); scanner.seek(first); assertTrue("Didn't overwrite kv when specifically requested!", kv2 == scanner.next()); scanner.close(); }
Example 6
Source File: SkipScanFilterTest.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void examine(SkipScanFilter skipper) { KeyValue kv = KeyValue.createFirstOnRow(rowkey); skipper.reset(); assertFalse(skipper.filterAllRemaining()); assertFalse(skipper.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())); assertEquals(ReturnCode.SEEK_NEXT_USING_HINT, skipper.filterKeyValue(kv)); assertEquals(KeyValue.createFirstOnRow(hint), skipper.getNextKeyHint(kv)); }
Example 7
Source File: TestApplyAndFilterDeletesFilter.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Hinting with this filter is a little convoluted as we binary search the list of families to * attempt to find the right one to seek. */ @Test public void testHintCorrectlyToNextFamily() { // start with doing a family delete, so we will seek to the next column KeyValue kv = createKvForType(Type.DeleteFamily); ApplyAndFilterDeletesFilter filter = new ApplyAndFilterDeletesFilter(EMPTY_SET); assertEquals(ReturnCode.SKIP, filter.filterKeyValue(kv)); KeyValue next = createKvForType(Type.Put); // make sure the hint is our attempt at the end key, because we have no more families to seek assertEquals("Didn't get a hint from a family delete", ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(next)); assertEquals("Didn't get END_KEY with no families to match", KeyValue.LOWESTKEY, filter.getNextKeyHint(next)); // check for a family that comes before our family, so we always seek to the end as well filter = new ApplyAndFilterDeletesFilter(asSet(Bytes.toBytes("afamily"))); assertEquals(ReturnCode.SKIP, filter.filterKeyValue(kv)); // make sure the hint is our attempt at the end key, because we have no more families to seek assertEquals("Didn't get a hint from a family delete", ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(next)); assertEquals("Didn't get END_KEY with no families to match", KeyValue.LOWESTKEY, filter.getNextKeyHint(next)); // check that we seek to the correct family that comes after our family byte[] laterFamily = Bytes.toBytes("zfamily"); filter = new ApplyAndFilterDeletesFilter(asSet(laterFamily)); assertEquals(ReturnCode.SKIP, filter.filterKeyValue(kv)); KeyValue expected = KeyValue.createFirstOnRow(kv.getRow(), laterFamily, new byte[0]); assertEquals("Didn't get a hint from a family delete", ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(next)); assertEquals("Didn't get correct next key with a next family", expected, filter.getNextKeyHint(next)); }
Example 8
Source File: TestIndexMemStore.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * We don't expect custom KeyValue creation, so we can't get into weird situations, where a * {@link Type#DeleteFamily} has a column qualifier specified. * @throws Exception */ @Test public void testExpectedOrdering() throws Exception { IndexMemStore store = new IndexMemStore(); KeyValue kv = new KeyValue(row, family, qual, 12, Type.Put, val); store.add(kv, true); KeyValue kv2 = new KeyValue(row, family, qual, 10, Type.Put, val2); store.add(kv2, true); KeyValue df = new KeyValue(row, family, null, 11, Type.DeleteFamily, null); store.add(df, true); KeyValue dc = new KeyValue(row, family, qual, 11, Type.DeleteColumn, null); store.add(dc, true); KeyValue d = new KeyValue(row, family, qual, 12, Type.Delete, null); store.add(d, true); // null qualifiers should always sort before the non-null cases KeyValueScanner scanner = store.getScanner(); KeyValue first = KeyValue.createFirstOnRow(row); assertTrue("Didn't have any data in the scanner", scanner.seek(first)); assertTrue("Didn't get delete family first (no qualifier == sort first)", df == scanner.next()); assertTrue("Didn't get point delete before corresponding put", d == scanner.next()); assertTrue("Didn't get larger ts Put", kv == scanner.next()); assertTrue("Didn't get delete column before corresponding put(delete sorts first)", dc == scanner.next()); assertTrue("Didn't get smaller ts Put", kv2 == scanner.next()); assertNull("Have more data in the scanner", scanner.next()); }
Example 9
Source File: ApplyAndFilterDeletesFilter.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public KeyValue getHint(KeyValue peeked) { // check to see if we have another column to seek ImmutableBytesPtr nextFamily = getNextFamily(new ImmutableBytesPtr(peeked.getBuffer(), peeked.getFamilyOffset(), peeked.getFamilyLength())); if (nextFamily == null) { // no known next family, so we can be completely done done = true; return KeyValue.LOWESTKEY; } // there is a valid family, so we should seek to that return KeyValue.createFirstOnRow(peeked.getRow(), nextFamily.copyBytesIfNecessary(), HConstants.EMPTY_BYTE_ARRAY); }
Example 10
Source File: KeyValueListScanner.java From hbase-secondary-index with GNU General Public License v3.0 | 5 votes |
public KeyValueListScanner(final KeyValue.KVComparator comparator, final KeyValue ... incData) { this.comparator = comparator; data = new ArrayList<KeyValue>(incData.length); for (int i = 0; i < incData.length; ++i) { data.add(incData[i]); } Collections.sort(data, this.comparator); this.iter = data.iterator(); if (!data.isEmpty()) { this.current = KeyValue.createFirstOnRow(data.get(0).getRow()); } }
Example 11
Source File: SkipScanFilterTest.java From phoenix with Apache License 2.0 | 5 votes |
@Override public void examine(SkipScanFilter skipper) throws IOException { KeyValue kv = KeyValue.createFirstOnRow(rowkey); skipper.reset(); assertEquals(ReturnCode.NEXT_ROW,skipper.filterKeyValue(kv)); skipper.reset(); assertTrue(skipper.filterAllRemaining()); }
Example 12
Source File: SkipScanFilterTest.java From phoenix with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public void examine(SkipScanFilter skipper) throws IOException { KeyValue kv = KeyValue.createFirstOnRow(rowkey); skipper.reset(); assertFalse(skipper.filterAllRemaining()); assertFalse(skipper.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())); assertEquals(kv.toString(), ReturnCode.INCLUDE, skipper.filterKeyValue(kv)); }
Example 13
Source File: SkipScanFilterTest.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void examine(SkipScanFilter skipper) { KeyValue kv = KeyValue.createFirstOnRow(rowkey); skipper.reset(); assertFalse(skipper.filterAllRemaining()); assertFalse(skipper.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())); assertEquals(kv.toString(), ReturnCode.INCLUDE, skipper.filterKeyValue(kv)); }
Example 14
Source File: TestApplyAndFilterDeletesFilter.java From phoenix with Apache License 2.0 | 5 votes |
/** * Hinting with this filter is a little convoluted as we binary search the list of families to * attempt to find the right one to seek. */ @Test public void testHintCorrectlyToNextFamily() { // start with doing a family delete, so we will seek to the next column KeyValue kv = createKvForType(Type.DeleteFamily); ApplyAndFilterDeletesFilter filter = new ApplyAndFilterDeletesFilter(EMPTY_SET); assertEquals(ReturnCode.SKIP, filter.filterKeyValue(kv)); KeyValue next = createKvForType(Type.Put); // make sure the hint is our attempt at the end key, because we have no more families to seek assertEquals("Didn't get a hint from a family delete", ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(next)); assertEquals("Didn't get END_KEY with no families to match", KeyValue.LOWESTKEY, filter.getNextCellHint(next)); // check for a family that comes before our family, so we always seek to the end as well filter = new ApplyAndFilterDeletesFilter(asSet(Bytes.toBytes("afamily"))); assertEquals(ReturnCode.SKIP, filter.filterKeyValue(kv)); // make sure the hint is our attempt at the end key, because we have no more families to seek assertEquals("Didn't get a hint from a family delete", ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(next)); assertEquals("Didn't get END_KEY with no families to match", KeyValue.LOWESTKEY, filter.getNextCellHint(next)); // check that we seek to the correct family that comes after our family byte[] laterFamily = Bytes.toBytes("zfamily"); filter = new ApplyAndFilterDeletesFilter(asSet(laterFamily)); assertEquals(ReturnCode.SKIP, filter.filterKeyValue(kv)); @SuppressWarnings("deprecation") KeyValue expected = KeyValue.createFirstOnRow(kv.getRow(), laterFamily, new byte[0]); assertEquals("Didn't get a hint from a family delete", ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(next)); assertEquals("Didn't get correct next key with a next family", expected, filter.getNextCellHint(next)); }
Example 15
Source File: TestIndexMemStore.java From phoenix with Apache License 2.0 | 5 votes |
/** * We don't expect custom KeyValue creation, so we can't get into weird situations, where a * {@link Type#DeleteFamily} has a column qualifier specified. * @throws Exception */ @Test public void testExpectedOrdering() throws Exception { IndexMemStore store = new IndexMemStore(); KeyValue kv = new KeyValue(row, family, qual, 12, Type.Put, val); store.add(kv, true); KeyValue kv2 = new KeyValue(row, family, qual, 10, Type.Put, val2); store.add(kv2, true); KeyValue df = new KeyValue(row, family, null, 11, Type.DeleteFamily, null); store.add(df, true); KeyValue dc = new KeyValue(row, family, qual, 11, Type.DeleteColumn, null); store.add(dc, true); KeyValue d = new KeyValue(row, family, qual, 12, Type.Delete, null); store.add(d, true); // null qualifiers should always sort before the non-null cases KeyValueScanner scanner = store.getScanner(); KeyValue first = KeyValue.createFirstOnRow(row); assertTrue("Didn't have any data in the scanner", scanner.seek(first)); assertTrue("Didn't get delete family first (no qualifier == sort first)", df == scanner.next()); assertTrue("Didn't get point delete before corresponding put", d == scanner.next()); assertTrue("Didn't get larger ts Put", kv == scanner.next()); assertTrue("Didn't get delete column before corresponding put(delete sorts first)", dc == scanner.next()); assertTrue("Didn't get smaller ts Put", kv2 == scanner.next()); assertNull("Have more data in the scanner", scanner.next()); }
Example 16
Source File: ResultUtil.java From phoenix with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static KeyValue getSearchTerm(Result r, byte[] family, byte[] qualifier) { byte[] rbytes = getRawBytes(r); int roffset = getKeyOffset(r); int rlength = getKeyLength(r); return KeyValue.createFirstOnRow(rbytes, roffset, rlength, family, 0, family.length, qualifier, 0, qualifier.length); }
Example 17
Source File: ResultUtil.java From phoenix with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Binary search for latest column value without allocating memory in the process */ public static KeyValue getColumnLatest(Result r, byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength) { KeyValue searchTerm = KeyValue.createFirstOnRow(row, roffset, rlength, family, foffset, flength, qualifier, qoffset, qlength); return getColumnLatest(r,searchTerm); }
Example 18
Source File: ResultUtil.java From phoenix with Apache License 2.0 | 4 votes |
/** * Binary search for latest column value without allocating memory in the process */ public static KeyValue getColumnLatest(Result r, byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength) { KeyValue searchTerm = KeyValue.createFirstOnRow(row, roffset, rlength, family, foffset, flength, qualifier, qoffset, qlength); return getColumnLatest(r,searchTerm); }
Example 19
Source File: ResultUtil.java From phoenix with Apache License 2.0 | 4 votes |
public static KeyValue getSearchTerm(Result r, byte[] family, byte[] qualifier) { byte[] rbytes = getRawBytes(r); int roffset = getKeyOffset(r); int rlength = getKeyLength(r); return KeyValue.createFirstOnRow(rbytes, roffset, rlength, family, 0, family.length, qualifier, 0, qualifier.length); }
Example 20
Source File: ColumnReference.java From phoenix with Apache License 2.0 | 4 votes |
public KeyValue getFirstKeyValueForRow(byte[] row) { return KeyValue.createFirstOnRow(row, family, qualifier == ALL_QUALIFIERS ? null : qualifier); }