Examples of TMutation


Examples of kr.co.vcnc.haeinsa.thrift.generated.TMutation

        }
    }

    @Override
    public TMutation toTMutation() {
        TMutation newTMutation = new TMutation(TMutationType.REMOVE);
        TRemove newTRemove = new TRemove();
        for (HaeinsaKeyValue kv : Iterables.concat(familyMap.values())) {
            switch (kv.getType()) {
            case DeleteColumn: {
                newTRemove.addToRemoveCells(new TCellKey().setFamily(kv.getFamily()).setQualifier(kv.getQualifier()));
                break;
            }
            case DeleteFamily: {
                newTRemove.addToRemoveFamilies(ByteBuffer.wrap(kv.getFamily()));
                break;
            }
            default:
                break;
            }
        }
        newTMutation.setRemove(newTRemove);
        return newTMutation;
    }
View Full Code Here

Examples of kr.co.vcnc.haeinsa.thrift.generated.TMutation

        for (int i = 0; i < remaining.size(); i++) {
            byte[] currentRowLockBytes = TRowLocks.serialize(rowTxState.getCurrent());
            int mutationOffset = i + 1;
            long mutationTimestamp = currentTimestamp + mutationOffset;

            TMutation mutation = remaining.get(i);
            switch (mutation.getType()) {
            case PUT: {
                TRowLock newRowLock = rowTxState.getCurrent().deepCopy();
                newRowLock.setCurrentTimestamp(mutationTimestamp);
                newRowLock.setMutations(remaining.subList(mutationOffset, remaining.size()));
                // Maintain prewritten state and extend lock by ROW_LOCK_TIMEOUT
                newRowLock.setExpiry(tx.getExpiry());
                Put put = new Put(row);
                put.add(LOCK_FAMILY, LOCK_QUALIFIER, newRowLock.getCurrentTimestamp(), TRowLocks.serialize(newRowLock));
                for (TKeyValue kv : mutation.getPut().getValues()) {
                    put.add(kv.getKey().getFamily(), kv.getKey().getQualifier(), newRowLock.getCurrentTimestamp(), kv.getValue());
                }
                if (!table.checkAndPut(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, put)) {
                    // Consider as conflict because another transaction might acquire lock of this row.
                    throw new ConflictException("can't acquire row's lock");
                } else {
                    rowTxState.setCurrent(newRowLock);
                }
                break;
            }
            case REMOVE: {
                Delete delete = new Delete(row);
                if (mutation.getRemove().getRemoveFamiliesSize() > 0) {
                    for (ByteBuffer removeFamily : mutation.getRemove().getRemoveFamilies()) {
                        delete.deleteFamily(removeFamily.array(), mutationTimestamp);
                    }
                }
                if (mutation.getRemove().getRemoveCellsSize() > 0) {
                    for (TCellKey removeCell : mutation.getRemove().getRemoveCells()) {
                        delete.deleteColumns(removeCell.getFamily(), removeCell.getQualifier(), mutationTimestamp);
                    }
                }
                if (!table.checkAndDelete(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, delete)) {
                    // Consider as conflict because another transaction might acquire lock of this row.
View Full Code Here

Examples of kr.co.vcnc.haeinsa.thrift.generated.TMutation

        }
    }

    @Override
    public TMutation toTMutation() {
        TMutation newTMutation = new TMutation();
        newTMutation.setType(TMutationType.PUT);
        TPut newTPut = new TPut();
        for (HaeinsaKeyValue kv : Iterables.concat(familyMap.values())) {
            TKeyValue newTKV = new TKeyValue();
            newTKV.setKey(new TCellKey().setFamily(kv.getFamily()).setQualifier(kv.getQualifier()));
            newTKV.setValue(kv.getValue());
            newTPut.addToValues(newTKV);
        }
        newTMutation.setPut(newTPut);
        return newTMutation;
    }
View Full Code Here

Examples of org.apache.accumulo.core.data.thrift.TMutation

    return false;
  }
 
  public TMutation toThrift() {
    serialize();
    return new TMutation(java.nio.ByteBuffer.wrap(row), java.nio.ByteBuffer.wrap(data), ByteBufferUtil.toByteBuffers(values), entries);
  }
View Full Code Here

Examples of org.apache.accumulo.core.data.thrift.TMutation

  @Test
  public void testThrift() {
    Mutation m1 = new Mutation("r1");
    m1.put("cf1", "cq1", "v1");
    TMutation tm1 = m1.toThrift();
    Mutation m2 = new Mutation(tm1);
    assertEquals(m1, m2);
  }
View Full Code Here

Examples of org.apache.accumulo.core.data.thrift.TMutation

 
  @Test(expected=IllegalArgumentException.class)
  public void testThrift_Invalid() {
    Mutation m1 = new Mutation("r1");
    m1.put("cf1", "cq1", "v1");
    TMutation tm1 = m1.toThrift();
    tm1.setRow((byte[]) null);
    new Mutation(tm1);
  }
View Full Code Here

Examples of org.apache.accumulo.core.data.thrift.TMutation

    return false;
  }
 
  public TMutation toThrift() {
    serialize();
    return new TMutation(java.nio.ByteBuffer.wrap(row), java.nio.ByteBuffer.wrap(data), ByteBufferUtil.toByteBuffers(values), entries);
  }
View Full Code Here

Examples of org.apache.accumulo.core.data.thrift.TMutation

    return false;
  }
 
  public TMutation toThrift() {
    serialize();
    return new TMutation(java.nio.ByteBuffer.wrap(row), java.nio.ByteBuffer.wrap(data), ByteBufferUtil.toByteBuffers(values), entries);
  }
View Full Code Here

Examples of org.apache.accumulo.core.data.thrift.TMutation

  @Test
  public void testThrift() {
    Mutation m1 = new Mutation("r1");
    m1.put("cf1", "cq1", "v1");
    TMutation tm1 = m1.toThrift();
    Mutation m2 = new Mutation(tm1);
    assertEquals(m1, m2);
  }
View Full Code Here

Examples of org.apache.accumulo.core.data.thrift.TMutation

  }
  @Test(expected=IllegalArgumentException.class)
  public void testThrift_Invalid() {
    Mutation m1 = new Mutation("r1");
    m1.put("cf1", "cq1", "v1");
    TMutation tm1 = m1.toThrift();
    tm1.setRow((byte[]) null);
    new Mutation(tm1);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.