@Override public Iterator<Result> write(Iterator<ConditionalMutation> mutations) { BlockingQueue<Result> resultQueue = new LinkedBlockingQueue<>(); List<QCMutation> mutationList = new ArrayList<>(); int count = 0; long entryTime = System.currentTimeMillis(); mloop: while (mutations.hasNext()) { ConditionalMutation mut = mutations.next(); count++; if (mut.getConditions().size() == 0) throw new IllegalArgumentException( "ConditionalMutation had no conditions " + new String(mut.getRow(), UTF_8)); for (Condition cond : mut.getConditions()) { if (!isVisible(cond.getVisibility())) { resultQueue.add(new Result(Status.INVISIBLE_VISIBILITY, mut, null)); continue mloop; } } // copy the mutations so that even if caller changes it, it will not matter mutationList.add(new QCMutation(mut, resultQueue, entryTime)); } queue(mutationList); return new RQIterator(resultQueue, count); }
private List<TCondition> convertConditions(ConditionalMutation cm, CompressedIterators compressedIters) { List<TCondition> conditions = new ArrayList<>(cm.getConditions().size()); // sort conditions inorder to get better lookup performance. Sort on client side so tserver does // not have to do it. Condition[] ca = cm.getConditions().toArray(new Condition[cm.getConditions().size()]); Arrays.sort(ca, CONDITION_COMPARATOR); for (Condition cond : ca) { long ts = 0; boolean hasTs = false; if (cond.getTimestamp() != null) { ts = cond.getTimestamp(); hasTs = true; } ByteBuffer iters = compressedIters.compress(cond.getIterators()); TCondition tc = new TCondition(ByteBufferUtil.toByteBuffers(cond.getFamily()), ByteBufferUtil.toByteBuffers(cond.getQualifier()), ByteBufferUtil.toByteBuffers(cond.getVisibility()), ts, hasTs, ByteBufferUtil.toByteBuffers(cond.getValue()), iters); conditions.add(tc); } return conditions; }
@Override public Iterator<Result> write(Iterator<ConditionalMutation> mutations) { BlockingQueue<Result> resultQueue = new LinkedBlockingQueue<>(); List<QCMutation> mutationList = new ArrayList<>(); int count = 0; long entryTime = System.currentTimeMillis(); mloop: while (mutations.hasNext()) { ConditionalMutation mut = mutations.next(); count++; if (mut.getConditions().size() == 0) throw new IllegalArgumentException( "ConditionalMutation had no conditions " + new String(mut.getRow(), UTF_8)); for (Condition cond : mut.getConditions()) { if (!isVisible(cond.getVisibility())) { resultQueue.add(new Result(Status.INVISIBLE_VISIBILITY, mut, null)); continue mloop; } } // copy the mutations so that even if caller changes it, it will not matter mutationList.add(new QCMutation(mut, resultQueue, entryTime)); } queue(mutationList); return new RQIterator(resultQueue, count); }
@Override public int compare(Condition c1, Condition c2) { int comp = c1.getFamily().compareTo(c2.getFamily()); if (comp == 0) { comp = c1.getQualifier().compareTo(c2.getQualifier()); if (comp == 0) { comp = c1.getVisibility().compareTo(c2.getVisibility()); if (comp == 0) { Long l1 = c1.getTimestamp(); Long l2 = c2.getTimestamp(); if (l1 == null) { l1 = MAX; } if (l2 == null) { l2 = MAX; } comp = l2.compareTo(l1); } } } return comp; } }
private List<TCondition> convertConditions(ConditionalMutation cm, CompressedIterators compressedIters) { List<TCondition> conditions = new ArrayList<>(cm.getConditions().size()); // sort conditions inorder to get better lookup performance. Sort on client side so tserver does // not have to do it. Condition[] ca = cm.getConditions().toArray(new Condition[cm.getConditions().size()]); Arrays.sort(ca, CONDITION_COMPARATOR); for (Condition cond : ca) { long ts = 0; boolean hasTs = false; if (cond.getTimestamp() != null) { ts = cond.getTimestamp(); hasTs = true; } ByteBuffer iters = compressedIters.compress(cond.getIterators()); TCondition tc = new TCondition(ByteBufferUtil.toByteBuffers(cond.getFamily()), ByteBufferUtil.toByteBuffers(cond.getQualifier()), ByteBufferUtil.toByteBuffers(cond.getVisibility()), ts, hasTs, ByteBufferUtil.toByteBuffers(cond.getValue()), iters); conditions.add(tc); } return conditions; }