Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.TableCreateDescriptor


            if (!descriptorJson.has("name")) {
                throw new ResourceException("Name must be included in POST body", BAD_REQUEST.getStatusCode());
            }
            String tableName = descriptorJson.get("name").asText();
            String keyPrefix = null;
            TableCreateDescriptor descriptor = null;
            if (descriptorJson.has("keyPrefix")) {
                keyPrefix = descriptorJson.get("keyPrefix").asText();
            }
            if (descriptorJson.has("splitKeys")) {
                byte[][] splitKeys = TableConfig.parseSplitKeys(null, descriptorJson.get("splitKeys").asText(), keyPrefix);
                descriptor = new TableCreateDescriptor(tableName, splitKeys);
            } else if (descriptorJson.has("numRegions")) {
                byte[][] splitKeys = TableConfig.parseSplitKeys(descriptorJson.get("numRegions").asInt(), null, keyPrefix);
               descriptor = new TableCreateDescriptor(tableName, splitKeys);
            } else {
                descriptor = new TableCreateDescriptor(tableName);
            }
            getRepository(uriInfo).getTableManager().createTable(descriptor);
            return Response.ok().build();
        } catch (Exception e) {
            throw new ResourceException("Error creating table", e, INTERNAL_SERVER_ERROR.getStatusCode());
View Full Code Here


        this.tableFactory = tableFactory;
    }

    @Override
    public RepositoryTable createTable(String tableName) throws InterruptedException, IOException {
        return createTable(new TableCreateDescriptor(tableName));
    }
View Full Code Here

            System.err.println("Region count and split keys cannot be combined, region count will be ignored");
        }

        if (splitKeys != null) {
            byte[][] parsedSplitKeys = TableConfig.parseSplitKeys(null, splitKeys, splitKeyPrefix);
            createDescriptor = new TableCreateDescriptor(tableName, parsedSplitKeys);
        } else if (regionCount != -1) {
            byte[][] parsedSplitKeys = TableConfig.parseSplitKeys(regionCount, null, splitKeyPrefix);
            createDescriptor = new TableCreateDescriptor(tableName, parsedSplitKeys);
        } else {
            createDescriptor = new TableCreateDescriptor(tableName);
        }
        return 0;
    }
View Full Code Here

            for (int i = 0; i < avroSplitKeys.size(); i++) {
                splitKeys[i] = asArray(avroSplitKeys.get(i));
            }
        }

        return new TableCreateDescriptor(name, splitKeys);
    }
View Full Code Here

public class TableCreateDescriptorTest {

    @Test
    public void testCreateInstance_OnlyName() {
        TableCreateDescriptor descriptor = new TableCreateDescriptor("mytable");
        assertEquals("mytable", descriptor.getName());
        assertNull(descriptor.getSplitKeys());
    }
View Full Code Here

    }

    @Test
    public void testCreateInstanceWithSplits_NoPrefix() {
        byte[][] splitKeys = TableConfig.parseSplitKeys(null, "04,08", null);
        TableCreateDescriptor descriptor = new TableCreateDescriptor("mytable", splitKeys);
        assertEquals(2, descriptor.getSplitKeys().length);
    }
View Full Code Here

    }

    @Test
    public void testCreateInstanceWithSplits_WithPrefix() {
        byte[][] inputSplitKeys = TableConfig.parseSplitKeys(null, "04,08,12", "\\x01");
        TableCreateDescriptor descriptor = new TableCreateDescriptor("mytable", inputSplitKeys);

        byte[][] splitKeys = descriptor.getSplitKeys();
        assertEquals(3, splitKeys.length);

    }
View Full Code Here

    }

    @Test
    public void testCreateInstance_NoPrefix() {
        byte[][] splitKeys = TableConfig.parseSplitKeys(3, null, null);
        TableCreateDescriptor descriptor = new TableCreateDescriptor("mytable", splitKeys);
        assertEquals(2, descriptor.getSplitKeys().length);
    }
View Full Code Here

    }

    @Test
    public void testCreateInstance_WithPrefix() {
        byte[][] inputSplitKeys = TableConfig.parseSplitKeys(3, null, "\\x01");
        TableCreateDescriptor descriptor = new TableCreateDescriptor("mytable", inputSplitKeys);
        byte[][] splitKeys = descriptor.getSplitKeys();
        assertEquals(2, descriptor.getSplitKeys().length);
        assertEquals(1, splitKeys[0][0]);
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.TableCreateDescriptor

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.