Package com.persistit

Examples of com.persistit.Key


                                    ForeignKey foreignKey, List<Column> columns,
                                    String operation) {
        if (!compareSelfReference(row, foreignKey)) {
            Index index = foreignKey.getReferencedIndex();
            SDType storeData = (SDType)store.createStoreData(session, index);
            Key key = store.getKey(session, storeData);
            try {
                boolean anyNull = crossReferenceKey(session, key, row, columns);
                if (!anyNull) {
                    assert index.isUnique();
                    checkReferencing(session, index, storeData, row, foreignKey, operation);
View Full Code Here


    protected void checkNotReferenced(Session session, RowData row,
                                      ForeignKey foreignKey, List<Column> columns,
                                      ForeignKey.Action action, String operation) {
        Index index = foreignKey.getReferencingIndex();
        SDType storeData = (SDType)store.createStoreData(session, index);
        Key key = store.getKey(session, storeData);
        try {
            boolean anyNull = crossReferenceKey(session, key, row, columns);
            if (!anyNull) {
                checkNotReferenced(session, index, storeData, row, foreignKey,
                                   compareSelfReference(row, foreignKey), action, operation);
View Full Code Here

    @SuppressWarnings("unchecked")
    protected void stillReferenced(Session session, Index index, SDType storeData,
                                   RowData row, ForeignKey foreignKey, String operation) {
        String key;
        if (row == null) {
            Key foundKey = store.getKey(session, storeData);
            key = formatKey(session, index, foundKey, foreignKey.getReferencedColumns(), foreignKey.getReferencingColumns());
        }
        else {
            key = formatKey(session, row, foreignKey.getReferencedColumns());
        }
View Full Code Here

        List<Object> keyList = new ArrayList<>();
        extractKeySegments(key, keyList);
        // Value traversal. If the value is defined, then it contains more fields encoded like a key.
        // TODO: What about group indexes?
        if (!groupIndex() && value.isDefined()) {
            Key buffer = new Key(key);
            buffer.clear();
            value.getByteArray(buffer.getEncodedBytes(), 0, 0, value.getArrayLength());
            buffer.setEncodedSize(value.getArrayLength());
            extractKeySegments(buffer, keyList);
        }
        return keyList;
    }
View Full Code Here

        assertTrue (!key.prefixOf(itemKey));
    }

    @Test
    public void copyFromKeyCustomer () {
        Key key = new Key (null, 2047);
        key.append(ordinal("customer"));
        key.append(42L);
       
        ValuesHKey customerKey = createHKey("customer");
        customerKey.copyFrom(key);
       
        assertEquals(customerKey.valueAt(0).getInt32(), 42);
View Full Code Here

        assertEquals (customerKey.values.size(), 1);
    }
   
    @Test
    public void copyFromKeyOrder () {
        Key key = new Key (null, 2047);
        key.append(ordinal("customer"));
        key.append(42L);
        key.append(ordinal("order"));
        key.append(51L);
       
        ValuesHKey orderKey = createHKey("order");
        orderKey.copyFrom(key);
       
        assertEquals (orderKey.segments(), 2);
View Full Code Here

    }

   
    @Test
    public void copyFromKeyItem () {
        Key key = new Key (null, 2047);
        key.append(ordinal("customer"));
        key.append(42L);
        key.append(ordinal("order"));
        key.append(51L);
        key.append(ordinal("item"));
        key.append(99L);
       
        ValuesHKey itemKey = createHKey("item");
        itemKey.copyFrom(key);
       
        assertEquals (itemKey.segments(), 3);
View Full Code Here

    @Test
    public void copyToKeyCustomer() {
        ValuesHKey customerKey = createHKey("customer");
        customerKey.valueAt(0).putInt32(42);

        Key key = new Key (null, 2047);
        customerKey.copyTo(key);
       
        key.indexTo(0);
        assertEquals (key.decodeInt(), ordinal("customer"));
        assertEquals (key.decodeLong(), 42);
    }
View Full Code Here

    public void copyToKeyItem() {
        ValuesHKey key = createHKey("item");
        key.valueAt(0).putInt32(42);
        key.valueAt(1).putInt32(51);

        Key target = new Key (null, 2047);
        key.copyTo(target);
       
        target.indexTo(0);
        assertEquals(target.decodeInt(), ordinal("customer"));
        assertEquals(target.decodeLong(), 42);
        assertEquals(target.decodeInt(), ordinal("order"));
        assertEquals(target.decodeLong(), 51);
        assertEquals(target.decodeInt(), ordinal("item"));
    }
View Full Code Here

        return compareOneKeySegment(that.key.getEncodedBytes(), thatPosition, thatEnd);
    }

    public int compare(byte[] bytes)
    {
        Key thatKey = new Key(key);
        thatKey.clear();
        thatKey.append(bytes);
        thatKey.indexTo(0);
        int thatPosition = thatKey.getIndex();
        thatKey.indexTo(1);
        int thatEnd = thatKey.getIndex();
        return compareOneKeySegment(thatKey.getEncodedBytes(), thatPosition, thatEnd);
    }
View Full Code Here

TOP

Related Classes of com.persistit.Key

Copyright © 2018 www.massapicom. 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.