public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) { byte [][] prefixes = new byte [filterArguments.size()][]; for (int i = 0 ; i < filterArguments.size(); i++) { byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(i)); prefixes[i] = columnPrefix; } return new MultipleColumnPrefixFilter(prefixes); }
/** * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static MultipleColumnPrefixFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.MultipleColumnPrefixFilter proto; try { proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } int numPrefixes = proto.getSortedPrefixesCount(); byte [][] prefixes = new byte[numPrefixes][]; for (int i = 0; i < numPrefixes; ++i) { prefixes[i] = proto.getSortedPrefixes(i).toByteArray(); } return new MultipleColumnPrefixFilter(prefixes); }
values[i] = Base64.getDecoder().decode(prefixes.get(i)); filter = new MultipleColumnPrefixFilter(values); } break; case MultiRowRangeFilter: {
@Test public void testMultipleColumnPrefixFilter() throws Exception { // empty array byte [][] prefixes = null; MultipleColumnPrefixFilter multipleColumnPrefixFilter = new MultipleColumnPrefixFilter(prefixes); assertTrue(multipleColumnPrefixFilter.areSerializedFieldsEqual( ProtobufUtil.toFilter(ProtobufUtil.toFilter(multipleColumnPrefixFilter)))); // non-empty array prefixes = new byte[2][]; prefixes[0] = Bytes.toBytes("a"); prefixes[1] = Bytes.toBytes(""); multipleColumnPrefixFilter = new MultipleColumnPrefixFilter(prefixes); assertTrue(multipleColumnPrefixFilter.areSerializedFieldsEqual( ProtobufUtil.toFilter(ProtobufUtil.toFilter(multipleColumnPrefixFilter)))); }
filter_prefix[1] = new byte [] {'q'}; filter = new MultipleColumnPrefixFilter(filter_prefix); scan.setFilter(filter); List<Cell> results = new ArrayList<>();
filter_prefix[1] = new byte [] {'q'}; filter = new MultipleColumnPrefixFilter(filter_prefix); scan.setFilter(filter); List<Cell> results = new ArrayList<>();
filter_prefix[0] = new byte [] {'p'}; multiplePrefixFilter = new MultipleColumnPrefixFilter(filter_prefix); scan1.setFilter(multiplePrefixFilter); List<Cell> results1 = new ArrayList<>();
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) { byte [][] prefixes = new byte [filterArguments.size()][]; for (int i = 0 ; i < filterArguments.size(); i++) { byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(i)); prefixes[i] = columnPrefix; } return new MultipleColumnPrefixFilter(prefixes); }
Table table = connection.getTable(TableName.valueOf("testtable")); Filter filter = new MultipleColumnPrefixFilter(new byte[][] { Bytes.toBytes("col-1"), Bytes.toBytes("col-2") });
/** * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static MultipleColumnPrefixFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.MultipleColumnPrefixFilter proto; try { proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } int numPrefixes = proto.getSortedPrefixesCount(); byte [][] prefixes = new byte[numPrefixes][]; for (int i = 0; i < numPrefixes; ++i) { prefixes[i] = proto.getSortedPrefixes(i).toByteArray(); } return new MultipleColumnPrefixFilter(prefixes); }
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) { byte [][] prefixes = new byte [filterArguments.size()][]; for (int i = 0 ; i < filterArguments.size(); i++) { byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(i)); prefixes[i] = columnPrefix; } return new MultipleColumnPrefixFilter(prefixes); }
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) { byte [][] prefixes = new byte [filterArguments.size()][]; for (int i = 0 ; i < filterArguments.size(); i++) { byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(i)); prefixes[i] = columnPrefix; } return new MultipleColumnPrefixFilter(prefixes); }
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) { byte [][] prefixes = new byte [filterArguments.size()][]; for (int i = 0 ; i < filterArguments.size(); i++) { byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(i)); prefixes[i] = columnPrefix; } return new MultipleColumnPrefixFilter(prefixes); }
/** * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static MultipleColumnPrefixFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.MultipleColumnPrefixFilter proto; try { proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } int numPrefixes = proto.getSortedPrefixesCount(); byte [][] prefixes = new byte[numPrefixes][]; for (int i = 0; i < numPrefixes; ++i) { prefixes[i] = proto.getSortedPrefixes(i).toByteArray(); } return new MultipleColumnPrefixFilter(prefixes); }
/** * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static MultipleColumnPrefixFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.MultipleColumnPrefixFilter proto; try { proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } int numPrefixes = proto.getSortedPrefixesCount(); byte [][] prefixes = new byte[numPrefixes][]; for (int i = 0; i < numPrefixes; ++i) { prefixes[i] = proto.getSortedPrefixes(i).toByteArray(); } return new MultipleColumnPrefixFilter(prefixes); }
public GraphFetchColumnFilterAssembler(Selection selection, PlasmaType rootType) { super(rootType); this.propertySelection = selection; this.columnKeyFac = new CompositeColumnKeyFactory(rootType); this.rootFilter = new FilterList(FilterList.Operator.MUST_PASS_ONE); // add default filters for graph state info needed for all queries QualifierFilter filter = null; for (GraphMetaKey field : GraphMetaKey.values()) { filter = new QualifierFilter(CompareFilter.CompareOp.EQUAL, new SubstringComparator( field.code())); this.rootFilter.addFilter(filter); } collect(); byte[][] prefixes = new byte[this.prefixMap.size()][]; int i = 0; for (byte[] prefix : this.prefixMap.values()) { prefixes[i] = prefix; i++; } MultipleColumnPrefixFilter multiPrefixfilter = new MultipleColumnPrefixFilter(prefixes); this.rootFilter.addFilter(multiPrefixfilter); }
public InitialFetchColumnFilterAssembler(Selection collector, PlasmaType rootType) { super(rootType); this.selection = collector; this.columnKeyFac = new CompositeColumnKeyFactory(rootType); this.rootFilter = new FilterList(FilterList.Operator.MUST_PASS_ONE); // add default filters for graph state info needed for all queries QualifierFilter filter = null; for (GraphMetaKey field : GraphMetaKey.values()) { filter = new QualifierFilter(CompareFilter.CompareOp.EQUAL, new SubstringComparator( field.code())); this.rootFilter.addFilter(filter); } collect(); byte[][] prefixes = new byte[prefixMap.size()][]; int i = 0; for (byte[] prefix : prefixMap.values()) { prefixes[i] = prefix; i++; } MultipleColumnPrefixFilter multiPrefixfilter = new MultipleColumnPrefixFilter(prefixes); this.rootFilter.addFilter(multiPrefixfilter); }
@Test public void testMultipleColumnPrefixFilter() throws Exception { // empty array byte [][] prefixes = null; MultipleColumnPrefixFilter multipleColumnPrefixFilter = new MultipleColumnPrefixFilter(prefixes); assertTrue(multipleColumnPrefixFilter.areSerializedFieldsEqual( ProtobufUtil.toFilter(ProtobufUtil.toFilter(multipleColumnPrefixFilter)))); // non-empty array prefixes = new byte[2][]; prefixes[0] = Bytes.toBytes("a"); prefixes[1] = Bytes.toBytes(""); multipleColumnPrefixFilter = new MultipleColumnPrefixFilter(prefixes); assertTrue(multipleColumnPrefixFilter.areSerializedFieldsEqual( ProtobufUtil.toFilter(ProtobufUtil.toFilter(multipleColumnPrefixFilter)))); }
filter_prefix[0] = new byte [] {'p'}; multiplePrefixFilter = new MultipleColumnPrefixFilter(filter_prefix); scan1.setFilter(multiplePrefixFilter); List<Cell> results1 = new ArrayList<>();
@Test public void testMultipleColumnPrefixes() throws IOException { // Initialize String goodValue = "includeThisValue"; Table table = getDefaultTable(); byte[] rowKey = dataHelper.randomData("testRow-"); Put put = new Put(rowKey); put.addColumn(COLUMN_FAMILY, dataHelper.randomData("a-"), Bytes.toBytes(goodValue)); put.addColumn(COLUMN_FAMILY, dataHelper.randomData("b-"), Bytes.toBytes(goodValue)); put.addColumn(COLUMN_FAMILY, dataHelper.randomData("c-"), Bytes.toBytes(goodValue)); put.addColumn(COLUMN_FAMILY, dataHelper.randomData("d-"), Bytes.toBytes(goodValue)); table.put(put); // Filter for results Filter filter = new MultipleColumnPrefixFilter(new byte[][]{ Bytes.toBytes("a-"), Bytes.toBytes("b-") }); Get get = new Get(rowKey).setFilter(filter); Result result = table.get(get); Cell[] cells = result.rawCells(); Assert.assertEquals("Should have two cells, prefixes a- and b-.", 2, cells.length); byte[] qualifier0 = CellUtil.cloneQualifier(cells[0]); Assert.assertTrue("qualifier0 should start with a-", qualifier0[0] == 'a' && qualifier0[1] == '-'); byte[] qualifier1 = CellUtil.cloneQualifier(cells[1]); Assert.assertTrue("qualifier1 should start with b-", qualifier1[0] == 'b' && qualifier1[1] == '-'); table.close(); }