Package com.splout.db.hadoop.TableSpec

Examples of com.splout.db.hadoop.TableSpec.FieldIndex


        throw new IllegalArgumentException("Partition field not contained in input schema: " + partitionField);
      }
      fields.add(field);
    }
    Field[] partitionByFields = fields.toArray(new Field[0]);
    partitionedTables.add(new Table(new TableInput(inputFormat, new HashMap<String, String>(), schema, new IdentityRecordProcessor(), input), new TableSpec(schema, partitionByFields, new FieldIndex[] { new FieldIndex(partitionByFields) },null, null, null, null, null)));
    TablespaceSpec tablespace = new TablespaceSpec(partitionedTables, new ArrayList<Table>(), nPartitions, null, SploutEngine.getDefault());
    return tablespace;
  }
View Full Code Here


      Field field1 = schema.getField(fieldToIndex);
      if(field1 == null) {
        throw new TableBuilderException("Invalid field to index: " + fieldToIndex
            + " not present in specified Schema: " + schema + ".");
      }
      indexes.add(new FieldIndex(field1));
    }
    // Also, support for compound indexes
    for(List<String> compoundIndex : compoundIndexes) {
      List<Field> compoundIndexFields = new ArrayList<Field>();
      for(String field : compoundIndex) {
        field = field.trim();
        // Check that each field exists in schema
        Field field2 = schema.getField(field);
        if(field2 == null) {
          throw new TableBuilderException("Invalid compound index: " + compoundIndex + ", field "
              + field + " not present in specified Schema: " + schema + ".");
        }
        compoundIndexFields.add(field2);
      }
      indexes.add(new FieldIndex(compoundIndexFields.toArray(new Field[0])));
    }

    // Schema + indexes = TableSpec
    TableSpec spec;
    FieldIndex[] theIndexes = indexes.toArray(new FieldIndex[0]);
View Full Code Here

  public void testPreSQL() throws Exception {
    final Schema tupleSchema1 = new Schema("schema1", Fields.parse("a:string, b:int"));
    String[] initSQL = new String[] { "init1", "init2" };
    String[] preInsertSQL = new String[] { "CREATE Mytable;", "ME_LO_INVENTO" };
    TableSpec tableSpec = new TableSpec(tupleSchema1, new Field[] { tupleSchema1.getField(0) },
        new FieldIndex[] { new FieldIndex(tupleSchema1.getField(0), tupleSchema1.getField(1)) },
        initSQL, preInsertSQL, null, null, null);
    String[] createTables = new SQLite4JavaOutputFormat(10, tableSpec)
        .getCreateTables(tableSpec);
    assertEquals("init1", createTables[0]);
    assertEquals("init2", createTables[1]);
View Full Code Here

  public void testPostSQL() throws Exception {
    final Schema tupleSchema1 = new Schema("schema1", Fields.parse("a:string, b:int"));
    String[] afterInsertSQL = new String[] { "afterinsert1", "afterinsert2" };
    String[] finalSQL = new String[] { "DROP INDEX idx_schema1_ab", "CREATE INDEX blablabla" };
    TableSpec tableSpec = new TableSpec(tupleSchema1, new Field[] { tupleSchema1.getField(0) },
        new FieldIndex[] { new FieldIndex(tupleSchema1.getField(0), tupleSchema1.getField(1)) }, null,
        null, afterInsertSQL, finalSQL, null);
    String[] createIndex = SploutSQLOutputFormat.getCreateIndexes(tableSpec);
    assertEquals("afterinsert1", createIndex[0]);
    assertEquals("afterinsert2", createIndex[1]);
    assertEquals("CREATE INDEX idx_schema1_ab ON schema1(`a`, `b`);", createIndex[2]);
View Full Code Here

  @Test
  public void testCompoundIndexes() throws Exception {
    final Schema tupleSchema1 = new Schema("schema1", Fields.parse("a:string, b:int"));
    TableSpec tableSpec = new TableSpec(tupleSchema1, new Field[] { tupleSchema1.getField(0) },
        new FieldIndex[] { new FieldIndex(tupleSchema1.getField(0), tupleSchema1.getField(1)) }, null,
        null, null, null, null);
    String[] createIndex = SploutSQLOutputFormat.getCreateIndexes(tableSpec);
    assertEquals("CREATE INDEX idx_schema1_ab ON schema1(`a`, `b`);", createIndex[0]);
  }
View Full Code Here

TOP

Related Classes of com.splout.db.hadoop.TableSpec.FieldIndex

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.