BindingHashShardingFunction { public static Bytes addShard(String nodeId, VariableOrder varOrder, VisibilityBindingSet bs) { checkNotNull(nodeId); checkNotNull(varOrder); checkNotNull(bs); String[] rowPrefixAndId = nodeId.split("_"); Preconditions.checkArgument(rowPrefixAndId.length == 2); String prefix = rowPrefixAndId[0]; String id = rowPrefixAndId[1]; String firstBindingString = ""; Bytes rowSuffix = Bytes.of(id); if (varOrder.getVariableOrders().size() > 0) { VariableOrder first = new VariableOrder(varOrder.getVariableOrders().get(0)); firstBindingString = BS_CONVERTER.convert(bs, first); rowSuffix = RowKeyUtil.makeRowKey(id, varOrder, bs); } BytesBuilder builder = Bytes.builder(); builder.append(Bytes.of(prefix + ":")); builder.append(genHash(Bytes.of(id + NODEID_BS_DELIM + firstBindingString))); builder.append(":"); builder.append(rowSuffix); return builder.toBytes(); }  static Bytes addShard(String nodeId, VariableOrder varOrder, VisibilityBindingSet bs); static Bytes getShardedScanPrefix(String nodeId, Value firstBsVal); static Bytes getShardedScanPrefix(String nodeId, String bindingString); static Bytes removeHash(Bytes prefixBytes, Bytes row);  }
@Test public void bindingSetRowTest() { String nodeId = NodeType.generateNewFluoIdForType(NodeType.STATEMENT_PATTERN); QueryBindingSet bs = new QueryBindingSet(); bs.addBinding("entity", VF.createIRI("urn:entity")); bs.addBinding("location", VF.createLiteral("location_1")); VisibilityBindingSet vBs = new VisibilityBindingSet(bs); VariableOrder varOrder = new VariableOrder("entity","location"); Bytes row = RowKeyUtil.makeRowKey(nodeId, varOrder, vBs); Bytes shardedRow = BindingHashShardingFunction.addShard(nodeId, varOrder, vBs); BindingSetRow expected = BindingSetRow.make(row); BindingSetRow actual = BindingSetRow.makeFromShardedRow(Bytes.of(SP_PREFIX), shardedRow); Assert.assertEquals(expected, actual); }