Package com.nearinfinity.honeycomb.mysql

Examples of com.nearinfinity.honeycomb.mysql.QueryKey


                                .build()),
                ImmutableList.<IndexSchema>of());
    }

    private QueryKey getQueryKey() {
        return new QueryKey("i1", QueryType.AFTER_KEY, ImmutableMap.<String, ByteBuffer>of());
    }
View Full Code Here


            return builder.withSortOrder(order.next()).build();
        }

        public Pair<IndexRowKey, QueryKey> nextWithQueryKey() {
            QueryKey queryKey = queryKeys.next();
            IndexRowKey rowKey = IndexRowKeyBuilder
                    .newBuilder(tableIds.next(), indexIds.next())
                    .withQueryKey(queryKey, tableSchema)
                    .withSortOrder(order.next())
                    .build();
View Full Code Here

        HashMap<String, ByteBuffer> keys = Maps.newHashMap();
        keys.put(TestConstants.COLUMN1, ITUtils.encodeValue(INDEX_COL_VALUE));
        keys.put(TestConstants.COLUMN2, null);

        final QueryKey key = new QueryKey(TestConstants.INDEX2, QueryType.EXACT_KEY, keys);

        ITUtils.assertReceivingDifferentRows(proxy, key, ROW_COUNT);
    }
View Full Code Here

        row.getRecords().put(TestConstants.COLUMN2, ITUtils.encodeValue(2)); // update t1 set c2=2 where c1 is null
        proxy.updateRow(nextRow, row.serialize());

        Map<String, ByteBuffer> searchMap = Maps.newHashMap();
        searchMap.put(TestConstants.COLUMN1, null);
        QueryKey key = new QueryKey(TestConstants.INDEX1, QueryType.EXACT_KEY, searchMap);
        proxy.startIndexScan(key.serialize());
        Row result = Row.deserialize(proxy.getNextRow());
        assertEquals(result.getRecords().get(TestConstants.COLUMN2).getLong(), ITUtils.encodeValue(2).getLong());
        proxy.endScan();
    }
View Full Code Here

     * @return The constructed index with the provided details
     */
    public static QueryKey createKey(final int keyValue, final QueryType queryType) {
        HashMap<String, ByteBuffer> keys = Maps.newHashMap();
        keys.put(TestConstants.COLUMN1, encodeValue(keyValue));
        return new QueryKey(TestConstants.INDEX1, queryType, keys);
    }
View Full Code Here

        proxy.startTableScan();
        assertResultCount(proxy, expectedRowCount);
        proxy.endScan();

        QueryKey queryKey;
        for(IndexSchema indexSchema : schema.getIndices()) {
            queryKey = new QueryKey(indexSchema.getIndexName(),
                    QueryType.INDEX_FIRST, ImmutableMap.<String, ByteBuffer>of());
            proxy.startIndexScan(queryKey.serialize());
            assertResultCount(proxy, expectedRowCount);
            proxy.endScan();

            queryKey = new QueryKey(indexSchema.getIndexName(),
                    QueryType.INDEX_LAST, ImmutableMap.<String, ByteBuffer>of());
            proxy.startIndexScan(queryKey.serialize());
            assertResultCount(proxy, expectedRowCount);
            proxy.endScan();
        }
    }
View Full Code Here

        // Add the new index to the table
        proxy.addIndex(NEW_INDEX_NAME, indexSchema.serialize());

        // Perform a scan with the new index

        final QueryKey key = new QueryKey(NEW_INDEX_NAME, QueryType.EXACT_KEY,
                ImmutableMap.<String, ByteBuffer>of(TestConstants.COLUMN1, ITUtils.encodeValue(INDEX_COL_VALUE)));

        ITUtils.assertReceivingDifferentRows(proxy, key, ROW_COUNT);
    }
View Full Code Here

        // Add the new index to the table
        proxy.addIndex(NEW_INDEX_NAME, indexSchema.serialize());

        // Perform a scan with the new index

        final QueryKey key = new QueryKey(NEW_INDEX_NAME, QueryType.EXACT_KEY,
                ImmutableMap.<String, ByteBuffer>of(TestConstants.COLUMN1, ITUtils.encodeValue(INDEX_COL_VALUE),
                        TestConstants.COLUMN2, ITUtils.encodeValue(column2Value)));

        ITUtils.assertReceivingDifferentRows(proxy, key, ROW_COUNT);
    }
View Full Code Here

    }

    @Test(expected = NullPointerException.class)
    public void testDropIndex() {
        final int keyValue = 7;
        final QueryKey key = ITUtils.createKey(keyValue, QueryType.EXACT_KEY);

        // Add data rows to index
        ITUtils.insertData(proxy, ROW_COUNT, keyValue);

        // Verify that we can get a row from the index scan
        proxy.startIndexScan(key.serialize());
        final Row row = Row.deserialize(proxy.getNextRow());
        byte[] result = proxy.getRow(Util.UUIDToBytes(row.getUUID()));

        assertNotNull(row);
        assertEquals(Row.deserialize(result).getUUID(), row.getUUID());

        proxy.endScan();

        // Drop the index from the table
        proxy.dropIndex(TestConstants.INDEX1);

        // Verify that the data row is still available after the index has been removed
        result = proxy.getRow(Util.UUIDToBytes(row.getUUID()));
        assertEquals(Row.deserialize(result).getUUID(), row.getUUID());

        // Verify that the scan is unable to execute
        proxy.startIndexScan(key.serialize());
    }
View Full Code Here

    @Test
    public void testGetRow() {
        ITUtils.insertData(proxy, ROW_COUNT, INDEX_COL_VALUE);

        final QueryKey key = ITUtils.createKey(INDEX_COL_VALUE, QueryType.EXACT_KEY);
        proxy.startIndexScan(key.serialize());

        final Row r = Row.deserialize(proxy.getNextRow());
        final byte[] result = proxy.getRow(Util.UUIDToBytes(r.getUUID()));

        assertNotNull(result);
View Full Code Here

TOP

Related Classes of com.nearinfinity.honeycomb.mysql.QueryKey

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.