test_class.file: culvert-main/src/test/java/com/bah/culvert/ClientTest.java
test_class.identifier: ClientTest
test_case.body: @Test
    public void testPut() throws Exception {
      TableAdapter primaryTable = createMock(TableAdapter.class);
  
      Client c = PowerMock.createPartialMock(Client.class, "getIndices",
          "getDatabaseAdapter");
      CKeyValue keyValue = new CKeyValue("rowid".getBytes(), "f".getBytes(),
          "q".getBytes(), "v".getBytes());
      ArrayList<CKeyValue> keyValueList = new ArrayList<CKeyValue>();
      keyValueList.add(keyValue);
  
      // used for main test and for setup
      Put put = new Put(keyValueList);
      Put put2 = new Put(keyValue);
      put.hashCode();
      put2.equals("");
  
      // MOCKING
      // mock out the index
      Index mockIndex = EasyMock.createMock(Index.class);
      EasyMock.expect(c.getIndices()).andReturn(new Index[] { mockIndex });
      EasyMock.expect(mockIndex.getColumnFamily()).andReturn("f".getBytes());
      EasyMock.expect(mockIndex.getColumnQualifier()).andReturn("q".getBytes());
      mockIndex.handlePut(EasyMock.anyObject(Put.class));
  
      // mock out the db
      DatabaseAdapter databaseAdapter = EasyMock
          .createMock(DatabaseAdapter.class);
      EasyMock.expect(databaseAdapter.verify()).andReturn(true);
      PowerMock.expectPrivate(c, "getDatabaseAdapter").andReturn(databaseAdapter);
      EasyMock.expect(databaseAdapter.getTableAdapter("foo")).andReturn(
          primaryTable);
  
      primaryTable.put(put);
  
      PowerMock.replayAll(mockIndex, primaryTable, databaseAdapter);
  
      c.put("foo", put);
      // c.createRecord(recordID, sourceID, fieldValues);
      EasyMock.verify(primaryTable);
    }
test_case.class_method_signature: ClientTest.testPut()
test_case.full_signature: @Test public void testPut()
test_case.identifier: testPut
test_case.invocations: createMock createPartialMock getBytes getBytes getBytes getBytes add hashCode equals createMock andReturn expect getIndices andReturn expect getColumnFamily getBytes andReturn expect getColumnQualifier getBytes handlePut anyObject createMock andReturn expect verify andReturn expectPrivate andReturn expect getTableAdapter put replayAll put verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPut()
focal_class.declarator: DATABASE_ADAPTER_CONF_KEY = "culvert.database.adapter"
focal_class.modifier: private static final
focal_class.original_string: private static final String DATABASE_ADAPTER_CONF_KEY = "culvert.database.adapter";
focal_class.type: String
focal_class.var_name: DATABASE_ADAPTER_CONF_KEY
focal_class.declarator: INDEXES_CONF_KEY = "culvert.indices.names"
focal_class.modifier: private static final
focal_class.original_string: private static final String INDEXES_CONF_KEY = "culvert.indices.names";
focal_class.type: String
focal_class.var_name: INDEXES_CONF_KEY
focal_class.declarator: DATABASE_ADAPTER_CONF_PREFIX = "culvert.database.conf"
focal_class.modifier: private static final
focal_class.original_string: private static final String DATABASE_ADAPTER_CONF_PREFIX = "culvert.database.conf";
focal_class.type: String
focal_class.var_name: DATABASE_ADAPTER_CONF_PREFIX
focal_class.declarator: configuration
focal_class.modifier: private final
focal_class.original_string: private final Configuration configuration;
focal_class.type: Configuration
focal_class.var_name: configuration
focal_class.file: culvert-main/src/main/java/com/bah/culvert/Client.java
focal_class.identifier: Client
focal_class.class_method_signature: Client.Client(Configuration conf)
focal_class.full_signature: public  Client(Configuration conf)
focal_class.identifier: Client
focal_class.modifiers: public
focal_class.parameters: (Configuration conf)
focal_class.signature:  Client(Configuration conf)
focal_class.class_method_signature: Client.put(String tableName, Put put)
focal_class.full_signature: public void put(String tableName, Put put)
focal_class.identifier: put
focal_class.modifiers: public
focal_class.parameters: (String tableName, Put put)
focal_class.return: void
focal_class.signature: void put(String tableName, Put put)
focal_class.class_method_signature: Client.getIndexMap()
focal_class.full_signature: public HashMap<String, Index> getIndexMap()
focal_class.identifier: getIndexMap
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: HashMap<String, Index>
focal_class.signature: HashMap<String, Index> getIndexMap()
focal_class.class_method_signature: Client.query(Constraint query)
focal_class.full_signature: public Iterator<Result> query(Constraint query)
focal_class.identifier: query
focal_class.modifiers: public
focal_class.parameters: (Constraint query)
focal_class.return: Iterator<Result>
focal_class.signature: Iterator<Result> query(Constraint query)
focal_class.class_method_signature: Client.indexClassConfKey(String indexName)
focal_class.full_signature: private static String indexClassConfKey(String indexName)
focal_class.identifier: indexClassConfKey
focal_class.modifiers: private static
focal_class.parameters: (String indexName)
focal_class.return: String
focal_class.signature: String indexClassConfKey(String indexName)
focal_class.class_method_signature: Client.indexConfPrefix(String indexName)
focal_class.full_signature: private static String indexConfPrefix(String indexName)
focal_class.identifier: indexConfPrefix
focal_class.modifiers: private static
focal_class.parameters: (String indexName)
focal_class.return: String
focal_class.signature: String indexConfPrefix(String indexName)
focal_class.class_method_signature: Client.getIndices()
focal_class.full_signature: public Index[] getIndices()
focal_class.identifier: getIndices
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Index[]
focal_class.signature: Index[] getIndices()
focal_class.class_method_signature: Client.getIndicesForTable(String tableName)
focal_class.full_signature: public Index[] getIndicesForTable(String tableName)
focal_class.identifier: getIndicesForTable
focal_class.modifiers: public
focal_class.parameters: (String tableName)
focal_class.return: Index[]
focal_class.signature: Index[] getIndicesForTable(String tableName)
focal_class.class_method_signature: Client.getIndexByName(String string)
focal_class.full_signature: public Index getIndexByName(String string)
focal_class.identifier: getIndexByName
focal_class.modifiers: public
focal_class.parameters: (String string)
focal_class.return: Index
focal_class.signature: Index getIndexByName(String string)
focal_class.class_method_signature: Client.getIndicesForColumn(String table, byte[] family,
        byte[] qualifier)
focal_class.full_signature: public Index[] getIndicesForColumn(String table, byte[] family,
        byte[] qualifier)
focal_class.identifier: getIndicesForColumn
focal_class.modifiers: public
focal_class.parameters: (String table, byte[] family,
        byte[] qualifier)
focal_class.return: Index[]
focal_class.signature: Index[] getIndicesForColumn(String table, byte[] family,
        byte[] qualifier)
focal_class.class_method_signature: Client.addIndex(Index index)
focal_class.full_signature: public void addIndex(Index index)
focal_class.identifier: addIndex
focal_class.modifiers: public
focal_class.parameters: (Index index)
focal_class.return: void
focal_class.signature: void addIndex(Index index)
focal_class.class_method_signature: Client.getConf()
focal_class.full_signature: public Configuration getConf()
focal_class.identifier: getConf
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Configuration
focal_class.signature: Configuration getConf()
focal_class.class_method_signature: Client.setDatabase(DatabaseAdapter db, Configuration conf)
focal_class.full_signature: public static void setDatabase(DatabaseAdapter db, Configuration conf)
focal_class.identifier: setDatabase
focal_class.modifiers: public static
focal_class.parameters: (DatabaseAdapter db, Configuration conf)
focal_class.return: void
focal_class.signature: void setDatabase(DatabaseAdapter db, Configuration conf)
focal_class.class_method_signature: Client.getDatabaseAdapter()
focal_class.full_signature: private DatabaseAdapter getDatabaseAdapter()
focal_class.identifier: getDatabaseAdapter
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: DatabaseAdapter
focal_class.signature: DatabaseAdapter getDatabaseAdapter()
focal_class.class_method_signature: Client.setDatabaseAdapter(Configuration conf,
        Class<? extends DatabaseAdapter> adapterClass)
focal_class.full_signature: public static void setDatabaseAdapter(Configuration conf,
        Class<? extends DatabaseAdapter> adapterClass)
focal_class.identifier: setDatabaseAdapter
focal_class.modifiers: public static
focal_class.parameters: (Configuration conf,
        Class<? extends DatabaseAdapter> adapterClass)
focal_class.return: void
focal_class.signature: void setDatabaseAdapter(Configuration conf,
        Class<? extends DatabaseAdapter> adapterClass)
focal_class.class_method_signature: Client.tableExists(String tableName)
focal_class.full_signature: public boolean tableExists(String tableName)
focal_class.identifier: tableExists
focal_class.modifiers: public
focal_class.parameters: (String tableName)
focal_class.return: boolean
focal_class.signature: boolean tableExists(String tableName)
focal_class.class_method_signature: Client.verify()
focal_class.full_signature: public boolean verify()
focal_class.identifier: verify
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean verify()
focal_method.body: public void put(String tableName, Put put) {
      // Get the KeyValue list
      Iterable<CKeyValue> keyValueList = put.getKeyValueList();
      List<CKeyValue> indexValues = new ArrayList<CKeyValue>();
      // for each index, add only the keyvalues that should be indexed
      for (Index index : getIndices()) {
        indexValues.clear();
        for (CKeyValue keyValue : keyValueList) {
          if (Bytes.compareTo(index.getColumnFamily(), keyValue.getFamily()) == 0) {
            if (Bytes.compareTo(index.getColumnQualifier(),
                keyValue.getQualifier()) == 0) {
              indexValues.add(keyValue);
            }
          }
        }
        index.handlePut(new Put(indexValues));
      }
      // TODO this is obviously not performant for every put
      // we should probably do some caching here
      DatabaseAdapter db = getDatabaseAdapter();
      if (!db.verify())
        throw new RuntimeException(
            "Could not connect to the database to make the put of the actual value. Index may be corrupt.");
      db.getTableAdapter(tableName).put(put);
    }
focal_method.class_method_signature: Client.put(String tableName, Put put)
focal_method.full_signature: public void put(String tableName, Put put)
focal_method.identifier: put
focal_method.invocations: getKeyValueList getIndices clear compareTo getColumnFamily getFamily compareTo getColumnQualifier getQualifier add handlePut getDatabaseAdapter verify put getTableAdapter
focal_method.modifiers: public
focal_method.parameters: (String tableName, Put put)
focal_method.return: void
focal_method.signature: void put(String tableName, Put put)