Package com.persistit

Examples of com.persistit.Key


    @Test
    public void testCopyFromItem() {
        Table items = ais.getTable("Test", CAOIBuilderFiller.ITEM_TABLE);
        FDBIndexRow row = new FDBIndexRow (testCreator, itemPK);
       
        Key pkKey = testCreator.createKey();
        pkKey.append(15L);
        pkKey.append(7L);
        pkKey.append(5L);
        row.copyFrom (pkKey, null);
        HKey hkey = row.ancestorHKey(items);
       
        assertNotNull (hkey);
        assertEquals(hkey.value(0).getInt64(), 7L);
View Full Code Here


        AkCollator caseInsensitiveCollator = AkCollatorFactory.getAkCollator("sv_se_ci");
        AkCollator binaryCollator = AkCollatorFactory.getAkCollator(AkCollatorFactory.UCS_BINARY);
        PersistitKeyValueSource source = new PersistitKeyValueSource(MString.VARCHAR.instance(true));
        long hash_AB;
        long hash_ab;
        Key key = store().createKey();
        {
            binaryCollator.append(key.clear(), "AB");
            source.attach(key, 0, MString.VARCHAR.instance(true));
            hash_AB = ValueSources.hash(source, binaryCollator);
            binaryCollator.append(key.clear(), "ab");
            source.attach(key, 0, MString.VARCHAR.instance(true));
            hash_ab = ValueSources.hash(source, binaryCollator);
            assertTrue(hash_AB != hash_ab);
        }
        {
            caseInsensitiveCollator.append(key.clear(), "AB");
            source.attach(key, 0, MString.VARCHAR.instance(true));
            hash_AB = ValueSources.hash(source, caseInsensitiveCollator);
            caseInsensitiveCollator.append(key.clear(), "ab");
            source.attach(key, 0, MString.VARCHAR.instance(true));
            hash_ab = ValueSources.hash(source, caseInsensitiveCollator);
            assertTrue(hash_AB == hash_ab);
        }
    }
View Full Code Here

        }
    }

    public static RowDef rowDefFromOrdinals(Group group, FDBStoreData storeData) {
        Table root = group.getRoot();
        Key hkey = storeData.persistitKey;
        hkey.reset();
        int ordinal = hkey.decodeInt();
        assert (root.getOrdinal() == ordinal) : hkey;
        Table table = root;
        int index = 0;
        while (true) {
            int[] keyDepth = table.hKey().keyDepth();
            index = keyDepth[keyDepth.length - 1];
            if (index >= hkey.getDepth()) {
                return table.rowDef();
            }
            hkey.indexTo(index);
            ordinal = hkey.decodeInt();
            boolean found = false;
            for (Join join : table.getChildJoins()) {
                table = join.getChild();
                if (table.getOrdinal() == ordinal) {
                    found = true;
View Full Code Here

    /* Allocate a new <code>HKey</code> and copy the given
     * key bytes into it. */
    protected Row toHkeyRow(String encoded) {
        HKey hkey = context.getStore().newHKey(rowType.hKey());
        Key key = context.getStore().createKey();
        byte decodedBytes[] = RowIndexer.decodeString(encoded);
        key.setEncodedSize(decodedBytes.length);
        System.arraycopy(decodedBytes, 0, key.getEncodedBytes(), 0, decodedBytes.length);
        hkey.copyFrom(key);
        return (Row)(ValuesHKey)hkey;
    }
View Full Code Here

        return keys.size();
    }

    @Override
    public List<? extends Key> split(Key keyToSample) {
        Key prev = keyToSample;
        for (int i = keys.size() ; i > 0; i--) {
            Key truncatedKey = keysFlywheel.get();
            prev.copyTo(truncatedKey);
            truncatedKey.setDepth(i);
            keys.set(i-1 , truncatedKey);
            prev = truncatedKey;
        }
        return keys;
    }
View Full Code Here

            currentDocument = null;
        }
    }

    protected void getKeyBytes(Row row) {
        Key key = new Key (null, 2047);
        row.hKey().copyTo(key);
        keyEncodedString = encodeBytes(key.getEncodedBytes(), 0, key.getEncodedSize());
        Field field = new StringField(IndexedField.KEY_FIELD, keyEncodedString, Store.YES);
        currentDocument.add(field);
    }
View Full Code Here

        List<HistogramEntry> entries = new ArrayList<>();
        for (Object eobj : (Iterable)obj) {
            if (!(eobj instanceof Map))
                throw new AkibanInternalException("Entry not in expected format");
            Map<?,?> emap = (Map<?,?>)eobj;
            Key key = encodeKey(index, firstColumn, columnCount,
                                (List<?>)emap.get(HISTOGRAM_KEY_ARRAY_KEY));
            String keyString = key.toString();
            byte[] keyBytes = new byte[key.getEncodedSize()];
            System.arraycopy(key.getEncodedBytes(), 0, keyBytes, 0, keyBytes.length);
            int eqCount = (Integer)emap.get(HISTOGRAM_EQUAL_COUNT_KEY);
            int ltCount = (Integer)emap.get(HISTOGRAM_LESS_COUNT_KEY);
            int distinctCount = (Integer)emap.get(HISTOGRAM_DISTINCT_COUNT_KEY);
            entries.add(new HistogramEntry(keyString, keyBytes,
                                           eqCount, ltCount, distinctCount));
View Full Code Here

    }

    private Row toHKeyRow(byte rowBytes[], HKeyRowType hKeyRowType, StoreAdapter store)
    {
        HKey hkey = store.newHKey(hKeyRowType.hKey());
        Key key = store.createKey();
       
        key.setEncodedSize(rowBytes.length);
        System.arraycopy(rowBytes, 0, key.getEncodedBytes(), 0, rowBytes.length);
       
        hkey.copyFrom(key);
       
        if (hkey instanceof ValuesHKey) {
            return ((Row)(ValuesHKey)hkey);
View Full Code Here

    public void visit(Key key, byte[] value) {
        key.indexTo(field);
        extractKey.clear().appendKeySegment(key);
        int[] curCount = countMap.get(extractKey);
        if(curCount == null) {
            Key storedKey = new Key(extractKey);
            curCount = new int[1];
            countMap.put(storedKey, curCount);
        }
        curCount[0] += 1;
        rowCount++;
View Full Code Here

    @Override
    public void copyFrom(Key key, Value value)
    {
        super.copyFrom(key, value);
        Key hKey = keyCreator.createKey();
        constructHKeyFromIndexKey(hKey, indexToHKey());
        hKeyCache.hKey(leafmostTable).copyFrom(hKey);
    }
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.