/** * make the hbase filter for selecting values of y-axis(response time) in order to select * transactions in scatter chart. 4 bytes for elapsed time should be attached for the prefix of * column qualifier for to use this filter. * * @param area * @param offsetTransactionId * @param offsetTransactionElapsed * @return */ private Filter makeResponseTimeFilter( final SelectedScatterArea area, final TransactionId offsetTransactionId, int offsetTransactionElapsed) { // filter by response time ResponseTimeRange responseTimeRange = area.getResponseTimeRange(); byte[] responseFrom = Bytes.toBytes(responseTimeRange.getFrom()); byte[] responseTo = Bytes.toBytes(responseTimeRange.getTo()); FilterList filterList = new FilterList(Operator.MUST_PASS_ALL); filterList.addFilter( new QualifierFilter(CompareOp.GREATER_OR_EQUAL, new BinaryPrefixComparator(responseFrom))); filterList.addFilter( new QualifierFilter(CompareOp.LESS_OR_EQUAL, new BinaryPrefixComparator(responseTo))); // add offset if (offsetTransactionId != null) { final Buffer buffer = new AutomaticBuffer(32); buffer.put(offsetTransactionElapsed); buffer.putPrefixedString(offsetTransactionId.getAgentId()); buffer.putSVar(offsetTransactionId.getAgentStartTime()); buffer.putVar(offsetTransactionId.getTransactionSequence()); byte[] qualifierOffset = buffer.getBuffer(); filterList.addFilter( new QualifierFilter(CompareOp.GREATER, new BinaryPrefixComparator(qualifierOffset))); } return filterList; }
@Test public void diffSeqDesc() { TransactionId id1 = new TransactionId("A1", 1, 2); TransactionId id2 = new TransactionId("A1", 1, 1); Assert.assertEquals(1, id1.compareTo(id2)); }
@Test public void diffAgentStartTimeDesc() { TransactionId id1 = new TransactionId("A1", 2, 1); TransactionId id2 = new TransactionId("A1", 1, 1); Assert.assertEquals(1, id1.compareTo(id2)); }
@Test public void sameAll() { TransactionId id1 = new TransactionId("A1", 1, 1); TransactionId id2 = new TransactionId("A1", 1, 1); Assert.assertEquals(0, id1.compareTo(id2)); }