Search in sources :

Example 31 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column in project jaxdb by jaxdb.

the class Generator method declareEnumClass.

private static String declareEnumClass(final String containerClassName, final $Enum column, final int spaces) {
    final String classSimpleName = Identifiers.toClassCase(column.getName$().text());
    final String className = containerClassName + "." + classSimpleName;
    final List<String> names = Dialect.parseEnum(column.getValues$().text());
    final StringBuilder out = new StringBuilder();
    final String s = Strings.repeat(' ', spaces);
    out.append('\n').append(s).append('@').append(EntityEnum.Type.class.getCanonicalName()).append("(\"").append(Dialect.getTypeName(column, null)).append("\")");
    out.append('\n').append(s).append("public static final class ").append(classSimpleName).append(" implements ").append(EntityEnum.class.getName()).append(" {");
    out.append('\n').append(s).append("  private static byte index = 0;");
    out.append('\n').append(s).append("  public static final ").append(className);
    for (int i = 0, len = names.size(); i < len; ++i) {
        out.append(' ').append(enumStringToEnum(names.get(i))).append(',');
    }
    out.setCharAt(out.length() - 1, ';');
    out.append('\n').append(s).append("  private static final ").append(className).append("[] values = {");
    for (int i = 0, len = names.size(); i < len; ++i) {
        final String name = names.get(i);
        out.append(enumStringToEnum(name)).append(" = new ").append(className).append("(\"").append(name).append("\"), ");
    }
    out.setCharAt(out.length() - 2, '}');
    out.setCharAt(out.length() - 1, ';');
    out.append("\n\n").append(s).append("  public static ").append(className).append("[] values() {");
    out.append('\n').append(s).append("    return values;");
    out.append('\n').append(s).append("  }\n");
    out.append('\n').append(s).append("  public static ").append(className).append(" valueOf(final ").append(String.class.getName()).append(" string) {");
    out.append('\n').append(s).append("    if (string == null)");
    out.append('\n').append(s).append("      return null;\n");
    out.append('\n').append(s).append("    for (final ").append(className).append(" value : values())");
    out.append('\n').append(s).append("      if (string.equals(value.name))");
    out.append('\n').append(s).append("        return value;\n");
    out.append('\n').append(s).append("    return null;");
    out.append('\n').append(s).append("  }\n");
    out.append('\n').append(s).append("  private final byte ordinal;");
    out.append('\n').append(s).append("  private final ").append(String.class.getName()).append(" name;\n");
    out.append('\n').append(s).append("  private ").append(classSimpleName).append("(final ").append(String.class.getName()).append(" name) {");
    out.append('\n').append(s).append("    this.ordinal = index++;");
    out.append('\n').append(s).append("    this.name = name;");
    out.append('\n').append(s).append("  }\n");
    out.append('\n').append(s).append("  public byte ordinal() {");
    out.append('\n').append(s).append("    return ordinal;");
    out.append('\n').append(s).append("  }\n");
    out.append('\n').append(s).append("  @").append(Override.class.getName()).append('\n').append(s).append("  public ").append(String.class.getName()).append(" toString() {\n").append(s).append("    return name;\n").append(s).append("  }\n").append(s).append("}");
    return out.toString();
}
Also used : EntityEnum(org.jaxdb.jsql.EntityEnum) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)

Example 32 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column in project YCSB by brianfrankcooper.

the class GoogleBigtableClient method read.

@Override
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
    if (debug) {
        System.out.println("Doing read from Bigtable columnfamily " + new String(columnFamilyBytes));
        System.out.println("Doing read for key: " + key);
    }
    setTable(table);
    RowFilter filter = RowFilter.newBuilder().setFamilyNameRegexFilterBytes(ByteStringer.wrap(columnFamilyBytes)).build();
    if (fields != null && fields.size() > 0) {
        Builder filterChain = RowFilter.Chain.newBuilder();
        filterChain.addFilters(filter);
        filterChain.addFilters(RowFilter.newBuilder().setCellsPerColumnLimitFilter(1).build());
        int count = 0;
        // usually "field#" so pre-alloc
        final StringBuilder regex = new StringBuilder(fields.size() * 6);
        for (final String field : fields) {
            if (count++ > 0) {
                regex.append("|");
            }
            regex.append(field);
        }
        filterChain.addFilters(RowFilter.newBuilder().setColumnQualifierRegexFilter(ByteStringer.wrap(regex.toString().getBytes()))).build();
        filter = RowFilter.newBuilder().setChain(filterChain.build()).build();
    }
    final ReadRowsRequest.Builder rrr = ReadRowsRequest.newBuilder().setTableNameBytes(ByteStringer.wrap(lastTableBytes)).setFilter(filter).setRows(RowSet.newBuilder().addRowKeys(ByteStringer.wrap(key.getBytes())));
    List<Row> rows;
    try {
        rows = client.readRowsAsync(rrr.build()).get();
        if (rows == null || rows.isEmpty()) {
            return Status.NOT_FOUND;
        }
        for (final Row row : rows) {
            for (final Family family : row.getFamiliesList()) {
                if (Arrays.equals(family.getNameBytes().toByteArray(), columnFamilyBytes)) {
                    for (final Column column : family.getColumnsList()) {
                        // we should only have a single cell per column
                        result.put(column.getQualifier().toString(UTF8_CHARSET), new ByteArrayByteIterator(column.getCells(0).getValue().toByteArray()));
                        if (debug) {
                            System.out.println("Result for field: " + column.getQualifier().toString(UTF8_CHARSET) + " is: " + column.getCells(0).getValue().toString(UTF8_CHARSET));
                        }
                    }
                }
            }
        }
        return Status.OK;
    } catch (InterruptedException e) {
        System.err.println("Interrupted during get: " + e);
        Thread.currentThread().interrupt();
        return Status.ERROR;
    } catch (ExecutionException e) {
        System.err.println("Exception during get: " + e);
        return Status.ERROR;
    }
}
Also used : Builder(com.google.bigtable.v2.RowFilter.Chain.Builder) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) ByteString(com.google.protobuf.ByteString) ByteArrayByteIterator(site.ycsb.ByteArrayByteIterator) RowFilter(com.google.bigtable.v2.RowFilter) Column(com.google.bigtable.v2.Column) Family(com.google.bigtable.v2.Family) Row(com.google.bigtable.v2.Row) DeleteFromRow(com.google.bigtable.v2.Mutation.DeleteFromRow) ExecutionException(java.util.concurrent.ExecutionException)

Example 33 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column in project simple-bigtable by spotify.

the class CellsReadImplTest method testParentDataTypeToDataType.

@Test
public void testParentDataTypeToDataType() throws Exception {
    assertEquals(Lists.newArrayList(), cellsRead.parentTypeToCurrentType().apply(Optional.empty()));
    assertEquals(Lists.newArrayList(), cellsRead.parentTypeToCurrentType().apply(Optional.of(Column.getDefaultInstance())));
    final Cell cell = Cell.getDefaultInstance();
    final Column column = Column.newBuilder().addCells(cell).build();
    assertEquals(ImmutableList.of(cell), cellsRead.parentTypeToCurrentType().apply(Optional.of(column)));
}
Also used : Column(com.google.bigtable.v2.Column) Cell(com.google.bigtable.v2.Cell) Test(org.junit.Test)

Example 34 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column in project molgenis-emx2 by molgenis.

the class TableSort method sortTableByDependency.

public static void sortTableByDependency(List<TableMetadata> tableList) {
    ArrayList<TableMetadata> result = new ArrayList<>();
    ArrayList<TableMetadata> todo = new ArrayList<>(tableList);
    // ensure deterministic order
    todo.sort(new Comparator<TableMetadata>() {

        @Override
        public int compare(TableMetadata o1, TableMetadata o2) {
            return o1.getTableName().compareTo(o2.getTableName());
        }
    });
    while (!todo.isEmpty()) {
        int size = todo.size();
        for (int i = 0; i < todo.size(); i++) {
            TableMetadata current = todo.get(i);
            boolean depends = false;
            for (int j = 0; j < todo.size(); j++) {
                if (current.getInherit() != null && current.getImportSchema() == null && todo.get(j).equals(current.getInheritedTable())) {
                    depends = true;
                    break;
                }
            }
            if (!depends)
                for (Column c : current.getColumns()) {
                    if (c.getRefTableName() != null && !c.isRefback()) {
                        for (int j = 0; j < todo.size(); j++) {
                            if (i != j && (todo.get(j).getTableName().equals(c.getRefTableName()))) {
                                depends = true;
                                break;
                            }
                        }
                    }
                }
            if (!depends) {
                result.add(todo.get(i));
                todo.remove(i);
            }
        }
        // check for circular relationship
        if (size == todo.size()) {
            throw new MolgenisException("circular dependency error: following tables have circular dependency: " + todo.stream().map(TableMetadata::getTableName).collect(Collectors.joining(",")));
        }
    }
    tableList.clear();
    tableList.addAll(result);
}
Also used : TableMetadata(org.molgenis.emx2.TableMetadata) Column(org.molgenis.emx2.Column) ArrayList(java.util.ArrayList) MolgenisException(org.molgenis.emx2.MolgenisException)

Example 35 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column in project molgenis-emx2 by molgenis.

the class EvaluateExpressionsTest method testCheckValidationColumnsSuccess.

@Test
public void testCheckValidationColumnsSuccess() {
    Collection<Column> columns = new ArrayList<>();
    Column column1 = new Column("columnName1");
    column1.setValidation("{columnName2}");
    Column column2 = new Column("columnName2");
    columns.add(column1);
    columns.add(column2);
    checkForMissingVariablesColumns(columns);
}
Also used : Column(org.molgenis.emx2.Column) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column)21 ArrayList (java.util.ArrayList)19 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)16 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)16 HashMap (java.util.HashMap)14 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint)13 List (java.util.List)11 Column (org.molgenis.emx2.Column)11 Column (com.google.bigtable.v2.Column)9 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer)9 Family (com.google.bigtable.v2.Family)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table)8 Test (org.junit.Test)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Named (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Named)7