コード例 #1
0
 @Test
 public void testAIS() throws Exception {
   FileDescriptorSet set = null;
   for (File file : files) {
     String sql = fileContents(file);
     runDDL(sql);
     AISToProtobuf ais2p = new AISToProtobuf(ProtobufRowFormat.Type.GROUP_MESSAGE, set);
     for (Group group : ais().getGroups().values()) {
       if (group.getName().getSchemaName().equals(SCHEMA)) {
         ais2p.addGroup(group);
       }
     }
     set = ais2p.build();
     StringBuilder proto = new StringBuilder();
     new ProtobufDecompiler(proto).decompile(set);
     String actual = proto.toString();
     String expected = null;
     File expectedFile = changeSuffix(file, ".proto");
     if (expectedFile.exists()) {
       expected = fileContents(expectedFile);
     }
     String fullCaseName = file.getName().replace("\\.sql$", "");
     if (expected == null) {
       fail(fullCaseName + " no expected result given. actual='" + actual + "'");
     } else {
       assertEqualsWithoutPattern(fullCaseName, expected, actual, UUID_REGEX);
     }
   }
 }
コード例 #2
0
 @Override
 public void open() {
   String currentSchema = context.getCurrentSchema();
   String schemaName, tableName;
   ValueSource value = valueNotNull(0);
   if (value == null) schemaName = currentSchema;
   else schemaName = value.getString();
   tableName = bindings.getValue(1).getString();
   TableName groupName = new TableName(schemaName, tableName);
   Group group = context.getStore().schema().ais().getGroup(groupName);
   if (group == null) throw new NoSuchGroupException(groupName);
   StorageDescription storage = group.getStorageDescription();
   if (!(storage instanceof ProtobufStorageDescription))
     throw new InvalidParameterValueException("group does not use STORAGE_FORMAT protobuf");
   FileDescriptorProto fileProto = ((ProtobufStorageDescription) storage).getFileProto();
   try {
     tempFile = File.createTempFile("group", ".proto");
     try (FileWriter writer = new FileWriter(tempFile)) {
       new ProtobufDecompiler(writer).decompile(fileProto);
     }
     reader = new BufferedReader(new FileReader(tempFile));
   } catch (IOException ex) {
     throw new AkibanInternalException("decompiling error", ex);
   }
   messagesSent = 0;
 }